text
stringlengths
1
1.05M
// Copyright (c) 2016-2018 The Libra Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <bench/bench.h> #include <support/lockedpool.h> #include <iostream> #include <vector> #define ASIZE 2048 #define BITER 5000 #define MSIZE 2048 static void BenchLockedPool(benchmark::State& state) { void *synth_base = reinterpret_cast<void*>(0x08000000); const size_t synth_size = 1024*1024; Arena b(synth_base, synth_size, 16); std::vector<void*> addr; for (int x=0; x<ASIZE; ++x) addr.push_back(nullptr); uint32_t s = 0x12345678; while (state.KeepRunning()) { for (int x=0; x<BITER; ++x) { int idx = s & (addr.size()-1); if (s & 0x80000000) { b.free(addr[idx]); addr[idx] = nullptr; } else if(!addr[idx]) { addr[idx] = b.alloc((s >> 16) & (MSIZE-1)); } bool lsb = s & 1; s >>= 1; if (lsb) s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 } } for (void *ptr: addr) b.free(ptr); addr.clear(); } BENCHMARK(BenchLockedPool, 1300);
; A228719: Decimal expansion of 3*Pi/5. ; Submitted by Jon Maiga ; 1,8,8,4,9,5,5,5,9,2,1,5,3,8,7,5,9,4,3,0,7,7,5,8,6,0,2,9,9,6,7,7,0,1,7,3,0,5,1,8,3,0,1,6,3,9,6,2,5,0,6,3,4,9,2,5,8,4,9,6,6,7,5,5,3,8,4,6,8,9,8,4,3,7,7,1,7,2,5,3,9,9,1,7,6,8,2,0,8,9,5,2,0,5,2,7,0,2,4,0 add $0,1 mov $2,1 mov $3,$0 mul $3,5 lpb $3 mul $1,$3 mov $5,$3 mul $5,2 add $5,1 mul $2,$5 add $1,$2 div $1,$0 div $2,$0 sub $3,1 lpe mul $1,3 div $1,25 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r8 push %rcx push %rdi push %rsi lea addresses_normal_ht+0x16faa, %rsi lea addresses_WC_ht+0x302a, %rdi nop and %r8, %r8 mov $7, %rcx rep movsq nop nop nop nop nop inc %r14 lea addresses_normal_ht+0xcc6a, %r12 sub %rcx, %rcx mov (%r12), %edi inc %r8 pop %rsi pop %rdi pop %rcx pop %r8 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r9 push %rbx push %rdi // Faulty Load lea addresses_WC+0x1928a, %rbx nop nop nop nop sub %r11, %r11 mov (%rbx), %r14 lea oracles, %r12 and $0xff, %r14 shlq $12, %r14 mov (%r12,%r14,1), %r14 pop %rdi pop %rbx pop %r9 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'00': 6346} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
_LoreleiBeforeBattleText:: text "Welcome to" line "#MON LEAGUE!" para "I am LORELEI of" line "the ELITE FOUR!" para "No one can best" line "me when it comes" cont "to icy #MON!" para "Freezing moves" line "are powerful!" para "Your #MON will" line "be at my mercy" cont "when they are" cont "frozen solid!" para "Hahaha!" line "Are you ready?" done _LoreleiEndBattleText:: text "How" line "dare you!" prompt _LoreleiAfterBattleText:: text "You're better" line "than I thought!" cont "Go on ahead!" para "You only got a" line "taste of #MON" cont "LEAGUE power!" done _LoreleiDontRunAwayText:: text "Someone's voice:" line "Don't run away!" done
; A282023: Start with 1; multiply alternately by 4 and 3. ; 1,4,12,48,144,576,1728,6912,20736,82944,248832,995328,2985984,11943936,35831808,143327232,429981696,1719926784,5159780352,20639121408,61917364224,247669456896,743008370688,2972033482752,8916100448256,35664401793024,106993205379072,427972821516288,1283918464548864,5135673858195456,15407021574586368,61628086298345472,184884258895036416,739537035580145664,2218611106740436992,8874444426961747968,26623333280885243904,106493333123540975616,319479999370622926848,1277919997482491707392,3833759992447475122176,15335039969789900488704,46005119909369701466112,184020479637478805864448,552061438912436417593344,2208245755649745670373376,6624737266949237011120128,26498949067796948044480512,79496847203390844133441536,317987388813563376533766144,953962166440690129601298432,3815848665762760518405193728,11447545997288281555215581184,45790183989153126220862324736,137370551967459378662586974208,549482207869837514650347896832,1648446623609512543951043690496,6593786494438050175804174761984,19781359483314150527412524285952,79125437933256602109650097143808,237376313799769806328950291431424,949505255199079225315801165725696,2848515765597237675947403497177088,11394063062388950703789613988708352,34182189187166852111368841966125056,136728756748667408445475367864500224,410186270246002225336426103593500672 mov $1,8 lpb $0 sub $0,1 gcd $2,2 add $2,2 mul $1,$2 sub $2,3 lpe div $1,8 mov $0,$1
; Title 'TestFile' .APPTYPE GUI include "inc\winconst.inc" include 'inc\Kernel32.def' include 'inc\User32.def' .DATA ; Variables FileHandle DD 0 ;THandle BytesWritten DD 0 ;DWORD FileName db 'TestFile',0 ALIGN 4 Buffer db 'Win Asm Test',0 .CODE ; FileHandle := CreateFileA(FileName, , 0, 0, 0, 0); PUSH 0 PUSH 0 PUSH CREATE_ALWAYS PUSH 0 PUSH 0 PUSH GENERIC_READ + GENERIC_WRITE PUSH FileName ; Address CALL CreateFileA MOV [FileHandle], EAX ; WriteFile(FileHandle, Buffer,strlen(buffer), BytesWritten, 0); PUSH 0 PUSH BytesWritten push buffer call strlen push eax PUSH Buffer PUSH [FileHandle] CALL WriteFile ; CloseHandle(FileHandle); PUSH [FileHandle] CALL CloseHandle ; ExitProcess(0); PUSH 0 CALL ExitProcess include 'inc\strings.inc' include 'inc\file.inc' end
; Keep SASM (https://github.com/mras0/sasm) comptabile ; A lot like the x86 version, except LastCFA is kept in bx cpu 8086 org 0x100 NUM_CELLS EQU 4096 RSIZE EQU 128 F_HIDDEN EQU 0x80 F_IMMED EQU 0x40 F_LENMASK EQU 0x1f O_RDONLY EQU 0 STDIN_FILENO EQU -1 ; 0 STDOUT_FILENO EQU -2 ; 1 Main: cld mov word [OutputFile], STDOUT_FILENO ; ; Process command line ; mov si, 0x81 xor di, di .SkipSpace: lodsb cmp al, 13 je .NoFile cmp al, ' ' jbe .SkipSpace mov di, si dec di xor bx, bx .FindEnd: inc bx lodsb cmp al, 13 je .AtEnd jmp .FindEnd .AtEnd: mov byte [di+bx], 0 xor ax, ax call OpenFile mov [InputFile], ax call PutHexByte jmp .HasFile .NoFile: mov word [InputFile], STDIN_FILENO .HasFile: mov sp, Cells+NUM_CELLS*2 ; S0 mov bp, Cells+RSIZE*2 ; R0 mov si, .Start jmp Next .Start: dw Quit ; Filename in DI, mode in AX (ignored for now) OpenFile: mov dx, di mov ax, 0x3d00 int 0x21 jc .Err ret .Err: mov bx, .MsgErrOpen call PutZString mov bx, di call PutZString mov al, 10 call Emit mov ax, 0x4c02 int 0x21 .MsgErrOpen: db 'Error opening file: ', 0 CloseFile: mov bx, ax mov ax, 0x3e00 int 0x21 ret ReadFile: %if 1 cmp ax, STDIN_FILENO jne .Normal push cx push di and cx, cx jz .Done .L: xor ah, ah int 0x16 cmp al, 13 jne .S mov al, 10 ; CR -> LF .S: stosb call Emit ; Echo dec cx jnz .L .Done: pop di pop ax ret .Normal: %endif mov bx, ax mov ah, 0x3f mov dx, di int 0x21 jnc .OK xor ax, ax .OK: ret WriteFile: %if 1 cmp ax, STDOUT_FILENO jne .Normal push cx push bp and cx, cx jz .Done .L: mov al, [di] inc di push cx mov bx, 7 mov ah, 0x0e cmp al, 10 jne .Pr mov al, 13 int 0x10 mov bx, 7 mov ax, 0x0e0a .Pr: int 0x10 pop cx dec cx jnz .L .Done: pop bp pop ax ret .Normal: %endif mov bx, ax mov ah, 0x40 mov dx, di int 0x21 jnc .OK xor ax, ax .OK: ret Emit: push bx push cx push dx push di push ax mov ax, [OutputFile] mov di, sp mov cx, 1 call WriteFile pop ax pop di pop dx pop cx pop bx ret ReadKey: push bx push di sub sp, 2 mov di, sp mov cx, 1 mov ax, [InputFile] call ReadFile and ax, ax jz .Ret mov al, [di] cmp al, 'a' jb .Ret cmp al, 'z' ja .Ret and al, 0xdf .Ret: add sp, 2 pop di pop bx ret Next: lodsw mov bx, ax jmp [bx] PutZString: mov al, [bx] and al, al jz .Done call Emit inc bx jmp PutZString .Done: ret PutHexWord: push ax mov al, ah call PutHexByte pop ax PutHexByte: push ax shr al, 1 shr al, 1 shr al, 1 shr al, 1 call PutHexDigit pop ax PutHexDigit: and al, 0x0f add al, '0' cmp al, '9' jbe Emit add al, 7 jmp Emit ReadWord: .SkipSpaces: call ReadKey and al, al jz .DoRead cmp al, ' ' jbe .SkipSpaces cmp al, 0x5C ; '\' jne .DoRead .SkipToNL: call ReadKey and al, al jz .DoRead cmp al, 10 jne .SkipToNL jmp .SkipSpaces .DoRead: mov di, WordBuffer .ReadLoop: cmp al, ' ' jbe .ReadDone stosb call ReadKey jmp .ReadLoop .ReadDone: mov cx, di mov dx, WordBuffer sub cx, dx xor al, al stosb mov di, dx ret FindWord: mov bx, [Latest] .Search: and bx, bx jz .Done mov al, [bx+2] and al, F_LENMASK|F_HIDDEN cmp al, cl jne .Next push cx push si push di mov si, bx add si, 3 repe cmpsb pop di pop si pop cx je .Done .Next: mov bx, [bx] jmp .Search .Done: ret WordCFA: xor ah, ah mov al, [bx+2] and al, F_LENMASK add al, 3 add bx, ax ret ConvertNumber: push si mov si, [Base] xor ax, ax and cx, cx jz .Err xor bh, bh mov bl, [di] push bx cmp bl, '-' jne .Cvt dec cx jz .Err inc di .Cvt: mov bl, [di] sub bl, '0' jb .Err cmp bl, 9 jbe .Add sub bl, 'A'-'0'-10 .Add: cmp bx, si jae .Err mul si add ax, bx inc di dec cx jnz .Cvt pop bx cmp bl, '-' jne .P neg ax .P: pop si ret .Err: InvalidWord: mov bx, .MsgInvalid call PutZString mov bx, WordBuffer call PutZString mov bx, .MsgInvalid2 call PutZString call PrintWords mov ax, 0x4c01 int 0x21 .MsgInvalid: db 13, 10, 'Invalid word: "', 0 .MsgInvalid2: db '"', 13, 10, 0 PrintWords: mov di, [Latest] mov dx, 10 ; Limit count .Loop: and di, di jnz .NotDone ret .NotDone: mov ax, di call PutHexWord mov al, ' ' call Emit xor cx, cx mov cl, [di+2] mov al, cl call PutHexByte mov al, ' ' call Emit and cl, F_LENMASK push di add di, 3 .L: and cl, cl jz .N mov al, [di] inc di call Emit dec cl jmp .L .N: pop di mov al, 10 call Emit mov di, [di] dec dx jnz .Loop DoComma: mov di, [Here] stosw mov [Here], di ret W_EMIT: dw 0 db 4, 'EMIT' DoEmit: dw $+2 pop ax call Emit jmp Next W_KEY: dw W_EMIT db 3, 'KEY' DoKey: dw $+2 call ReadKey xor ah, ah push ax jmp Next W_EXIT: dw W_KEY db 4, 'EXIT' Exit: dw $+2 mov si, [bp] add bp, 2 jmp Next W_BRANCH: dw W_EXIT db 6, 'BRANCH' Branch: dw $+2 add si, [si] jmp Next W_ZBRANCH: dw W_BRANCH db 7, '0BRANCH' ZBranch: dw $+2 pop ax test ax, ax jz Branch+2 lodsw jmp Next W_EXECUTE: dw W_ZBRANCH db 7, 'EXECUTE' Execute: dw $+2 pop bx jmp [bx] W_LIT: dw W_EXECUTE db 3, 'LIT' Lit: dw $+2 lodsw push ax jmp Next W_LITSTRING: dw W_LIT db 9, 'LITSTRING' LitString: dw $+2 lodsw push si push ax add si, ax jmp Next W_CHAR: dw W_LITSTRING db 4, 'CHAR' GetChar: dw $+2 call ReadWord xor ax, ax mov al, [di] push ax jmp Next W_COMMA: dw W_CHAR db 1, ',' Comma: dw $+2 pop ax call DoComma jmp Next W_OPENFILE: dw W_COMMA db 9, 'OPEN-FILE' DoOpenFile: dw $+2 pop ax pop di call OpenFile push ax jmp Next W_CLOSEFILE: dw W_OPENFILE db 10, 'CLOSE-FILE' DoCloseFile: dw $+2 pop ax call CloseFile jmp Next W_READFILE: dw W_CLOSEFILE db 9, 'READ-FILE' DoReadFile: dw $+2 pop ax pop cx pop di call ReadFile push ax jmp Next W_WRITEFILE: dw W_READFILE db 10, 'WRITE-FILE' DoWriteFile: dw $+2 pop ax pop cx pop di call WriteFile push ax jmp Next W_WORD: dw W_WRITEFILE db 4, 'WORD' GetWord: dw $+2 call ReadWord push di push cx jmp Next W_CREATE: dw W_WORD db 6, 'CREATE' Create: dw $+2 pop cx pop bx mov di, [Here] mov ax, [Latest] mov [Latest], di stosw mov al, cl stosb push si mov si, bx rep movsb pop si mov [Here], di jmp Next W_FIND: dw W_CREATE db 4, 'FIND' Find: dw $+2 pop cx pop di call FindWord push bx jmp Next W_CFA: dw W_FIND db 4, '>CFA' Cfa: dw $+2 pop bx call WordCFA push bx jmp Next W_HIDDEN: dw W_CFA db 6, 'HIDDEN' Hidden: dw $+2 pop bx xor byte [bx+2], F_HIDDEN jmp Next W_IMMEDIATE: dw W_HIDDEN db 9|F_IMMED, 'IMMEDIATE' Immediate: dw $+2 mov bx, [Latest] xor byte [bx+2], F_IMMED jmp Next W_LBRACKET: dw W_IMMEDIATE db 1|F_IMMED, '[' LBracket: dw $+2 mov byte [State], 0 jmp Next W_RBRACKET: dw W_LBRACKET db 1, ']' RBracket: dw $+2 mov byte [State], 1 jmp Next W_TICK: dw W_RBRACKET db 1, 0x27 ; ' Tick: dw $+2 lodsw push ax jmp Next W_FETCH: dw W_TICK db 1, '@' Fetch: dw $+2 pop bx push word [bx] jmp Next W_STORE: dw W_FETCH db 1, '!' Store: dw $+2 pop di pop ax stosw jmp Next W_CFETCH: dw W_STORE db 2, 'C@' CFetch: dw $+2 pop bx xor ah, ah mov al, [bx] push ax jmp Next W_CSTORE: dw W_CFETCH db 2, 'C!' CStore: dw $+2 pop di pop ax stosb jmp Next W_DSPFETCH: dw W_CSTORE db 4, 'DSP@' DspFetch: dw $+2 mov ax, sp push ax jmp Next W_DSPSTORE: dw W_DSPFETCH db 4, 'DSP!' DspStore: dw $+2 pop ax mov sp, ax jmp Next W_RSPFETCH: dw W_DSPSTORE db 4, 'RSP@' RspFetch: dw $+2 push bp jmp Next W_RSPSTORE: dw W_RSPFETCH db 4, 'RSP!' RspStore: dw $+2 pop bp jmp Next W_TOR: dw W_RSPSTORE db 2, '>R' ToR: dw $+2 sub bp, 2 pop word [bp] jmp Next W_FROMR: dw W_TOR db 2, 'R>' FromR: dw $+2 push word [bp] add bp, 2 jmp Next W_SWAP: dw W_FROMR db 4, 'SWAP' Swap: dw $+2 pop ax pop bx push ax push bx jmp Next W_ROT: dw W_SWAP db 3, 'ROT' Rot: dw $+2 pop cx pop bx pop ax push bx push cx push ax jmp Next W_ADD: dw W_ROT db 1, '+' Add: dw $+2 pop bx pop ax add ax, bx push ax jmp Next W_SUB: dw W_ADD db 1, '-' Sub: dw $+2 pop bx pop ax sub ax, bx push ax jmp Next W_MUL: dw W_SUB db 1, '*' Mul: dw $+2 pop bx pop ax mul bx push ax jmp Next W_DIVMOD: dw W_MUL db 4, '/MOD' DivMod: dw $+2 pop bx pop ax cwd idiv bx push dx push ax jmp Next W_UDIVMOD: dw W_DIVMOD db 5, 'U/MOD' UDivMod: dw $+2 pop bx pop ax xor dx, dx div bx push dx push ax jmp Next W_AND: dw W_UDIVMOD db 3, 'AND' BAnd: dw $+2 pop bx pop ax and ax, bx push ax jmp Next W_OR: dw W_AND db 2, 'OR' BOr: dw $+2 pop bx pop ax or ax, bx push ax jmp Next W_XOR: dw W_OR db 3, 'XOR' BXor: dw $+2 pop bx pop ax xor ax, bx push ax jmp Next W_INVERT: dw W_XOR db 6, 'INVERT' Invert: dw $+2 mov bx, sp not word [bx] jmp Next W_ALIGNED: dw W_INVERT db 7, 'ALIGNED' Aligned: dw $+2 jmp Next W_EQ: dw W_ALIGNED db 1, '=' Eq: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx jne .P not cx .P: push cx jmp Next W_NE: dw W_EQ db 2, '<>' Ne: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx je .P not cx .P: push cx jmp Next W_LT: dw W_NE db 1, '<' Lt: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx jnl .P not cx .P: push cx jmp Next W_LE: dw W_LT db 2, '<=' Le: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx jg .P not cx .P: push cx jmp Next W_GE: dw W_LE db 2, '>=' Ge: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx jl .P not cx .P: push cx jmp Next W_GT: dw W_GE db 1, '>' Gt: dw $+2 pop bx pop ax xor cx, cx cmp ax, bx jng .P not cx .P: push cx jmp Next W_INTERPRET: dw W_GT db 9, 'INTERPRET' Interpret: dw $+2 .Loop: call ReadWord and cx, cx jnz .NotDone mov ax, 0x4c00 int 0x21 .NotDone: %if 0 mov al, [State] call PutHexByte mov al, ' ' call Emit mov bx, di call PutZString mov al, 10 call Emit %endif push cx push di call FindWord pop di pop cx and bx, bx jz .Number test byte [bx+2], F_IMMED pushf call WordCFA popf jnz .ExecuteWord cmp byte [State], 0 jz .ExecuteWord mov ax, bx and ax, ax jnz .CompileWord jmp InvalidWord .CompileWord: call DoComma jmp .Loop .ExecuteWord: jmp [bx] .Number: call ConvertNumber push ax cmp byte [State], 0 jz .Loop mov ax, Lit call DoComma pop ax call DoComma jmp .Loop DoCol: sub bp, 2 mov [bp], si mov si, bx add si, 2 jmp Next W_QUIT: dw W_INTERPRET db 4, 'QUIT' Quit: dw DoCol dw Lit, Cells+RSIZE*2, RspStore dw Interpret dw Branch, -4 W_COLON: dw W_QUIT db 1, ':' Colon: dw DoCol dw GetWord, Create dw Lit, DoCol, Comma dw Lit, Latest, Fetch, Hidden dw RBracket dw Exit W_SEMICOLON: dw W_COLON db 1|F_IMMED, ';' SemiColon: dw DoCol dw Lit, Exit, Comma dw Lit, Latest, Fetch, Hidden dw LBracket dw Exit W_LATEST: dw W_SEMICOLON db 6, 'LATEST' GetLatest: dw $+2 mov ax, Latest push ax jmp Next W_HERE: dw W_LATEST db 4, 'HERE' GetHere: dw $+2 mov ax, Here push ax jmp Next W_STATE: dw W_HERE db 5, 'STATE' GetState: dw $+2 mov ax, State push ax jmp Next W_BASE: dw W_STATE db 4, 'BASE' GetBase: dw $+2 mov ax, Base push ax jmp Next W_CELLSIZE: dw W_BASE db 9, 'CELL-SIZE' GetCellSize: dw $+2 mov ax, 2 push ax jmp Next W_DOCOL: dw W_CELLSIZE db 5, 'DOCOL' DOCOL: dw $+2 mov ax, DoCol push ax jmp Next W_S0: dw W_DOCOL db 2, 'S0' GetS0: dw $+2 mov ax, Cells+NUM_CELLS*2 ; S0 push ax jmp Next W_R0: dw W_S0 db 2, 'R0' GetR0: dw $+2 mov ax, Cells+RSIZE*2 ; R0 push ax jmp Next W_F_HIDDEN: dw W_R0 db 8, 'F_HIDDEN' GetFHidden: dw $+2 mov ax, F_HIDDEN push ax jmp Next W_F_IMMED: dw W_F_HIDDEN db 7, 'F_IMMED' GetFImmed: dw $+2 mov ax, F_IMMED push ax jmp Next W_F_LENMASK: dw W_F_IMMED db 9, 'F_LENMASK' GetFLenmask: dw $+2 mov ax, F_LENMASK push ax jmp Next W_O_RDONLY: dw W_F_LENMASK db 8, 'O_RDONLY' GetORdOnly: dw $+2 mov ax, O_RDONLY push ax jmp Next W_STDIN: dw W_O_RDONLY db 5, 'STDIN' GetStdin: dw $+2 mov ax, STDIN_FILENO push ax jmp Next W_STDOUT: dw W_STDIN db 6, 'STDOUT' GetStdout: dw $+2 mov ax, STDOUT_FILENO push ax jmp Next W_DSP: dw W_STDOUT db 3, 'DSP' GetDsp: dw $+2 mov ax, 0 push ax jmp Next Latest: dw W_DSP State: dw 0 Here: dw Cells+RSIZE*2 ; R0 Base: dw 10 InputFile: resw 1 OutputFile: resw 1 Cells: resw NUM_CELLS WordBuffer: resb F_LENMASK+1
; A048722: Reversed binary packing of Fibonacci sequence A000045. ; Submitted by Christian Krause ; 0,1,3,7,29,233,7457,1908993,15638470657,32796250015268865,563435284988077103288156161,20299895516157546089301785397257605216206849,12565026726380593749379544715414757684521993402717913413208480665305089 mov $3,2 mov $4,1 lpb $0 sub $0,1 mul $1,$4 add $1,1 mul $4,$3 add $2,$4 mov $4,$3 mov $3,$2 mod $2,2 lpe mov $0,$1
; A180357: a(n) = n^7 + 7*n. ; 0,8,142,2208,16412,78160,279978,823592,2097208,4783032,10000070,19487248,35831892,62748608,105413602,170859480,268435568,410338792,612220158,893871872,1280000140,1801088688,2494358042 mov $1,7 mul $1,$0 mov $2,$0 pow $2,7 add $1,$2
#include "tgbot/net/BoostHttpOnlySslClient.h" #include "tgbot/Bot.h" #include "tgbot/EventBroadcaster.h" #include <memory> #include <string> namespace TgBot { Bot::Bot(std::string token, const HttpClient& httpClient, const std::string& url) : _token(std::move(token)) , _api(_token, httpClient, url) , _eventBroadcaster(std::make_unique<EventBroadcaster>()) , _eventHandler(getEvents()) { } HttpClient& Bot::_getDefaultHttpClient() { static BoostHttpOnlySslClient instance; return instance; } }
;; nasm part1.asm -f elf64 && ld -o part1 part1.o section .data births: times 100 dd 0 count: dd 0 buf: dd 0 section .text global _start _start: call readinput xor rcx, rcx init: movsxd rax, [births+4*rcx] mov [births+4*(rcx+7)], eax inc rcx cmp rcx, 80 jne init xor rcx, rcx outer: movsxd rax, [births+4*rcx] add [count], rax test rax, rax jz out mov rbx, rcx add rbx, 9 inner: cmp rbx, 80 jge out add [births+4*rbx], eax add rbx, 7 jmp inner out: inc rcx cmp rcx, 80 jne outer mov rax, count call print mov dword [buf], 0xa call write xor rdi, rdi mov rax, 0x3c syscall readinput: xor rdi, rdi lea rsi, buf mov rdx, 0x1 read: xor rax, rax syscall mov rax, [buf] cmp rax, 0xa je eof cmp rax, 0x2c je read inc dword [births+4*(rax-0x30)] inc dword [count] jmp read eof: ret print: movsxd rbx, [rax] mov rax, rbx test rax, rax jnz digits mov dword [buf], 0x30 call write ret digits: mov rbx, 0x3b9aca00 loop0: xor rdx, rdx div rbx mov r8, rax mov r9, rdx mov rax, rbx xor rdx, rdx mov rbx, 10 div rbx mov rbx, rax mov rax, r9 test r8, r8 jz loop0 loop1: mov [buf], r8 add dword [buf], 0x30 call write test rbx, rbx jz end xor rdx, rdx mov rax, r9 div rbx mov r8, rax mov r9, rdx mov rax, rbx xor rdx, rdx mov rbx, 10 div rbx mov rbx, rax mov rax, r9 jmp loop1 end: ret write: mov rdi, 0x1 lea rsi, [buf] mov rdx, 0x1 mov rax, 0x1 syscall ret
; ; ANSI Video handling for the Robotron Z1013 ; ; Text Attributes ; m - Set Graphic Rendition ; ; The most difficult thing to port: ; Be careful here... ; ; Stefano Bodrato - Aug 2016 ; ; ; $Id: f_ansi_attr.asm,v 1.1 2016/08/05 07:04:10 stefano Exp $ ; SECTION code_clib PUBLIC ansi_attr PUBLIC z1013_inverse .ansi_attr ret SECTION bss_clib .z1013_inverse defb 0
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text p224r1_data: _prime224r1: .long 0x1, 0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF .p2align 5, 0x90 _h9_add_224: movl (%esi), %eax addl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax adcl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax adcl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax adcl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax adcl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax adcl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax adcl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .p2align 5, 0x90 _h9_sub_224: movl (%esi), %eax subl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax sbbl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax sbbl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax sbbl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax sbbl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax sbbl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax sbbl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .p2align 5, 0x90 _h9_shl_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm1 movl (24)(%esi), %eax psrldq $(4), %xmm1 movdqa %xmm0, %xmm2 psllq $(1), %xmm0 psrlq $(63), %xmm2 movdqa %xmm1, %xmm3 psllq $(1), %xmm1 psrlq $(63), %xmm3 palignr $(8), %xmm2, %xmm3 pslldq $(8), %xmm2 por %xmm3, %xmm1 por %xmm2, %xmm0 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) shr $(31), %eax ret .p2align 5, 0x90 _h9_shr_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm2 movd %eax, %xmm1 palignr $(4), %xmm2, %xmm1 movdqa %xmm0, %xmm2 psrlq $(1), %xmm0 psllq $(63), %xmm2 movdqa %xmm1, %xmm3 psrlq $(1), %xmm1 psllq $(63), %xmm3 movdqa %xmm3, %xmm4 palignr $(8), %xmm2, %xmm3 psrldq $(8), %xmm4 por %xmm3, %xmm0 por %xmm4, %xmm1 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) ret .p2align 5, 0x90 .globl _h9_p224r1_add _h9_p224r1_add: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call _h9_add_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi call .L__0000gas_5 .L__0000gas_5: pop %ebx sub $(.L__0000gas_5-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_sub_224 lea (%esp), %esi movl (8)(%ebp), %edi sub %eax, %edx cmovne %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_sub _h9_p224r1_sub: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call _h9_sub_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi call .L__0001gas_6 .L__0001gas_6: pop %ebx sub $(.L__0001gas_6-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_neg _h9_p224r1_neg: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi mov $(0), %eax subl (%esi), %eax movl %eax, (%edi) mov $(0), %eax sbbl (4)(%esi), %eax movl %eax, (4)(%edi) mov $(0), %eax sbbl (8)(%esi), %eax movl %eax, (8)(%edi) mov $(0), %eax sbbl (12)(%esi), %eax movl %eax, (12)(%edi) mov $(0), %eax sbbl (16)(%esi), %eax movl %eax, (16)(%edi) mov $(0), %eax sbbl (20)(%esi), %eax movl %eax, (20)(%edi) mov $(0), %eax sbbl (24)(%esi), %eax movl %eax, (24)(%edi) sbb %edx, %edx lea (%esp), %edi movl (8)(%ebp), %esi call .L__0002gas_7 .L__0002gas_7: pop %ebx sub $(.L__0002gas_7-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_mul_by_2 _h9_p224r1_mul_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call _h9_shl_224 mov %eax, %edx mov %edi, %esi movl (8)(%ebp), %edi call .L__0003gas_8 .L__0003gas_8: pop %ebx sub $(.L__0003gas_8-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_mul_by_3 _h9_p224r1_mul_by_3: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(64), %esp and $(-16), %esp movl %eax, (60)(%esp) call .L__0004gas_9 .L__0004gas_9: pop %eax sub $(.L__0004gas_9-p224r1_data), %eax lea ((_prime224r1-p224r1_data))(%eax), %eax movl %eax, (56)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call _h9_shl_224 mov %eax, %edx mov %edi, %esi lea (28)(%esp), %edi mov (56)(%esp), %ebx call _h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov %edi, %esi movl (12)(%ebp), %ebx call _h9_add_224 mov %eax, %edx movl (8)(%ebp), %edi mov (56)(%esp), %ebx call _h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (60)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_div_by_2 _h9_p224r1_div_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call .L__0005gas_10 .L__0005gas_10: pop %ebx sub $(.L__0005gas_10-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_add_224 mov $(0), %edx movl (%esi), %ecx and $(1), %ecx cmovne %edi, %esi cmove %edx, %eax movl (8)(%ebp), %edi call _h9_shr_224 mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_mul_mont_slm _h9_p224r1_mul_mont_slm: push %ebp mov %esp, %ebp push %ebx push %esi push %edi push %ebp mov %esp, %eax sub $(48), %esp and $(-16), %esp movl %eax, (44)(%esp) pxor %mm0, %mm0 movq %mm0, (%esp) movq %mm0, (8)(%esp) movq %mm0, (16)(%esp) movq %mm0, (24)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebp movl %edi, (32)(%esp) movl %esi, (36)(%esp) movl %ebp, (40)(%esp) mov $(7), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 .p2align 5, 0x90 .Lmmul_loopgas_11: movd %edi, %mm7 movl (%ebp), %edx movl (%esi), %eax movd %edx, %mm0 add $(4), %ebp movl %ebp, (40)(%esp) pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 mul %edx addl (%esp), %eax adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (4)(%esp), %ecx movd (20)(%esi), %mm1 adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (8)(%esp), %ebx movd (24)(%esi), %mm2 adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (12)(%esp), %ebp adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (16)(%esp), %edi adc $(0), %edx neg %eax adc $(0), %ecx movl %ecx, (%esp) adc $(0), %ebx movl %ebx, (4)(%esp) mov %eax, %ecx sbb $(0), %eax sub %eax, %ebp movl %ebp, (8)(%esp) mov %ecx, %eax mov $(0), %ebp sbb $(0), %edi movl %edi, (12)(%esp) adc $(0), %ebp movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (20)(%esp), %ecx adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (24)(%esp), %ebx adc $(0), %edx sub %ebp, %ecx movl %ecx, (16)(%esp) sbb $(0), %ebx movl %ebx, (20)(%esp) movd %mm7, %edi sbb $(0), %eax mov $(0), %ebx addl (28)(%esp), %edx adc $(0), %ebx add %eax, %edx movl %edx, (24)(%esp) adc $(0), %ebx movl %ebx, (28)(%esp) sub $(1), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 jz .Lexit_mmul_loopgas_11 movl (40)(%esp), %ebp jmp .Lmmul_loopgas_11 .Lexit_mmul_loopgas_11: emms mov (32)(%esp), %edi lea (%esp), %esi call .L__0006gas_11 .L__0006gas_11: pop %ebx sub $(.L__0006gas_11-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_sub_224 movl (28)(%esp), %edx sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (44)(%esp), %esp pop %ebp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_sqr_mont_slm _h9_p224r1_sqr_mont_slm: push %ebp mov %esp, %ebp push %esi push %edi movl (12)(%ebp), %esi movl (8)(%ebp), %edi push %esi push %esi push %edi call _h9_p224r1_mul_mont_slm add $(12), %esp pop %edi pop %esi pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_mred _h9_p224r1_mred: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %esi mov $(7), %ecx xor %edx, %edx .p2align 5, 0x90 .Lmred_loopgas_13: movl (%esi), %eax neg %eax mov $(0), %ebx movl %ebx, (%esi) movl (4)(%esi), %ebx adc $(0), %ebx movl %ebx, (4)(%esi) movl (8)(%esi), %ebx adc $(0), %ebx movl %ebx, (8)(%esi) push %eax movl (12)(%esi), %ebx sbb $(0), %eax sub %eax, %ebx movl %ebx, (12)(%esi) pop %eax movl (16)(%esi), %ebx sbb $(0), %ebx movl %ebx, (16)(%esi) movl (20)(%esi), %ebx sbb $(0), %ebx movl %ebx, (20)(%esi) movl (24)(%esi), %ebx sbb $(0), %ebx movl %ebx, (24)(%esi) movl (28)(%esi), %ebx sbb $(0), %eax add %edx, %eax mov $(0), %edx adc $(0), %edx add %eax, %ebx movl %ebx, (28)(%esi) adc $(0), %edx lea (4)(%esi), %esi sub $(1), %ecx jnz .Lmred_loopgas_13 movl (8)(%ebp), %edi call .L__0007gas_13 .L__0007gas_13: pop %ebx sub $(.L__0007gas_13-p224r1_data), %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call _h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_p224r1_select_pp_w5 _h9_p224r1_select_pp_w5: push %ebp mov %esp, %ebp push %esi push %edi pxor %xmm0, %xmm0 movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %eax movd %eax, %xmm7 pshufd $(0), %xmm7, %xmm7 mov $(1), %edx movd %edx, %xmm6 pshufd $(0), %xmm6, %xmm6 movdqa %xmm0, (%edi) movdqa %xmm0, (16)(%edi) movdqa %xmm0, (32)(%edi) movdqa %xmm0, (48)(%edi) movdqa %xmm0, (64)(%edi) pxor %xmm3, %xmm3 movdqa %xmm6, %xmm5 mov $(16), %ecx .p2align 5, 0x90 .Lselect_loopgas_14: movdqa %xmm5, %xmm4 pcmpeqd %xmm7, %xmm4 movdqu (%esi), %xmm0 pand %xmm4, %xmm0 por (%edi), %xmm0 movdqa %xmm0, (%edi) movdqu (16)(%esi), %xmm1 pand %xmm4, %xmm1 por (16)(%edi), %xmm1 movdqa %xmm1, (16)(%edi) movdqu (32)(%esi), %xmm0 pand %xmm4, %xmm0 por (32)(%edi), %xmm0 movdqa %xmm0, (32)(%edi) movdqu (48)(%esi), %xmm1 pand %xmm4, %xmm1 por (48)(%edi), %xmm1 movdqa %xmm1, (48)(%edi) movdqu (64)(%esi), %xmm0 pand %xmm4, %xmm0 por (64)(%edi), %xmm0 movdqa %xmm0, (64)(%edi) movd (80)(%esi), %xmm1 pand %xmm4, %xmm1 por %xmm1, %xmm3 paddd %xmm6, %xmm5 add $(84), %esi sub $(1), %ecx jnz .Lselect_loopgas_14 movd %xmm3, (80)(%edi) pop %edi pop %esi pop %ebp ret
; A190181: Decimal expansion of (15+sqrt(465))/12. ; Submitted by Jon Maiga ; 3,0,4,6,9,8,8,2,2,1,0,7,0,6,5,2,0,5,6,2,2,7,8,2,8,4,8,3,2,5,0,0,9,8,7,2,9,8,0,7,0,8,8,3,6,0,9,7,5,6,5,8,1,6,9,6,1,0,9,4,1,7,1,0,4,7,6,3,1,1,1,7,8,1,0,5,7,1,6,9,9,8,9,2,9,5,0,4,3,6,8,7,8,2,3,8,3,4,1,4 mov $3,$0 mul $3,4 lpb $3 add $5,$2 add $5,$2 add $1,$5 mov $2,$5 sub $2,1 add $2,$1 mul $2,3 add $2,$1 mul $2,3 sub $3,2 lpe mov $1,3 add $1,$5 cmp $6,0 add $2,$6 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r8 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x18d8b, %rsi lea addresses_A_ht+0x1258b, %rdi nop nop sub %r13, %r13 mov $95, %rcx rep movsw nop add %r9, %r9 lea addresses_A_ht+0x17c3d, %r9 nop nop nop nop add %rdx, %rdx movw $0x6162, (%r9) nop cmp %rsi, %rsi lea addresses_UC_ht+0x1830b, %r13 nop nop nop xor $1261, %r8 movw $0x6162, (%r13) nop add %r13, %r13 lea addresses_WC_ht+0x167ab, %rsi lea addresses_A_ht+0x1008d, %rdi nop nop nop nop cmp $9898, %rax mov $35, %rcx rep movsw nop nop sub $15640, %rdi lea addresses_normal_ht+0xbd8b, %r9 nop nop nop nop nop add $23158, %r8 and $0xffffffffffffffc0, %r9 movaps (%r9), %xmm5 vpextrq $0, %xmm5, %r13 nop nop inc %r8 lea addresses_WC_ht+0x1780b, %rsi nop nop nop nop and %r13, %r13 mov (%rsi), %edx nop nop cmp %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r13 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %r9 push %rbp push %rcx push %rdx // Store lea addresses_D+0x148cb, %rcx nop nop cmp %r13, %r13 mov $0x5152535455565758, %rdx movq %rdx, (%rcx) nop add %rdx, %rdx // Store lea addresses_WT+0x2bc3, %r12 and %rbp, %rbp movw $0x5152, (%r12) nop nop add %r13, %r13 // Store mov $0x13c4d90000000c4b, %r9 nop nop nop nop and %rbp, %rbp movw $0x5152, (%r9) nop nop xor %r8, %r8 // Faulty Load lea addresses_US+0x958b, %r13 nop nop sub %rbp, %rbp movaps (%r13), %xmm5 vpextrq $0, %xmm5, %r12 lea oracles, %r9 and $0xff, %r12 shlq $12, %r12 mov (%r9,%r12,1), %r12 pop %rdx pop %rcx pop %rbp pop %r9 pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6}} {'00': 5248} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; WriteMm5.Asm ; ; Abstract: ; ; AsmWriteMm5 function ; ; Notes: ; ;------------------------------------------------------------------------------ DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; AsmWriteMm5 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmWriteMm5) ASM_PFX(AsmWriteMm5): ; ; 64-bit MASM doesn't support MMX instructions, so use opcode here ; DB 0x48, 0xf, 0x6e, 0xe9 ret
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld c, 41 ld b, 03 ld d, 03 lbegin_waitm3: ldff a, (c) and a, d cmp a, b jrnz lbegin_waitm3 ld a, 20 ldff(c), a ld a, 02 ldff(ff), a ei xor a, a ldff(68), a ld c, 69 lbegin_clearbgp0: xor a, a ldff(c), a ldff a, (c) or a, a jrnz lbegin_clearbgp0 inc a ld a, 05 ldff(43), a xor a, a inc a .text@1000 lstatint: nop .text@1036 ldff(c), a ldff a, (c) and a, 07 jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
SECTION code_fp_math32 PUBLIC _log2 EXTERN cm32_sdcc_log2 defc _log2 = cm32_sdcc_log2
; =============================================================== ; May 2017 ; =============================================================== ; ; uchar tshc_aaddr2cy(void *aaddr) ; ; Character y coordinate corresponding to attribute address. ; ; =============================================================== SECTION code_clib SECTION code_arch PUBLIC asm_tshc_aaddr2cy EXTERN asm_zx_saddr2cy defc asm_tshc_aaddr2cy = asm_zx_saddr2cy
; A318937: a(n) = 16 times the sum of the cubes of the divisors of 2*n+1. ; 16,448,2016,5504,12112,21312,35168,56448,78624,109760,154112,194688,252016,327040,390240,476672,596736,693504,810464,984704,1102752,1272128,1526112,1661184,1887888,2201472,2382048,2685312,3073280,3286080,3631712,4166528,4431168,4812224,5451264,5726592,6224288,7056448,7331328,7888640,8830096,9148608,9906624,10926720,11279520,12097792,13346816,13829760,14602784,16133184,16484832,17483648,19418112,19600704,20720480,22692992,23086368,24530688,26622176,27046656,28366288,30877056,31502016,32774144 mul $0,2 add $0,1 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 pow $3,3 add $1,$3 lpe mul $1,16 add $1,16 mov $0,$1
//c++ includes #include <assert.h> #include <iostream> //slicer includes #include "slicer.hpp" //SIGMA includes #include "moab/Core.hpp" #include "moab/Interface.hpp" //test driver includes #include "testutils.hpp" using namespace moab; void group_slicing_test(); //structure functions void line_struct_test(); //test functions void create_surface_intersections_test(); void intersection_test(); void triangle_plane_intersect_test(); void get_intersection_test(); void get_sets_by_category_test(); void get_surfaces_test(); void get_all_volumes_test(); void test_point_match(); void get_volume_intersections_test(); void stitch_test(); void get_containment_test(); void is_poly_a_in_poly_b_test(); void get_fill_windings_test(); void find_winding_test(); void set_windings_test(); int main(int /* argc */, char** /* argv */) { // setup moab::ErrorCode result = mbi()->load_mesh("cube.h5m"); MB_CHK_SET_ERR(result, "Could not load test file"); // testing int failed_tests = 0; failed_tests += RUN_TEST(line_struct_test); failed_tests += RUN_TEST(get_sets_by_category_test); failed_tests += RUN_TEST(get_surfaces_test); failed_tests += RUN_TEST(get_all_volumes_test); failed_tests += RUN_TEST(test_point_match); failed_tests += RUN_TEST(create_surface_intersections_test); failed_tests += RUN_TEST(get_intersection_test); failed_tests += RUN_TEST(triangle_plane_intersect_test); failed_tests += RUN_TEST(get_volume_intersections_test); failed_tests += RUN_TEST(stitch_test); failed_tests += RUN_TEST(get_containment_test); failed_tests += RUN_TEST(is_poly_a_in_poly_b_test); failed_tests += RUN_TEST(get_fill_windings_test); failed_tests += RUN_TEST(find_winding_test); failed_tests += RUN_TEST(set_windings_test); failed_tests += RUN_TEST(group_slicing_test); // tear down result = mbi()->delete_mesh(); MB_CHK_SET_ERR(result, "Failed to delete mesh entities in MOAB instance"); return failed_tests; } void group_slicing_test() { std::cout << "Running gst" << std::cout; std::vector< std::vector<xypnt> > paths; std::vector< std::vector<int> > codes; std::vector<std::string> grp_names; std::vector<int> grp_ids; moab::ErrorCode result = slice_faceted_model("teapot_grps_zip.h5m", 1, 0.0, paths, codes, grp_names, grp_ids, true); MB_CHK_SET_ERR_CONT(result, "Failed to slice the provided facet model"); //there should only be one path for this slice assert(1 == paths.size()); //the group names, ids, and number of paths should match assert(grp_names.size() == paths.size() && grp_names.size() == grp_ids.size() && grp_names.size() == codes.size()); } void line_struct_test() { Line test_line; moab::CartVect point(0,1,0); // check initialization of values CHECK( !test_line.started ); CHECK( !test_line.full ); // now add a point to the line test_line.add_pnt(point); // the line has one point now // but is not full CHECK( test_line.started ); CHECK( !test_line.full ); // add another point test_line.add_pnt(point); // the line has now been started // but is not full CHECK( test_line.started ); CHECK( test_line.full ); // added the same point to the line twice // make sure this is the case CHECK( test_line.begin == test_line.end ); } void create_surface_intersections_test() { moab::Range surfs; get_all_surfaces(surfs); std::map<moab::EntityHandle, std::vector<Loop> >int_map; moab::ErrorCode result = create_surface_intersections(surfs, 0, 0, int_map); MB_CHK_SET_ERR_CONT(result, "Failed to create surface intersections"); CHECK((int)int_map.size() == 6); // the cube should have 6 surfaces //check for surfaces w/ intersections int num_intersections = 0; std::map<moab::EntityHandle, std::vector<Loop> >::iterator i; for (i = int_map.begin(); i != int_map.end() ; i++) { if ((i->second).size() != 0) { num_intersections++; } } // the axis and coordinate given should slice through four surfaces CHECK(4 == num_intersections); } void intersection_test() { moab::ErrorCode result; //create a new triangle in the moab instance moab::CartVect coords[3]; coords[0][0] = 1; coords[0][1] = 0; coords[0][2] = 0; coords[1][0] = 0; coords[1][1] = 1; coords[1][2] = 0; coords[2][0] = 0; coords[2][1] = 0; coords[2][2] = 1; moab::EntityHandle v0,v1,v2,tri; result = mbi()->create_vertex(coords[0].array(), v0); MB_CHK_SET_ERR_CONT(result, "Failed to create test vertex zero"); result = mbi()->create_vertex(coords[1].array(), v1); MB_CHK_SET_ERR_CONT(result, "Failed to create test vertex one"); result = mbi()->create_vertex(coords[2].array(), v2); MB_CHK_SET_ERR_CONT(result, "Failed to create test vertex two"); moab::EntityHandle verts[] = {v0,v1,v2}; result = mbi()->create_element(MBTRI, verts, 3, tri); MB_CHK_SET_ERR_CONT(result, "Failed to create test triangle"); Line test_line; bool intersect; result = intersection(2, 0.5, tri, test_line, intersect); MB_CHK_SET_ERR_CONT(result, "Failed to detect intersection of line with triangle"); CHECK(intersect); //make sure the values we get back from this function are //correct CHECK(test_line.begin[0] == 0); CHECK(test_line.begin[1] == 0.5); CHECK(test_line.begin[2] == 0.5); CHECK(test_line.end[0] == 0.5); CHECK(test_line.end[1] == 0); CHECK(test_line.end[2] == 0.5); Line test_line2; //this plane should not intersect our triangle result = intersection(2, 6, tri, test_line2, intersect); MB_CHK_SET_ERR_CONT(result, "Failed to detect intersection of line with triangle"); CHECK(!intersect); } void triangle_plane_intersect_test() { moab::CartVect coords[3]; coords[0][0] = 1; coords[0][1] = 0; coords[0][2] = 0; coords[1][0] = 0; coords[1][1] = 1; coords[1][2] = 0; coords[2][0] = 0; coords[2][1] = 0; coords[2][2] = 1; Line test_line; CHECK(!test_line.full); triangle_plane_intersect(2, 0.5, coords, test_line); CHECK(test_line.started); CHECK(test_line.full); //make sure the values we get back from this function are //correct CHECK(test_line.begin[0] == 0); CHECK(test_line.begin[1] == 0.5); CHECK(test_line.begin[2] == 0.5); CHECK(test_line.end[0] == 0.5); CHECK(test_line.end[1] == 0); CHECK(test_line.end[2] == 0.5); Line test_line2; // this plane should not intersect with the triangle triangle_plane_intersect(2, 6.0, coords, test_line2); CHECK(!test_line2.started); CHECK(!test_line2.full); } void get_intersection_test() { moab::CartVect point0( 1, 1, 0 ); moab::CartVect point1(-1, 1, 0 ); Line test_line; get_intersection(point0, point1, 0, 0.0, test_line); CHECK(test_line.begin[0] == 0.0); CHECK(test_line.begin[1] == 1.0); CHECK(test_line.begin[2] == 0.0); point1[0] = 1; point1[1] = -1; point1[2] = 0; test_line.started = true; get_intersection(point0, point1, 1 , 0.0, test_line); CHECK(test_line.end[0] == 1.0); CHECK(test_line.end[1] == 0.0); CHECK(test_line.end[2] == 0.0); point1[0] = 1; point1[1] = 1; point1[2] = 2; Line test_line2; get_intersection(point0, point1, 2 , 1.0, test_line2); CHECK(test_line2.begin[0] = 1.0); CHECK(test_line2.begin[1] = 1.0); CHECK(test_line2.begin[2] = 1.0); //this function expects an intersection to exist //an intentional failure case will not be created } void get_volume_intersections_test() { //get the volume from the instance moab::Range sets; char category[CATEGORY_TAG_SIZE] = "Volume"; moab::ErrorCode result = get_sets_by_category(sets, category); MB_CHK_SET_ERR_CONT(result, "Failed to get the volume meshsets"); moab::EntityHandle cube_vol = sets[0]; //there should only be one volume in the test model //create surface intersections for the model char category1[CATEGORY_TAG_SIZE] = "Surface"; sets.clear(); result = get_sets_by_category(sets, category1); MB_CHK_SET_ERR_CONT(result, "Failed to get the surface meshsets"); //create a fake map for this volume. std::map< moab::EntityHandle, std::vector<Loop> > fake_map; std::vector<Loop> dummy_loop; dummy_loop.resize(2); fake_map[sets[0]] = dummy_loop; //check that we get this loop back std::vector<Loop> intersections; get_volume_intersections(cube_vol, fake_map, intersections); //we should get back our dummy loop once //and insert it into the intersections vector CHECK(2 == intersections.size()); //add a new dummy to the map fake_map[sets[1]] = dummy_loop; intersections.clear(); get_volume_intersections(cube_vol, fake_map, intersections); //with this map we should get 4 values in the intersections vector CHECK(4 == intersections.size()); } Loop create_circle_loop(double radius, unsigned int intervals) { Loop circle_loop; double x,y,z; double theta; //add a complete unit circle for (unsigned int i = 0; i <= intervals; i++) { theta = 2*M_PI * (double) i * (1/(double)intervals); x = radius*cos(theta); y = radius*sin(theta); z = 1.0; moab::CartVect pnt( x, y, z); circle_loop.points.push_back(pnt); } circle_loop.gen_xys(2); //create 2-D points for this loop (slice is along z) return circle_loop; } void stitch_test() { std::vector<Loop> dummy_intersections; std::vector<Loop> returned_paths; Loop dummy_loop1 = create_circle_loop( 1.0, 10 ); dummy_intersections.push_back(dummy_loop1); //this should return the circle stitch(dummy_intersections, returned_paths); CHECK(1 == (int)returned_paths.size()); //clear some data returned_paths.clear(); dummy_loop1.points.clear(); Loop dummy_loop2 = create_circle_loop(2.0, 10); dummy_intersections.push_back(dummy_loop2); stitch(dummy_intersections, returned_paths); // there should now be two paths: the unit circle and the larger circle of rad 2 CHECK(2 == (int)returned_paths.size()); //clear everything returned_paths.clear(); dummy_intersections.clear(); dummy_loop1.points.clear(); dummy_loop2.points.clear(); //now write half the points of a circle to one loop and half to the other dummy_loop1 = create_circle_loop(1.0, 10); //give half of dummy_loop1's points to dummy_loop2 dummy_loop2.points.insert(dummy_loop2.points.begin(), dummy_loop1.points.begin()+3, dummy_loop1.points.end()); dummy_loop1.points.erase(dummy_loop1.points.begin()+4, dummy_loop1.points.end()); dummy_intersections.push_back(dummy_loop1); dummy_intersections.push_back(dummy_loop2); //the function should find these two sections and stitch them without a problem stitch(dummy_intersections, returned_paths); CHECK(1 == (int)returned_paths.size()); //check that our end and beginning points are correct //if these loops stitch correctly the beginning of the path will be the beginning of dummy_loop1 // the end of the path will be the end of dummy_loop2 //BEFORE *- coincident point (beginning and end of circle) // dummy_loop1 *-----------# // dummy_loop2 #-----------* //AFTER # - test points // returned_path #-----------**-----------# moab::CartVect begin_test_pnt = dummy_loop2.points.front(); moab::CartVect end_test_pnt = dummy_loop1.points.back(); CHECK(returned_paths[0].points.front() == begin_test_pnt); CHECK(returned_paths[0].points.back() == end_test_pnt); //this function should always return a closed loop (i.e. # == # in above diagram ) CHECK(returned_paths[0].points.front() == returned_paths[0].points.back()); } void get_containment_test() { std::vector<Loop> test_loops; //create some loops for testing containment (concentric circles) test_loops.push_back(create_circle_loop(1.0, 10)); test_loops.push_back(create_circle_loop(2.0, 10)); test_loops.push_back(create_circle_loop(3.0, 10)); test_loops.push_back(create_circle_loop(4.0, 10)); //now get the containment matrix for these loops std::vector< std::vector<int> > returned_mat, test_mat; get_containment(test_loops, returned_mat); //what we expect our matrix to look like std::vector<int> row(4); row[0] = 1; row[1] = 1; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 1; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 0; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 0; row[2] = 0; row[3] = 1; test_mat.push_back(row); //the matrices should be of the same size CHECK_EQUAL(test_mat.size(), returned_mat.size()); for (unsigned int i = 0; i < test_mat.size(); i ++) { CHECK_EQUAL(test_mat[i].size(),returned_mat[i].size()); //the matrices should be square CHECK(returned_mat.size() == returned_mat[i].size()); CHECK(test_mat.size() == test_mat[i].size()); for (unsigned int j = 0; j < test_mat[i].size(); j++) { //check that the values match in our test matrix CHECK_EQUAL(test_mat[i][j], returned_mat[i][j]); } } } void is_poly_a_in_poly_b_test() { //create a few test loops Loop test_loop1, test_loop2, test_loop3; double base_radius = 2.0; unsigned int intervals = 20; test_loop1 = create_circle_loop(base_radius, intervals); //any polygon should be contained by itself CHECK(is_poly_a_in_poly_b(test_loop1, test_loop1)); double tolerances[6] = {1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6}; for (unsigned int i = 0; i < 6; i++) { double tol = tolerances[i]; double larger_rad = base_radius + tol; double smaller_rad = base_radius - tol; test_loop2 = create_circle_loop(larger_rad, intervals+3); // one just on the outside test_loop3 = create_circle_loop(smaller_rad, intervals+3); // one just on the inside CHECK(is_poly_a_in_poly_b(test_loop1, test_loop2)); CHECK(!is_poly_a_in_poly_b(test_loop2, test_loop1)); CHECK(!is_poly_a_in_poly_b(test_loop1, test_loop3)); CHECK(is_poly_a_in_poly_b(test_loop3, test_loop1)); CHECK(is_poly_a_in_poly_b(test_loop3, test_loop2)); CHECK(!is_poly_a_in_poly_b(test_loop2, test_loop3)); test_loop2.points.clear(); test_loop2.xypnts.clear(); test_loop3.points.clear(); test_loop3.xypnts.clear(); } } void find_winding_test() { //create some test loop double loop_radius = 2.0; unsigned int intervals = 20; Loop test_loop = create_circle_loop(loop_radius, intervals); //according to the increasing angle convention used in create_circle_loop //this polygon should be wound CCW CHECK_EQUAL(CCW, find_winding(test_loop)); std::reverse(test_loop.xypnts.begin(), test_loop.xypnts.end()); //should have a reversed winding now CHECK_EQUAL(CW, find_winding(test_loop)); } void get_fill_windings_test() { //create a sample matrix for this test std::vector< std::vector<int> > test_mat; std::vector<int> row(4); row[0] = 1; row[1] = 1; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 1; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 0; row[2] = 1; row[3] = 1; test_mat.push_back(row); row[0] = 0; row[1] = 0; row[2] = 0; row[3] = 1; test_mat.push_back(row); std::vector<int> expected_results, returned_results; expected_results.resize(4); expected_results[0] = CW; expected_results[1] = CCW; expected_results[2] = CW; expected_results[3] = CCW; get_fill_windings(test_mat, returned_results); //check that our returned matrix is the right size CHECK_EQUAL(expected_results.size(), returned_results.size()); //now make sure the values are correct for (unsigned int i = 0 ; i < 4; i++) { CHECK_EQUAL(expected_results[i], returned_results[i]); } } void set_windings_test() { Loop test_loop1, test_loop2; std::vector<Loop> test_loops, returned_loops; double loop_rad = 2.0; unsigned int intervals = 20; test_loop1 = create_circle_loop(loop_rad, intervals); test_loops.push_back(test_loop1); test_loops.push_back(test_loop1); returned_loops = test_loops; std::vector<int> current_windings, desired_windings; current_windings.resize(2); desired_windings.resize(2); //these will come back CCW from the current circle loop function current_windings[0] = CCW; current_windings[1] = CCW; desired_windings[0] = CCW; desired_windings[1] = CW; set_windings(current_windings, desired_windings, returned_loops); //check that loop sizes are unaltered CHECK_EQUAL(2, (int)returned_loops.size()); CHECK_EQUAL(test_loops[0].xypnts.size(), returned_loops[0].xypnts.size()); CHECK_EQUAL(test_loops[1].xypnts.size(), returned_loops[1].xypnts.size()); //check that the first returned loop is unaltered (matches test_loop) for (unsigned int i = 0; i < test_loop1.xypnts.size(); i++) { CHECK(test_loop1.points[i] == returned_loops[0].points[i]); CHECK(test_loop1.xypnts[i].x == returned_loops[0].xypnts[i].x); CHECK(test_loop1.xypnts[i].y == returned_loops[0].xypnts[i].y); } //now make sure the second returned loop is reversed std::reverse(test_loop1.xypnts.begin(), test_loop1.xypnts.end()); std::reverse(test_loop1.points.begin(), test_loop1.points.end()); for (unsigned int i = 0; i < test_loop1.xypnts.size(); i++) { CHECK(test_loop1.points[i] == returned_loops[1].points[i]); CHECK(test_loop1.xypnts[i].x == returned_loops[1].xypnts[i].x); CHECK(test_loop1.xypnts[i].y == returned_loops[1].xypnts[i].y); } } void get_sets_by_category_test() { moab::Range sets; char category1[CATEGORY_TAG_SIZE] = "Volume"; moab::ErrorCode result = get_sets_by_category(sets, category1); MB_CHK_SET_ERR_CONT(result, "Failed to get the volume meshsets"); CHECK_EQUAL(1, (int)sets.size()); sets.clear(); char category2[CATEGORY_TAG_SIZE] = "Surface"; result = get_sets_by_category(sets, category2); CHECK_EQUAL(6, (int)sets.size()); } void get_surfaces_test() { moab::Range surfaces; moab::ErrorCode result = get_all_surfaces(surfaces); MB_CHK_SET_ERR_CONT(result, "Failed to get all surfaces"); //test file is a cube and should have 6 surfaces CHECK_EQUAL(6, (int)surfaces.size()); } void get_all_volumes_test() { moab::Range volumes; moab::ErrorCode result = get_all_volumes(volumes); MB_CHK_SET_ERR_CONT(result, "Failed to get all of the volumes"); //test file is a lone cube and should have 1 volume CHECK_EQUAL(1, (int)volumes.size()); } void test_point_match() { //setup two cart vectors that will represent points moab::CartVect a,b; //initialize a[0] = 1.0; a[1] = 1.0; a[2] = 1.0-1e-7; //make b equal to a b=a; //These should be recognized as coincident for this tolerance CHECK(point_match(a,b, 1e-6)); //Now alter b a little bit b[2] = 1.0; //These should still be recognized as coincident CHECK(point_match(a,b,1e-6)); // This point should not be recognized as coincident CHECK(!point_match(a,b,1e-8)); //Now alter b a lot (relatively) b[2] = 2.0; //This should not be recognized as coincident CHECK(!point_match(a,b)); }
// Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "base58.h" #include "clientversion.h" #include "credits.h" #include "core_io.h" #include "keystore.h" #include "primitives/block.h" // for MAX_BLOCK_SIZE #include "primitives/transaction.h" #include "script/script.h" #include "script/sign.h" #include "ui_interface.h" // for _(...) #include "univalue/univalue.h" #include "util.h" #include "utilmoneystr.h" #include "utilstrencodings.h" #include <stdio.h> #include <boost/algorithm/string.hpp> #include <boost/assign/list_of.hpp> using namespace boost::assign; using namespace std; static bool fCreateBlank; static map<string, UniValue> registers; CClientUIInterface uiInterface; static bool AppInitRawTx(int argc, char* argv[]) { // // Parameters // ParseParameters(argc, argv); // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) if (!SelectParamsFromCommandLine()) { fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n"); return false; } fCreateBlank = GetBoolArg("-create", false); if (argc < 2 || mapArgs.count("-?") || mapArgs.count("-help")) { // First part of help message is specific to this utility std::string strUsage = _("AdvantageCoin Core advantagecoin-tx utility version") + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\n" + " advantagecoin-tx [options] <hex-tx> [commands] " + _("Update hex-encoded advantagecoin transaction") + "\n" + " advantagecoin-tx [options] -create [commands] " + _("Create hex-encoded advantagecoin transaction") + "\n" + "\n"; fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Options:")); strUsage += HelpMessageOpt("-?", _("This help message")); strUsage += HelpMessageOpt("-create", _("Create new, empty TX.")); strUsage += HelpMessageOpt("-json", _("Select JSON output")); strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction.")); strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.")); strUsage += HelpMessageOpt("-testnet", _("Use the test network")); fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Commands:")); strUsage += HelpMessageOpt("delin=N", _("Delete input N from TX")); strUsage += HelpMessageOpt("delout=N", _("Delete output N from TX")); strUsage += HelpMessageOpt("in=TXID:VOUT", _("Add input to TX")); strUsage += HelpMessageOpt("locktime=N", _("Set TX lock time to N")); strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N")); strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX")); strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT", _("Add raw script output to TX")); strUsage += HelpMessageOpt("sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " + _("This command requires JSON registers:") + _("prevtxs=JSON object") + ", " + _("privatekeys=JSON object") + ". " + _("See signrawtransaction docs for format of sighash flags, JSON objects.")); fprintf(stdout, "%s", strUsage.c_str()); strUsage = HelpMessageGroup(_("Register Commands:")); strUsage += HelpMessageOpt("load=NAME:FILENAME", _("Load JSON file FILENAME into register NAME")); strUsage += HelpMessageOpt("set=NAME:JSON-STRING", _("Set register NAME to given JSON-STRING")); fprintf(stdout, "%s", strUsage.c_str()); return false; } return true; } static void RegisterSetJson(const string& key, const string& rawJson) { UniValue val; if (!val.read(rawJson)) { string strErr = "Cannot parse JSON for key " + key; throw runtime_error(strErr); } registers[key] = val; } static void RegisterSet(const string& strInput) { // separate NAME:VALUE in string size_t pos = strInput.find(':'); if ((pos == string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) throw runtime_error("Register input requires NAME:VALUE"); string key = strInput.substr(0, pos); string valStr = strInput.substr(pos + 1, string::npos); RegisterSetJson(key, valStr); } static void RegisterLoad(const string& strInput) { // separate NAME:FILENAME in string size_t pos = strInput.find(':'); if ((pos == string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) throw runtime_error("Register load requires NAME:FILENAME"); string key = strInput.substr(0, pos); string filename = strInput.substr(pos + 1, string::npos); FILE* f = fopen(filename.c_str(), "r"); if (!f) { string strErr = "Cannot open file " + filename; throw runtime_error(strErr); } // load file chunks into one big buffer string valStr; while ((!feof(f)) && (!ferror(f))) { char buf[4096]; int bread = fread(buf, 1, sizeof(buf), f); if (bread <= 0) break; valStr.insert(valStr.size(), buf, bread); } if (ferror(f)) { string strErr = "Error reading file " + filename; throw runtime_error(strErr); } fclose(f); // evaluate as JSON buffer register RegisterSetJson(key, valStr); } static void MutateTxVersion(CMutableTransaction& tx, const string& cmdVal) { int64_t newVersion = atoi64(cmdVal); if (newVersion < 1 || newVersion > CTransaction::CURRENT_VERSION) throw runtime_error("Invalid TX version requested"); tx.nVersion = (int)newVersion; } static void MutateTxLocktime(CMutableTransaction& tx, const string& cmdVal) { int64_t newLocktime = atoi64(cmdVal); if (newLocktime < 0LL || newLocktime > 0xffffffffLL) throw runtime_error("Invalid TX locktime requested"); tx.nLockTime = (unsigned int)newLocktime; } static void MutateTxAddInput(CMutableTransaction& tx, const string& strInput) { // separate TXID:VOUT in string size_t pos = strInput.find(':'); if ((pos == string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) throw runtime_error("TX input missing separator"); // extract and validate TXID string strTxid = strInput.substr(0, pos); if ((strTxid.size() != 64) || !IsHex(strTxid)) throw runtime_error("invalid TX input txid"); uint256 txid(strTxid); static const unsigned int minTxOutSz = 9; static const unsigned int maxVout = MAX_BLOCK_SIZE / minTxOutSz; // extract and validate vout string strVout = strInput.substr(pos + 1, string::npos); int vout = atoi(strVout); if ((vout < 0) || (vout > (int)maxVout)) throw runtime_error("invalid TX input vout"); // append to transaction input list CTxIn txin(txid, vout); tx.vin.push_back(txin); } static void MutateTxAddOutAddr(CMutableTransaction& tx, const string& strInput) { // separate VALUE:ADDRESS in string size_t pos = strInput.find(':'); if ((pos == string::npos) || (pos == 0) || (pos == (strInput.size() - 1))) throw runtime_error("TX output missing separator"); // extract and validate VALUE string strValue = strInput.substr(0, pos); CAmount value; if (!ParseMoney(strValue, value)) throw runtime_error("invalid TX output value"); // extract and validate ADDRESS string strAddr = strInput.substr(pos + 1, string::npos); CBitcoinAddress addr(strAddr); if (!addr.IsValid()) throw runtime_error("invalid TX output address"); // build standard output script via GetScriptForDestination() CScript scriptPubKey = GetScriptForDestination(addr.Get()); // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxAddOutScript(CMutableTransaction& tx, const string& strInput) { // separate VALUE:SCRIPT in string size_t pos = strInput.find(':'); if ((pos == string::npos) || (pos == 0)) throw runtime_error("TX output missing separator"); // extract and validate VALUE string strValue = strInput.substr(0, pos); CAmount value; if (!ParseMoney(strValue, value)) throw runtime_error("invalid TX output value"); // extract and validate script string strScript = strInput.substr(pos + 1, string::npos); CScript scriptPubKey = ParseScript(strScript); // throws on err // construct TxOut, append to transaction output list CTxOut txout(value, scriptPubKey); tx.vout.push_back(txout); } static void MutateTxDelInput(CMutableTransaction& tx, const string& strInIdx) { // parse requested deletion index int inIdx = atoi(strInIdx); if (inIdx < 0 || inIdx >= (int)tx.vin.size()) { string strErr = "Invalid TX input index '" + strInIdx + "'"; throw runtime_error(strErr.c_str()); } // delete input from transaction tx.vin.erase(tx.vin.begin() + inIdx); } static void MutateTxDelOutput(CMutableTransaction& tx, const string& strOutIdx) { // parse requested deletion index int outIdx = atoi(strOutIdx); if (outIdx < 0 || outIdx >= (int)tx.vout.size()) { string strErr = "Invalid TX output index '" + strOutIdx + "'"; throw runtime_error(strErr.c_str()); } // delete output from transaction tx.vout.erase(tx.vout.begin() + outIdx); } static const unsigned int N_SIGHASH_OPTS = 6; static const struct { const char* flagStr; int flags; } sighashOptions[N_SIGHASH_OPTS] = { {"ALL", SIGHASH_ALL}, {"NONE", SIGHASH_NONE}, {"SINGLE", SIGHASH_SINGLE}, {"ALL|ANYONECANPAY", SIGHASH_ALL | SIGHASH_ANYONECANPAY}, {"NONE|ANYONECANPAY", SIGHASH_NONE | SIGHASH_ANYONECANPAY}, {"SINGLE|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_ANYONECANPAY}, }; static bool findSighashFlags(int& flags, const string& flagStr) { flags = 0; for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) { if (flagStr == sighashOptions[i].flagStr) { flags = sighashOptions[i].flags; return true; } } return false; } uint256 ParseHashUO(map<string, UniValue>& o, string strKey) { if (!o.count(strKey)) return 0; return ParseHashUV(o[strKey], strKey); } vector<unsigned char> ParseHexUO(map<string, UniValue>& o, string strKey) { if (!o.count(strKey)) { vector<unsigned char> emptyVec; return emptyVec; } return ParseHexUV(o[strKey], strKey); } static void MutateTxSign(CMutableTransaction& tx, const string& flagStr) { int nHashType = SIGHASH_ALL; if (flagStr.size() > 0) if (!findSighashFlags(nHashType, flagStr)) throw runtime_error("unknown sighash flag/sign option"); vector<CTransaction> txVariants; txVariants.push_back(tx); // mergedTx will end up with all the signatures; it // starts as a clone of the raw tx: CMutableTransaction mergedTx(txVariants[0]); bool fComplete = true; CCreditsView viewDummy; CCreditsViewCache view(&viewDummy); if (!registers.count("privatekeys")) throw runtime_error("privatekeys register variable must be set."); bool fGivenKeys = false; CBasicKeyStore tempKeystore; UniValue keysObj = registers["privatekeys"]; fGivenKeys = true; for (unsigned int kidx = 0; kidx < keysObj.count(); kidx++) { if (!keysObj[kidx].isStr()) throw runtime_error("privatekey not a string"); CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(keysObj[kidx].getValStr()); if (!fGood) throw runtime_error("privatekey not valid"); CKey key = vchSecret.GetKey(); tempKeystore.AddKey(key); } // Add previous txouts given in the RPC call: if (!registers.count("prevtxs")) throw runtime_error("prevtxs register variable must be set."); UniValue prevtxsObj = registers["prevtxs"]; { for (unsigned int previdx = 0; previdx < prevtxsObj.count(); previdx++) { UniValue prevOut = prevtxsObj[previdx]; if (!prevOut.isObject()) throw runtime_error("expected prevtxs internal object"); map<string, UniValue::VType> types = map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR); if (!prevOut.checkObject(types)) throw runtime_error("prevtxs internal object typecheck fail"); uint256 txid = ParseHashUV(prevOut["txid"], "txid"); int nOut = atoi(prevOut["vout"].getValStr()); if (nOut < 0) throw runtime_error("vout must be positive"); vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey")); CScript scriptPubKey(pkData.begin(), pkData.end()); { CCreditsModifier credits = view.ModifyCredits(txid); if (credits->IsAvailable(nOut) && credits->vout[nOut].scriptPubKey != scriptPubKey) { string err("Previous output scriptPubKey mismatch:\n"); err = err + credits->vout[nOut].scriptPubKey.ToString() + "\nvs:\n" + scriptPubKey.ToString(); throw runtime_error(err); } if ((unsigned int)nOut >= credits->vout.size()) credits->vout.resize(nOut + 1); credits->vout[nOut].scriptPubKey = scriptPubKey; credits->vout[nOut].nValue = 0; // we don't know the actual output value } // if redeemScript given and private keys given, // add redeemScript to the tempKeystore so it can be signed: if (fGivenKeys && scriptPubKey.IsPayToScriptHash() && prevOut.exists("redeemScript")) { UniValue v = prevOut["redeemScript"]; vector<unsigned char> rsData(ParseHexUV(v, "redeemScript")); CScript redeemScript(rsData.begin(), rsData.end()); tempKeystore.AddCScript(redeemScript); } } } const CKeyStore& keystore = tempKeystore; bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); // Sign what we can: for (unsigned int i = 0; i < mergedTx.vin.size(); i++) { CTxIn& txin = mergedTx.vin[i]; const CCredits* credits = view.AccessCredits(txin.prevout.hash); if (!credits || !credits->IsAvailable(txin.prevout.n)) { fComplete = false; continue; } const CScript& prevPubKey = credits->vout[txin.prevout.n].scriptPubKey; txin.scriptSig.clear(); // Only sign SIGHASH_SINGLE if there's a corresponding output: if (!fHashSingle || (i < mergedTx.vout.size())) SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: BOOST_FOREACH (const CTransaction& txv, txVariants) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i))) fComplete = false; } if (fComplete) { // do nothing... for now // perhaps store this for later optional JSON output } tx = mergedTx; } static void MutateTx(CMutableTransaction& tx, const string& command, const string& commandVal) { if (command == "nversion") MutateTxVersion(tx, commandVal); else if (command == "locktime") MutateTxLocktime(tx, commandVal); else if (command == "delin") MutateTxDelInput(tx, commandVal); else if (command == "in") MutateTxAddInput(tx, commandVal); else if (command == "delout") MutateTxDelOutput(tx, commandVal); else if (command == "outaddr") MutateTxAddOutAddr(tx, commandVal); else if (command == "outscript") MutateTxAddOutScript(tx, commandVal); else if (command == "sign") MutateTxSign(tx, commandVal); else if (command == "load") RegisterLoad(commandVal); else if (command == "set") RegisterSet(commandVal); else throw runtime_error("unknown command"); } static void OutputTxJSON(const CTransaction& tx) { UniValue entry(UniValue::VOBJ); TxToUniv(tx, 0, entry); string jsonOutput = entry.write(4); fprintf(stdout, "%s\n", jsonOutput.c_str()); } static void OutputTxHash(const CTransaction& tx) { string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id) fprintf(stdout, "%s\n", strHexHash.c_str()); } static void OutputTxHex(const CTransaction& tx) { string strHex = EncodeHexTx(tx); fprintf(stdout, "%s\n", strHex.c_str()); } static void OutputTx(const CTransaction& tx) { if (GetBoolArg("-json", false)) OutputTxJSON(tx); else if (GetBoolArg("-txid", false)) OutputTxHash(tx); else OutputTxHex(tx); } static string readStdin() { char buf[4096]; string ret; while (!feof(stdin)) { size_t bread = fread(buf, 1, sizeof(buf), stdin); ret.append(buf, bread); if (bread < sizeof(buf)) break; } if (ferror(stdin)) throw runtime_error("error reading stdin"); boost::algorithm::trim_right(ret); return ret; } static int CommandLineRawTx(int argc, char* argv[]) { string strPrint; int nRet = 0; try { // Skip switches; Permit common stdin convention "-" while (argc > 1 && IsSwitchChar(argv[1][0]) && (argv[1][1] != 0)) { argc--; argv++; } CTransaction txDecodeTmp; int startArg; if (!fCreateBlank) { // require at least one param if (argc < 2) throw runtime_error("too few parameters"); // param: hex-encoded advantagecoin transaction string strHexTx(argv[1]); if (strHexTx == "-") // "-" implies standard input strHexTx = readStdin(); if (!DecodeHexTx(txDecodeTmp, strHexTx)) throw runtime_error("invalid transaction encoding"); startArg = 2; } else startArg = 1; CMutableTransaction tx(txDecodeTmp); for (int i = startArg; i < argc; i++) { string arg = argv[i]; string key, value; size_t eqpos = arg.find('='); if (eqpos == string::npos) key = arg; else { key = arg.substr(0, eqpos); value = arg.substr(eqpos + 1); } MutateTx(tx, key, value); } OutputTx(tx); } catch (boost::thread_interrupted) { throw; } catch (std::exception& e) { strPrint = string("error: ") + e.what(); nRet = EXIT_FAILURE; } catch (...) { PrintExceptionContinue(NULL, "CommandLineRawTx()"); throw; } if (strPrint != "") { fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str()); } return nRet; } int main(int argc, char* argv[]) { SetupEnvironment(); try { if (!AppInitRawTx(argc, argv)) return EXIT_FAILURE; } catch (std::exception& e) { PrintExceptionContinue(&e, "AppInitRawTx()"); return EXIT_FAILURE; } catch (...) { PrintExceptionContinue(NULL, "AppInitRawTx()"); return EXIT_FAILURE; } int ret = EXIT_FAILURE; try { ret = CommandLineRawTx(argc, argv); } catch (std::exception& e) { PrintExceptionContinue(&e, "CommandLineRawTx()"); } catch (...) { PrintExceptionContinue(NULL, "CommandLineRawTx()"); } return ret; }
; SM Multiworld support ; ; ; Implement auto-saving on death as a temporary measure to prevent lost items ; Game state 15h (Samus ran out of health, black out surroundings) ;;; ; JSL $9BB3A7[$9B:B3A7] ; org $C2DD7E ; $82DD7E ; jsl sm_mw_autosave org $C28BB3 jsl sm_mw_hook_main_game org $C09490 jsl sm_mw_check_softreset : nop org $f83000 sm_mw_nmi_read_messages: rep #$30 lda.l config_multiworld beq + lda.l !MESSAGEBASE+$18E bne + jsl read_messages + inc $05b8 rtl ; Display message that we picked up someone elses item ; X = item id, Y = player id sm_mw_display_item_sent: stx $c1 sty $c3 ;lda #$0168 ; With fanfare skip, no need to queue room track ;jsl $82e118 ; Queue room track after item fanfare lda #$005c jsl $858080 rtl sm_mw_receive_item: pha : phx cmp #$00b0 ; If below B0 it's an alttp item bcc .alttpItem cmp #$00c5 bcs .smCustomItem ; Above C5 is custom SM items sec sbc #$00b0 asl #4 : tax lda.l sm_item_table+$2, x ; Read item flag sta $cc lda #$005d sta $ce lda.l #sm_item_table sta $ca txa : clc : adc $ca : tax ldy #$00cc jsl sm_mw_call_receive ; Call original item receive code (reading the item to get from $cc-ce) plx : pla rts .alttpItem lda #$0001 sta.l !SM_MULTIWORLD_PICKUP jsl alttp_item_pickup plx : pla rts .smCustomItem pha lda #$0001 sta.l !SM_MULTIWORLD_PICKUP pla sec sbc #$00b0 jsl receive_sm_item_long plx : pla rts sm_mw_handle_queue: pha : phx .loop ; lda.l !SRAM_MW_RPTR ; cmp.l !SRAM_MW_WPTR ; beq .end ; asl #2 : tax ; lda.l !SRAM_MW_RECVQ, x : sta $c3 ; lda.l !SRAM_MW_RECVQ+$2, x : sta $c1 ; jsr sm_mw_receive_item ; lda.l !SRAM_MW_RPTR ; inc a ; cmp #$0010 ; bne + ; lda.l #$0000 ; + ; sta.l !SRAM_MW_RPTR lda.l !SRAM_MW_ITEMS_RECV_RPTR cmp.l !SRAM_MW_ITEMS_RECV_WPTR beq .end asl #2 : tax lda.l !SRAM_MW_ITEMS_RECV, x : sta $c3 lda.l !SRAM_MW_ITEMS_RECV+$2, x : sta $c1 jsr sm_mw_receive_item lda.l !SRAM_MW_ITEMS_RECV_RPTR inc a sta.l !SRAM_MW_ITEMS_RECV_RPTR bra .loop .end plx : pla rts sm_mw_hook_main_game: jsl $A09169 ; Last routine of game mode 8 (main gameplay) lda.l config_multiworld beq + lda $0998 cmp #$0008 bne + jsr sm_mw_handle_queue ; Handle MW RECVQ only in gamemode 8 + rtl sm_mw_autosave: lda.l $a16168 : pha ; Backup save station variables lda.l $a16166 : pha ; so the autosave saves to the last savestation lda $a16030 ; Load old saved health and resave it bne + lda #$0063 ; Load 99 if old saved health is 0 to prevent death loops + sta $7e09c2 lda #$0000 jsl $818000 ; Save SRAM pla : sta.l $a16166 pla : sta.l $a16168 ; Set these values to 0 to force load from the ship if samus dies jsl sm_fix_checksum ; Fix SRAM checksum (otherwise SM deletes the file on load) jsl $9BB3A7 rtl sm_mw_check_softreset: lda $8b cmp #$3030 ; Check if Start+Select+L+R are pressed bne + lda.l !SRAM_SAVING ; Don't reset while saving to SRAM bne + lda $0617 ; Don't reset if uploading to the APU bne + lda $0998 ; Don't reset during SM boot or title screen cmp #$0002 bcc + stz $4200 ; Disable NMI and joypad autoread jml $808462 ; Jump to SM soft-reset + rtl
lda {c1},y clc adc {c1},x sta {m1} lda {c1}+1,y adc {c1}+1,x sta {m1}+1
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: init_floatpack.asm,v 1.5 2016-06-22 19:50:49 dom Exp $ ; SECTION code_fp INCLUDE "target/cpc/def/cpcfp.def" PUBLIC init_floatpack ; All the library routines that we have to change EXTERN atan EXTERN cos EXTERN dadd EXTERN ddiv EXTERN deg EXTERN deq EXTERN dge EXTERN dgt EXTERN dleq EXTERN dlt EXTERN dmul EXTERN dne EXTERN dsub EXTERN exp EXTERN float EXTERN floor EXTERN fprand EXTERN ifix EXTERN log10 EXTERN log EXTERN minusfa EXTERN pi EXTERN pow10 EXTERN pow EXTERN rad EXTERN sin EXTERN sqrt EXTERN tan ; The actual place where we have to change things EXTERN atanc EXTERN cosc EXTERN daddc EXTERN ddivc EXTERN degc EXTERN deqc EXTERN dgec EXTERN dgtc EXTERN dleqc EXTERN dltc EXTERN dmulc EXTERN dnec EXTERN dsubc EXTERN expc EXTERN floatc EXTERN floorc EXTERN floorc2 EXTERN fprandc EXTERN ifixc EXTERN log10c EXTERN logc EXTERN minusfac EXTERN pic EXTERN pow10c EXTERN powc EXTERN radc EXTERN sinc EXTERN skelc EXTERN sqrtc EXTERN tanc .init_floatpack ld hl,$BD65 ld a,(hl) cp 158 jp z,init_cpc464float cp 200 jp z,init_cpc664float ret .init_cpc464float ld hl,CPCFP464_FLO_ATAN ld (atanc),hl ld hl,CPCFP464_FLO_COS ld (cosc),hl ld hl,CPCFP464_FLO_ADD ld (daddc),hl ld hl,CPCFP464_FLO_DIV ld (ddivc),hl ld hl,CPCFP464_FLO_DEG_RAD ld (degc),hl ld (radc),hl ld hl,CPCFP464_FLO_CMP ld (deqc),hl ld (dgec),hl ld (dgtc),hl ld (dleqc),hl ld (dltc),hl ld (dnec),hl ld hl,CPCFP464_FLO_MUL ld (dmulc),hl ld hl,CPCFP464_FLO_REV_SUB ld (dsubc),hl ld hl,CPCFP464_FLO_EXP ld (expc),hl ld hl,CPCFP464_INT_2_FLO ld (floatc),hl ld hl,CPCFP464_FLO_BINFIX ld (floorc),hl ld hl,CPCFP464_BIN_2_FLO ld (floorc2),hl ld hl,CPCFP464_FLO_RND ld (fprandc),hl ld hl,CPCFP464_FLO_2_INT ld (ifixc),hl ld hl,CPCFP464_FLO_LOG10 ld (log10c),hl ld hl,CPCFP464_FLO_LOG ld (logc),hl ld hl,CPCFP464_FLO_INV_SGN ld (minusfac),hl ld hl,CPCFP464_FLO_PI ld (pic),hl ld hl,CPCFP464_FLO_POW10 ld (pow10c),hl ld hl,CPCFP464_FLO_POW ld (powc),hl ld hl,CPCFP464_FLO_SIN ld (sinc),hl ld hl,CPCFP464_FLO_SQRT ld (sqrtc),hl ld hl,CPCFP464_FLO_TAN ld (tanc),hl ret .init_cpc664float ld hl,CPCFP664_FLO_ATAN ld (atanc),hl ld hl,CPCFP664_FLO_COS ld (cosc),hl ld hl,CPCFP664_FLO_ADD ld (daddc),hl ld hl,CPCFP664_FLO_DIV ld (ddivc),hl ld hl,CPCFP664_FLO_DEG_RAD ld (degc),hl ld (radc),hl ld hl,CPCFP664_FLO_CMP ld (deqc),hl ld (dgec),hl ld (dgtc),hl ld (dleqc),hl ld (dltc),hl ld (dnec),hl ld hl,CPCFP664_FLO_MUL ld (dmulc),hl ld hl,CPCFP664_FLO_REV_SUB ld (dsubc),hl ld hl,CPCFP664_FLO_EXP ld (expc),hl ld hl,CPCFP664_INT_2_FLO ld (floatc),hl ld hl,CPCFP664_FLO_BINFIX ld (floorc),hl ld hl,CPCFP664_BIN_2_FLO ld (floorc2),hl ld hl,CPCFP664_FLO_RND ld (fprandc),hl ld hl,CPCFP664_FLO_2_INT ld (ifixc),hl ld hl,CPCFP664_FLO_LOG10 ld (log10c),hl ld hl,CPCFP664_FLO_LOG ld (logc),hl ld hl,CPCFP664_FLO_INV_SGN ld (minusfac),hl ld hl,CPCFP664_FLO_PI ld (pic),hl ld hl,CPCFP664_FLO_POW10 ld (pow10c),hl ld hl,CPCFP664_FLO_POW ld (powc),hl ld hl,CPCFP664_FLO_SIN ld (sinc),hl ld hl,CPCFP664_FLO_SQRT ld (sqrtc),hl ld hl,CPCFP664_FLO_TAN ld (tanc),hl ret
; Z88 Small C+ Run Time Library ; Long functions ; SECTION code_crt0_sccz80 PUBLIC l_long_xor ; dehl = primary ; stack = secondary, ret .l_long_xor pop ix pop bc ld a,c xor l ld l,a ld a,b xor h ld h,a pop bc ld a,c xor e ld e,a ld a,b xor d ld d,a jp (ix) ;.l_long_xor ; ld a,d ; exx ;primary; ; pop bc; ; pop hl ; pop de ; push bc ; xor d ; ld d,a ; ld a,e ; exx ;2nd ; xor e ; exx ;1st ; ld e,a ; ld a,h ; exx ;2nd ; xor h ; exx ;1st ; ld h,a ; ld a,l ; exx ;2nd ; xor l ; exx ;1st ; ld l,a ; ret
#pragma once #include <array> #include <functional> #include <iostream> #include <numeric> #include <vector> #include "../util/binary_tree.hpp" #include "../util/indices.hpp" namespace bulk { /** Base class for partitionings over a 1D processor grid. */ template <int D> class partitioning { public: /** Construct a partitioning for a global size. */ partitioning(index_type<D> global_size) : global_size_(global_size) {} virtual ~partitioning() = default; /** Get the local and global sizes. */ index_type<D> global_size() const { return global_size_; } /** of an arbitrary processor */ virtual index_type<D> local_size(int processor) = 0; /** the total count of elements on a processor */ size_t local_count(int processor) { auto size = local_size(processor); return std::accumulate(size.begin(), size.end(), 1, std::multiplies<int>()); } /** Get the owner of a global index. */ virtual int owner(index_type<D> xs) = 0; /** Convert indices between global and local. */ virtual index_type<D> local(index_type<D> xs) = 0; virtual index_type<D> global(index_type<D> xs, int processor) = 0; protected: index_type<D> global_size_; }; /** Base class for partitionings over a multi-dimensional processor grid */ template <int D, int G> class multi_partitioning : public partitioning<D> { public: using partitioning<D>::local_size; multi_partitioning(index_type<D> global_size, index_type<G> grid_size) : partitioning<D>(global_size), grid_size_(grid_size) {} virtual ~multi_partitioning() = default; /** Get the local and global sizes. */ virtual index_type<D> local_size(index_type<G> processor) = 0; index_type<D> local_size(int processor) override { return this->local_size(util::unflatten<G>(grid_size_, processor)); }; /** Get the multi-dimensional owner of a global index. */ virtual index_type<G> multi_owner(index_type<D> xs) = 0; int owner(index_type<D> xs) override { return util::flatten<G>(grid_size_, multi_owner(xs)); } /** Convert indices between global and local. */ virtual index_type<D> global(index_type<D> xs, index_type<G> processor) = 0; index_type<D> global(index_type<D> xs, int processor) override { return global(xs, util::unflatten<G>(grid_size_, processor)); }; index_type<G> grid() { return grid_size_; } /** Convert between rank and multi rank */ int rank(index_type<G> t) { return util::flatten<G>(grid_size_, t); } index_type<G> multi_rank(int t) { return util::unflatten<G>(grid_size_, t); } protected: index_type<G> grid_size_; }; /** Rectangular partitionings over a multi-dimensional processor grid */ template <int D, int G> class rectangular_partitioning : public multi_partitioning<D, G> { public: using multi_partitioning<D, G>::global; rectangular_partitioning(index_type<D> global_size, index_type<G> grid_size) : multi_partitioning<D, G>(global_size, grid_size) {} /** Support origin queries by flattened, or multi-index */ virtual index_type<D> origin(index_type<G> processor) const { return this->origin(util::flatten<G>(this->grid_size_, processor)); } virtual index_type<D> origin(int processor) const { return this->origin(util::unflatten<G>(this->grid_size_, processor)); } index_type<D> global(index_type<D> xs, index_type<G> processor) override { index_type<D> global = origin(processor); for (int d = 0; d < D; ++d) { global[d] += xs[d]; } return global; } }; /** Cartesian partitionings over a multi-dimensional processor grid */ template <int D, int G = D> class cartesian_partitioning : public multi_partitioning<D, G> { public: cartesian_partitioning(index_type<D> global_size, index_type<G> grid_size) : multi_partitioning<D, G>(global_size, grid_size) {} /** Obtain the owner of index i for the g-th dimension */ using multi_partitioning<D, G>::owner; virtual int owner(int g, size_t i) = 0; /** Obtain the local index of global index i for the g-th dimension */ using multi_partitioning<D, G>::local; virtual size_t local(int g, size_t i) = 0; /** Obtain the global index of local index i for the g-th dimension */ using multi_partitioning<D, G>::global; virtual size_t global(int g, int u, size_t i) = 0; /** Obtain the local size for the g-th dimension */ using multi_partitioning<D, G>::local_size; virtual size_t local_size(int g, int u) = 0; }; } // namespace bulk
; A296028: Characteristic function of primes in the nonmultiples of 3. ; 0,1,0,1,1,0,0,1,1,0,0,1,1,0,0,1,0,0,0,1,1,0,0,0,1,0,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,1,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1 mul $0,3 div $0,2 seq $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
/* * Copyright (c) 2012-2013, 2015-2016 ARM Limited * All rights reserved. * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Copyright (c) 2003-2005 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Erik Hallnor * Steve Reinhardt * Ron Dreslinski */ /** * @file * Declares a basic cache interface BaseCache. */ #ifndef __MEM_CACHE_BASE_HH__ #define __MEM_CACHE_BASE_HH__ #include <algorithm> #include <list> #include <string> #include <vector> #include "base/misc.hh" #include "base/statistics.hh" #include "base/trace.hh" #include "base/types.hh" #include "debug/Cache.hh" #include "debug/CachePort.hh" #include "mem/cache/mshr_queue.hh" #include "mem/cache/write_queue.hh" #include "mem/mem_object.hh" #include "mem/packet.hh" #include "mem/qport.hh" #include "mem/request.hh" #include "params/BaseCache.hh" #include "sim/eventq.hh" #include "sim/full_system.hh" #include "sim/sim_exit.hh" #include "sim/system.hh" /** * A basic cache interface. Implements some common functions for speed. */ class BaseCache : public MemObject { protected: /** * Indexes to enumerate the MSHR queues. */ enum MSHRQueueIndex { MSHRQueue_MSHRs, MSHRQueue_WriteBuffer }; public: /** * Reasons for caches to be blocked. */ enum BlockedCause { Blocked_NoMSHRs = MSHRQueue_MSHRs, Blocked_NoWBBuffers = MSHRQueue_WriteBuffer, Blocked_NoTargets, NUM_BLOCKED_CAUSES }; protected: /** * A cache master port is used for the memory-side port of the * cache, and in addition to the basic timing port that only sends * response packets through a transmit list, it also offers the * ability to schedule and send request packets (requests & * writebacks). The send event is scheduled through schedSendEvent, * and the sendDeferredPacket of the timing port is modified to * consider both the transmit list and the requests from the MSHR. */ class CacheMasterPort : public QueuedMasterPort { public: /** * Schedule a send of a request packet (from the MSHR). Note * that we could already have a retry outstanding. */ void schedSendEvent(Tick time) { DPRINTF(CachePort, "Scheduling send event at %llu\n", time); reqQueue.schedSendEvent(time); } protected: CacheMasterPort(const std::string &_name, BaseCache *_cache, ReqPacketQueue &_reqQueue, SnoopRespPacketQueue &_snoopRespQueue) : QueuedMasterPort(_name, _cache, _reqQueue, _snoopRespQueue) { } /** * Memory-side port always snoops. * * @return always true */ virtual bool isSnooping() const { return true; } }; /** * A cache slave port is used for the CPU-side port of the cache, * and it is basically a simple timing port that uses a transmit * list for responses to the CPU (or connected master). In * addition, it has the functionality to block the port for * incoming requests. If blocked, the port will issue a retry once * unblocked. */ class CacheSlavePort : public QueuedSlavePort { public: /** Do not accept any new requests. */ void setBlocked(); /** Return to normal operation and accept new requests. */ void clearBlocked(); bool isBlocked() const { return blocked; } protected: CacheSlavePort(const std::string &_name, BaseCache *_cache, const std::string &_label); /** A normal packet queue used to store responses. */ RespPacketQueue queue; bool blocked; bool mustSendRetry; private: void processSendRetry(); EventWrapper<CacheSlavePort, &CacheSlavePort::processSendRetry> sendRetryEvent; }; CacheSlavePort *cpuSidePort; CacheMasterPort *memSidePort; protected: /** Miss status registers */ MSHRQueue mshrQueue; /** Write/writeback buffer */ WriteQueue writeBuffer; /** * Mark a request as in service (sent downstream in the memory * system), effectively making this MSHR the ordering point. */ void markInService(MSHR *mshr, bool pending_modified_resp) { bool wasFull = mshrQueue.isFull(); mshrQueue.markInService(mshr, pending_modified_resp); if (wasFull && !mshrQueue.isFull()) { clearBlocked(Blocked_NoMSHRs); } } void markInService(WriteQueueEntry *entry) { bool wasFull = writeBuffer.isFull(); writeBuffer.markInService(entry); if (wasFull && !writeBuffer.isFull()) { clearBlocked(Blocked_NoWBBuffers); } } /** * Determine if we should allocate on a fill or not. * * @param cmd Packet command being added as an MSHR target * * @return Whether we should allocate on a fill or not */ virtual bool allocOnFill(MemCmd cmd) const = 0; /** * Write back dirty blocks in the cache using functional accesses. */ virtual void memWriteback() = 0; /** * Invalidates all blocks in the cache. * * @warn Dirty cache lines will not be written back to * memory. Make sure to call functionalWriteback() first if you * want the to write them to memory. */ virtual void memInvalidate() = 0; /** * Determine if there are any dirty blocks in the cache. * * \return true if at least one block is dirty, false otherwise. */ virtual bool isDirty() const = 0; /** * Determine if an address is in the ranges covered by this * cache. This is useful to filter snoops. * * @param addr Address to check against * * @return If the address in question is in range */ bool inRange(Addr addr) const; /** Block size of this cache */ const unsigned blkSize; /** * The latency of tag lookup of a cache. It occurs when there is * an access to the cache. */ const Cycles lookupLatency; /** * This is the forward latency of the cache. It occurs when there * is a cache miss and a request is forwarded downstream, in * particular an outbound miss. */ const Cycles forwardLatency; /** The latency to fill a cache block */ const Cycles fillLatency; /** * The latency of sending reponse to its upper level cache/core on * a linefill. The responseLatency parameter captures this * latency. */ const Cycles responseLatency; /** The number of targets for each MSHR. */ const int numTarget; /** Do we forward snoops from mem side port through to cpu side port? */ bool forwardSnoops; /** * Is this cache read only, for example the instruction cache, or * table-walker cache. A cache that is read only should never see * any writes, and should never get any dirty data (and hence * never have to do any writebacks). */ const bool isReadOnly; /** * Bit vector of the blocking reasons for the access path. * @sa #BlockedCause */ uint8_t blocked; /** Increasing order number assigned to each incoming request. */ uint64_t order; /** Stores time the cache blocked for statistics. */ Cycles blockedCycle; /** Pointer to the MSHR that has no targets. */ MSHR *noTargetMSHR; /** The number of misses to trigger an exit event. */ Counter missCount; /** * The address range to which the cache responds on the CPU side. * Normally this is all possible memory addresses. */ const AddrRangeList addrRanges; public: /** System we are currently operating in. */ System *system; // Statistics /** * @addtogroup CacheStatistics * @{ */ /** Number of hits per thread for each type of command. @sa Packet::Command */ Stats::Vector hits[MemCmd::NUM_MEM_CMDS]; /** Number of hits for demand accesses. */ Stats::Formula demandHits; /** Number of hit for all accesses. */ Stats::Formula overallHits; /** Number of misses per thread for each type of command. @sa Packet::Command */ Stats::Vector misses[MemCmd::NUM_MEM_CMDS]; /** Number of misses for demand accesses. */ Stats::Formula demandMisses; /** Number of misses for all accesses. */ Stats::Formula overallMisses; /** * Total number of cycles per thread/command spent waiting for a miss. * Used to calculate the average miss latency. */ Stats::Vector missLatency[MemCmd::NUM_MEM_CMDS]; /** Total number of cycles spent waiting for demand misses. */ Stats::Formula demandMissLatency; /** Total number of cycles spent waiting for all misses. */ Stats::Formula overallMissLatency; /** The number of accesses per command and thread. */ Stats::Formula accesses[MemCmd::NUM_MEM_CMDS]; /** The number of demand accesses. */ Stats::Formula demandAccesses; /** The number of overall accesses. */ Stats::Formula overallAccesses; /** The miss rate per command and thread. */ Stats::Formula missRate[MemCmd::NUM_MEM_CMDS]; /** The miss rate of all demand accesses. */ Stats::Formula demandMissRate; /** The miss rate for all accesses. */ Stats::Formula overallMissRate; /** The average miss latency per command and thread. */ Stats::Formula avgMissLatency[MemCmd::NUM_MEM_CMDS]; /** The average miss latency for demand misses. */ Stats::Formula demandAvgMissLatency; /** The average miss latency for all misses. */ Stats::Formula overallAvgMissLatency; /** The total number of cycles blocked for each blocked cause. */ Stats::Vector blocked_cycles; /** The number of times this cache blocked for each blocked cause. */ Stats::Vector blocked_causes; /** The average number of cycles blocked for each blocked cause. */ Stats::Formula avg_blocked; /** The number of times a HW-prefetched block is evicted w/o reference. */ Stats::Scalar unusedPrefetches; /** Number of blocks written back per thread. */ Stats::Vector writebacks; /** Number of misses that hit in the MSHRs per command and thread. */ Stats::Vector mshr_hits[MemCmd::NUM_MEM_CMDS]; /** Demand misses that hit in the MSHRs. */ Stats::Formula demandMshrHits; /** Total number of misses that hit in the MSHRs. */ Stats::Formula overallMshrHits; /** Number of misses that miss in the MSHRs, per command and thread. */ Stats::Vector mshr_misses[MemCmd::NUM_MEM_CMDS]; /** Demand misses that miss in the MSHRs. */ Stats::Formula demandMshrMisses; /** Total number of misses that miss in the MSHRs. */ Stats::Formula overallMshrMisses; /** Number of misses that miss in the MSHRs, per command and thread. */ Stats::Vector mshr_uncacheable[MemCmd::NUM_MEM_CMDS]; /** Total number of misses that miss in the MSHRs. */ Stats::Formula overallMshrUncacheable; /** Total cycle latency of each MSHR miss, per command and thread. */ Stats::Vector mshr_miss_latency[MemCmd::NUM_MEM_CMDS]; /** Total cycle latency of demand MSHR misses. */ Stats::Formula demandMshrMissLatency; /** Total cycle latency of overall MSHR misses. */ Stats::Formula overallMshrMissLatency; /** Total cycle latency of each MSHR miss, per command and thread. */ Stats::Vector mshr_uncacheable_lat[MemCmd::NUM_MEM_CMDS]; /** Total cycle latency of overall MSHR misses. */ Stats::Formula overallMshrUncacheableLatency; #if 0 /** The total number of MSHR accesses per command and thread. */ Stats::Formula mshrAccesses[MemCmd::NUM_MEM_CMDS]; /** The total number of demand MSHR accesses. */ Stats::Formula demandMshrAccesses; /** The total number of MSHR accesses. */ Stats::Formula overallMshrAccesses; #endif /** The miss rate in the MSHRs pre command and thread. */ Stats::Formula mshrMissRate[MemCmd::NUM_MEM_CMDS]; /** The demand miss rate in the MSHRs. */ Stats::Formula demandMshrMissRate; /** The overall miss rate in the MSHRs. */ Stats::Formula overallMshrMissRate; /** The average latency of an MSHR miss, per command and thread. */ Stats::Formula avgMshrMissLatency[MemCmd::NUM_MEM_CMDS]; /** The average latency of a demand MSHR miss. */ Stats::Formula demandAvgMshrMissLatency; /** The average overall latency of an MSHR miss. */ Stats::Formula overallAvgMshrMissLatency; /** The average latency of an MSHR miss, per command and thread. */ Stats::Formula avgMshrUncacheableLatency[MemCmd::NUM_MEM_CMDS]; /** The average overall latency of an MSHR miss. */ Stats::Formula overallAvgMshrUncacheableLatency; /** * @} */ /** * Register stats for this object. */ virtual void regStats(); public: BaseCache(const BaseCacheParams *p, unsigned blk_size); ~BaseCache() {} virtual void init(); virtual BaseMasterPort &getMasterPort(const std::string &if_name, PortID idx = InvalidPortID); virtual BaseSlavePort &getSlavePort(const std::string &if_name, PortID idx = InvalidPortID); /** * Query block size of a cache. * @return The block size */ unsigned getBlockSize() const { return blkSize; } Addr blockAlign(Addr addr) const { return (addr & ~(Addr(blkSize - 1))); } const AddrRangeList &getAddrRanges() const { return addrRanges; } MSHR *allocateMissBuffer(PacketPtr pkt, Tick time, bool sched_send = true) { MSHR *mshr = mshrQueue.allocate(blockAlign(pkt->getAddr()), blkSize, pkt, time, order++, allocOnFill(pkt->cmd)); if (mshrQueue.isFull()) { setBlocked((BlockedCause)MSHRQueue_MSHRs); } if (sched_send) { // schedule the send schedMemSideSendEvent(time); } return mshr; } void allocateWriteBuffer(PacketPtr pkt, Tick time) { // should only see writes or clean evicts here assert(pkt->isWrite() || pkt->cmd == MemCmd::CleanEvict); Addr blk_addr = blockAlign(pkt->getAddr()); WriteQueueEntry *wq_entry = writeBuffer.findMatch(blk_addr, pkt->isSecure()); if (wq_entry && !wq_entry->inService) { DPRINTF(Cache, "Potential to merge writeback %s to %#llx", pkt->cmdString(), pkt->getAddr()); } writeBuffer.allocate(blk_addr, blkSize, pkt, time, order++); if (writeBuffer.isFull()) { setBlocked((BlockedCause)MSHRQueue_WriteBuffer); } // schedule the send schedMemSideSendEvent(time); } /** * Returns true if the cache is blocked for accesses. */ bool isBlocked() const { return blocked != 0; } /** * Marks the access path of the cache as blocked for the given cause. This * also sets the blocked flag in the slave interface. * @param cause The reason for the cache blocking. */ void setBlocked(BlockedCause cause) { uint8_t flag = 1 << cause; if (blocked == 0) { blocked_causes[cause]++; blockedCycle = curCycle(); cpuSidePort->setBlocked(); } blocked |= flag; DPRINTF(Cache,"Blocking for cause %d, mask=%d\n", cause, blocked); } /** * Marks the cache as unblocked for the given cause. This also clears the * blocked flags in the appropriate interfaces. * @param cause The newly unblocked cause. * @warning Calling this function can cause a blocked request on the bus to * access the cache. The cache must be in a state to handle that request. */ void clearBlocked(BlockedCause cause) { uint8_t flag = 1 << cause; blocked &= ~flag; DPRINTF(Cache,"Unblocking for cause %d, mask=%d\n", cause, blocked); if (blocked == 0) { blocked_cycles[cause] += curCycle() - blockedCycle; cpuSidePort->clearBlocked(); } } /** * Schedule a send event for the memory-side port. If already * scheduled, this may reschedule the event at an earlier * time. When the specified time is reached, the port is free to * send either a response, a request, or a prefetch request. * * @param time The time when to attempt sending a packet. */ void schedMemSideSendEvent(Tick time) { memSidePort->schedSendEvent(time); } virtual bool inCache(Addr addr, bool is_secure) const = 0; virtual bool inMissQueue(Addr addr, bool is_secure) const = 0; void incMissCount(PacketPtr pkt) { assert(pkt->req->masterId() < system->maxMasters()); misses[pkt->cmdToIndex()][pkt->req->masterId()]++; pkt->req->incAccessDepth(); if (missCount) { --missCount; if (missCount == 0) exitSimLoop("A cache reached the maximum miss count"); } } void incHitCount(PacketPtr pkt) { assert(pkt->req->masterId() < system->maxMasters()); hits[pkt->cmdToIndex()][pkt->req->masterId()]++; } }; #endif //__MEM_CACHE_BASE_HH__
* * $Id: amiga_hookentry.asm,v 1.3 2006-01-08 12:04:22 obarthel Exp $ * * :ts=8 * * Portable ISO 'C' (1994) runtime library for the Amiga computer * Copyright (c) 2002-2015 by Olaf Barthel <obarthel (at) gmx.net> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Neither the name of Olaf Barthel nor the names of contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * section text,code h_SubEntry equ 12 xdef _HookEntry _HookEntry: move.l a1,-(sp) move.l a2,-(sp) move.l a0,-(sp) move.l h_SubEntry(a0),a0 jsr (a0) lea 12(sp),sp rts end
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "sagbitconsensus.h" #include "primitives/transaction.h" #include "pubkey.h" #include "script/interpreter.h" #include "version.h" namespace { /** A class that deserializes a single CTransaction one time. */ class TxInputStream { public: TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen) : m_type(nTypeIn), m_version(nVersionIn), m_data(txTo), m_remaining(txToLen) {} TxInputStream& read(char* pch, size_t nSize) { if (nSize > m_remaining) throw std::ios_base::failure(std::string(__func__) + ": end of data"); if (pch == NULL) throw std::ios_base::failure(std::string(__func__) + ": bad destination buffer"); if (m_data == NULL) throw std::ios_base::failure(std::string(__func__) + ": bad source buffer"); memcpy(pch, m_data, nSize); m_remaining -= nSize; m_data += nSize; return *this; } template<typename T> TxInputStream& operator>>(T& obj) { ::Unserialize(*this, obj, m_type, m_version); return *this; } private: const int m_type; const int m_version; const unsigned char* m_data; size_t m_remaining; }; inline int set_error(sagbitconsensus_error* ret, sagbitconsensus_error serror) { if (ret) *ret = serror; return 0; } struct ECCryptoClosure { ECCVerifyHandle handle; }; ECCryptoClosure instance_of_eccryptoclosure; } int sagbitconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, const unsigned char *txTo , unsigned int txToLen, unsigned int nIn, unsigned int flags, sagbitconsensus_error* err) { try { TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen); CTransaction tx; stream >> tx; if (nIn >= tx.vin.size()) return set_error(err, sagbitconsensus_ERR_TX_INDEX); if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen) return set_error(err, sagbitconsensus_ERR_TX_SIZE_MISMATCH); // Regardless of the verification result, the tx did not error. set_error(err, sagbitconsensus_ERR_OK); return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, TransactionSignatureChecker(&tx, nIn), NULL); } catch (const std::exception&) { return set_error(err, sagbitconsensus_ERR_TX_DESERIALIZE); // Error deserializing } } unsigned int sagbitconsensus_version() { // Just use the API version for now return SAGBITCONSENSUS_API_VER; }
/* * This file is a part of the open source stm32plus library. * Copyright (c) 2011,2012,2013,2014 Andy Brown <www.andybrown.me.uk> * Please see website for licensing terms. */ #include "config/stm32plus.h" #include "config/filesystem.h" namespace stm32plus { namespace fat { /** * Constructor. * @param[in] fs_ The filesystem reference for this iterator. * @param[in] options_ Options that control how to iterator over this directory. */ Fat16RootDirectoryEntryIterator::Fat16RootDirectoryEntryIterator(FatFileSystem& fs_,Options options_) : DirectoryEntryIterator(fs_,options_), _currentSector(fs_.getBootSector().BPB_BytsPerSec) { _entriesPerSector=_fs.getBootSector().BPB_BytsPerSec/sizeof(DirectoryEntry); _rootDirMaxEntries=_fs.getBootSector().BPB_RootEntCnt; reset(); } /* * reset the iteration */ void Fat16RootDirectoryEntryIterator::reset() { _currentIndex=-1; _firstEntryInCurrentSector=-1; } /* * Get the byte offset into the sector of this entry */ uint32_t Fat16RootDirectoryEntryIterator::entryOffsetInSector(uint32_t entryIndex_) const { return (entryIndex_%_entriesPerSector)*sizeof(DirectoryEntry); } /* * Return true if the current entry is in the current sector. * Assumes _currentIndex!=-1 and _firstEntryInCurrentSector!=-1 */ bool Fat16RootDirectoryEntryIterator::isEntryInCurrentSector() const { return _currentIndex-_firstEntryInCurrentSector<_entriesPerSector; } /* * Get the sector index for the given entry */ uint32_t Fat16RootDirectoryEntryIterator::sectorIndexForEntry(uint32_t entryIndex_) const { return _fs.getRootDirectoryFirstSector()+(entryIndex_/_entriesPerSector); } /* * Move to next entry */ bool Fat16RootDirectoryEntryIterator::internalNext() { uint32_t offset; // update to next entry, or zero if this is the first move _currentIndex++; // check for the end of this fixed length structure if(_currentIndex==_rootDirMaxEntries) return errorProvider.set(ErrorProvider::ERROR_PROVIDER_ITERATOR,E_END_OF_ENTRIES); // first time? if(_currentIndex==0||!isEntryInCurrentSector()) { // current index is not in the cached sector, read new sector if(!readSectorForEntry(_currentIndex)) return false; } // get the offset into the sector and copy offset=entryOffsetInSector(_currentIndex); memcpy(&_currentEntry.Dirent,static_cast<uint8_t *> (_currentSector)+offset,sizeof(DirectoryEntry)); _currentEntry.SectorNumber=sectorIndexForEntry(_currentIndex); _currentEntry.IndexWithinSector=_currentIndex%_entriesPerSector; // check for end-of-entries if((_currentEntry.Dirent.sdir.DIR_Attr&DirectoryEntry::ATTR_LONG_NAME_MASK)!=DirectoryEntry::ATTR_LONG_NAME&&_currentEntry.Dirent.sdir.DIR_Name[0]=='\0') return errorProvider.set(ErrorProvider::ERROR_PROVIDER_ITERATOR,E_END_OF_ENTRIES); return true; } /* * Read a sector for the given entry index */ bool Fat16RootDirectoryEntryIterator::readSectorForEntry(uint32_t entryIndex_) { uint32_t sectorIndex; // check if reached the end if(entryIndex_/_entriesPerSector>=((Fat16FileSystem&)_fs).getRootDirSectors()) return false; sectorIndex=sectorIndexForEntry(entryIndex_); return _fs.readSector(sectorIndex,_currentSector); } /* * 'extend' the directory to include space for new entries. The directory has a fixed number sectors * so we cannot allocate more if the end is reached */ bool Fat16RootDirectoryEntryIterator::extendDirectory(DirectoryEntry *dirents_,uint32_t direntCount_) { DirectoryEntryWithLocation dloc; uint32_t i; // go to the end reset(); while(next()) ; if(!errorProvider.isLastError(ErrorProvider::ERROR_PROVIDER_ITERATOR,Iterator<DirectoryEntryWithLocation>::E_END_OF_ENTRIES)) return false; // have we got space? if(_currentIndex>_rootDirMaxEntries-direntCount_) return errorProvider.set(ErrorProvider::ERROR_PROVIDER_ITERATOR,E_ROOT_DIRECTORY_FULL); for(i=0;i<=direntCount_;i++) { if(_currentIndex+i<_rootDirMaxEntries) { // may not be space for the end marker dloc.SectorNumber=sectorIndexForEntry(_currentIndex+i); dloc.IndexWithinSector=(_currentIndex+i)%_entriesPerSector; if(i==direntCount_) memset(&dloc.Dirent,0,sizeof(dloc.Dirent)); // end of entries marker else dloc.Dirent=dirents_[i]; // struct copy if(!_fs.writeDirectoryEntry(dloc)) return false; } } return true; } } }
IDEAL SEGMENT CODE1 ASSUME CS:GROUP1 ORG 100h start: mov di, OFFSET data1 int 20h ENDS CODE1 SEGMENT UDATA1 UNINIT data1 DD ? ENDS UDATA1 GROUP GROUP1 CODE1,UDATA1 END start
#ifndef STAN_MATH_REV_SCAL_FUN_PHI_HPP #define STAN_MATH_REV_SCAL_FUN_PHI_HPP #include <stan/math/rev/meta.hpp> #include <stan/math/rev/core.hpp> #include <stan/math/prim/scal/fun/Phi.hpp> #include <cmath> namespace stan { namespace math { namespace internal { class Phi_vari : public op_v_vari { public: explicit Phi_vari(vari* avi) : op_v_vari(Phi(avi->val_), avi) {} void chain() { static const double NEG_HALF = -0.5; avi_->adj_ += adj_ * INV_SQRT_TWO_PI * std::exp(NEG_HALF * avi_->val_ * avi_->val_); } }; } // namespace internal /** * The unit normal cumulative density function for variables (stan). * * See Phi() for the double-based version. * * The derivative is the unit normal density function, * * \f$\frac{d}{dx} \Phi(x) = \mbox{\sf Norm}(x|0, 1) = \frac{1}{\sqrt{2\pi}} \exp(-\frac{1}{2} x^2)\f$. * * \f[ \mbox{Phi}(x) = \begin{cases} 0 & \mbox{if } x < -37.5 \\ \Phi(x) & \mbox{if } -37.5 \leq x \leq 8.25 \\ 1 & \mbox{if } x > 8.25 \\[6pt] \textrm{error} & \mbox{if } x = \textrm{NaN} \end{cases} \f] \f[ \frac{\partial\, \mbox{Phi}(x)}{\partial x} = \begin{cases} 0 & \mbox{if } x < -27.5 \\ \frac{\partial\, \Phi(x)}{\partial x} & \mbox{if } -27.5 \leq x \leq 27.5 \\ 0 & \mbox{if } x > 27.5 \\[6pt] \textrm{error} & \mbox{if } x = \textrm{NaN} \end{cases} \f] \f[ \Phi(x) = \frac{1}{\sqrt{2\pi}} \int_{0}^{x} e^{-t^2/2} dt \f] \f[ \frac{\partial \, \Phi(x)}{\partial x} = \frac{e^{-x^2/2}}{\sqrt{2\pi}} \f] * * @param a Variable argument. * @return The unit normal cdf evaluated at the specified argument. */ inline var Phi(const var& a) { return var(new internal::Phi_vari(a.vi_)); } } // namespace math } // namespace stan #endif
class Solution { public: int XXX(string s) { string roma1 = "MDCLXVI"; int num_basic[7] = {1000,500,100,50,10,5,1}; int num = 0; int len = s.length(); for(int i = 0; i < len; i++) { for (int j = 0; j < 7; j++) { if(s[i] == roma1[j] ) { num += num_basic[j]; cout << num << endl; if ( i > 0) { if ((s[i] == roma1[0] || s[i] == roma1[1]) && s[i-1] == roma1[2]) { num -= 200; } else if ((s[i] == roma1[2] || s[i] == roma1[3]) && s[i-1] == roma1[4]) { num -= 20; } else if ((s[i] == roma1[4] || s[i] == roma1[5]) && s[i-1] == roma1[6]) { num -= 2; } } } } } return num; } };
; ============================================================================= ; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems ; Copyright (C) 2008-2014 Return Infinity -- see LICENSE.TXT ; ; System Variables ; ============================================================================= ;CONFIG cfg_smpinit: db 1 ; By default SMP is enabled. Set to 0 to disable. cfg_vesa: db 1 ; By default VESA is disabled. Set to 1 to enable. cfg_default: db 0 ; By default we don't need a config file so set to 0. If a config file is found set to 1. cfg_e820: db 1 ; By default E820 should be present. Pure64 will set this to 0 if not found/usable. cfg_mbr: db 0 ; Did we boot off of a disk with a proper MBR cfg_hdd: db 0 ; Was a bootable drive detected ; Memory locations E820Map: equ 0x0000000000004000 InfoMap: equ 0x0000000000005000 SystemVariables: equ 0x0000000000005A00 VBEModeInfoBlock: equ 0x0000000000005C00 ; 256 bytes ahci_cmdlist: equ 0x0000000000070000 ; 4096 bytes 0x070000 -> 0x071FFF ahci_cmdtable: equ 0x0000000000072000 ; 57344 bytes 0x072000 -> 0x07FFFF ; DQ - Starting at offset 0, increments by 0x8 os_ACPITableAddress: equ SystemVariables + 0x00 screen_cursor_offset: equ SystemVariables + 0x08 os_LocalX2APICAddress: equ SystemVariables + 0x10 os_Counter_Timer: equ SystemVariables + 0x18 os_Counter_RTC: equ SystemVariables + 0x20 os_LocalAPICAddress: equ SystemVariables + 0x28 os_IOAPICAddress: equ SystemVariables + 0x30 os_HPETAddress: equ SystemVariables + 0x38 ; DD - Starting at offset 128, increments by 4 os_BSP: equ SystemVariables + 128 mem_amount: equ SystemVariables + 132 os_VideoBase: equ SystemVariables + 136 ; DW - Starting at offset 256, increments by 2 cpu_speed: equ SystemVariables + 256 cpu_activated: equ SystemVariables + 258 cpu_detected: equ SystemVariables + 260 ; DB - Starting at offset 384, increments by 1 screen_cursor_x: equ SystemVariables + 386 screen_cursor_y: equ SystemVariables + 387 memtempstring: equ SystemVariables + 390 speedtempstring: equ SystemVariables + 400 cpu_amount_string: equ SystemVariables + 410 os_key: equ SystemVariables + 421 os_IOAPICCount: equ SystemVariables + 424 ;MISC screen_cols: db 80 screen_rows: db 25 hextable: db '0123456789ABCDEF' ;STRINGS msg_initializing: db 'Pure64 v0.6.1 - www.returninfinity.com', 13, 10, 13, 10, 'Initializing system... ', 0 msg_done: db ' Done', 0 msg_CPU: db '[CPU: ', 0 msg_mhz: db 'MHz x', 0 msg_MEM: db '] [MEM: ', 0 msg_mb: db ' MiB]', 0 msg_startingkernel: db 'Starting kernel...', 13, 13, 0 msg_no64: db 'ERROR: This computer does not support 64-bit mode.', 0 msg_novesa: db 'VESA error', 0 ; VESA ; Mandatory information for all VBE revisions VBEModeInfoBlock.ModeAttributes equ VBEModeInfoBlock + 0 ; DW - mode attributes VBEModeInfoBlock.WinAAttributes equ VBEModeInfoBlock + 2 ; DB - window A attributes VBEModeInfoBlock.WinBAttributes equ VBEModeInfoBlock + 3 ; DB - window B attributes VBEModeInfoBlock.WinGranularity equ VBEModeInfoBlock + 4 ; DW - window granularity in KB VBEModeInfoBlock.WinSize equ VBEModeInfoBlock + 6 ; DW - window size in KB VBEModeInfoBlock.WinASegment equ VBEModeInfoBlock + 8 ; DW - window A start segment VBEModeInfoBlock.WinBSegment equ VBEModeInfoBlock + 10 ; DW - window B start segment VBEModeInfoBlock.WinFuncPtr equ VBEModeInfoBlock + 12 ; DD - real mode pointer to window function VBEModeInfoBlock.BytesPerScanLine equ VBEModeInfoBlock + 16 ; DW - bytes per scan line ; Mandatory information for VBE 1.2 and above VBEModeInfoBlock.XResolution equ VBEModeInfoBlock + 18 ; DW - horizontal resolution in pixels or characters VBEModeInfoBlock.YResolution equ VBEModeInfoBlock + 20 ; DW - vertical resolution in pixels or characters VBEModeInfoBlock.XCharSize equ VBEModeInfoBlock + 22 ; DB - character cell width in pixels VBEModeInfoBlock.YCharSize equ VBEModeInfoBlock + 23 ; DB - character cell height in pixels VBEModeInfoBlock.NumberOfPlanes equ VBEModeInfoBlock + 24 ; DB - number of memory planes VBEModeInfoBlock.BitsPerPixel equ VBEModeInfoBlock + 25 ; DB - bits per pixel VBEModeInfoBlock.NumberOfBanks equ VBEModeInfoBlock + 26 ; DB - number of banks VBEModeInfoBlock.MemoryModel equ VBEModeInfoBlock + 27 ; DB - memory model type VBEModeInfoBlock.BankSize equ VBEModeInfoBlock + 28 ; DB - bank size in KB VBEModeInfoBlock.NumberOfImagePages equ VBEModeInfoBlock + 29 ; DB - number of image pages VBEModeInfoBlock.Reserved equ VBEModeInfoBlock + 30 ; DB - reserved (0x00 for VBE 1.0-2.0, 0x01 for VBE 3.0) ; Direct Color fields (required for direct/6 and YUV/7 memory models) VBEModeInfoBlock.RedMaskSize equ VBEModeInfoBlock + 31 ; DB - size of direct color red mask in bits VBEModeInfoBlock.RedFieldPosition equ VBEModeInfoBlock + 32 ; DB - bit position of lsb of red mask VBEModeInfoBlock.GreenMaskSize equ VBEModeInfoBlock + 33 ; DB - size of direct color green mask in bits VBEModeInfoBlock.GreenFieldPosition equ VBEModeInfoBlock + 34 ; DB - bit position of lsb of green mask VBEModeInfoBlock.BlueMaskSize equ VBEModeInfoBlock + 35 ; DB - size of direct color blue mask in bits VBEModeInfoBlock.BlueFieldPosition equ VBEModeInfoBlock + 36 ; DB - bit position of lsb of blue mask VBEModeInfoBlock.RsvdMaskSize equ VBEModeInfoBlock + 37 ; DB - size of direct color reserved mask in bits VBEModeInfoBlock.RsvdFieldPosition equ VBEModeInfoBlock + 38 ; DB - bit position of lsb of reserved mask VBEModeInfoBlock.DirectColorModeInfo equ VBEModeInfoBlock + 39 ; DB - direct color mode attributes ; Mandatory information for VBE 2.0 and above VBEModeInfoBlock.PhysBasePtr equ VBEModeInfoBlock + 40 ; DD - physical address for flat memory frame buffer VBEModeInfoBlock.Reserved1 equ VBEModeInfoBlock + 44 ; DD - Reserved - always set to 0 VBEModeInfoBlock.Reserved2 equ VBEModeInfoBlock + 48 ; DD - Reserved - always set to 0 ; ----------------------------------------------------------------------------- align 16 GDTR64: ; Global Descriptors Table Register dw gdt64_end - gdt64 - 1 ; limit of GDT (size minus one) dq 0x0000000000001000 ; linear address of GDT gdt64: ; This structure is copied to 0x0000000000001000 SYS64_NULL_SEL equ $-gdt64 ; Null Segment dq 0x0000000000000000 SYS64_CODE_SEL equ $-gdt64 ; Code segment, read/execute, nonconforming dq 0x0020980000000000 ; 0x00209A0000000000 SYS64_DATA_SEL equ $-gdt64 ; Data segment, read/write, expand down dq 0x0000900000000000 ; 0x0020920000000000 gdt64_end: IDTR64: ; Interrupt Descriptor Table Register dw 256*16-1 ; limit of IDT (size minus one) (4096 bytes - 1) dq 0x0000000000000000 ; linear address of IDT ; ----------------------------------------------------------------------------- ; ============================================================================= ; EOF
; A088679: a(n) = a(n-1)^2 * n / (n-1), n>1, a(0) = 0, a(1) = 1. ; Submitted by Jon Maiga ; 0,1,2,6,48,2880,9953280,115579079884800,15266884236590834264309760000,262212473580148912869121218589990322256745385164800000000 mov $2,1 lpb $0 sub $0,1 pow $1,2 add $1,$2 mul $2,$1 lpe mov $0,$1
; A076367: Primes with subscripts from the Bonse sequence. ; 2,3,3,5,5,5,7,7,7,11,11,11,11,11,13,13,13,17,17,17,17,17,19,19,19,23,23,23,23,23,29,29,29,29,29,29,29,31,31,31,37,37,37,37,37,37,37,41,41,41,41,41,43,43,43,47,47,47,47,47,53,53,53,53,53,53,53,59,59,59,59,59 mov $2,$0 add $2,1 pow $2,2 add $2,1 lpb $2 trn $0,1 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 sub $2,1 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 mov $5,$1 cmp $5,0 add $1,$5 add $1,1 lpe mov $0,$1
format ELF64 executable 3 entry start segment readable writeable msg db 'Hello the brave to the isekai!', 0Ah, 0 msgf db 'Adapt to the new environment with FASM.', 0Ah, 0 segment readable executable start: mov rax, msg call sprint mov rax, msgf call sprint call quitProgram include 'procs.inc'
Music_WildBattle_Ch0:: tempo 104 volume 7, 7 duty 3 vibrato 6, 3, 4 toggleperfectpitch notetype 12, 11, 3 octave 4 C_ 1 octave 3 B_ 1 A# 1 A_ 1 A# 1 A_ 1 G# 1 G_ 1 G# 1 G_ 1 F# 1 F_ 1 F# 1 F_ 1 E_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 C# 1 C_ 1 octave 2 B_ 1 octave 3 C_ 1 octave 2 B_ 1 A# 1 A_ 1 A# 1 B_ 1 octave 3 C_ 1 C# 1 notetype 12, 11, 1 G_ 6 E_ 6 D# 12 C# 14 E_ 6 D# 10 notetype 12, 4, 15 C# 10 notetype 12, 11, 1 G_ 6 E_ 6 D# 12 C# 14 E_ 6 D# 10 C# 10 Music_WildBattle_branch_230e0:: notetype 12, 11, 3 C# 1 D_ 1 C# 1 C_ 1 C# 1 D_ 1 C# 1 C_ 1 C# 1 D_ 1 D# 1 D_ 1 C# 1 C_ 1 octave 2 B_ 1 octave 3 C_ 1 C# 1 D_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 A_ 1 G# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 A_ 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 F_ 1 E_ 1 D# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 F_ 1 E_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 A_ 1 G# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 A_ 1 G# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 A_ 1 G# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 D_ 1 C# 1 D_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 F# 1 F_ 1 E_ 1 D# 1 E_ 1 F_ 1 F# 1 G_ 1 G# 1 notetype 12, 11, 5 D_ 4 C_ 4 D_ 4 F_ 4 E_ 6 D_ 6 F_ 4 notetype 12, 11, 7 A_ 16 G_ 16 notetype 12, 11, 5 D_ 4 C_ 4 D_ 4 F_ 4 G_ 6 A_ 6 B_ 4 notetype 12, 11, 7 octave 4 C_ 16 notetype 12, 3, 15 G_ 16 notetype 12, 11, 5 octave 3 C_ 12 C_ 2 rest 2 D_ 2 C_ 2 rest 12 C# 12 C# 2 rest 2 F_ 2 notetype 12, 10, 3 D# 6 notetype 12, 10, 7 C# 8 loopchannel 0, Music_WildBattle_branch_230e0 Music_WildBattle_Ch1:: duty 3 vibrato 8, 2, 5 notetype 12, 12, 3 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 octave 4 G_ 1 F# 1 F_ 1 octave 5 G_ 1 notetype 12, 12, 2 octave 4 G_ 6 octave 3 G_ 6 G_ 12 G_ 14 G_ 6 G_ 10 notetype 12, 9, 0 F# 10 notetype 12, 12, 2 G_ 6 G_ 6 G_ 12 G_ 14 G_ 6 G_ 10 G_ 10 Music_WildBattle_branch_23225:: notetype 12, 12, 5 G_ 6 F# 6 E_ 4 G_ 6 A_ 6 G_ 4 octave 4 G# 12 G_ 2 rest 2 G# 2 G_ 2 rest 4 notetype 12, 11, 7 octave 5 C# 8 notetype 12, 12, 5 octave 4 C_ 6 octave 3 A# 6 G# 4 octave 4 C# 6 C_ 6 octave 3 A# 4 octave 4 F_ 6 E_ 6 D_ 4 notetype 12, 12, 7 octave 3 A# 4 octave 4 C_ 4 D_ 4 F_ 4 notetype 12, 12, 0 G# 16 notetype 12, 11, 0 G# 16 notetype 12, 4, 14 G_ 16 notetype 12, 12, 7 G_ 16 octave 3 F_ 8 A# 8 octave 4 D_ 8 F_ 8 notetype 12, 12, 0 E_ 16 notetype 12, 12, 7 E_ 16 octave 3 F_ 8 A# 8 octave 4 D_ 8 F_ 8 notetype 12, 12, 0 G_ 16 notetype 12, 3, 15 octave 5 C_ 16 notetype 12, 12, 5 octave 4 E_ 12 E_ 2 rest 2 F_ 2 notetype 12, 12, 1 E_ 4 notetype 12, 12, 5 rest 10 F_ 12 F_ 2 rest 2 G# 2 notetype 12, 10, 3 G_ 6 notetype 12, 12, 7 F_ 8 loopchannel 0, Music_WildBattle_branch_23225 Music_WildBattle_Ch2:: vibrato 0, 2, 0 notetype 12, 1, 1 octave 4 C# 1 rest 1 C# 1 C_ 1 D_ 1 rest 1 D_ 1 C_ 1 D# 1 rest 1 D# 1 C_ 1 E_ 1 rest 1 E_ 1 C_ 1 F_ 1 rest 1 F_ 1 C_ 1 F# 1 rest 1 F# 1 C_ 1 G_ 1 rest 1 G_ 1 C_ 1 octave 3 A# 2 B_ 2 Music_WildBattle_branch_232b5:: octave 4 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C# 2 G# 2 C# 4 G# 2 A# 2 G# 2 G_ 2 C# 2 G# 2 C# 4 G# 2 A# 2 G# 2 F_ 2 loopchannel 2, Music_WildBattle_branch_232b5 Music_WildBattle_branch_232d8:: C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 G# 12 G_ 2 rest 2 G# 2 G_ 2 rest 4 F_ 2 E_ 2 D_ 2 C# 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 octave 3 A# 2 octave 4 F_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 F_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C_ 2 G_ 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 C# 2 G# 2 loopchannel 0, Music_WildBattle_branch_232d8
; A067421: Sixth column of triangle A067417. ; 1,8,144,2592,46656,839808,15116544,272097792,4897760256,88159684608,1586874322944,28563737812992,514147280633856,9254651051409408,166583718925369344,2998506940656648192,53973124931819667456,971516248772754014208,17487292477909572255744,314771264602372300603392,5665882762842701410861056,101985889731168625395499008,1835746015161035257118982144,33043428272898634628141678592,594781708912175423306550214656,10706070760419157619517903863808,192709273687544837151322269548544 add $0,2 mov $1,18 pow $1,$0 mov $0,$1 sub $0,729 div $0,729 add $0,1
; A253887: Row index of n in A191450: a(3n) = 2n, a(3n+1) = 2n+1, a(3n+2) = a(n+1). ; 1,1,2,3,1,4,5,2,6,7,3,8,9,1,10,11,4,12,13,5,14,15,2,16,17,6,18,19,7,20,21,3,22,23,8,24,25,9,26,27,1,28,29,10,30,31,11,32,33,4,34,35,12,36,37,13,38,39,5,40,41,14,42,43,15,44,45,2,46,47,16,48,49,17,50,51,6,52,53,18,54,55,19,56,57,7,58,59,20,60,61,21,62,63,3,64,65,22,66,67 mul $0,4 lpb $0 sub $0,1 mul $0,2 sub $0,6 dif $0,6 lpe div $0,6 add $0,1
; A334316: E.g.f. A(x) satisfies: A(x) = x * exp(A(x)) * (1 - A(x)). ; Submitted by Jon Maiga ; 1,0,-3,-8,45,576,385,-54144,-499527,4787200,160740261,558627840,-45943496027,-854266871808,8403892043625,590895130771456,4982009666876145,-320936968832679936,-10133752613818727987,75595253378088960000,11587542472638176520861,180588595039707930296320,-9607815555618679978587183,-477058461402304282506559488,1419625691716419283762515625,786024494197635301819312766976,19771369682309829513958640951925,-865406014014693401568795850440704,-65546339568001876435337490025279467 add $0,1 mov $2,$0 seq $0,317279 ; a(n) = Sum_{k=0..n} (-1)^(n-k)*binomial(n-1,k-1)*n^k*n!/k!. div $0,$2
global my_strlen, my_strcpy, my_strcmp, my_strcat section .data section .text my_strlen: mov rax, 0 len_loop: mov dl, [rdi + rax] inc rax cmp dl, 0 jz len_end jmp len_loop len_end: dec rax ret my_strcpy: mov r9, 0 cpy_loop: mov dl, [rsi + r9] cmp dl, 0 jz cpy_end mov [rdi + r9], dl inc r9 jmp cpy_loop cpy_end: mov byte [rdi + r9], 0 mov rax, rdi ret my_strcmp: mov r9,0 cmp_loop: cmp byte [rdi + r9], 0 jz cmp_end_ge cmp byte [rsi + r9],0 jz cmp_end_g mov dl, [rdi + r9] cmp byte dl, [rsi + r9] jg cmp_end_g cmp byte dl, [rsi + r9] jl cmp_end_l inc r9 jmp cmp_loop cmp_end_g: mov rax, 1 ret cmp_end_l: mov rax, -1 ret cmp_end_ge: cmp byte [rsi+ r9], 0 jnz cmp_end_l mov rax, 0 ret my_strcat: push rsi call my_strlen pop rsi mov r9, 0 cat_loop: cmp byte [rsi + r9], 0 jz cat_end mov byte dl,[rsi + r9] mov [rdi + rax], dl inc r9 inc rax jmp cat_loop cat_end: mov byte [rdi + rax], 0 mov rax, rdi ret
;----------------------------------------------------- ;Generate a random number ;I: bx min val ; bp max val ;O: ax random number ;----------------------------------------------------- _random_word: push dx push cx mov ax, rndseed cmp ax, 0x0000 ;check if first entry jne do_rand ; jmp if not first entry ; ; initialize the random seed ; call _random_seed do_rand: mov cx,0x04E7 ;get constant multiplier mul cx add ax,0x181D ;add constant adjustment factor adc dx,0 mov cx,0x7262 ;mod value for ranging div cx mov rndseed,dx ;store new seed ; ; now convert number to desired range ; mov ax,dx call _scale_word pop cx pop dx ret ;----------------------------------------------------- ;----------------------------------------------------- ;Scale number ;I: bx min val ; bp max val ; ax number to be scaled ;O: ax scaled number ;----------------------------------------------------- _scale_word: push cx push dx mov cx,bp sub cx,bx ;compute range delta mul cx ;(input value) * (delta) mov ax,dx add ax,bx ;result + low range = scaled number pop dx pop cx ret ;----------------------------------------------------- ;Generate random seed ;I: none ;O: ax low val of clock ;----------------------------------------------------- _random_seed push cx push bx mov bx, 0x046C mov cx,ds sub ax,ax mov ds,ax mov ax,[bx] mov ds,cx pop bx pop cx ret ;-----------------------------------------------------
BeastsCheck: ; Check if the player owns all three legendary beasts. ; They must exist in either party or PC, and have the player's OT and ID. ; Return the result in wScriptVar. ld hl, RAIKOU call GetPokemonIDFromIndex ld [wScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ld hl, ENTEI call GetPokemonIDFromIndex ld [wScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ld hl, SUICUNE call GetPokemonIDFromIndex ld [wScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ; they exist ld a, 1 ld [wScriptVar], a ret .notexist xor a ld [wScriptVar], a ret MonCheck: ; Check if the player owns any Pokémon of the species in wScriptVar. ; Return the result in wScriptVar. call CheckOwnMonAnywhere jr c, .exists ; doesn't exist xor a ld [wScriptVar], a ret .exists ld a, 1 ld [wScriptVar], a ret CheckOwnMonAnywhere: ; Check if the player owns any monsters of the species in wScriptVar. ; It must exist in either party or PC, and have the player's OT and ID. ; If there are no monsters in the party, ; the player must not own any yet. ld a, [wPartyCount] and a ret z ld d, a ld e, 0 ld hl, wPartyMon1Species ld bc, wPartyMonOT ; Run CheckOwnMon on each Pokémon in the party. .partymon and a call CheckOwnMon ret c ; found! push bc ld bc, PARTYMON_STRUCT_LENGTH add hl, bc pop bc call UpdateOTPointer dec d jr nz, .partymon ; Run CheckOwnMon on each Pokémon in the PC. ld a, BANK(sBoxCount) call GetSRAMBank ld a, [sBoxCount] and a jr z, .boxes ld d, a ld hl, sBoxMon1Species ld bc, sBoxMonOT .openboxmon and a call CheckOwnMon jr nc, .loop ; found! call CloseSRAM ret .loop push bc ld bc, BOXMON_STRUCT_LENGTH add hl, bc pop bc call UpdateOTPointer dec d jr nz, .openboxmon ; Run CheckOwnMon on each monster in the other 13 PC boxes. .boxes call CloseSRAM ld a, [wSavedAtLeastOnce] and a ret z ld c, 0 ld a, [wScriptVar] call GetPokemonIndexFromID ld d, h ld e, l .box ; Don't search the current box again. ld a, [wCurBox] and $f cp c jr z, .loopbox ; Load the box's indexes. ld hl, BoxPokemonIndexesAddressTable ld b, 0 add hl, bc add hl, bc add hl, bc ld a, [hli] ldh [hTemp], a call GetSRAMBank ld a, [hli] ld h, [hl] ld l, a .boxmon ld a, [hli] cp e ld a, [hli] jr nz, .loopboxmon cp d jr nz, .loopboxmon push hl push de push bc call GetBoxMonPointers ld a, [wTempSpecies] call IsAPokemon ccf call c, CheckOwnMon ;calls with carry set (skips species check) pop bc pop de pop hl jp c, CloseSRAM ;preserves flags ldh a, [hTemp] call GetSRAMBank .loopboxmon inc b ld a, b cp MONS_PER_BOX jr c, .boxmon .loopbox inc c ld a, c cp NUM_BOXES jr c, .box ; not found call CloseSRAM and a ret CheckOwnMon: ; Check if a Pokémon belongs to the player and is of a specific species. ; inputs: ; hl, pointer to PartyMonNSpecies ; bc, pointer to PartyMonNOT ; wScriptVar should contain the species we're looking for ; carry flag: if set, skip species check ; outputs: ; sets carry if monster matches species, ID, and OT name. push bc push hl push de ld d, b ld e, c ; check species jr c, .no_species_check ld a, [wScriptVar] ; species we're looking for ld b, [hl] ; species we have cp b jr nz, .notfound ; species doesn't match .no_species_check ; check ID number ld bc, MON_ID add hl, bc ; now hl points to ID number ld a, [wPlayerID] cp [hl] jr nz, .notfound ; ID doesn't match inc hl ld a, [wPlayerID + 1] cp [hl] jr nz, .notfound ; ID doesn't match ; check OT ; This only checks five characters, which is fine for the Japanese version, ; but in the English version the player name is 7 characters, so this is wrong. ld hl, wPlayerName rept NAME_LENGTH_JAPANESE + -2 ; should be PLAYER_NAME_LENGTH + -2 ld a, [de] cp [hl] jr nz, .notfound cp "@" jr z, .found ; reached end of string inc hl inc de endr ld a, [de] cp [hl] jr z, .found .notfound pop de pop hl pop bc and a ret .found pop de pop hl pop bc scf ret GetBoxMonPointers:: ; in: b = slot, c = box ; out: hl = pointer to mon struct, de = pointer to nickname, bc = pointer to OT ; also loads the corresponding box bank in SRAM and sets wTempSpecies to the party ID (or 0 for an empty slot) ld e, b ld b, 0 ld hl, BoxAddressTable1 add hl, bc add hl, bc add hl, bc ld a, [hli] call GetSRAMBank ld a, [hli] ld h, [hl] ld l, a ld a, e ld d, h ld e, l cp [hl] ld c, a ld a, b ;b = 0 jr nc, .got_ID inc hl add hl, bc ld a, [hl] .got_ID ld [wTempSpecies], a ld a, c ld hl, sBoxMonOT - sBox add hl, de ld c, NAME_LENGTH push af call AddNTimes pop af push hl ld hl, sBoxMonNicknames - sBox add hl, de if MON_NAME_LENGTH != NAME_LENGTH ld c, MON_NAME_LENGTH endc push af call AddNTimes pop af push hl ld hl, sBoxMons - sBox add hl, de pop de ld c, BOXMON_STRUCT_LENGTH call AddNTimes pop bc ret GetBoxMonPokemonIndexPointer:: ; in: b = slot, c = box ; out: b = bank, hl = pointer ; preserves de ld a, b ld b, 0 ld hl, BoxPokemonIndexesAddressTable add hl, bc add hl, bc add hl, bc ld c, a ld a, [hli] push af ld a, [hli] ld h, [hl] ld l, a ld b, 0 add hl, bc add hl, bc pop bc ret BoxAddressTable1: dba sBox1 dba sBox2 dba sBox3 dba sBox4 dba sBox5 dba sBox6 dba sBox7 dba sBox8 dba sBox9 dba sBox10 dba sBox11 dba sBox12 dba sBox13 dba sBox14 BoxPokemonIndexesAddressTable: dba sBox1PokemonIndexes dba sBox2PokemonIndexes dba sBox3PokemonIndexes dba sBox4PokemonIndexes dba sBox5PokemonIndexes dba sBox6PokemonIndexes dba sBox7PokemonIndexes dba sBox8PokemonIndexes dba sBox9PokemonIndexes dba sBox10PokemonIndexes dba sBox11PokemonIndexes dba sBox12PokemonIndexes dba sBox13PokemonIndexes dba sBox14PokemonIndexes UpdateOTPointer: push hl ld hl, NAME_LENGTH add hl, bc ld b, h ld c, l pop hl ret
Mus88_Extra_Life_Header: smpsHeaderStartSong 1 smpsHeaderVoice Mus88_Extra_Life_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $02, $05 smpsHeaderDAC Mus88_Extra_Life_DAC smpsHeaderFM Mus88_Extra_Life_FM1, $E8, $10 smpsHeaderFM Mus88_Extra_Life_FM2, $E8, $10 smpsHeaderFM Mus88_Extra_Life_FM3, $E8, $10 smpsHeaderFM Mus88_Extra_Life_FM4, $E8, $10 smpsHeaderFM Mus88_Extra_Life_FM5, $E8, $10 smpsHeaderPSG Mus88_Extra_Life_PSG1, $D0, $06, $00, fTone_05 smpsHeaderPSG Mus88_Extra_Life_PSG2, $DC, $06, $00, fTone_05 smpsHeaderPSG Mus88_Extra_Life_PSG3, $DC, $00, $00, fTone_04 ; FM4 Data Mus88_Extra_Life_FM4: smpsAlterNote $03 smpsPan panRight, $00 smpsJump Mus88_Extra_Life_Jump01 ; FM1 Data Mus88_Extra_Life_FM1: smpsPan panLeft, $00 Mus88_Extra_Life_Jump01: smpsSetvoice $00 smpsNoteFill $06 dc.b nE7, $06, $03, $03, $06, $06 smpsNoteFill $00 dc.b nFs7, $09, nD7, nCs7, $06, nE7, $18 smpsStop ; FM2 Data Mus88_Extra_Life_FM2: smpsSetvoice $01 smpsNoteFill $06 smpsNop $01 dc.b nCs7, $06, $03, $03, $06, $06 smpsNoteFill $00 dc.b nD7, $09, nB6, nA6, $06, nCs7, $18 smpsNop $01 smpsStop ; FM5 Data Mus88_Extra_Life_FM5: smpsAlterNote $03 smpsPan panRight, $00 smpsJump Mus88_Extra_Life_Jump00 ; FM3 Data Mus88_Extra_Life_FM3: smpsPan panLeft, $00 Mus88_Extra_Life_Jump00: smpsSetvoice $02 dc.b nA4, $0C, nRst, $06, nA4, nG4, nRst, $03, nG4, $06, nRst, $03 dc.b nG4, $06, nA4, $18 smpsStop ; PSG1 Data Mus88_Extra_Life_PSG1: smpsNoteFill $06 dc.b nCs7, $06, $03, $03, $06, $06 smpsNoteFill $00 dc.b nD7, $09, nB6, nA6, $06, nCs7, $18 ; PSG2 Data Mus88_Extra_Life_PSG2: ; PSG3 Data Mus88_Extra_Life_PSG3: smpsStop ; DAC Data Mus88_Extra_Life_DAC: dc.b dHiTimpani, $12, $06, dVLowTimpani, $09, $09, $06, dHiTimpani, $06, dLowTimpani, dHiTimpani, dLowTimpani dc.b dHiTimpani, $0C smpsFade Mus88_Extra_Life_Voices: ; Voice $00 ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53, $0E, $0E, $0E, $03 ; $00, $00, $00, $00, $1F, $FF, $1F, $0F, $18, $4E, $16, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $01, $01, $07, $01 smpsVcRateScale $01, $02, $02, $02 smpsVcAttackRate $13, $0D, $0E, $0E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $03, $0E, $0E, $0E smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $00, $01, $0F, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $16, $4E, $18 ; Voice $01 ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53, $0E, $0E, $0E, $03 ; $00, $00, $00, $00, $1F, $FF, $1F, $0F, $18, $28, $27, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $01, $01, $07, $01 smpsVcRateScale $01, $02, $02, $02 smpsVcAttackRate $13, $0D, $0E, $0E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $03, $0E, $0E, $0E smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $00, $01, $0F, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $27, $28, $18 ; Voice $02 ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53, $0E, $0E, $0E, $03 ; $00, $00, $00, $07, $1F, $FF, $1F, $0F, $18, $28, $27, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $01, $01, $07, $01 smpsVcRateScale $01, $02, $02, $02 smpsVcAttackRate $13, $0D, $0E, $0E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $03, $0E, $0E, $0E smpsVcDecayRate2 $07, $00, $00, $00 smpsVcDecayLevel $00, $01, $0F, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $27, $28, $18
; A015530: Expansion of x/(1 - 4*x - 3*x^2). ; Submitted by Jamie Morken(s4) ; 0,1,4,19,88,409,1900,8827,41008,190513,885076,4111843,19102600,88745929,412291516,1915403851,8898489952,41340171361,192056155300,892245135283,4145149007032,19257331433977,89464772757004,415631085329947,1930918659590800,8970567894353041,41675027556184564,193611813907797379,899472338299743208,4178724794922364969,19413316194588689500,90189439163121852907,418997705236253480128,1946559138434379479233,9043229669446278357316,42012596093088251866963,195180073380691842539800,906758081802032125760089 mov $1,1 lpb $0 sub $0,1 mov $2,$3 mul $2,3 mul $3,4 add $3,$1 mov $1,$2 lpe mov $0,$3
; A338863: Product of the nonzero digits of (n written in base 6). ; Submitted by Jamie Morken(m3) ; 1,1,2,3,4,5,1,1,2,3,4,5,2,2,4,6,8,10,3,3,6,9,12,15,4,4,8,12,16,20,5,5,10,15,20,25,1,1,2,3,4,5,1,1,2,3,4,5,2,2,4,6,8,10,3,3,6,9,12,15,4,4,8,12,16,20,5,5,10,15,20,25,2,2,4,6,8,10,2,2,4 seq $0,7092 ; Numbers in base 6. seq $0,51801 ; Product of the nonzero digits of n.
; A075870: Numbers k such that 2*k^2 - 4 is a square. ; 2,10,58,338,1970,11482,66922,390050,2273378,13250218,77227930,450117362,2623476242,15290740090,89120964298,519435045698,3027489309890,17645500813642,102845515571962,599427592618130,3493720040136818,20362892648202778,118683635849079850,691738922446276322,4031749898828578082,23498760470525192170,136960812924322574938,798266117075410257458,4652635889528138969810,27117549220093423561402,158052659431032402398602,921198407366100990830210,5369137784765573542582658,31293628301227340264665738,182392632022598468045411770,1063062163834363468007804882,6195980350983582340001417522,36112819942067130572000700250,210480939301419201092002783978,1226772815866448075980016003618,7150155955897269254788093237730,41674162919517167452748543422762,242894821561205735461703167298842,1415694766447717245317470460370290,8251273777125097736443119594922898,48091947896302869173341247109167098,280300413600692117303604363060079690 mov $1,2 mov $2,1 lpb $0 sub $0,1 add $1,$2 add $2,$1 add $2,$1 add $1,$2 lpe mov $0,$1
bits 16 global _start extern stage2 _start: pop dx cli xor ax, ax mov ds, ax mov es, ax mov ss, ax mov sp, 0x5000 jmp 0x0:real_start real_start: lgdt [gdt_descriptor] mov eax, cr0 or eax, 0x1 mov cr0, eax jmp CODE_SEG:pt_mode bits 32 pt_mode: mov ax, DATA_SEG mov ds, ax mov es, ax mov ss, ax call stage2 cli hlt gdt_start: ; don't remove the labels, they're needed to compute sizes and jumps ; the GDT starts with a null 8-byte dd 0x0 ; 4 byte dd 0x0 ; 4 byte ; GDT for code segment. base = 0x00000000, length = 0xfffff ; for flags, refer to os-dev.pdf document, page 36 gdt_code: dw 0xffff ; segment length, bits 0-15 dw 0x0 ; segment base, bits 0-15 db 0x0 ; segment base, bits 16-23 db 10011010b ; flags (8 bits) db 11001111b ; flags (4 bits) + segment length, bits 16-19 db 0x0 ; segment base, bits 24-31 ; GDT for data segment. base and length identical to code segment ; some flags changed, again, refer to os-dev.pdf gdt_data: dw 0xffff dw 0x0 db 0x0 db 10010010b db 11001111b db 0x0 gdt_end: ; GDT descriptor gdt_descriptor: dw gdt_end - gdt_start - 1 ; size (16 bit), always one less of its true size dd gdt_start ; address (32 bit) ; define some constants for later use CODE_SEG equ gdt_code - gdt_start DATA_SEG equ gdt_data - gdt_start
PAGE 80,132 ; TITLE DEBUASM.ASM ;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ ; Code for the UASSEMble command in the debugger IF1 %OUT COMPONENT=DEBUG, MODULE=DEBUASM ENDIF .XLIST .XCREF include version.inc ; cas -- missing equates INCLUDE DOSSYM.INC INCLUDE debug.inc .CREF .LIST CODE SEGMENT PUBLIC BYTE CODE ENDS CONST SEGMENT PUBLIC BYTE EXTRN SYNERR_PTR:BYTE,UNASSEM_LN_PTR:WORD EXTRN NSEG:WORD,SISAVE:WORD,BPSAVE:WORD,DISAVE:WORD EXTRN BXSAVE:WORD,DSSAVE:WORD,ESSAVE:WORD,CSSAVE:WORD,IPSAVE:WORD EXTRN SSSAVE:WORD,CXSAVE:WORD,SPSAVE:WORD,FLSAVE:WORD EXTRN DISTAB:WORD,SHFTAB:WORD,IMMTAB:WORD,GRP1TAB:WORD,GRP2TAB:WORD EXTRN DBMN:BYTE,ESCMN:BYTE,DISPB:WORD,STACK:BYTE,REG8:BYTE EXTRN REG16:BYTE,SREG:BYTE,SIZ8:BYTE,SEGTAB:WORD,M8087_TAB:BYTE EXTRN FI_TAB:BYTE,SIZE_TAB:BYTE,MD9_TAB:BYTE,MD9_TAB2:BYTE EXTRN MDB_TAB:BYTE,MDB_TAB2:BYTE,MDD_TAB:BYTE,MDD_TAB2:BYTE EXTRN MDF_TAB:BYTE CONST ENDS CSTACK SEGMENT STACK CSTACK ENDS DATA SEGMENT PUBLIC BYTE EXTRN DISADD:BYTE,DISCNT:WORD,BYTCNT:BYTE,TEMP:BYTE,AWORD:BYTE EXTRN MIDFLD:BYTE,MODE:BYTE,REGMEM:BYTE,OPCODE:WORD,OPBUF:BYTE EXTRN INDEX:WORD,ARG_BUF:BYTE,ARG_BUF_PTR:BYTE,ARG_BUF_INDEX:WORD EXTRN OPBUF:BYTE,OPCODE:WORD DATA ENDS DG GROUP CODE,CONST,CSTACK,DATA CODE SEGMENT PUBLIC BYTE ASSUME CS:DG,DS:DG,ES:DG,SS:DG PUBLIC UNASSEM PUBLIC DISASLN,MEMIMM,JMPCALL,SIGNIMM,ALUFROMREG,WORDTOALU PUBLIC GRP2,PREFIX,OUTVARW,GRP1,SSPRE,MOVSEGTO,DSPRE,SHIFT PUBLIC ESPRE,IMMED,CSPRE,OUTVARB,CHK10,ACCIMM,INT3,INVARB PUBLIC MOVSEGFROM,LOADACC,OUTFIXB,XCHGAX,REGIMMW,SHORTJMP PUBLIC SAV8,M8087,M8087_DB,M8087_DF,M8087_D9,M8087_DD PUBLIC SAV16,SAVHEX,INFIXW,REGIMMB,OUTFIXW,SHIFTV,LONGJMP PUBLIC INVARW,STOREACC,INFIXB,NOOPERANDS,ALUTOREG PUBLIC SEGOP,REGOP,GETADDR EXTRN CRLF:NEAR,BLANK:NEAR,TAB:NEAR,STD_PRINTF:NEAR EXTRN HEX:NEAR,DEFAULT:NEAR,OUTSI:NEAR,OUTDI:NEAR EXTRN HEX_ADDRESS_ONLY:NEAR UNASSEM: MOV BP,[CSSAVE] ; Default code segment MOV DI,OFFSET DG:DISADD ; Default address MOV CX,DISPB ; Default length SHR CX,1 SHR CX,1 CALL DEFAULT MOV WORD PTR [DISADD],DX ; Displacement of disassembly MOV WORD PTR [DISADD+2],AX ; Segment MOV WORD PTR [DISCNT],CX ; No. of bytes (but whole instructions) DISLP: CALL DISASLN ; Disassemble one line CALL CRLF TEST [DISCNT],-1 ; See if we've used up the range JNZ DISLP RET GOTDIS: PUSH DS ; RE-GET LAST BYTE PUSH SI LDS SI,DWORD PTR [DISADD] MOV AL,[SI-1] POP SI POP DS RET GETDIS: PUSH DS LDS SI,DWORD PTR [DISADD] LODSB ; Get the next byte of code POP DS MOV WORD PTR [DISADD],SI ; Update pointer PUSH AX PUSH DI MOV DI,[ARG_BUF_INDEX] CALL HEX ; Display each code byte MOV [ARG_BUF_INDEX],DI POP DI MOV SI,[DISCNT] OR SI,SI ; Check if range exhausted JZ ENDRNG ; If so, don't wrap around DEC SI ; Count off the bytes MOV [DISCNT],SI ENDRNG: INC BYTE PTR[BYTCNT] ; Keep track of no. of bytes per line POP AX RET DSPRE: INC BYTE PTR [NSEG+1] SSPRE: INC BYTE PTR [NSEG+1] CSPRE: INC BYTE PTR [NSEG+1] ESPRE: INC BYTE PTR [NSEG+1] PREFIX: POP BX ; Dump off return address CALL FINLN CALL CRLF DISASLN: PUSH DS LDS SI,DWORD PTR [DISADD] CALL OUTSI ; Show disassembly address POP DS CALL HEX_ADDRESS_ONLY DISASLN1: MOV BYTE PTR [BYTCNT],0 ; Count of code bytes per line ; Fill overflow area with zeros MOV DI,OFFSET DG:OPBUF MOV CX,50 MOV AL,0 REP STOSB ; fill buffer with spaces MOV DI,OFFSET DG:OPBUF MOV CX,OPBUFLEN MOV AL," " REP STOSB MOV DI,OFFSET DG:ARG_BUF MOV [ARG_BUF_INDEX],DI CALL GETDIS ; Get opcode MOV DI,[ARG_BUF_INDEX] MOV AH,0 MOV BX,AX AND AL,1 ; Mask to "W" bit MOV [AWORD],AL MOV AL,BL ; Restore opcode SHL BX,1 SHL BX,1 ; Multiply opcode by 4 ADD BX,OFFSET DG:DISTAB MOV DX,[BX] ; Get pointer to mnemonic from table MOV [OPCODE],DX MOV [ARG_BUF_INDEX],DI MOV DI,OFFSET DG:OPBUF CALL WORD PTR [BX+2] FINLN: MOV AH,[BYTCNT] ; See how many bytes in this instruction ADD AH,AH ; Each uses two characters MOV AL,14 ; Amount of space we want to use SUB AL,AH ; See how many fill characters needed CBW XCHG CX,AX ; Parameter for TAB needed in CX MOV DI,[ARG_BUF_INDEX] CALL TAB MOV SI,[OPCODE] OR SI,SI JZ GET_TAB GET_OPCODE: LODSB OR AL,AL JZ GET_TAB STOSB JMP GET_OPCODE GET_TAB: MOV AL,9 STOSB MOV BYTE PTR [DI],0 ; nul terminate address buffer MOV DX,OFFSET DG:UNASSEM_LN_PTR CALL STD_PRINTF RET GETMODE: CALL GETDIS ; Get the address mode byte MOV AH,AL AND AL,7 ; Mask to "r/m" field MOV [REGMEM],AL SHR AH,1 SHR AH,1 SHR AH,1 MOV AL,AH AND AL,7 ; Mask to center 3-bit field MOV [MIDFLD],AL SHR AH,1 SHR AH,1 SHR AH,1 MOV [MODE],AH ; Leaving 2-bit "MOD" field RET IMMED: MOV BX,OFFSET DG:IMMTAB CALL GETMNE FINIMM: CALL TESTREG JMP SHORT IMM MEMIMM: CALL GETMODE JMP SHORT FINIMM ACCIMM: XOR AL,AL IMM1: CALL SAVREG IMM: MOV AL,"," STOSB TEST BYTE PTR [AWORD],-1 JNZ SAV16 SAV8: CALL GETDIS JMP SHORT SAVHEX LONGJMP: PUSH DI MOV DI,OFFSET DG:TEMP CALL SAV16 POP DI CALL SAV16 MOV AL,":" STOSB MOV SI,OFFSET DG:TEMP MOV CX,4 MOVDIG: LODSB STOSB LOOP MOVDIG RET SAV16: CALL GETDIS ; Get low byte MOV DL,AL CALL GETDIS ; Get high byte MOV DH,AL CALL SAVHEX ; Convert and store high byte MOV AL,DL SAVHEX: MOV AH,AL SHR AL,1 SHR AL,1 SHR AL,1 SHR AL,1 CALL SAVDIG MOV AL,AH SAVDIG: AND AL,0FH ADD AL,90H DAA ADC AL,40H DAA STOSB RET CHK10: CALL GETDIS CMP AL,10 JNZ SAVHEX RET SIGNIMM: MOV BX,OFFSET DG:IMMTAB CALL GETMNE CALL TESTREG MOV AL,"," STOSB SAVD8: CALL GETDIS ; Get signed 8-bit number CBW MOV DX,AX ; Save true 16-bit value in DX MOV AH,AL MOV AL,"+" OR AH,AH ; JZ NOSIGN JNS POSITIV ; OK if positive MOV AL,"-" NEG AH ; Get magnitude if negative POSITIV: STOSB ; NOSIGN: MOV AL,AH JMP SHORT SAVHEX ALUFROMREG: CALL GETADDR MOV AL,"," STOSB REGFLD: MOV AL,[MIDFLD] SAVREG: MOV SI,OFFSET DG:REG8 CMP BYTE PTR [AWORD],1 JNE FNDREG SAVREG16: MOV SI,OFFSET DG:REG16 FNDREG: CBW ADD SI,AX ADD SI,AX MOVSW RET SEGOP: SHR AL,1 SHR AL,1 SHR AL,1 SAVSEG: AND AL,3 MOV SI,OFFSET DG:SREG JMP SHORT FNDREG REGOP: AND AL,7 JMP SHORT SAVREG16 MOVSEGTO: MOV BYTE PTR [AWORD],1 CALL GETADDR MOV AL,"," STOSB MOV AL,[MIDFLD] JMP SHORT SAVSEG MOVSEGFROM: CALL GETMODE CALL SAVSEG MOV BYTE PTR [AWORD],1 JMP SHORT MEMOP2 GETADDR: CALL GETMODE JMP SHORT ADDRMOD WORDTOALU: MOV BYTE PTR [AWORD],1 ALUTOREG: CALL GETMODE CALL REGFLD MEMOP2: MOV AL,"," STOSB ADDRMOD: CMP BYTE PTR [MODE],3 MOV AL,[REGMEM] JE SAVREG XOR BX,BX MOV BYTE PTR [NSEG],3 MOV BYTE PTR [DI],"[" INC DI CMP AL,6 JNE NODRCT CMP BYTE PTR [MODE],0 JE DIRECT ; Mode=0 and R/M=6 means direct addr. NODRCT: MOV DL,AL CMP AL,1 JBE USEBX CMP AL,7 JE USEBX CMP AL,3 JBE USEBP CMP AL,6 JNE CHKPLS USEBP: MOV BX,[BPSAVE] MOV BYTE PTR [NSEG],2 ; Change default to Stack Segment MOV AX,BPREG SAVBASE: STOSW CHKPLS: CMP DL,4 JAE NOPLUS MOV AL,"+" STOSB NOPLUS: CMP DL,6 JAE DOMODE ; No index register AND DL,1 ; Even for SI, odd for DI JZ USESI ADD BX,[DISAVE] MOV AX,DIREG SAVINDX: STOSW DOMODE: MOV AL,[MODE] OR AL,AL JZ CLOSADD ; If no displacement, then done CMP AL,2 JZ ADDDIR CALL SAVD8 ; Signed 8-bit displacement ADDCLOS: ADD BX,DX CLOSADD: MOV AL,"]" STOSB MOV [INDEX],BX NOOPERANDS: RET ADDDIR: MOV AL,"+" STOSB DIRECT: CALL SAV16 JMP SHORT ADDCLOS USEBX: MOV BX,[BXSAVE] MOV AX,BXREG JMP SHORT SAVBASE USESI: ADD BX,[SISAVE] MOV AX,SIREG JMP SHORT SAVINDX SHORTJMP: CALL GETDIS CBW ADD AX,WORD PTR [DISADD] XCHG DX,AX SAVJMP: MOV AL,DH CALL SAVHEX MOV AL,DL JMP SAVHEX JMPCALL: CALL GETDIS MOV DL,AL CALL GETDIS MOV DH,AL ADD DX,WORD PTR [DISADD] JMP SHORT SAVJMP XCHGAX: AND AL,7 CALL SAVREG16 MOV AL,"," STOSB XOR AL,AL JMP SAVREG16 LOADACC: XOR AL,AL CALL SAVREG MOV AL,"," STOSB MEMDIR: MOV AL,"[" STOSB XOR BX,BX MOV BYTE PTR [NSEG],3 JMP DIRECT STOREACC: CALL MEMDIR MOV AL,"," STOSB XOR AL,AL JMP SAVREG REGIMMB: MOV BYTE PTR [AWORD],0 JMP SHORT REGIMM REGIMMW: MOV BYTE PTR [AWORD],1 REGIMM: AND AL,7 JMP IMM1 INT3: MOV BYTE PTR [DI],"3" INC DI RET ; 8087 instructions whose first byte is 0dfh M8087_DF: CALL GET64F JZ ISDD3 MOV SI,OFFSET DG:MDF_TAB JMP short NODB3 ; 8087 instructions whose first byte is 0ddh M8087_DD: CALL GET64F JZ ISDD3 MOV SI,OFFSET DG:MDD_TAB JMP short NOD93 ISDD3: MOV AL,DL TEST AL,100B JZ ISSTI JMP ESC0 ISSTI: AND AL,11B MOV SI,OFFSET DG:MDD_TAB2 MOV CL,AL CALL MOVBYT JMP short PUTRST ; 8087 instructions whose first byte is 0dbh M8087_DB: CALL GET64F JZ ISDB3 MOV SI,OFFSET DG:MDB_TAB NODB3: CALL PUTOP CALL PUTSIZE JMP ADDRMOD ISDB3: MOV AL,DL TEST AL,100B JNZ ISDBIG ESC0V: JMP ESC0 ISDBIG: CALL GOTDIS AND AL,11111B CMP AL,4 JAE ESC0V MOV SI,OFFSET DG:MDB_TAB2 JMP short DOBIG ; 8087 instructions whose first byte is 0d9h M8087_D9: CALL GET64F JZ ISD93 MOV SI,OFFSET DG:MD9_TAB NOD93: CALL PUTOP AND AL,111B CMP AL,3 JA NOSHO MOV AL,DL CALL PUTSIZE NOSHO: JMP ADDRMOD ISD93: MOV AL,DL TEST AL,100B JNZ ISD9BIG AND AL,111B OR AL,AL JNZ NOTFLD MOV AX,"DL" STOSW JMP SHORT PUTRST NOTFLD: CMP AL,1 JNZ NOTFXCH MOV AX,"CX" STOSW MOV AL,"H" JMP SHORT PUTRST1 NOTFXCH: CMP AL,3 JNZ NOTFSTP MOV AX,"TS" STOSW MOV AL,"P" PUTRST1: STOSB PUTRST: MOV AL,9 STOSB JMP short PUTST0 NOTFSTP: CALL GOTDIS CMP AL,11010000B ; CHECK FOR FNOP JZ GOTFNOP JMP ESC0 GOTFNOP: MOV AX,"ON" STOSW MOV AL,"P" STOSB RET ISD9BIG: CALL GOTDIS ; GET THE MODE BYTE MOV SI,OFFSET DG:MD9_TAB2 DOBIG: AND AL,11111B MOV CL,AL JMP MOVBYT ; entry point for the remaining 8087 instructions M8087: CALL GET64 CALL PUTFI ; PUT FIRST PART OF OPCODE MOV AL,DL CMP BYTE PTR [MODE],11B ; CHECK FOR REGISTER MODE JZ MODEIS3 CALL PUTMN ; PUT MIDDLE PART OF OPCODE NO3: MOV AL,9 ; OUTPUT A TAB STOSB MOV AL,DL CALL PUTSIZE ; OUTPUT THE OPERAND SIZE JMP ADDRMOD MODEIS3: TEST AL,100000B ; D BIT SET? JZ MPUT ; NOPE... TEST AL,000100B ; FDIV OR FSUB? JZ MPUT ; NOPE... XOR AL,1 ; REVERSE SENSE OF R MOV DL,AL ; SAVE CHANGE MPUT: CALL PUTMN ; PUT MIDDLE PART OF OPCODE MOV AL,DL TEST AL,010000B JZ NOPSH MOV AL,"P" STOSB NOPSH: MOV AL,9 STOSB MOV AL,DL AND AL,00000111B CMP AL,2 ; FCOM JZ PUTST0 CMP AL,3 ; FCOMP JZ PUTST0 MOV AL,DL TEST AL,100000B JZ PUTSTST0 ; output 8087 registers in the form st(n),st PUTST0ST: CALL PUTST0 MOV AL,',' ISCOMP: STOSB PUTST: MOV AX,"TS" STOSW RET ; output 8087 registers in the form st,st(n) PUTSTST0: CALL PUTST MOV AL,',' STOSB PUTST0: CALL PUTST MOV AL,"(" STOSB MOV AL,[REGMEM] ADD AL,"0" STOSB MOV AL,")" STOSB RET ; output an 8087 mnemonic PUTMN: MOV SI,OFFSET DG:M8087_TAB MOV CL,AL AND CL,00000111B JMP SHORT MOVBYT ; output either 'FI' or 'F' for first byte of opcode PUTFI: MOV SI,OFFSET DG:FI_TAB JMP SHORT PUTFI2 ; output size (dword, tbyte, etc.) PUTSIZE: MOV SI,OFFSET DG:SIZE_TAB PUTFI2: CMP BYTE PTR [MODE],11B ; check if 8087 register JNZ PUTFI3 AND AL,111000B ; LOOK FOR INVALID FORM OF 0DAH OPERANDS CMP AL,010000B JZ ESC0PJ MOV AL,DL CMP AL,110011B ; FCOMPP JNZ GOFI CMP BYTE PTR [REGMEM],1 JZ GOFI ESC0PJ: jmp short ESC0P ; we could've reached without a ; ; double branch here, but we needed ; ; a bridge for ESC0PJ GOFI: XOR CL,CL JMP SHORT MOVBYT ; Look for qword PUTFI3: CMP AL,111101B JZ GOTQU CMP AL,111111B JNZ NOTQU GOTQU: MOV CL,2 JMP SHORT MOVBYT ; look for tbyte NOTQU: CMP AL,011101B JZ GOTTB CMP AL,111100B JZ GOTTB CMP AL,111110B JZ GOTTB CMP AL,011111B JNZ NOTTB GOTTB: MOV CL,5 JMP SHORT MOVBYT NOTTB: MOV CL,4 SHR AL,CL MOV CL,AL ; SI POINTS TO A TABLE OF TEXT SEPARATED BY "$" ; CL = WHICH ELEMENT IN THE TABLE YOU WISH TO COPY TO [DI] MOVBYT: PUSH AX INC CL MOVBYT1: DEC CL JZ MOVBYT3 MOVBYT2: LODSB CMP AL,"$" JZ MOVBYT1 JMP MOVBYT2 MOVBYT3: LODSB CMP AL,'$' JZ MOVBYT5 CMP AL,'@' ; THIS MEANS RESVERED OP-CODE JNZ MOVBYT4 POP AX JMP SHORT ESC0P ; GO DO AN ESCAPE COMMAND MOVBYT4: STOSB JMP MOVBYT3 MOVBYT5: POP AX RET PUTOP: AND AL,111B MOV CL,AL CALL MOVBYT MOV AL,9 STOSB MOV AL,DL RET GET64F: CALL GET64 MOV AL,"F" STOSB CMP BYTE PTR [MODE],3 MOV AL,DL RET GET64: AND AL,7 MOV DL,AL CALL GETMODE SHL DL,1 SHL DL,1 SHL DL,1 OR AL,DL MOV DL,AL ; SAVE RESULT RET ESC0P: POP DI ; CLEAN UP STACK ESC0: MOV WORD PTR [OPCODE],OFFSET DG:ESCMN MOV AL,DL MOV DI,OFFSET DG:OPBUF JMP SHORT ESC1 ESCP: CALL GET64 ESC1: CALL SAVHEX CMP BYTE PTR [MODE],3 JZ SHRTESC MOV BYTE PTR [AWORD],1 JMP MEMOP2 SHRTESC: MOV AL,"," STOSB MOV AL,[REGMEM] AND AL,7 JMP SAVREG INVARW: CALL PUTAX JMP SHORT INVAR INVARB: CALL PUTAL INVAR: MOV AL,',' STOSB JMP short PUTDX INFIXW: CALL PUTAX JMP SHORT INFIX INFIXB: CALL PUTAL INFIX: MOV AL,',' STOSB JMP SAV8 STOSW ;IS THIS DEAD CODE? EMK RET OUTVARB: MOV BX,"LA" JMP SHORT OUTVAR OUTVARW: MOV BX,"XA" OUTVAR: CALL PUTDX OUTFV: MOV AL,',' STOSB MOV AX,BX STOSW RET OUTFIXB: MOV BX,"LA" JMP SHORT OUTFIX OUTFIXW: MOV BX,"XA" OUTFIX: CALL SAV8 JMP OUTFV PUTAL: MOV AX,"A"+4C00H ; "AL" JMP SHORT PUTX PUTAX: MOV AX,"A"+5800H ; "AX" JMP SHORT PUTX PUTDX: MOV AX,"D"+5800H ; "DX" PUTX: STOSW RET SHFT: MOV BX,OFFSET DG:SHFTAB CALL GETMNE TESTREG: CMP BYTE PTR [MODE],3 JZ NOFLG MOV SI,OFFSET DG:SIZE_TAB MOV CL,3 TEST BYTE PTR [AWORD],-1 JNZ TEST_1 INC CL TEST_1: CALL MOVBYT NOFLG: JMP ADDRMOD SHIFTV: CALL SHFT MOV AL,"," STOSB MOV WORD PTR [DI],"C"+4C00H ; "CL" ADD DI,2 RET SHIFT: CALL SHFT MOV AX,"1," STOSW RET GETMNE: CALL GETMODE MOV DL,AL CBW SHL AX,1 ADD BX,AX MOV AX,[BX] MOV [OPCODE],AX MOV AL,DL RET GRP1: MOV BX,OFFSET DG:GRP1TAB CALL GETMNE OR AL,AL JZ FINIMMJ JMP TESTREG FINIMMJ: JMP FINIMM GRP2: MOV BX,OFFSET DG:GRP2TAB CALL GETMNE CMP AL,2 JB TESTREG CMP AL,6 JAE INDIRECT TEST AL,1 JZ INDIRECT MOV AX,"AF" ; "FAR" STOSW MOV AX," R" STOSW INDIRECT: JMP ADDRMOD CODE ENDS END UNASSEM 
; Provided under the CC0 license. See the included LICENSE.txt for details. ; This is a 2-line kernel! kernel sta WSYNC lda #255 sta TIM64T lda #1 sta VDELBL sta VDELP0 ldx ballheight inx inx stx temp4 lda player1y sta temp3 ifconst shakescreen jsr doshakescreen else ldx missile0height inx endif inx stx stack1 lda bally sta stack2 lda player0y ldx #0 sta WSYNC stx GRP0 stx GRP1 stx PF1L stx PF2 stx CXCLR ifconst readpaddle stx paddle else sleep 3 endif sta temp2,x ;store these so they can be retrieved later ifnconst pfres ldx #128-(44+(4-pfwidth)*12)/2 else ldx #130-(pfres*pfwidth)/2 endif dec player0y lda missile0y sta temp5 lda missile1y sta temp6 lda playfieldpos sta temp1 ifconst pfrowheight lda #pfrowheight+2 else ifnconst pfres lda #10 else lda #(96/pfres)+2 ; try to come close to the real size endif endif clc sbc playfieldpos sta playfieldpos jmp .startkernel .skipDrawP0 lda #0 tay jmp .continueP0 .skipDrawP1 lda #0 tay jmp .continueP1 .kerloop ; enter at cycle 59?? continuekernel sleep 2 continuekernel2 lda ballheight ifconst pfres ldy playfield+pfres*pfwidth-132,x sty PF1L ;3 ldy playfield+pfres*pfwidth-131-pfadjust,x sty PF2L ;3 ldy playfield+pfres*pfwidth-129,x sty PF1R ; 3 too early? ldy playfield+pfres*pfwidth-130-pfadjust,x sty PF2R ;3 else ldy playfield-48+pfwidth*12+44-128,x sty PF1L ;3 ldy playfield-48+pfwidth*12+45-128-pfadjust,x ;4 sty PF2L ;3 ldy playfield-48+pfwidth*12+47-128,x ;4 sty PF1R ; 3 too early? ldy playfield-48+pfwidth*12+46-128-pfadjust,x;4 sty PF2R ;3 endif ; should be playfield+$38 for width=2 dcp bally rol rol ; rol ; rol goback sta ENABL .startkernel lda player1height ;3 dcp player1y ;5 bcc .skipDrawP1 ;2 ldy player1y ;3 lda (player1pointer),y ;5; player0pointer must be selected carefully by the compiler ; so it doesn't cross a page boundary! .continueP1 sta GRP1 ;3 ifnconst player1colors lda missile1height ;3 dcp missile1y ;5 rol;2 rol;2 sta ENAM1 ;3 else lda (player1color),y sta COLUP1 ifnconst playercolors sleep 7 else lda.w player0colorstore sta COLUP0 endif endif ifconst pfres lda playfield+pfres*pfwidth-132,x sta PF1L ;3 lda playfield+pfres*pfwidth-131-pfadjust,x sta PF2L ;3 lda playfield+pfres*pfwidth-129,x sta PF1R ; 3 too early? lda playfield+pfres*pfwidth-130-pfadjust,x sta PF2R ;3 else lda playfield-48+pfwidth*12+44-128,x ;4 sta PF1L ;3 lda playfield-48+pfwidth*12+45-128-pfadjust,x ;4 sta PF2L ;3 lda playfield-48+pfwidth*12+47-128,x ;4 sta PF1R ; 3 too early? lda playfield-48+pfwidth*12+46-128-pfadjust,x;4 sta PF2R ;3 endif ; sleep 3 lda player0height dcp player0y bcc .skipDrawP0 ldy player0y lda (player0pointer),y .continueP0 sta GRP0 ifnconst no_blank_lines ifnconst playercolors lda missile0height ;3 dcp missile0y ;5 sbc stack1 sta ENAM0 ;3 else lda (player0color),y sta player0colorstore sleep 6 endif dec temp1 bne continuekernel else dec temp1 beq altkernel2 ifconst readpaddle ldy currentpaddle lda INPT0,y bpl noreadpaddle inc paddle jmp continuekernel2 noreadpaddle sleep 2 jmp continuekernel else ifnconst playercolors ifconst PFcolors txa tay lda (pfcolortable),y ifnconst backgroundchange sta COLUPF else sta COLUBK endif jmp continuekernel else ifconst kernelmacrodef kernelmacro else sleep 12 endif endif else lda (player0color),y sta player0colorstore sleep 4 endif jmp continuekernel endif altkernel2 txa sbx #256-pfwidth/2 bmi lastkernelline ifconst pfrowheight lda #pfrowheight else ifnconst pfres lda #8 else lda #(96/pfres) ; try to come close to the real size endif endif sta temp1 jmp continuekernel endif altkernel ifconst PFmaskvalue lda #PFmaskvalue else lda #0 endif sta PF1L sta PF2 ;sleep 3 ;28 cycles to fix things ;minus 11=17 ; lax temp4 ; clc txa sbx #256-pfwidth/2 bmi lastkernelline ifconst PFcolorandheight ifconst pfres ldy playfieldcolorandheight-131+pfres*pfwidth,x else ldy playfieldcolorandheight-87,x endif ifnconst backgroundchange sty COLUPF else sty COLUBK endif ifconst pfres lda playfieldcolorandheight-132+pfres*pfwidth,x else lda playfieldcolorandheight-88,x endif sta.w temp1 endif ifconst PFheights lsr lsr tay lda (pfheighttable),y sta.w temp1 endif ifconst PFcolors tay lda (pfcolortable),y ifnconst backgroundchange sta COLUPF else sta COLUBK endif ifconst pfrowheight lda #pfrowheight else ifnconst pfres lda #8 else lda #(96/pfres) ; try to come close to the real size endif endif sta temp1 endif ifnconst PFcolorandheight ifnconst PFcolors ifnconst PFheights ifnconst no_blank_lines ; read paddle 0 ; lo-res paddle read ; bit INPT0 ; bmi paddleskipread ; inc paddle0 ;donepaddleskip sleep 10 ifconst pfrowheight lda #pfrowheight else ifnconst pfres lda #8 else lda #(96/pfres) ; try to come close to the real size endif endif sta temp1 endif endif endif endif lda ballheight dcp bally sbc temp4 jmp goback ifnconst no_blank_lines lastkernelline ifnconst PFcolors sleep 10 else ldy #124 lda (pfcolortable),y sta COLUPF endif ifconst PFheights ldx #1 sleep 3 ; this was over 1 cycle else ldx playfieldpos sleep 2 ; this was over 1 cycle endif jmp enterlastkernel else lastkernelline ifconst PFheights ldx #1 sleep 4 ; this was over 1 cycle else ldx playfieldpos sleep 3 ; this was over 1 cycle endif cpx #1 bne .enterfromNBL jmp no_blank_lines_bailout endif if ((<*)>$d5) align 256 endif ; this is a kludge to prevent page wrapping - fix!!! .skipDrawlastP1 sleep 2 lda #0 jmp .continuelastP1 .endkerloop ; enter at cycle 59?? nop .enterfromNBL ifconst pfres ldy.w playfield+pfres*pfwidth-4 sty PF1L ;3 ldy.w playfield+pfres*pfwidth-3-pfadjust sty PF2L ;3 ldy.w playfield+pfres*pfwidth-1 sty PF1R ; possibly too early? ldy.w playfield+pfres*pfwidth-2-pfadjust sty PF2R ;3 else ldy.w playfield-48+pfwidth*12+44 sty PF1L ;3 ldy.w playfield-48+pfwidth*12+45-pfadjust sty PF2L ;3 ldy.w playfield-48+pfwidth*12+47 sty PF1R ; possibly too early? ldy.w playfield-48+pfwidth*12+46-pfadjust sty PF2R ;3 endif enterlastkernel lda ballheight ; tya dcp bally ; sleep 4 ; sbc stack3 rol rol sta ENABL lda player1height ;3 dcp player1y ;5 bcc .skipDrawlastP1 ldy player1y ;3 lda (player1pointer),y ;5; player0pointer must be selected carefully by the compiler ; so it doesn't cross a page boundary! .continuelastP1 sta GRP1 ;3 ifnconst player1colors lda missile1height ;3 dcp missile1y ;5 else lda (player1color),y sta COLUP1 endif dex ;dec temp4 ; might try putting this above PF writes beq endkernel ifconst pfres ldy.w playfield+pfres*pfwidth-4 sty PF1L ;3 ldy.w playfield+pfres*pfwidth-3-pfadjust sty PF2L ;3 ldy.w playfield+pfres*pfwidth-1 sty PF1R ; possibly too early? ldy.w playfield+pfres*pfwidth-2-pfadjust sty PF2R ;3 else ldy.w playfield-48+pfwidth*12+44 sty PF1L ;3 ldy.w playfield-48+pfwidth*12+45-pfadjust sty PF2L ;3 ldy.w playfield-48+pfwidth*12+47 sty PF1R ; possibly too early? ldy.w playfield-48+pfwidth*12+46-pfadjust sty PF2R ;3 endif ifnconst player1colors rol;2 rol;2 sta ENAM1 ;3 else ifnconst playercolors sleep 7 else lda.w player0colorstore sta COLUP0 endif endif lda.w player0height dcp player0y bcc .skipDrawlastP0 ldy player0y lda (player0pointer),y .continuelastP0 sta GRP0 ifnconst no_blank_lines lda missile0height ;3 dcp missile0y ;5 sbc stack1 sta ENAM0 ;3 jmp .endkerloop else ifconst readpaddle ldy currentpaddle lda INPT0,y bpl noreadpaddle2 inc paddle jmp .endkerloop noreadpaddle2 sleep 4 jmp .endkerloop else ; no_blank_lines and no paddle reading pla pha ; 14 cycles in 4 bytes pla pha ; sleep 14 jmp .endkerloop endif endif ; ifconst donepaddleskip ;paddleskipread ; this is kind of lame, since it requires 4 cycles from a page boundary crossing ; plus we get a lo-res paddle read ; bmi donepaddleskip ; endif .skipDrawlastP0 sleep 2 lda #0 jmp .continuelastP0 ifconst no_blank_lines no_blank_lines_bailout ldx #0 endif endkernel ; 6 digit score routine stx PF1 stx PF2 stx PF0 clc ifconst pfrowheight lda #pfrowheight+2 else ifnconst pfres lda #10 else lda #(96/pfres)+2 ; try to come close to the real size endif endif sbc playfieldpos sta playfieldpos txa ifconst shakescreen bit shakescreen bmi noshakescreen2 ldx #$3D noshakescreen2 endif sta WSYNC,x ; STA WSYNC ;first one, need one more sta REFP0 sta REFP1 STA GRP0 STA GRP1 ; STA PF1 ; STA PF2 sta HMCLR sta ENAM0 sta ENAM1 sta ENABL lda temp2 ;restore variables that were obliterated by kernel sta player0y lda temp3 sta player1y ifnconst player1colors lda temp6 sta missile1y endif ifnconst playercolors ifnconst readpaddle lda temp5 sta missile0y endif endif lda stack2 sta bally ; strangely, this isn't required any more. might have ; resulted from the no_blank_lines score bounce fix ;ifconst no_blank_lines ;sta WSYNC ;endif lda INTIM clc ifnconst vblank_time adc #43+12+87 else adc #vblank_time+12+87 endif ; sta WSYNC sta TIM64T ifconst minikernel jsr minikernel endif ; now reassign temp vars for score pointers ; score pointers contain: ; score1-5: lo1,lo2,lo3,lo4,lo5,lo6 ; swap lo2->temp1 ; swap lo4->temp3 ; swap lo6->temp5 ifnconst noscore lda scorepointers+1 ; ldy temp1 sta temp1 ; sty scorepointers+1 lda scorepointers+3 ; ldy temp3 sta temp3 ; sty scorepointers+3 sta HMCLR tsx stx stack1 ldx #$E0 stx HMP0 LDA scorecolor STA COLUP0 STA COLUP1 ifconst pfscore lda pfscorecolor sta COLUPF endif sta WSYNC ldx #0 STx GRP0 STx GRP1 ; seems to be needed because of vdel lda scorepointers+5 ; ldy temp5 sta temp5,x ; sty scorepointers+5 lda #>scoretable sta scorepointers+1 sta scorepointers+3 sta scorepointers+5 sta temp2 sta temp4 sta temp6 LDY #7 STY VDELP0 STA RESP0 STA RESP1 LDA #$03 STA NUSIZ0 STA NUSIZ1 STA VDELP1 LDA #$F0 STA HMP1 lda (scorepointers),y sta GRP0 STA HMOVE ; cycle 73 ? jmp beginscore if ((<*)>$d4) align 256 ; kludge that potentially wastes space! should be fixed! endif loop2 lda (scorepointers),y ;+5 68 204 sta GRP0 ;+3 71 213 D1 -- -- -- ifconst pfscore lda.w pfscore1 sta PF1 else sleep 7 endif ; cycle 0 beginscore lda (scorepointers+$8),y ;+5 5 15 sta GRP1 ;+3 8 24 D1 D1 D2 -- lda (scorepointers+$6),y ;+5 13 39 sta GRP0 ;+3 16 48 D3 D1 D2 D2 lax (scorepointers+$2),y ;+5 29 87 txs lax (scorepointers+$4),y ;+5 36 108 sleep 3 ifconst pfscore lda pfscore2 sta PF1 else sleep 6 endif lda (scorepointers+$A),y ;+5 21 63 stx GRP1 ;+3 44 132 D3 D3 D4 D2! tsx stx GRP0 ;+3 47 141 D5 D3! D4 D4 sta GRP1 ;+3 50 150 D5 D5 D6 D4! sty GRP0 ;+3 53 159 D4* D5! D6 D6 dey bpl loop2 ;+2 60 180 ldx stack1 txs ; lda scorepointers+1 ldy temp1 ; sta temp1 sty scorepointers+1 LDA #0 sta PF1 STA GRP0 STA GRP1 STA VDELP0 STA VDELP1;do we need these STA NUSIZ0 STA NUSIZ1 ; lda scorepointers+3 ldy temp3 ; sta temp3 sty scorepointers+3 ; lda scorepointers+5 ldy temp5 ; sta temp5 sty scorepointers+5 endif ;noscore LDA #%11000010 sta WSYNC STA VBLANK RETURN ifconst shakescreen doshakescreen bit shakescreen bmi noshakescreen sta WSYNC noshakescreen ldx missile0height inx rts endif
; CON scheduler for SMSQmulator ; 2004-03-18 1.01 cursor status is toggled before calling cn_curtg (wl) ; 2012-xx-xx 1.01 suspend java job when cursor toggle ; 2016 no longer used in SMSQmulator 2.17 section con ; include 'dev8_keys_con' include 'dev8_keys_sys' include 'dev8_keys_java' ; xdef cn_sched ; xref pt_sched xref cn_curtg ; cn_sched move.l sys_ckyq(a6),d0 ; keyboard queue beq.s csh_exit ; ... none move.l d0,a0 move.b sd_curf-sd_keyq(a0),d0 ; cursor status beq.s csh_exit ; ... none sub.w d3,sys_cfst(a6) ; count down bgt.s csh_exit ; not ready yet move.w #12,sys_cfst(a6) moveq #jt5.slep,d0 dc.w jva.trp5 ; call java possibly suspend job sub.w #sd_keyq,a0 ; base of channel block neg.b sd_curf(a0) ; change state - this is wished state jsr cn_curtg ; toogle now csh_exit jmp pt_sched end
; A001810: a(n) = n!*n*(n-1)*(n-2)/36. ; 0,0,0,1,16,200,2400,29400,376320,5080320,72576000,1097712000,17563392000,296821324800,5288816332800,99165306240000,1952793722880000,40311241850880000,870722823979008000,19645683716026368000,462251381553561600000,11325158848062259200000,288493520129585971200000,7630653607427548938240000,209297927518012770877440000,5945963849943544627200000000,174759633154862442086400000000,5308323857078946678374400000000,166469036157995767833821184000000,5384633054187478490317062144000000 mov $2,$0 bin $2,3 mov $1,$2 lpb $0 mul $1,$0 sub $0,1 lpe div $1,6 mov $0,$1
; A013961: a(n) = sigma_13(n), the sum of the 13th powers of the divisors of n. ; Submitted by Christian Krause ; 1,8193,1594324,67117057,1220703126,13062296532,96889010408,549822930945,2541867422653,10001220711318,34522712143932,107006334784468,302875106592254,793811662272744,1946196290656824,4504149450301441,9904578032905938,20825519793796029,42052983462257060,81930001287820182,154472474629724192,282844580595234876,504036361936467384,876595894555956180,1490116120605468751,2481455748310337022,4052557694886398920,6502905234227329256,10260628712958602190,15945186209351359032,24417546297445042592 add $0,1 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 pow $3,13 add $1,$3 lpe add $1,1 mov $0,$1
SFX_Trade_Machine_1_Ch5: duty_cycle 2 pitch_sweep 1, 5 square_note 15, 15, 0, 1264 square_note 15, 15, 2, 1616 pitch_sweep 0, 8 sound_ret
// Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/objects/contexts.h" #include "src/ast/modules.h" #include "src/debug/debug.h" #include "src/execution/isolate-inl.h" #include "src/init/bootstrapper.h" #include "src/objects/module-inl.h" namespace v8 { namespace internal { Handle<ScriptContextTable> ScriptContextTable::Extend( Handle<ScriptContextTable> table, Handle<Context> script_context) { Handle<ScriptContextTable> result; int used = table->used(); int length = table->length(); CHECK(used >= 0 && length > 0 && used < length); if (used + kFirstContextSlotIndex == length) { CHECK(length < Smi::kMaxValue / 2); Isolate* isolate = script_context->GetIsolate(); Handle<FixedArray> copy = isolate->factory()->CopyFixedArrayAndGrow(table, length); copy->set_map(ReadOnlyRoots(isolate).script_context_table_map()); result = Handle<ScriptContextTable>::cast(copy); } else { result = table; } result->set_used(used + 1); DCHECK(script_context->IsScriptContext()); result->set(used + kFirstContextSlotIndex, *script_context); return result; } bool ScriptContextTable::Lookup(Isolate* isolate, ScriptContextTable table, String name, LookupResult* result) { DisallowHeapAllocation no_gc; // Static variables cannot be in script contexts. IsStaticFlag is_static_flag; for (int i = 0; i < table.used(); i++) { Context context = table.get_context(i); DCHECK(context.IsScriptContext()); int slot_index = ScopeInfo::ContextSlotIndex( context.scope_info(), name, &result->mode, &result->init_flag, &result->maybe_assigned_flag, &is_static_flag); if (slot_index >= 0) { result->context_index = i; result->slot_index = slot_index; return true; } } return false; } bool Context::is_declaration_context() { if (IsFunctionContext() || IsNativeContext() || IsScriptContext() || IsModuleContext()) { return true; } if (IsEvalContext()) { return scope_info().language_mode() == LanguageMode::kStrict; } if (!IsBlockContext()) return false; return scope_info().is_declaration_scope(); } Context Context::declaration_context() { Context current = *this; while (!current.is_declaration_context()) { current = current.previous(); } return current; } Context Context::closure_context() { Context current = *this; while (!current.IsFunctionContext() && !current.IsScriptContext() && !current.IsModuleContext() && !current.IsNativeContext() && !current.IsEvalContext()) { current = current.previous(); } return current; } JSObject Context::extension_object() { DCHECK(IsNativeContext() || IsFunctionContext() || IsBlockContext() || IsEvalContext() || IsCatchContext()); HeapObject object = extension(); if (object.IsUndefined()) return JSObject(); DCHECK(object.IsJSContextExtensionObject() || (IsNativeContext() && object.IsJSGlobalObject())); return JSObject::cast(object); } JSReceiver Context::extension_receiver() { DCHECK(IsNativeContext() || IsWithContext() || IsEvalContext() || IsFunctionContext() || IsBlockContext()); return IsWithContext() ? JSReceiver::cast(extension()) : extension_object(); } ScopeInfo Context::scope_info() { return ScopeInfo::cast(get(SCOPE_INFO_INDEX)); } SourceTextModule Context::module() { Context current = *this; while (!current.IsModuleContext()) { current = current.previous(); } return SourceTextModule::cast(current.extension()); } JSGlobalObject Context::global_object() { return JSGlobalObject::cast(native_context().extension()); } Context Context::script_context() { Context current = *this; while (!current.IsScriptContext()) { current = current.previous(); } return current; } JSGlobalProxy Context::global_proxy() { return native_context().global_proxy_object(); } /** * Lookups a property in an object environment, taking the unscopables into * account. This is used For HasBinding spec algorithms for ObjectEnvironment. */ static Maybe<bool> UnscopableLookup(LookupIterator* it, bool is_with_context) { Isolate* isolate = it->isolate(); Maybe<bool> found = JSReceiver::HasProperty(it); if (!is_with_context || found.IsNothing() || !found.FromJust()) return found; Handle<Object> unscopables; ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, unscopables, JSReceiver::GetProperty(isolate, Handle<JSReceiver>::cast(it->GetReceiver()), isolate->factory()->unscopables_symbol()), Nothing<bool>()); if (!unscopables->IsJSReceiver()) return Just(true); Handle<Object> blacklist; ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, blacklist, JSReceiver::GetProperty(isolate, Handle<JSReceiver>::cast(unscopables), it->name()), Nothing<bool>()); return Just(!blacklist->BooleanValue(isolate)); } static PropertyAttributes GetAttributesForMode(VariableMode mode) { DCHECK(IsSerializableVariableMode(mode)); return IsConstVariableMode(mode) ? READ_ONLY : NONE; } // static Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, ContextLookupFlags flags, int* index, PropertyAttributes* attributes, InitializationFlag* init_flag, VariableMode* variable_mode, bool* is_sloppy_function_name) { Isolate* isolate = context->GetIsolate(); bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; *index = kNotFound; *attributes = ABSENT; *init_flag = kCreatedInitialized; *variable_mode = VariableMode::kVar; if (is_sloppy_function_name != nullptr) { *is_sloppy_function_name = false; } if (FLAG_trace_contexts) { PrintF("Context::Lookup("); name->ShortPrint(); PrintF(")\n"); } do { if (FLAG_trace_contexts) { PrintF(" - looking in context %p", reinterpret_cast<void*>(context->ptr())); if (context->IsScriptContext()) PrintF(" (script context)"); if (context->IsNativeContext()) PrintF(" (native context)"); PrintF("\n"); } // 1. Check global objects, subjects of with, and extension objects. DCHECK_IMPLIES(context->IsEvalContext() && context->has_extension(), context->extension().IsTheHole(isolate)); if ((context->IsNativeContext() || context->IsWithContext() || context->IsFunctionContext() || context->IsBlockContext()) && context->has_extension() && !context->extension_receiver().is_null()) { Handle<JSReceiver> object(context->extension_receiver(), isolate); if (context->IsNativeContext()) { DisallowHeapAllocation no_gc; if (FLAG_trace_contexts) { PrintF(" - trying other script contexts\n"); } // Try other script contexts. ScriptContextTable script_contexts = context->global_object().native_context().script_context_table(); ScriptContextTable::LookupResult r; if (ScriptContextTable::Lookup(isolate, script_contexts, *name, &r)) { Context context = script_contexts.get_context(r.context_index); if (FLAG_trace_contexts) { PrintF("=> found property in script context %d: %p\n", r.context_index, reinterpret_cast<void*>(context.ptr())); } *index = r.slot_index; *variable_mode = r.mode; *init_flag = r.init_flag; *attributes = GetAttributesForMode(r.mode); return handle(context, isolate); } } // Context extension objects needs to behave as if they have no // prototype. So even if we want to follow prototype chains, we need // to only do a local lookup for context extension objects. Maybe<PropertyAttributes> maybe = Nothing<PropertyAttributes>(); if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || object->IsJSContextExtensionObject()) { maybe = JSReceiver::GetOwnPropertyAttributes(object, name); } else { // A with context will never bind "this", but debug-eval may look into // a with context when resolving "this". Other synthetic variables such // as new.target may be resolved as VariableMode::kDynamicLocal due to // bug v8:5405 , skipping them here serves as a workaround until a more // thorough fix can be applied. // TODO(v8:5405): Replace this check with a DCHECK when resolution of // of synthetic variables does not go through this code path. if (ScopeInfo::VariableIsSynthetic(*name)) { DCHECK(context->IsWithContext()); maybe = Just(ABSENT); } else { LookupIterator it(object, name, object); Maybe<bool> found = UnscopableLookup(&it, context->IsWithContext()); if (found.IsNothing()) { maybe = Nothing<PropertyAttributes>(); } else { // Luckily, consumers of |maybe| only care whether the property // was absent or not, so we can return a dummy |NONE| value // for its attributes when it was present. maybe = Just(found.FromJust() ? NONE : ABSENT); } } } if (maybe.IsNothing()) return Handle<Object>(); DCHECK(!isolate->has_pending_exception()); *attributes = maybe.FromJust(); if (maybe.FromJust() != ABSENT) { if (FLAG_trace_contexts) { PrintF("=> found property in context object %p\n", reinterpret_cast<void*>(object->ptr())); } return object; } } // 2. Check the context proper if it has slots. if (context->IsFunctionContext() || context->IsBlockContext() || context->IsScriptContext() || context->IsEvalContext() || context->IsModuleContext() || context->IsCatchContext()) { DisallowHeapAllocation no_gc; // Use serialized scope information of functions and blocks to search // for the context index. ScopeInfo scope_info = context->scope_info(); VariableMode mode; InitializationFlag flag; MaybeAssignedFlag maybe_assigned_flag; IsStaticFlag is_static_flag; int slot_index = ScopeInfo::ContextSlotIndex(scope_info, *name, &mode, &flag, &maybe_assigned_flag, &is_static_flag); DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); if (slot_index >= 0) { // Re-direct lookup to the ScriptContextTable in case we find a hole in // a REPL script context. REPL scripts allow re-declaration of // script-level let bindings. The value itself is stored in the script // context of the first script that declared a variable, all other // script contexts will contain 'the hole' for that particular name. if (scope_info.IsReplModeScope() && context->get(slot_index).IsTheHole(isolate)) { context = Handle<Context>(context->previous(), isolate); continue; } if (FLAG_trace_contexts) { PrintF("=> found local in context slot %d (mode = %hhu)\n", slot_index, static_cast<uint8_t>(mode)); } *index = slot_index; *variable_mode = mode; *init_flag = flag; *attributes = GetAttributesForMode(mode); return context; } // Check the slot corresponding to the intermediate context holding // only the function name variable. It's conceptually (and spec-wise) // in an outer scope of the function's declaration scope. if (follow_context_chain && context->IsFunctionContext()) { int function_index = scope_info.FunctionContextSlotIndex(*name); if (function_index >= 0) { if (FLAG_trace_contexts) { PrintF("=> found intermediate function in context slot %d\n", function_index); } *index = function_index; *attributes = READ_ONLY; *init_flag = kCreatedInitialized; *variable_mode = VariableMode::kConst; if (is_sloppy_function_name != nullptr && is_sloppy(scope_info.language_mode())) { *is_sloppy_function_name = true; } return context; } } // Lookup variable in module imports and exports. if (context->IsModuleContext()) { VariableMode mode; InitializationFlag flag; MaybeAssignedFlag maybe_assigned_flag; int cell_index = scope_info.ModuleIndex(*name, &mode, &flag, &maybe_assigned_flag); if (cell_index != 0) { if (FLAG_trace_contexts) { PrintF("=> found in module imports or exports\n"); } *index = cell_index; *variable_mode = mode; *init_flag = flag; *attributes = SourceTextModuleDescriptor::GetCellIndexKind( cell_index) == SourceTextModuleDescriptor::kExport ? GetAttributesForMode(mode) : READ_ONLY; return handle(context->module(), isolate); } } } else if (context->IsDebugEvaluateContext()) { // Check materialized locals. Object ext = context->get(EXTENSION_INDEX); if (ext.IsJSReceiver()) { Handle<JSReceiver> extension(JSReceiver::cast(ext), isolate); LookupIterator it(extension, name, extension); Maybe<bool> found = JSReceiver::HasProperty(&it); if (found.FromMaybe(false)) { *attributes = NONE; return extension; } } // Check blacklist. Names that are listed, cannot be resolved further. Object blacklist = context->get(BLACK_LIST_INDEX); if (blacklist.IsStringSet() && StringSet::cast(blacklist).Has(isolate, name)) { if (FLAG_trace_contexts) { PrintF(" - name is blacklisted. Aborting.\n"); } break; } // Check the original context, but do not follow its context chain. Object obj = context->get(WRAPPED_CONTEXT_INDEX); if (obj.IsContext()) { Handle<Context> context(Context::cast(obj), isolate); Handle<Object> result = Context::Lookup(context, name, DONT_FOLLOW_CHAINS, index, attributes, init_flag, variable_mode); if (!result.is_null()) return result; } } // 3. Prepare to continue with the previous (next outermost) context. if (context->IsNativeContext()) break; context = Handle<Context>(context->previous(), isolate); } while (follow_context_chain); if (FLAG_trace_contexts) { PrintF("=> no property/slot found\n"); } return Handle<Object>::null(); } void NativeContext::AddOptimizedCode(Code code) { DCHECK(code.kind() == Code::OPTIMIZED_FUNCTION); DCHECK(code.next_code_link().IsUndefined()); code.set_next_code_link(get(OPTIMIZED_CODE_LIST)); set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER); } void NativeContext::SetOptimizedCodeListHead(Object head) { set(OPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER); } Object NativeContext::OptimizedCodeListHead() { return get(OPTIMIZED_CODE_LIST); } void NativeContext::SetDeoptimizedCodeListHead(Object head) { set(DEOPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER); } Object NativeContext::DeoptimizedCodeListHead() { return get(DEOPTIMIZED_CODE_LIST); } Handle<Object> Context::ErrorMessageForCodeGenerationFromStrings() { Isolate* isolate = GetIsolate(); Handle<Object> result(error_message_for_code_gen_from_strings(), isolate); if (!result->IsUndefined(isolate)) return result; return isolate->factory()->NewStringFromStaticChars( "Code generation from strings disallowed for this context"); } #define COMPARE_NAME(index, type, name) \ if (string->IsOneByteEqualTo(StaticCharVector(#name))) return index; int Context::IntrinsicIndexForName(Handle<String> string) { NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(COMPARE_NAME); return kNotFound; } #undef COMPARE_NAME #define COMPARE_NAME(index, type, name) \ { \ const int name_length = static_cast<int>(arraysize(#name)) - 1; \ if ((length == name_length) && strncmp(string, #name, name_length) == 0) \ return index; \ } int Context::IntrinsicIndexForName(const unsigned char* unsigned_string, int length) { const char* string = reinterpret_cast<const char*>(unsigned_string); NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(COMPARE_NAME); return kNotFound; } #undef COMPARE_NAME #ifdef DEBUG bool Context::IsBootstrappingOrValidParentContext(Object object, Context child) { // During bootstrapping we allow all objects to pass as // contexts. This is necessary to fix circular dependencies. if (child.GetIsolate()->bootstrapper()->IsActive()) return true; if (!object.IsContext()) return false; Context context = Context::cast(object); return context.IsNativeContext() || context.IsScriptContext() || context.IsModuleContext() || !child.IsModuleContext(); } #endif void NativeContext::ResetErrorsThrown() { set_errors_thrown(Smi::FromInt(0)); } void NativeContext::IncrementErrorsThrown() { int previous_value = errors_thrown().value(); set_errors_thrown(Smi::FromInt(previous_value + 1)); } int NativeContext::GetErrorsThrown() { return errors_thrown().value(); } STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 2); STATIC_ASSERT(Context::MIN_CONTEXT_EXTENDED_SLOTS == 3); STATIC_ASSERT(NativeContext::kScopeInfoOffset == Context::OffsetOfElementAt(NativeContext::SCOPE_INFO_INDEX)); STATIC_ASSERT(NativeContext::kPreviousOffset == Context::OffsetOfElementAt(NativeContext::PREVIOUS_INDEX)); STATIC_ASSERT(NativeContext::kExtensionOffset == Context::OffsetOfElementAt(NativeContext::EXTENSION_INDEX)); STATIC_ASSERT(NativeContext::kStartOfStrongFieldsOffset == Context::OffsetOfElementAt(-1)); STATIC_ASSERT(NativeContext::kStartOfWeakFieldsOffset == Context::OffsetOfElementAt(NativeContext::FIRST_WEAK_SLOT)); STATIC_ASSERT(NativeContext::kMicrotaskQueueOffset == Context::SizeFor(NativeContext::NATIVE_CONTEXT_SLOTS)); STATIC_ASSERT(NativeContext::kSize == (Context::SizeFor(NativeContext::NATIVE_CONTEXT_SLOTS) + kSystemPointerSize)); void NativeContext::SetDetachedWindowReason( v8::Context::DetachedWindowReason reason) { set_detached_window_reason(Smi::FromEnum(reason)); } v8::Context::DetachedWindowReason NativeContext::GetDetachedWindowReason() const { return static_cast<v8::Context::DetachedWindowReason>( detached_window_reason().value()); } } // namespace internal } // namespace v8
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0xcf67, %rdx nop nop sub $10773, %rcx mov (%rdx), %esi nop nop nop nop and $42159, %r11 lea addresses_normal_ht+0x2d67, %rcx nop nop nop nop add %r12, %r12 mov $0x6162636465666768, %r11 movq %r11, %xmm1 movups %xmm1, (%rcx) nop nop nop nop sub $63112, %rcx lea addresses_normal_ht+0x137c7, %rsi lea addresses_A_ht+0xc867, %rdi nop nop nop mfence mov $116, %rcx rep movsb nop nop nop cmp %rdx, %rdx lea addresses_D_ht+0x1ab3f, %rsi lea addresses_WT_ht+0x1ee67, %rdi cmp %r15, %r15 mov $81, %rcx rep movsl nop nop nop nop dec %rdi lea addresses_UC_ht+0x6a4b, %rsi lea addresses_WT_ht+0xbb67, %rdi nop dec %rdx mov $108, %rcx rep movsw nop cmp %rdx, %rdx lea addresses_UC_ht+0x18fa7, %rsi lea addresses_UC_ht+0xc8b8, %rdi nop add %r11, %r11 mov $53, %rcx rep movsl nop nop nop xor %rsi, %rsi lea addresses_A_ht+0x1c367, %rsi lea addresses_WT_ht+0x1e367, %rdi sub $9368, %r12 mov $101, %rcx rep movsl nop nop nop nop nop and $11349, %rcx lea addresses_WC_ht+0xfc67, %rsi lea addresses_A_ht+0x13b67, %rdi nop nop nop nop nop inc %r8 mov $85, %rcx rep movsb nop xor %r12, %r12 lea addresses_D_ht+0x13f41, %rsi lea addresses_WT_ht+0x1dfe7, %rdi nop nop nop nop nop and $34154, %r8 mov $26, %rcx rep movsl add $6571, %r12 lea addresses_normal_ht+0x4c67, %r11 nop nop nop and %r15, %r15 mov $0x6162636465666768, %rdx movq %rdx, (%r11) nop nop nop nop cmp $6957, %r11 lea addresses_WT_ht+0x10179, %rsi lea addresses_UC_ht+0xeb67, %rdi nop nop nop xor %r8, %r8 mov $78, %rcx rep movsl nop nop xor $4271, %r8 lea addresses_A_ht+0xbf27, %r8 nop cmp %rsi, %rsi movb (%r8), %dl nop nop add $41774, %rcx lea addresses_A_ht+0x2195, %rcx and $7775, %r15 mov (%rcx), %edx cmp $60541, %r15 lea addresses_normal_ht+0x13dc3, %rsi lea addresses_normal_ht+0x1cde7, %rdi add %rdx, %rdx mov $6, %rcx rep movsq nop nop nop nop nop cmp %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r8 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_RW+0x4028, %rsi lea addresses_PSE+0xe95, %rdi nop and $23780, %rbp mov $94, %rcx rep movsl nop nop nop and $46318, %rdi // Store lea addresses_WT+0x16967, %rsi nop nop and %rbx, %rbx mov $0x5152535455565758, %rbp movq %rbp, %xmm6 vmovups %ymm6, (%rsi) nop nop xor %r8, %r8 // Store lea addresses_RW+0xfce7, %rbx nop add $32333, %rcx mov $0x5152535455565758, %rax movq %rax, %xmm7 movups %xmm7, (%rbx) nop and %rbp, %rbp // Store lea addresses_A+0xe4e7, %rdi nop nop nop nop nop and %rbx, %rbx mov $0x5152535455565758, %r8 movq %r8, %xmm5 movups %xmm5, (%rdi) add %rbx, %rbx // Load lea addresses_normal+0xec67, %rbx nop nop nop nop nop xor $39207, %rdi mov (%rbx), %ax nop nop nop nop xor %rax, %rax // Store lea addresses_US+0x162df, %rdi nop nop add $24702, %rsi mov $0x5152535455565758, %r8 movq %r8, %xmm5 vmovntdq %ymm5, (%rdi) nop nop add $35497, %rsi // Store lea addresses_US+0x1e247, %rsi nop nop cmp $36954, %rbp mov $0x5152535455565758, %r8 movq %r8, %xmm5 movups %xmm5, (%rsi) nop dec %rdi // Faulty Load lea addresses_RW+0x8b67, %rdi clflush (%rdi) nop nop dec %rax movups (%rdi), %xmm3 vpextrq $0, %xmm3, %rcx lea oracles, %rbp and $0xff, %rcx shlq $12, %rcx mov (%rbp,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_PSE'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_RW'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 7}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 2}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal', 'congruent': 7}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_US', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_US', 'congruent': 4}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 6}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}} {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 7}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 1}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
.386 .MODEL SMALL PUBLIC SHOW_ALL PUBLIC PRINT_NUM PUBLIC SHOW_ICONS PUBLIC CAL_PROFIT PUBLIC SORT_PROFIT PUBLIC CLEAR_SCREEN PUBLIC S1,GA1,S2,GB1 PUBLIC ATTR_OFF,MEN_ATTR STACK SEGMENT USE16 STACK 'STACK' DB 200 DUP(0) STACK ENDS ;------------------------------- DATA SEGMENT USE16 PUBLIC 'D' BNAME DW 'IX' xor 12788,'GN' xor 12788 ,'R ' xor 12788,'LU' xor 12788,'NI' xor 12788,77 ;系统登录名 BPASS DW 'ET' xor 12788,'TS' xor 12788 ,77,0 ;系统登陆密码 IN_NAME DB 10+1,?,11 DUP(0) ;为回车预留一位 IN_PWD DB 6+1,?,7 DUP(0) ;为回车预留一位 IN_PRO DB 10+1,?,11 DUP(0) ;为回车预留一位 NA_MEN DB 'Please input the username: $' ;显示信息-输入姓名 PWD_MEN DB 'Please input the password: $' ;显示信息-输入密码8 FAIL DB 'Login failed: Press any key to continue! $' ;显示信息-登录失败 FAIL_TH DB 'Three failures in landing, You will be landing as a visitor! $' PRO_MEN DB 'Please enter the product name: $' ;显示信息-输入商品名称 AUTH DB ? ;存放登陆状态 F_TIME DB 0 ;存放错误次数 N EQU 30 ;存放商品类别数 ;------------------------------- ;第一个网店信息 S1 DB 'SHOP1',0 ;网店名称 GA1 DB 'BOOK',6 DUP(0) ;第一个商品名称 DW 35 xor 12788,56,70,25,? ;分别为第一个商品 进价,售价,进货量,已售量,利润率 GA2 DB 'PEN',7 DUP(0) ;... DW 12 xor 12788,30,25,5,? GAN DB N-2 DUP('Temp-Value',15 xor 244,49,20,0,30,0,2,0,?,?) ;------------------------------- ;第二个网店信息 S2 DB 'SHOP2',0 ;网店名称 GB1 DB 'BOOK',6 DUP(0) ;第一个商品名称 DW 12 xor 12788,28,20,15,? ;分别为第一个商品 进价,售价,进货量,已售量,利润率 GB2 DB 'PEN',7 DUP(0) ;... 57 DW 35 xor 12788,50,30,24,? GBN DB N-2 DUP('Temp-Value',15 xor 244,49,20,0,30,0,2,0,?,?) ;------------------------------- OUT_SHOP EQU 1H OUT_NAME EQU 2H OUT_INPRI EQU 4H OUT_OUTPRI EQU 8H OUT_INNUM EQU 10H OUT_OUTNUM EQU 20H OUT_RANK EQU 40H ;既表示利润率信息 又表示rank信息 MEN_ATTR DB 'Shop No.: $ ', 'Product Name: $ ', 'Product Purchase Price: $ ', 'Product Selling Price: $ ', 'Product Purchase Volume: $ ', 'Product Sales Volume: $ ', 'Product Average Profit: $ ', 'Product Profit Ranking: $ ' ATTR_OFF DB 0,0,10,12,14,16,18 ICONS_FILE DB 'C:\ICONS.txt',0 FAIL_INQUIRED_GOODS_INFORM DB 'Wrong inquired goods input! Please try again ', 0AH, 0DH, '$' FAIL_MODIFIED_GOODS_INFORM DB 'Wrong goods input! Please try again', 0AH, 0DH, '$' INQ_INFORM DB 'Please enter the inquired goods name: $' MOD_SHOP_INFORM DB 'Please enter the shop name: $' MOD_GOOD_INFORM DB 'Please enter the modified goods name: $' PAGE_TRANS_INFORM DB 'Press page up/down to get more info Press ESC to quit$' POWED_BY_INFORM DB 'Powered by $' MODE_INFORM DB 'Please enter the display mode [0-1]: $' CAL_SUCCESS DB 'Succeed in calculating the profit rate! $' RANK_SUCCESS DB 'Succeed in ranking the profit rate! $' SHOW_MENU_TITLE DB 'SHOW MENU$' SHOW_MENU_1 DB '1.INQUIRE GOODS INFO$' SHOW_MENU_2 DB '2.MODIFY GOODS INFO$' SHOW_MENU_3 DB '3.CALCUL THE PROFIT$' SHOU_MENU_4 DB '4.RANK CALCUL PROFIT$' SHOW_MENU_5 DB '5.SHOW ALL GOOD INFO$' SHOW_MENU_6 DB '6.EXIT $' SHOW_MENU_CHOOSE DB 'Please enter the choice: $' BUF DB 15 DUP(0) ORDER DW N*2*2 DUP(0) INQ_GA DB 80,?,80 DUP(0) MOD_SHOP DB 80,?,80 DUP(0) MOD_GA DB 80,?,80 DUP(0) MOD_DATA DB 80,?,80 DUP(0) CHOICE DB 80,?,80 DUP(0) ;------------------------------- KEY_LENTH DB 2 xor 'B' KEY DB (244-34)/5,(49-34)/5 ORIGINAL_IP DW 0,? ORIGINAL_CS DW 0,? ANTI_ADDR DW ANTI,? EXIT_ADDR DW EXIT DATA ENDS ;------------------------------- CODE SEGMENT USE16 PUBLIC 'C' ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK IN_STRING MACRO A,B ;宏定义 输入字符串 A表示输入时的提示信息 B表示输入字符串的位置偏移量 LEA DX,A ;将提示信息字符串偏移地址存入DX MOV AH,9 ;将代表显示字符串的9号调用存入AH INT 21H ;执行中断 LEA DX,B ;将存放输入信息的字符串偏移地址存入DX MOV AH,10 ;将代表输入字符串的10号调用存入AH INT 21H ;执行中断 MOV DL,10 ;将换行符存入DL MOV AH,2 ;将代表输出字符的2号调用存入AH INT 21H ;执行中断 ENDM ;结束宏定义 ;------------------------------- OUT_INFO MACRO A,B ;宏定义 输出信息 A表示输出信息(字符串偏移地址 或者 字符) B表示输出类型 MOV DX,A ;将待输出的 字符串偏移地址 或 字符 存入DX MOV AH,B ;将输出类型存入AH 可能为9or2 分别表示输出字符串 和 字符 INT 21H ;调用中断 ENDM ;结束宏定义 ;------------------------------- CAL_RATE MACRO A ;计算商品利润率并保存到对应位置 参数--商品信息存放位置 XOR EDX,EDX ;高位补0 MOVZX EAX,WORD PTR DS:[A+10];计算总收入 EAX=售价 UNCHIFF MOVZX ECX,WORD PTR DS:[A+10+2*2];ECX=售货量 MUL ECX ;EAX=总收入 MOVZX ECX,WORD PTR DS:[A+10+2*1] ;计算成本 EBX=进价 MOVZX EDI,WORD PTR DS:[A+10+2*3];ECX=进货量 IMUL ECX,EDI ;EBX=总成本 XCHG EAX,ECX IMUL EAX,100 ;将总收入乘以100 这样会获得百分比下的整数部分 IDIV ECX ;除以成本 SUB EAX,100 ;减去成本 MOV word ptr DS:[A+10+2*4],AX ;将计算得到的利润率百分之下的整数部分存入AX ENDM ;------------------------------- CHIFF MACRO A,B LOCAL CIRCLE,NTO0 PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI PUSH BP MOV SI,A MOV CX,B MOVZX DX,BYTE PTR [KEY_LENTH] XOR DL,'B' PUSH DX MOV BX,0 MOV BP,0 LEA DI,KEY CIRCLE: MOV DL,[SI+BX] MOV AL,DS:[DI+BP] MOV AH,5 MUL AH ADD AL,34 XOR DL,AL MOV [SI+BX],DL INC BX INC BP XCHG DI,[ESP] CMP BP,DI JNZ NTO0 XOR BP,BP NTO0: XCHG DI,[ESP] CMP BX,CX JNZ CIRCLE POP DX POP BP POP DI POP SI POP DX POP CX POP BX POP AX ENDM ;------------------------------- UNCHIFF MACRO LOCAL CIRCLE,NTO0 PUSH CX PUSH DX PUSH DI MOV DX,AX LEA DI,KEY MOV AL,DS:[DI] MOV AH,5 MUL AH ADD AL,34 MOV CL,AL MOV AL,DS:[DI+1] MOV AH,5 MUL AH ADD AL,34 MOV AH,AL MOV AL,CL XOR AX,DX POP DI POP DX POP CX ENDM ;------------------------------- SHOW_INFO MACRO A,B,C LOCAL PRE_LPP4,LOOPP4,OUT_ATTR,OUT_NEXT,LP,P_NUM,NEXTP4,OUT_10,FINISH,J_P_N PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI PUSH BP MOV CX,A MOV SI,B MOV DI,C ADD CX,48 SHR DI,1 JNC PRE_LPP4 OUT_INFO <OFFSET MEN_ATTR>,9 OUT_INFO CX,2 MOV CH,1 PRE_LPP4: MOV BX,1 LOOPP4: SHR DI,1 JNC NEXTP4 CMP CH,0 JE OUT_ATTR OUT_INFO 10,2 OUT_ATTR: INC CH MOV BP,BX CMP BX,6 JNE OUT_NEXT CMP CL,'2' JNE OUT_NEXT INC BP OUT_NEXT: IMUL BP,30 ADD BP,OFFSET MEN_ATTR OUT_INFO BP,9 MOVZX BP,BYTE PTR [BX+ATTR_OFF] ADD BP,SI CMP BX,1 JNE P_NUM MOV DH,10 LP: CMP DH,0 JE NEXTP4 MOV DL,DS:[BP] MOV AH,2 INT 21H INC BP DEC DH JMP LP P_NUM: PUSH AX MOV AX,DS:[BP] CMP BX,2 JNE J_P_N UNCHIFF J_P_N: PUSH AX CALL PRINT_NUM POP AX CMP BX,6 JNE NEXTP4 CMP CL,'1' JNE NEXTP4 OUT_INFO '%',2 NEXTP4: INC BX CMP BX,7 JB LOOPP4 OUT_10: CMP CH,1 JE FINISH OUT_INFO 10,2 FINISH: POP BP POP DI POP SI POP DX POP CX POP BX POP AX ENDM ;------------------------------- START: MOV AX,DATA ;将DATA的段地址存入AX MOV DS,AX ;将数据段与DATA建立联系 MOV ES,AX ;将附加数据段与DATA建立联系 (此时数据段和附加数据段重叠 均访问DATA 方便之后串操作 SI默认访问当前数据段 DI默认访问当前附加数据段) MOV AH,0 MOV AL,12H INT 10H CLI MOV BP,WORD PTR ANTI_ADDR PUSH BP MOV AH,2ch POP BX MOV CX,[ESP-2] PUSH BX STI CALL CX CMP AX,1 JZ EXIT CMP AX,0 JNZ EXIT MOV WORD PTR ANTI_ADDR,0 IN_NAME_PAS: ;功能一:输入账号 密码 MOV BYTE PTR AUTH,0 ;将登陆状态重置为0 (有可能之后会重新登陆) IN_STRING NA_MEN,IN_NAME ;输入账号 LEA BX,IN_NAME ;判断名字输入是否为回车或者q CMP BYTE PTR [BX+1],1 ;如果长度大于1那么为正常输入情况 JA CONTINUE ;继续输入密码 CMP BYTE PTR [BX+2],13 ;长度<=1与回车ASCLL码比较 JZ IN_PRO_NAME ;是则直接跳转到功能三:计算利润的输入商品名 此时AUTH=0 CMP BYTE PTR [BX+2],'q' ;不等与'q'比较 JZ EXIT ;相等则直接退出 MOV BP,[ESP] MOV ANTI_ADDR,BP CONTINUE: ;否则继续 IN_STRING PWD_MEN,IN_PWD ;输入密码 CALL BP CMP AX,1 JZ EXIT CMP_NAME_PAS: ;比较用户名密码是否正确 PUSH OFFSET BNAME ;传参--将正确用户名入栈 PUSH OFFSET IN_NAME ;传参--将输入的用户名入栈 CALL JUDGE ;调用子程序比较用户名 CMP AX,0 ;比较返回值AX 1表示相等 0表示不等 JNE CMP_PAS INC BYTE PTR F_TIME CMP BYTE PTR F_TIME,3 JE IN_PRO_NAME JMP FAIL_LOG ;等于0就跳转到提示函数 否则继续 CMP_PAS: PUSH OFFSET BPASS ;传参--将正确密码入栈 PUSH OFFSET IN_PWD ;传参--将输入的密码入栈 CALL JUDGE ;调用子程序比较密码 CMP AX,0 ;比较返回值AX 1表示相等 0表示不等 JNE SUCCESS INC BYTE PTR F_TIME CMP BYTE PTR F_TIME,3 JE IN_PRO_NAME JMP FAIL_LOG ;等于0就跳转到提示函数 否则继续 SUCCESS: MOV BYTE PTR AUTH,1 ;若之前没有跳转 说明成功登陆 将AUTH赋值为1 IN_PRO_NAME: ;输入商品名称 ;IN_STRING PRO_MEN,IN_PRO ;使用宏输入商品名称 CMP BYTE PTR AUTH,1 JE JM OUT_INFO <OFFSET FAIL_TH>,9 MOV AH,1 INT 21H JM: JMP SHOW_MENU FAIL_LOG: ;登陆失败 OUT_INFO <OFFSET FAIL>,9 ;调用宏输出登陆失败信息 OUT_INFO 10,2 MOV AH,1 ;输入一个字符 -- 按任意键继续 INT 21H ;执行中断 JMP IN_NAME_PAS ;------------------------------- JUDGE PROC ;参数字符串原串 目的串 PUSH BP ;栈:原串(2) 目的串(2) 子程序返回地址(2) BP(2) BP在栈中的位置也是BP指向的位置 MOV BP,SP ;栈:原串(2) 目的串(2) 子程序返回地址(2) BP(2) PUSH BX ;栈:原串(2) 目的串(2) 子程序返回地址(2) BP(2) BX(2) PUSH CX ;栈:原串(2) 目的串(2) 子程序返回地址(2) BP(2) BX(2) CX(2) PUSH DX XCHG DI,[BP+6] ;DI存储原串 方便等会串搜索 栈:DI(2) 目的串(2) 子程序返回地址(2) BP(2) BX(2) CX(2) XCHG SI,[BP+4] ;SI存储目的串 栈:DI(2) SI(2) 子程序返回地址(2) BP(2) BX(2) CX(2) cli MOV AH,2CH MOV BX,DI ;将原串的偏移量放在BX INT 21H MOV AL,77 ;将搜索值0放在AL 即搜索结束标记 PUSH DX MOVZX CX,BYTE PTR [SI] ;将搜索次数放在CX REPNE SCASB ;执行串搜索 执行完后DI为字符串结束标记0的偏移量 SUB DI,BX ;获得原串长度 存放到DI DEC DI XCHG DI,BX ;交换DI,BX BX为长度 DI为原串起始地址 MOV AH,2CH INT 21H STI MOV AX,WORD PTR EXIT_ADDR CMP DX,[ESP] POP DX JE COMPARE JMP AX COMPARE: MOVSX AX,BYTE PTR [SI+1] ;将目的串长度存入AX CMP BX,AX ;比较原串与目的串长度 JNZ NO ;不相等则返回0 ADD SI,2 CHIFF SI,BX MOV CX,BX ;POP CX ;否则开始比较各个位 将比较长度存入CX ;ADD SI,2 ;将SI变成目的串的起始地址 REPE CMPSB ;开始比较 JNZ NO ;如果不相等则返回0 YES:MOV AX,1 ;否则返回1 将返回值放在AX中 JMP JUDGE_RET ;跳转到返回处 NO: MOV AX,0 ;否则返回0 JUDGE_RET: POP DX POP CX ;栈:DI(2) SI(2) 子程序返回地址(2) BP(2) BX(2) POP BX ;栈:DI(2) SI(2) 子程序返回地址(2) BP(2) MOV SI,[BP+4] ;栈:DI(2) SI(2) 子程序返回地址(2) BP(2) MOV DI,[BP+6] ;栈:DI(2) SI(2) 子程序返回地址(2) BP(2) POP BP ;栈:DI(2) SI(2) 子程序返回地址(2) RET 4 ;跳转到栈顶指向的IP 忽略4个字节 JUDGE ENDP ;------------------------------- SHOW_MENU: CALL CLEAR_SCREEN CALL SHOW_ICONS MOV DH, 7 MOV DL, 30 MOV BH, 0 MOV AH, 02H INT 10H LEA DX, SHOW_MENU_TITLE MOV AH, 9 INT 21H MOV CL, 7 MOV CH, 0 LEA SI, SHOW_MENU_1 SHOW_MENU_CIR: INC CL INC CH MOV DH, CL MOV DL, 25 MOV BH, 0 MOV AH, 02H INT 10H MOV DX, SI MOV AH, 9 INT 21H ADD SI, 21 CMP BYTE PTR AUTH,0 JNE CMP6 ADD SI, 21*4 ADD CH, 4 CMP6: CMP CH, 6 JNAE SHOW_MENU_CIR ADD CL, 2 ;行数 MOV DH, CL MOV DL, 23 MOV BH, 0 MOV AH, 02H INT 10H LEA DX, SHOW_MENU_CHOOSE MOV AH, 9 INT 21H LEA DX, CHOICE MOV AH, 10 INT 21H CALL CLEAR_SCREEN CMP BYTE PTR[CHOICE + 2], '1' JZ SHOW_1 CMP BYTE PTR AUTH,0 JZ JUDGE_6 CMP BYTE PTR[CHOICE + 2], '2' JZ SHOW_2 CMP BYTE PTR[CHOICE + 2], '3' JZ SHOW_3 CMP BYTE PTR[CHOICE + 2], '4' JZ SHOW_4 CMP BYTE PTR[CHOICE + 2], '5' JZ SHOW_5 JUDGE_6: CMP BYTE PTR[CHOICE + 2], '6' JZ SHOW_6 JMP SHOW_MENU SHOW_1: CALL INQ_INFO MOV AH, 1 INT 21H JMP SHOW_MENU SHOW_2: CALL MOD_INFO JMP SHOW_MENU SHOW_3: CALL CAL_PROFIT JMP SHOW_MENU SHOW_4: CALL SORT_PROFIT JMP SHOW_MENU SHOW_5: CALL SHOW_ALL JMP SHOW_MENU SHOW_6: CALL EXIT JMP SHOW_MENU EXIT PROC MOV AH, 4CH INT 21H EXIT ENDP ;------------------------------- INQ_INFO PROC ;查询商品信息 F_3_1: PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI IN_STRING INQ_INFORM,INQ_GA ;输入查询商品信息 LEA BX, INQ_GA + 2 ;商品名称偏移地址 CMP BYTE PTR[BX], 0DH JE F_3_1_BACK ;输入回车,回到功能三1 LEA AX, GA1 ;商品1的偏移地址 MOV CL, N F_3_1_1: ;循环网店中所有商品 MOV DI, AX ;已有商品的偏移地址 MOV SI, BX ;输入商品的偏移地址 F_3_1_2: ;比较两个商品字节 MOV CH, BYTE PTR[SI] CMP CH, BYTE PTR[DI] JNE F_3_1_3 INC SI INC DI CMP BYTE PTR[DI], 0 JNZ F_3_1_2 CMP BYTE PTR[SI], 0DH JNZ F_3_1_2 JMP JUDGE_1 ;成功找到匹配目标 F_3_1_3: ;继续循环,比较下一件商品 ADD AX, 20 DEC CL JNZ F_3_1_1 JMP FAIL_INQUIRED_GOODS ;未找到,提示重新输入商品 JUDGE_1: ;AX为当前商品的偏移地址 ;----------------------------输出商品信息 SHOW_INFO 1, AX, OUT_SHOP+OUT_NAME+OUT_INPRI+OUT_INNUM+OUT_OUTNUM ADD AX,OFFSET GB1 SUB AX,OFFSET GA1 SHOW_INFO 2, AX, OUT_SHOP+OUT_NAME+OUT_INPRI+OUT_INNUM+OUT_OUTNUM F_3_1_BACK: POP DI POP SI POP DX POP CX POP BX POP AX RET INQ_INFO ENDP ;------------------------------- MOD_INFO PROC ;修改商品信息 F_3_2: PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI IN_STRING MOD_SHOP_INFORM, MOD_SHOP ;输入修改商品的商店信息 IN_STRING MOD_GOOD_INFORM, MOD_GA ;输入修改商品信息 LEA BX, MOD_GA + 2 ;商品名称偏移地址 CMP BYTE PTR[BX], 0DH JE F_3_2_BACK ;输入回车,回到功能三1 MOV CL, N LEA AX, GA1 ;待修改商品的商店偏移地址 CMP BYTE PTR[MOD_SHOP + 2], '1' JZ F_3_2_1 ADD AX,OFFSET GB1 SUB AX,OFFSET GA1 F_3_2_1: ;循环网店中所有商品 MOV DI, AX ;已有商品的偏移地址 MOV SI, BX ;输入商品的偏移地址 F_3_2_2: ;比较两个商品字节 MOV CH, BYTE PTR[SI] CMP CH, BYTE PTR[DI] JNE F_3_2_3 INC SI INC DI CMP BYTE PTR[DI], 0 JNZ F_3_2_2 CMP BYTE PTR[SI], 0DH JNZ F_3_2_2 JMP JUDGE_2 ;成功找到匹配目标 F_3_2_3: ;继续循环,比较下一件商品 ADD AX, 20 DEC CL JNZ F_3_2_1 JMP FAIL_MODIFIED_GOODS ;未找到,提示重新输入商品 JUDGE_2: ;AX为当前商品的偏移地址 ;----------------------------输出商品信息 MOV BX, OUT_INPRI ;BX--输出哪项数据 MOV DI, 0 PUSH AX F_3_2_4: POP AX SHOW_INFO 1, AX, BX PUSH AX MOV DL, '>' MOV AH, 2 INT 21H LEA DX, MOD_DATA MOV AH, 10 INT 21H LEA CX, MOD_DATA + 2 PUSH BX MOV BX, CX CMP BYTE PTR[BX], 0DH ;输入回车 POP BX JZ F_3_2_6 MOV SI, CX F_3_2_5: CMP BYTE PTR[SI], '0' JB FAIL_ILLEGAL_INPUT CMP BYTE PTR[SI], '9' JA FAIL_ILLEGAL_INPUT INC SI CMP BYTE PTR[SI], 0DH JNZ F_3_2_5 LEA SI, MOD_DATA + 2 MOV DX, 0 F_3_2_IN: MOV CL, BYTE PTR[SI] SUB CL, 30H MOV CH, 0 IMUL DX, 10 ADD DX, CX INC SI CMP BYTE PTR[SI], 0DH JNZ F_3_2_IN POP AX PUSH BX MOV BX, AX MOV WORD PTR[BX + DI + 10], DX POP BX PUSH AX F_3_2_6: MOV DL, 0AH MOV AH, 2 INT 21H MOV DL, 0DH MOV AH, 2 INT 21H ADD DI, 2 SAL BX, 1 CMP BX, 20H JNZ F_3_2_4 POP AX F_3_2_BACK: POP DI POP SI POP DX POP CX POP BX POP AX RET MOD_INFO ENDP FAIL_ILLEGAL_INPUT: MOV DL, 0AH MOV AH, 2 INT 21H MOV DL, 0DH MOV AH, 2 INT 21H JMP F_3_2_4 FAIL_MODIFIED_GOODS: LEA DX, FAIL_MODIFIED_GOODS_INFORM MOV AH, 9 INT 21H MOV AH, 1 INT 21H POP DI POP SI POP DX POP CX POP BX POP AX JMP F_3_2 FAIL_INQUIRED_GOODS: LEA DX, FAIL_INQUIRED_GOODS_INFORM MOV AH, 9 INT 21H MOV AH, 1 INT 21H POP DI POP SI POP DX POP CX POP BX POP AX JMP F_3_1 ;------------------------------- CAL_PROFIT PROC ;计算商品利润率并保存到对应位置 参数--商品信息存放位置 PUSH ESI PUSH EDI PUSH EBP PUSH EAX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) PUSH EBX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) PUSH ECX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) ECX(4) PUSH EDX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) ECX(4) EDX(4) LEA EBX,GA1 LEA EBP,GB1 SUB EBP,EBX LOOPP5: ;循环找到DI(输入的商品名称)对应的商品 REFRESH: CAL_RATE EBX ;获得一号商店该商品利润率 CAL_RATE EBX+EBP ;获得二号商店该商品利润率 MOV AX,DS:[EBX+18] ADD AX,DS:[EBP+EBX+18] SAR AX,1 MOV [EBX+18],AX ADD BX,20 CMP BX,OFFSET GA1+20*N JB LOOPP5 CALL CLEAR_SCREEN OUT_INFO <OFFSET CAL_SUCCESS>,9 MOV AH,1 INT 21H POP EDX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) ECX(4) POP ECX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) POP EBX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) EBX(4) POP EAX ;栈:SI(2) 子程序返回地址(2) BP(2) EAX(4) POP EBP POP EDI POP ESI RET CAL_PROFIT ENDP ;------------------------------- SORT_PROFIT PROC PUSH AX PUSH EBX PUSH CX PUSH DX PUSH ESI PUSH DI PUSH BP MOV CX,1 XOR DI,DI MOV BP,-101 S_RLP1: MOV AX,-101 XOR EBX,EBX S_RLP2: MOV DX,WORD PTR [EBX+GB1+18] CMP DX,AX JNG NEXT_LP2 MOV AX,DX MOV ESI,EBX NEXT_LP2: ADD EBX,20 CMP EBX,N*20 JB S_RLP2 MOV DX,CX CMP BP,AX JZ SAME MOV BP,AX XOR DI,DI JMP ASSIGN SAME: INC DI ASSIGN: SUB DX,DI NEG DX SUB DX,100 MOV WORD PTR [ESI+GB1+18],DX INC CX CMP CX,N JBE S_RLP1 XOR EBX,EBX S_RLP3: MOV DX,WORD PTR [EBX+GB1+18] ADD DX,100 NEG DX MOV WORD PTR [EBX+GB1+18],DX ADD EBX,20 CMP EBX,N*20 JB S_RLP3 CALL CLEAR_SCREEN OUT_INFO <OFFSET RANK_SUCCESS>,9 MOV AH,1 INT 21H POP BP POP DI POP ESI POP DX POP CX POP EBX POP AX RET SORT_PROFIT ENDP ;------------------------------- SHOW_ALL PROC PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI SELECT: CALL CLEAR_SCREEN OUT_INFO <OFFSET MODE_INFORM>,9 LEA DX,CHOICE MOV AH,10 INT 21H CALL CLEAR_SCREEN CMP CHOICE[2],'0' JE TYPE1 CMP CHOICE[2],'1' JE TYPE2 CMP CHOICE[2],13 JE S_W_RET JMP SELECT TYPE1: LEA DI,ORDER LEA SI,GA1 SP1:MOV [DI],SI MOV WORD PTR [DI+2],1 ADD DI,4 ADD SI,20 CMP SI,OFFSET GA1+N*20 JB SP1 LEA SI,GB1 SP2:MOV [DI],SI MOV WORD PTR [DI+2],2 ADD DI,4 ADD SI,20 CMP SI,OFFSET GB1+N*20 JB SP2 JMP DISPLAY TYPE2: LEA DI,ORDER MOV CX,1 MOV SI,1 SP3:MOV BX,0 SP4:CMP WORD PTR [BX+GB1+18],SI JNE N_SP4 INC CX MOV AX,OFFSET GA1 ADD AX,BX MOV [DI],AX MOV WORD PTR [DI+2],1 ADD AX,OFFSET GB1-OFFSET GA1 MOV [DI+4],AX MOV WORD PTR [DI+6],2 ADD DI,8 N_SP4: ADD BX,20 CMP BX,N*20 JB SP4 INC SI CMP CX,N JB SP3 DISPLAY: MOV DI,0 PRINT4: MOV SI,DI IMUL SI,16 ADD SI,OFFSET ORDER CALL CLEAR_SCREEN MOV CX,4 S_WLP1: SHOW_INFO [SI+2],[SI],127 ADD SI,4 CMP SI,OFFSET ORDER+N*2*4 JAE H_I DEC CX JNE S_WLP1 H_I:OUT_INFO 10,2 OUT_INFO <OFFSET PAGE_TRANS_INFORM>,9 DIRECT: MOV AH,0 INT 16H CMP AH,48H JE PAGE_UP CMP AH,50H JE PAGE_DOWN CMP AH,01H JE S_W_RET JMP DIRECT PAGE_UP: CMP DI,0 JE PRINT4 DEC DI JMP PRINT4 PAGE_DOWN: CMP DI,N/2-1 JAE PRINT4 INC DI JMP PRINT4 S_W_RET: POP DI POP SI POP DX POP CX POP BX POP AX RET SHOW_ALL ENDP ;------------------------------- CLEAR_SCREEN PROC PUSH AX PUSH BX PUSH CX PUSH DX XOR BH,BH XOR CH,CH C_SLP1: XOR CL,CL MOV DX,CX MOV AH,02H INT 10H PUSH CX XOR BH,BH MOV CX,80 MOV AL,' ' MOV BL,0FH MOV AH,09H INT 10H POP CX INC CH CMP CH,30 JB C_SLP1 XOR DX,DX XOR BH,BH MOV AH,02H INT 10H POP DX POP CX POP BX POP AX RET CLEAR_SCREEN ENDP ;------------------------------- SHOW_ICONS PROC PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI MOV BH,0 MOV DH,28 MOV DL,61 MOV AH,02H INT 10H LEA DX,POWED_BY_INFORM MOV AH,9 INT 21H LEA DX,ICONS_FILE MOV AL,0 MOV AH,3DH INT 21H MOV SI,AX MOV BX,0 S_ILP1: MOV DI,0 S_ILP2: PUSH BX MOV BX,SI MOV CX,1 LEA DX,BUF MOV AH,3FH INT 21H POP BX CMP BYTE PTR BUF,'0' JZ NS_ILP2 MOV DX,430 MOV CX,580 ADD DX,BX ADD CX,DI MOV AL,3 MOV AH,0CH INT 10H NS_ILP2: INC DI CMP DI,60 JB S_ILP2 PUSH BX MOV BX,SI MOV CX,2 LEA DX,BUF MOV AH,3FH INT 21H POP BX INC BX CMP BX,40 JB S_ILP1 MOV BX,SI MOV AH,3EH INT 21H POP DI POP SI POP DX POP CX POP BX POP AX RET SHOW_ICONS ENDP ;------------------------------- ;功能:讲AX中的有符号二进制数以十进制形式在显示器上输出 ;入口参数:AX - 存放待转换的有符号二进制数 ;出口参数:转换后的带符号十进制数载显示器上输出 ;所用寄存器: EBX--用来存放基数10 ; SI---用来作10进制数ASCLL码存储区的指针 ;调用子程序: RADIX PRINT_NUM PROC PUSH BP MOV BP,SP PUSH EAX PUSH EBX PUSH DX PUSH SI ;保存现场 LEA SI, BUF MOVSX EAX,WORD PTR [BP+4] B: OR EAX, EAX JNS PLUS NEG EAX MOV BYTE PTR[SI], '-' INC SI PLUS: MOV EBX, 10 CALL RADIX MOV BYTE PTR[SI], '$' LEA DX, BUF MOV AH, 9 INT 21H POP SI POP DX POP EBX POP EAX POP BP RET 2 PRINT_NUM ENDP ;------------------------------- ;功能:将EAX中的32位无符号二进制数转换为10进制 ;入口参数: ; EAX -- 存放带转换的32位无符号二进制数 ; EBX -- 存放要转换进制的基数 ; SI -- 存放转换后的P进制ASCII码数字串的字节缓冲区首址 ;出口参数: ; 所求10进制ASCII码数字串按高位在前、低位在后的顺序存放在以SI为指针的字节缓冲区中 ; SI--指向字节缓冲区最后一个ASCII码的下一个字节处 ;所使用寄存器: ;CX--P进制数字入栈、出栈时的计数器 ;EDX--做除法时存放被除数高位或余数 RADIX PROC PUSH CX PUSH EDX XOR CX, CX ;计数器清零 LOP1: XOR EDX, EDX DIV EBX PUSH DX INC CX OR EAX, EAX JNZ LOP1 ;EAX!=0, 转LOP1继续循环 LOP2: POP AX ADD AL, 30H MOV [SI], AL INC SI LOOP LOP2 POP EDX POP CX RET RADIX ENDP ANTI PROC PUSH ES PUSH BX PUSH DX PUSH SI ANTI_BEGIN: MOV AX,1 MOV SI,AX IMUL SI,4 ;获取原来的中断地址 XOR BX,BX MOV ES,BX MOV BX,ES:[SI] MOV ORIGINAL_IP,BX MOV BX,ES:[SI+2] MOV ORIGINAL_CS,BX ;用35H号中断获取原来地址 MOV AL,1 MOV AH,35H INT 21H ;比较35H号中断获取的地址与寄存器寻址获得的是否相等 CMP BX,WORD PTR ORIGINAL_IP JE J_G_ES ;相等说明正常继续 JMP R_EXIT db 88 DUP(?) J_G_ES: MOV BX,ES CMP BX,WORD PTR ORIGINAL_CS JE RESET JMP R_EXIT db 66 DUP(?) ;设置新的值 RESET: PUSH DS MOV DS,AX MOV DX,AX MOV AH,25H INT 21H POP DS ;获得的新的值是否和原来值相等 MOV AH,35H INT 21H CMP ORIGINAL_IP,BX JNE J_O_CS JMP R_EXIT ;相等说明没改 直接退出 db 44 DUP(?) J_O_CS: MOV DX,ES CMP ORIGINAL_CS,DX JNE RECOVER JMP R_EXIT db 22 DUP(?) RECOVER: PUSH DS MOV BX,ORIGINAL_CS MOV DX,ORIGINAL_IP MOV DS,BX MOV AH,25H INT 21H POP DS ADD AX,2 CMP AX,4 JB ANTI_BEGIN MOV AX,0 RET_ANTI: POP SI POP DX POP BX POP ES RET R_EXIT: MOV AX,1 JMP RET_ANTI ANTI ENDP CODE ENDS ; END START ;结束程序 指定程序入口
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2018 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %include "reg_sizes.asm" %include "lz0a_const.asm" %include "data_struct2.asm" %include "igzip_compare_types.asm" %define NEQ 4 %ifdef HAVE_AS_KNOWS_AVX512 %ifidn __OUTPUT_FORMAT__, win64 %define arg1 rcx %define arg2 rdx %define arg3 r8 %define dist_code rsi %define len rdi %else %define arg1 rdi %define arg2 rsi %define arg3 rdx %define dist_code rcx %define len r8 %endif %define next_in arg1 %define end_in arg2 %define match_lookup arg3 %define match_in rax %define dist r9 %define match_offset r10 %define tmp1 r11 %define zmatch_lookup zmm0 %define zmatch_lookup2 zmm1 %define zlens zmm2 %define zdist_codes zmm3 %define zdist_extras zmm4 %define zdists zmm5 %define zdists2 zmm6 %define zlens1 zmm7 %define zlens2 zmm8 %define zlookup zmm9 %define zlookup2 zmm10 %define datas zmm11 %define ztmp1 zmm12 %define ztmp2 zmm13 %define zvect_size zmm17 %define ztwofiftyfour zmm18 %define ztwofiftysix zmm19 %define ztwosixtytwo zmm20 %define znlen_mask zmm21 %define zbswap zmm22 %define zqword_shuf zmm23 %define zdatas_perm3 zmm24 %define zdatas_perm2 zmm25 %define zincrement zmm26 %define zdists_mask zmm27 %define zdists_start zmm28 %define zlong_lens2 zmm29 %define zlong_lens zmm30 %define zlens_mask zmm31 %ifidn __OUTPUT_FORMAT__, win64 %define stack_size 8*16 + 2 * 8 + 8 %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size vmovdqa [rsp + 0*16], xmm6 vmovdqa [rsp + 1*16], xmm7 vmovdqa [rsp + 2*16], xmm8 vmovdqa [rsp + 3*16], xmm9 vmovdqa [rsp + 4*16], xmm10 vmovdqa [rsp + 5*16], xmm11 vmovdqa [rsp + 6*16], xmm12 vmovdqa [rsp + 7*16], xmm13 save_reg rsi, 8*16 + 0*8 save_reg rdi, 8*16 + 1*8 end_prolog %endm %macro FUNC_RESTORE 0 vmovdqa xmm6, [rsp + 0*16] vmovdqa xmm7, [rsp + 1*16] vmovdqa xmm8, [rsp + 2*16] vmovdqa xmm9, [rsp + 3*16] vmovdqa xmm10, [rsp + 4*16] vmovdqa xmm11, [rsp + 5*16] vmovdqa xmm12, [rsp + 6*16] vmovdqa xmm13, [rsp + 7*16] mov rsi, [rsp + 8*16 + 0*8] mov rdi, [rsp + 8*16 + 1*8] add rsp, stack_size %endm %else %define func(x) x: %macro FUNC_SAVE 0 %endm %macro FUNC_RESTORE 0 %endm %endif %define VECT_SIZE 16 global set_long_icf_fg_06 func(set_long_icf_fg_06) FUNC_SAVE sub end_in, LA + 15 vmovdqu32 zlong_lens, [long_len] vmovdqu32 zlong_lens2, [long_len2] vmovdqu32 zlens_mask, [len_mask] vmovdqu16 zdists_start, [dist_start] vmovdqu32 zdists_mask, [dists_mask] vmovdqu32 zincrement, [increment] vmovdqu64 zdatas_perm2, [datas_perm2] vmovdqu64 zdatas_perm3, [datas_perm3] vmovdqu64 zqword_shuf, [qword_shuf] vmovdqu64 zbswap, [bswap_shuf] vmovdqu64 znlen_mask, [nlen_mask] vmovdqu64 zvect_size, [vect_size] vmovdqu64 ztwofiftyfour, [twofiftyfour] vmovdqu64 ztwofiftysix, [twofiftysix] vmovdqu64 ztwosixtytwo, [twosixtytwo] vmovdqu32 zmatch_lookup, [match_lookup] fill_loop: ; Tahiti is a magical place vmovdqu32 zmatch_lookup2, zmatch_lookup vmovdqu32 zmatch_lookup, [match_lookup + ICF_CODE_BYTES * VECT_SIZE] cmp next_in, end_in jae end_fill vpandd zlens, zmatch_lookup2, zlens_mask vpcmpgtd k3, zlens, zlong_lens ;; Speculatively increment add next_in, VECT_SIZE add match_lookup, ICF_CODE_BYTES * VECT_SIZE ktestw k3, k3 jz fill_loop vpsrld zdist_codes, zmatch_lookup2, DIST_OFFSET vpmovdw zdists %+ y, zdist_codes ; Relies on perm working mod 32 vpermw zdists, zdists, zdists_start vpmovzxwd zdists, zdists %+ y vpsrld zdist_extras, zmatch_lookup2, EXTRA_BITS_OFFSET vpsubd zdist_extras, zincrement, zdist_extras vpsubd zdists, zdist_extras, zdists vextracti32x8 zdists2 %+ y, zdists, 1 kmovb k6, k3 kshiftrw k7, k3, 8 vpgatherdq zlens1 {k6}, [next_in + zdists %+ y - 8] vpgatherdq zlens2 {k7}, [next_in + zdists2 %+ y - 8] vmovdqu8 datas %+ y, [next_in - 8] vpermq zlookup, zdatas_perm2, datas vpshufb zlookup, zlookup, zqword_shuf vpermq zlookup2, zdatas_perm3, datas vpshufb zlookup2, zlookup2, zqword_shuf vpxorq zlens1, zlens1, zlookup vpxorq zlens2, zlens2, zlookup2 vpshufb zlens1, zlens1, zbswap vpshufb zlens2, zlens2, zbswap vplzcntq zlens1, zlens1 vplzcntq zlens2, zlens2 vpmovqd zlens1 %+ y, zlens1 vpmovqd zlens2 %+ y, zlens2 vinserti32x8 zlens1, zlens2 %+ y, 1 vpsrld zlens1 {k3}{z}, zlens1, 3 vpandd zmatch_lookup2 {k3}{z}, zmatch_lookup2, znlen_mask vpaddd zmatch_lookup2 {k3}{z}, zmatch_lookup2, ztwosixtytwo vpaddd zmatch_lookup2 {k3}{z}, zmatch_lookup2, zlens1 vmovdqu32 [match_lookup - ICF_CODE_BYTES * VECT_SIZE] {k3}, zmatch_lookup2 vpcmpgtd k3, zlens1, zlong_lens2 ktestw k3, k3 jz fill_loop vpsubd zdists, zincrement, zdists vpcompressd zdists2 {k3}, zdists vpcompressd zmatch_lookup2 {k3}, zmatch_lookup2 kmovq match_offset, k3 tzcnt match_offset, match_offset vmovd dist %+ d, zdists2 %+ x lea next_in, [next_in + match_offset - VECT_SIZE] lea match_lookup, [match_lookup + ICF_CODE_BYTES * (match_offset - VECT_SIZE)] mov match_in, next_in sub match_in, dist mov len, 2 %rep 3 vmovdqu8 ztmp1, [next_in + len] vmovdqu8 ztmp2, [match_in + len] vpcmpb k3, ztmp1, [match_in + len], NEQ ktestq k3, k3 jnz miscompare add len, 64 %endrep vmovdqu8 ztmp1, [next_in + len] vmovdqu8 ztmp2, [match_in + len] vpcmpb k3, ztmp1, ztmp2, 4 miscompare: kmovq tmp1, k3 tzcnt tmp1, tmp1 add len, tmp1 add next_in, len lea match_lookup, [match_lookup + ICF_CODE_BYTES * len] vmovdqu32 zmatch_lookup, [match_lookup] vpbroadcastd zmatch_lookup2, zmatch_lookup2 %+ x vpandd zmatch_lookup2, zmatch_lookup2, znlen_mask vpbroadcastd zlens1, len %+ d vpsubd zlens1, zlens1, zincrement vpaddd zlens1, zlens1, ztwofiftyfour neg len update_match_lookup: vpandd zlens2, zlens_mask, [match_lookup + ICF_CODE_BYTES * len] vpcmpgtd k3, zlens1, zlens2 vpcmpgtd k4, zlens1, ztwofiftysix kandw k3, k3, k4 vpaddd zlens2 {k3}{z}, zlens1, zmatch_lookup2 vmovdqu32 [match_lookup + ICF_CODE_BYTES * len] {k3}, zlens2 knotw k3, k3 ktestw k3, k3 jnz fill_loop add len, VECT_SIZE vpsubd zlens1, zlens1, zvect_size jmp update_match_lookup end_fill: FUNC_RESTORE ret endproc_frame section .data align 64 dist_start: dw 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0007, 0x0009, 0x000d dw 0x0011, 0x0019, 0x0021, 0x0031, 0x0041, 0x0061, 0x0081, 0x00c1 dw 0x0101, 0x0181, 0x0201, 0x0301, 0x0401, 0x0601, 0x0801, 0x0c01 dw 0x1001, 0x1801, 0x2001, 0x3001, 0x4001, 0x6001, 0x0000, 0x0000 len_mask: dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK dists_mask: dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK long_len: dd 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105 dd 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105 long_len2: dd 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7 dd 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7 increment: dd 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 dd 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf datas_perm2: dq 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1 datas_perm3: dq 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2 bswap_shuf: db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 db 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 db 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08 qword_shuf: db 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 db 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 db 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 db 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa db 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb db 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc db 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd db 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe db 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf vect_size: dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE twofiftyfour: dd 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe dd 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe twofiftysix: dd 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100 dd 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100 twosixtytwo: dd 0x106, 0x106, 0x106, 0x106, 0x106, 0x106, 0x106, 0x106 dd 0x106, 0x106, 0x106, 0x106, 0x106, 0x106, 0x106, 0x106 nlen_mask: dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00 dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00 dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00 dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00 %endif
//Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <boost/qvm/map.hpp> #include <boost/qvm/mat_traits_array.hpp> #include <boost/qvm/vec_operations.hpp> #include <boost/qvm/mat_operations.hpp> #include <boost/qvm/mat.hpp> #include "test_qvm_vector.hpp" #include "gold.hpp" namespace { template <int Dim> void test() { using namespace boost::qvm; test_qvm::vector<V1,Dim> x(42,1); float y[Dim][Dim]; assign(y,diag_mat(x)); for( int i=0; i!=Dim; ++i ) x.b[i]=y[i][i]; BOOST_QVM_TEST_EQ(x.a,x.b); test_qvm::scalar_multiply_v(x.b,x.a,2.0f); diag(diag_mat(x)) *= 2; BOOST_QVM_TEST_EQ(x.a,x.b); diag_mat(x) + diag_mat(x); -diag_mat(x); } } int main() { test<2>(); test<3>(); test<4>(); test<5>(); return boost::report_errors(); }
db 0 ; species ID placeholder db 60, 45, 70, 95, 45, 90 ; hp atk def spd sat sdf db ELECTRIC, ELECTRIC ; type db 200 ; catch rate db 142 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 10 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/pachirisu/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_FAIRY, EGG_GROUND ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, HIDDEN_POWER, SNORE, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, THUNDER, RETURN, DIG, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SWIFT, DEFENSE_CURL, THUNDERPUNCH, DETECT, REST, ATTRACT, CUT, FLASH, THUNDERBOLT ; end
;PhaserX ;by utz 09'2016 * www.irrlichtproject.de ;******************************************************************************* ;; include "equates.h" ;; BORDER .equ $14 ;; org #8000 di exx push hl ;preserve HL' for return to BASIC ld (oldSP),sp ld hl,musicData ld (seqpntr),hl ld iyl,0 ;timer lo ;******************************************************************************* rdseq seqpntr .equ .(+ 1 current-origin) ld sp,0 rdseq0 xor a pop de ;pattern pointer to DE or d ld (seqpntr),sp jr nz,rdptn0 .(if (symbol-ref 'row-play) " halt" ;; " ld sp,loop\n jr .(+ 3 (symbol-ref 'rdseq))" " ld sp,loop\n jr rdseq0") ;; ;jp exit ;uncomment to disable looping ;; ld sp,loop ;get loop point ;; jr rdseq+3 ;******************************************************************************* exit oldSP .equ .(+ 1 current-origin) ld sp,0 pop hl exx ei ret ;******************************************************************************* rdptn0 ld (ptnpntr),de readPtn in a,($fe) ;read kbd cpl and $1f jr nz,exit ptnpntr .equ .(+ 1 current-origin) ld sp,0 pop af ;speed + drums jr z,rdseq jp c,drum1 jp m,drum2 ex af,af' drumret pop af ;flags + mix_method (xor = $ac, or = $b4, and = a4) ld (mixMethod),a jr c,noUpdateCh1 exx ld a,$9f ;sbc a,a jp pe,setSid ld a,$97 ;sub a,a setSid ld (sid),a ld hl,$04cb ;rlc h jp m,setNoise ld hl,$0 setNoise ld (noise),hl pop bc ;dutymod/duty 1 ld a,b ld (dutymod1),a pop de ;freq1 ld hl,0 ;reset ch1 accu exx noUpdateCh1 jr z,noUpdateCh2 pop hl ;dutymod 2a/b ld a,h ld (dutymod2a),a ld a,l ld (dutymod2b),a pop bc ;duty 2a/b pop de ;freq 2a pop hl ;freq 2b ld (freq2b),hl pop ix ;phase 2b ld hl,0 ;reset ch2a accu noUpdateCh2 ld (ptnpntr),sp freq2b .equ .(+ 1 current-origin) ld sp,0 ;******************************************************************************* playNote exx ;4 add hl,de ;11 sid sbc a,a ;4 ;replace with sub a for no sid ld b,a ;4 ;temp add a,c ;4 ;c = duty ld c,a ;4 ld a,b ;4 dutymod1 .equ .(+ 1 current-origin) and $0 ;7 xor c ;4 ld c,a ;4 cp h ;4 sbc a,a ;4 noise .ds 2 ;8 ;replace with rlc h for noise exx ;4 add hl,de ;11 out ($fe),a ;11___104 sbc a,a ;4 dutymod2a .equ .(+ 1 current-origin) and $0 ;7 xor b ;4 ld b,a ;4 cp h ;4 sbc a,a ;4 ld iyh,a ;8 add ix,sp ;15 sbc a,a ;4 dutymod2b .equ .(+ 1 current-origin) and $0 ;7 xor c ;4 ld c,a ;4 cp ixh ;8 sbc a,a ;4 mixMethod .equ .(+ 1 current-origin) and iyh ;8 dec iyl ;8 jr nz,skipTimerHi ;12 ex af,af' dec a jp z,readPtn ex af,af' skipTimerHi out ($fe),a ;11___120 jr playNote ;12 ;224 ;******************************************************************************* drum2 ld (restoreHL),hl ld (restoreBC),bc ex af,af' ld hl,hat1 ld b, .(- (symbol-ref 'hat1end) (symbol-ref 'hat1)) jr drentry drum1 ld (restoreHL),hl ld (restoreBC),bc ex af,af' ld hl,kick1 ;10 ld b, .(- (symbol-ref 'kick1end) (symbol-ref 'kick1)) ;7 drentry xor a ;4 _s2 xor BORDER ;7 ld c,(hl) ;7 inc hl ;6 _s1 out ($fe),a ;11 dec c ;4 jr nz,_s1 ;12/7 djnz _s2 ;13/8 ld iyl,$11 ;7 ;correct tempo restoreHL .equ .(+ 1 current-origin) ld hl,0 restoreBC .equ .(+ 1 current-origin) ld bc,0 jp drumret ;10 kick1 ;27*16*4 + 27*32*4 + 27*64*4 + 27*128*4 + 27*256*4 = 53568, + 20*33 = 53568 -> -239 loops -> AF' = $11 .ds 4,$10 .ds 4,$20 .ds 4,$40 .ds 4,$80 .ds 4,0 kick1end hat1 .db 16,3,12,6,9,20,4,8,2,14,9,17,5,8,12,4,7,16,13,22,5,3,16,3,12,6,9,20,4,8,2,14,9,17,5,8,12,4,7,16,13,22,5,3 .db 12,8,1,24,6,7,4,9,18,12,8,3,11,7,5,8,3,17,9,15,22,6,5,8,11,13,4,8,12,9,2,4,7,8,12,6,7,4,19,22,1,9,6,27,4,3,11 .db 5,8,14,2,11,13,5,9,2,17,10,3,7,19,4,3,8,2,9,11,4,17,6,4,9,14,2,22,8,4,19,2,3,5,11,1,16,20,4,7 .db 8,9,4,12,2,8,14,3,7,7,13,9,15,1,8,4,17,3,22,4,8,11,4,21,9,6,12,4,3,8,7,17,5,9,2,11,17,4,9,3,2 .db 22,4,7,3,8,9,4,11,8,5,9,2,6,2,8,8,3,11,5,3,9,6,7,4,8 hat1end musicData loop ;; include "music.asm"
#include "keystore.h" #include "core/proto.h" #include <boost/filesystem.hpp> #include <stdexcept> #include <stdio.h> namespace beam { namespace { using PrivKey = ECC::Scalar::Native; using KeyPairs = std::map<PubKey, ECC::NoLeak<PrivKey>>; using Nonce = ECC::Scalar::Native; using PasswordHash = ECC::NoLeak<ECC::Hash::Value>; void gen_nonce(Nonce& nonce) { ECC::Scalar sc; uint64_t seed; // here we want to read as little as possible from slow sources, TODO: review this ECC::GenRandom(&seed, 8); ECC::Hash::Processor() << seed >> sc.m_Value; nonce.Import(sc); } void hash_from_password(PasswordHash& out, const void* password, size_t passwordLen) { ECC::Hash::Processor() << Blob(password, static_cast<uint32_t>(passwordLen)) >> out.V; } void aes_decrypt(void* buffer, size_t bufferLen, const PasswordHash& key) { AES::Encoder enc; enc.Init(key.V.m_pData); AES::Decoder dec; dec.Init(enc); uint8_t* p = (uint8_t*)buffer; uint8_t* end = p + bufferLen; for (; p<end; p+=AES::s_BlockSize) { dec.Proceed(p, p); } } void aes_encrypt(void* buffer, size_t bufferLen, const PasswordHash& key) { AES::Encoder enc; enc.Init(key.V.m_pData); uint8_t* p = (uint8_t*)buffer; uint8_t* end = p + bufferLen; for (; p<end; p+=AES::s_BlockSize) { enc.Proceed(p, p); } } struct AutoClose { FILE* f=0; ~AutoClose() { if(f) fclose(f); } }; void xor_32_bytes(uint8_t* out, const uint8_t* mask) { for (int i=0; i<32; ++i) { *(out++) ^= *(mask++); } } FILE* open_file(const std::string& fileName, bool newFile) { FILE* f = nullptr; #ifdef WIN32 if (_wfopen_s(&f, Utf8toUtf16(fileName.c_str()).c_str(), newFile ? L"w+b" : L"a+b") != 0) { f = nullptr; } #else f = fopen(fileName.c_str(), newFile ? "w+b" : "a+b"); #endif if (!f) { throw KeyStoreException(std::string("keystore: cannot open file ") + fileName); } return f; } void read_keystore_file(KeyPairs& out, const std::string& fileName, const PasswordHash& key) { AutoClose a; a.f = open_file(fileName, false); fseek(a.f, 0, SEEK_END); size_t size = ftell(a.f); if (size == 0) { return; } static const size_t MAX_FILE_SIZE = 64*2000; if ((size % 64) != 0 || size > MAX_FILE_SIZE) { fclose(a.f); throw KeyStoreException(std::string("keystore: invalid file size: ") + fileName); } void* buffer = alloca(size); rewind(a.f); auto bytesRead = fread(buffer, 1, size, a.f); if (bytesRead != size) { throw KeyStoreException(std::string("keystore: file read error: ") + fileName); } aes_decrypt(buffer, size, key); uint8_t* p = (uint8_t*)buffer; const uint8_t* end = p + size; PubKey pubKey; for (; p<end; p += 64) { xor_32_bytes(p, p + 32); memcpy(pubKey.m_pData, p, 32); memcpy(&(out[pubKey].V), p+32, 32); } } void write_keystore_file(const KeyPairs& in, const std::string& fileName, const PasswordHash& key) { std::string newFileName = fileName + ".new"; size_t size = in.size() * 64; { AutoClose a; a.f = open_file(newFileName, true); if (size == 0) return; void* buffer = alloca(size); uint8_t* p = (uint8_t*)buffer; for (const auto& kp : in) { memcpy(p, kp.first.m_pData, 32); memcpy(p + 32, &(kp.second.V), 32); xor_32_bytes(p, p + 32); p += 64; } aes_encrypt(buffer, size, key); if (size != fwrite(buffer, 1, size, a.f)) { throw KeyStoreException(std::string("keystore: cannot write file ") + newFileName); } } #ifdef WIN32 boost::filesystem::rename(Utf8toUtf16(newFileName.c_str()), Utf8toUtf16(fileName.c_str())); #else boost::filesystem::rename(newFileName, fileName); #endif } } //namespace class LocalFileKeystore : public IKeyStore { public: LocalFileKeystore(const IKeyStore::Options& options, const void* password, size_t passwordLen) : _fileName(options.fileName) { hash_from_password(_pass, password, passwordLen); bool allEnabled = (options.flags & Options::enable_all_keys) != 0; if (allEnabled) { read_keystore_file_and_check(); } else { enable_keys(options.enableKeys); } } private: void read_keystore_file_and_check() { read_keystore_file(_keyPairs, _fileName, _pass); if (_keyPairs.empty()) return; static const char data[] = "xoxoxoxo"; ByteBuffer buf; std::string errorMsg(std::string("keystore: file corrupted: ") + _fileName); if (!encrypt(buf, data, sizeof(data), _keyPairs.begin()->first)) { throw KeyStoreException(errorMsg); } uint8_t* out=0; uint32_t size=0; if ( !decrypt(out, size, buf, _keyPairs.begin()->first) || size != sizeof(data) || memcmp(data, out, size) != 0 ) { throw KeyStoreException(errorMsg); } } void gen_keypair(PubKey& pubKey) override { ECC::NoLeak<PrivKey> privKey; gen_nonce(privKey.V); proto::Sk2Pk(pubKey, privKey.V); memcpy(&(_unsaved[pubKey].V), &privKey.V, 32); } void save_keypair(const PubKey& pubKey, bool enable) override { auto it = _unsaved.find(pubKey); if (it == _unsaved.end()) { return; } memcpy(&(_keyPairs[pubKey].V), &(it->second.V), 32); write_keystore_file(_keyPairs, _fileName, _pass); if (!enable) { _keyPairs.erase(pubKey); } _unsaved.erase(it); } size_t size() override { return _keyPairs.size(); } void change_password(const void* password, size_t passwordLen) override { KeyPairs savedKeys; read_keystore_file(savedKeys, _fileName, _pass); hash_from_password(_pass, password, passwordLen); write_keystore_file(savedKeys, _fileName, _pass); } void get_enabled_keys(std::set<PubKey>& enabledKeys) override { enabledKeys.clear(); for (const auto& p : _keyPairs) { enabledKeys.insert(p.first); } } void enable_keys(const std::set<PubKey>& enableKeys) override { _keyPairs.clear(); if (enableKeys.empty()) return; read_keystore_file_and_check(); if (_keyPairs.empty()) return; std::set<PubKey> toBeErased; for (const auto& p : _keyPairs) { if (enableKeys.count(p.first) == 0) { toBeErased.insert(p.first); } } for (const auto& k : toBeErased) { _keyPairs.erase(k); } } void disable_key(const PubKey& pubKey) override { _keyPairs.erase(pubKey); } void erase_key(const PubKey& pubKey) override { size_t s = _keyPairs.size(); _keyPairs.erase(pubKey); if (s != _keyPairs.size()) { write_keystore_file(_keyPairs, _fileName, _pass); } } bool encrypt(ByteBuffer& out, const void* data, size_t size, const PubKey& pubKey) override { Nonce nonce; gen_nonce(nonce); return proto::BbsEncrypt(out, pubKey, nonce, data, static_cast<uint32_t>(size)); } bool encrypt(ByteBuffer& out, const io::SerializedMsg& in, const PubKey& pubKey) override { io::SharedBuffer msg = io::normalize(in, false); return encrypt(out, msg.data, msg.size, pubKey); } bool decrypt(uint8_t*& out, uint32_t& size, ByteBuffer& buffer, const PubKey& pubKey) override { auto it = _keyPairs.find(pubKey); if (it == _keyPairs.end()) { return false; } out = &buffer.at(0); size = static_cast<uint32_t>(buffer.size()); return proto::BbsDecrypt(out, size, (PrivKey&)it->second.V); } std::string _fileName; KeyPairs _keyPairs; KeyPairs _unsaved; // TODO: use locked in memory secure buffer PasswordHash _pass; }; IKeyStore::Ptr IKeyStore::create(const IKeyStore::Options& options, const void* password, size_t passwordLen) { static const std::string errMsgPrefix("keystore create: "); Ptr ptr; if (options.flags & Options::local_file) { if (options.fileName.empty() || passwordLen == 0) { throw KeyStoreException(errMsgPrefix + "empty file name or key"); } ptr = std::make_shared<LocalFileKeystore>(options, password, passwordLen); } else { throw KeyStoreException(errMsgPrefix + "invalid options"); } return ptr; } } //namespace
; A179453: Decimal expansion of the inradius of an icosidodecahedron with edge length 1. ; Submitted by Jon Maiga ; 1,4,6,3,5,2,5,4,9,1,5,6,2,4,2,1,1,3,6,1,5,3,4,4,0,1,2,5,7,7,4,2,2,8,5,8,8,2,9,0,2,3,1,8,8,4,8,5,4,3,2,2,1,4,6,6,0,1,5,8,6,4,6,7,0,2,8,9,4,5,3,4,7,1,1,4,1,7,6,8,3,7,2,8,0,4,0,5,4,0,3,1,4,2,0,4,3,3,5,3 mov $2,1 mov $3,$0 mul $3,4 lpb $3 add $1,$2 mul $5,2 add $5,$2 add $1,$5 add $2,$1 mul $1,2 sub $3,1 lpe mov $1,1 add $1,$5 mul $1,3 mul $2,2 mov $4,10 pow $4,$0 div $2,$4 add $1,$2 div $1,$2 mov $0,$1 sub $0,1 mod $0,10
\ ****************************************************************************** \ \ REVS DONINGTON PARK TRACK SOURCE \ \ Revs was written by Geoffrey J Crammond and is copyright Acornsoft 1985 \ \ The code on this site has been reconstructed from a disassembly of the \ original game binaries \ \ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes \ in the documentation are entirely my fault \ \ The terminology and notations used in this commentary are explained at \ https://revs.bbcelite.com/about_site/terminology_used_in_this_commentary.html \ \ The deep dive articles referred to in this commentary can be found at \ https://revs.bbcelite.com/deep_dives \ \ ------------------------------------------------------------------------------ \ \ This source file produces the following binary file: \ \ * DoningtonPark.bin \ \ ****************************************************************************** GUARD &7C00 \ Guard against assembling over screen memory \ ****************************************************************************** \ \ Configuration variables \ \ ****************************************************************************** LOAD% = &70DB \ The load address of the track binary CODE% = &5300 \ The assembly address of the track data \ ****************************************************************************** \ \ REVS DONINGTON PARK TRACK \ \ Produces the binary file DoningtonPark.bin that contains the Donington Park \ track. \ \ ****************************************************************************** ORG CODE% .trackData EQUB &D3, &D1, &1E, &D1, &D0, &FF, &D1, &FF EQUB &E1, &D1, &1C, &F6, &D0, &3F, &F6, &51 EQUB &F3, &D1, &19, &15, &D0, &08, &15, &00 EQUB &F2, &D3, &19, &18, &D3, &12, &19, &0A EQUB &04, &D7, &19, &1B, &D6, &FF, &1B, &FF EQUB &13, &DB, &15, &3E, &DA, &2D, &3E, &5B EQUB &23, &DE, &14, &54, &DD, &19, &55, &0F EQUB &23, &E3, &14, &57, &E3, &FF, &58, &8A EQUB &35, &ED, &14, &50, &ED, &FF, &51, &FF EQUB &45, &F5, &0D, &39, &F6, &06, &39, &FF EQUB &55, &F4, &0B, &31, &F5, &1E, &31, &0A EQUB &54, &F5, &09, &2A, &F6, &23, &2B, &78 EQUB &64, &FE, &06, &19, &FF, &13, &1A, &0D EQUB &64, &FD, &06, &16, &FE, &20, &16, &FF EQUB &73, &EF, &09, &05, &F0, &1D, &05, &0E EQUB &73, &EE, &09, &03, &EF, &FF, &03, &FF EQUB &73, &ED, &0D, &F8, &EE, &0E, &F8, &FF EQUB &83, &ED, &11, &EA, &EE, &21, &EB, &00 EQUB &83, &F0, &14, &E3, &F1, &0F, &E3, &72 EQUB &93, &F5, &17, &DB, &F6, &1B, &DB, &11 EQUB &A3, &F3, &18, &D5, &F4, &FF, &D5, &FF EQUB &A3, &EA, &1A, &CF, &EA, &1B, &CE, &6F EQUB &B3, &DC, &1E, &C5, &DC, &12, &C4, &08 EQUB &B3, &DA, &1E, &C5, &D9, &06, &C4, &76 EQUB &C3, &D7, &1E, &C6, &D6, &25, &C5, &0E EQUB &03, &CF, &14, &BB, &CE, &FF, &BC, &FF EQUB &85, &75, &A9, &CD, &4C, &00, &0C, &45 EQUB &25, &4C, &50, &34, &98, &20, &00, &0C EQUB &85, &75, &20, &00, &0C, &06, &74, &2A EQUB &60, &C9, &0B, &B0, &03, &20, &F3, &12 EQUB &4C, &F3, &12, &8D, &55, &4F, &8D, &59 EQUB &4F, &60, &00, &3A, &00, &00, &00, &00 \ &5400 EQUB &49, &8A, &CA, &27, &FC, &1B, &8C, &39 EQUB &94, &D1, &C9, &C1, &D6, &D7, &E1, &47 EQUB &F3, &2C, &43, &24, &12, &12, &13, &14 EQUB &12, &26, &24, &25, &15, &4C, &4C, &4C EQUB &44, &4C, &4C, &19, &24, &46, &25, &2F EQUB &00, &00, &00, &00, &00, &00, &10, &03 EQUB &FE, &FA, &00, &00, &00, &00, &00, &01 EQUB &02, &05, &01, &00, &01, &01, &00, &00 EQUB &00, &00, &00, &00, &FD, &FE, &00, &00 EQUB &00, &01, &00, &06, &FC, &00, &00, &FE EQUB &FE, &FE, &00, &01, &02, &04, &04, &00 EQUB &00, &00, &00, &00, &00, &07, &00, &02 EQUB &01, &01, &21, &34, &40, &48, &55, &64 EQUB &75, &8D, &9C, &A0, &B4, &C0, &00, &08 EQUB &13, &10, &AD, &FC, &53, &0A, &AD, &FD EQUB &53, &2A, &48, &2A, &2A, &2A, &29, &07 EQUB &85, &75, &4A, &68, &29, &3F, &90, &04 EQUB &49, &3F, &69, &00, &AA, &BC, &BF, &57 EQUB &BD, &BF, &58, &AA, &A5, &75, &18, &69 EQUB &01, &29, &02, &D0, &06, &84, &76, &86 EQUB &77, &F0, &04, &86, &76, &84, &77, &A5 EQUB &75, &C9, &04, &90, &06, &A9, &00, &E5 EQUB &76, &85, &76, &A5, &75, &C9, &06, &B0 EQUB &0A, &C9, &02, &90, &06, &A9, &00, &E5 EQUB &77, &85, &77, &A4, &02, &A9, &86, &85 EQUB &75, &A5, &76, &99, &00, &54, &20, &EB EQUB &54, &99, &00, &58, &A5, &77, &99, &00 EQUB &56, &20, &EB, &54, &49, &FF, &18, &69 EQUB &01, &99, &00, &57, &AD, &FE, &53, &99 EQUB &00, &55, &60, &08, &4C, &1B, &46, &A5 EQUB &01, &29, &40, &F0, &03, &20, &82, &55 EQUB &A5, &24, &18, &69, &03, &60, &03, &60 \ &5500 EQUB &72, &1B, &72, &72, &EF, &AF, &BC, &72 EQUB &79, &62, &62, &62, &A0, &62, &62, &C8 EQUB &BD, &D7, &B6, &ED, &56, &5A, &55, &55 EQUB &54, &56, &56, &57, &57, &55, &56, &57 EQUB &58, &54, &54, &56, &55, &53, &57, &59 EQUB &00, &00, &00, &00, &00, &00, &4B, &71 EQUB &94, &73, &00, &00, &00, &00, &A9, &C7 EQUB &94, &88, &83, &00, &53, &6E, &B6, &AD EQUB &B2, &FD, &00, &00, &DE, &46, &00, &00 EQUB &00, &3F, &00, &05, &9F, &00, &00, &C1 EQUB &2A, &D8, &5B, &66, &72, &BE, &4B, &00 EQUB &00, &00, &00, &00, &00, &DD, &BC, &24 EQUB &62, &A4, &04, &F1, &F4, &FE, &05, &EF EQUB &21, &FE, &F6, &05, &42, &07, &02, &01 EQUB &FB, &05, &A5, &01, &29, &40, &F0, &06 EQUB &20, &E0, &13, &20, &C4, &55, &60, &20 EQUB &E0, &13, &AC, &FA, &53, &AD, &FF, &53 EQUB &38, &24, &25, &30, &13, &69, &00, &D9 EQUB &28, &57, &90, &22, &A9, &00, &C8, &CC EQUB &FB, &53, &90, &1A, &A0, &00, &F0, &16 EQUB &E9, &01, &B0, &12, &98, &29, &7F, &A8 EQUB &C0, &01, &B0, &03, &AC, &FB, &53, &88 EQUB &B9, &28, &57, &38, &E9, &01, &8D, &FF EQUB &53, &8C, &FA, &53, &60, &24, &43, &30 EQUB &FB, &4C, &0B, &14, &86, &45, &AC, &FA EQUB &53, &30, &2F, &B9, &28, &55, &85, &74 EQUB &B9, &28, &54, &24, &25, &20, &40, &0E EQUB &85, &75, &A5, &74, &18, &6D, &FC, &53 EQUB &8D, &FC, &53, &A5, &75, &6D, &FD, &53 EQUB &8D, &FD, &53, &B9, &28, &56, &24, &25 EQUB &20, &50, &34, &18, &6D, &FE, &53, &8D EQUB &FE, &53, &20, &72, &54, &A6, &45, &60 \ &5600 EQUB &A9, &E9, &8D, &DF, &24, &A9, &53, &8D EQUB &E0, &24, &A9, &C9, &8D, &CC, &45, &A9 EQUB &59, &8D, &CD, &45, &A9, &4B, &8D, &72 EQUB &27, &A9, &A9, &8D, &10, &13, &A9, &88 EQUB &8D, &11, &13, &A9, &16, &4C, &F3, &53 EQUB &FA, &01, &FE, &02, &00, &00, &00, &00 EQUB &00, &00, &FF, &00, &01, &00, &00, &00 EQUB &00, &00, &00, &00, &FF, &FE, &FE, &FF EQUB &00, &00, &00, &01, &00, &00, &00, &02 EQUB &00, &00, &00, &04, &00, &02, &00, &00 EQUB &00, &FF, &00, &00, &00, &FF, &FF, &FF EQUB &00, &02, &00, &FD, &FF, &FF, &00, &00 EQUB &00, &00, &E6, &09, &08, &56, &34, &1D EQUB &EC, &CC, &E8, &08, &C2, &0D, &08, &0B EQUB &22, &08, &84, &1B, &B9, &05, &59, &85 EQUB &02, &98, &4A, &4A, &4A, &A8, &B9, &46 EQUB &58, &8D, &FC, &53, &B9, &64, &58, &8D EQUB &FD, &53, &B9, &28, &58, &8D, &FE, &53 EQUB &B9, &82, &58, &4A, &6A, &8D, &FA, &53 EQUB &A9, &0E, &6A, &8D, &B3, &23, &A9, &00 EQUB &8D, &FF, &53, &24, &25, &30, &03, &20 EQUB &C4, &55, &A4, &1B, &A5, &02, &60, &48 EQUB &A5, &42, &C9, &0C, &68, &B0, &04, &85 EQUB &1F, &84, &51, &60, &90, &07, &A5, &42 EQUB &C9, &0A, &90, &01, &60, &4C, &90, &24 EQUB &98, &29, &20, &85, &82, &A9, &00, &85 EQUB &7F, &88, &B9, &20, &5F, &C5, &1F, &B0 EQUB &1E, &C5, &7F, &B0, &F2, &A5, &7F, &69 EQUB &00, &99, &20, &5F, &A5, &82, &D0, &E9 EQUB &A5, &7F, &8D, &EA, &1F, &C8, &20, &3B EQUB &25, &88, &38, &66, &82, &30, &DA, &A4 EQUB &4B, &88, &84, &75, &4C, &33, &19, &00 \ &5700 EQUB &A2, &13, &BD, &14, &54, &85, &75, &BD EQUB &00, &54, &85, &74, &A0, &00, &BD, &00 EQUB &55, &91, &74, &C8, &BD, &14, &55, &91 EQUB &74, &CA, &10, &E6, &A9, &4C, &8D, &1A EQUB &26, &8D, &8B, &24, &4C, &00, &58, &00 EQUB &04, &14, &0B, &0F, &11, &03, &03, &03 EQUB &03, &09, &10, &3A, &10, &16, &07, &04 EQUB &04, &09, &08, &12, &04, &05, &0A, &08 EQUB &12, &09, &0A, &08, &08, &07, &06, &0B EQUB &03, &06, &0F, &07, &06, &0E, &03, &07 EQUB &06, &0C, &0C, &08, &04, &03, &06, &02 EQUB &17, &0C, &06, &0D, &05, &05, &07, &05 EQUB &09, &0D, &4F, &B6, &0E, &39, &21, &31 EQUB &2A, &29, &1D, &FC, &29, &F6, &FC, &D6 EQUB &B5, &FE, &8D, &EA, &1F, &99, &48, &5F EQUB &60, &A4, &6F, &B9, &E8, &06, &C9, &10 EQUB &D0, &0F, &B9, &80, &08, &C9, &02, &90 EQUB &03, &4E, &FB, &62, &A0, &D7, &4C, &DC EQUB &53, &48, &C9, &58, &D0, &04, &A9, &27 EQUB &D0, &06, &C9, &A8, &D0, &09, &A9, &21 EQUB &D9, &80, &08, &90, &0A, &B0, &0B, &C9 EQUB &60, &F0, &04, &C9, &B0, &D0, &03, &4E EQUB &FB, &62, &68, &4C, &D8, &59, &20, &50 EQUB &34, &4C, &D0, &53, &4C, &EF, &53, &00 EQUB &01, &03, &04, &06, &07, &09, &0A, &0C EQUB &0D, &0F, &10, &12, &13, &15, &16, &17 EQUB &19, &1A, &1C, &1D, &1F, &20, &21, &23 EQUB &24, &26, &27, &28, &2A, &2B, &2D, &2E EQUB &2F, &31, &32, &33, &35, &36, &37, &39 EQUB &3A, &3B, &3C, &3E, &3F, &40, &41, &43 EQUB &44, &45, &46, &47, &49, &4A, &4B, &4C EQUB &4D, &4E, &4F, &51, &52, &53, &54, &55 \ &5800 EQUB &A9, &20, &8D, &48, &12, &8D, &FB, &12 EQUB &8D, &38, &25, &8D, &CB, &45, &8D, &23 EQUB &2F, &A9, &EA, &8D, &45, &25, &A9, &0D EQUB &8D, &EA, &24, &A9, &A2, &8D, &E9, &1F EQUB &A9, &00, &8D, &1B, &23, &4C, &00, &56 EQUB &FC, &FC, &00, &00, &00, &F0, &00, &00 EQUB &00, &D6, &DE, &DE, &F4, &10, &10, &10 EQUB &2C, &2C, &20, &20, &17, &15, &01, &FC EQUB &FC, &F9, &E9, &E6, &FF, &00, &00, &00 EQUB &00, &34, &FB, &FB, &B6, &CE, &E6, &45 EQUB &45, &1F, &99, &BC, &BC, &76, &BD, &BD EQUB &D9, &4D, &11, &11, &11, &62, &86, &96 EQUB &8E, &28, &C8, &00, &00, &00, &00, &3B EQUB &04, &04, &10, &4C, &58, &87, &87, &6A EQUB &71, &9B, &9B, &87, &7E, &7E, &65, &75 EQUB &A7, &A7, &A7, &CE, &D3, &11, &03, &DF EQUB &F3, &00, &01, &00, &14, &20, &28, &30 EQUB &40, &48, &50, &68, &70, &78, &8C, &91 EQUB &90, &94, &A1, &A0, &A8, &B0, &BC, &C4 EQUB &D4, &D8, &DC, &DA, &DE, &DA, &E2, &00 EQUB &18, &18, &47, &84, &18, &18, &47, &19 EQUB &19, &19, &58, &20, &5F, &35, &58, &00 EQUB &00, &58, &64, &3F, &18, &18, &53, &18 EQUB &59, &18, &18, &18, &18, &18, &00, &78 EQUB &78, &78, &78, &78, &78, &78, &78, &77 EQUB &77, &77, &77, &77, &76, &76, &76, &76 EQUB &75, &75, &75, &74, &74, &74, &73, &73 EQUB &72, &72, &71, &71, &70, &70, &6F, &6F EQUB &6E, &6E, &6D, &6C, &6C, &6B, &6B, &6A EQUB &69, &68, &68, &67, &66, &65, &65, &64 EQUB &63, &62, &61, &60, &60, &5F, &5E, &5D EQUB &5C, &5B, &5A, &59, &58, &57, &56, &55 \ &5900 EQUB &00, &20, &00, &20, &24, &01, &20, &4F EQUB &70, &20, &C4, &28, &24, &03, &28, &43 EQUB &ED, &20, &6C, &90, &24, &1F, &90, &09 EQUB &73, &72, &6C, &33, &52, &01, &2C, &0C EQUB &44, &42, &6C, &9A, &48, &0E, &B5, &4A EQUB &70, &04, &44, &00, &0A, &09, &1B, &31 EQUB &ED, &28, &CC, &A8, &41, &13, &0A, &0D EQUB &42, &02, &CC, &29, &4D, &21, &17, &1A EQUB &ED, &4C, &CC, &AD, &DA, &14, &7C, &36 EQUB &68, &97, &F4, &E9, &8E, &23, &BD, &12 EQUB &73, &1D, &24, &9D, &14, &0E, &71, &0F EQUB &70, &AB, &26, &E7, &82, &1E, &68, &29 EQUB &ED, &29, &48, &BF, &13, &20, &16, &07 EQUB &2A, &6F, &64, &B0, &33, &00, &12, &2E EQUB &73, &F5, &44, &CC, &B9, &02, &2E, &06 EQUB &40, &EA, &A4, &37, &E1, &09, &0B, &18 EQUB &28, &58, &0E, &1B, &53, &22, &23, &1C EQUB &73, &C8, &DE, &FB, &C3, &24, &03, &12 EQUB &70, &F9, &A8, &4B, &C2, &0F, &E3, &14 EQUB &ED, &83, &28, &2C, &75, &24, &6F, &0D EQUB &42, &B0, &9B, &CF, &40, &0B, &01, &19 EQUB &70, &1E, &A9, &12, &AE, &26, &44, &24 EQUB &ED, &56, &96, &5E, &E6, &24, &90, &05 EQUB &42, &15, &8C, &47, &C1, &03, &5A, &07 EQUB &ED, &17, &70, &9E, &A3, &0C, &BD, &1B EQUB &00, &D0, &09, &A5, &63, &20, &10, &46 EQUB &10, &02, &C6, &77, &0A, &26, &77, &60 EQUB &A0, &B5, &C9, &18, &D0, &02, &A0, &CD EQUB &C9, &30, &F0, &04, &C9, &28, &D0, &02 EQUB &A0, &BC, &4C, &DC, &53, &B9, &61, &5F EQUB &C9, &8B, &F0, &04, &B9, &60, &5F, &60 EQUB &4A, &60, &C8, &28, &CF, &02, &FE, &01 \ &5A00 EQUB &17, &13, &00, &01, &01, &00, &68, &00 EQUB &68, &45, &3C, &33, &2C, &A1, &00, &A1 EQUB &6A, &5D, &4F, &45, &86, &92, &98, &04 EQUB &21, &14, &00, &20, &7F, &55, &4C, &72 EQUB &54, &00 .CallTrackHook JMP &5700 .trackChecksum EQUB &A8, &CD, &4B, &65 EQUS "REVS" \ Game name EQUS "Donington Park" \ Track name EQUB 13 EQUB &22, &20, &42, &52 EQUB &41, &4E, &44, &53, &20, &48, &41, &54 EQUB &43, &48, &22, &2C, &22, &20, &44, &4F EQUB &4E, &49, &4E, &47, &54, &4F, &4E, &20 EQUB &50, &41, &52, &4B, &22, &2C, &22, &20 EQUB &4F, &55, &4C, &54, &4F, &4E, &20, &50 EQUB &41, &52, &4B, &20, &20, &20, &22, &2C EQUB &22, &20, &53, &4E, &45, &54, &54, &45 EQUB &52, &54, &4F, &4E, &20, &20, &20, &20 EQUB &22, &0D, &04, &06, &0A, &20, &DC, &22 EQUB &22, &20, &20, &0D, &04, &10, &24, &20 EQUB &F4, &20, &50, &72, &6F, &67, &72, &61 EQUB &6D, &73, &20, &6F, &6E, &20, &74, &68 EQUB &65, &20, &64, &69, &73, &63, &20, &6F EQUB &72, &20, &74, &61, &70, &65, &20, &0D EQUB &04, &1A, &11, &20, &DC, &42, &20, &2C EQUB &44, &20, &2C, &4F, &20, &2C, &53, &20 EQUB &0D, &04, &24, &0E, &20, &DC, &22, &22 EQUB &20, &20, &20, &20, &20, &20, &0D, &FF \ ****************************************************************************** \ \ Save DoningtonPark.bin \ \ ****************************************************************************** SAVE "3-assembled-output/DoningtonPark.bin", CODE%, P%
; A083423: a(n) = (5*3^n + (-3)^n)/6. ; 1,2,9,18,81,162,729,1458,6561,13122,59049,118098,531441,1062882,4782969,9565938,43046721,86093442,387420489,774840978,3486784401,6973568802,31381059609,62762119218,282429536481,564859072962 mov $1,$0 gcd $1,2 add $1,1 mov $2,$0 lpb $2,1 mul $1,3 sub $2,1 lpe sub $1,3 div $1,3 add $1,1
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2016 The DarkNet developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "walletmodel.h" #include "addresstablemodel.h" #include "guiconstants.h" #include "recentrequeststablemodel.h" #include "transactiontablemodel.h" #include "base58.h" #include "db.h" #include "keystore.h" #include "main.h" #include "sync.h" #include "ui_interface.h" #include "wallet.h" #include "walletdb.h" // for BackupWallet #include "spork.h" #include <stdint.h> #include <QDebug> #include <QSet> #include <QTimer> using namespace std; WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), transactionTableModel(0), recentRequestsTableModel(0), cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), cachedEncryptionStatus(Unencrypted), cachedNumBlocks(0) { fHaveWatchOnly = wallet->HaveWatchOnly(); fForceCheckBalanceChanged = false; addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); recentRequestsTableModel = new RecentRequestsTableModel(wallet, this); // This timer will be fired repeatedly to update the balance pollTimer = new QTimer(this); connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged())); pollTimer->start(MODEL_UPDATE_DELAY); subscribeToCoreSignals(); } WalletModel::~WalletModel() { unsubscribeFromCoreSignals(); } CAmount WalletModel::getBalance(const CCoinControl *coinControl) const { if (coinControl) { CAmount nBalance = 0; std::vector<COutput> vCoins; wallet->AvailableCoins(vCoins, true, coinControl); BOOST_FOREACH(const COutput& out, vCoins) if(out.fSpendable) nBalance += out.tx->vout[out.i].nValue; return nBalance; } return wallet->GetBalance(); } CAmount WalletModel::getAnonymizedBalance() const { return wallet->GetAnonymizedBalance(); } CAmount WalletModel::getUnconfirmedBalance() const { return wallet->GetUnconfirmedBalance(); } CAmount WalletModel::getImmatureBalance() const { return wallet->GetImmatureBalance(); } bool WalletModel::haveWatchOnly() const { return fHaveWatchOnly; } CAmount WalletModel::getWatchBalance() const { return wallet->GetWatchOnlyBalance(); } CAmount WalletModel::getWatchUnconfirmedBalance() const { return wallet->GetUnconfirmedWatchOnlyBalance(); } CAmount WalletModel::getWatchImmatureBalance() const { return wallet->GetImmatureWatchOnlyBalance(); } void WalletModel::updateStatus() { EncryptionStatus newEncryptionStatus = getEncryptionStatus(); if(cachedEncryptionStatus != newEncryptionStatus) emit encryptionStatusChanged(newEncryptionStatus); } void WalletModel::pollBalanceChanged() { // Get required locks upfront. This avoids the GUI from getting stuck on // periodical polls if the core is holding the locks for a longer time - // for example, during a wallet rescan. TRY_LOCK(cs_main, lockMain); if(!lockMain) return; TRY_LOCK(wallet->cs_wallet, lockWallet); if(!lockWallet) return; if(fForceCheckBalanceChanged || chainActive.Height() != cachedNumBlocks || nObfuscationRounds != cachedObfuscationRounds || cachedTxLocks != nCompleteTXLocks) { fForceCheckBalanceChanged = false; // Balance and number of transactions might have changed cachedNumBlocks = chainActive.Height(); cachedObfuscationRounds = nObfuscationRounds; checkBalanceChanged(); if(transactionTableModel){ transactionTableModel->updateConfirmations(); } } } void WalletModel::checkBalanceChanged() { TRY_LOCK(cs_main, lockMain); if(!lockMain) return; CAmount newBalance = getBalance(); CAmount newUnconfirmedBalance = getUnconfirmedBalance(); CAmount newImmatureBalance = getImmatureBalance(); CAmount newAnonymizedBalance = getAnonymizedBalance(); CAmount newWatchOnlyBalance = 0; CAmount newWatchUnconfBalance = 0; CAmount newWatchImmatureBalance = 0; if (haveWatchOnly()) { newWatchOnlyBalance = getWatchBalance(); newWatchUnconfBalance = getWatchUnconfirmedBalance(); newWatchImmatureBalance = getWatchImmatureBalance(); } if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance || cachedAnonymizedBalance != newAnonymizedBalance || cachedTxLocks != nCompleteTXLocks || cachedWatchOnlyBalance != newWatchOnlyBalance || cachedWatchUnconfBalance != newWatchUnconfBalance || cachedWatchImmatureBalance != newWatchImmatureBalance) { cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; cachedImmatureBalance = newImmatureBalance; cachedAnonymizedBalance = newAnonymizedBalance; cachedTxLocks = nCompleteTXLocks; cachedWatchOnlyBalance = newWatchOnlyBalance; cachedWatchUnconfBalance = newWatchUnconfBalance; cachedWatchImmatureBalance = newWatchImmatureBalance; emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance, newAnonymizedBalance, newWatchOnlyBalance, newWatchUnconfBalance, newWatchImmatureBalance); } } void WalletModel::updateTransaction() { // Balance and number of transactions might have changed fForceCheckBalanceChanged = true; } void WalletModel::updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status) { if(addressTableModel) addressTableModel->updateEntry(address, label, isMine, purpose, status); } void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly) { fHaveWatchOnly = fHaveWatchonly; emit notifyWatchonlyChanged(fHaveWatchonly); } bool WalletModel::validateAddress(const QString &address) { CBitcoinAddress addressParsed(address.toStdString()); return addressParsed.IsValid(); } WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl) { CAmount total = 0; QList<SendCoinsRecipient> recipients = transaction.getRecipients(); std::vector<std::pair<CScript, CAmount> > vecSend; if(recipients.empty()) { return OK; } if(isAnonymizeOnlyUnlocked()) { return AnonymizeOnlyUnlocked; } QSet<QString> setAddress; // Used to detect duplicates int nAddresses = 0; // Pre-check input data for validity foreach(const SendCoinsRecipient &rcp, recipients) { if (rcp.paymentRequest.IsInitialized()) { // PaymentRequest... CAmount subtotal = 0; const payments::PaymentDetails& details = rcp.paymentRequest.getDetails(); for (int i = 0; i < details.outputs_size(); i++) { const payments::Output& out = details.outputs(i); if (out.amount() <= 0) continue; subtotal += out.amount(); const unsigned char* scriptStr = (const unsigned char*)out.script().data(); CScript scriptPubKey(scriptStr, scriptStr+out.script().size()); vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, out.amount())); } if (subtotal <= 0) { return InvalidAmount; } total += subtotal; } else { // User-entered darknet address / amount: if(!validateAddress(rcp.address)) { return InvalidAddress; } if(rcp.amount <= 0) { return InvalidAmount; } setAddress.insert(rcp.address); ++nAddresses; CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get()); vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, rcp.amount)); total += rcp.amount; } } if(setAddress.size() != nAddresses) { return DuplicateAddress; } CAmount nBalance = getBalance(coinControl); if(total > nBalance) { return AmountExceedsBalance; } { LOCK2(cs_main, wallet->cs_wallet); transaction.newPossibleKeyChange(wallet); CAmount nFeeRequired = 0; std::string strFailReason; CWalletTx *newTx = transaction.getTransaction(); CReserveKey *keyChange = transaction.getPossibleKeyChange(); if(recipients[0].useSwiftTX && total > GetSporkValue(SPORK_5_MAX_VALUE)*COIN){ emit message(tr("Send Coins"), tr("SwiftTX doesn't support sending values that high yet. Transactions are currently limited to %1 DNET.").arg(GetSporkValue(SPORK_5_MAX_VALUE)), CClientUIInterface::MSG_ERROR); return TransactionCreationFailed; } bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl, recipients[0].inputType, recipients[0].useSwiftTX); transaction.setTransactionFee(nFeeRequired); if(recipients[0].useSwiftTX && newTx->GetValueOut() > GetSporkValue(SPORK_5_MAX_VALUE)*COIN){ emit message(tr("Send Coins"), tr("SwiftTX doesn't support sending values that high yet. Transactions are currently limited to %1 DNET.").arg(GetSporkValue(SPORK_5_MAX_VALUE)), CClientUIInterface::MSG_ERROR); return TransactionCreationFailed; } if(!fCreated) { if((total + nFeeRequired) > nBalance) { return SendCoinsReturn(AmountWithFeeExceedsBalance); } emit message(tr("Send Coins"), QString::fromStdString(strFailReason), CClientUIInterface::MSG_ERROR); return TransactionCreationFailed; } // reject insane fee if (nFeeRequired > ::minRelayTxFee.GetFee(transaction.getTransactionSize()) * 10000) return InsaneFee; } return SendCoinsReturn(OK); } WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction) { QByteArray transaction_array; /* store serialized transaction */ if(isAnonymizeOnlyUnlocked()) { return AnonymizeOnlyUnlocked; } { LOCK2(cs_main, wallet->cs_wallet); CWalletTx *newTx = transaction.getTransaction(); QList<SendCoinsRecipient> recipients = transaction.getRecipients(); // Store PaymentRequests in wtx.vOrderForm in wallet. foreach(const SendCoinsRecipient &rcp, recipients) { if (rcp.paymentRequest.IsInitialized()) { std::string key("PaymentRequest"); std::string value; rcp.paymentRequest.SerializeToString(&value); newTx->vOrderForm.push_back(make_pair(key, value)); } else if (!rcp.message.isEmpty()) // Message from normal darknet:URI (darknet:XyZ...?message=example) { newTx->vOrderForm.push_back(make_pair("Message", rcp.message.toStdString())); } } CReserveKey *keyChange = transaction.getPossibleKeyChange(); transaction.getRecipients(); if(!wallet->CommitTransaction(*newTx, *keyChange, (recipients[0].useSwiftTX) ? "ix" : "tx")) return TransactionCommitFailed; CTransaction* t = (CTransaction*)newTx; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << *t; transaction_array.append(&(ssTx[0]), ssTx.size()); } // Add addresses / update labels that we've sent to to the address book, // and emit coinsSent signal for each recipient foreach(const SendCoinsRecipient &rcp, transaction.getRecipients()) { // Don't touch the address book when we have a payment request if (!rcp.paymentRequest.IsInitialized()) { std::string strAddress = rcp.address.toStdString(); CTxDestination dest = CBitcoinAddress(strAddress).Get(); std::string strLabel = rcp.label.toStdString(); { LOCK(wallet->cs_wallet); std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest); // Check if we have a new address or an updated label if (mi == wallet->mapAddressBook.end()) { wallet->SetAddressBook(dest, strLabel, "send"); } else if (mi->second.name != strLabel) { wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose } } } emit coinsSent(wallet, rcp, transaction_array); } checkBalanceChanged(); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits return SendCoinsReturn(OK); } OptionsModel *WalletModel::getOptionsModel() { return optionsModel; } AddressTableModel *WalletModel::getAddressTableModel() { return addressTableModel; } TransactionTableModel *WalletModel::getTransactionTableModel() { return transactionTableModel; } RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel() { return recentRequestsTableModel; } WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const { if(!wallet->IsCrypted()) { return Unencrypted; } else if(wallet->IsLocked()) { return Locked; } else if (wallet->fWalletUnlockAnonymizeOnly) { return UnlockedForAnonymizationOnly; } else { return Unlocked; } } bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase) { if(encrypted) { // Encrypt return wallet->EncryptWallet(passphrase); } else { // Decrypt -- TODO; not supported yet return false; } } bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool anonymizeOnly) { if(locked) { // Lock return wallet->Lock(); } else { // Unlock return wallet->Unlock(passPhrase, anonymizeOnly); } } bool WalletModel::isAnonymizeOnlyUnlocked() { return wallet->fWalletUnlockAnonymizeOnly; } bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass) { bool retval; { LOCK(wallet->cs_wallet); wallet->Lock(); // Make sure wallet is locked before attempting pass change retval = wallet->ChangeWalletPassphrase(oldPass, newPass); } return retval; } bool WalletModel::backupWallet(const QString &filename) { return BackupWallet(*wallet, filename.toLocal8Bit().data()); } // Handlers for core signals static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet) { qDebug() << "NotifyKeyStoreStatusChanged"; QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection); } static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status) { QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString()); QString strLabel = QString::fromStdString(label); QString strPurpose = QString::fromStdString(purpose); qDebug() << "NotifyAddressBookChanged : " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status); QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection, Q_ARG(QString, strAddress), Q_ARG(QString, strLabel), Q_ARG(bool, isMine), Q_ARG(QString, strPurpose), Q_ARG(int, status)); } // queue notifications to show a non freezing progress dialog e.g. for rescan static bool fQueueNotifications = false; static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications; static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status) { if (fQueueNotifications) { vQueueNotifications.push_back(make_pair(hash, status)); return; } QString strHash = QString::fromStdString(hash.GetHex()); qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status); QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection/*, Q_ARG(QString, strHash), Q_ARG(int, status)*/); } static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress) { // emits signal "showProgress" QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(title)), Q_ARG(int, nProgress)); } static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly) { QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection, Q_ARG(bool, fHaveWatchonly)); } void WalletModel::subscribeToCoreSignals() { // Connect signals to wallet wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); wallet->NotifyWatchonlyChanged.connect(boost::bind(NotifyWatchonlyChanged, this, _1)); } void WalletModel::unsubscribeFromCoreSignals() { // Disconnect signals from wallet wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); wallet->NotifyWatchonlyChanged.disconnect(boost::bind(NotifyWatchonlyChanged, this, _1)); } // WalletModel::UnlockContext implementation WalletModel::UnlockContext WalletModel::requestUnlock(bool relock) { bool was_locked = getEncryptionStatus() == Locked; if (!was_locked && isAnonymizeOnlyUnlocked()) { setWalletLocked(true); was_locked = getEncryptionStatus() == Locked; } if(was_locked) { // Request UI to unlock wallet emit requireUnlock(); } // If wallet is still locked, unlock was failed or cancelled, mark context as invalid bool valid = getEncryptionStatus() != Locked; return UnlockContext(this, valid, relock); // return UnlockContext(this, valid, was_locked && !isAnonymizeOnlyUnlocked()); } WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool relock): wallet(wallet), valid(valid), relock(relock) { } WalletModel::UnlockContext::~UnlockContext() { if(valid && relock) { wallet->setWalletLocked(true); } } void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs) { // Transfer context; old object no longer relocks wallet *this = rhs; rhs.relock = false; } bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const { return wallet->GetPubKey(address, vchPubKeyOut); } // returns a list of COutputs from COutPoints void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs) { LOCK2(cs_main, wallet->cs_wallet); BOOST_FOREACH(const COutPoint& outpoint, vOutpoints) { if (!wallet->mapWallet.count(outpoint.hash)) continue; int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); if (nDepth < 0) continue; COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true); vOutputs.push_back(out); } } bool WalletModel::isSpent(const COutPoint& outpoint) const { LOCK2(cs_main, wallet->cs_wallet); return wallet->IsSpent(outpoint.hash, outpoint.n); } // AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address) void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const { std::vector<COutput> vCoins; wallet->AvailableCoins(vCoins); LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet std::vector<COutPoint> vLockedCoins; wallet->ListLockedCoins(vLockedCoins); // add locked coins BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins) { if (!wallet->mapWallet.count(outpoint.hash)) continue; int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); if (nDepth < 0) continue; COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true); if (outpoint.n < out.tx->vout.size() && wallet->IsMine(out.tx->vout[outpoint.n]) == ISMINE_SPENDABLE) vCoins.push_back(out); } BOOST_FOREACH(const COutput& out, vCoins) { COutput cout = out; while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0])) { if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break; cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true); } CTxDestination address; if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue; mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out); } } bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const { LOCK2(cs_main, wallet->cs_wallet); return wallet->IsLockedCoin(hash, n); } void WalletModel::lockCoin(COutPoint& output) { LOCK2(cs_main, wallet->cs_wallet); wallet->LockCoin(output); } void WalletModel::unlockCoin(COutPoint& output) { LOCK2(cs_main, wallet->cs_wallet); wallet->UnlockCoin(output); } void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts) { LOCK2(cs_main, wallet->cs_wallet); wallet->ListLockedCoins(vOutpts); } void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests) { LOCK(wallet->cs_wallet); BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook) BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item2, item.second.destdata) if (item2.first.size() > 2 && item2.first.substr(0,2) == "rr") // receive request vReceiveRequests.push_back(item2.second); } bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest) { CTxDestination dest = CBitcoinAddress(sAddress).Get(); std::stringstream ss; ss << nId; std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata LOCK(wallet->cs_wallet); if (sRequest.empty()) return wallet->EraseDestData(dest, key); else return wallet->AddDestData(dest, key, sRequest); }
[BITS 32] MOV ECX, msg MOV EDX, 1 put_loop: MOV AL, [CS:ECX] CMP AL, 0 JE fin INT 0x40 ADD ECX, 1 JMP put_loop fin: MOV EDX, 4 INT 0x40 msg: DB "hello", 0
#include <iostream> #include "tree.h" #include "linklist.h" #include "solution.h" int main() { Solution s; const int N = 7; int nums[N] = { 3,9,20,NULL,NULL,15,7 }; TreeNode *tree; creatTreeNode(tree, nums, N, 0); //int res = s.maxDepth(tree); vector<vector<int>>res = s.zigzagLevelOrder(tree); for (int i = 0; i <res.size(); i++) { for (int j = 0; j <res[i].size(); j++) { std::cout << res[i][j] << std::endl; } std::cout << "********" << std::endl; } std::cout << "Test Finished." << std::endl; std::getchar(); return 0; }
data export cg_customSoundNames align 4 LABELV cg_customSoundNames address $71 address $72 address $73 address $74 address $75 address $76 address $77 address $78 address $79 address $80 address $81 address $82 address $83 skip 76 export CG_CustomSound code proc CG_CustomSound 16 8 ADDRFP4 0 ADDRFP4 0 INDIRI4 ASGNI4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRFP4 4 INDIRP4 INDIRI1 CVII4 1 CNSTI4 42 EQI4 $85 ADDRFP4 4 INDIRP4 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 8 ADDRGP4 trap_S_RegisterSound CALLI4 ASGNI4 ADDRLP4 8 INDIRI4 RETI4 ADDRGP4 $84 JUMPV LABELV $85 ADDRFP4 0 INDIRI4 CNSTI4 0 LTI4 $89 ADDRFP4 0 INDIRI4 CNSTI4 64 LTI4 $87 LABELV $89 ADDRFP4 0 CNSTI4 0 ASGNI4 LABELV $87 ADDRLP4 4 CNSTI4 1716 ADDRFP4 0 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 0 CNSTI4 0 ASGNI4 ADDRGP4 $94 JUMPV LABELV $91 ADDRFP4 4 INDIRP4 ARGP4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 cg_customSoundNames ADDP4 INDIRP4 ARGP4 ADDRLP4 12 ADDRGP4 qk_strcmp CALLI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 0 NEI4 $95 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRLP4 4 INDIRP4 CNSTI4 1588 ADDP4 ADDP4 INDIRI4 RETI4 ADDRGP4 $84 JUMPV LABELV $95 LABELV $92 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $94 ADDRLP4 0 INDIRI4 CNSTI4 32 GEI4 $97 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 cg_customSoundNames ADDP4 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $91 LABELV $97 ADDRGP4 $98 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_Error CALLV pop CNSTI4 0 RETI4 LABELV $84 endproc CG_CustomSound 16 8 proc CG_ParseAnimationFile 20088 12 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 8 ADDRFP4 4 INDIRP4 CNSTI4 552 ADDP4 ASGNP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 20032 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 20036 ADDRGP4 trap_FS_FOpenFile CALLI4 ASGNI4 ADDRLP4 28 ADDRLP4 20036 INDIRI4 ASGNI4 ADDRLP4 28 INDIRI4 CNSTI4 0 GTI4 $100 CNSTI4 0 RETI4 ADDRGP4 $99 JUMPV LABELV $100 ADDRLP4 28 INDIRI4 CVIU4 4 CNSTU4 19999 LTU4 $102 ADDRGP4 $104 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_Printf CALLV pop ADDRLP4 20032 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop CNSTI4 0 RETI4 ADDRGP4 $99 JUMPV LABELV $102 ADDRLP4 32 ARGP4 ADDRLP4 28 INDIRI4 ARGI4 ADDRLP4 20032 INDIRI4 ARGI4 ADDRGP4 trap_FS_Read CALLV pop ADDRLP4 28 INDIRI4 ADDRLP4 32 ADDP4 CNSTI1 0 ASGNI1 ADDRLP4 20032 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop ADDRLP4 12 ADDRLP4 32 ASGNP4 ADDRLP4 20040 CNSTI4 0 ASGNI4 ADDRLP4 24 ADDRLP4 20040 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 ADDRLP4 20040 INDIRI4 ASGNI4 ADDRLP4 20048 CNSTF4 0 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 512 ADDP4 ADDRLP4 20048 INDIRF4 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 508 ADDP4 ADDRLP4 20048 INDIRF4 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 504 ADDP4 ADDRLP4 20048 INDIRF4 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 520 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 496 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 500 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 $106 JUMPV LABELV $105 ADDRLP4 20 ADDRLP4 12 INDIRP4 ASGNP4 ADDRLP4 12 ARGP4 ADDRLP4 20052 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20052 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $108 ADDRGP4 $107 JUMPV LABELV $108 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $112 ARGP4 ADDRLP4 20056 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20056 INDIRI4 CNSTI4 0 NEI4 $110 ADDRLP4 12 ARGP4 ADDRLP4 20060 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20060 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $113 ADDRGP4 $107 JUMPV LABELV $113 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $117 ARGP4 ADDRLP4 20064 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20064 INDIRI4 CNSTI4 0 EQI4 $119 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $118 ARGP4 ADDRLP4 20068 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20068 INDIRI4 CNSTI4 0 NEI4 $115 LABELV $119 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 $106 JUMPV LABELV $115 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $122 ARGP4 ADDRLP4 20072 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20072 INDIRI4 CNSTI4 0 NEI4 $120 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 CNSTI4 1 ASGNI4 ADDRGP4 $106 JUMPV LABELV $120 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $125 ARGP4 ADDRLP4 20076 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20076 INDIRI4 CNSTI4 0 NEI4 $123 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 CNSTI4 2 ASGNI4 ADDRGP4 $106 JUMPV LABELV $123 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $128 ARGP4 ADDRLP4 20080 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20080 INDIRI4 CNSTI4 0 NEI4 $126 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 CNSTI4 3 ASGNI4 ADDRGP4 $106 JUMPV LABELV $126 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $131 ARGP4 ADDRLP4 20084 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20084 INDIRI4 CNSTI4 0 NEI4 $129 ADDRFP4 4 INDIRP4 CNSTI4 516 ADDP4 CNSTI4 4 ASGNI4 ADDRGP4 $106 JUMPV LABELV $129 ADDRGP4 $132 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 CG_Printf CALLV pop ADDRGP4 $106 JUMPV LABELV $110 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $135 ARGP4 ADDRLP4 20060 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20060 INDIRI4 CNSTI4 0 NEI4 $133 ADDRLP4 4 CNSTI4 0 ASGNI4 LABELV $136 ADDRLP4 12 ARGP4 ADDRLP4 20064 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20064 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $140 ADDRGP4 $106 JUMPV LABELV $140 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 20068 ADDRGP4 qk_atof CALLF4 ASGNF4 ADDRLP4 4 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 4 INDIRP4 CNSTI4 504 ADDP4 ADDP4 ADDRLP4 20068 INDIRF4 ASGNF4 LABELV $137 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 4 INDIRI4 CNSTI4 3 LTI4 $136 ADDRGP4 $106 JUMPV LABELV $133 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $144 ARGP4 ADDRLP4 20064 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20064 INDIRI4 CNSTI4 0 NEI4 $142 ADDRLP4 12 ARGP4 ADDRLP4 20068 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20068 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $145 ADDRGP4 $107 JUMPV LABELV $145 ADDRLP4 20072 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 ASGNI4 ADDRLP4 20072 INDIRI4 CNSTI4 102 EQI4 $149 ADDRLP4 20072 INDIRI4 CNSTI4 70 NEI4 $147 LABELV $149 ADDRFP4 4 INDIRP4 CNSTI4 520 ADDP4 CNSTI4 1 ASGNI4 ADDRGP4 $106 JUMPV LABELV $147 ADDRLP4 20076 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 ASGNI4 ADDRLP4 20076 INDIRI4 CNSTI4 110 EQI4 $152 ADDRLP4 20076 INDIRI4 CNSTI4 78 NEI4 $150 LABELV $152 ADDRFP4 4 INDIRP4 CNSTI4 520 ADDP4 CNSTI4 2 ASGNI4 ADDRGP4 $106 JUMPV LABELV $150 ADDRFP4 4 INDIRP4 CNSTI4 520 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 $106 JUMPV LABELV $142 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $155 ARGP4 ADDRLP4 20068 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20068 INDIRI4 CNSTI4 0 NEI4 $153 ADDRFP4 4 INDIRP4 CNSTI4 496 ADDP4 CNSTI4 1 ASGNI4 ADDRGP4 $106 JUMPV LABELV $153 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $158 ARGP4 ADDRLP4 20072 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20072 INDIRI4 CNSTI4 0 NEI4 $156 ADDRFP4 4 INDIRP4 CNSTI4 500 ADDP4 CNSTI4 1 ASGNI4 ADDRGP4 $106 JUMPV LABELV $156 ADDRLP4 20076 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 ASGNI4 ADDRLP4 20076 INDIRI4 CNSTI4 48 LTI4 $159 ADDRLP4 20076 INDIRI4 CNSTI4 57 GTI4 $159 ADDRLP4 12 ADDRLP4 20 INDIRP4 ASGNP4 ADDRGP4 $107 JUMPV LABELV $159 ADDRGP4 $161 ARGP4 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 Com_Printf CALLV pop LABELV $106 ADDRGP4 $105 JUMPV LABELV $107 ADDRLP4 4 CNSTI4 0 ASGNI4 LABELV $162 ADDRLP4 12 ARGP4 ADDRLP4 20052 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20052 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $166 ADDRLP4 4 INDIRI4 CNSTI4 25 LTI4 $164 ADDRLP4 4 INDIRI4 CNSTI4 30 GTI4 $164 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 ADDRLP4 8 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 12 ADDP4 ADDRLP4 8 INDIRP4 CNSTI4 180 ADDP4 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 16 ADDP4 ADDRLP4 8 INDIRP4 CNSTI4 184 ADDP4 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 8 ADDP4 ADDRLP4 8 INDIRP4 CNSTI4 176 ADDP4 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 4 ADDP4 ADDRLP4 8 INDIRP4 CNSTI4 172 ADDP4 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 20 ADDP4 CNSTI4 0 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 24 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 $163 JUMPV LABELV $166 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 20056 ADDRGP4 qk_atoi CALLI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 ADDRLP4 20056 INDIRI4 ASGNI4 ADDRLP4 4 INDIRI4 CNSTI4 13 NEI4 $170 ADDRLP4 24 ADDRLP4 8 INDIRP4 CNSTI4 364 ADDP4 INDIRI4 ADDRLP4 8 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 SUBI4 ASGNI4 LABELV $170 ADDRLP4 4 INDIRI4 CNSTI4 13 LTI4 $172 ADDRLP4 4 INDIRI4 CNSTI4 25 GEI4 $172 ADDRLP4 20064 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 ASGNP4 ADDRLP4 20064 INDIRP4 ADDRLP4 20064 INDIRP4 INDIRI4 ADDRLP4 24 INDIRI4 SUBI4 ASGNI4 LABELV $172 ADDRLP4 12 ARGP4 ADDRLP4 20064 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20064 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $174 ADDRGP4 $164 JUMPV LABELV $174 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 20068 ADDRGP4 qk_atoi CALLI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 4 ADDP4 ADDRLP4 20068 INDIRI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 20 ADDP4 CNSTI4 0 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 24 ADDP4 CNSTI4 0 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 4 ADDP4 INDIRI4 CNSTI4 0 GEI4 $176 ADDRLP4 20072 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 4 ADDP4 ASGNP4 ADDRLP4 20072 INDIRP4 ADDRLP4 20072 INDIRP4 INDIRI4 NEGI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 20 ADDP4 CNSTI4 1 ASGNI4 LABELV $176 ADDRLP4 12 ARGP4 ADDRLP4 20072 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20072 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $178 ADDRGP4 $164 JUMPV LABELV $178 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 20076 ADDRGP4 qk_atoi CALLI4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 8 ADDP4 ADDRLP4 20076 INDIRI4 ASGNI4 ADDRLP4 12 ARGP4 ADDRLP4 20080 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 20080 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $180 ADDRGP4 $164 JUMPV LABELV $180 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 20084 ADDRGP4 qk_atof CALLF4 ASGNF4 ADDRLP4 16 ADDRLP4 20084 INDIRF4 ASGNF4 ADDRLP4 16 INDIRF4 CNSTF4 0 NEF4 $182 ADDRLP4 16 CNSTF4 1065353216 ASGNF4 LABELV $182 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 12 ADDP4 CNSTF4 1148846080 ADDRLP4 16 INDIRF4 DIVF4 CVFI4 4 ASGNI4 CNSTI4 28 ADDRLP4 4 INDIRI4 MULI4 ADDRLP4 8 INDIRP4 ADDP4 CNSTI4 16 ADDP4 CNSTF4 1148846080 ADDRLP4 16 INDIRF4 DIVF4 CVFI4 4 ASGNI4 LABELV $163 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 4 INDIRI4 CNSTI4 31 LTI4 $162 LABELV $164 ADDRLP4 4 INDIRI4 CNSTI4 31 EQI4 $184 ADDRGP4 $186 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $99 JUMPV LABELV $184 ADDRLP4 8 INDIRP4 CNSTI4 896 ADDP4 ARGP4 ADDRLP4 8 INDIRP4 CNSTI4 364 ADDP4 ARGP4 CNSTU4 28 ARGU4 ADDRGP4 qk_memcpy CALLP4 pop ADDRLP4 8 INDIRP4 CNSTI4 916 ADDP4 CNSTI4 1 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 924 ADDP4 ARGP4 ADDRLP4 8 INDIRP4 CNSTI4 392 ADDP4 ARGP4 CNSTU4 28 ARGU4 ADDRGP4 qk_memcpy CALLP4 pop ADDRLP4 8 INDIRP4 CNSTI4 944 ADDP4 CNSTI4 1 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 952 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 956 ADDP4 CNSTI4 16 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 960 ADDP4 CNSTI4 16 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 964 ADDP4 CNSTI4 66 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 968 ADDP4 CNSTI4 66 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 972 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 980 ADDP4 CNSTI4 16 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 984 ADDP4 CNSTI4 5 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 988 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 992 ADDP4 CNSTI4 50 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 996 ADDP4 CNSTI4 50 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1000 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1008 ADDP4 CNSTI4 16 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1012 ADDP4 CNSTI4 5 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1016 ADDP4 CNSTI4 1 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1020 ADDP4 CNSTI4 66 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1024 ADDP4 CNSTI4 66 ASGNI4 ADDRLP4 8 INDIRP4 CNSTI4 1028 ADDP4 CNSTI4 1 ASGNI4 CNSTI4 1 RETI4 LABELV $99 endproc CG_ParseAnimationFile 20088 12 proc CG_FileExists 8 12 ADDRFP4 0 INDIRP4 ARGP4 CNSTP4 0 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 4 ADDRGP4 trap_FS_FOpenFile CALLI4 ASGNI4 ADDRLP4 0 ADDRLP4 4 INDIRI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 0 LEI4 $188 CNSTI4 1 RETI4 ADDRGP4 $187 JUMPV LABELV $188 CNSTI4 0 RETI4 LABELV $187 endproc CG_FileExists 8 12 proc CG_FindClientModelFile 32 40 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRI4 ASGNI4 ADDRFP4 12 ADDRFP4 12 INDIRP4 ASGNP4 ADDRFP4 16 ADDRFP4 16 INDIRP4 ASGNP4 ADDRFP4 20 ADDRFP4 20 INDIRP4 ASGNP4 ADDRFP4 24 ADDRFP4 24 INDIRP4 ASGNP4 ADDRFP4 28 ADDRFP4 28 INDIRP4 ASGNP4 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $191 ADDRLP4 12 ADDRFP4 8 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 2 EQI4 $197 ADDRGP4 $194 JUMPV LABELV $197 ADDRLP4 8 ADDRGP4 $198 ASGNP4 ADDRGP4 $192 JUMPV LABELV $194 ADDRLP4 8 ADDRGP4 $199 ASGNP4 ADDRGP4 $192 JUMPV LABELV $191 ADDRLP4 8 ADDRGP4 $117 ASGNP4 LABELV $192 ADDRLP4 4 ADDRGP4 $200 ASGNP4 ADDRGP4 $202 JUMPV LABELV $201 ADDRLP4 0 CNSTI4 0 ASGNI4 LABELV $204 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 12 INDIRI4 NEI4 $208 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $208 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 12 INDIRI4 EQI4 $208 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $210 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $209 JUMPV LABELV $208 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $211 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $209 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 20 ADDRGP4 CG_FileExists CALLI4 ASGNI4 ADDRLP4 20 INDIRI4 CNSTI4 0 EQI4 $212 CNSTI4 1 RETI4 ADDRGP4 $190 JUMPV LABELV $212 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $214 ADDRLP4 24 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 24 INDIRI4 NEI4 $217 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $217 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 24 INDIRI4 EQI4 $217 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $219 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $215 JUMPV LABELV $217 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $220 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $215 JUMPV LABELV $214 ADDRLP4 24 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 24 INDIRI4 NEI4 $221 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $221 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 24 INDIRI4 EQI4 $221 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $219 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $222 JUMPV LABELV $221 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $220 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $222 LABELV $215 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 24 ADDRGP4 CG_FileExists CALLI4 ASGNI4 ADDRLP4 24 INDIRI4 CNSTI4 0 EQI4 $223 CNSTI4 1 RETI4 ADDRGP4 $190 JUMPV LABELV $223 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $227 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $225 LABELV $227 ADDRGP4 $206 JUMPV LABELV $225 LABELV $205 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LTI4 $204 LABELV $206 ADDRLP4 4 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $228 ADDRGP4 $203 JUMPV LABELV $228 ADDRLP4 4 ADDRGP4 $230 ASGNP4 LABELV $202 ADDRGP4 $201 JUMPV LABELV $203 CNSTI4 0 RETI4 LABELV $190 endproc CG_FindClientModelFile 32 40 proc CG_FindClientHeadFile 32 40 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRI4 ASGNI4 ADDRFP4 12 ADDRFP4 12 INDIRP4 ASGNP4 ADDRFP4 16 ADDRFP4 16 INDIRP4 ASGNP4 ADDRFP4 20 ADDRFP4 20 INDIRP4 ASGNP4 ADDRFP4 24 ADDRFP4 24 INDIRP4 ASGNP4 ADDRFP4 28 ADDRFP4 28 INDIRP4 ASGNP4 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $232 ADDRLP4 12 ADDRFP4 8 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 2 EQI4 $238 ADDRGP4 $235 JUMPV LABELV $238 ADDRLP4 8 ADDRGP4 $198 ASGNP4 ADDRGP4 $233 JUMPV LABELV $235 ADDRLP4 8 ADDRGP4 $199 ASGNP4 ADDRGP4 $233 JUMPV LABELV $232 ADDRLP4 8 ADDRGP4 $117 ASGNP4 LABELV $233 ADDRFP4 16 INDIRP4 INDIRI1 CVII4 1 CNSTI4 42 NEI4 $239 ADDRLP4 4 ADDRGP4 $241 ASGNP4 ADDRFP4 16 ADDRFP4 16 INDIRP4 CNSTI4 1 ADDP4 ASGNP4 ADDRGP4 $243 JUMPV LABELV $239 ADDRLP4 4 ADDRGP4 $200 ASGNP4 ADDRGP4 $243 JUMPV LABELV $242 ADDRLP4 0 CNSTI4 0 ASGNI4 LABELV $245 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 12 INDIRI4 NEI4 $249 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $249 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 12 INDIRI4 EQI4 $249 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $251 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $250 JUMPV LABELV $249 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $252 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $250 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 20 ADDRGP4 CG_FileExists CALLI4 ASGNI4 ADDRLP4 20 INDIRI4 CNSTI4 0 EQI4 $253 CNSTI4 1 RETI4 ADDRGP4 $231 JUMPV LABELV $253 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $255 ADDRLP4 24 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 24 INDIRI4 NEI4 $258 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $258 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 24 INDIRI4 EQI4 $258 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $219 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $256 JUMPV LABELV $258 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $220 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $256 JUMPV LABELV $255 ADDRLP4 24 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 ADDRLP4 24 INDIRI4 NEI4 $260 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $260 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 ADDRLP4 24 INDIRI4 EQI4 $260 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $219 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $261 JUMPV LABELV $260 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRI4 ARGI4 ADDRGP4 $220 ARGP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 24 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 28 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $261 LABELV $256 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 24 ADDRGP4 CG_FileExists CALLI4 ASGNI4 ADDRLP4 24 INDIRI4 CNSTI4 0 EQI4 $262 CNSTI4 1 RETI4 ADDRGP4 $231 JUMPV LABELV $262 ADDRFP4 12 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $266 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $264 LABELV $266 ADDRGP4 $247 JUMPV LABELV $264 LABELV $246 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LTI4 $245 LABELV $247 ADDRLP4 4 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $267 ADDRGP4 $244 JUMPV LABELV $267 ADDRLP4 4 ADDRGP4 $241 ASGNP4 LABELV $243 ADDRGP4 $242 JUMPV LABELV $244 CNSTI4 0 RETI4 LABELV $231 endproc CG_FindClientHeadFile 32 40 proc CG_RegisterClientSkin 84 32 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRGP4 $272 ARGP4 ADDRGP4 $273 ARGP4 ADDRLP4 64 ADDRGP4 CG_FindClientModelFile CALLI4 ASGNI4 ADDRLP4 64 INDIRI4 CNSTI4 0 EQI4 $270 ADDRLP4 0 ARGP4 ADDRLP4 68 ADDRGP4 trap_R_RegisterSkin CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 ADDRLP4 68 INDIRI4 ASGNI4 LABELV $270 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 INDIRI4 CNSTI4 0 NEI4 $274 ADDRGP4 $276 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop LABELV $274 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRGP4 $279 ARGP4 ADDRGP4 $273 ARGP4 ADDRLP4 68 ADDRGP4 CG_FindClientModelFile CALLI4 ASGNI4 ADDRLP4 68 INDIRI4 CNSTI4 0 EQI4 $277 ADDRLP4 0 ARGP4 ADDRLP4 72 ADDRGP4 trap_R_RegisterSkin CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 536 ADDP4 ADDRLP4 72 INDIRI4 ASGNI4 LABELV $277 ADDRFP4 0 INDIRP4 CNSTI4 536 ADDP4 INDIRI4 CNSTI4 0 NEI4 $280 ADDRGP4 $282 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop LABELV $280 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRGP4 $285 ARGP4 ADDRGP4 $273 ARGP4 ADDRLP4 72 ADDRGP4 CG_FindClientHeadFile CALLI4 ASGNI4 ADDRLP4 72 INDIRI4 CNSTI4 0 EQI4 $283 ADDRLP4 0 ARGP4 ADDRLP4 76 ADDRGP4 trap_R_RegisterSkin CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 544 ADDP4 ADDRLP4 76 INDIRI4 ASGNI4 LABELV $283 ADDRFP4 0 INDIRP4 CNSTI4 544 ADDP4 INDIRI4 CNSTI4 0 NEI4 $286 ADDRGP4 $288 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop LABELV $286 ADDRLP4 80 CNSTI4 0 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 INDIRI4 ADDRLP4 80 INDIRI4 EQI4 $292 ADDRFP4 0 INDIRP4 CNSTI4 536 ADDP4 INDIRI4 ADDRLP4 80 INDIRI4 EQI4 $292 ADDRFP4 0 INDIRP4 CNSTI4 544 ADDP4 INDIRI4 ADDRLP4 80 INDIRI4 NEI4 $289 LABELV $292 CNSTI4 0 RETI4 ADDRGP4 $269 JUMPV LABELV $289 CNSTI4 1 RETI4 LABELV $269 endproc CG_RegisterClientSkin 84 32 proc CG_RegisterClientModelname 164 32 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRFP4 12 ADDRFP4 12 INDIRP4 ASGNP4 ADDRFP4 16 ADDRFP4 16 INDIRP4 ASGNP4 ADDRFP4 20 ADDRFP4 20 INDIRP4 ASGNP4 ADDRFP4 12 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $294 ADDRLP4 64 ADDRFP4 4 INDIRP4 ASGNP4 ADDRGP4 $295 JUMPV LABELV $294 ADDRLP4 64 ADDRFP4 12 INDIRP4 ASGNP4 LABELV $295 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $296 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRLP4 132 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 ADDRLP4 132 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 INDIRI4 CNSTI4 0 NEI4 $297 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $299 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRLP4 136 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 ADDRLP4 136 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 INDIRI4 CNSTI4 0 NEI4 $300 ADDRGP4 $302 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $300 LABELV $297 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $303 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRLP4 136 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 ADDRLP4 136 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 CNSTI4 0 NEI4 $304 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $306 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRLP4 140 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 ADDRLP4 140 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 CNSTI4 0 NEI4 $307 ADDRGP4 $302 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $307 LABELV $304 ADDRLP4 64 INDIRP4 INDIRI1 CVII4 1 CNSTI4 42 NEI4 $309 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $311 ARGP4 ADDRLP4 140 ADDRFP4 12 INDIRP4 CNSTI4 1 ADDP4 ASGNP4 ADDRLP4 140 INDIRP4 ARGP4 ADDRLP4 140 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $310 JUMPV LABELV $309 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $312 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $310 ADDRLP4 0 ARGP4 ADDRLP4 140 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 540 ADDP4 ADDRLP4 140 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 540 ADDP4 INDIRI4 CNSTI4 0 NEI4 $313 ADDRLP4 64 INDIRP4 INDIRI1 CVII4 1 CNSTI4 42 EQI4 $313 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $311 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRLP4 148 ADDRGP4 trap_R_RegisterModel CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 540 ADDP4 ADDRLP4 148 INDIRI4 ASGNI4 LABELV $313 ADDRFP4 0 INDIRP4 CNSTI4 540 ADDP4 INDIRI4 CNSTI4 0 NEI4 $315 ADDRGP4 $302 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $315 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRLP4 144 ADDRGP4 CG_RegisterClientSkin CALLI4 ASGNI4 ADDRLP4 144 INDIRI4 CNSTI4 0 NEI4 $317 ADDRFP4 20 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $319 ADDRFP4 20 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $319 ADDRGP4 $321 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRGP4 Com_Printf CALLV pop ADDRFP4 0 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 CNSTI4 2 NEI4 $322 ADDRLP4 68 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $324 ARGP4 ADDRGP4 $325 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRGP4 $323 JUMPV LABELV $322 ADDRLP4 68 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $324 ARGP4 ADDRGP4 $326 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop LABELV $323 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 68 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRLP4 152 ADDRGP4 CG_RegisterClientSkin CALLI4 ASGNI4 ADDRLP4 152 INDIRI4 CNSTI4 0 NEI4 $320 ADDRGP4 $321 ARGP4 ADDRLP4 68 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $319 ADDRGP4 $329 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $320 LABELV $317 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $330 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 148 ADDRGP4 CG_ParseAnimationFile CALLI4 ASGNI4 ADDRLP4 148 INDIRI4 CNSTI4 0 NEI4 $331 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 $333 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 Com_sprintf CALLI4 pop ADDRLP4 0 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 152 ADDRGP4 CG_ParseAnimationFile CALLI4 ASGNI4 ADDRLP4 152 INDIRI4 CNSTI4 0 NEI4 $334 ADDRGP4 $336 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 Com_Printf CALLV pop CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $334 LABELV $331 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRGP4 $339 ARGP4 ADDRGP4 $273 ARGP4 ADDRLP4 152 ADDRGP4 CG_FindClientHeadFile CALLI4 ASGNI4 ADDRLP4 152 INDIRI4 CNSTI4 0 EQI4 $337 ADDRLP4 0 ARGP4 ADDRLP4 156 ADDRGP4 trap_R_RegisterShaderNoMip CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 548 ADDP4 ADDRLP4 156 INDIRI4 ASGNI4 ADDRGP4 $338 JUMPV LABELV $337 ADDRLP4 0 ARGP4 CNSTI4 64 ARGI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 20 INDIRP4 ARGP4 ADDRLP4 64 INDIRP4 ARGP4 ADDRFP4 16 INDIRP4 ARGP4 ADDRGP4 $339 ARGP4 ADDRGP4 $342 ARGP4 ADDRLP4 156 ADDRGP4 CG_FindClientHeadFile CALLI4 ASGNI4 ADDRLP4 156 INDIRI4 CNSTI4 0 EQI4 $340 ADDRLP4 0 ARGP4 ADDRLP4 160 ADDRGP4 trap_R_RegisterShaderNoMip CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 548 ADDP4 ADDRLP4 160 INDIRI4 ASGNI4 LABELV $340 LABELV $338 ADDRFP4 0 INDIRP4 CNSTI4 548 ADDP4 INDIRI4 CNSTI4 0 NEI4 $343 CNSTI4 0 RETI4 ADDRGP4 $293 JUMPV LABELV $343 CNSTI4 1 RETI4 LABELV $293 endproc CG_RegisterClientModelname 164 32 proc CG_ColorFromString 20 4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 8 CNSTF4 0 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 8 INDIRF4 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 ADDRLP4 8 INDIRF4 ASGNF4 ADDRFP4 4 INDIRP4 ADDRLP4 8 INDIRF4 ASGNF4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 12 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0 ADDRLP4 12 INDIRI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 1 LTI4 $348 ADDRLP4 0 INDIRI4 CNSTI4 7 LEI4 $346 LABELV $348 ADDRFP4 4 INDIRP4 CNSTF4 1065353216 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 CNSTF4 1065353216 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 CNSTF4 1065353216 ASGNF4 ADDRGP4 $345 JUMPV LABELV $346 ADDRLP4 0 INDIRI4 CNSTI4 1 BANDI4 CNSTI4 0 EQI4 $349 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 CNSTF4 1065353216 ASGNF4 LABELV $349 ADDRLP4 0 INDIRI4 CNSTI4 2 BANDI4 CNSTI4 0 EQI4 $351 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 CNSTF4 1065353216 ASGNF4 LABELV $351 ADDRLP4 0 INDIRI4 CNSTI4 4 BANDI4 CNSTI4 0 EQI4 $353 ADDRFP4 4 INDIRP4 CNSTF4 1065353216 ASGNF4 LABELV $353 LABELV $345 endproc CG_ColorFromString 20 4 proc CG_LoadClientInfo 148 24 ADDRFP4 0 ADDRFP4 0 INDIRI4 ASGNI4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 20 CNSTI1 0 ASGNI1 ADDRLP4 8 CNSTI4 1 ASGNI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 168 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 232 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 296 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 360 ADDP4 ARGP4 ADDRLP4 20 ARGP4 ADDRLP4 88 ADDRGP4 CG_RegisterClientModelname CALLI4 ASGNI4 ADDRLP4 88 INDIRI4 CNSTI4 0 NEI4 $356 ADDRGP4 cg_buildScript+12 INDIRI4 CNSTI4 0 EQI4 $358 ADDRGP4 $361 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 168 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 232 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 296 ADDP4 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 360 ADDP4 ARGP4 ADDRLP4 20 ARGP4 ADDRGP4 CG_Error CALLV pop LABELV $358 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $362 ADDRFP4 4 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 CNSTI4 2 NEI4 $365 ADDRLP4 20 ARGP4 ADDRGP4 $325 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $366 JUMPV LABELV $365 ADDRLP4 20 ARGP4 ADDRGP4 $326 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop LABELV $366 ADDRFP4 4 INDIRP4 ARGP4 ADDRLP4 96 ADDRGP4 $369 ASGNP4 ADDRLP4 96 INDIRP4 ARGP4 ADDRLP4 100 ADDRFP4 4 INDIRP4 CNSTI4 232 ADDP4 ASGNP4 ADDRLP4 100 INDIRP4 ARGP4 ADDRLP4 96 INDIRP4 ARGP4 ADDRLP4 100 INDIRP4 ARGP4 ADDRLP4 20 ARGP4 ADDRLP4 104 ADDRGP4 CG_RegisterClientModelname CALLI4 ASGNI4 ADDRLP4 104 INDIRI4 CNSTI4 0 NEI4 $363 ADDRGP4 $370 ARGP4 ADDRGP4 $369 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 232 ADDP4 ARGP4 ADDRGP4 CG_Error CALLV pop ADDRGP4 $363 JUMPV LABELV $362 ADDRFP4 4 INDIRP4 ARGP4 ADDRLP4 92 ADDRGP4 $369 ASGNP4 ADDRLP4 92 INDIRP4 ARGP4 ADDRLP4 96 ADDRGP4 $117 ASGNP4 ADDRLP4 96 INDIRP4 ARGP4 ADDRLP4 92 INDIRP4 ARGP4 ADDRLP4 96 INDIRP4 ARGP4 ADDRLP4 20 ARGP4 ADDRLP4 100 ADDRGP4 CG_RegisterClientModelname CALLI4 ASGNI4 ADDRLP4 100 INDIRI4 CNSTI4 0 NEI4 $371 ADDRGP4 $373 ARGP4 ADDRGP4 $369 ARGP4 ADDRGP4 CG_Error CALLV pop LABELV $371 LABELV $363 ADDRLP4 8 CNSTI4 0 ASGNI4 LABELV $356 ADDRFP4 4 INDIRP4 CNSTI4 492 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 CNSTI4 0 EQI4 $374 ADDRLP4 92 ARGP4 ADDRFP4 4 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 ARGI4 ADDRLP4 140 CNSTI4 0 ASGNI4 ADDRLP4 140 INDIRI4 ARGI4 ADDRLP4 140 INDIRI4 ARGI4 CNSTF4 1065353216 ARGF4 ADDRGP4 $378 ARGP4 ADDRLP4 144 ADDRGP4 trap_R_LerpTag CALLI4 ASGNI4 ADDRLP4 144 INDIRI4 CNSTI4 0 EQI4 $376 ADDRFP4 4 INDIRP4 CNSTI4 492 ADDP4 CNSTI4 1 ASGNI4 LABELV $376 LABELV $374 ADDRLP4 12 ADDRFP4 4 INDIRP4 CNSTI4 168 ADDP4 ASGNP4 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $381 ADDRLP4 92 ADDRGP4 $369 ASGNP4 ADDRGP4 $382 JUMPV LABELV $381 ADDRLP4 92 ADDRGP4 $369 ASGNP4 LABELV $382 ADDRLP4 16 ADDRLP4 92 INDIRP4 ASGNP4 ADDRLP4 0 CNSTI4 0 ASGNI4 LABELV $383 ADDRLP4 4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 cg_customSoundNames ADDP4 INDIRP4 ASGNP4 ADDRLP4 4 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $387 ADDRGP4 $385 JUMPV LABELV $387 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 4 INDIRP4 CNSTI4 1588 ADDP4 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 8 INDIRI4 CNSTI4 0 EQI4 $389 ADDRGP4 $391 ARGP4 ADDRLP4 12 INDIRP4 ARGP4 ADDRLP4 4 INDIRP4 CNSTI4 1 ADDP4 ARGP4 ADDRLP4 96 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 96 INDIRP4 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 100 ADDRGP4 trap_S_RegisterSound CALLI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 4 INDIRP4 CNSTI4 1588 ADDP4 ADDP4 ADDRLP4 100 INDIRI4 ASGNI4 LABELV $389 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 4 INDIRP4 CNSTI4 1588 ADDP4 ADDP4 INDIRI4 CNSTI4 0 NEI4 $392 ADDRGP4 $391 ARGP4 ADDRLP4 16 INDIRP4 ARGP4 ADDRLP4 4 INDIRP4 CNSTI4 1 ADDP4 ARGP4 ADDRLP4 96 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 96 INDIRP4 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 100 ADDRGP4 trap_S_RegisterSound CALLI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 4 INDIRP4 CNSTI4 1588 ADDP4 ADDP4 ADDRLP4 100 INDIRI4 ASGNI4 LABELV $392 LABELV $384 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 32 LTI4 $383 LABELV $385 ADDRFP4 4 INDIRP4 CNSTI4 488 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 0 CNSTI4 0 ASGNI4 LABELV $394 ADDRLP4 96 CNSTI4 716 ADDRLP4 0 INDIRI4 MULI4 ASGNI4 ADDRLP4 96 INDIRI4 ADDRGP4 cg_entities+168 ADDP4 INDIRI4 ADDRFP4 0 INDIRI4 NEI4 $398 ADDRLP4 96 INDIRI4 ADDRGP4 cg_entities+4 ADDP4 INDIRI4 CNSTI4 1 NEI4 $398 CNSTI4 716 ADDRLP4 0 INDIRI4 MULI4 ADDRGP4 cg_entities ADDP4 ARGP4 ADDRGP4 CG_ResetPlayerEntity CALLV pop LABELV $398 LABELV $395 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 1024 LTI4 $394 LABELV $355 endproc CG_LoadClientInfo 148 24 proc CG_CopyClientInfoModel 52 12 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 0 CNSTI4 504 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 0 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 0 INDIRI4 ADDP4 INDIRB ASGNB 12 ADDRLP4 4 CNSTI4 516 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 4 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 4 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 8 CNSTI4 520 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 8 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 8 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 12 CNSTI4 524 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 12 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 12 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 16 CNSTI4 528 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 20 CNSTI4 532 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 20 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 20 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 24 CNSTI4 536 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 28 CNSTI4 540 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 32 CNSTI4 544 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 36 CNSTI4 548 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 36 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 36 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 40 CNSTI4 492 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 40 INDIRI4 ADDP4 ADDRFP4 0 INDIRP4 ADDRLP4 40 INDIRI4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 44 CNSTI4 552 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 44 INDIRI4 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 ADDRLP4 44 INDIRI4 ADDP4 ARGP4 CNSTU4 1036 ARGU4 ADDRGP4 qk_memcpy CALLP4 pop ADDRLP4 48 CNSTI4 1588 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 48 INDIRI4 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 ADDRLP4 48 INDIRI4 ADDP4 ARGP4 CNSTU4 128 ARGU4 ADDRGP4 qk_memcpy CALLP4 pop LABELV $402 endproc CG_CopyClientInfoModel 52 12 proc CG_ScanForExistingClientInfo 60 8 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRGP4 $407 JUMPV LABELV $404 ADDRLP4 0 CNSTI4 1716 ADDRLP4 4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI4 CNSTI4 0 NEI4 $410 ADDRGP4 $405 JUMPV LABELV $410 ADDRLP4 0 INDIRP4 CNSTI4 488 ADDP4 INDIRI4 CNSTI4 0 EQI4 $412 ADDRGP4 $405 JUMPV LABELV $412 ADDRLP4 8 CNSTI4 168 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 8 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 8 INDIRI4 ADDP4 ARGP4 ADDRLP4 12 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 0 NEI4 $414 ADDRLP4 16 CNSTI4 232 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 20 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20 INDIRI4 CNSTI4 0 NEI4 $414 ADDRLP4 24 CNSTI4 296 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 ARGP4 ADDRLP4 28 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 28 INDIRI4 CNSTI4 0 NEI4 $414 ADDRLP4 32 CNSTI4 360 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 ARGP4 ADDRLP4 36 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 36 INDIRI4 CNSTI4 0 NEI4 $414 ADDRLP4 40 CNSTI4 456 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 40 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 40 INDIRI4 ADDP4 ARGP4 ADDRLP4 44 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 44 INDIRI4 CNSTI4 0 NEI4 $414 ADDRLP4 48 CNSTI4 424 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 48 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 48 INDIRI4 ADDP4 ARGP4 ADDRLP4 52 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 52 INDIRI4 CNSTI4 0 NEI4 $414 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $417 ADDRLP4 56 CNSTI4 68 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 56 INDIRI4 ADDP4 INDIRI4 ADDRLP4 0 INDIRP4 ADDRLP4 56 INDIRI4 ADDP4 INDIRI4 NEI4 $414 LABELV $417 ADDRFP4 0 INDIRP4 CNSTI4 488 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_CopyClientInfoModel CALLV pop CNSTI4 1 RETI4 ADDRGP4 $403 JUMPV LABELV $414 LABELV $405 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $407 ADDRLP4 4 INDIRI4 ADDRGP4 cgs+31480 INDIRI4 LTI4 $404 CNSTI4 0 RETI4 LABELV $403 endproc CG_ScanForExistingClientInfo 60 8 proc CG_SetDeferredClientInfo 36 8 ADDRFP4 0 ADDRFP4 0 INDIRI4 ASGNI4 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRGP4 $422 JUMPV LABELV $419 ADDRLP4 0 CNSTI4 1716 ADDRLP4 4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $427 ADDRLP4 0 INDIRP4 CNSTI4 488 ADDP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $425 LABELV $427 ADDRGP4 $420 JUMPV LABELV $425 ADDRLP4 16 CNSTI4 232 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 20 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20 INDIRI4 CNSTI4 0 NEI4 $432 ADDRLP4 24 CNSTI4 168 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 ARGP4 ADDRLP4 28 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 28 INDIRI4 CNSTI4 0 NEI4 $432 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $428 ADDRLP4 32 CNSTI4 68 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 INDIRI4 ADDRLP4 0 INDIRP4 ADDRLP4 32 INDIRI4 ADDP4 INDIRI4 EQI4 $428 LABELV $432 ADDRGP4 $420 JUMPV LABELV $428 ADDRFP4 0 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_LoadClientInfo CALLV pop ADDRGP4 $418 JUMPV LABELV $420 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $422 ADDRLP4 4 INDIRI4 ADDRGP4 cgs+31480 INDIRI4 LTI4 $419 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $433 ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRGP4 $439 JUMPV LABELV $436 ADDRLP4 0 CNSTI4 1716 ADDRLP4 4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $444 ADDRLP4 0 INDIRP4 CNSTI4 488 ADDP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $442 LABELV $444 ADDRGP4 $437 JUMPV LABELV $442 ADDRLP4 16 CNSTI4 232 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 0 INDIRP4 ADDRLP4 16 INDIRI4 ADDP4 ARGP4 ADDRLP4 20 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 20 INDIRI4 CNSTI4 0 NEI4 $448 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $445 ADDRLP4 24 CNSTI4 68 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 INDIRI4 ADDRLP4 0 INDIRP4 ADDRLP4 24 INDIRI4 ADDP4 INDIRI4 EQI4 $445 LABELV $448 ADDRGP4 $437 JUMPV LABELV $445 ADDRFP4 4 INDIRP4 CNSTI4 488 ADDP4 CNSTI4 1 ASGNI4 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_CopyClientInfoModel CALLV pop ADDRGP4 $418 JUMPV LABELV $437 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $439 ADDRLP4 4 INDIRI4 ADDRGP4 cgs+31480 INDIRI4 LTI4 $436 ADDRFP4 0 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_LoadClientInfo CALLV pop ADDRGP4 $418 JUMPV LABELV $433 ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRGP4 $452 JUMPV LABELV $449 ADDRLP4 0 CNSTI4 1716 ADDRLP4 4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI4 CNSTI4 0 NEI4 $455 ADDRGP4 $450 JUMPV LABELV $455 ADDRFP4 4 INDIRP4 CNSTI4 488 ADDP4 CNSTI4 1 ASGNI4 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_CopyClientInfoModel CALLV pop ADDRGP4 $418 JUMPV LABELV $450 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $452 ADDRLP4 4 INDIRI4 ADDRGP4 cgs+31480 INDIRI4 LTI4 $449 ADDRGP4 $457 ARGP4 ADDRGP4 CG_Printf CALLV pop ADDRFP4 0 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_LoadClientInfo CALLV pop LABELV $418 endproc CG_SetDeferredClientInfo 36 8 export CG_NewClientInfo proc CG_NewClientInfo 1972 12 ADDRLP4 1732 ADDRFP4 0 INDIRI4 ASGNI4 ADDRLP4 1728 CNSTI4 1716 ADDRLP4 1732 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 1732 INDIRI4 CNSTI4 544 ADDI4 ARGI4 ADDRLP4 1736 ADDRGP4 CG_ConfigString CALLP4 ASGNP4 ADDRLP4 1720 ADDRLP4 1736 INDIRP4 ASGNP4 ADDRLP4 1720 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $460 ADDRLP4 1728 INDIRP4 ARGP4 CNSTI4 0 ARGI4 CNSTU4 1716 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRGP4 $458 JUMPV LABELV $460 ADDRLP4 0 ARGP4 CNSTI4 0 ARGI4 CNSTU4 1716 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $462 ARGP4 ADDRLP4 1740 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1740 INDIRP4 ASGNP4 ADDRLP4 0+4 ARGP4 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $465 ARGP4 ADDRLP4 1744 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1744 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 0+76 ARGP4 ADDRGP4 CG_ColorFromString CALLV pop ADDRLP4 1752 CNSTF4 1132396544 ADDRLP4 0+76 INDIRF4 MULF4 ASGNF4 ADDRLP4 1756 CNSTF4 1325400064 ASGNF4 ADDRLP4 1752 INDIRF4 ADDRLP4 1756 INDIRF4 LTF4 $470 ADDRLP4 1748 ADDRLP4 1752 INDIRF4 ADDRLP4 1756 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $471 JUMPV LABELV $470 ADDRLP4 1748 ADDRLP4 1752 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $471 ADDRLP4 0+100 ADDRLP4 1748 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 1764 CNSTF4 1132396544 ADDRLP4 0+76+4 INDIRF4 MULF4 ASGNF4 ADDRLP4 1768 CNSTF4 1325400064 ASGNF4 ADDRLP4 1764 INDIRF4 ADDRLP4 1768 INDIRF4 LTF4 $477 ADDRLP4 1760 ADDRLP4 1764 INDIRF4 ADDRLP4 1768 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $478 JUMPV LABELV $477 ADDRLP4 1760 ADDRLP4 1764 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $478 ADDRLP4 0+100+1 ADDRLP4 1760 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 1776 CNSTF4 1132396544 ADDRLP4 0+76+8 INDIRF4 MULF4 ASGNF4 ADDRLP4 1780 CNSTF4 1325400064 ASGNF4 ADDRLP4 1776 INDIRF4 ADDRLP4 1780 INDIRF4 LTF4 $484 ADDRLP4 1772 ADDRLP4 1776 INDIRF4 ADDRLP4 1780 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $485 JUMPV LABELV $484 ADDRLP4 1772 ADDRLP4 1776 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $485 ADDRLP4 0+100+2 ADDRLP4 1772 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 0+100+3 CNSTU1 255 ASGNU1 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $488 ARGP4 ADDRLP4 1784 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1784 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 0+88 ARGP4 ADDRGP4 CG_ColorFromString CALLV pop ADDRLP4 1792 CNSTF4 1132396544 ADDRLP4 0+88 INDIRF4 MULF4 ASGNF4 ADDRLP4 1796 CNSTF4 1325400064 ASGNF4 ADDRLP4 1792 INDIRF4 ADDRLP4 1796 INDIRF4 LTF4 $493 ADDRLP4 1788 ADDRLP4 1792 INDIRF4 ADDRLP4 1796 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $494 JUMPV LABELV $493 ADDRLP4 1788 ADDRLP4 1792 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $494 ADDRLP4 0+104 ADDRLP4 1788 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 1804 CNSTF4 1132396544 ADDRLP4 0+88+4 INDIRF4 MULF4 ASGNF4 ADDRLP4 1808 CNSTF4 1325400064 ASGNF4 ADDRLP4 1804 INDIRF4 ADDRLP4 1808 INDIRF4 LTF4 $500 ADDRLP4 1800 ADDRLP4 1804 INDIRF4 ADDRLP4 1808 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $501 JUMPV LABELV $500 ADDRLP4 1800 ADDRLP4 1804 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $501 ADDRLP4 0+104+1 ADDRLP4 1800 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 1816 CNSTF4 1132396544 ADDRLP4 0+88+8 INDIRF4 MULF4 ASGNF4 ADDRLP4 1820 CNSTF4 1325400064 ASGNF4 ADDRLP4 1816 INDIRF4 ADDRLP4 1820 INDIRF4 LTF4 $507 ADDRLP4 1812 ADDRLP4 1816 INDIRF4 ADDRLP4 1820 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $508 JUMPV LABELV $507 ADDRLP4 1812 ADDRLP4 1816 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $508 ADDRLP4 0+104+2 ADDRLP4 1812 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 0+104+3 CNSTU1 255 ASGNU1 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $511 ARGP4 ADDRLP4 1824 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1824 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1828 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+72 ADDRLP4 1828 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $513 ARGP4 ADDRLP4 1832 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1832 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1836 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+128 ADDRLP4 1836 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $515 ARGP4 ADDRLP4 1840 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1840 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1844 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+132 ADDRLP4 1844 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $517 ARGP4 ADDRLP4 1848 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1848 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1852 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+136 ADDRLP4 1852 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $519 ARGP4 ADDRLP4 1856 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1856 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1860 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+68 ADDRLP4 1860 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $521 ARGP4 ADDRLP4 1864 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1864 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1868 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+140 ADDRLP4 1868 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $523 ARGP4 ADDRLP4 1872 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1872 INDIRP4 ASGNP4 ADDRLP4 1716 INDIRP4 ARGP4 ADDRLP4 1876 ADDRGP4 qk_atoi CALLI4 ASGNI4 ADDRLP4 0+144 ADDRLP4 1876 INDIRI4 ASGNI4 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $525 ARGP4 ADDRLP4 1880 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1880 INDIRP4 ASGNP4 ADDRLP4 0+424 ARGP4 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 32 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $527 ARGP4 ADDRLP4 1884 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1884 INDIRP4 ASGNP4 ADDRLP4 0+456 ARGP4 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 32 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $529 ARGP4 ADDRLP4 1888 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1888 INDIRP4 ASGNP4 ADDRGP4 cg_forceModel+12 INDIRI4 CNSTI4 0 EQI4 $530 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $533 ADDRLP4 0+168 ARGP4 ADDRGP4 $369 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+232 ARGP4 ADDRGP4 $117 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $534 JUMPV LABELV $533 ADDRGP4 $529 ARGP4 ADDRLP4 1892 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 trap_Cvar_VariableStringBuffer CALLV pop ADDRLP4 1892 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1960 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1956 ADDRLP4 1960 INDIRP4 ASGNP4 ADDRLP4 1960 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $540 ADDRLP4 1956 ADDRGP4 $117 ASGNP4 ADDRGP4 $541 JUMPV LABELV $540 ADDRLP4 1964 ADDRLP4 1956 INDIRP4 ASGNP4 ADDRLP4 1956 ADDRLP4 1964 INDIRP4 CNSTI4 1 ADDP4 ASGNP4 ADDRLP4 1964 INDIRP4 CNSTI1 0 ASGNI1 LABELV $541 ADDRLP4 0+232 ARGP4 ADDRLP4 1956 INDIRP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+168 ARGP4 ADDRLP4 1892 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop LABELV $534 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $531 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1960 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1724 ADDRLP4 1960 INDIRP4 ASGNP4 ADDRLP4 1724 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $531 ADDRLP4 0+232 ARGP4 ADDRLP4 1724 INDIRP4 CNSTI4 1 ADDP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $531 JUMPV LABELV $530 ADDRLP4 0+168 ARGP4 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+168 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1892 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1724 ADDRLP4 1892 INDIRP4 ASGNP4 ADDRLP4 1724 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $556 ADDRLP4 0+232 ARGP4 ADDRGP4 $117 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $557 JUMPV LABELV $556 ADDRLP4 0+232 ARGP4 ADDRLP4 1724 INDIRP4 CNSTI4 1 ADDP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 1724 INDIRP4 CNSTI1 0 ASGNI1 LABELV $557 LABELV $531 ADDRLP4 1720 INDIRP4 ARGP4 ADDRGP4 $562 ARGP4 ADDRLP4 1892 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1716 ADDRLP4 1892 INDIRP4 ASGNP4 ADDRGP4 cg_forceModel+12 INDIRI4 CNSTI4 0 EQI4 $563 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $566 ADDRLP4 0+296 ARGP4 ADDRGP4 $369 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+360 ARGP4 ADDRGP4 $117 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $567 JUMPV LABELV $566 ADDRGP4 $573 ARGP4 ADDRLP4 1896 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 trap_Cvar_VariableStringBuffer CALLV pop ADDRLP4 1896 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1964 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1960 ADDRLP4 1964 INDIRP4 ASGNP4 ADDRLP4 1964 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $574 ADDRLP4 1960 ADDRGP4 $117 ASGNP4 ADDRGP4 $575 JUMPV LABELV $574 ADDRLP4 1968 ADDRLP4 1960 INDIRP4 ASGNP4 ADDRLP4 1960 ADDRLP4 1968 INDIRP4 CNSTI4 1 ADDP4 ASGNP4 ADDRLP4 1968 INDIRP4 CNSTI1 0 ASGNI1 LABELV $575 ADDRLP4 0+360 ARGP4 ADDRLP4 1960 INDIRP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+296 ARGP4 ADDRLP4 1896 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop LABELV $567 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $564 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1964 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1724 ADDRLP4 1964 INDIRP4 ASGNP4 ADDRLP4 1724 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $564 ADDRLP4 0+360 ARGP4 ADDRLP4 1724 INDIRP4 CNSTI4 1 ADDP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $564 JUMPV LABELV $563 ADDRLP4 0+296 ARGP4 ADDRLP4 1716 INDIRP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 0+296 ARGP4 CNSTI4 47 ARGI4 ADDRLP4 1896 ADDRGP4 qk_strchr CALLP4 ASGNP4 ADDRLP4 1724 ADDRLP4 1896 INDIRP4 ASGNP4 ADDRLP4 1724 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $590 ADDRLP4 0+360 ARGP4 ADDRGP4 $117 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRGP4 $591 JUMPV LABELV $590 ADDRLP4 0+360 ARGP4 ADDRLP4 1724 INDIRP4 CNSTI4 1 ADDP4 ARGP4 CNSTI4 64 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRLP4 1724 INDIRP4 CNSTI1 0 ASGNI1 LABELV $591 LABELV $564 ADDRLP4 0 ARGP4 ADDRLP4 1896 ADDRGP4 CG_ScanForExistingClientInfo CALLI4 ASGNI4 ADDRLP4 1896 INDIRI4 CNSTI4 0 NEI4 $596 ADDRLP4 1908 ADDRGP4 trap_MemoryRemaining CALLI4 ASGNI4 ADDRLP4 1908 INDIRI4 CNSTI4 4000000 GEI4 $599 ADDRLP4 1904 CNSTI4 1 ASGNI4 ADDRGP4 $600 JUMPV LABELV $599 ADDRLP4 1904 CNSTI4 0 ASGNI4 LABELV $600 ADDRLP4 1900 ADDRLP4 1904 INDIRI4 ASGNI4 ADDRLP4 1912 CNSTI4 0 ASGNI4 ADDRLP4 1900 INDIRI4 ADDRLP4 1912 INDIRI4 NEI4 $606 ADDRGP4 cg_deferPlayers+12 INDIRI4 ADDRLP4 1912 INDIRI4 EQI4 $601 ADDRGP4 cg_buildScript+12 INDIRI4 ADDRLP4 1912 INDIRI4 NEI4 $601 ADDRGP4 cg+20 INDIRI4 ADDRLP4 1912 INDIRI4 NEI4 $601 LABELV $606 ADDRFP4 0 INDIRI4 ARGI4 ADDRLP4 0 ARGP4 ADDRGP4 CG_SetDeferredClientInfo CALLV pop ADDRLP4 1900 INDIRI4 CNSTI4 0 EQI4 $602 ADDRGP4 $609 ARGP4 ADDRGP4 CG_Printf CALLV pop ADDRLP4 0+488 CNSTI4 0 ASGNI4 ADDRGP4 $602 JUMPV LABELV $601 ADDRFP4 0 INDIRI4 ARGI4 ADDRLP4 0 ARGP4 ADDRGP4 CG_LoadClientInfo CALLV pop LABELV $602 LABELV $596 ADDRLP4 0 CNSTI4 1 ASGNI4 ADDRLP4 1728 INDIRP4 ADDRLP4 0 INDIRB ASGNB 1716 LABELV $458 endproc CG_NewClientInfo 1972 12 export CG_LoadDeferredPlayers proc CG_LoadDeferredPlayers 20 8 ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRLP4 0 ADDRGP4 cgs+40972 ASGNP4 ADDRGP4 $615 JUMPV LABELV $612 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $618 ADDRLP4 0 INDIRP4 CNSTI4 488 ADDP4 INDIRI4 ADDRLP4 12 INDIRI4 EQI4 $618 ADDRLP4 16 ADDRGP4 trap_MemoryRemaining CALLI4 ASGNI4 ADDRLP4 16 INDIRI4 CNSTI4 4000000 GEI4 $620 ADDRGP4 $609 ARGP4 ADDRGP4 CG_Printf CALLV pop ADDRLP4 0 INDIRP4 CNSTI4 488 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 $613 JUMPV LABELV $620 ADDRLP4 4 INDIRI4 ARGI4 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 CG_LoadClientInfo CALLV pop LABELV $618 LABELV $613 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRLP4 0 ADDRLP4 0 INDIRP4 CNSTI4 1716 ADDP4 ASGNP4 LABELV $615 ADDRLP4 4 INDIRI4 ADDRGP4 cgs+31480 INDIRI4 LTI4 $612 LABELV $611 endproc CG_LoadDeferredPlayers 20 8 proc CG_SetLerpFrameAnimation 12 8 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRFP4 8 ADDRFP4 8 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 36 ADDP4 ADDRFP4 8 INDIRI4 ASGNI4 ADDRFP4 8 ADDRFP4 8 INDIRI4 CNSTI4 -129 BANDI4 ASGNI4 ADDRFP4 8 INDIRI4 CNSTI4 0 LTI4 $625 ADDRFP4 8 INDIRI4 CNSTI4 37 LTI4 $623 LABELV $625 ADDRGP4 $626 ARGP4 ADDRFP4 8 INDIRI4 ARGI4 ADDRGP4 CG_Error CALLV pop LABELV $623 ADDRLP4 0 CNSTI4 28 ADDRFP4 8 INDIRI4 MULI4 ADDRFP4 0 INDIRP4 CNSTI4 552 ADDP4 ADDP4 ASGNP4 ADDRFP4 4 INDIRP4 CNSTI4 40 ADDP4 ADDRLP4 0 INDIRP4 ASGNP4 ADDRFP4 4 INDIRP4 CNSTI4 44 ADDP4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 ADDRLP4 0 INDIRP4 CNSTI4 16 ADDP4 INDIRI4 ADDI4 ASGNI4 ADDRGP4 cg_debugAnim+12 INDIRI4 CNSTI4 0 EQI4 $627 ADDRGP4 $630 ARGP4 ADDRFP4 8 INDIRI4 ARGI4 ADDRGP4 CG_Printf CALLV pop LABELV $627 LABELV $622 endproc CG_SetLerpFrameAnimation 12 8 proc CG_RunLerpFrame 48 12 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRGP4 cg_animSpeed+12 INDIRI4 CNSTI4 0 NEI4 $632 ADDRLP4 16 CNSTF4 0 ASGNF4 ADDRFP4 4 INDIRP4 CNSTI4 16 ADDP4 ADDRLP4 16 INDIRF4 ASGNF4 ADDRLP4 20 ADDRLP4 16 INDIRF4 CVFI4 4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 20 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 20 INDIRI4 ASGNI4 ADDRGP4 $631 JUMPV LABELV $632 ADDRFP4 8 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 36 ADDP4 INDIRI4 NEI4 $637 ADDRFP4 4 INDIRP4 CNSTI4 40 ADDP4 INDIRP4 CVPU4 4 CNSTU4 0 NEU4 $635 LABELV $637 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRI4 ARGI4 ADDRGP4 CG_SetLerpFrameAnimation CALLV pop LABELV $635 ADDRGP4 cg+107604 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 LTI4 $638 ADDRFP4 4 INDIRP4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0 ADDRFP4 4 INDIRP4 CNSTI4 40 ADDP4 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 CNSTI4 0 NEI4 $641 ADDRGP4 $631 JUMPV LABELV $641 ADDRGP4 cg+107604 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 44 ADDP4 INDIRI4 GEI4 $643 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 ADDRFP4 4 INDIRP4 CNSTI4 44 ADDP4 INDIRI4 ASGNI4 ADDRGP4 $644 JUMPV LABELV $643 ADDRLP4 28 CNSTI4 12 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ADDRLP4 0 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 INDIRI4 ADDI4 ASGNI4 LABELV $644 ADDRLP4 28 CNSTI4 12 ASGNI4 ADDRLP4 4 ADDRFP4 4 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 44 ADDP4 INDIRI4 SUBI4 ADDRLP4 0 INDIRP4 ADDRLP4 28 INDIRI4 ADDP4 INDIRI4 DIVI4 ASGNI4 ADDRLP4 4 ADDRLP4 4 INDIRI4 CVIF4 4 ADDRFP4 12 INDIRF4 MULF4 CVFI4 4 ASGNI4 ADDRLP4 8 ADDRLP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0 INDIRP4 CNSTI4 24 ADDP4 INDIRI4 CNSTI4 0 EQI4 $646 ADDRLP4 8 ADDRLP4 8 INDIRI4 CNSTI4 1 LSHI4 ASGNI4 LABELV $646 ADDRLP4 4 INDIRI4 ADDRLP4 8 INDIRI4 LTI4 $648 ADDRLP4 4 ADDRLP4 4 INDIRI4 ADDRLP4 8 INDIRI4 SUBI4 ASGNI4 ADDRLP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 0 EQI4 $650 ADDRLP4 40 ADDRLP4 0 INDIRP4 CNSTI4 8 ADDP4 ASGNP4 ADDRLP4 4 ADDRLP4 4 INDIRI4 ADDRLP4 40 INDIRP4 INDIRI4 MODI4 ASGNI4 ADDRLP4 4 ADDRLP4 4 INDIRI4 ADDRLP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ADDRLP4 40 INDIRP4 INDIRI4 SUBI4 ADDI4 ASGNI4 ADDRGP4 $651 JUMPV LABELV $650 ADDRLP4 4 ADDRLP4 8 INDIRI4 CNSTI4 1 SUBI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 LABELV $651 LABELV $648 ADDRLP4 0 INDIRP4 CNSTI4 20 ADDP4 INDIRI4 CNSTI4 0 EQI4 $653 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ADDI4 CNSTI4 1 SUBI4 ADDRLP4 4 INDIRI4 SUBI4 ASGNI4 ADDRGP4 $654 JUMPV LABELV $653 ADDRLP4 0 INDIRP4 CNSTI4 24 ADDP4 INDIRI4 CNSTI4 0 EQI4 $655 ADDRLP4 4 INDIRI4 ADDRLP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 LTI4 $655 ADDRLP4 44 ADDRLP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 44 INDIRI4 ADDI4 CNSTI4 1 SUBI4 ADDRLP4 4 INDIRI4 ADDRLP4 44 INDIRI4 MODI4 SUBI4 ASGNI4 ADDRGP4 $656 JUMPV LABELV $655 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 0 INDIRP4 INDIRI4 ADDRLP4 4 INDIRI4 ADDI4 ASGNI4 LABELV $656 LABELV $654 ADDRGP4 cg+107604 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 LEI4 $657 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 ADDRGP4 cg_debugAnim+12 INDIRI4 CNSTI4 0 EQI4 $661 ADDRGP4 $664 ARGP4 ADDRGP4 CG_Printf CALLV pop LABELV $661 LABELV $657 LABELV $638 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 ADDRGP4 cg+107604 INDIRI4 CNSTI4 200 ADDI4 LEI4 $665 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 LABELV $665 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ADDRGP4 cg+107604 INDIRI4 LEI4 $669 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 LABELV $669 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 NEI4 $673 ADDRFP4 4 INDIRP4 CNSTI4 16 ADDP4 CNSTF4 0 ASGNF4 ADDRGP4 $674 JUMPV LABELV $673 ADDRLP4 24 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 16 ADDP4 CNSTF4 1065353216 ADDRGP4 cg+107604 INDIRI4 ADDRLP4 24 INDIRI4 SUBI4 CVIF4 4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 INDIRI4 ADDRLP4 24 INDIRI4 SUBI4 CVIF4 4 DIVF4 SUBF4 ASGNF4 LABELV $674 LABELV $631 endproc CG_RunLerpFrame 48 12 proc CG_ClearLerpFrame 16 12 ADDRFP4 4 ADDRFP4 4 INDIRP4 ASGNP4 ADDRLP4 4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 4 ADDP4 ADDRLP4 4 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 12 ADDP4 ADDRLP4 4 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRFP4 8 INDIRI4 ARGI4 ADDRGP4 CG_SetLerpFrameAnimation CALLV pop ADDRLP4 12 ADDRFP4 4 INDIRP4 CNSTI4 40 ADDP4 INDIRP4 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ADDRLP4 12 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 12 INDIRI4 ASGNI4 LABELV $676 endproc CG_ClearLerpFrame 16 12 proc CG_PlayerAnimation 20 16 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 8 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 ASGNI4 ADDRGP4 cg_noPlayerAnims+12 INDIRI4 CNSTI4 0 EQI4 $679 ADDRLP4 12 CNSTI4 0 ASGNI4 ADDRFP4 20 INDIRP4 ADDRLP4 12 INDIRI4 ASGNI4 ADDRFP4 16 INDIRP4 ADDRLP4 12 INDIRI4 ASGNI4 ADDRFP4 8 INDIRP4 ADDRLP4 12 INDIRI4 ASGNI4 ADDRFP4 4 INDIRP4 ADDRLP4 12 INDIRI4 ASGNI4 ADDRGP4 $678 JUMPV LABELV $679 ADDRFP4 0 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 8 BANDI4 CNSTI4 0 EQI4 $682 ADDRLP4 4 CNSTF4 1069547520 ASGNF4 ADDRGP4 $683 JUMPV LABELV $682 ADDRLP4 4 CNSTF4 1065353216 ASGNF4 LABELV $683 ADDRLP4 0 CNSTI4 1716 ADDRLP4 8 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRFP4 0 INDIRP4 CNSTI4 476 ADDP4 INDIRI4 CNSTI4 0 EQI4 $685 ADDRFP4 0 INDIRP4 CNSTI4 196 ADDP4 INDIRI4 CNSTI4 -129 BANDI4 CNSTI4 22 NEI4 $685 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 452 ADDP4 ARGP4 CNSTI4 24 ARGI4 ADDRLP4 4 INDIRF4 ARGF4 ADDRGP4 CG_RunLerpFrame CALLV pop ADDRGP4 $686 JUMPV LABELV $685 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 452 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 196 ADDP4 INDIRI4 ARGI4 ADDRLP4 4 INDIRF4 ARGF4 ADDRGP4 CG_RunLerpFrame CALLV pop LABELV $686 ADDRFP4 4 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 452 ADDP4 INDIRI4 ASGNI4 ADDRFP4 8 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 460 ADDP4 INDIRI4 ASGNI4 ADDRFP4 12 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 468 ADDP4 INDIRF4 ASGNF4 ADDRLP4 0 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 500 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 200 ADDP4 INDIRI4 ARGI4 ADDRLP4 4 INDIRF4 ARGF4 ADDRGP4 CG_RunLerpFrame CALLV pop ADDRFP4 16 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 500 ADDP4 INDIRI4 ASGNI4 ADDRFP4 20 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 508 ADDP4 INDIRI4 ASGNI4 ADDRFP4 24 INDIRP4 ADDRFP4 0 INDIRP4 CNSTI4 516 ADDP4 INDIRF4 ASGNF4 LABELV $678 endproc CG_PlayerAnimation 20 16 proc CG_SwingAngles 28 8 ADDRFP4 0 ADDRFP4 0 INDIRF4 ASGNF4 ADDRFP4 16 ADDRFP4 16 INDIRP4 ASGNP4 ADDRFP4 20 INDIRP4 INDIRI4 CNSTI4 0 NEI4 $688 ADDRFP4 16 INDIRP4 INDIRF4 ARGF4 ADDRFP4 0 INDIRF4 ARGF4 ADDRLP4 12 ADDRGP4 AngleSubtract CALLF4 ASGNF4 ADDRLP4 0 ADDRLP4 12 INDIRF4 ASGNF4 ADDRLP4 20 ADDRFP4 4 INDIRF4 ASGNF4 ADDRLP4 0 INDIRF4 ADDRLP4 20 INDIRF4 GTF4 $692 ADDRLP4 0 INDIRF4 ADDRLP4 20 INDIRF4 NEGF4 GEF4 $690 LABELV $692 ADDRFP4 20 INDIRP4 CNSTI4 1 ASGNI4 LABELV $690 LABELV $688 ADDRFP4 20 INDIRP4 INDIRI4 CNSTI4 0 NEI4 $693 ADDRGP4 $687 JUMPV LABELV $693 ADDRFP4 0 INDIRF4 ARGF4 ADDRFP4 16 INDIRP4 INDIRF4 ARGF4 ADDRLP4 12 ADDRGP4 AngleSubtract CALLF4 ASGNF4 ADDRLP4 0 ADDRLP4 12 INDIRF4 ASGNF4 ADDRLP4 0 INDIRF4 ARGF4 ADDRLP4 16 ADDRGP4 qk_fabs CALLF4 ASGNF4 ADDRLP4 4 ADDRLP4 16 INDIRF4 ASGNF4 ADDRLP4 4 INDIRF4 CNSTF4 1056964608 ADDRFP4 4 INDIRF4 MULF4 GEF4 $695 ADDRLP4 4 CNSTF4 1056964608 ASGNF4 ADDRGP4 $696 JUMPV LABELV $695 ADDRLP4 4 INDIRF4 ADDRFP4 4 INDIRF4 GEF4 $697 ADDRLP4 4 CNSTF4 1065353216 ASGNF4 ADDRGP4 $698 JUMPV LABELV $697 ADDRLP4 4 CNSTF4 1073741824 ASGNF4 LABELV $698 LABELV $696 ADDRLP4 0 INDIRF4 CNSTF4 0 LTF4 $699 ADDRLP4 8 ADDRGP4 cg+107600 INDIRI4 CVIF4 4 ADDRLP4 4 INDIRF4 MULF4 ADDRFP4 12 INDIRF4 MULF4 ASGNF4 ADDRLP4 8 INDIRF4 ADDRLP4 0 INDIRF4 LTF4 $702 ADDRLP4 8 ADDRLP4 0 INDIRF4 ASGNF4 ADDRFP4 20 INDIRP4 CNSTI4 0 ASGNI4 LABELV $702 ADDRFP4 16 INDIRP4 INDIRF4 ADDRLP4 8 INDIRF4 ADDF4 ARGF4 ADDRLP4 24 ADDRGP4 AngleMod CALLF4 ASGNF4 ADDRFP4 16 INDIRP4 ADDRLP4 24 INDIRF4 ASGNF4 ADDRGP4 $700 JUMPV LABELV $699 ADDRLP4 0 INDIRF4 CNSTF4 0 GEF4 $704 ADDRLP4 8 ADDRGP4 cg+107600 INDIRI4 CVIF4 4 ADDRLP4 4 INDIRF4 MULF4 ADDRFP4 12 INDIRF4 NEGF4 MULF4 ASGNF4 ADDRLP4 8 INDIRF4 ADDRLP4 0 INDIRF4 GTF4 $707 ADDRLP4 8 ADDRLP4 0 INDIRF4 ASGNF4 ADDRFP4 20 INDIRP4 CNSTI4 0 ASGNI4 LABELV $707 ADDRFP4 16 INDIRP4 INDIRF4 ADDRLP4 8 INDIRF4 ADDF4 ARGF4 ADDRLP4 24 ADDRGP4 AngleMod CALLF4 ASGNF4 ADDRFP4 16 INDIRP4 ADDRLP4 24 INDIRF4 ASGNF4 LABELV $704 LABELV $700 ADDRFP4 0 INDIRF4 ARGF4 ADDRFP4 16 INDIRP4 INDIRF4 ARGF4 ADDRLP4 20 ADDRGP4 AngleSubtract CALLF4 ASGNF4 ADDRLP4 0 ADDRLP4 20 INDIRF4 ASGNF4 ADDRLP4 0 INDIRF4 ADDRFP4 8 INDIRF4 LEF4 $709 ADDRFP4 0 INDIRF4 ADDRFP4 8 INDIRF4 CNSTF4 1065353216 SUBF4 SUBF4 ARGF4 ADDRLP4 24 ADDRGP4 AngleMod CALLF4 ASGNF4 ADDRFP4 16 INDIRP4 ADDRLP4 24 INDIRF4 ASGNF4 ADDRGP4 $710 JUMPV LABELV $709 ADDRLP4 0 INDIRF4 ADDRFP4 8 INDIRF4 NEGF4 GEF4 $711 ADDRFP4 0 INDIRF4 ADDRFP4 8 INDIRF4 CNSTF4 1065353216 SUBF4 ADDF4 ARGF4 ADDRLP4 24 ADDRGP4 AngleMod CALLF4 ASGNF4 ADDRFP4 16 INDIRP4 ADDRLP4 24 INDIRF4 ASGNF4 LABELV $711 LABELV $710 LABELV $687 endproc CG_SwingAngles 28 8 proc CG_AddPainTwitch 12 0 ADDRLP4 0 ADDRGP4 cg+107604 INDIRI4 ADDRFP4 0 INDIRP4 CNSTI4 596 ADDP4 INDIRI4 SUBI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 200 LTI4 $715 ADDRGP4 $713 JUMPV LABELV $715 ADDRLP4 4 CNSTF4 1065353216 ADDRLP4 0 INDIRI4 CVIF4 4 CNSTF4 1128792064 DIVF4 SUBF4 ASGNF4 ADDRFP4 0 INDIRP4 CNSTI4 600 ADDP4 INDIRI4 CNSTI4 0 EQI4 $717 ADDRLP4 8 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ASGNP4 ADDRLP4 8 INDIRP4 ADDRLP4 8 INDIRP4 INDIRF4 CNSTF4 1101004800 ADDRLP4 4 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRGP4 $718 JUMPV LABELV $717 ADDRLP4 8 ADDRFP4 4 INDIRP4 CNSTI4 8 ADDP4 ASGNP4 ADDRLP4 8 INDIRP4 ADDRLP4 8 INDIRP4 INDIRF4 CNSTF4 1101004800 ADDRLP4 4 INDIRF4 MULF4 SUBF4 ASGNF4 LABELV $718 LABELV $713 endproc CG_AddPainTwitch 12 0 data align 4 LABELV $720 byte 4 0 byte 4 22 byte 4 45 byte 4 -22 byte 4 0 byte 4 22 byte 4 -45 byte 4 -22 code proc CG_PlayerAngles 156 24 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 24 ADDRFP4 0 INDIRP4 CNSTI4 704 ADDP4 INDIRB ASGNB 12 ADDRLP4 24+4 INDIRF4 ARGF4 ADDRLP4 68 ADDRGP4 AngleMod CALLF4 ASGNF4 ADDRLP4 24+4 ADDRLP4 68 INDIRF4 ASGNF4 ADDRLP4 72 CNSTF4 0 ASGNF4 ADDRLP4 12+8 ADDRLP4 72 INDIRF4 ASGNF4 ADDRLP4 12+4 ADDRLP4 72 INDIRF4 ASGNF4 ADDRLP4 12 ADDRLP4 72 INDIRF4 ASGNF4 ADDRLP4 76 CNSTF4 0 ASGNF4 ADDRLP4 0+8 ADDRLP4 76 INDIRF4 ASGNF4 ADDRLP4 0+4 ADDRLP4 76 INDIRF4 ASGNF4 ADDRLP4 0 ADDRLP4 76 INDIRF4 ASGNF4 ADDRLP4 84 CNSTI4 -129 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 196 ADDP4 INDIRI4 ADDRLP4 84 INDIRI4 BANDI4 CNSTI4 22 NEI4 $729 ADDRLP4 88 ADDRFP4 0 INDIRP4 CNSTI4 200 ADDP4 INDIRI4 ADDRLP4 84 INDIRI4 BANDI4 ASGNI4 ADDRLP4 88 INDIRI4 CNSTI4 11 EQI4 $727 ADDRLP4 88 INDIRI4 CNSTI4 12 EQI4 $727 LABELV $729 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 CNSTI4 1 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 CNSTI4 1 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 476 ADDP4 CNSTI4 1 ASGNI4 LABELV $727 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 1 BANDI4 CNSTI4 0 EQI4 $730 ADDRLP4 52 CNSTI4 0 ASGNI4 ADDRGP4 $731 JUMPV LABELV $730 ADDRLP4 52 ADDRFP4 0 INDIRP4 CNSTI4 132 ADDP4 INDIRF4 CVFI4 4 ASGNI4 ADDRLP4 52 INDIRI4 CNSTI4 0 LTI4 $734 ADDRLP4 52 INDIRI4 CNSTI4 7 LEI4 $732 LABELV $734 ADDRGP4 $735 ARGP4 ADDRGP4 CG_Error CALLV pop LABELV $732 LABELV $731 ADDRLP4 12+4 ADDRLP4 24+4 INDIRF4 ADDRLP4 52 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 $720 ADDP4 INDIRI4 CVIF4 4 ADDF4 ASGNF4 ADDRLP4 0+4 ADDRLP4 24+4 INDIRF4 CNSTF4 1048576000 ADDRLP4 52 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 $720 ADDP4 INDIRI4 CVIF4 4 MULF4 ADDF4 ASGNF4 ADDRLP4 0+4 INDIRF4 ARGF4 CNSTF4 1103626240 ARGF4 CNSTF4 1119092736 ARGF4 ADDRGP4 cg_swingSpeed+8 INDIRF4 ARGF4 ADDRFP4 0 INDIRP4 CNSTI4 520 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 ARGP4 ADDRGP4 CG_SwingAngles CALLV pop ADDRLP4 12+4 INDIRF4 ARGF4 CNSTF4 1109393408 ARGF4 CNSTF4 1119092736 ARGF4 ADDRGP4 cg_swingSpeed+8 INDIRF4 ARGF4 ADDRFP4 0 INDIRP4 CNSTI4 472 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 476 ADDP4 ARGP4 ADDRGP4 CG_SwingAngles CALLV pop ADDRLP4 0+4 ADDRFP4 0 INDIRP4 CNSTI4 520 ADDP4 INDIRF4 ASGNF4 ADDRLP4 12+4 ADDRFP4 0 INDIRP4 CNSTI4 472 ADDP4 INDIRF4 ASGNF4 ADDRLP4 24 INDIRF4 CNSTF4 1127481344 LEF4 $746 ADDRLP4 60 CNSTF4 1061158912 ADDRLP4 24 INDIRF4 CNSTF4 3283353600 ADDF4 MULF4 ASGNF4 ADDRGP4 $747 JUMPV LABELV $746 ADDRLP4 60 CNSTF4 1061158912 ADDRLP4 24 INDIRF4 MULF4 ASGNF4 LABELV $747 ADDRLP4 60 INDIRF4 ARGF4 CNSTF4 1097859072 ARGF4 CNSTF4 1106247680 ARGF4 CNSTF4 1036831949 ARGF4 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 ARGP4 ADDRGP4 CG_SwingAngles CALLV pop ADDRLP4 0 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 INDIRF4 ASGNF4 ADDRLP4 36 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 ASGNI4 ADDRLP4 36 INDIRI4 CNSTI4 0 LTI4 $748 ADDRLP4 36 INDIRI4 CNSTI4 64 GEI4 $748 ADDRLP4 64 CNSTI4 1716 ADDRLP4 36 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 64 INDIRP4 CNSTI4 500 ADDP4 INDIRI4 CNSTI4 0 EQI4 $751 ADDRLP4 0 CNSTF4 0 ASGNF4 LABELV $751 LABELV $748 ADDRLP4 40 ADDRFP4 0 INDIRP4 CNSTI4 36 ADDP4 INDIRB ASGNB 12 ADDRLP4 40 ARGP4 ADDRLP4 112 ADDRGP4 VectorNormalize CALLF4 ASGNF4 ADDRLP4 56 ADDRLP4 112 INDIRF4 ASGNF4 ADDRLP4 56 INDIRF4 CNSTF4 0 EQF4 $753 ADDRLP4 56 CNSTF4 1028443341 ADDRLP4 56 INDIRF4 MULF4 ASGNF4 ADDRLP4 12 ARGP4 ADDRLP4 116 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 152 ADDRLP4 56 INDIRF4 ADDRLP4 40 INDIRF4 ADDRLP4 116+12 INDIRF4 MULF4 ADDRLP4 40+4 INDIRF4 ADDRLP4 116+12+4 INDIRF4 MULF4 ADDF4 ADDRLP4 40+8 INDIRF4 ADDRLP4 116+12+8 INDIRF4 MULF4 ADDF4 MULF4 ASGNF4 ADDRLP4 12+8 ADDRLP4 12+8 INDIRF4 ADDRLP4 152 INDIRF4 SUBF4 ASGNF4 ADDRLP4 152 ADDRLP4 56 INDIRF4 ADDRLP4 40 INDIRF4 ADDRLP4 116 INDIRF4 MULF4 ADDRLP4 40+4 INDIRF4 ADDRLP4 116+4 INDIRF4 MULF4 ADDF4 ADDRLP4 40+8 INDIRF4 ADDRLP4 116+8 INDIRF4 MULF4 ADDF4 MULF4 ASGNF4 ADDRLP4 12 ADDRLP4 12 INDIRF4 ADDRLP4 152 INDIRF4 ADDF4 ASGNF4 LABELV $753 ADDRLP4 36 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 ASGNI4 ADDRLP4 36 INDIRI4 CNSTI4 0 LTI4 $767 ADDRLP4 36 INDIRI4 CNSTI4 64 GEI4 $767 ADDRLP4 64 CNSTI4 1716 ADDRLP4 36 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 64 INDIRP4 CNSTI4 496 ADDP4 INDIRI4 CNSTI4 0 EQI4 $770 ADDRLP4 12+4 ADDRLP4 0+4 INDIRF4 ASGNF4 ADDRLP4 120 CNSTF4 0 ASGNF4 ADDRLP4 12 ADDRLP4 120 INDIRF4 ASGNF4 ADDRLP4 12+8 ADDRLP4 120 INDIRF4 ASGNF4 LABELV $770 LABELV $767 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 CG_AddPainTwitch CALLV pop ADDRLP4 24 ARGP4 ADDRLP4 0 ARGP4 ADDRLP4 24 ARGP4 ADDRGP4 AnglesSubtract CALLV pop ADDRLP4 0 ARGP4 ADDRLP4 12 ARGP4 ADDRLP4 0 ARGP4 ADDRGP4 AnglesSubtract CALLV pop ADDRLP4 12 ARGP4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 0 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 24 ARGP4 ADDRFP4 12 INDIRP4 ARGP4 ADDRGP4 AnglesToAxis CALLV pop LABELV $719 endproc CG_PlayerAngles 156 24 proc CG_HasteTrail 40 48 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 0 INDIRP4 CNSTI4 436 ADDP4 INDIRI4 ADDRGP4 cg+107604 INDIRI4 LEI4 $776 ADDRGP4 $775 JUMPV LABELV $776 ADDRLP4 12 ADDRFP4 0 INDIRP4 CNSTI4 488 ADDP4 INDIRI4 CNSTI4 -129 BANDI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 15 EQI4 $779 ADDRLP4 12 INDIRI4 CNSTI4 16 EQI4 $779 ADDRGP4 $775 JUMPV LABELV $779 ADDRLP4 24 ADDRFP4 0 INDIRP4 CNSTI4 436 ADDP4 ASGNP4 ADDRLP4 24 INDIRP4 ADDRLP4 24 INDIRP4 INDIRI4 CNSTI4 100 ADDI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 436 ADDP4 INDIRI4 ADDRGP4 cg+107604 INDIRI4 GEI4 $781 ADDRFP4 0 INDIRP4 CNSTI4 436 ADDP4 ADDRGP4 cg+107604 INDIRI4 ASGNI4 LABELV $781 ADDRLP4 0 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 0+8 ADDRLP4 0+8 INDIRF4 CNSTF4 1098907648 SUBF4 ASGNF4 ADDRLP4 0 ARGP4 ADDRGP4 vec3_origin ARGP4 CNSTF4 1090519040 ARGF4 ADDRLP4 28 CNSTF4 1065353216 ASGNF4 ADDRLP4 28 INDIRF4 ARGF4 ADDRLP4 28 INDIRF4 ARGF4 ADDRLP4 28 INDIRF4 ARGF4 ADDRLP4 28 INDIRF4 ARGF4 CNSTF4 1140457472 ARGF4 ADDRGP4 cg+107604 INDIRI4 ARGI4 ADDRLP4 32 CNSTI4 0 ASGNI4 ADDRLP4 32 INDIRI4 ARGI4 ADDRLP4 32 INDIRI4 ARGI4 ADDRGP4 cgs+152852+404 INDIRI4 ARGI4 ADDRLP4 36 ADDRGP4 CG_SmokePuff CALLP4 ASGNP4 ADDRLP4 16 ADDRLP4 36 INDIRP4 ASGNP4 ADDRLP4 16 INDIRP4 CNSTI4 8 ADDP4 CNSTI4 7 ASGNI4 LABELV $775 endproc CG_HasteTrail 40 48 proc CG_TrailItem 192 12 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 140 ADDRFP4 0 INDIRP4 CNSTI4 704 ADDP4 INDIRB ASGNB 12 ADDRLP4 188 CNSTF4 0 ASGNF4 ADDRLP4 140 ADDRLP4 188 INDIRF4 ASGNF4 ADDRLP4 140+8 ADDRLP4 188 INDIRF4 ASGNF4 ADDRLP4 140 ARGP4 ADDRLP4 152 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 0 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 0+68 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRF4 CNSTF4 3246391296 ADDRLP4 152 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 0+68+4 ADDRFP4 0 INDIRP4 CNSTI4 696 ADDP4 INDIRF4 CNSTF4 3246391296 ADDRLP4 152+4 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 0+68+8 ADDRFP4 0 INDIRP4 CNSTI4 700 ADDP4 INDIRF4 CNSTF4 3246391296 ADDRLP4 152+8 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 0+68+8 ADDRLP4 0+68+8 INDIRF4 CNSTF4 1098907648 ADDF4 ASGNF4 ADDRLP4 140+4 ADDRLP4 140+4 INDIRF4 CNSTF4 1119092736 ADDF4 ASGNF4 ADDRLP4 140 ARGP4 ADDRLP4 0+28 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 0+8 ADDRFP4 4 INDIRI4 ASGNI4 ADDRLP4 0 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $789 endproc CG_TrailItem 192 12 proc CG_PlayerFlag 356 24 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 8 ADDRFP4 8 INDIRP4 ASGNP4 ADDRLP4 0 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 0+8 ADDRGP4 cgs+152852+72 INDIRI4 ASGNI4 ADDRLP4 0+12 ADDRFP4 8 INDIRP4 CNSTI4 12 ADDP4 INDIRB ASGNB 12 ADDRLP4 0+24 ADDRFP4 8 INDIRP4 CNSTI4 24 ADDP4 INDIRF4 ASGNF4 ADDRLP4 0+4 ADDRFP4 8 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0 ARGP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRFP4 8 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 ARGI4 ADDRGP4 $378 ARGP4 ADDRGP4 CG_PositionEntityOnTag CALLV pop ADDRLP4 0 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop ADDRLP4 140 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 140+8 ADDRGP4 cgs+152852+76 INDIRI4 ASGNI4 ADDRLP4 140+108 ADDRFP4 4 INDIRI4 ASGNI4 ADDRLP4 140+12 ADDRFP4 8 INDIRP4 CNSTI4 12 ADDP4 INDIRB ASGNB 12 ADDRLP4 140+24 ADDRFP4 8 INDIRP4 CNSTI4 24 ADDP4 INDIRF4 ASGNF4 ADDRLP4 140+4 ADDRFP4 8 INDIRP4 CNSTI4 4 ADDP4 INDIRI4 ASGNI4 ADDRLP4 332 CNSTF4 0 ASGNF4 ADDRLP4 280+8 ADDRLP4 332 INDIRF4 ASGNF4 ADDRLP4 280+4 ADDRLP4 332 INDIRF4 ASGNF4 ADDRLP4 280 ADDRLP4 332 INDIRF4 ASGNF4 ADDRLP4 312 CNSTI4 0 ASGNI4 ADDRLP4 304 ADDRFP4 0 INDIRP4 CNSTI4 196 ADDP4 INDIRI4 CNSTI4 -129 BANDI4 ASGNI4 ADDRLP4 304 INDIRI4 CNSTI4 22 EQI4 $821 ADDRLP4 304 INDIRI4 CNSTI4 23 NEI4 $819 LABELV $821 ADDRLP4 320 CNSTI4 35 ASGNI4 ADDRGP4 $820 JUMPV LABELV $819 ADDRLP4 304 INDIRI4 CNSTI4 14 EQI4 $824 ADDRLP4 304 INDIRI4 CNSTI4 13 NEI4 $822 LABELV $824 ADDRLP4 320 CNSTI4 35 ASGNI4 ADDRLP4 312 CNSTI4 1 ASGNI4 ADDRGP4 $823 JUMPV LABELV $822 ADDRLP4 320 CNSTI4 34 ASGNI4 ADDRLP4 312 CNSTI4 1 ASGNI4 LABELV $823 LABELV $820 ADDRLP4 312 INDIRI4 CNSTI4 0 EQI4 $825 ADDRLP4 292 ADDRFP4 0 INDIRP4 CNSTI4 36 ADDP4 INDIRB ASGNB 12 ADDRLP4 292+8 ADDRLP4 292+8 INDIRF4 CNSTF4 1120403456 ADDF4 ASGNF4 ADDRLP4 292 ARGP4 ADDRGP4 VectorNormalize CALLF4 pop ADDRLP4 308 ADDRLP4 0+28+24 INDIRF4 ADDRLP4 292 INDIRF4 MULF4 ADDRLP4 0+28+24+4 INDIRF4 ADDRLP4 292+4 INDIRF4 MULF4 ADDF4 ADDRLP4 0+28+24+8 INDIRF4 ADDRLP4 292+8 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 308 INDIRF4 ARGF4 ADDRLP4 344 ADDRGP4 qk_fabs CALLF4 ASGNF4 ADDRLP4 344 INDIRF4 CNSTF4 1063675494 GEF4 $838 ADDRLP4 308 ADDRLP4 0+28 INDIRF4 ADDRLP4 292 INDIRF4 MULF4 ADDRLP4 0+28+4 INDIRF4 ADDRLP4 292+4 INDIRF4 MULF4 ADDF4 ADDRLP4 0+28+8 INDIRF4 ADDRLP4 292+8 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 308 INDIRF4 CNSTF4 1065353216 LEF4 $847 ADDRLP4 308 CNSTF4 1065353216 ASGNF4 ADDRGP4 $848 JUMPV LABELV $847 ADDRLP4 308 INDIRF4 CNSTF4 3212836864 GEF4 $849 ADDRLP4 308 CNSTF4 3212836864 ASGNF4 LABELV $849 LABELV $848 ADDRLP4 308 INDIRF4 ARGF4 ADDRLP4 348 ADDRGP4 qk_acos CALLF4 ASGNF4 ADDRLP4 324 ADDRLP4 348 INDIRF4 ASGNF4 ADDRLP4 308 ADDRLP4 0+28+12 INDIRF4 ADDRLP4 292 INDIRF4 MULF4 ADDRLP4 0+28+12+4 INDIRF4 ADDRLP4 292+4 INDIRF4 MULF4 ADDF4 ADDRLP4 0+28+12+8 INDIRF4 ADDRLP4 292+8 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 308 INDIRF4 CNSTF4 0 GEF4 $861 ADDRLP4 280+4 CNSTF4 1135869952 CNSTF4 1127481344 ADDRLP4 324 INDIRF4 MULF4 CNSTF4 1078530011 DIVF4 SUBF4 ASGNF4 ADDRGP4 $862 JUMPV LABELV $861 ADDRLP4 280+4 CNSTF4 1127481344 ADDRLP4 324 INDIRF4 MULF4 CNSTF4 1078530011 DIVF4 ASGNF4 LABELV $862 ADDRLP4 280+4 INDIRF4 CNSTF4 0 GEF4 $865 ADDRLP4 280+4 ADDRLP4 280+4 INDIRF4 CNSTF4 1135869952 ADDF4 ASGNF4 LABELV $865 ADDRLP4 280+4 INDIRF4 CNSTF4 1135869952 LEF4 $869 ADDRLP4 280+4 ADDRLP4 280+4 INDIRF4 CNSTF4 1135869952 SUBF4 ASGNF4 LABELV $869 ADDRLP4 280+4 INDIRF4 ARGF4 CNSTF4 1103626240 ARGF4 CNSTF4 1119092736 ARGF4 CNSTF4 1041865114 ARGF4 ADDRFP4 0 INDIRP4 CNSTI4 568 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 572 ADDP4 ARGP4 ADDRGP4 CG_SwingAngles CALLV pop LABELV $838 LABELV $825 ADDRLP4 280+4 ADDRFP4 0 INDIRP4 CNSTI4 568 ADDP4 INDIRF4 ASGNF4 ADDRLP4 316 CNSTI4 1716 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 316 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 548 ADDP4 ARGP4 ADDRLP4 320 INDIRI4 ARGI4 CNSTF4 1065353216 ARGF4 ADDRGP4 CG_RunLerpFrame CALLV pop ADDRLP4 140+96 ADDRFP4 0 INDIRP4 CNSTI4 548 ADDP4 INDIRI4 ASGNI4 ADDRLP4 140+80 ADDRFP4 0 INDIRP4 CNSTI4 556 ADDP4 INDIRI4 ASGNI4 ADDRLP4 140+100 ADDRFP4 0 INDIRP4 CNSTI4 564 ADDP4 INDIRF4 ASGNF4 ADDRLP4 280 ARGP4 ADDRLP4 140+28 ARGP4 ADDRGP4 AnglesToAxis CALLV pop ADDRLP4 140 ARGP4 ADDRLP4 0 ARGP4 ADDRLP4 0+8 INDIRI4 ARGI4 ADDRGP4 $378 ARGP4 ADDRGP4 CG_PositionRotatedEntityOnTag CALLV pop ADDRLP4 140 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $803 endproc CG_PlayerFlag 356 24 proc CG_PlayerPowerups 16 20 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 0 ADDRFP4 0 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 0 NEI4 $882 ADDRGP4 $881 JUMPV LABELV $882 ADDRLP4 0 INDIRI4 CNSTI4 2 BANDI4 CNSTI4 0 EQI4 $884 ADDRLP4 8 ADDRGP4 qk_rand CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRLP4 8 INDIRI4 CNSTI4 31 BANDI4 CNSTI4 200 ADDI4 CVIF4 4 ARGF4 ADDRLP4 12 CNSTF4 1045220557 ASGNF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRLP4 12 INDIRF4 ARGF4 CNSTF4 1065353216 ARGF4 ADDRGP4 trap_R_AddLightToScene CALLV pop LABELV $884 ADDRLP4 0 INDIRI4 CNSTI4 64 BANDI4 CNSTI4 0 EQI4 $886 ADDRFP4 0 INDIRP4 INDIRI4 ARGI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRGP4 vec3_origin ARGP4 ADDRGP4 cgs+152852+824 INDIRI4 ARGI4 ADDRGP4 trap_S_AddLoopingSound CALLV pop LABELV $886 ADDRLP4 4 CNSTI4 1716 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 0 INDIRI4 CNSTI4 128 BANDI4 CNSTI4 0 EQI4 $891 ADDRLP4 4 INDIRP4 CNSTI4 492 ADDP4 INDIRI4 CNSTI4 0 EQI4 $893 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+80 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_PlayerFlag CALLV pop ADDRGP4 $894 JUMPV LABELV $893 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+20 INDIRI4 ARGI4 ADDRGP4 CG_TrailItem CALLV pop LABELV $894 ADDRLP4 8 ADDRGP4 qk_rand CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRLP4 8 INDIRI4 CNSTI4 31 BANDI4 CNSTI4 200 ADDI4 CVIF4 4 ARGF4 CNSTF4 1065353216 ARGF4 ADDRLP4 12 CNSTF4 1045220557 ASGNF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRGP4 trap_R_AddLightToScene CALLV pop LABELV $891 ADDRLP4 0 INDIRI4 CNSTI4 256 BANDI4 CNSTI4 0 EQI4 $899 ADDRLP4 4 INDIRP4 CNSTI4 492 ADDP4 INDIRI4 CNSTI4 0 EQI4 $901 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+84 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_PlayerFlag CALLV pop ADDRGP4 $902 JUMPV LABELV $901 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+24 INDIRI4 ARGI4 ADDRGP4 CG_TrailItem CALLV pop LABELV $902 ADDRLP4 8 ADDRGP4 qk_rand CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRLP4 8 INDIRI4 CNSTI4 31 BANDI4 CNSTI4 200 ADDI4 CVIF4 4 ARGF4 ADDRLP4 12 CNSTF4 1045220557 ASGNF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRLP4 12 INDIRF4 ARGF4 CNSTF4 1065353216 ARGF4 ADDRGP4 trap_R_AddLightToScene CALLV pop LABELV $899 ADDRLP4 0 INDIRI4 CNSTI4 512 BANDI4 CNSTI4 0 EQI4 $907 ADDRLP4 4 INDIRP4 CNSTI4 492 ADDP4 INDIRI4 CNSTI4 0 EQI4 $909 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+88 INDIRI4 ARGI4 ADDRFP4 4 INDIRP4 ARGP4 ADDRGP4 CG_PlayerFlag CALLV pop ADDRGP4 $910 JUMPV LABELV $909 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+28 INDIRI4 ARGI4 ADDRGP4 CG_TrailItem CALLV pop LABELV $910 ADDRLP4 8 ADDRGP4 qk_rand CALLI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRLP4 8 INDIRI4 CNSTI4 31 BANDI4 CNSTI4 200 ADDI4 CVIF4 4 ARGF4 ADDRLP4 12 CNSTF4 1065353216 ASGNF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRLP4 12 INDIRF4 ARGF4 ADDRGP4 trap_R_AddLightToScene CALLV pop LABELV $907 ADDRLP4 0 INDIRI4 CNSTI4 8 BANDI4 CNSTI4 0 EQI4 $915 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_HasteTrail CALLV pop LABELV $915 LABELV $881 endproc CG_PlayerPowerups 16 20 proc CG_PlayerFloatSprite 144 12 ADDRFP4 0 INDIRP4 INDIRI4 ADDRGP4 cg+36 INDIRP4 CNSTI4 184 ADDP4 INDIRI4 NEI4 $918 ADDRGP4 cg+107628 INDIRI4 CNSTI4 0 NEI4 $918 ADDRLP4 140 CNSTI4 2 ASGNI4 ADDRGP4 $919 JUMPV LABELV $918 ADDRLP4 140 CNSTI4 0 ASGNI4 LABELV $919 ADDRLP4 0 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 0+68 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 0+68+8 ADDRLP4 0+68+8 INDIRF4 CNSTF4 1111490560 ADDF4 ASGNF4 ADDRLP4 0 CNSTI4 2 ASGNI4 ADDRLP4 0+112 ADDRFP4 4 INDIRI4 ASGNI4 ADDRLP4 0+132 CNSTF4 1092616192 ASGNF4 ADDRLP4 0+4 ADDRLP4 140 INDIRI4 ASGNI4 ADDRLP4 0+116 CNSTU1 255 ASGNU1 ADDRLP4 0+116+1 CNSTU1 255 ASGNU1 ADDRLP4 0+116+2 CNSTU1 255 ASGNU1 ADDRLP4 0+116+3 CNSTU1 255 ASGNU1 ADDRLP4 0 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $917 endproc CG_PlayerFloatSprite 144 12 proc CG_PlayerSprites 8 8 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 8192 BANDI4 CNSTI4 0 EQI4 $936 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+192 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $936 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 4096 BANDI4 CNSTI4 0 EQI4 $940 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+188 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $940 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 32768 BANDI4 CNSTI4 0 EQI4 $944 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+476 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $944 ADDRLP4 4 CNSTI4 8 ASGNI4 ADDRFP4 0 INDIRP4 ADDRLP4 4 INDIRI4 ADDP4 INDIRI4 ADDRLP4 4 INDIRI4 BANDI4 CNSTI4 0 EQI4 $948 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+480 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $948 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 64 BANDI4 CNSTI4 0 EQI4 $952 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+484 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $952 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 65536 BANDI4 CNSTI4 0 EQI4 $956 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+488 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $956 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 131072 BANDI4 CNSTI4 0 EQI4 $960 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+492 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $960 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 2048 BANDI4 CNSTI4 0 EQI4 $964 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+496 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop ADDRGP4 $935 JUMPV LABELV $964 ADDRLP4 0 CNSTI4 1716 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 MULI4 ADDRGP4 cgs+40972+68 ADDP4 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRI4 CNSTI4 1 BANDI4 CNSTI4 0 NEI4 $970 ADDRGP4 cg+36 INDIRP4 CNSTI4 304 ADDP4 INDIRI4 ADDRLP4 0 INDIRI4 NEI4 $970 ADDRGP4 cgs+31456 INDIRI4 CNSTI4 3 LTI4 $970 ADDRGP4 cg_drawFriend+12 INDIRI4 CNSTI4 0 EQI4 $935 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 cgs+152852+184 INDIRI4 ARGI4 ADDRGP4 CG_PlayerFloatSprite CALLV pop LABELV $970 LABELV $935 endproc CG_PlayerSprites 8 8 lit align 4 LABELV $980 byte 4 3245342720 byte 4 3245342720 byte 4 0 align 4 LABELV $981 byte 4 1097859072 byte 4 1097859072 byte 4 1073741824 code proc CG_PlayerShadow 104 44 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 72 ADDRGP4 $980 INDIRB ASGNB 12 ADDRLP4 84 ADDRGP4 $981 INDIRB ASGNB 12 ADDRFP4 4 INDIRP4 CNSTF4 0 ASGNF4 ADDRGP4 cg_shadows+12 INDIRI4 CNSTI4 0 NEI4 $982 CNSTI4 0 RETI4 ADDRGP4 $979 JUMPV LABELV $982 ADDRFP4 0 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 16 BANDI4 CNSTI4 0 EQI4 $985 CNSTI4 0 RETI4 ADDRGP4 $979 JUMPV LABELV $985 ADDRLP4 60 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 60+8 ADDRLP4 60+8 INDIRF4 CNSTF4 1124073472 SUBF4 ASGNF4 ADDRLP4 0 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRLP4 60 ARGP4 ADDRLP4 72 ARGP4 ADDRLP4 84 ARGP4 CNSTI4 0 ARGI4 CNSTI4 33619969 ARGI4 ADDRGP4 trap_CM_BoxTrace CALLV pop ADDRLP4 0+8 INDIRF4 CNSTF4 1065353216 EQF4 $993 ADDRLP4 96 CNSTI4 0 ASGNI4 ADDRLP4 0+4 INDIRI4 ADDRLP4 96 INDIRI4 NEI4 $993 ADDRLP4 0 INDIRI4 ADDRLP4 96 INDIRI4 EQI4 $988 LABELV $993 CNSTI4 0 RETI4 ADDRGP4 $979 JUMPV LABELV $988 ADDRFP4 4 INDIRP4 ADDRLP4 0+12+8 INDIRF4 CNSTF4 1065353216 ADDF4 ASGNF4 ADDRGP4 cg_shadows+12 INDIRI4 CNSTI4 1 EQI4 $996 CNSTI4 1 RETI4 ADDRGP4 $979 JUMPV LABELV $996 ADDRLP4 56 CNSTF4 1065353216 ADDRLP4 0+8 INDIRF4 SUBF4 ASGNF4 ADDRGP4 cgs+152852+328 INDIRI4 ARGI4 ADDRLP4 0+12 ARGP4 ADDRLP4 0+24 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 472 ADDP4 INDIRF4 ARGF4 ADDRLP4 56 INDIRF4 ARGF4 ADDRLP4 56 INDIRF4 ARGF4 ADDRLP4 56 INDIRF4 ARGF4 CNSTF4 1065353216 ARGF4 CNSTI4 0 ARGI4 CNSTF4 1103101952 ARGF4 CNSTI4 1 ARGI4 ADDRGP4 CG_ImpactMark CALLV pop CNSTI4 1 RETI4 LABELV $979 endproc CG_PlayerShadow 104 44 proc CG_PlayerSplash 196 28 ADDRGP4 cg_shadows+12 INDIRI4 CNSTI4 0 NEI4 $1005 ADDRGP4 $1004 JUMPV LABELV $1005 ADDRLP4 164 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 164+8 ADDRLP4 164+8 INDIRF4 CNSTF4 1103101952 SUBF4 ASGNF4 ADDRLP4 164 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 180 ADDRGP4 CG_PointContents CALLI4 ASGNI4 ADDRLP4 176 ADDRLP4 180 INDIRI4 ASGNI4 ADDRLP4 176 INDIRI4 CNSTI4 56 BANDI4 CNSTI4 0 NEI4 $1009 ADDRGP4 $1004 JUMPV LABELV $1009 ADDRLP4 152 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 152+8 ADDRLP4 152+8 INDIRF4 CNSTF4 1107296256 ADDF4 ASGNF4 ADDRLP4 152 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 184 ADDRGP4 CG_PointContents CALLI4 ASGNI4 ADDRLP4 176 ADDRLP4 184 INDIRI4 ASGNI4 ADDRLP4 176 INDIRI4 CNSTI4 57 BANDI4 CNSTI4 0 EQI4 $1012 ADDRGP4 $1004 JUMPV LABELV $1012 ADDRLP4 96 ARGP4 ADDRLP4 152 ARGP4 ADDRLP4 164 ARGP4 ADDRLP4 188 CNSTP4 0 ASGNP4 ADDRLP4 188 INDIRP4 ARGP4 ADDRLP4 188 INDIRP4 ARGP4 CNSTI4 0 ARGI4 CNSTI4 56 ARGI4 ADDRGP4 trap_CM_BoxTrace CALLV pop ADDRLP4 96+8 INDIRF4 CNSTF4 1065353216 NEF4 $1014 ADDRGP4 $1004 JUMPV LABELV $1014 ADDRLP4 0 ADDRLP4 96+12 INDIRB ASGNB 12 ADDRLP4 192 CNSTF4 1107296256 ASGNF4 ADDRLP4 0 ADDRLP4 0 INDIRF4 ADDRLP4 192 INDIRF4 SUBF4 ASGNF4 ADDRLP4 0+4 ADDRLP4 0+4 INDIRF4 ADDRLP4 192 INDIRF4 SUBF4 ASGNF4 ADDRLP4 0+12 CNSTF4 0 ASGNF4 ADDRLP4 0+12+4 CNSTF4 0 ASGNF4 ADDRLP4 0+20 CNSTU1 255 ASGNU1 ADDRLP4 0+20+1 CNSTU1 255 ASGNU1 ADDRLP4 0+20+2 CNSTU1 255 ASGNU1 ADDRLP4 0+20+3 CNSTU1 255 ASGNU1 ADDRLP4 0+24 ADDRLP4 96+12 INDIRB ASGNB 12 ADDRLP4 0+24 ADDRLP4 0+24 INDIRF4 CNSTF4 1107296256 SUBF4 ASGNF4 ADDRLP4 0+24+4 ADDRLP4 0+24+4 INDIRF4 CNSTF4 1107296256 ADDF4 ASGNF4 ADDRLP4 0+24+12 CNSTF4 0 ASGNF4 ADDRLP4 0+24+12+4 CNSTF4 1065353216 ASGNF4 ADDRLP4 0+24+20 CNSTU1 255 ASGNU1 ADDRLP4 0+24+20+1 CNSTU1 255 ASGNU1 ADDRLP4 0+24+20+2 CNSTU1 255 ASGNU1 ADDRLP4 0+24+20+3 CNSTU1 255 ASGNU1 ADDRLP4 0+48 ADDRLP4 96+12 INDIRB ASGNB 12 ADDRLP4 0+48 ADDRLP4 0+48 INDIRF4 CNSTF4 1107296256 ADDF4 ASGNF4 ADDRLP4 0+48+4 ADDRLP4 0+48+4 INDIRF4 CNSTF4 1107296256 ADDF4 ASGNF4 ADDRLP4 0+48+12 CNSTF4 1065353216 ASGNF4 ADDRLP4 0+48+12+4 CNSTF4 1065353216 ASGNF4 ADDRLP4 0+48+20 CNSTU1 255 ASGNU1 ADDRLP4 0+48+20+1 CNSTU1 255 ASGNU1 ADDRLP4 0+48+20+2 CNSTU1 255 ASGNU1 ADDRLP4 0+48+20+3 CNSTU1 255 ASGNU1 ADDRLP4 0+72 ADDRLP4 96+12 INDIRB ASGNB 12 ADDRLP4 0+72 ADDRLP4 0+72 INDIRF4 CNSTF4 1107296256 ADDF4 ASGNF4 ADDRLP4 0+72+4 ADDRLP4 0+72+4 INDIRF4 CNSTF4 1107296256 SUBF4 ASGNF4 ADDRLP4 0+72+12 CNSTF4 1065353216 ASGNF4 ADDRLP4 0+72+12+4 CNSTF4 0 ASGNF4 ADDRLP4 0+72+20 CNSTU1 255 ASGNU1 ADDRLP4 0+72+20+1 CNSTU1 255 ASGNU1 ADDRLP4 0+72+20+2 CNSTU1 255 ASGNU1 ADDRLP4 0+72+20+3 CNSTU1 255 ASGNU1 ADDRGP4 cgs+152852+352 INDIRI4 ARGI4 CNSTI4 4 ARGI4 ADDRLP4 0 ARGP4 ADDRGP4 trap_R_AddPolyToScene CALLV pop LABELV $1004 endproc CG_PlayerSplash 196 28 export CG_AddRefEntityWithPowerups proc CG_AddRefEntityWithPowerups 0 4 ADDRFP4 4 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 16 BANDI4 CNSTI4 0 EQI4 $1095 ADDRFP4 0 INDIRP4 CNSTI4 112 ADDP4 ADDRGP4 cgs+152852+388 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop ADDRGP4 $1096 JUMPV LABELV $1095 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop ADDRFP4 4 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 2 BANDI4 CNSTI4 0 EQI4 $1099 ADDRFP4 8 INDIRI4 CNSTI4 1 NEI4 $1101 ADDRFP4 0 INDIRP4 CNSTI4 112 ADDP4 ADDRGP4 cgs+152852+380 INDIRI4 ASGNI4 ADDRGP4 $1102 JUMPV LABELV $1101 ADDRFP4 0 INDIRP4 CNSTI4 112 ADDP4 ADDRGP4 cgs+152852+376 INDIRI4 ASGNI4 LABELV $1102 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $1099 ADDRFP4 4 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 32 BANDI4 CNSTI4 0 EQI4 $1107 ADDRGP4 cg+107604 INDIRI4 CNSTI4 100 DIVI4 CNSTI4 10 MODI4 CNSTI4 1 NEI4 $1109 ADDRFP4 0 INDIRP4 CNSTI4 112 ADDP4 ADDRGP4 cgs+152852+392 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $1109 LABELV $1107 ADDRFP4 4 INDIRP4 CNSTI4 188 ADDP4 INDIRI4 CNSTI4 4 BANDI4 CNSTI4 0 EQI4 $1114 ADDRFP4 0 INDIRP4 CNSTI4 112 ADDP4 ADDRGP4 cgs+152852+396 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 trap_R_AddRefEntityToScene CALLV pop LABELV $1114 LABELV $1096 LABELV $1094 endproc CG_AddRefEntityWithPowerups 0 4 export CG_LightVerts proc CG_LightVerts 88 16 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 4 ADDRFP4 4 INDIRI4 ASGNI4 ADDRFP4 8 ADDRFP4 8 INDIRP4 ASGNP4 ADDRFP4 8 INDIRP4 ARGP4 ADDRLP4 12 ARGP4 ADDRLP4 36 ARGP4 ADDRLP4 24 ARGP4 ADDRGP4 trap_R_LightForPoint CALLI4 pop ADDRLP4 4 CNSTI4 0 ASGNI4 ADDRGP4 $1122 JUMPV LABELV $1119 ADDRLP4 8 ADDRFP4 0 INDIRP4 INDIRF4 ADDRLP4 24 INDIRF4 MULF4 ADDRFP4 0 INDIRP4 CNSTI4 4 ADDP4 INDIRF4 ADDRLP4 24+4 INDIRF4 MULF4 ADDF4 ADDRFP4 0 INDIRP4 CNSTI4 8 ADDP4 INDIRF4 ADDRLP4 24+8 INDIRF4 MULF4 ADDF4 ASGNF4 ADDRLP4 8 INDIRF4 CNSTF4 0 GTF4 $1125 ADDRLP4 56 ADDRLP4 12 INDIRF4 ASGNF4 ADDRLP4 60 CNSTF4 1325400064 ASGNF4 ADDRLP4 56 INDIRF4 ADDRLP4 60 INDIRF4 LTF4 $1128 ADDRLP4 52 ADDRLP4 56 INDIRF4 ADDRLP4 60 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $1129 JUMPV LABELV $1128 ADDRLP4 52 ADDRLP4 56 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $1129 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 20 ADDP4 ADDRLP4 52 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 68 ADDRLP4 12+4 INDIRF4 ASGNF4 ADDRLP4 72 CNSTF4 1325400064 ASGNF4 ADDRLP4 68 INDIRF4 ADDRLP4 72 INDIRF4 LTF4 $1132 ADDRLP4 64 ADDRLP4 68 INDIRF4 ADDRLP4 72 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $1133 JUMPV LABELV $1132 ADDRLP4 64 ADDRLP4 68 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $1133 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 21 ADDP4 ADDRLP4 64 INDIRU4 CVUU1 4 ASGNU1 ADDRLP4 80 ADDRLP4 12+8 INDIRF4 ASGNF4 ADDRLP4 84 CNSTF4 1325400064 ASGNF4 ADDRLP4 80 INDIRF4 ADDRLP4 84 INDIRF4 LTF4 $1136 ADDRLP4 76 ADDRLP4 80 INDIRF4 ADDRLP4 84 INDIRF4 SUBF4 CVFI4 4 CVIU4 4 CNSTU4 2147483648 ADDU4 ASGNU4 ADDRGP4 $1137 JUMPV LABELV $1136 ADDRLP4 76 ADDRLP4 80 INDIRF4 CVFI4 4 CVIU4 4 ASGNU4 LABELV $1137 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 22 ADDP4 ADDRLP4 76 INDIRU4 CVUU1 4 ASGNU1 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 23 ADDP4 CNSTU1 255 ASGNU1 ADDRGP4 $1120 JUMPV LABELV $1125 ADDRLP4 0 ADDRLP4 12 INDIRF4 ADDRLP4 8 INDIRF4 ADDRLP4 36 INDIRF4 MULF4 ADDF4 CVFI4 4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 255 LEI4 $1138 ADDRLP4 0 CNSTI4 255 ASGNI4 LABELV $1138 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 20 ADDP4 ADDRLP4 0 INDIRI4 CVIU4 4 CVUU1 4 ASGNU1 ADDRLP4 0 ADDRLP4 12+4 INDIRF4 ADDRLP4 8 INDIRF4 ADDRLP4 36+4 INDIRF4 MULF4 ADDF4 CVFI4 4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 255 LEI4 $1142 ADDRLP4 0 CNSTI4 255 ASGNI4 LABELV $1142 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 21 ADDP4 ADDRLP4 0 INDIRI4 CVIU4 4 CVUU1 4 ASGNU1 ADDRLP4 0 ADDRLP4 12+8 INDIRF4 ADDRLP4 8 INDIRF4 ADDRLP4 36+8 INDIRF4 MULF4 ADDF4 CVFI4 4 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 255 LEI4 $1146 ADDRLP4 0 CNSTI4 255 ASGNI4 LABELV $1146 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 22 ADDP4 ADDRLP4 0 INDIRI4 CVIU4 4 CVUU1 4 ASGNU1 CNSTI4 24 ADDRLP4 4 INDIRI4 MULI4 ADDRFP4 8 INDIRP4 ADDP4 CNSTI4 23 ADDP4 CNSTU1 255 ASGNU1 LABELV $1120 ADDRLP4 4 ADDRLP4 4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $1122 ADDRLP4 4 INDIRI4 ADDRFP4 4 INDIRI4 LTI4 $1119 CNSTI4 1 RETI4 LABELV $1118 endproc CG_LightVerts 88 16 export CG_Player proc CG_Player 448 28 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 428 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 ASGNI4 ADDRLP4 428 INDIRI4 CNSTI4 0 LTI4 $1151 ADDRLP4 428 INDIRI4 CNSTI4 64 LTI4 $1149 LABELV $1151 ADDRGP4 $1152 ARGP4 ADDRGP4 CG_Error CALLV pop LABELV $1149 ADDRLP4 280 CNSTI4 1716 ADDRLP4 428 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ASGNP4 ADDRLP4 280 INDIRP4 INDIRI4 CNSTI4 0 NEI4 $1154 ADDRGP4 $1148 JUMPV LABELV $1154 ADDRLP4 424 CNSTI4 0 ASGNI4 ADDRFP4 0 INDIRP4 INDIRI4 ADDRGP4 cg+36 INDIRP4 CNSTI4 184 ADDP4 INDIRI4 NEI4 $1156 ADDRGP4 cg+107628 INDIRI4 CNSTI4 0 NEI4 $1159 ADDRLP4 424 CNSTI4 2 ASGNI4 ADDRGP4 $1160 JUMPV LABELV $1159 ADDRGP4 cg_cameraMode+12 INDIRI4 CNSTI4 0 EQI4 $1162 ADDRGP4 $1148 JUMPV LABELV $1162 LABELV $1160 LABELV $1156 ADDRLP4 0 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 140 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRLP4 284 ARGP4 CNSTI4 0 ARGI4 CNSTU4 140 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0+28 ARGP4 ADDRLP4 140+28 ARGP4 ADDRLP4 284+28 ARGP4 ADDRGP4 CG_PlayerAngles CALLV pop ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0+96 ARGP4 ADDRLP4 0+80 ARGP4 ADDRLP4 0+100 ARGP4 ADDRLP4 140+96 ARGP4 ADDRLP4 140+80 ARGP4 ADDRLP4 140+100 ARGP4 ADDRGP4 CG_PlayerAnimation CALLV pop ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_PlayerSprites CALLV pop ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 432 ARGP4 ADDRLP4 444 ADDRGP4 CG_PlayerShadow CALLI4 ASGNI4 ADDRLP4 436 ADDRLP4 444 INDIRI4 ASGNI4 ADDRFP4 0 INDIRP4 ARGP4 ADDRGP4 CG_PlayerSplash CALLV pop ADDRGP4 cg_shadows+12 INDIRI4 CNSTI4 3 NEI4 $1174 ADDRLP4 436 INDIRI4 CNSTI4 0 EQI4 $1174 ADDRLP4 424 ADDRLP4 424 INDIRI4 CNSTI4 256 BORI4 ASGNI4 LABELV $1174 ADDRLP4 424 ADDRLP4 424 INDIRI4 CNSTI4 128 BORI4 ASGNI4 ADDRLP4 0+8 ADDRLP4 280 INDIRP4 CNSTI4 524 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0+108 ADDRLP4 280 INDIRP4 CNSTI4 528 ADDP4 INDIRI4 ASGNI4 ADDRLP4 0+68 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 0+12 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 0+24 ADDRLP4 432 INDIRF4 ASGNF4 ADDRLP4 0+4 ADDRLP4 424 INDIRI4 ASGNI4 ADDRLP4 0+84 ADDRLP4 0+68 INDIRB ASGNB 12 ADDRLP4 0 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_AddRefEntityWithPowerups CALLV pop ADDRLP4 0+8 INDIRI4 CNSTI4 0 NEI4 $1185 ADDRGP4 $1148 JUMPV LABELV $1185 ADDRLP4 140+8 ADDRLP4 280 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 ASGNI4 ADDRLP4 140+8 INDIRI4 CNSTI4 0 NEI4 $1189 ADDRGP4 $1148 JUMPV LABELV $1189 ADDRLP4 140+108 ADDRLP4 280 INDIRP4 CNSTI4 536 ADDP4 INDIRI4 ASGNI4 ADDRLP4 140+12 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 140 ARGP4 ADDRLP4 0 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 524 ADDP4 INDIRI4 ARGI4 ADDRGP4 $1194 ARGP4 ADDRGP4 CG_PositionRotatedEntityOnTag CALLV pop ADDRLP4 140+24 ADDRLP4 432 INDIRF4 ASGNF4 ADDRLP4 140+4 ADDRLP4 424 INDIRI4 ASGNI4 ADDRLP4 140 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_AddRefEntityWithPowerups CALLV pop ADDRLP4 284+8 ADDRLP4 280 INDIRP4 CNSTI4 540 ADDP4 INDIRI4 ASGNI4 ADDRLP4 284+8 INDIRI4 CNSTI4 0 NEI4 $1198 ADDRGP4 $1148 JUMPV LABELV $1198 ADDRLP4 284+108 ADDRLP4 280 INDIRP4 CNSTI4 544 ADDP4 INDIRI4 ASGNI4 ADDRLP4 284+12 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRLP4 284 ARGP4 ADDRLP4 140 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 532 ADDP4 INDIRI4 ARGI4 ADDRGP4 $1203 ARGP4 ADDRGP4 CG_PositionRotatedEntityOnTag CALLV pop ADDRLP4 284+24 ADDRLP4 432 INDIRF4 ASGNF4 ADDRLP4 284+4 ADDRLP4 424 INDIRI4 ASGNI4 ADDRLP4 284 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_AddRefEntityWithPowerups CALLV pop ADDRLP4 140 ARGP4 CNSTP4 0 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 280 INDIRP4 CNSTI4 68 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_AddPlayerWeapon CALLV pop ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 140 ARGP4 ADDRGP4 CG_PlayerPowerups CALLV pop LABELV $1148 endproc CG_Player 448 28 export CG_ResetPlayerEntity proc CG_ResetPlayerEntity 40 12 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRFP4 0 INDIRP4 CNSTI4 624 ADDP4 CNSTI4 -99999 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 652 ADDP4 CNSTI4 0 ASGNI4 CNSTI4 1716 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 452 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 196 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_ClearLerpFrame CALLV pop CNSTI4 1716 ADDRFP4 0 INDIRP4 CNSTI4 168 ADDP4 INDIRI4 MULI4 ADDRGP4 cgs+40972 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 500 ADDP4 ARGP4 ADDRFP4 0 INDIRP4 CNSTI4 200 ADDP4 INDIRI4 ARGI4 ADDRGP4 CG_ClearLerpFrame CALLV pop ADDRFP4 0 INDIRP4 CNSTI4 12 ADDP4 ARGP4 ADDRGP4 cg+107604 INDIRI4 ARGI4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 ARGP4 ADDRGP4 BG_EvaluateTrajectory CALLV pop ADDRFP4 0 INDIRP4 CNSTI4 48 ADDP4 ARGP4 ADDRGP4 cg+107604 INDIRI4 ARGI4 ADDRFP4 0 INDIRP4 CNSTI4 704 ADDP4 ARGP4 ADDRGP4 BG_EvaluateTrajectory CALLV pop ADDRFP4 0 INDIRP4 CNSTI4 656 ADDP4 ADDRFP4 0 INDIRP4 CNSTI4 692 ADDP4 INDIRB ASGNB 12 ADDRFP4 0 INDIRP4 CNSTI4 668 ADDP4 ADDRFP4 0 INDIRP4 CNSTI4 704 ADDP4 INDIRB ASGNB 12 ADDRFP4 0 INDIRP4 CNSTI4 452 ADDP4 ARGP4 CNSTI4 0 ARGI4 CNSTU4 48 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRFP4 0 INDIRP4 CNSTI4 472 ADDP4 ADDRFP4 0 INDIRP4 CNSTI4 672 ADDP4 INDIRF4 ASGNF4 ADDRFP4 0 INDIRP4 CNSTI4 476 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 480 ADDP4 CNSTF4 0 ASGNF4 ADDRFP4 0 INDIRP4 CNSTI4 484 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 500 ADDP4 ARGP4 CNSTI4 0 ARGI4 CNSTU4 48 ARGU4 ADDRGP4 qk_memset CALLP4 pop ADDRFP4 0 INDIRP4 CNSTI4 520 ADDP4 ADDRFP4 0 INDIRP4 CNSTI4 672 ADDP4 INDIRF4 ASGNF4 ADDRFP4 0 INDIRP4 CNSTI4 524 ADDP4 CNSTI4 0 ASGNI4 ADDRFP4 0 INDIRP4 CNSTI4 528 ADDP4 ADDRFP4 0 INDIRP4 CNSTI4 668 ADDP4 INDIRF4 ASGNF4 ADDRFP4 0 INDIRP4 CNSTI4 532 ADDP4 CNSTI4 0 ASGNI4 ADDRGP4 cg_debugPosition+12 INDIRI4 CNSTI4 0 EQI4 $1211 ADDRGP4 $1214 ARGP4 ADDRFP4 0 INDIRP4 INDIRI4 ARGI4 ADDRFP4 0 INDIRP4 CNSTI4 520 ADDP4 INDIRF4 ARGF4 ADDRGP4 CG_Printf CALLV pop LABELV $1211 LABELV $1206 endproc CG_ResetPlayerEntity 40 12 import CG_NewParticleArea import initparticles import CG_ParticleExplosion import CG_ParticleMisc import CG_ParticleDust import CG_ParticleSparks import CG_ParticleBulletDebris import CG_ParticleSnowFlurry import CG_AddParticleShrapnel import CG_ParticleSmoke import CG_ParticleSnow import CG_AddParticles import CG_ClearParticles import trap_GetEntityToken import trap_getCameraInfo import trap_startCamera import trap_loadCamera import trap_SnapVector import trap_RealTime import trap_CIN_SetExtents import trap_CIN_DrawCinematic import trap_CIN_RunCinematic import trap_CIN_StopCinematic import trap_CIN_PlayCinematic import trap_Key_GetKey import trap_Key_SetCatcher import trap_Key_GetCatcher import trap_Key_IsDown import trap_R_RegisterFont import trap_MemoryRemaining import testPrintFloat import testPrintInt import trap_SetUserCmdValue import trap_GetUserCmd import trap_GetCurrentCmdNumber import trap_GetServerCommand import trap_GetSnapshot import trap_GetCurrentSnapshotNumber import trap_GetGameState import trap_GetGlconfig import trap_R_inPVS import trap_R_RemapShader import trap_R_LerpTag import trap_R_ModelBounds import trap_R_DrawStretchPic import trap_R_SetColor import trap_R_RenderScene import trap_R_LightForPoint import trap_R_AddAdditiveLightToScene import trap_R_AddLightToScene import trap_R_AddPolysToScene import trap_R_AddPolyToScene import trap_R_AddRefEntityToScene import trap_R_ClearScene import trap_R_RegisterShaderNoMip import trap_R_RegisterShader import trap_R_RegisterSkin import trap_R_RegisterModel import trap_R_LoadWorldMap import trap_S_StopBackgroundTrack import trap_S_StartBackgroundTrack import trap_S_RegisterSound import trap_S_Respatialize import trap_S_UpdateEntityPosition import trap_S_AddRealLoopingSound import trap_S_AddLoopingSound import trap_S_ClearLoopingSounds import trap_S_StartLocalSound import trap_S_StopLoopingSound import trap_S_StartSound import trap_CM_MarkFragments import trap_CM_TransformedCapsuleTrace import trap_CM_TransformedBoxTrace import trap_CM_CapsuleTrace import trap_CM_BoxTrace import trap_CM_TransformedPointContents import trap_CM_PointContents import trap_CM_TempBoxModel import trap_CM_InlineModel import trap_CM_NumInlineModels import trap_CM_LoadMap import trap_UpdateScreen import trap_SendClientCommand import trap_RemoveCommand import trap_AddCommand import trap_SendConsoleCommand import trap_FS_Seek import trap_FS_FCloseFile import trap_FS_Write import trap_FS_Read import trap_FS_FOpenFile import trap_Args import trap_Argv import trap_Argc import trap_Cvar_VariableStringBuffer import trap_Cvar_Set import trap_Cvar_Update import trap_Cvar_Register import trap_Milliseconds import trap_Error import trap_Print import CG_CheckChangedPredictableEvents import CG_TransitionPlayerState import CG_Respawn import CG_ShaderStateChanged import CG_SetConfigValues import CG_ParseServerinfo import CG_ExecuteNewServerCommands import CG_InitConsoleCommands import CG_ConsoleCommand import CG_DrawOldTourneyScoreboard import CG_DrawOldScoreboard import CG_DrawInformation import CG_LoadingClient import CG_LoadingItem import CG_LoadingString import CG_ProcessSnapshots import CG_MakeExplosion import CG_Bleed import CG_BigExplode import CG_GibPlayer import CG_ScorePlum import CG_SpawnEffect import CG_BubbleTrail import CG_SmokePuff import CG_AddLocalEntities import CG_AllocLocalEntity import CG_InitLocalEntities import CG_ImpactMark import CG_AddMarks import CG_InitMarkPolys import CG_OutOfAmmoChange import CG_DrawWeaponSelect import CG_AddPlayerWeapon import CG_AddViewWeapon import CG_GrappleTrail import CG_RailTrail import CG_Bullet import CG_ShotgunFire import CG_MissileHitPlayer import CG_MissileHitWall import CG_FireWeapon import CG_RegisterItemVisuals import CG_RegisterWeapon import CG_Weapon_f import CG_PrevWeapon_f import CG_NextWeapon_f import CG_PositionRotatedEntityOnTag import CG_PositionEntityOnTag import CG_AdjustPositionForMover import CG_Beam import CG_AddPacketEntities import CG_SetEntitySoundPosition import CG_PainEvent import CG_EntityEvent import CG_PlaceString import CG_CheckEvents import CG_PredictPlayerState import CG_Trace import CG_PointContents import CG_BuildSolidList import CG_StatusHandle import CG_OtherTeamHasFlag import CG_YourTeamHasFlag import CG_GameTypeString import CG_CheckOrderPending import CG_Text_PaintChar import CG_Draw3DModel import CG_GetKillerText import CG_GetGameStatusText import CG_GetTeamColor import CG_InitTeamChat import CG_SetPrintString import CG_ShowResponseHead import CG_RunMenuScript import CG_OwnerDrawVisible import CG_GetValue import CG_SelectNextPlayer import CG_SelectPrevPlayer import CG_Text_Height import CG_Text_Width import CG_Text_Paint import CG_OwnerDraw import CG_DrawTeamBackground import CG_DrawFlagModel import CG_DrawActive import CG_DrawHead import CG_CenterPrint import CG_AddLagometerSnapshotInfo import CG_AddLagometerFrameInfo import teamChat2 import teamChat1 import systemChat import drawTeamOverlayModificationCount import numSortedTeamPlayers import sortedTeamPlayers import CG_DrawTopBottom import CG_DrawSides import CG_DrawRect import UI_DrawProportionalString import CG_GetColorForHealth import CG_ColorForHealth import CG_TileClear import CG_TeamColor import CG_FadeColor import CG_DrawStrlen import CG_DrawSmallStringColor import CG_DrawSmallString import CG_DrawBigStringColor import CG_DrawBigString import CG_DrawStringExt import CG_DrawString import CG_DrawPic import CG_FillRect import CG_AdjustFrom640 import CG_DrawActiveFrame import CG_AddBufferedSound import CG_ZoomUp_f import CG_ZoomDown_f import CG_TestModelPrevSkin_f import CG_TestModelNextSkin_f import CG_TestModelPrevFrame_f import CG_TestModelNextFrame_f import CG_TestGun_f import CG_TestModel_f import CG_BuildSpectatorString import CG_GetSelectedScore import CG_SetScoreSelection import CG_RankRunFrame import CG_EventHandling import CG_MouseEvent import CG_KeyEvent import CG_LoadMenus import CG_LastAttacker import CG_CrosshairPlayer import CG_UpdateCvars import CG_StartMusic import CG_Error import CG_Printf import CG_Argv import CG_ConfigString import cg_trueLightning import cg_oldPlasma import cg_oldRocket import cg_oldRail import cg_noProjectileTrail import cg_noTaunt import cg_bigFont import cg_smallFont import cg_cameraMode import cg_timescale import cg_timescaleFadeSpeed import cg_timescaleFadeEnd import cg_cameraOrbitDelay import cg_cameraOrbit import pmove_msec import pmove_fixed import cg_smoothClients import cg_scorePlum import cg_teamChatsOnly import cg_drawFriend import cg_deferPlayers import cg_predictItems import cg_blood import cg_paused import cg_buildScript import cg_forceModel import cg_stats import cg_teamChatHeight import cg_teamChatTime import cg_synchronousClients import cg_drawAttacker import cg_lagometer import cg_thirdPerson import cg_thirdPersonAngle import cg_thirdPersonRange import cg_zoomFov import cg_fov import cg_simpleItems import cg_ignore import cg_autoswitch import cg_tracerLength import cg_tracerWidth import cg_tracerChance import cg_viewsize import cg_drawGun import cg_gun_z import cg_gun_y import cg_gun_x import cg_gun_frame import cg_brassTime import cg_addMarks import cg_footsteps import cg_showmiss import cg_noPlayerAnims import cg_nopredict import cg_errorDecay import cg_railTrailTime import cg_debugEvents import cg_debugPosition import cg_debugAnim import cg_animSpeed import cg_draw2D import cg_drawStatus import cg_crosshairHealth import cg_crosshairSize import cg_crosshairY import cg_crosshairX import cg_teamOverlayUserinfo import cg_drawTeamOverlay import cg_drawRewards import cg_drawCrosshairNames import cg_drawCrosshair import cg_drawAmmoWarning import cg_drawIcons import cg_draw3dIcons import cg_drawSnapshot import cg_drawFPS import cg_drawTimer import cg_gibs import cg_shadows import cg_swingSpeed import cg_bobroll import cg_bobpitch import cg_bobup import cg_runroll import cg_runpitch import cg_centertime import cg_markPolys import cg_items import cg_weapons import cg_entities import cg import cgs import BG_PlayerTouchesItem import BG_PlayerStateToEntityStateExtraPolate import BG_PlayerStateToEntityState import BG_TouchJumpPad import BG_AddPredictableEventToPlayerstate import BG_EvaluateTrajectoryDelta import BG_EvaluateTrajectory import BG_CanItemBeGrabbed import BG_FindItemForHoldable import BG_FindItemForPowerup import BG_FindItemForWeapon import BG_FindItem import bg_numItems import bg_itemlist import Pmove import PM_UpdateViewAngles import Com_Printf import Com_Error import Info_NextPair import Info_Validate import Info_SetValueForKey_Big import Info_SetValueForKey import Info_RemoveKey_Big import Info_RemoveKey import Info_ValueForKey import Com_TruncateLongString import va import Q_CountChar import Q_CleanStr import Q_PrintStrlen import Q_strcat import Q_strncpyz import Q_stristr import Q_strupr import Q_strlwr import Q_stricmpn import Q_strncmp import Q_stricmp import Q_isintegral import Q_isanumber import Q_isalpha import Q_isupper import Q_islower import Q_isprint import Com_RandomBytes import Com_SkipCharset import Com_SkipTokens import Com_sprintf import Com_HexStrToInt import Parse3DMatrix import Parse2DMatrix import Parse1DMatrix import SkipRestOfLine import SkipBracedSection import COM_MatchToken import COM_ParseWarning import COM_ParseError import COM_Compress import COM_ParseExt import COM_Parse import COM_GetCurrentParseLine import COM_BeginParseSession import COM_DefaultExtension import COM_CompareExtension import COM_StripExtension import COM_GetExtension import COM_SkipPath import Com_Clamp import PerpendicularVector import AngleVectors import MatrixMultiply import MakeNormalVectors import RotateAroundDirection import RotatePointAroundVector import ProjectPointOnPlane import PlaneFromPoints import AngleDelta import AngleNormalize180 import AngleNormalize360 import AnglesSubtract import AngleSubtract import LerpAngle import AngleMod import BoundsIntersectPoint import BoundsIntersectSphere import BoundsIntersect import BoxOnPlaneSide import SetPlaneSignbits import AxisCopy import AxisClear import AnglesToAxis import vectoangles import Q_crandom import Q_random import Q_rand import Q_acos import Q_log2 import VectorRotate import Vector4Scale import VectorNormalize2 import VectorNormalize import CrossProduct import VectorInverse import VectorNormalizeFast import DistanceSquared import Distance import VectorLengthSquared import VectorLength import VectorCompare import AddPointToBounds import ClearBounds import RadiusFromBounds import NormalizeColor import ColorBytes4 import ColorBytes3 import _VectorMA import _VectorScale import _VectorCopy import _VectorAdd import _VectorSubtract import _DotProduct import ByteToDir import DirToByte import ClampShort import ClampChar import Q_rsqrt import Q_fabs import Q_isnan import axisDefault import vec3_origin import g_color_table import colorDkGrey import colorMdGrey import colorLtGrey import colorWhite import colorCyan import colorMagenta import colorYellow import colorBlue import colorGreen import colorRed import colorBlack import bytedirs import Hunk_AllocDebug import FloatSwap import LongSwap import ShortSwap import CopyLongSwap import CopyShortSwap import qk_acos import qk_fabs import qk_abs import qk_tan import qk_atan2 import qk_cos import qk_sin import qk_sqrt import qk_floor import qk_ceil import qk_memcpy import qk_memset import qk_memmove import qk_sscanf import qk_vsnprintf import qk_strtol import qk_atoi import qk_strtod import qk_atof import qk_toupper import qk_tolower import qk_strncpy import qk_strstr import qk_strrchr import qk_strchr import qk_strcmp import qk_strcpy import qk_strcat import qk_strlen import qk_rand import qk_srand import qk_qsort lit align 1 LABELV $1214 byte 1 37 byte 1 105 byte 1 32 byte 1 82 byte 1 101 byte 1 115 byte 1 101 byte 1 116 byte 1 80 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 69 byte 1 110 byte 1 116 byte 1 105 byte 1 116 byte 1 121 byte 1 32 byte 1 121 byte 1 97 byte 1 119 byte 1 61 byte 1 37 byte 1 102 byte 1 10 byte 1 0 align 1 LABELV $1203 byte 1 116 byte 1 97 byte 1 103 byte 1 95 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 0 align 1 LABELV $1194 byte 1 116 byte 1 97 byte 1 103 byte 1 95 byte 1 116 byte 1 111 byte 1 114 byte 1 115 byte 1 111 byte 1 0 align 1 LABELV $1152 byte 1 66 byte 1 97 byte 1 100 byte 1 32 byte 1 99 byte 1 108 byte 1 105 byte 1 101 byte 1 110 byte 1 116 byte 1 78 byte 1 117 byte 1 109 byte 1 32 byte 1 111 byte 1 110 byte 1 32 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 32 byte 1 101 byte 1 110 byte 1 116 byte 1 105 byte 1 116 byte 1 121 byte 1 0 align 1 LABELV $735 byte 1 66 byte 1 97 byte 1 100 byte 1 32 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 32 byte 1 109 byte 1 111 byte 1 118 byte 1 101 byte 1 109 byte 1 101 byte 1 110 byte 1 116 byte 1 32 byte 1 97 byte 1 110 byte 1 103 byte 1 108 byte 1 101 byte 1 0 align 1 LABELV $664 byte 1 67 byte 1 108 byte 1 97 byte 1 109 byte 1 112 byte 1 32 byte 1 108 byte 1 102 byte 1 45 byte 1 62 byte 1 102 byte 1 114 byte 1 97 byte 1 109 byte 1 101 byte 1 84 byte 1 105 byte 1 109 byte 1 101 byte 1 10 byte 1 0 align 1 LABELV $630 byte 1 65 byte 1 110 byte 1 105 byte 1 109 byte 1 58 byte 1 32 byte 1 37 byte 1 105 byte 1 10 byte 1 0 align 1 LABELV $626 byte 1 66 byte 1 97 byte 1 100 byte 1 32 byte 1 97 byte 1 110 byte 1 105 byte 1 109 byte 1 97 byte 1 116 byte 1 105 byte 1 111 byte 1 110 byte 1 32 byte 1 110 byte 1 117 byte 1 109 byte 1 98 byte 1 101 byte 1 114 byte 1 58 byte 1 32 byte 1 37 byte 1 105 byte 1 0 align 1 LABELV $609 byte 1 77 byte 1 101 byte 1 109 byte 1 111 byte 1 114 byte 1 121 byte 1 32 byte 1 105 byte 1 115 byte 1 32 byte 1 108 byte 1 111 byte 1 119 byte 1 46 byte 1 32 byte 1 85 byte 1 115 byte 1 105 byte 1 110 byte 1 103 byte 1 32 byte 1 100 byte 1 101 byte 1 102 byte 1 101 byte 1 114 byte 1 114 byte 1 101 byte 1 100 byte 1 32 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 46 byte 1 10 byte 1 0 align 1 LABELV $573 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 0 align 1 LABELV $562 byte 1 104 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 0 align 1 LABELV $529 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 0 align 1 LABELV $527 byte 1 103 byte 1 95 byte 1 98 byte 1 108 byte 1 117 byte 1 101 byte 1 116 byte 1 101 byte 1 97 byte 1 109 byte 1 0 align 1 LABELV $525 byte 1 103 byte 1 95 byte 1 114 byte 1 101 byte 1 100 byte 1 116 byte 1 101 byte 1 97 byte 1 109 byte 1 0 align 1 LABELV $523 byte 1 116 byte 1 108 byte 1 0 align 1 LABELV $521 byte 1 116 byte 1 116 byte 1 0 align 1 LABELV $519 byte 1 116 byte 1 0 align 1 LABELV $517 byte 1 108 byte 1 0 align 1 LABELV $515 byte 1 119 byte 1 0 align 1 LABELV $513 byte 1 104 byte 1 99 byte 1 0 align 1 LABELV $511 byte 1 115 byte 1 107 byte 1 105 byte 1 108 byte 1 108 byte 1 0 align 1 LABELV $488 byte 1 99 byte 1 50 byte 1 0 align 1 LABELV $465 byte 1 99 byte 1 49 byte 1 0 align 1 LABELV $462 byte 1 110 byte 1 0 align 1 LABELV $457 byte 1 67 byte 1 71 byte 1 95 byte 1 83 byte 1 101 byte 1 116 byte 1 68 byte 1 101 byte 1 102 byte 1 101 byte 1 114 byte 1 114 byte 1 101 byte 1 100 byte 1 67 byte 1 108 byte 1 105 byte 1 101 byte 1 110 byte 1 116 byte 1 73 byte 1 110 byte 1 102 byte 1 111 byte 1 58 byte 1 32 byte 1 110 byte 1 111 byte 1 32 byte 1 118 byte 1 97 byte 1 108 byte 1 105 byte 1 100 byte 1 32 byte 1 99 byte 1 108 byte 1 105 byte 1 101 byte 1 110 byte 1 116 byte 1 115 byte 1 33 byte 1 10 byte 1 0 align 1 LABELV $391 byte 1 115 byte 1 111 byte 1 117 byte 1 110 byte 1 100 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $378 byte 1 116 byte 1 97 byte 1 103 byte 1 95 byte 1 102 byte 1 108 byte 1 97 byte 1 103 byte 1 0 align 1 LABELV $373 byte 1 68 byte 1 69 byte 1 70 byte 1 65 byte 1 85 byte 1 76 byte 1 84 byte 1 95 byte 1 77 byte 1 79 byte 1 68 byte 1 69 byte 1 76 byte 1 32 byte 1 40 byte 1 37 byte 1 115 byte 1 41 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 114 byte 1 101 byte 1 103 byte 1 105 byte 1 115 byte 1 116 byte 1 101 byte 1 114 byte 1 0 align 1 LABELV $370 byte 1 68 byte 1 69 byte 1 70 byte 1 65 byte 1 85 byte 1 76 byte 1 84 byte 1 95 byte 1 84 byte 1 69 byte 1 65 byte 1 77 byte 1 95 byte 1 77 byte 1 79 byte 1 68 byte 1 69 byte 1 76 byte 1 32 byte 1 47 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 40 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 41 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 114 byte 1 101 byte 1 103 byte 1 105 byte 1 115 byte 1 116 byte 1 101 byte 1 114 byte 1 0 align 1 LABELV $369 byte 1 115 byte 1 97 byte 1 114 byte 1 103 byte 1 101 byte 1 0 align 1 LABELV $361 byte 1 67 byte 1 71 byte 1 95 byte 1 82 byte 1 101 byte 1 103 byte 1 105 byte 1 115 byte 1 116 byte 1 101 byte 1 114 byte 1 67 byte 1 108 byte 1 105 byte 1 101 byte 1 110 byte 1 116 byte 1 77 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 110 byte 1 97 byte 1 109 byte 1 101 byte 1 40 byte 1 32 byte 1 37 byte 1 115 byte 1 44 byte 1 32 byte 1 37 byte 1 115 byte 1 44 byte 1 32 byte 1 37 byte 1 115 byte 1 44 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 41 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 0 align 1 LABELV $342 byte 1 116 byte 1 103 byte 1 97 byte 1 0 align 1 LABELV $339 byte 1 105 byte 1 99 byte 1 111 byte 1 110 byte 1 0 align 1 LABELV $336 byte 1 70 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 97 byte 1 110 byte 1 105 byte 1 109 byte 1 97 byte 1 116 byte 1 105 byte 1 111 byte 1 110 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $333 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 99 byte 1 104 byte 1 97 byte 1 114 byte 1 97 byte 1 99 byte 1 116 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 97 byte 1 110 byte 1 105 byte 1 109 byte 1 97 byte 1 116 byte 1 105 byte 1 111 byte 1 110 byte 1 46 byte 1 99 byte 1 102 byte 1 103 byte 1 0 align 1 LABELV $330 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 97 byte 1 110 byte 1 105 byte 1 109 byte 1 97 byte 1 116 byte 1 105 byte 1 111 byte 1 110 byte 1 46 byte 1 99 byte 1 102 byte 1 103 byte 1 0 align 1 LABELV $329 byte 1 70 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 44 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $326 byte 1 83 byte 1 116 byte 1 114 byte 1 111 byte 1 103 byte 1 103 byte 1 115 byte 1 0 align 1 LABELV $325 byte 1 80 byte 1 97 byte 1 103 byte 1 97 byte 1 110 byte 1 115 byte 1 0 align 1 LABELV $324 byte 1 37 byte 1 115 byte 1 47 byte 1 0 align 1 LABELV $321 byte 1 70 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 44 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $312 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $311 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $306 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 99 byte 1 104 byte 1 97 byte 1 114 byte 1 97 byte 1 99 byte 1 116 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 117 byte 1 112 byte 1 112 byte 1 101 byte 1 114 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $303 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 117 byte 1 112 byte 1 112 byte 1 101 byte 1 114 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $302 byte 1 70 byte 1 97 byte 1 105 byte 1 108 byte 1 101 byte 1 100 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $299 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 99 byte 1 104 byte 1 97 byte 1 114 byte 1 97 byte 1 99 byte 1 116 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 108 byte 1 111 byte 1 119 byte 1 101 byte 1 114 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $296 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 108 byte 1 111 byte 1 119 byte 1 101 byte 1 114 byte 1 46 byte 1 109 byte 1 100 byte 1 51 byte 1 0 align 1 LABELV $288 byte 1 72 byte 1 101 byte 1 97 byte 1 100 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 117 byte 1 114 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $285 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 0 align 1 LABELV $282 byte 1 84 byte 1 111 byte 1 114 byte 1 115 byte 1 111 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 117 byte 1 114 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $279 byte 1 117 byte 1 112 byte 1 112 byte 1 101 byte 1 114 byte 1 0 align 1 LABELV $276 byte 1 76 byte 1 101 byte 1 103 byte 1 32 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 102 byte 1 97 byte 1 105 byte 1 108 byte 1 117 byte 1 114 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $273 byte 1 115 byte 1 107 byte 1 105 byte 1 110 byte 1 0 align 1 LABELV $272 byte 1 108 byte 1 111 byte 1 119 byte 1 101 byte 1 114 byte 1 0 align 1 LABELV $252 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $251 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $241 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 115 byte 1 47 byte 1 0 align 1 LABELV $230 byte 1 99 byte 1 104 byte 1 97 byte 1 114 byte 1 97 byte 1 99 byte 1 116 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 0 align 1 LABELV $220 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $219 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $211 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $210 byte 1 109 byte 1 111 byte 1 100 byte 1 101 byte 1 108 byte 1 115 byte 1 47 byte 1 112 byte 1 108 byte 1 97 byte 1 121 byte 1 101 byte 1 114 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 95 byte 1 37 byte 1 115 byte 1 46 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $200 byte 1 0 align 1 LABELV $199 byte 1 114 byte 1 101 byte 1 100 byte 1 0 align 1 LABELV $198 byte 1 98 byte 1 108 byte 1 117 byte 1 101 byte 1 0 align 1 LABELV $186 byte 1 69 byte 1 114 byte 1 114 byte 1 111 byte 1 114 byte 1 32 byte 1 112 byte 1 97 byte 1 114 byte 1 115 byte 1 105 byte 1 110 byte 1 103 byte 1 32 byte 1 97 byte 1 110 byte 1 105 byte 1 109 byte 1 97 byte 1 116 byte 1 105 byte 1 111 byte 1 110 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $161 byte 1 117 byte 1 110 byte 1 107 byte 1 110 byte 1 111 byte 1 119 byte 1 110 byte 1 32 byte 1 116 byte 1 111 byte 1 107 byte 1 101 byte 1 110 byte 1 32 byte 1 39 byte 1 37 byte 1 115 byte 1 39 byte 1 32 byte 1 105 byte 1 110 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $158 byte 1 102 byte 1 105 byte 1 120 byte 1 101 byte 1 100 byte 1 116 byte 1 111 byte 1 114 byte 1 115 byte 1 111 byte 1 0 align 1 LABELV $155 byte 1 102 byte 1 105 byte 1 120 byte 1 101 byte 1 100 byte 1 108 byte 1 101 byte 1 103 byte 1 115 byte 1 0 align 1 LABELV $144 byte 1 115 byte 1 101 byte 1 120 byte 1 0 align 1 LABELV $135 byte 1 104 byte 1 101 byte 1 97 byte 1 100 byte 1 111 byte 1 102 byte 1 102 byte 1 115 byte 1 101 byte 1 116 byte 1 0 align 1 LABELV $132 byte 1 66 byte 1 97 byte 1 100 byte 1 32 byte 1 102 byte 1 111 byte 1 111 byte 1 116 byte 1 115 byte 1 116 byte 1 101 byte 1 112 byte 1 115 byte 1 32 byte 1 112 byte 1 97 byte 1 114 byte 1 109 byte 1 32 byte 1 105 byte 1 110 byte 1 32 byte 1 37 byte 1 115 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $131 byte 1 101 byte 1 110 byte 1 101 byte 1 114 byte 1 103 byte 1 121 byte 1 0 align 1 LABELV $128 byte 1 109 byte 1 101 byte 1 99 byte 1 104 byte 1 0 align 1 LABELV $125 byte 1 102 byte 1 108 byte 1 101 byte 1 115 byte 1 104 byte 1 0 align 1 LABELV $122 byte 1 98 byte 1 111 byte 1 111 byte 1 116 byte 1 0 align 1 LABELV $118 byte 1 110 byte 1 111 byte 1 114 byte 1 109 byte 1 97 byte 1 108 byte 1 0 align 1 LABELV $117 byte 1 100 byte 1 101 byte 1 102 byte 1 97 byte 1 117 byte 1 108 byte 1 116 byte 1 0 align 1 LABELV $112 byte 1 102 byte 1 111 byte 1 111 byte 1 116 byte 1 115 byte 1 116 byte 1 101 byte 1 112 byte 1 115 byte 1 0 align 1 LABELV $104 byte 1 70 byte 1 105 byte 1 108 byte 1 101 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 116 byte 1 111 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 110 byte 1 103 byte 1 10 byte 1 0 align 1 LABELV $98 byte 1 85 byte 1 110 byte 1 107 byte 1 110 byte 1 111 byte 1 119 byte 1 110 byte 1 32 byte 1 99 byte 1 117 byte 1 115 byte 1 116 byte 1 111 byte 1 109 byte 1 32 byte 1 115 byte 1 111 byte 1 117 byte 1 110 byte 1 100 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $83 byte 1 42 byte 1 116 byte 1 97 byte 1 117 byte 1 110 byte 1 116 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $82 byte 1 42 byte 1 102 byte 1 97 byte 1 108 byte 1 108 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $81 byte 1 42 byte 1 100 byte 1 114 byte 1 111 byte 1 119 byte 1 110 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $80 byte 1 42 byte 1 103 byte 1 97 byte 1 115 byte 1 112 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $79 byte 1 42 byte 1 102 byte 1 97 byte 1 108 byte 1 108 byte 1 105 byte 1 110 byte 1 103 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $78 byte 1 42 byte 1 112 byte 1 97 byte 1 105 byte 1 110 byte 1 49 byte 1 48 byte 1 48 byte 1 95 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $77 byte 1 42 byte 1 112 byte 1 97 byte 1 105 byte 1 110 byte 1 55 byte 1 53 byte 1 95 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $76 byte 1 42 byte 1 112 byte 1 97 byte 1 105 byte 1 110 byte 1 53 byte 1 48 byte 1 95 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $75 byte 1 42 byte 1 112 byte 1 97 byte 1 105 byte 1 110 byte 1 50 byte 1 53 byte 1 95 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $74 byte 1 42 byte 1 106 byte 1 117 byte 1 109 byte 1 112 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $73 byte 1 42 byte 1 100 byte 1 101 byte 1 97 byte 1 116 byte 1 104 byte 1 51 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $72 byte 1 42 byte 1 100 byte 1 101 byte 1 97 byte 1 116 byte 1 104 byte 1 50 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0 align 1 LABELV $71 byte 1 42 byte 1 100 byte 1 101 byte 1 97 byte 1 116 byte 1 104 byte 1 49 byte 1 46 byte 1 119 byte 1 97 byte 1 118 byte 1 0
; A024306: a(n) = s(1)t(n) + s(2)t(n-1) + ... + s(k)t(n+1-k), where k=[ (n+1)/2) ], s = (natural numbers >= 2), t = (natural numbers >= 3). ; 6,8,22,27,52,61,100,114,170,190,266,293,392,427,552,596,750,804,990,1055,1276,1353,1612,1702,2002,2106,2450,2569,2960,3095,3536,3688,4182,4352,4902,5091,5700,5909,6580,6810,7546,7798,8602,8877,9752,10051,11000,11324 mov $2,4 mov $3,$0 add $0,1 add $2,$0 add $3,1 lpb $0 sub $0,1 add $3,$2 add $1,$3 mov $4,$0 trn $0,1 mov $2,$4 lpe mov $0,$1
/* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2020 Scientific Computing and Imaging Institute, University of Utah. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <Interface/Modules/Fields/CalculateMeshCenterDialog.h> #include <Core/Algorithms/Legacy/Fields/MeshDerivatives/CalculateMeshCenterAlgo.h> #include <Dataflow/Network/ModuleStateInterface.h> ///TODO: extract into intermediate using namespace SCIRun::Gui; using namespace SCIRun::Dataflow::Networks; using namespace SCIRun::Core::Algorithms::Fields; CalculateMeshCenterDialog::CalculateMeshCenterDialog(const std::string& name, ModuleStateHandle state, QWidget* parent /* = 0 */) : ModuleDialogGeneric(state, parent) { setupUi(this); setWindowTitle(QString::fromStdString(name)); fixSize(); addComboBoxManager(method_, Parameters::Method, {{"Average of Node Locations", "nodeCenter"}, {"Average of Element Centers", "elemCenter"}, {"Volumetric Center", "weightedElemCenter"}, {"Bounding Box Center","boundingBoxCenter"}, {"Middle Index Node","midNodeIndex"}, {"Middle Index Element","midElemIndex"}}); }
#ifndef FLOAT_PARAM_CPP #define FLOAT_PARAM_CPP #include "linear_fill_numeric_param.cpp" #include <string> class FloatParam : public LinearFillNumericParam { public: using LinearFillNumericParam::LinearFillNumericParam; std::string GetFormattedLabel() { int dec = std::abs((int)((GetValue() - (int)GetValue()) * 100)); return this->label + ": " + (std::to_string( (int)GetValue())) + "." + (dec < 10 ? "0" : "") + std::to_string(dec); } }; #endif
;/* ; * Z88 Standard Library ; * ; * long __FASTCALL__ atol(char *str) ; * ; * djm 25/2/2001 ; * ; * $Id: atol.asm,v 1.6 2016/03/06 21:56:32 dom Exp $ ; */ ; Removed C front end to make FASTCALL, consistent with ; all other targets. Was atol.c, that file now removed. ; 12.2006 aralbrec SECTION code_clib PUBLIC atol PUBLIC _atol PUBLIC ASMDISP_ATOL .atol ._atol INCLUDE "integer.def" ex de,hl push hl push hl ; make space for a temporary long on stack ld hl,0 add hl,sp ex de,hl ; hl = char*, de = & long ld b,254 call_oz(gn_gdn) ; preserves ix pop hl pop de ret z ; was a number ld hl,0 ld d,h ld e,l ret DEFC ASMDISP_ATOL = 0
; ; ZX IF1 & Microdrive functions ; ; Stefano Bodrato - Oct. 2004 ; ; ; if1_checkblock: ; - check the loaded block for integrity ; - other various checks ; ; $Id: if1_checkblock.asm,v 1.1 2008/06/29 08:25:47 aralbrec Exp $ ; XLIB if1_checkblock LIB if1_checksum XREF mdvbuffer XDEF if1_sect_read XDEF if1_verifymode status: defb 0 if1_sect_read: defb 0 if1_verifymode: defb 0 if1_checkblock: push ix pop hl ld de,43h ; RECFLAG add hl,de ld bc,14 call if1_checksum ld hl,status ; D70E ld (hl),1 ; jr nz,chksector inc (hl) ld a,(ix+43h) ; RECFLG or (ix+46h) ; 2nd byte of RECLEN and 2 jr z,chk1 bit 1,(ix+43h) ; RECFLG jr z,chksector ld a,(ix+47h) ; RECNAM: file name or a jr nz,chksector chk1: ld a,4 jr chk2 chksector: push ix pop hl ld de,52h ; CHDATA add hl,de ld bc,512 ; 512 bytes of data call if1_checksum ; verify checksum ld a,(status) jr nz,chk2 inc a inc a chk2: ld hl,if1_sect_read ; flag for "sector read" cp (hl) ret c ret z ld (hl),a ld b,a ld a,(if1_verifymode) bit 2,a ld a,b ret nz ; Copy microdrive channel to work buffer push ix pop hl ld de,(mdvbuffer) ld bc,595 ldir ret
; A080085: Number of factors of 2 in the factorial of the n-th prime, counted with multiplicity. ; 1,1,3,4,8,10,15,16,19,25,26,34,38,39,42,49,54,56,64,67,70,74,79,85,94,97,98,102,104,109,120,128,134,135,145,146,152,159,162,168,174,176,184,190,193,194,206,216,222,224,228,232,236,244,255,259,265,266,273,277,278,289,302,305,308,311,326,333,341,343,349,353,360,367,372,375,385,392,397,404,414,416,424,428,432,436,445,452,455,456,461,471,480,484,492,495,501,518,519,536 seq $0,40 ; The prime numbers. div $0,2 lpb $0 add $1,$0 div $0,2 lpe mov $0,$1
; Building the project ; xa tilt.asm -C -o tilt\(E\).nes ; ; Building raw ROMs ; xa tilt.asm -DNO_INES_HEADER -C -o tilt_prg.bin ; Constants depending on mapper #define DEFAULT_MAPPER #ifdef MAPPER_UNROM #undef DEFAULT_MAPPER MAPPER_NUMBER=2 SUBMAPPER_NUMBER=1 MAPPER_BATTERY_FLAG=1 #endif #ifdef MAPPER_UNROM512 #undef DEFAULT_MAPPER MAPPER_NUMBER=30 SUBMAPPER_NUMBER=0 MAPPER_BATTERY_FLAG=1 #endif #ifdef MAPPER_RAINBOW512 #undef DEFAULT_MAPPER MAPPER_NUMBER=3870 SUBMAPPER_NUMBER=0 MAPPER_BATTERY_FLAG=1 #endif #ifdef DEFAULT_MAPPER #undef DEFAULT_MAPPER #define MAPPER_RAINBOW MAPPER_NUMBER=3871 SUBMAPPER_NUMBER=0 MAPPER_BATTERY_FLAG=0 #endif ; iNES header #ifndef NO_INES_HEADER #include "nine/ines_header.asm" #endif ; No-data declarations #include "game/constants.asm" #include "nine/macros.asm" #include "game/macros.asm" #include "game/rainbow_lib_macros.asm" #include "nine/nes_labels.asm" #include "game/mem_labels.asm" ; PRG-ROM #ifndef NO_PRG_ROM #include "game/extra_banks.asm" #echo #echo ===== FIXED-BANK ===== * = $c000 ; $c000 is where the PRG fixed bank rom is mapped in CPU space, so code position is relative to it code_begin: #include "game/logic/animation_opcodes.asm" #include "nine/prg_rom/prg_rom.asm" #include "game/logic/logic.asm" code_end: #include "game/data/fixed-bank-data.asm" #ifdef SERVER_BYTECODE #include "game/logic/server_bytecode_extras.asm" #endif #include "game/fixed_bank_filler.asm" #endif
;SHARED SPRITE PALETTE FIX ; ;This is a repair so that sprites that previously shared Link's palette ;no longer share his palette. In the vanilla game this was not an issue ;but with custom sprites some very strange color transitions can occur. ; ;The convention in the comments here is that bits are labeled [7:0] ; ;Written by Artheau ;during a cold morning on Oct. 29, 2018 ; ;Bee (Credits) ;Seems like this was a bug in the vanilla game ;This puts the bee on the palette it uses in the rest of the game (bits 1-3) ;Appears virtually identical org $0ECFBA db $76 ;Chests (Credits) ;Gives them a much more natural color (bits 1-3) ;There is one hex value for each chest ;The result is a visual improvement org $0ED35A db $37 org $0ED362 db $37 org $0ED36A db $37 ;Sweeping Woman (In-Game) ;Puts her on the same color of red that she is in the ending credits (bits 1-3) org $DB383 db $07 ;Ravens (Credits) ;Puts them on the same color as they are in-game (bits 1-3) org $0ED653 db $09 ;Running Man (In-Game) ;Puts the jacket on the same palette as the hat ;bits 1-3 are XORed with the base palette (currently 0b011) org $05E9DA db $00 org $05E9EA db $40 org $05E9FA db $00 org $05EA0A db $40 org $05EA1A db $00 org $05EA2A db $00 org $05EA3A db $40 org $05EA4A db $40 ;Running Man (Credits Only) ;Puts the jacket and the arm on the same palette as the hat (bits 1-3) org $0ECE72 db $47 org $0ECE8A db $07 org $0ECE92 db $07 org $0ECEA2 db $47 org $0ECEAA db $07 org $0ECEBA db $47 ;Hoarder (when under a stone) ;Complete fix ;This was a bug that made the hoarder ignore its palette setting only when it was under a rock org $06AAAC db $F0 ;But now we have to give it the correct palette info (bits 1-3) org $06AA46 db $0B org $06AA48 db $0B org $06AA4A db $0B org $06AA4C db $0B org $06AA4E db $4B ;Thief (friendly thief in cave) ;There is a subtle difference in color here (more pastel) ;His palette is given by bits 1-3 org $0DC322 db $07 ;set him to red ;Alternate palette options: ;db $09 ;lavender ;db $0B ;green ;db $0D ;yellow (same as he is in the credits) ;Pedestal Pull ;This edit DOES create a visual difference ;so I also present some alternate options ; ; ;Option A: Fix the red pendant, but now it ignores shadows ;and as a result, looks bugged ;org $05893D ;db $07 ; ; ;Option B: Make the red pendant a yellow pendant ;org $05893D ;db $0D ; ; ;Option C: Also change the other pendants so that they all ;ignore shadows. This looks better because they appear to ;glow even brighter ;BUT I had to compromise on the color of the blue pendant org $058933 db $05 ;change palette of blue pendant org $058938 db $01 ;change palette of green pendant org $05893D db $07 ;change palette of red pendant ;the pendants travel in a direction determined by their color ;so option C also requires a fix to their directional movement org $058D21 db $04 org $058D22 db $04 org $058D23 db $FC org $058D24 db $00 org $058D25 db $FE org $058D26 db $FE org $058D27 db $FE org $058D28 db $FC ;Blind Maiden ;Previously she switched palettes when she arrived at the light (although it was very subtle) ;Here we just set it so that she starts at that color org $0DB410 db $4B ;sets the palette of the prison sprite (bits 1-3) org $09A8EB db $05 ;sets the palette of the tagalong (bits 0-2) ;Crystal Maiden (credits) ;One of the crystal maidens was on Link's palette, but only in the end sequence ;palette given by bits 1-3 org $0EC8C3 db $37 ;Cukeman (Everywhere) ;This guy is such a bugfest. Did you know that his body remains an enemy and if you try talking to him, ;you have to target the overlaid sprite that only has eyeballs and a mouth? ;This is why you can still be damaged by him. In any case, I digress. Let's talk edits. ; ;These edits specifically target the color of his lips ;Bits 1-3 are XORed with his base ID palette (0b100) ;and the base palette cannot be changed without breaking buzzblobs (i.e. green dancing pickles) org $1AFA93 db $0F org $1AFAAB db $0F org $1AFAC3 db $0F org $1AFADB db $0F org $1AFAF3 db $0F org $1AFB0B db $0F ;BUT there is a very specific ramification of the above edits: ;Because his lips were moved to the red palette, his lips ;no longer respond to shadowing effects ;(like how red rupees appear in lost woods) ;this will only be apparent if enemizer places him in areas like lost woods ;or in the end credits sequence during his short cameo, ;so the line below replaces him in the end sequence ;with a buzzblob org $0ED664 db $00 ;number of cukeman in the scene (up to 4)
#include "ace/Monitor_Control/Packets_Sent_Monitor.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE { namespace Monitor_Control { const char* Packets_Sent_Monitor::default_name_ = "OS/Network/PacketsSent"; Packets_Sent_Monitor::Packets_Sent_Monitor (const char* name) : Monitor_Base (name, Monitor_Control_Types::MC_NUMBER) #if defined (ACE_HAS_WIN32_PDH) , Windows_Multi_Instance_Monitor ( ACE_TEXT ("\\Network Interface(*)\\Packets Sent/sec")) #elif defined (ACE_LINUX) || defined (AIX) , Linux_Network_Interface_Monitor ( " %*[^:]: %*u %*u %*u %*u %*u %*u %*u %*u %*u %lu") /// Scan format for /proc/net/dev #elif defined (ACE_HAS_KSTAT) , Solaris_Network_Interface_Monitor (ACE_TEXT ("opackets")) #elif defined (__NetBSD__) || defined (__OpenBSD__) , BSD_Network_Interface_Monitor (ACE_TEXT ("opackets")) #elif defined (__FreeBSD__) || defined (__Lynx__) , FreeBSD_Network_Interface_Monitor (ACE_TEXT ("opackets")) #endif {} void Packets_Sent_Monitor::update (void) { this->update_i (); /// On some platforms, value_ is an ACE_UINT64. this->receive (static_cast<double> (this->value_)); } const char* Packets_Sent_Monitor::default_name (void) { return Packets_Sent_Monitor::default_name_; } void Packets_Sent_Monitor::clear_i (void) { this->clear_impl (); this->Monitor_Base::clear_i (); } } } ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
// Copyright 1995, 2007, 2008, 2012-2014, 2021 by Jon Dart // Stand-alone console executable to build "ecodata.cpp" file // from "eco" text file. #include "board.h" #include "notation.h" #include "legal.h" #include "globals.h" #include "scoring.h" #include <cctype> #include <iostream> #include <fstream> #include <regex> #include <sstream> #include <unordered_map> void charout(unsigned char c) { if (c == '"') { std::cout << '\\' << '"'; } else if (c == '\\') { std::cout << '\\' << '\\'; } else if (c >= ' ' && (int)c < 127) { std::cout << c; } else { std::cout << '\\'; std::ios_base::fmtflags original_flags = std::cout.flags(); std::cout.fill('0'); std::streamsize oldwidth = std::cout.width(); std::cout.width(3); std::cout << std::oct << (unsigned)c; std::cout.width(oldwidth); std::cout.fill(' '); std::cout.flags(original_flags); } } static void write_64(hash_t h, std::ostream &out) { std::ios_base::fmtflags original_flags = out.flags(); out << "0x" << std::hex << h << "ULL"; out.flags(original_flags); } static std::unordered_map<hash_t,unsigned> hashes; static const auto pattern = std::regex("^([A-Z\\d]+)\\s+(.+[\\w\\d\\-\\+#])(\\s+\\\"([^\"]*).*)?$"); int do_eco(const std::string &eco_line, unsigned line) { if (eco_line.empty()) return 0; ColorType side = White; Board board; int movecount = 0; // Parse the line std::string code, name, moves, text; std::smatch match; if (std::regex_match(eco_line,match,pattern)) { assert(match.size()>=3); name = ""; // may be missing code = match[1]; // first match is whole string moves = match[2]; if (match.size() > 4) { name = match[4]; // inner group } // parse moves std::stringstream s(moves); while (s >> text) { // skip numbers if (isdigit(text[0])) continue; // parse the move Move m = Notation::value(board,side,Notation::InputFormat::SAN,text); if (IsNull(m) || !legalMove(board,StartSquare(m),DestSquare(m))) { std::cerr << "Illegal or invalid move: " << text << std::endl; return -1; } else { ++movecount; board.doMove(m); } side = OppositeColor(side); } } else { std::cerr << "Failed to parse line " << line << std::endl; return -1; } auto hashMatch = hashes.find(board.hashCode()); if (hashMatch != hashes.end()) { std::cerr << "warning: duplicate hash, lines " << (*hashMatch).second << " & " << line << std::endl; } hashes.emplace(std::pair<hash_t,unsigned>(board.hashCode(),line)); std::cout << '{' << '"' << code << '"' << ", "; write_64(board.hashCode(),std::cout); std::cout << ", "; if (name.length()) std::cout << '"' << name << '"'; else std::cout << '"' << '"'; std::cout << "},"; std::cout << std::endl; return 0; } int CDECL main(int argc, char **argv) { if (argc ==1) { std::cerr << "Usage: makeeco eco_file" << std::endl; return -1; } Bitboard::init(); Board::init(); globals::initOptions(); Attacks::init(); Scoring::init(); if (!globals::initGlobals(false)) { globals::cleanupGlobals(); exit(-1); } atexit(globals::cleanupGlobals); std::ifstream eco_file( argv[argc-1], std::ios::in); if (!eco_file.good()) { std::cerr << "Cannot open file: " << argv[argc-1] << std::endl; return -1; } Board b; std::cout << "// This is a machine-generated file. Do not edit." << std::endl; std::cout << std::endl; std::cout << "#include \"ecodata.h\"" << std::endl << std::endl; std::cout << "const struct ECOData eco_codes[] =" << std::endl; std::cout << "{{" << '"' << "A00" << '"' << ", "; write_64(b.hashCode(),std::cout); std::cout << ", " << '"' << '"' << "}," << std::endl; unsigned lines = 1; while (eco_file.good() && !eco_file.eof()) { std::string eco_line; getline(eco_file,eco_line); if (do_eco(eco_line,lines)) { std::cerr << "error in ECO file, line " << lines << std::endl; } ++lines; } std::cout << "{0,0," << '"' << '"' << "}};" << std::endl; return 0; }
/* * TS Elements * Copyright 2015-2018 M. Newhouse * Released under the MIT license. */ #pragma once #include "terrain_definition.hpp" #include <vector> #include <cstdint> namespace ts { namespace resources { // The TerrainLibrary represents, well, a library of terrains. // It exposes a fixed-size array of regular terrains, which define various properties // that affect the handling. class TerrainLibrary { public: void define_terrain(const TerrainDefinition& terrain); const TerrainDefinition& terrain(TerrainId terrain_id) const; static constexpr std::uint32_t max_terrains = 256; private: std::vector<TerrainDefinition> terrains_ = std::vector<TerrainDefinition>(max_terrains); }; } }
; A124099: Sum_(x^i*y^j*z^k) with i + j + k = m and (x, y, z) = the primitive Pythagorean triple (5, 12, 13). ; Submitted by Jon Maiga ; 1,30,619,10920,177061,2726130,40547359,588485820,8387148121,117876868230,1638536364499,22574666496720,308755233696781,4197234089634330,56765041887676039,764357559726523620 add $0,2 lpb $0 sub $0,1 div $1,2 max $2,26 mul $2,12 mul $3,13 add $3,$1 mul $1,10 add $1,$2 lpe mov $0,$3 div $0,156
.byte $01 ; Unknown purpose .byte OBJ_REDTROOPA, $13, $12 .byte OBJ_REDTROOPA, $1A, $18 .byte OBJ_WOODENPLATFORMFALL, $21, $13 .byte OBJ_FLYINGREDPARATROOPA, $30, $11 .byte OBJ_GREENTROOPA, $36, $18 .byte OBJ_WOODENPLATUNSTABLE, $4D, $18 .byte OBJ_FLYINGREDPARATROOPA, $5C, $0D .byte OBJ_OSCILLATING_HS, $74, $14 .byte OBJ_WOODENPLATUNSTABLE, $78, $12 .byte OBJ_FLYINGREDPARATROOPA, $82, $15 .byte OBJ_ENDLEVELCARD, $98, $15 .byte OBJ_GREENTROOPA, $98, $18 .byte $FF ; Terminator
;; ;; Copyright (c) 2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %include "include/os.asm" [bits 64] default rel section .data ;; Ethernet FCS CRC32 0x04c11db7 ;; http://www.ietf.org/rfc/rfc1952.txt align 64 MKGLOBAL(crc32_ethernet_fcs_const,data,internal) crc32_ethernet_fcs_const: dq 0x00000000e95c1271, 0x00000000ce3371cb ; 2048-bits fold dq 0x00000000910eeec1, 0x0000000033fff533 ; 1024-bits fold dq 0x000000000cbec0ed, 0x0000000031f8303f ; 896-bits fold dq 0x0000000057c54819, 0x00000000df068dc2 ; 768-bits fold dq 0x00000000ae0b5394, 0x000000001c279815 ; 640-bits fold dq 0x000000001d9513d7, 0x000000008f352d95 ; 512-bits fold dq 0x00000000af449247, 0x000000003db1ecdc ; 384-bits fold dq 0x0000000081256527, 0x00000000f1da05aa ; 256-bits fold dq 0x00000000ccaa009e, 0x00000000ae689191 ; 128-bits fold dq 0x0000000000000000, 0x0000000000000000 ; padding dq 0x00000000ccaa009e, 0x00000000b8bc6765 ; 128-bits to 64-bits fold dq 0x00000001f7011640, 0x00000001db710640 ; 64-bits to 32-bits reduction ;; CRC16 X25 CCITT 0x1021 / initial value = 0xffff align 64 MKGLOBAL(crc16_x25_ccitt_const,data,internal) crc16_x25_ccitt_const: dq 0x0000000000009a19, 0x0000000000002df8 ; 2048-b fold dq 0x00000000000068af, 0x000000000000b6c9 ; 1024-b fold dq 0x000000000000c64f, 0x000000000000cd95 ; 896-b fold dq 0x000000000000d341, 0x000000000000b8f2 ; 768-b fold dq 0x0000000000000842, 0x000000000000b072 ; 640-b fold dq 0x00000000000047e3, 0x000000000000922d ; 512-b fold dq 0x0000000000000e3a, 0x0000000000004d7a ; 384-b fold dq 0x0000000000005b44, 0x0000000000007762 ; 256-b fold dq 0x00000000000081bf, 0x0000000000008e10 ; 128-b fold dq 0x0000000000000000, 0x0000000000000000 ; padding dq 0x00000000000081bf, 0x0000000000001cbb ; 128-bits to 64-bits fold dq 0x000000011c581910, 0x0000000000010810 ; 64-bits to 32-bits reduction %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %r9 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x1de66, %r11 nop nop nop inc %rdi mov (%r11), %r9 nop nop nop nop nop cmp $49823, %r14 lea addresses_UC_ht+0x105a, %r12 nop nop nop nop nop and $25192, %r11 movups (%r12), %xmm2 vpextrq $1, %xmm2, %rax nop nop xor $38404, %r14 lea addresses_normal_ht+0x16466, %rax nop nop xor %rbp, %rbp vmovups (%rax), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %rdi nop nop nop nop sub %r11, %r11 lea addresses_A_ht+0xe466, %rsi lea addresses_WT_ht+0x1ec66, %rdi nop nop xor %r12, %r12 mov $59, %rcx rep movsb nop dec %r11 lea addresses_A_ht+0x8166, %r9 nop nop nop nop and %rcx, %rcx mov (%r9), %r14 nop nop nop nop nop add $52575, %r14 lea addresses_WT_ht+0xf5d6, %r9 nop nop nop nop add $17810, %rax mov $0x6162636465666768, %r12 movq %r12, %xmm2 vmovups %ymm2, (%r9) nop nop nop xor %rbp, %rbp lea addresses_WC_ht+0x158c6, %rsi lea addresses_WT_ht+0x8376, %rdi dec %r14 mov $84, %rcx rep movsb nop nop nop cmp $62072, %rdi lea addresses_normal_ht+0x1057e, %rsi lea addresses_UC_ht+0xeedb, %rdi nop nop and $19170, %rbp mov $53, %rcx rep movsl nop nop nop nop nop dec %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %rbp push %rbx push %rcx push %rsi // Faulty Load lea addresses_US+0xf466, %rsi nop nop nop and %rcx, %rcx mov (%rsi), %ebp lea oracles, %rbx and $0xff, %rbp shlq $12, %rbp mov (%rbx,%rbp,1), %rbp pop %rsi pop %rcx pop %rbx pop %rbp pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_US', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}} {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'00': 91} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A025774: Expansion of 1/((1-x)(1-x^4)(1-x^9)). ; 1,1,1,1,2,2,2,2,3,4,4,4,5,6,6,6,7,8,9,9,10,11,12,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,36,38,39,40,42,44,45,46,48,50,52,53,55,57,59,60,62 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 mov $2,80 mov $3,$0 mov $0,44 add $2,$3 mov $4,$2 sub $4,4 mul $4,2 lpb $0 mov $0,$4 div $0,9 lpe div $4,8 mov $2,$4 sub $2,$0 mov $6,$2 sub $6,2 add $1,$6 lpe mov $0,$1
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Yiffcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "db.h" #include "net.h" #include "init.h" #include "addrman.h" #include "ui_interface.h" #include "script.h" #ifdef WIN32 #include <string.h> #endif #ifdef USE_UPNP #include <miniupnpc/miniwget.h> #include <miniupnpc/miniupnpc.h> #include <miniupnpc/upnpcommands.h> #include <miniupnpc/upnperrors.h> #endif // Dump addresses to peers.dat every 15 minutes (900s) #define DUMP_ADDRESSES_INTERVAL 900 using namespace std; using namespace boost; static const int MAX_OUTBOUND_CONNECTIONS = 8; bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); struct LocalServiceInfo { int nScore; int nPort; }; // // Global state variables // bool fDiscover = true; uint64 nLocalServices = NODE_NETWORK; static CCriticalSection cs_mapLocalHost; static map<CNetAddr, LocalServiceInfo> mapLocalHost; static bool vfReachable[NET_MAX] = {}; static bool vfLimited[NET_MAX] = {}; static CNode* pnodeLocalHost = NULL; static CNode* pnodeSync = NULL; uint64 nLocalHostNonce = 0; static std::vector<SOCKET> vhListenSocket; CAddrMan addrman; int nMaxConnections = 125; vector<CNode*> vNodes; CCriticalSection cs_vNodes; map<CInv, CDataStream> mapRelay; deque<pair<int64, CInv> > vRelayExpiration; CCriticalSection cs_mapRelay; limitedmap<CInv, int64> mapAlreadyAskedFor(MAX_INV_SZ); static deque<string> vOneShots; CCriticalSection cs_vOneShots; set<CNetAddr> setservAddNodeAddresses; CCriticalSection cs_setservAddNodeAddresses; vector<std::string> vAddedNodes; CCriticalSection cs_vAddedNodes; static CSemaphore *semOutbound = NULL; void AddOneShot(string strDest) { LOCK(cs_vOneShots); vOneShots.push_back(strDest); } unsigned short GetListenPort() { return (unsigned short)(GetArg("-port", GetDefaultPort())); } void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd) { // Filter out duplicate requests if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd) return; pindexLastGetBlocksBegin = pindexBegin; hashLastGetBlocksEnd = hashEnd; PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd); } // find 'best' local address for a particular peer bool GetLocal(CService& addr, const CNetAddr *paddrPeer) { if (fNoListen) return false; int nBestScore = -1; int nBestReachability = -1; { LOCK(cs_mapLocalHost); for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++) { int nScore = (*it).second.nScore; int nReachability = (*it).first.GetReachabilityFrom(paddrPeer); if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) { addr = CService((*it).first, (*it).second.nPort); nBestReachability = nReachability; nBestScore = nScore; } } } return nBestScore >= 0; } // get best local address for a particular peer as a CAddress CAddress GetLocalAddress(const CNetAddr *paddrPeer) { CAddress ret(CService("0.0.0.0",0),0); CService addr; if (GetLocal(addr, paddrPeer)) { ret = CAddress(addr); ret.nServices = nLocalServices; ret.nTime = GetAdjustedTime(); } return ret; } bool RecvLine(SOCKET hSocket, string& strLine) { strLine = ""; loop { char c; int nBytes = recv(hSocket, &c, 1, 0); if (nBytes > 0) { if (c == '\n') continue; if (c == '\r') return true; strLine += c; if (strLine.size() >= 9000) return true; } else if (nBytes <= 0) { boost::this_thread::interruption_point(); if (nBytes < 0) { int nErr = WSAGetLastError(); if (nErr == WSAEMSGSIZE) continue; if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) { MilliSleep(10); continue; } } if (!strLine.empty()) return true; if (nBytes == 0) { // socket closed printf("socket closed\n"); return false; } else { // socket error int nErr = WSAGetLastError(); printf("recv failed: %d\n", nErr); return false; } } } } // used when scores of local addresses may have changed // pushes better local address to peers void static AdvertizeLocal() { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (pnode->fSuccessfullyConnected) { CAddress addrLocal = GetLocalAddress(&pnode->addr); if (addrLocal.IsRoutable() && (CService)addrLocal != (CService)pnode->addrLocal) { pnode->PushAddress(addrLocal); pnode->addrLocal = addrLocal; } } } } void SetReachable(enum Network net, bool fFlag) { LOCK(cs_mapLocalHost); vfReachable[net] = fFlag; if (net == NET_IPV6 && fFlag) vfReachable[NET_IPV4] = true; } // learn a new local address bool AddLocal(const CService& addr, int nScore) { if (!addr.IsRoutable()) return false; if (!fDiscover && nScore < LOCAL_MANUAL) return false; if (IsLimited(addr)) return false; printf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore); { LOCK(cs_mapLocalHost); bool fAlready = mapLocalHost.count(addr) > 0; LocalServiceInfo &info = mapLocalHost[addr]; if (!fAlready || nScore >= info.nScore) { info.nScore = nScore + (fAlready ? 1 : 0); info.nPort = addr.GetPort(); } SetReachable(addr.GetNetwork()); } AdvertizeLocal(); return true; } bool AddLocal(const CNetAddr &addr, int nScore) { return AddLocal(CService(addr, GetListenPort()), nScore); } /** Make a particular network entirely off-limits (no automatic connects to it) */ void SetLimited(enum Network net, bool fLimited) { if (net == NET_UNROUTABLE) return; LOCK(cs_mapLocalHost); vfLimited[net] = fLimited; } bool IsLimited(enum Network net) { LOCK(cs_mapLocalHost); return vfLimited[net]; } bool IsLimited(const CNetAddr &addr) { return IsLimited(addr.GetNetwork()); } /** vote for a local address */ bool SeenLocal(const CService& addr) { { LOCK(cs_mapLocalHost); if (mapLocalHost.count(addr) == 0) return false; mapLocalHost[addr].nScore++; } AdvertizeLocal(); return true; } /** check whether a given address is potentially local */ bool IsLocal(const CService& addr) { LOCK(cs_mapLocalHost); return mapLocalHost.count(addr) > 0; } /** check whether a given address is in a network we can probably connect to */ bool IsReachable(const CNetAddr& addr) { LOCK(cs_mapLocalHost); enum Network net = addr.GetNetwork(); return vfReachable[net] && !vfLimited[net]; } bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const char* pszKeyword, CNetAddr& ipRet) { SOCKET hSocket; if (!ConnectSocket(addrConnect, hSocket)) return error("GetMyExternalIP() : connection to %s failed", addrConnect.ToString().c_str()); send(hSocket, pszGet, strlen(pszGet), MSG_NOSIGNAL); string strLine; while (RecvLine(hSocket, strLine)) { if (strLine.empty()) // HTTP response is separated from headers by blank line { loop { if (!RecvLine(hSocket, strLine)) { closesocket(hSocket); return false; } if (pszKeyword == NULL) break; if (strLine.find(pszKeyword) != string::npos) { strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword)); break; } } closesocket(hSocket); if (strLine.find("<") != string::npos) strLine = strLine.substr(0, strLine.find("<")); strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r")); while (strLine.size() > 0 && isspace(strLine[strLine.size()-1])) strLine.resize(strLine.size()-1); CService addr(strLine,0,true); printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str()); if (!addr.IsValid() || !addr.IsRoutable()) return false; ipRet.SetIP(addr); return true; } } closesocket(hSocket); return error("GetMyExternalIP() : connection closed"); } bool GetMyExternalIP(CNetAddr& ipRet) { CService addrConnect; const char* pszGet; const char* pszKeyword; for (int nLookup = 0; nLookup <= 1; nLookup++) for (int nHost = 1; nHost <= 2; nHost++) { // We should be phasing out our use of sites like these. If we need // replacements, we should ask for volunteers to put this simple // php file on their web server that prints the client IP: // <?php echo $_SERVER["REMOTE_ADDR"]; ?> if (nHost == 1) { addrConnect = CService("91.198.22.70", 80); // checkip.dyndns.org if (nLookup == 1) { CService addrIP("checkip.dyndns.org", 80, true); if (addrIP.IsValid()) addrConnect = addrIP; } pszGet = "GET / HTTP/1.1\r\n" "Host: checkip.dyndns.org\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" "Connection: close\r\n" "\r\n"; pszKeyword = "Address:"; } else if (nHost == 2) { addrConnect = CService("74.208.43.192", 80); // www.showmyip.com if (nLookup == 1) { CService addrIP("www.showmyip.com", 80, true); if (addrIP.IsValid()) addrConnect = addrIP; } pszGet = "GET /simple/ HTTP/1.1\r\n" "Host: www.showmyip.com\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" "Connection: close\r\n" "\r\n"; pszKeyword = NULL; // Returns just IP address } if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet)) return true; } return false; } void ThreadGetMyExternalIP(void* parg) { // Make this thread recognisable as the external IP detection thread RenameThread("yiffcoin-ext-ip"); CNetAddr addrLocalHost; if (GetMyExternalIP(addrLocalHost)) { printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str()); AddLocal(addrLocalHost, LOCAL_HTTP); } } void AddressCurrentlyConnected(const CService& addr) { addrman.Connected(addr); } CNode* FindNode(const CNetAddr& ip) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if ((CNetAddr)pnode->addr == ip) return (pnode); return NULL; } CNode* FindNode(std::string addrName) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->addrName == addrName) return (pnode); return NULL; } CNode* FindNode(const CService& addr) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if ((CService)pnode->addr == addr) return (pnode); return NULL; } CNode* ConnectNode(CAddress addrConnect, const char *pszDest) { if (pszDest == NULL) { if (IsLocal(addrConnect)) return NULL; // Look for an existing connection CNode* pnode = FindNode((CService)addrConnect); if (pnode) { pnode->AddRef(); return pnode; } } /// debug print printf("trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString().c_str(), pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0); // Connect SOCKET hSocket; if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, GetDefaultPort()) : ConnectSocket(addrConnect, hSocket)) { addrman.Attempt(addrConnect); /// debug print printf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str()); // Set to non-blocking #ifdef WIN32 u_long nOne = 1; if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) printf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError()); #else if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) printf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno); #endif // Add node CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); pnode->AddRef(); { LOCK(cs_vNodes); vNodes.push_back(pnode); } pnode->nTimeConnected = GetTime(); return pnode; } else { return NULL; } } void CNode::CloseSocketDisconnect() { fDisconnect = true; if (hSocket != INVALID_SOCKET) { printf("disconnecting node %s\n", addrName.c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; } // in case this fails, we'll empty the recv buffer when the CNode is deleted TRY_LOCK(cs_vRecvMsg, lockRecv); if (lockRecv) vRecvMsg.clear(); // if this was the sync node, we'll need a new one if (this == pnodeSync) pnodeSync = NULL; } void CNode::Cleanup() { } void CNode::PushVersion() { /// when NTP implemented, change to just nTime = GetAdjustedTime() int64 nTime = (fInbound ? GetAdjustedTime() : GetTime()); CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0))); CAddress addrMe = GetLocalAddress(&addr); RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str()); PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight); } std::map<CNetAddr, int64> CNode::setBanned; CCriticalSection CNode::cs_setBanned; void CNode::ClearBanned() { setBanned.clear(); } bool CNode::IsBanned(CNetAddr ip) { bool fResult = false; { LOCK(cs_setBanned); std::map<CNetAddr, int64>::iterator i = setBanned.find(ip); if (i != setBanned.end()) { int64 t = (*i).second; if (GetTime() < t) fResult = true; } } return fResult; } bool CNode::Misbehaving(int howmuch) { if (addr.IsLocal()) { printf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch); return false; } nMisbehavior += howmuch; if (nMisbehavior >= GetArg("-banscore", 100)) { int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior); { LOCK(cs_setBanned); if (setBanned[addr] < banTime) setBanned[addr] = banTime; } CloseSocketDisconnect(); return true; } else printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior); return false; } #undef X #define X(name) stats.name = name void CNode::copyStats(CNodeStats &stats) { X(nServices); X(nLastSend); X(nLastRecv); X(nTimeConnected); X(addrName); X(nVersion); X(cleanSubVer); X(fInbound); X(nStartingHeight); X(nMisbehavior); X(nSendBytes); X(nRecvBytes); X(nBlocksRequested); stats.fSyncNode = (this == pnodeSync); } #undef X // requires LOCK(cs_vRecvMsg) bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) { while (nBytes > 0) { // get current incomplete message, or create a new one if (vRecvMsg.empty() || vRecvMsg.back().complete()) vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion)); CNetMessage& msg = vRecvMsg.back(); // absorb network data int handled; if (!msg.in_data) handled = msg.readHeader(pch, nBytes); else handled = msg.readData(pch, nBytes); if (handled < 0) return false; pch += handled; nBytes -= handled; } return true; } int CNetMessage::readHeader(const char *pch, unsigned int nBytes) { // copy data to temporary parsing buffer unsigned int nRemaining = 24 - nHdrPos; unsigned int nCopy = std::min(nRemaining, nBytes); memcpy(&hdrbuf[nHdrPos], pch, nCopy); nHdrPos += nCopy; // if header incomplete, exit if (nHdrPos < 24) return nCopy; // deserialize to CMessageHeader try { hdrbuf >> hdr; } catch (std::exception &e) { return -1; } // reject messages larger than MAX_SIZE if (hdr.nMessageSize > MAX_SIZE) return -1; // switch state to reading message data in_data = true; vRecv.resize(hdr.nMessageSize); return nCopy; } int CNetMessage::readData(const char *pch, unsigned int nBytes) { unsigned int nRemaining = hdr.nMessageSize - nDataPos; unsigned int nCopy = std::min(nRemaining, nBytes); memcpy(&vRecv[nDataPos], pch, nCopy); nDataPos += nCopy; return nCopy; } // requires LOCK(cs_vSend) void SocketSendData(CNode *pnode) { std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin(); while (it != pnode->vSendMsg.end()) { const CSerializeData &data = *it; assert(data.size() > pnode->nSendOffset); int nBytes = send(pnode->hSocket, &data[pnode->nSendOffset], data.size() - pnode->nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT); if (nBytes > 0) { pnode->nLastSend = GetTime(); pnode->nSendBytes += nBytes; pnode->nSendOffset += nBytes; if (pnode->nSendOffset == data.size()) { pnode->nSendOffset = 0; pnode->nSendSize -= data.size(); it++; } else { // could not send full message; stop sending more break; } } else { if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { printf("socket send error %d\n", nErr); pnode->CloseSocketDisconnect(); } } // couldn't send anything at all break; } } if (it == pnode->vSendMsg.end()) { assert(pnode->nSendOffset == 0); assert(pnode->nSendSize == 0); } pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it); } static list<CNode*> vNodesDisconnected; void ThreadSocketHandler() { unsigned int nPrevNodeCount = 0; loop { // // Disconnect nodes // { LOCK(cs_vNodes); // Disconnect unused nodes vector<CNode*> vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) { // remove from vNodes vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); // release outbound grant (if any) pnode->grantOutbound.Release(); // close socket and cleanup pnode->CloseSocketDisconnect(); pnode->Cleanup(); // hold in disconnected pool until all refs are released if (pnode->fNetworkNode || pnode->fInbound) pnode->Release(); vNodesDisconnected.push_back(pnode); } } // Delete disconnected nodes list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected; BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) { bool fDelete = false; { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { TRY_LOCK(pnode->cs_inventory, lockInv); if (lockInv) fDelete = true; } } } if (fDelete) { vNodesDisconnected.remove(pnode); delete pnode; } } } } if (vNodes.size() != nPrevNodeCount) { nPrevNodeCount = vNodes.size(); uiInterface.NotifyNumConnectionsChanged(vNodes.size()); } // // Find which sockets have data to receive // struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 50000; // frequency to poll pnode->vSend fd_set fdsetRecv; fd_set fdsetSend; fd_set fdsetError; FD_ZERO(&fdsetRecv); FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); SOCKET hSocketMax = 0; bool have_fds = false; BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) { FD_SET(hListenSocket, &fdsetRecv); hSocketMax = max(hSocketMax, hListenSocket); have_fds = true; } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (pnode->hSocket == INVALID_SOCKET) continue; FD_SET(pnode->hSocket, &fdsetError); hSocketMax = max(hSocketMax, pnode->hSocket); have_fds = true; // Implement the following logic: // * If there is data to send, select() for sending data. As this only // happens when optimistic write failed, we choose to first drain the // write buffer in this case before receiving more. This avoids // needlessly queueing received data, if the remote peer is not themselves // receiving data. This means properly utilizing TCP flow control signalling. // * Otherwise, if there is no (complete) message in the receive buffer, // or there is space left in the buffer, select() for receiving data. // * (if neither of the above applies, there is certainly one message // in the receiver buffer ready to be processed). // Together, that means that at least one of the following is always possible, // so we don't deadlock: // * We send some data. // * We wait for data to be received (and disconnect after timeout). // * We process a message in the buffer (message handler thread). { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend && !pnode->vSendMsg.empty()) { FD_SET(pnode->hSocket, &fdsetSend); continue; } } { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv && ( pnode->vRecvMsg.empty() || !pnode->vRecvMsg.front().complete() || pnode->GetTotalRecvSize() <= ReceiveFloodSize())) FD_SET(pnode->hSocket, &fdsetRecv); } } } int nSelect = select(have_fds ? hSocketMax + 1 : 0, &fdsetRecv, &fdsetSend, &fdsetError, &timeout); boost::this_thread::interruption_point(); if (nSelect == SOCKET_ERROR) { if (have_fds) { int nErr = WSAGetLastError(); printf("socket select error %d\n", nErr); for (unsigned int i = 0; i <= hSocketMax; i++) FD_SET(i, &fdsetRecv); } FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); MilliSleep(timeout.tv_usec/1000); } // // Accept new connections // BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv)) { #ifdef USE_IPV6 struct sockaddr_storage sockaddr; #else struct sockaddr sockaddr; #endif socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); CAddress addr; int nInbound = 0; if (hSocket != INVALID_SOCKET) if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr)) printf("Warning: Unknown socket family\n"); { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->fInbound) nInbound++; } if (hSocket == INVALID_SOCKET) { int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK) printf("socket error accept failed: %d\n", nErr); } else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS) { { LOCK(cs_setservAddNodeAddresses); if (!setservAddNodeAddresses.count(addr)) closesocket(hSocket); } } else if (CNode::IsBanned(addr)) { printf("connection from %s dropped (banned)\n", addr.ToString().c_str()); closesocket(hSocket); } else { printf("accepted connection %s\n", addr.ToString().c_str()); CNode* pnode = new CNode(hSocket, addr, "", true); pnode->AddRef(); { LOCK(cs_vNodes); vNodes.push_back(pnode); } } } // // Service each socket // vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->AddRef(); } BOOST_FOREACH(CNode* pnode, vNodesCopy) { boost::this_thread::interruption_point(); // // Receive // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { { // typical socket buffer is 8K-64K char pchBuf[0x10000]; int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); if (nBytes > 0) { if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) pnode->CloseSocketDisconnect(); pnode->nLastRecv = GetTime(); pnode->nRecvBytes += nBytes; } else if (nBytes == 0) { // socket closed gracefully if (!pnode->fDisconnect) printf("socket closed\n"); pnode->CloseSocketDisconnect(); } else if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { if (!pnode->fDisconnect) printf("socket recv error %d\n", nErr); pnode->CloseSocketDisconnect(); } } } } } // // Send // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetSend)) { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) SocketSendData(pnode); } // // Inactivity checking // if (pnode->vSendMsg.empty()) pnode->nLastSendEmpty = GetTime(); if (GetTime() - pnode->nTimeConnected > 60) { if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) { printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0); pnode->fDisconnect = true; } else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60) { printf("socket not sending\n"); pnode->fDisconnect = true; } else if (GetTime() - pnode->nLastRecv > 90*60) { printf("socket inactivity timeout\n"); pnode->fDisconnect = true; } } } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->Release(); } MilliSleep(10); } } #ifdef USE_UPNP void ThreadMapPort() { std::string port = strprintf("%u", GetListenPort()); const char * multicastif = 0; const char * minissdpdpath = 0; struct UPNPDev * devlist = 0; char lanaddr[64]; #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); #else /* miniupnpc 1.6 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); #endif struct UPNPUrls urls; struct IGDdatas data; int r; r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { if (fDiscover) { char externalIPAddress[40]; r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); if(r != UPNPCOMMAND_SUCCESS) printf("UPnP: GetExternalIPAddress() returned %d\n", r); else { if(externalIPAddress[0]) { printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); } else printf("UPnP: GetExternalIPAddress failed.\n"); } } string strDesc = "Yiffcoin " + FormatFullVersion(); try { loop { #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port.c_str(), port.c_str(), lanaddr, r, strupnperror(r)); else printf("UPnP Port Mapping successful.\n");; MilliSleep(20*60*1000); // Refresh every 20 minutes } } catch (boost::thread_interrupted) { r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); printf("UPNP_DeletePortMapping() returned : %d\n", r); freeUPNPDevlist(devlist); devlist = 0; FreeUPNPUrls(&urls); throw; } } else { printf("No valid UPnP IGDs found\n"); freeUPNPDevlist(devlist); devlist = 0; if (r != 0) FreeUPNPUrls(&urls); } } void MapPort(bool fUseUPnP) { static boost::thread* upnp_thread = NULL; if (fUseUPnP) { if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); delete upnp_thread; } upnp_thread = new boost::thread(boost::bind(&TraceThread<boost::function<void()> >, "upnp", &ThreadMapPort)); } else if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); delete upnp_thread; upnp_thread = NULL; } } #else void MapPort(bool) { // Intentionally left blank. } #endif // DNS seeds // Each pair gives a source name and a seed name. // The first name is used as information source for addrman. // The second name should resolve to a list of seed addresses. static const char *strMainNetDNSSeed[][2] = { {"techwolf.tk", "dnsseed.techwolf.tk"}, {NULL, NULL} }; static const char *strTestNetDNSSeed[][2] = { {"techwolf.tk", "testnetseed.techwolf.tk"}, {NULL, NULL} }; void ThreadDNSAddressSeed() { static const char *(*strDNSSeed)[2] = fTestNet ? strTestNetDNSSeed : strMainNetDNSSeed; int found = 0; printf("Loading addresses from DNS seeds (could take a while)\n"); for (unsigned int seed_idx = 0; strDNSSeed[seed_idx][0] != NULL; seed_idx++) { if (HaveNameProxy()) { AddOneShot(strDNSSeed[seed_idx][1]); } else { vector<CNetAddr> vaddr; vector<CAddress> vAdd; if (LookupHost(strDNSSeed[seed_idx][1], vaddr)) { BOOST_FOREACH(CNetAddr& ip, vaddr) { int nOneDay = 24*3600; CAddress addr = CAddress(CService(ip, GetDefaultPort())); addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old vAdd.push_back(addr); found++; } } addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true)); } } printf("%d addresses found from DNS seeds\n", found); } unsigned int pnSeed[] = { 0x6ab5368e, 0x63109859, 0x6c47bb25, 0x87d888c1, 0x1d9b2e48, 0x63a6c545, 0xf3ca1a48, 0x23b6b242, 0x8a67c7c6, 0x70a6f1c0, 0xc585c96d, 0x5cc4fd36, 0x239be836, 0x6660dc36, 0x2664cb36, 0xa602cd36, 0xb83dfc36, 0x70a2fe18, 0x2c589d55, 0xf969ec2e, 0x702ab643, 0x6a97e655, 0xad9751ce, 0x57e5025a, 0x9d065643, 0xe7b5ff60, 0x959d0d5a, 0x9667a318, 0xeba0c118, 0xb380d418, 0x170ccdde, 0x3548d9a2, 0x3261ff53, 0x42df0676, 0x9d7445ae, 0x1db3e953, 0xafc0b1b7, 0x1648934b, 0x535ee644, 0x4b89b64f, 0x56ed3060, 0x0810a15f, 0x03590ccf, 0x80752452, 0x0cc87162, 0xfec159d5, 0xcf0df618, 0x48865456, 0xdec8e55a, 0x91e6ee5b, 0xc4739518, 0x24d45453, 0xd5e5be44, 0xdafcff57, 0x0e73ca18, 0x83c4d148, 0x5a51ee53, 0x367e1c56, 0x2d651f54, 0x5eb4be43, 0x621589b2, 0x81dddedd, 0xd7499f56, 0xa48a694c, 0xd408c762, 0x88d36144, 0x6891772e, 0x38e89c73, 0x8ce3a856, 0x52fa1fb0, 0xd9d5796d, 0x27318945, 0x2e680452, 0x619bc445, 0xd0dc092e, 0x7192c962, 0xc2c9e405, 0xb9e3e747, 0xe459c9c1, 0x9d043b25, 0xe2b235c6, 0xed2dcf18, 0xb3d03cae, 0x3d2dafb8, 0xd46a0e45, 0x4a32f1d8, 0x350be560, 0xab0a648a, 0x87b6bc43, 0x6745629b, 0x72b9c362, 0x03a91c05, 0x7320bd3b, 0x32920b18, 0xbc2ca162, 0x216c4f7d, 0x64151a4e, 0x4b63e20c, 0xe703c3be, 0xc2d5fab2, 0x2b28b762, 0xde47b0ba, 0xf2e19dd9, 0x99044fad, 0x8252a5c0, 0x6e8be597, 0x4f0bb56c, 0xfaa52252, 0x8f764b52, 0xe5b21cad, 0x020cab4d, 0xc8e8f763, 0x2eaacc6d, 0x2ce4dd4e, 0xfe27345c, 0xb21f09b0, 0x8b4199d9, 0x6b53c248, 0x42a8966d, 0xd5387145, 0xc091c257, 0x2fe06751, 0xecf66552, 0x37dd0418, 0x8073c57c, 0x5471d54e, 0x56953360, 0x0d1ffcdf, 0xb4554318, 0x16cb54c6, 0xa064d05e, 0x2b0fa93a, 0xec26d162, 0x9ca91b42, 0xdcfa4457, 0x1b5c0a7a, 0x4561a17c, 0xcc52a662, 0xf9d47ad9, 0xfa418cb2, 0x88085618, 0x007aa55f, 0xfa2e4d4d, 0x8516a843, 0x634ac658, 0x2c36f62e, 0x3f0cbe5e, 0xd0e87257, 0x37d5e6bc, 0x5941c1c7, 0x5ee001ae, 0xc2791e6c, 0x0c6220b2, 0xab1ba258, 0x4719c076, 0xabb6a942, 0x6e588b52, 0x101a4352, 0x9604b362, 0x16607fc7, 0x4a687d45, 0xc217feb2, 0xaebb6b18, 0x4439412e, 0x41330360, 0xca23946d, 0x1c699d76, 0xcd302344, 0x4683afad, 0xad3c644f, 0x95ab4f05, 0xb34ec562, 0x57e3ff50, 0xcb950847, 0x743ced60, 0xb6734347, 0x6237a2b2, 0x1517e244, 0xfd0b128b, 0xb7eb605f, 0x6a9717ad, 0x7e8d65ae, 0xdddc4cad, 0xc63530a6, 0xfcd78559, 0xc779e25e, 0xf683de58, 0x7cd1ff50, 0x6e0931ad, 0x7c1b46ad, 0x9f4b4252, 0xf421482e, 0xeca7e697, 0xfe466544, 0x46fa2240, 0xd33328bc, 0x7be6d7bd, 0xc205c27b, 0xa04c07d8, 0x5bcdb350, 0x847bc74a, 0x14967f45, 0x59b341ad, 0x9ce4d783, 0xc38300c0, 0x4f1b4aad, 0x018daa32, 0x95d7f854, 0x4bd58543, 0xfe8446ad, 0xc3288f18, 0xcda2e253, 0x662e4852, 0x9338e24e, 0xc2fd1218, 0xa7198252, 0x481858b8, 0x55b74374, 0xbd458d5e, 0xb2cc6d54, 0x2ca11b4e, 0x62d1be58, 0xf0637fbc, 0xd9943950, 0x0f6f4a47, 0x188a6144, 0x768ea0d8, 0xd2c31c54, 0x29462ed5, 0x2b546ad5, 0x8ba12d6c, 0x1a3f7255, 0xa836e23c, 0xdcde0552, 0xda5b3945, 0x7e3720b2, 0x8c098018, 0x42cddd50, 0x0c52a65f, 0x8cce175e, 0x96554242, 0x7309c779, 0xcb2537ca, 0xecfb70d9, 0x19c0b259, 0x7b559ed8, 0x2f03ae44, 0x1b2b0f05, 0x9e72165e, 0x4ac7413e, 0xa22cbb6a, 0x9fc7624d, 0xbb101a54, 0xfdb0c23e, 0x84a65a47, 0x1efded62, 0x1f47f554, 0xe5c16ad2, 0x76b62332, 0xe4613d46, 0xd74f6ec1, 0x3d0e2b32, 0x6725fe5e, 0xb62a8729, 0x922e9925, 0x7efc2544, 0x12af60d4, 0x5e042f44, 0x5fcaff54, 0x144a3493, 0x5788ec47, 0x729175b2, 0x493b316c, 0x949d4542, 0x4ffc8856, 0x18a95b61, 0xdaabc547, 0xc879d855, 0x7d8488c1, 0x3cb7b052, 0xbe8ade6f, 0x6ef6a555, 0x737e5247, 0x7368e252, 0x5fbe1056, 0xb848e217, 0x44a44105, 0xb7610150, 0x3c2eed62, 0x2b0c9e6d, 0x2a1698b4, 0x4e6fa443, 0xb6c3fe4d, 0xd86c8a43, 0x48b27125, 0x9d9c60cb, 0x349a6d4c, 0xae336259, 0x81d7976d, 0x8e9fe2c0, 0x5f20c2dd, 0x6f289e52, 0xe954cf51, 0xc96eb248, 0x1c29f562, 0xb01e3842, 0x119511b9, 0x4811856d, 0x172ff854, 0x7dab5451, 0x52520752, 0xc414ed52, 0x368f4105, 0x7767b047, 0x1c459f32, 0x05b5e697, 0xb5273160, 0x99eaec69, 0x0cd7a951, 0x36e1f13e, 0xee815148, 0x5773e8bc, 0xf61f35ad, 0xa0b903ae, 0x2d811660, 0x98aec3be, 0x851afa59, 0xce25a518, 0xfcaaf2a2, 0x90bde760, 0x04cb16ad, 0x70a30432, 0xa6cd3e47, 0x0ccac672, 0xb238a018, 0xf7db8156, 0xed1e0331, 0xe2590ccf, 0x0cde9e56, 0x5cc39744, 0x4e3c957c, 0xc57e67d3, 0x6b547662, 0x073cd243, 0x670d9a18, 0x4666ae58, 0x661abd59, 0x64c94732, 0x8371cc82, 0x2f460843, 0x03bcfa45, 0xa23cac70, 0x1fa47b46, 0xec86b4ad, 0x183e3105, 0x6dea2446, 0x0331bcd1, 0x2673cf18, 0x5ccbdaac, 0xa0483850, 0x9b28c34a, 0xc69b9b62, 0xac944946, 0x3723b456, 0x4a53485d, 0x365fa8bc, 0x3adfbd5e, 0xdefbb143, 0x6ca64746, 0xadea802e, 0x89c0bbad, 0xefcc854f, 0x38cca5bc, 0xacc61e5e, 0x5bc43ab8, 0x3003795b, 0x391c2352, 0xe410f6ad, 0x3fa6f957, 0xd6b095d4, 0xeb00ba43, 0xf92f174c, 0xb45c0644, 0x6b299c53, 0xff0cf172, 0xaafe4a4c, 0xeb4aea5c, 0xb61dae43, 0x22115347, 0xfd510e6c, 0xe037fc50, 0xa5498e3d, 0xd36b8118, 0x0b6a0250, 0xd3260c5e, 0xe540424b, 0xbb630732, 0xa5cca46d, 0xdbb27a47, 0x5874ba6a, 0x581d4342, 0xa68b7125, 0x0b3b9f58, 0x2b8a8d18, 0x3155e763, 0x455e6951, 0xe79c0260, 0x683a474b, 0xfcabe697, 0xf3d1e13c, 0x8c0eb57c, 0x34a9e155, 0xc51d1e4c, 0x26fc8748, 0x3817ba6a, 0xbc36225f, 0x8dc42e5a, 0x51676c4e, 0x0f77a843, 0xf45ebebc, 0x2dc05874, 0x9be1ac5f, 0x1471595c, 0xa6d260d8, 0x3e2a008e, 0x0a2ff462, 0xfbe632c6, 0xf701af5d, 0x6cca155c, 0xf2e2af51, 0xb5c47a47, 0x322968d5, 0xfe651b4e, 0x11bccecd, 0xc2140418, 0xa741a465, 0xc8f45f48, 0x0400b0b4, 0x0e36c14e, 0x1f028cb2, 0x221db552, 0x4876ced5, 0x8e7c4abc, 0xd4b4734c, 0xce4b79d9, 0xf2879056, 0xa761794d, 0xc89c96b2, 0xd042af44, 0xd5f63418, 0x744731ad, 0xa94e7cae, 0x52b85b4d, 0x01978932, 0xa6abd1d3, 0xd4fae247, 0x71cd9344, 0xde60bb6a, 0xec358489, 0x6e054cdc, 0xc92728bc, 0x231ea8bc, 0x74a5a2bc, 0x6d6f135d, 0x26dd6596, 0x9d5386d1, 0x268bf232, 0x3867324a, 0x315e5353, 0x1ed2a443, 0xd79a9d51, 0x39dfe550, 0x3f1ef181, 0x2f65fe79, 0xf6caf04d, 0x3fd33644, 0xd9abf043, 0x1a84c94e, 0x61618445, 0x7bd81318, 0xb4f8764c, 0x8c6ae963, 0x7d659c5c, 0x9f294257, 0x5711be58, 0x3ac6b247, 0xe4f07d60, 0xe6bf7162, 0x96742752, 0x23329cca, 0xc219cd5c, 0xa6f23418, 0xf4908053, 0x63130652, 0xf68fc948, 0x028fb54b, 0x83ec1a18, 0xe88b4e8b, 0xf057ffcf, 0x4b3efe60, 0x359fff60, 0xba675642, 0xd5fe664c, 0xc8a2b862, 0x4f8f576d, 0xb7827462, 0x1cc0c954, 0x6655aa7c, 0x9bc71451, 0x1039b456, 0x91d5e37c, 0x1ccb6c53, 0x2e36313e, 0x6afd5251, 0xee91107c, 0xe9c0844b, 0xf133e347, 0xc1cd1b41, 0x3a0ab052, 0x30dee25a, 0xa75bd152, 0x319da1b8, 0xd8f97561, 0x2fa794d5, 0x92a70d6c, 0xd6b470d5, 0xb524c90e, 0x109a64ae, 0x7038af89, 0x3205e418, 0x313a015e, 0xd2d3175e, 0xc07593b8, 0x179ee97a, 0x78fdec47, 0x775d6d3a, 0xccc93a40, 0xdbbbd9ad, 0x803c6f12, 0xfd4bc14a, 0x8ed15250, 0x19c65958, 0xc8300c5e, 0x87757db2, 0x82fe0444, 0x3ce0035e, 0x19f0e762, 0x160c4c57, 0x069b0418, 0x9c6e4356, 0xa10df12e, 0x1936654d, 0xd30b2848, 0x464aa5b2, 0xbb0b1b55, 0x03f3d318, 0x0431e06c, 0x0d94f15b, 0xabc2ed47, 0xf23a00c2, 0x3bee4954, 0xd1e72a52, 0xd464d054, 0xcf141118, 0xf57f4bc8, 0xd8b1ac6c, 0x136ea959, 0x63275d4a, 0x391e8c18, 0xd4dd4832, 0x96610b6d, 0x9cfb5153, 0x4a80ee48, 0x345e7cbc, 0xde810b59, 0x134a4c90, 0x4544ed5e, 0xdc801956, 0x9d6b3ac6, 0x0a037786, 0xdcaafd62, 0xd65ee05a, 0x158b754c, 0x53427dd5, 0xa32774bc, 0xa22af3a2, 0x0c1f7157, 0xa0b58429, 0x349f3156, 0x9cd6a34d, 0x67eb1c56, 0x20b5e597, 0xd40f7162, 0xa4cb0379, 0x0e1efc53, 0xe5c8e554, 0x3ebf8052, 0x6ee00847, 0x99206883, 0xc851767d }; void DumpAddresses() { int64 nStart = GetTimeMillis(); CAddrDB adb; adb.Write(addrman); printf("Flushed %d addresses to peers.dat %"PRI64d"ms\n", addrman.size(), GetTimeMillis() - nStart); } void static ProcessOneShot() { string strDest; { LOCK(cs_vOneShots); if (vOneShots.empty()) return; strDest = vOneShots.front(); vOneShots.pop_front(); } CAddress addr; CSemaphoreGrant grant(*semOutbound, true); if (grant) { if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true)) AddOneShot(strDest); } } void ThreadOpenConnections() { // Connect to specific addresses if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { for (int64 nLoop = 0;; nLoop++) { ProcessOneShot(); BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"]) { CAddress addr; OpenNetworkConnection(addr, NULL, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { MilliSleep(500); } } MilliSleep(500); } } // Initiate network connections int64 nStart = GetTime(); loop { ProcessOneShot(); MilliSleep(500); CSemaphoreGrant grant(*semOutbound); boost::this_thread::interruption_point(); // Add seed nodes if IRC isn't working if (addrman.size()==0 && (GetTime() - nStart > 60) && !fTestNet) { std::vector<CAddress> vAdd; for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++) { // It'll only connect to one or two seed nodes because once it connects, // it'll get a pile of addresses with newer timestamps. // Seed nodes are given a random 'last seen time' of between one and two // weeks ago. const int64 nOneWeek = 7*24*60*60; struct in_addr ip; memcpy(&ip, &pnSeed[i], sizeof(ip)); CAddress addr(CService(ip, GetDefaultPort())); addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; vAdd.push_back(addr); } addrman.Add(vAdd, CNetAddr("127.0.0.1")); } // // Choose an address to connect to based on most recently seen // CAddress addrConnect; // Only connect out to one peer per network group (/16 for IPv4). // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. int nOutbound = 0; set<vector<unsigned char> > setConnected; { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (!pnode->fInbound) { setConnected.insert(pnode->addr.GetGroup()); nOutbound++; } } } int64 nANow = GetAdjustedTime(); int nTries = 0; loop { // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); // if we selected an invalid address, restart if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr)) break; // If we didn't find an appropriate destination after trying 100 addresses fetched from addrman, // stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates // already-connected network ranges, ...) before trying new addrman addresses. nTries++; if (nTries > 100) break; if (IsLimited(addr)) continue; // only consider very recently tried nodes after 30 failed attempts if (nANow - addr.nLastTry < 600 && nTries < 30) continue; // do not allow non-default ports, unless after 50 invalid addresses selected already if (addr.GetPort() != GetDefaultPort() && nTries < 50) continue; addrConnect = addr; break; } if (addrConnect.IsValid()) OpenNetworkConnection(addrConnect, &grant); } } void ThreadOpenAddedConnections() { { LOCK(cs_vAddedNodes); vAddedNodes = mapMultiArgs["-addnode"]; } if (HaveNameProxy()) { while(true) { list<string> lAddresses(0); { LOCK(cs_vAddedNodes); BOOST_FOREACH(string& strAddNode, vAddedNodes) lAddresses.push_back(strAddNode); } BOOST_FOREACH(string& strAddNode, lAddresses) { CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); MilliSleep(500); } MilliSleep(120000); // Retry every 2 minutes } } for (unsigned int i = 0; true; i++) { list<string> lAddresses(0); { LOCK(cs_vAddedNodes); BOOST_FOREACH(string& strAddNode, vAddedNodes) lAddresses.push_back(strAddNode); } list<vector<CService> > lservAddressesToAdd(0); BOOST_FOREACH(string& strAddNode, lAddresses) { vector<CService> vservNode(0); if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0)) { lservAddressesToAdd.push_back(vservNode); { LOCK(cs_setservAddNodeAddresses); BOOST_FOREACH(CService& serv, vservNode) setservAddNodeAddresses.insert(serv); } } } // Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry // (keeping in mind that addnode entries can have many IPs if fNameLookup) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) BOOST_FOREACH(CService& addrNode, *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); it--; break; } } BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); MilliSleep(500); } MilliSleep(120000); // Retry every 2 minutes } } // if successful, this moves the passed grant to the constructed node bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound, const char *strDest, bool fOneShot) { // // Initiate outbound network connection // boost::this_thread::interruption_point(); if (!strDest) if (IsLocal(addrConnect) || FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort().c_str())) return false; if (strDest && FindNode(strDest)) return false; CNode* pnode = ConnectNode(addrConnect, strDest); boost::this_thread::interruption_point(); if (!pnode) return false; if (grantOutbound) grantOutbound->MoveTo(pnode->grantOutbound); pnode->fNetworkNode = true; if (fOneShot) pnode->fOneShot = true; return true; } // for now, use a very simple selection metric: the node from which we received // most recently double static NodeSyncScore(const CNode *pnode) { return -pnode->nLastRecv; } void static StartSync(const vector<CNode*> &vNodes) { CNode *pnodeNewSync = NULL; double dBestScore = 0; // fImporting and fReindex are accessed out of cs_main here, but only // as an optimization - they are checked again in SendMessages. if (fImporting || fReindex) return; // Iterate over all nodes BOOST_FOREACH(CNode* pnode, vNodes) { // check preconditions for allowing a sync if (!pnode->fClient && !pnode->fOneShot && !pnode->fDisconnect && pnode->fSuccessfullyConnected && (pnode->nStartingHeight > (nBestHeight - 144)) && (pnode->nVersion < NOBLKS_VERSION_START || pnode->nVersion >= NOBLKS_VERSION_END)) { // if ok, compare node's score with the best so far double dScore = NodeSyncScore(pnode); if (pnodeNewSync == NULL || dScore > dBestScore) { pnodeNewSync = pnode; dBestScore = dScore; } } } // if a new sync candidate was found, start sync! if (pnodeNewSync) { pnodeNewSync->fStartSync = true; pnodeSync = pnodeNewSync; } } void ThreadMessageHandler() { SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); while (true) { bool fHaveSyncNode = false; vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) { pnode->AddRef(); if (pnode == pnodeSync) fHaveSyncNode = true; } } if (!fHaveSyncNode) StartSync(vNodesCopy); // Poll the connected nodes for messages CNode* pnodeTrickle = NULL; if (!vNodesCopy.empty()) pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; bool fSleep = true; BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect) continue; // Receive messages { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { if (!ProcessMessages(pnode)) pnode->CloseSocketDisconnect(); if (pnode->nSendSize < SendBufferSize()) { if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete())) { fSleep = false; } } } } boost::this_thread::interruption_point(); // Send messages { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) SendMessages(pnode, pnode == pnodeTrickle); } boost::this_thread::interruption_point(); } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->Release(); } if (fSleep) MilliSleep(100); } } bool BindListenPort(const CService &addrBind, string& strError) { strError = ""; int nOne = 1; // Create socket for listening for incoming connections #ifdef USE_IPV6 struct sockaddr_storage sockaddr; #else struct sockaddr sockaddr; #endif socklen_t len = sizeof(sockaddr); if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString().c_str()); printf("%s\n", strError.c_str()); return false; } SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); if (hListenSocket == INVALID_SOCKET) { strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } #ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif #ifndef WIN32 // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. Not an issue on windows. setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); #endif #ifdef WIN32 // Set to non-blocking, incoming connections will also inherit this if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) #else if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) #endif { strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } #ifdef USE_IPV6 // some systems don't have IPV6_V6ONLY but are always v6only; others do have the option // and enable it by default or not. Try to enable it, if possible. if (addrBind.IsIPv6()) { #ifdef IPV6_V6ONLY #ifdef WIN32 setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int)); #else setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int)); #endif #endif #ifdef WIN32 int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */; int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */; // this call is allowed to fail setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int)); #endif } #endif if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) { int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) strError = strprintf(_("Unable to bind to %s on this computer. Yiffcoin is probably already running."), addrBind.ToString().c_str()); else strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr)); printf("%s\n", strError.c_str()); return false; } printf("Bound to %s\n", addrBind.ToString().c_str()); // Listen for incoming connections if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR) { strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } vhListenSocket.push_back(hListenSocket); if (addrBind.IsRoutable() && fDiscover) AddLocal(addrBind, LOCAL_BIND); return true; } void static Discover() { if (!fDiscover) return; #ifdef WIN32 // Get local host IP char pszHostName[1000] = ""; if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector<CNetAddr> vaddr; if (LookupHost(pszHostName, vaddr)) { BOOST_FOREACH (const CNetAddr &addr, vaddr) { AddLocal(addr, LOCAL_IF); } } } #else // Get local host ip struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) { for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) { if (ifa->ifa_addr == NULL) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue; if (strcmp(ifa->ifa_name, "lo") == 0) continue; if (strcmp(ifa->ifa_name, "lo0") == 0) continue; if (ifa->ifa_addr->sa_family == AF_INET) { struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); CNetAddr addr(s4->sin_addr); if (AddLocal(addr, LOCAL_IF)) printf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str()); } #ifdef USE_IPV6 else if (ifa->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr); CNetAddr addr(s6->sin6_addr); if (AddLocal(addr, LOCAL_IF)) printf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str()); } #endif } freeifaddrs(myaddrs); } #endif // Don't use external IPv4 discovery, when -onlynet="IPv6" if (!IsLimited(NET_IPV4)) NewThread(ThreadGetMyExternalIP, NULL); } void StartNode(boost::thread_group& threadGroup) { if (semOutbound == NULL) { // initialize semaphore int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections); semOutbound = new CSemaphore(nMaxOutbound); } if (pnodeLocalHost == NULL) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); Discover(); // // Start threads // if (!GetBoolArg("-dnsseed", true)) printf("DNS seeding disabled\n"); else threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "dnsseed", &ThreadDNSAddressSeed)); #ifdef USE_UPNP // Map ports with UPnP MapPort(GetBoolArg("-upnp", USE_UPNP)); #endif // Send and receive from sockets, accept connections threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler)); // Initiate outbound connections from -addnode threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "addcon", &ThreadOpenAddedConnections)); // Initiate outbound connections threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "opencon", &ThreadOpenConnections)); // Process messages threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "msghand", &ThreadMessageHandler)); // Dump network addresses threadGroup.create_thread(boost::bind(&LoopForever<void (*)()>, "dumpaddr", &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000)); } bool StopNode() { printf("StopNode()\n"); GenerateYiffcoins(false, NULL); MapPort(false); nTransactionsUpdated++; if (semOutbound) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) semOutbound->post(); MilliSleep(50); DumpAddresses(); return true; } class CNetCleanup { public: CNetCleanup() { } ~CNetCleanup() { // Close sockets BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->hSocket != INVALID_SOCKET) closesocket(pnode->hSocket); BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) if (hListenSocket != INVALID_SOCKET) if (closesocket(hListenSocket) == SOCKET_ERROR) printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); // clean up some globals (to help leak detection) BOOST_FOREACH(CNode *pnode, vNodes) delete pnode; BOOST_FOREACH(CNode *pnode, vNodesDisconnected) delete pnode; vNodes.clear(); vNodesDisconnected.clear(); delete semOutbound; semOutbound = NULL; delete pnodeLocalHost; pnodeLocalHost = NULL; #ifdef WIN32 // Shutdown Windows Sockets WSACleanup(); #endif } } instance_of_cnetcleanup; void RelayTransaction(const CTransaction& tx, const uint256& hash) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(10000); ss << tx; RelayTransaction(tx, hash, ss); } void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss) { CInv inv(MSG_TX, hash); { LOCK(cs_mapRelay); // Expire old relay messages while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime()) { mapRelay.erase(vRelayExpiration.front().second); vRelayExpiration.pop_front(); } // Save original serialized message so newer versions are preserved mapRelay.insert(std::make_pair(inv, ss)); vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); } LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if(!pnode->fRelayTxes) continue; LOCK(pnode->cs_filter); if (pnode->pfilter) { if (pnode->pfilter->IsRelevantAndUpdate(tx, hash)) pnode->PushInventory(inv); } else pnode->PushInventory(inv); } }
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp if(argc != 3){ 7: 83 39 03 cmpl $0x3,(%ecx) { a: ff 71 fc pushl -0x4(%ecx) d: 55 push %ebp e: 89 e5 mov %esp,%ebp 10: 53 push %ebx 11: 51 push %ecx 12: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 15: 74 13 je 2a <main+0x2a> printf(2, "Usage: ln old new\n"); 17: 52 push %edx 18: 52 push %edx 19: 68 68 07 00 00 push $0x768 1e: 6a 02 push $0x2 20: e8 eb 03 00 00 call 410 <printf> exit(); 25: e8 88 02 00 00 call 2b2 <exit> } if(link(argv[1], argv[2]) < 0) 2a: 50 push %eax 2b: 50 push %eax 2c: ff 73 08 pushl 0x8(%ebx) 2f: ff 73 04 pushl 0x4(%ebx) 32: e8 db 02 00 00 call 312 <link> 37: 83 c4 10 add $0x10,%esp 3a: 85 c0 test %eax,%eax 3c: 78 05 js 43 <main+0x43> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 3e: e8 6f 02 00 00 call 2b2 <exit> printf(2, "link %s %s: failed\n", argv[1], argv[2]); 43: ff 73 08 pushl 0x8(%ebx) 46: ff 73 04 pushl 0x4(%ebx) 49: 68 7b 07 00 00 push $0x77b 4e: 6a 02 push $0x2 50: e8 bb 03 00 00 call 410 <printf> 55: 83 c4 10 add $0x10,%esp 58: eb e4 jmp 3e <main+0x3e> 5a: 66 90 xchg %ax,%ax 5c: 66 90 xchg %ax,%ax 5e: 66 90 xchg %ax,%ax 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 45 08 mov 0x8(%ebp),%eax 67: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 6a: 89 c2 mov %eax,%edx 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 70: 83 c1 01 add $0x1,%ecx 73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 77: 83 c2 01 add $0x1,%edx 7a: 84 db test %bl,%bl 7c: 88 5a ff mov %bl,-0x1(%edx) 7f: 75 ef jne 70 <strcpy+0x10> ; return os; } 81: 5b pop %ebx 82: 5d pop %ebp 83: c3 ret 84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 53 push %ebx 94: 8b 55 08 mov 0x8(%ebp),%edx 97: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9a: 0f b6 02 movzbl (%edx),%eax 9d: 0f b6 19 movzbl (%ecx),%ebx a0: 84 c0 test %al,%al a2: 75 1c jne c0 <strcmp+0x30> a4: eb 2a jmp d0 <strcmp+0x40> a6: 8d 76 00 lea 0x0(%esi),%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; b0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) b3: 0f b6 02 movzbl (%edx),%eax p++, q++; b6: 83 c1 01 add $0x1,%ecx b9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) bc: 84 c0 test %al,%al be: 74 10 je d0 <strcmp+0x40> c0: 38 d8 cmp %bl,%al c2: 74 ec je b0 <strcmp+0x20> return (uchar)*p - (uchar)*q; c4: 29 d8 sub %ebx,%eax } c6: 5b pop %ebx c7: 5d pop %ebp c8: c3 ret c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi d0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5d pop %ebp d6: c3 ret d7: 89 f6 mov %esi,%esi d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000e0 <strlen>: uint strlen(const char *s) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) e6: 80 39 00 cmpb $0x0,(%ecx) e9: 74 15 je 100 <strlen+0x20> eb: 31 d2 xor %edx,%edx ed: 8d 76 00 lea 0x0(%esi),%esi f0: 83 c2 01 add $0x1,%edx f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) f7: 89 d0 mov %edx,%eax f9: 75 f5 jne f0 <strlen+0x10> ; return n; } fb: 5d pop %ebp fc: c3 ret fd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 100: 31 c0 xor %eax,%eax } 102: 5d pop %ebp 103: c3 ret 104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 117: 8b 4d 10 mov 0x10(%ebp),%ecx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 d7 mov %edx,%edi 11f: fc cld 120: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 122: 89 d0 mov %edx,%eax 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 127: 89 f6 mov %esi,%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <strchr>: char* strchr(const char *s, char c) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 53 push %ebx 134: 8b 45 08 mov 0x8(%ebp),%eax 137: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 13a: 0f b6 10 movzbl (%eax),%edx 13d: 84 d2 test %dl,%dl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d9 mov %ebx,%ecx 145: 75 0d jne 154 <strchr+0x24> 147: eb 17 jmp 160 <strchr+0x30> 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 38 ca cmp %cl,%dl 152: 74 0c je 160 <strchr+0x30> for(; *s; s++) 154: 83 c0 01 add $0x1,%eax 157: 0f b6 10 movzbl (%eax),%edx 15a: 84 d2 test %dl,%dl 15c: 75 f2 jne 150 <strchr+0x20> return (char*)s; return 0; 15e: 31 c0 xor %eax,%eax } 160: 5b pop %ebx 161: 5d pop %ebp 162: c3 ret 163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <gets>: char* gets(char *buf, int max) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 57 push %edi 174: 56 push %esi 175: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 176: 31 f6 xor %esi,%esi 178: 89 f3 mov %esi,%ebx { 17a: 83 ec 1c sub $0x1c,%esp 17d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 180: eb 2f jmp 1b1 <gets+0x41> 182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 188: 8d 45 e7 lea -0x19(%ebp),%eax 18b: 83 ec 04 sub $0x4,%esp 18e: 6a 01 push $0x1 190: 50 push %eax 191: 6a 00 push $0x0 193: e8 32 01 00 00 call 2ca <read> if(cc < 1) 198: 83 c4 10 add $0x10,%esp 19b: 85 c0 test %eax,%eax 19d: 7e 1c jle 1bb <gets+0x4b> break; buf[i++] = c; 19f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1a3: 83 c7 01 add $0x1,%edi 1a6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1a9: 3c 0a cmp $0xa,%al 1ab: 74 23 je 1d0 <gets+0x60> 1ad: 3c 0d cmp $0xd,%al 1af: 74 1f je 1d0 <gets+0x60> for(i=0; i+1 < max; ){ 1b1: 83 c3 01 add $0x1,%ebx 1b4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1b7: 89 fe mov %edi,%esi 1b9: 7c cd jl 188 <gets+0x18> 1bb: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1bd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1c0: c6 03 00 movb $0x0,(%ebx) } 1c3: 8d 65 f4 lea -0xc(%ebp),%esp 1c6: 5b pop %ebx 1c7: 5e pop %esi 1c8: 5f pop %edi 1c9: 5d pop %ebp 1ca: c3 ret 1cb: 90 nop 1cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1d0: 8b 75 08 mov 0x8(%ebp),%esi 1d3: 8b 45 08 mov 0x8(%ebp),%eax 1d6: 01 de add %ebx,%esi 1d8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1da: c6 03 00 movb $0x0,(%ebx) } 1dd: 8d 65 f4 lea -0xc(%ebp),%esp 1e0: 5b pop %ebx 1e1: 5e pop %esi 1e2: 5f pop %edi 1e3: 5d pop %ebp 1e4: c3 ret 1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001f0 <stat>: int stat(const char *n, struct stat *st) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 56 push %esi 1f4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1f5: 83 ec 08 sub $0x8,%esp 1f8: 6a 00 push $0x0 1fa: ff 75 08 pushl 0x8(%ebp) 1fd: e8 f0 00 00 00 call 2f2 <open> if(fd < 0) 202: 83 c4 10 add $0x10,%esp 205: 85 c0 test %eax,%eax 207: 78 27 js 230 <stat+0x40> return -1; r = fstat(fd, st); 209: 83 ec 08 sub $0x8,%esp 20c: ff 75 0c pushl 0xc(%ebp) 20f: 89 c3 mov %eax,%ebx 211: 50 push %eax 212: e8 f3 00 00 00 call 30a <fstat> close(fd); 217: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 21a: 89 c6 mov %eax,%esi close(fd); 21c: e8 b9 00 00 00 call 2da <close> return r; 221: 83 c4 10 add $0x10,%esp } 224: 8d 65 f8 lea -0x8(%ebp),%esp 227: 89 f0 mov %esi,%eax 229: 5b pop %ebx 22a: 5e pop %esi 22b: 5d pop %ebp 22c: c3 ret 22d: 8d 76 00 lea 0x0(%esi),%esi return -1; 230: be ff ff ff ff mov $0xffffffff,%esi 235: eb ed jmp 224 <stat+0x34> 237: 89 f6 mov %esi,%esi 239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000240 <atoi>: int atoi(const char *s) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 53 push %ebx 244: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 247: 0f be 11 movsbl (%ecx),%edx 24a: 8d 42 d0 lea -0x30(%edx),%eax 24d: 3c 09 cmp $0x9,%al n = 0; 24f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 254: 77 1f ja 275 <atoi+0x35> 256: 8d 76 00 lea 0x0(%esi),%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 260: 8d 04 80 lea (%eax,%eax,4),%eax 263: 83 c1 01 add $0x1,%ecx 266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 26a: 0f be 11 movsbl (%ecx),%edx 26d: 8d 5a d0 lea -0x30(%edx),%ebx 270: 80 fb 09 cmp $0x9,%bl 273: 76 eb jbe 260 <atoi+0x20> return n; } 275: 5b pop %ebx 276: 5d pop %ebp 277: c3 ret 278: 90 nop 279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000280 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 56 push %esi 284: 53 push %ebx 285: 8b 5d 10 mov 0x10(%ebp),%ebx 288: 8b 45 08 mov 0x8(%ebp),%eax 28b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 28e: 85 db test %ebx,%ebx 290: 7e 14 jle 2a6 <memmove+0x26> 292: 31 d2 xor %edx,%edx 294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 298: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 29c: 88 0c 10 mov %cl,(%eax,%edx,1) 29f: 83 c2 01 add $0x1,%edx while(n-- > 0) 2a2: 39 d3 cmp %edx,%ebx 2a4: 75 f2 jne 298 <memmove+0x18> return vdst; } 2a6: 5b pop %ebx 2a7: 5e pop %esi 2a8: 5d pop %ebp 2a9: c3 ret 000002aa <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2aa: b8 01 00 00 00 mov $0x1,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <exit>: SYSCALL(exit) 2b2: b8 02 00 00 00 mov $0x2,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <wait>: SYSCALL(wait) 2ba: b8 03 00 00 00 mov $0x3,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <pipe>: SYSCALL(pipe) 2c2: b8 04 00 00 00 mov $0x4,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <read>: SYSCALL(read) 2ca: b8 05 00 00 00 mov $0x5,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <write>: SYSCALL(write) 2d2: b8 10 00 00 00 mov $0x10,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <close>: SYSCALL(close) 2da: b8 15 00 00 00 mov $0x15,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <kill>: SYSCALL(kill) 2e2: b8 06 00 00 00 mov $0x6,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <exec>: SYSCALL(exec) 2ea: b8 07 00 00 00 mov $0x7,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <open>: SYSCALL(open) 2f2: b8 0f 00 00 00 mov $0xf,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <mknod>: SYSCALL(mknod) 2fa: b8 11 00 00 00 mov $0x11,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <unlink>: SYSCALL(unlink) 302: b8 12 00 00 00 mov $0x12,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <fstat>: SYSCALL(fstat) 30a: b8 08 00 00 00 mov $0x8,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <link>: SYSCALL(link) 312: b8 13 00 00 00 mov $0x13,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <mkdir>: SYSCALL(mkdir) 31a: b8 14 00 00 00 mov $0x14,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <chdir>: SYSCALL(chdir) 322: b8 09 00 00 00 mov $0x9,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <dup>: SYSCALL(dup) 32a: b8 0a 00 00 00 mov $0xa,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <getpid>: SYSCALL(getpid) 332: b8 0b 00 00 00 mov $0xb,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <sbrk>: SYSCALL(sbrk) 33a: b8 0c 00 00 00 mov $0xc,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <sleep>: SYSCALL(sleep) 342: b8 0d 00 00 00 mov $0xd,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <uptime>: SYSCALL(uptime) 34a: b8 0e 00 00 00 mov $0xe,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <info>: SYSCALL(info) 352: b8 16 00 00 00 mov $0x16,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <settickets>: SYSCALL(settickets) 35a: b8 17 00 00 00 mov $0x17,%eax 35f: cd 40 int $0x40 361: c3 ret 362: 66 90 xchg %ax,%ax 364: 66 90 xchg %ax,%ax 366: 66 90 xchg %ax,%ax 368: 66 90 xchg %ax,%ax 36a: 66 90 xchg %ax,%ax 36c: 66 90 xchg %ax,%ax 36e: 66 90 xchg %ax,%ax 00000370 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 370: 55 push %ebp 371: 89 e5 mov %esp,%ebp 373: 57 push %edi 374: 56 push %esi 375: 53 push %ebx 376: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 379: 85 d2 test %edx,%edx { 37b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 37e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 380: 79 76 jns 3f8 <printint+0x88> 382: f6 45 08 01 testb $0x1,0x8(%ebp) 386: 74 70 je 3f8 <printint+0x88> x = -xx; 388: f7 d8 neg %eax neg = 1; 38a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 391: 31 f6 xor %esi,%esi 393: 8d 5d d7 lea -0x29(%ebp),%ebx 396: eb 0a jmp 3a2 <printint+0x32> 398: 90 nop 399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3a0: 89 fe mov %edi,%esi 3a2: 31 d2 xor %edx,%edx 3a4: 8d 7e 01 lea 0x1(%esi),%edi 3a7: f7 f1 div %ecx 3a9: 0f b6 92 98 07 00 00 movzbl 0x798(%edx),%edx }while((x /= base) != 0); 3b0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3b2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3b5: 75 e9 jne 3a0 <printint+0x30> if(neg) 3b7: 8b 45 c4 mov -0x3c(%ebp),%eax 3ba: 85 c0 test %eax,%eax 3bc: 74 08 je 3c6 <printint+0x56> buf[i++] = '-'; 3be: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 3c3: 8d 7e 02 lea 0x2(%esi),%edi 3c6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 3ca: 8b 7d c0 mov -0x40(%ebp),%edi 3cd: 8d 76 00 lea 0x0(%esi),%esi 3d0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3d3: 83 ec 04 sub $0x4,%esp 3d6: 83 ee 01 sub $0x1,%esi 3d9: 6a 01 push $0x1 3db: 53 push %ebx 3dc: 57 push %edi 3dd: 88 45 d7 mov %al,-0x29(%ebp) 3e0: e8 ed fe ff ff call 2d2 <write> while(--i >= 0) 3e5: 83 c4 10 add $0x10,%esp 3e8: 39 de cmp %ebx,%esi 3ea: 75 e4 jne 3d0 <printint+0x60> putc(fd, buf[i]); } 3ec: 8d 65 f4 lea -0xc(%ebp),%esp 3ef: 5b pop %ebx 3f0: 5e pop %esi 3f1: 5f pop %edi 3f2: 5d pop %ebp 3f3: c3 ret 3f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3f8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3ff: eb 90 jmp 391 <printint+0x21> 401: eb 0d jmp 410 <printf> 403: 90 nop 404: 90 nop 405: 90 nop 406: 90 nop 407: 90 nop 408: 90 nop 409: 90 nop 40a: 90 nop 40b: 90 nop 40c: 90 nop 40d: 90 nop 40e: 90 nop 40f: 90 nop 00000410 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 53 push %ebx 416: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 419: 8b 75 0c mov 0xc(%ebp),%esi 41c: 0f b6 1e movzbl (%esi),%ebx 41f: 84 db test %bl,%bl 421: 0f 84 b3 00 00 00 je 4da <printf+0xca> ap = (uint*)(void*)&fmt + 1; 427: 8d 45 10 lea 0x10(%ebp),%eax 42a: 83 c6 01 add $0x1,%esi state = 0; 42d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 42f: 89 45 d4 mov %eax,-0x2c(%ebp) 432: eb 2f jmp 463 <printf+0x53> 434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 438: 83 f8 25 cmp $0x25,%eax 43b: 0f 84 a7 00 00 00 je 4e8 <printf+0xd8> write(fd, &c, 1); 441: 8d 45 e2 lea -0x1e(%ebp),%eax 444: 83 ec 04 sub $0x4,%esp 447: 88 5d e2 mov %bl,-0x1e(%ebp) 44a: 6a 01 push $0x1 44c: 50 push %eax 44d: ff 75 08 pushl 0x8(%ebp) 450: e8 7d fe ff ff call 2d2 <write> 455: 83 c4 10 add $0x10,%esp 458: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 45b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 45f: 84 db test %bl,%bl 461: 74 77 je 4da <printf+0xca> if(state == 0){ 463: 85 ff test %edi,%edi c = fmt[i] & 0xff; 465: 0f be cb movsbl %bl,%ecx 468: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 46b: 74 cb je 438 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 46d: 83 ff 25 cmp $0x25,%edi 470: 75 e6 jne 458 <printf+0x48> if(c == 'd'){ 472: 83 f8 64 cmp $0x64,%eax 475: 0f 84 05 01 00 00 je 580 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 47b: 81 e1 f7 00 00 00 and $0xf7,%ecx 481: 83 f9 70 cmp $0x70,%ecx 484: 74 72 je 4f8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 486: 83 f8 73 cmp $0x73,%eax 489: 0f 84 99 00 00 00 je 528 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 48f: 83 f8 63 cmp $0x63,%eax 492: 0f 84 08 01 00 00 je 5a0 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 498: 83 f8 25 cmp $0x25,%eax 49b: 0f 84 ef 00 00 00 je 590 <printf+0x180> write(fd, &c, 1); 4a1: 8d 45 e7 lea -0x19(%ebp),%eax 4a4: 83 ec 04 sub $0x4,%esp 4a7: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4ab: 6a 01 push $0x1 4ad: 50 push %eax 4ae: ff 75 08 pushl 0x8(%ebp) 4b1: e8 1c fe ff ff call 2d2 <write> 4b6: 83 c4 0c add $0xc,%esp 4b9: 8d 45 e6 lea -0x1a(%ebp),%eax 4bc: 88 5d e6 mov %bl,-0x1a(%ebp) 4bf: 6a 01 push $0x1 4c1: 50 push %eax 4c2: ff 75 08 pushl 0x8(%ebp) 4c5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4c8: 31 ff xor %edi,%edi write(fd, &c, 1); 4ca: e8 03 fe ff ff call 2d2 <write> for(i = 0; fmt[i]; i++){ 4cf: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4d3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4d6: 84 db test %bl,%bl 4d8: 75 89 jne 463 <printf+0x53> } } } 4da: 8d 65 f4 lea -0xc(%ebp),%esp 4dd: 5b pop %ebx 4de: 5e pop %esi 4df: 5f pop %edi 4e0: 5d pop %ebp 4e1: c3 ret 4e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 4e8: bf 25 00 00 00 mov $0x25,%edi 4ed: e9 66 ff ff ff jmp 458 <printf+0x48> 4f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 4f8: 83 ec 0c sub $0xc,%esp 4fb: b9 10 00 00 00 mov $0x10,%ecx 500: 6a 00 push $0x0 502: 8b 7d d4 mov -0x2c(%ebp),%edi 505: 8b 45 08 mov 0x8(%ebp),%eax 508: 8b 17 mov (%edi),%edx 50a: e8 61 fe ff ff call 370 <printint> ap++; 50f: 89 f8 mov %edi,%eax 511: 83 c4 10 add $0x10,%esp state = 0; 514: 31 ff xor %edi,%edi ap++; 516: 83 c0 04 add $0x4,%eax 519: 89 45 d4 mov %eax,-0x2c(%ebp) 51c: e9 37 ff ff ff jmp 458 <printf+0x48> 521: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 528: 8b 45 d4 mov -0x2c(%ebp),%eax 52b: 8b 08 mov (%eax),%ecx ap++; 52d: 83 c0 04 add $0x4,%eax 530: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 533: 85 c9 test %ecx,%ecx 535: 0f 84 8e 00 00 00 je 5c9 <printf+0x1b9> while(*s != 0){ 53b: 0f b6 01 movzbl (%ecx),%eax state = 0; 53e: 31 ff xor %edi,%edi s = (char*)*ap; 540: 89 cb mov %ecx,%ebx while(*s != 0){ 542: 84 c0 test %al,%al 544: 0f 84 0e ff ff ff je 458 <printf+0x48> 54a: 89 75 d0 mov %esi,-0x30(%ebp) 54d: 89 de mov %ebx,%esi 54f: 8b 5d 08 mov 0x8(%ebp),%ebx 552: 8d 7d e3 lea -0x1d(%ebp),%edi 555: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 558: 83 ec 04 sub $0x4,%esp s++; 55b: 83 c6 01 add $0x1,%esi 55e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 561: 6a 01 push $0x1 563: 57 push %edi 564: 53 push %ebx 565: e8 68 fd ff ff call 2d2 <write> while(*s != 0){ 56a: 0f b6 06 movzbl (%esi),%eax 56d: 83 c4 10 add $0x10,%esp 570: 84 c0 test %al,%al 572: 75 e4 jne 558 <printf+0x148> 574: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 577: 31 ff xor %edi,%edi 579: e9 da fe ff ff jmp 458 <printf+0x48> 57e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 580: 83 ec 0c sub $0xc,%esp 583: b9 0a 00 00 00 mov $0xa,%ecx 588: 6a 01 push $0x1 58a: e9 73 ff ff ff jmp 502 <printf+0xf2> 58f: 90 nop write(fd, &c, 1); 590: 83 ec 04 sub $0x4,%esp 593: 88 5d e5 mov %bl,-0x1b(%ebp) 596: 8d 45 e5 lea -0x1b(%ebp),%eax 599: 6a 01 push $0x1 59b: e9 21 ff ff ff jmp 4c1 <printf+0xb1> putc(fd, *ap); 5a0: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 5a3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 5a6: 8b 07 mov (%edi),%eax write(fd, &c, 1); 5a8: 6a 01 push $0x1 ap++; 5aa: 83 c7 04 add $0x4,%edi putc(fd, *ap); 5ad: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5b0: 8d 45 e4 lea -0x1c(%ebp),%eax 5b3: 50 push %eax 5b4: ff 75 08 pushl 0x8(%ebp) 5b7: e8 16 fd ff ff call 2d2 <write> ap++; 5bc: 89 7d d4 mov %edi,-0x2c(%ebp) 5bf: 83 c4 10 add $0x10,%esp state = 0; 5c2: 31 ff xor %edi,%edi 5c4: e9 8f fe ff ff jmp 458 <printf+0x48> s = "(null)"; 5c9: bb 8f 07 00 00 mov $0x78f,%ebx while(*s != 0){ 5ce: b8 28 00 00 00 mov $0x28,%eax 5d3: e9 72 ff ff ff jmp 54a <printf+0x13a> 5d8: 66 90 xchg %ax,%ax 5da: 66 90 xchg %ax,%ax 5dc: 66 90 xchg %ax,%ax 5de: 66 90 xchg %ax,%ax 000005e0 <free>: static Header base; static Header *freep; void free(void *ap) { 5e0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5e1: a1 40 0a 00 00 mov 0xa40,%eax { 5e6: 89 e5 mov %esp,%ebp 5e8: 57 push %edi 5e9: 56 push %esi 5ea: 53 push %ebx 5eb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 5ee: 8d 4b f8 lea -0x8(%ebx),%ecx 5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5f8: 39 c8 cmp %ecx,%eax 5fa: 8b 10 mov (%eax),%edx 5fc: 73 32 jae 630 <free+0x50> 5fe: 39 d1 cmp %edx,%ecx 600: 72 04 jb 606 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 602: 39 d0 cmp %edx,%eax 604: 72 32 jb 638 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 606: 8b 73 fc mov -0x4(%ebx),%esi 609: 8d 3c f1 lea (%ecx,%esi,8),%edi 60c: 39 fa cmp %edi,%edx 60e: 74 30 je 640 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 610: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 613: 8b 50 04 mov 0x4(%eax),%edx 616: 8d 34 d0 lea (%eax,%edx,8),%esi 619: 39 f1 cmp %esi,%ecx 61b: 74 3a je 657 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 61d: 89 08 mov %ecx,(%eax) freep = p; 61f: a3 40 0a 00 00 mov %eax,0xa40 } 624: 5b pop %ebx 625: 5e pop %esi 626: 5f pop %edi 627: 5d pop %ebp 628: c3 ret 629: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 630: 39 d0 cmp %edx,%eax 632: 72 04 jb 638 <free+0x58> 634: 39 d1 cmp %edx,%ecx 636: 72 ce jb 606 <free+0x26> { 638: 89 d0 mov %edx,%eax 63a: eb bc jmp 5f8 <free+0x18> 63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 640: 03 72 04 add 0x4(%edx),%esi 643: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 646: 8b 10 mov (%eax),%edx 648: 8b 12 mov (%edx),%edx 64a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 64d: 8b 50 04 mov 0x4(%eax),%edx 650: 8d 34 d0 lea (%eax,%edx,8),%esi 653: 39 f1 cmp %esi,%ecx 655: 75 c6 jne 61d <free+0x3d> p->s.size += bp->s.size; 657: 03 53 fc add -0x4(%ebx),%edx freep = p; 65a: a3 40 0a 00 00 mov %eax,0xa40 p->s.size += bp->s.size; 65f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 662: 8b 53 f8 mov -0x8(%ebx),%edx 665: 89 10 mov %edx,(%eax) } 667: 5b pop %ebx 668: 5e pop %esi 669: 5f pop %edi 66a: 5d pop %ebp 66b: c3 ret 66c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000670 <malloc>: return freep; } void* malloc(uint nbytes) { 670: 55 push %ebp 671: 89 e5 mov %esp,%ebp 673: 57 push %edi 674: 56 push %esi 675: 53 push %ebx 676: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 679: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 67c: 8b 15 40 0a 00 00 mov 0xa40,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 682: 8d 78 07 lea 0x7(%eax),%edi 685: c1 ef 03 shr $0x3,%edi 688: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 68b: 85 d2 test %edx,%edx 68d: 0f 84 9d 00 00 00 je 730 <malloc+0xc0> 693: 8b 02 mov (%edx),%eax 695: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 698: 39 cf cmp %ecx,%edi 69a: 76 6c jbe 708 <malloc+0x98> 69c: 81 ff 00 10 00 00 cmp $0x1000,%edi 6a2: bb 00 10 00 00 mov $0x1000,%ebx 6a7: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6aa: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6b1: eb 0e jmp 6c1 <malloc+0x51> 6b3: 90 nop 6b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6b8: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6ba: 8b 48 04 mov 0x4(%eax),%ecx 6bd: 39 f9 cmp %edi,%ecx 6bf: 73 47 jae 708 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6c1: 39 05 40 0a 00 00 cmp %eax,0xa40 6c7: 89 c2 mov %eax,%edx 6c9: 75 ed jne 6b8 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 6cb: 83 ec 0c sub $0xc,%esp 6ce: 56 push %esi 6cf: e8 66 fc ff ff call 33a <sbrk> if(p == (char*)-1) 6d4: 83 c4 10 add $0x10,%esp 6d7: 83 f8 ff cmp $0xffffffff,%eax 6da: 74 1c je 6f8 <malloc+0x88> hp->s.size = nu; 6dc: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6df: 83 ec 0c sub $0xc,%esp 6e2: 83 c0 08 add $0x8,%eax 6e5: 50 push %eax 6e6: e8 f5 fe ff ff call 5e0 <free> return freep; 6eb: 8b 15 40 0a 00 00 mov 0xa40,%edx if((p = morecore(nunits)) == 0) 6f1: 83 c4 10 add $0x10,%esp 6f4: 85 d2 test %edx,%edx 6f6: 75 c0 jne 6b8 <malloc+0x48> return 0; } } 6f8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 6fb: 31 c0 xor %eax,%eax } 6fd: 5b pop %ebx 6fe: 5e pop %esi 6ff: 5f pop %edi 700: 5d pop %ebp 701: c3 ret 702: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 708: 39 cf cmp %ecx,%edi 70a: 74 54 je 760 <malloc+0xf0> p->s.size -= nunits; 70c: 29 f9 sub %edi,%ecx 70e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 711: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 714: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 717: 89 15 40 0a 00 00 mov %edx,0xa40 } 71d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 720: 83 c0 08 add $0x8,%eax } 723: 5b pop %ebx 724: 5e pop %esi 725: 5f pop %edi 726: 5d pop %ebp 727: c3 ret 728: 90 nop 729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 730: c7 05 40 0a 00 00 44 movl $0xa44,0xa40 737: 0a 00 00 73a: c7 05 44 0a 00 00 44 movl $0xa44,0xa44 741: 0a 00 00 base.s.size = 0; 744: b8 44 0a 00 00 mov $0xa44,%eax 749: c7 05 48 0a 00 00 00 movl $0x0,0xa48 750: 00 00 00 753: e9 44 ff ff ff jmp 69c <malloc+0x2c> 758: 90 nop 759: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 760: 8b 08 mov (%eax),%ecx 762: 89 0a mov %ecx,(%edx) 764: eb b1 jmp 717 <malloc+0xa7>
; A065262: The nonpositive side (-1, -2, -3, ...) of the site swap sequence A065261. The bisection of odd terms of A065261. ; 1,1,5,2,9,3,13,4,17,5,21,6,25,7,29,8,33,9,37,10,41,11,45,12,49,13,53,14,57,15,61,16,65,17,69,18,73,19,77,20,81,21,85,22,89,23,93,24,97,25,101,26,105,27,109,28,113,29,117,30,121,31,125,32,129,33,133,34,137,35,141,36,145,37,149,38,153,39,157,40,161,41,165,42,169,43,173,44,177,45,181,46,185,47,189,48,193,49,197,50 mul $0,6 add $0,2 dif $0,4 div $0,3 add $0,1
#include <iostream> #include "stdio.h" using namespace std; int main() { float s = 0, cont = 1; while(cont <= 100) { s = 1/cont + s; cont = cont + 1; } printf("%.2f\n",s); return 0; }
// Formatting library for C++ - tests of the OS-specific functionality // // Copyright (c) 2012 - present, Victor Zverovich // All rights reserved. // // For the license information refer to format.h. #include "fmt/os.h" #include <cstdlib> // std::exit #include <cstring> #include <memory> #include "gtest-extra.h" #include "util.h" #ifdef fileno # undef fileno #endif using fmt::buffered_file; using fmt::error_code; #ifdef _WIN32 # include <windows.h> TEST(UtilTest, UTF16ToUTF8) { std::string s = "ёжик"; fmt::detail::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A"); EXPECT_EQ(s, u.str()); EXPECT_EQ(s.size(), u.size()); } TEST(UtilTest, UTF16ToUTF8EmptyString) { std::string s = ""; fmt::detail::utf16_to_utf8 u(L""); EXPECT_EQ(s, u.str()); EXPECT_EQ(s.size(), u.size()); } template <typename Converter, typename Char> void check_utf_conversion_error( const char* message, fmt::basic_string_view<Char> str = fmt::basic_string_view<Char>(0, 1)) { fmt::memory_buffer out; fmt::detail::format_windows_error(out, ERROR_INVALID_PARAMETER, message); fmt::system_error error(0, ""); try { (Converter)(str); } catch (const fmt::system_error& e) { error = e; } EXPECT_EQ(ERROR_INVALID_PARAMETER, error.error_code()); EXPECT_EQ(fmt::to_string(out), error.what()); } TEST(UtilTest, UTF16ToUTF8Error) { check_utf_conversion_error<fmt::detail::utf16_to_utf8, wchar_t>( "cannot convert string from UTF-16 to UTF-8"); } TEST(UtilTest, UTF16ToUTF8Convert) { fmt::detail::utf16_to_utf8 u; EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(0, 1))); EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(L"foo", INT_MAX + 1u))); } TEST(UtilTest, FormatWindowsError) { LPWSTR message = 0; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, ERROR_FILE_EXISTS, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>(&message), 0, 0); fmt::detail::utf16_to_utf8 utf8_message(message); LocalFree(message); fmt::memory_buffer actual_message; fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), fmt::to_string(actual_message)); actual_message.resize(0); auto max_size = fmt::detail::max_value<size_t>() / 2; fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, fmt::string_view(nullptr, max_size)); EXPECT_EQ(fmt::format("error {}", ERROR_FILE_EXISTS), fmt::to_string(actual_message)); } TEST(UtilTest, FormatLongWindowsError) { LPWSTR message = 0; // this error code is not available on all Windows platforms and // Windows SDKs, so do not fail the test if the error string cannot // be retrieved. const int provisioning_not_allowed = 0x80284013L /*TBS_E_PROVISIONING_NOT_ALLOWED*/; if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, static_cast<DWORD>(provisioning_not_allowed), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>(&message), 0, 0) == 0) { return; } fmt::detail::utf16_to_utf8 utf8_message(message); LocalFree(message); fmt::memory_buffer actual_message; fmt::detail::format_windows_error(actual_message, provisioning_not_allowed, "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), fmt::to_string(actual_message)); } TEST(UtilTest, WindowsError) { fmt::system_error error(0, ""); try { throw fmt::windows_error(ERROR_FILE_EXISTS, "test {}", "error"); } catch (const fmt::system_error& e) { error = e; } fmt::memory_buffer message; fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, "test error"); EXPECT_EQ(to_string(message), error.what()); EXPECT_EQ(ERROR_FILE_EXISTS, error.error_code()); } TEST(UtilTest, ReportWindowsError) { fmt::memory_buffer out; fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, "test error"); out.push_back('\n'); EXPECT_WRITE(stderr, fmt::report_windows_error(ERROR_FILE_EXISTS, "test error"), fmt::to_string(out)); } #endif // _WIN32 #if FMT_USE_FCNTL using fmt::file; // Checks if the file is open by reading one character from it. static bool isopen(int fd) { char buffer; return FMT_POSIX(read(fd, &buffer, 1)) == 1; } static bool isclosed(int fd) { char buffer; std::streamsize result = 0; SUPPRESS_ASSERT(result = FMT_POSIX(read(fd, &buffer, 1))); return result == -1 && errno == EBADF; } // Opens a file for reading. static file open_file() { file read_end, write_end; file::pipe(read_end, write_end); write_end.write(FILE_CONTENT, std::strlen(FILE_CONTENT)); write_end.close(); return read_end; } // Attempts to write a string to a file. static void write(file& f, fmt::string_view s) { size_t num_chars_left = s.size(); const char* ptr = s.data(); do { size_t count = f.write(ptr, num_chars_left); ptr += count; // We can't write more than size_t bytes since num_chars_left // has type size_t. num_chars_left -= count; } while (num_chars_left != 0); } TEST(BufferedFileTest, DefaultCtor) { buffered_file f; EXPECT_TRUE(f.get() == nullptr); } TEST(BufferedFileTest, MoveCtor) { buffered_file bf = open_buffered_file(); FILE* fp = bf.get(); EXPECT_TRUE(fp != nullptr); buffered_file bf2(std::move(bf)); EXPECT_EQ(fp, bf2.get()); EXPECT_TRUE(bf.get() == nullptr); } TEST(BufferedFileTest, MoveAssignment) { buffered_file bf = open_buffered_file(); FILE* fp = bf.get(); EXPECT_TRUE(fp != nullptr); buffered_file bf2; bf2 = std::move(bf); EXPECT_EQ(fp, bf2.get()); EXPECT_TRUE(bf.get() == nullptr); } TEST(BufferedFileTest, MoveAssignmentClosesFile) { buffered_file bf = open_buffered_file(); buffered_file bf2 = open_buffered_file(); int old_fd = bf2.fileno(); bf2 = std::move(bf); EXPECT_TRUE(isclosed(old_fd)); } TEST(BufferedFileTest, MoveFromTemporaryInCtor) { FILE* fp = nullptr; buffered_file f(open_buffered_file(&fp)); EXPECT_EQ(fp, f.get()); } TEST(BufferedFileTest, MoveFromTemporaryInAssignment) { FILE* fp = nullptr; buffered_file f; f = open_buffered_file(&fp); EXPECT_EQ(fp, f.get()); } TEST(BufferedFileTest, MoveFromTemporaryInAssignmentClosesFile) { buffered_file f = open_buffered_file(); int old_fd = f.fileno(); f = open_buffered_file(); EXPECT_TRUE(isclosed(old_fd)); } TEST(BufferedFileTest, CloseFileInDtor) { int fd = 0; { buffered_file f = open_buffered_file(); fd = f.fileno(); } EXPECT_TRUE(isclosed(fd)); } TEST(BufferedFileTest, CloseErrorInDtor) { std::unique_ptr<buffered_file> f(new buffered_file(open_buffered_file())); EXPECT_WRITE( stderr, { // The close function must be called inside EXPECT_WRITE, // otherwise the system may recycle closed file descriptor when // redirecting the output in EXPECT_STDERR and the second close // will break output redirection. FMT_POSIX(close(f->fileno())); SUPPRESS_ASSERT(f.reset(nullptr)); }, format_system_error(EBADF, "cannot close file") + "\n"); } TEST(BufferedFileTest, Close) { buffered_file f = open_buffered_file(); int fd = f.fileno(); f.close(); EXPECT_TRUE(f.get() == nullptr); EXPECT_TRUE(isclosed(fd)); } TEST(BufferedFileTest, CloseError) { buffered_file f = open_buffered_file(); FMT_POSIX(close(f.fileno())); EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, "cannot close file"); EXPECT_TRUE(f.get() == nullptr); } TEST(BufferedFileTest, Fileno) { buffered_file f; # ifndef __COVERITY__ // fileno on a null FILE pointer either crashes or returns an error. // Disable Coverity because this is intentional. EXPECT_DEATH_IF_SUPPORTED( { try { f.fileno(); } catch (const fmt::system_error&) { std::exit(1); } }, ""); # endif f = open_buffered_file(); EXPECT_TRUE(f.fileno() != -1); file copy = file::dup(f.fileno()); EXPECT_READ(copy, FILE_CONTENT); } TEST(OStreamTest, Move) { fmt::ostream out = fmt::output_file("test-file"); fmt::ostream moved(std::move(out)); moved.print("hello"); } TEST(OStreamTest, Print) { fmt::ostream out = fmt::output_file("test-file"); out.print("The answer is {}.\n", 42); out.close(); file in("test-file", file::RDONLY); EXPECT_READ(in, "The answer is 42.\n"); } TEST(OStreamTest, BufferBoundary) { auto str = std::string(4096, 'x'); fmt::ostream out = fmt::output_file("test-file"); out.print("{}", str); out.print("{}", str); out.close(); file in("test-file", file::RDONLY); EXPECT_READ(in, str + str); } TEST(OStreamTest, BufferSize) { fmt::ostream out = fmt::output_file("test-file", fmt::buffer_size=1); out.print("{}", "foo"); out.close(); file in("test-file", file::RDONLY); EXPECT_READ(in, "foo"); } TEST(OStreamTest, Truncate) { { fmt::ostream out = fmt::output_file("test-file"); out.print("0123456789"); } { fmt::ostream out = fmt::output_file("test-file"); out.print("foo"); } file in("test-file", file::RDONLY); EXPECT_EQ("foo", read(in, 4)); } TEST(FileTest, DefaultCtor) { file f; EXPECT_EQ(-1, f.descriptor()); } TEST(FileTest, OpenBufferedFileInCtor) { FILE* fp = safe_fopen("test-file", "w"); std::fputs(FILE_CONTENT, fp); std::fclose(fp); file f("test-file", file::RDONLY); ASSERT_TRUE(isopen(f.descriptor())); } TEST(FileTest, OpenBufferedFileError) { EXPECT_SYSTEM_ERROR(file("nonexistent", file::RDONLY), ENOENT, "cannot open file nonexistent"); } TEST(FileTest, MoveCtor) { file f = open_file(); int fd = f.descriptor(); EXPECT_NE(-1, fd); file f2(std::move(f)); EXPECT_EQ(fd, f2.descriptor()); EXPECT_EQ(-1, f.descriptor()); } TEST(FileTest, MoveAssignment) { file f = open_file(); int fd = f.descriptor(); EXPECT_NE(-1, fd); file f2; f2 = std::move(f); EXPECT_EQ(fd, f2.descriptor()); EXPECT_EQ(-1, f.descriptor()); } TEST(FileTest, MoveAssignmentClosesFile) { file f = open_file(); file f2 = open_file(); int old_fd = f2.descriptor(); f2 = std::move(f); EXPECT_TRUE(isclosed(old_fd)); } static file OpenBufferedFile(int& fd) { file f = open_file(); fd = f.descriptor(); return f; } TEST(FileTest, MoveFromTemporaryInCtor) { int fd = 0xdead; file f(OpenBufferedFile(fd)); EXPECT_EQ(fd, f.descriptor()); } TEST(FileTest, MoveFromTemporaryInAssignment) { int fd = 0xdead; file f; f = OpenBufferedFile(fd); EXPECT_EQ(fd, f.descriptor()); } TEST(FileTest, MoveFromTemporaryInAssignmentClosesFile) { int fd = 0xdead; file f = open_file(); int old_fd = f.descriptor(); f = OpenBufferedFile(fd); EXPECT_TRUE(isclosed(old_fd)); } TEST(FileTest, CloseFileInDtor) { int fd = 0; { file f = open_file(); fd = f.descriptor(); } EXPECT_TRUE(isclosed(fd)); } TEST(FileTest, CloseErrorInDtor) { std::unique_ptr<file> f(new file(open_file())); EXPECT_WRITE( stderr, { // The close function must be called inside EXPECT_WRITE, // otherwise the system may recycle closed file descriptor when // redirecting the output in EXPECT_STDERR and the second close // will break output redirection. FMT_POSIX(close(f->descriptor())); SUPPRESS_ASSERT(f.reset(nullptr)); }, format_system_error(EBADF, "cannot close file") + "\n"); } TEST(FileTest, Close) { file f = open_file(); int fd = f.descriptor(); f.close(); EXPECT_EQ(-1, f.descriptor()); EXPECT_TRUE(isclosed(fd)); } TEST(FileTest, CloseError) { file f = open_file(); FMT_POSIX(close(f.descriptor())); EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, "cannot close file"); EXPECT_EQ(-1, f.descriptor()); } TEST(FileTest, Read) { file f = open_file(); EXPECT_READ(f, FILE_CONTENT); } TEST(FileTest, ReadError) { file f("test-file", file::WRONLY); char buf; // We intentionally read from a file opened in the write-only mode to // cause error. EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, "cannot read from file"); } TEST(FileTest, Write) { file read_end, write_end; file::pipe(read_end, write_end); write(write_end, "test"); write_end.close(); EXPECT_READ(read_end, "test"); } TEST(FileTest, WriteError) { file f("test-file", file::RDONLY); // We intentionally write to a file opened in the read-only mode to // cause error. EXPECT_SYSTEM_ERROR(f.write(" ", 1), EBADF, "cannot write to file"); } TEST(FileTest, Dup) { file f = open_file(); file copy = file::dup(f.descriptor()); EXPECT_NE(f.descriptor(), copy.descriptor()); EXPECT_EQ(FILE_CONTENT, read(copy, std::strlen(FILE_CONTENT))); } # ifndef __COVERITY__ TEST(FileTest, DupError) { int value = -1; EXPECT_SYSTEM_ERROR_NOASSERT(file::dup(value), EBADF, "cannot duplicate file descriptor -1"); } # endif TEST(FileTest, Dup2) { file f = open_file(); file copy = open_file(); f.dup2(copy.descriptor()); EXPECT_NE(f.descriptor(), copy.descriptor()); EXPECT_READ(copy, FILE_CONTENT); } TEST(FileTest, Dup2Error) { file f = open_file(); EXPECT_SYSTEM_ERROR_NOASSERT( f.dup2(-1), EBADF, fmt::format("cannot duplicate file descriptor {} to -1", f.descriptor())); } TEST(FileTest, Dup2NoExcept) { file f = open_file(); file copy = open_file(); error_code ec; f.dup2(copy.descriptor(), ec); EXPECT_EQ(ec.get(), 0); EXPECT_NE(f.descriptor(), copy.descriptor()); EXPECT_READ(copy, FILE_CONTENT); } TEST(FileTest, Dup2NoExceptError) { file f = open_file(); error_code ec; SUPPRESS_ASSERT(f.dup2(-1, ec)); EXPECT_EQ(EBADF, ec.get()); } TEST(FileTest, Pipe) { file read_end, write_end; file::pipe(read_end, write_end); EXPECT_NE(-1, read_end.descriptor()); EXPECT_NE(-1, write_end.descriptor()); write(write_end, "test"); EXPECT_READ(read_end, "test"); } TEST(FileTest, Fdopen) { file read_end, write_end; file::pipe(read_end, write_end); int read_fd = read_end.descriptor(); EXPECT_EQ(read_fd, FMT_POSIX(fileno(read_end.fdopen("r").get()))); } # ifdef FMT_LOCALE TEST(LocaleTest, Strtod) { fmt::locale loc; const char *start = "4.2", *ptr = start; EXPECT_EQ(4.2, loc.strtod(ptr)); EXPECT_EQ(start + 3, ptr); } # endif #endif // FMT_USE_FCNTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CONSOLE_01_OUTPUT_TERMINAL ; library driver for output terminals ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; The root class of CONSOLE_01_OUTPUT terminals. ; ; This is an abstract class that CONSOLE_01_OUTPUT terminals ; can derive from to change stdio's STDIO_MSG_PUTC and ; STDIO_MSG_WRIT messages into multiple OTERM_MSG_PUTC messages ; which demand output of a single char only. ; ; Other stdio messages are treated as errors or no-ops ; as appropriate. ; ; ;;;;;;;;;;;;;;;;;;;; ; DRIVER CLASS DIAGRAM ; ;;;;;;;;;;;;;;;;;;;; ; ; CONSOLE_01_OUTPUT_TERMINAL (root, abstract) ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; MESSAGES CONSUMED FROM STDIO ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; * STDIO_MSG_PUTC ; Generates multiple OTERM_MSG_PUTC messages. ; ; * STDIO_MSG_WRIT ; Generates multiple OTERM_MSG_PUTC messages. ; ; * STDIO_MSG_SEEK -> no error, do nothing ; * STDIO_MSG_FLSH -> no error, do nothing ; * STDIO_MSG_CLOS -> no error, do nothing ; ; Any other messages are reported as errors via ; error_enotsup_zc ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; MESSAGES GENERATED FOR DERIVED DRIVERS ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; * OTERM_MSG_PUTC ; ; Source of character is stdio. ; ; enter : c = ascii code ; can use : af, bc, de, hl, af' ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;; ; BYTES RESERVED IN FDSTRUCT ; ;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; offset (wrt FDSTRUCT.JP) description ; ; 8..13 mutex SECTION code_driver SECTION code_driver_terminal_output PUBLIC console_01_output_terminal EXTERN STDIO_MSG_WRIT, STDIO_MSG_PUTC, STDIO_MSG_SEEK EXTERN STDIO_MSG_FLSH, STDIO_MSG_CLOS EXTERN console_01_output_stdio_msg_writ, console_01_output_stdio_msg_putc EXTERN error_znc, error_lznc, error_enotsup_zc console_01_output_terminal: cp STDIO_MSG_WRIT jp z, console_01_output_stdio_msg_writ cp STDIO_MSG_PUTC jp z, console_01_output_stdio_msg_putc cp STDIO_MSG_SEEK jp z, error_lznc ; do nothing, report no error cp STDIO_MSG_FLSH jp z, error_znc ; do nothing, report no error cp STDIO_MSG_CLOS jp z, error_znc ; do nothing, report no error jp error_enotsup_zc ; hl = 0 puts FILE stream in error state
addi x10, x0, 10 addi x11, x0, -4 addi x12, x0, 34 addi x13, x0, -23 fcvt.s.w f0, x10 fcvt.s.w f1, x11 fcvt.s.w f2, x12 fcvt.s.w f3, x13 fsgnj.s f10, f0, f1 fsgnjn.s f11, f0, f1 fsgnjx.s f12, f1, f3
; =============================================================== ; Feb 2014 ; =============================================================== ; ; int bv_priority_queue_shrink_to_fit(bv_priority_queue_t *q) ; ; Release any excess memory allocated for the queue. ; ; After calling, priority_queue.capacity == priority_queue.size ; ; =============================================================== SECTION code_clib SECTION code_adt_bv_priority_queue PUBLIC asm_bv_priority_queue_shrink_to_fit EXTERN asm_b_vector_shrink_to_fit asm_bv_priority_queue_shrink_to_fit: inc hl inc hl jp asm_b_vector_shrink_to_fit ; enter : hl = priority_queue * ; ; exit : success ; ; hl = -1 ; carry reset ; ; fail on realloc not getting lock ; ; hl = 0 ; carry set, errno set ; ; uses : af, bc, de, hl
@ OR[280] : Pointer to raw integer @ OR[281] : Start bit-position @ OR[282] : Number of bits in the input @ OR[283] : Return buffer location @ OR[284] : Starting buffer offset @ OR[285] : 0: don't print trailing 0-s, 1: print trailing 0-s @ OR[286] : Number of digits to display (?) @ @ Return: Number of characters printed @ OR[285] determines if OR[289] ends up being 48 (0) or 32 (non-0) 0x0000 (0x000000) 0x1030- f:00010 d: 48 | A = 48 (0x0030) 0x0001 (0x000002) 0x2921- f:00024 d: 289 | OR[289] = A 0x0002 (0x000004) 0x211D- f:00020 d: 285 | A = OR[285] 0x0003 (0x000006) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001) 0x0004 (0x000008) 0x8603- f:00103 d: 3 | P = P + 3 (0x0007), A # 0 0x0005 (0x00000A) 0x1020- f:00010 d: 32 | A = 32 (0x0020) 0x0006 (0x00000C) 0x2921- f:00024 d: 289 | OR[289] = A @ OR[285] also determines if OR[286] gets initialized to 10 (0) or left as it came in (non-0) 0x0007 (0x00000E) 0x211D- f:00020 d: 285 | A = OR[285] 0x0008 (0x000010) 0x8603- f:00103 d: 3 | P = P + 3 (0x000B), A # 0 0x0009 (0x000012) 0x100A- f:00010 d: 10 | A = 10 (0x000A) 0x000A (0x000014) 0x291E- f:00024 d: 286 | OR[286] = A @ @ Load the requested number of bits from the input number into OR[293] (high word) and OR[294] (low word) in the following loop @ (very wierd, but we essentially bit-by-bit shift in the input into the two registers above) @ @ Initialize loop variables OR[293] and OR[294] to both 0. 0x000B (0x000016) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x000C (0x000018) 0x2925- f:00024 d: 293 | OR[293] = A 0x000D (0x00001A) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x000E (0x00001C) 0x2926- f:00024 d: 294 | OR[294] = A @ Shift result (OR[293]:OR[294]) left by one 0x000F (0x00001E) 0x1010- f:00010 d: 16 | A = 16 (0x0010) @ Extract MSB of OR[294] into OR[269] 0x0010 (0x000020) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001) 0x0011 (0x000022) 0x5800- f:00054 d: 0 | B = A 0x0012 (0x000024) 0x2126- f:00020 d: 294 | A = OR[294] @@@@@@@@@@@@@@@@@@@@ THIS IS AT 3bb8 0x0013 (0x000026) 0x4800- f:00044 d: 0 | A = A > B 0x0014 (0x000028) 0x290D- f:00024 d: 269 | OR[269] = A 0x0015 (0x00002A) 0x1001- f:00010 d: 1 | A = 1 (0x0001) @ Shift OR[294] up by 1 0x0016 (0x00002C) 0x5800- f:00054 d: 0 | B = A 0x0017 (0x00002E) 0x2126- f:00020 d: 294 | A = OR[294] 0x0018 (0x000030) 0x4A00- f:00045 d: 0 | A = A < B 0x0019 (0x000032) 0x2926- f:00024 d: 294 | OR[294] = A 0x001A (0x000034) 0x2125- f:00020 d: 293 | A = OR[293] @ Shift OR[293] up by 1, add-in carry from OR[294] (now in OR[269]) @@@@@@@@@@@@@ THIS IS AT 3bc0 0x001B (0x000036) 0x4A00- f:00045 d: 0 | A = A < B 0x001C (0x000038) 0x250D- f:00022 d: 269 | A = A + OR[269] 0x001D (0x00003A) 0x2925- f:00024 d: 293 | OR[293] = A 0x001E (0x00003C) 0x100F- f:00010 d: 15 | A = 15 (0x000F) @ Calculate bit-position (in B) as the lower-order 4 bits of OR[281] (actually 15-(OR[281] & 0xf) 0x001F (0x00003E) 0x2719- f:00023 d: 281 | A = A - OR[281] 0x0020 (0x000040) 0x120F- f:00011 d: 15 | A = A & 15 (0x000F) 0x0021 (0x000042) 0x5800- f:00054 d: 0 | B = A 0x0022 (0x000044) 0x2119- f:00020 d: 281 | A = OR[281] @ Calculate the word-offset from the higer-order bits of OR[281], and load the approparite word 0x0023 (0x000046) 0x0804- f:00004 d: 4 | A = A > 4 (0x0004) 0x0024 (0x000048) 0x2518- f:00022 d: 280 | A = A + OR[280] 0x0025 (0x00004A) 0x290D- f:00024 d: 269 | OR[269] = A 0x0026 (0x00004C) 0x310D- f:00030 d: 269 | A = (OR[269]) 0x0027 (0x00004E) 0x4800- f:00044 d: 0 | A = A > B @ Extract the appropriate bit from the loaded word and store it in OR[287] 0x0028 (0x000050) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001) 0x0029 (0x000052) 0x291F- f:00024 d: 287 | OR[287] = A 0x002A (0x000054) 0x2126- f:00020 d: 294 | A = OR[294] @ Add in the extracted bit as the LSB of OR[294] 0x002B (0x000056) 0x251F- f:00022 d: 287 | A = A + OR[287] 0x002C (0x000058) 0x2926- f:00024 d: 294 | OR[294] = A 0x002D (0x00005A) 0x2F1A- f:00027 d: 282 | OR[282] = OR[282] - 1 @ Decrement bit-count, increment bit-position and loop if necessary 0x002E (0x00005C) 0x2D19- f:00026 d: 281 | OR[281] = OR[281] + 1 0x002F (0x00005E) 0x211A- f:00020 d: 282 | A = OR[282] 0x0030 (0x000060) 0x8E21- f:00107 d: 33 | P = P - 33 (0x000F), A # 0 @ Now we have the extracted number in OR[293]:OR[294]. Still in binary format, but only the relevant bits @ Load current power of 10 from multiplication table below into OR[291] (lower) and OR[290] (higher) 0x0031 (0x000062) 0x211E- f:00020 d: 286 | A = OR[286] @ Load the lower word into OR[291] 0x0032 (0x000064) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001) 0x0033 (0x000066) 0x1C00-0x0097 f:00016 d: 0 | A = A + 151 (0x0097) 0x0035 (0x00006A) 0x2403- f:00022 d: 3 | A = A + OR[3] 0x0036 (0x00006C) 0x2924- f:00024 d: 292 | OR[292] = A 0x0037 (0x00006E) 0x3124- f:00030 d: 292 | A = (OR[292]) 0x0038 (0x000070) 0x2923- f:00024 d: 291 | OR[291] = A 0x0039 (0x000072) 0x2123- f:00020 d: 291 | A = OR[291] 0x003A (0x000074) 0x844C- f:00102 d: 76 | P = P + 76 (0x0086), A = 0 @ Bail if we fall off at the beginning of the table (no power of 10 should have a lower byte of 0) 0x003B (0x000076) 0x2F24- f:00027 d: 292 | OR[292] = OR[292] - 1 @ Load the upper word into OR[290] 0x003C (0x000078) 0x3124- f:00030 d: 292 | A = (OR[292]) 0x003D (0x00007A) 0x2922- f:00024 d: 290 | OR[290] = A 0x003E (0x00007C) 0x2F24- f:00027 d: 292 | OR[292] = OR[292] - 1 @ Update pointer to the next power of 10 (well, previous as we start from the top) @ This seems to be a simple divide loop by continously subtracting OR[291]:OR[290] from OR[293]:OR[294] until we get a negative result (?). We also increment OR[288] in each iteration to get the result 0x003F (0x00007E) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x0040 (0x000080) 0x2920- f:00024 d: 288 | OR[288] = A 0x0041 (0x000082) 0x2D20- f:00026 d: 288 | OR[288] = OR[288] + 1 0x0042 (0x000084) 0x2125- f:00020 d: 293 | A = OR[293] 0x0043 (0x000086) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x0044 (0x000088) 0x2925- f:00024 d: 293 | OR[293] = A 0x0045 (0x00008A) 0x0810- f:00004 d: 16 | A = A > 16 (0x0010) 0x0046 (0x00008C) 0x290F- f:00024 d: 271 | OR[271] = A 0x0047 (0x00008E) 0x2126- f:00020 d: 294 | A = OR[294] 0x0048 (0x000090) 0x2723- f:00023 d: 291 | A = A - OR[291] 0x0049 (0x000092) 0x2926- f:00024 d: 294 | OR[294] = A 0x004A (0x000094) 0x8202- f:00101 d: 2 | P = P + 2 (0x004C), C = 1 0x004B (0x000096) 0x2F25- f:00027 d: 293 | OR[293] = OR[293] - 1 0x004C (0x000098) 0x0810- f:00004 d: 16 | A = A > 16 (0x0010) 0x004D (0x00009A) 0x230F- f:00021 d: 271 | A = A & OR[271] 0x004E (0x00009C) 0x8E0D- f:00107 d: 13 | P = P - 13 (0x0041), A # 0 @ Since we've decremented until the remainder is negative, add once back the divisor (OR[291]:OR[290]) and decement OR[288] to get the true dividend (OR[288]) and remainder (OR[293]:OR[294]) 0x004F (0x00009E) 0x2125- f:00020 d: 293 | A = OR[293] 0x0050 (0x0000A0) 0x2522- f:00022 d: 290 | A = A + OR[290] 0x0051 (0x0000A2) 0x2925- f:00024 d: 293 | OR[293] = A 0x0052 (0x0000A4) 0x2126- f:00020 d: 294 | A = OR[294] 0x0053 (0x0000A6) 0x2523- f:00022 d: 291 | A = A + OR[291] 0x0054 (0x0000A8) 0x2926- f:00024 d: 294 | OR[294] = A 0x0055 (0x0000AA) 0x8002- f:00100 d: 2 | P = P + 2 (0x0057), C = 0 0x0056 (0x0000AC) 0x2D25- f:00026 d: 293 | OR[293] = OR[293] + 1 0x0057 (0x0000AE) 0x2F20- f:00027 d: 288 | OR[288] = OR[288] - 1 0x0058 (0x0000B0) 0x2F1E- f:00027 d: 286 | OR[286] = OR[286] - 1 @ Decrease the number of digits left to process 0x0059 (0x0000B2) 0x1009- f:00010 d: 9 | A = 9 (0x0009) @ Test if digit is biffer than 9 (I guess bail if it is) 0x005A (0x0000B4) 0x2720- f:00023 d: 288 | A = A - OR[288] 0x005B (0x0000B6) 0x8029- f:00100 d: 41 | P = P + 41 (0x0084), C = 0 @ If the digit is non-0, print it and record the fact that we've printed something in OR[285], so subsequent 0-s are also printed @ If the digit is 0, but it's the last digit, print it as well @ If the digit is 0, and not the last one, but OR[285] is 0 (left-aligned, maybe), than simply eat it and continue to the next character @ If the digit is 0, and not the last one, but OR[285] is non-0 (0-filled or character already printed), print it 0x005C (0x0000B8) 0x2120- f:00020 d: 288 | A = OR[288] @ If digit is 0, and it's not the last digit, do something special, otherwise continue 0x005D (0x0000BA) 0x8604- f:00103 d: 4 | P = P + 4 (0x0061), A # 0 0x005E (0x0000BC) 0x211E- f:00020 d: 286 | A = OR[286] 0x005F (0x0000BE) 0x8402- f:00102 d: 2 | P = P + 2 (0x0061), A = 0 0x0060 (0x0000C0) 0x7005- f:00070 d: 5 | P = P + 5 (0x0065) 0x0061 (0x0000C2) 0x1030- f:00010 d: 48 | A = 48 (0x0030) 0x0062 (0x0000C4) 0x2921- f:00024 d: 289 | OR[289] = A 0x0063 (0x0000C6) 0x1002- f:00010 d: 2 | A = 2 (0x0002) 0x0064 (0x0000C8) 0x291D- f:00024 d: 285 | OR[285] = A 0x0065 (0x0000CA) 0x211D- f:00020 d: 285 | A = OR[285] 0x0066 (0x0000CC) 0x8C2F- f:00106 d: 47 | P = P - 47 (0x0037), A = 0 @ Continue on with the next digit @ Print the character into the buffer at OR[283], offset OR[284]. This is a bit tricky as we're running on a 16-bit machine, but essentially write the byte into the buffer 0x0067 (0x0000CE) 0x2120- f:00020 d: 288 | A = OR[288] @ OR[289] contains the offset of '0', so we calculate the ASCII code for the digit 0x0068 (0x0000D0) 0x2521- f:00022 d: 289 | A = A + OR[289] 0x0069 (0x0000D2) 0x2920- f:00024 d: 288 | OR[288] = A 0x006A (0x0000D4) 0x2120- f:00020 d: 288 | A = OR[288] 0x006B (0x0000D6) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF) 0x006C (0x0000D8) 0x290D- f:00024 d: 269 | OR[269] = A 0x006D (0x0000DA) 0x211C- f:00020 d: 284 | A = OR[284] 0x006E (0x0000DC) 0x0801- f:00004 d: 1 | A = A > 1 (0x0001) 0x006F (0x0000DE) 0x251B- f:00022 d: 283 | A = A + OR[283] 0x0070 (0x0000E0) 0x290E- f:00024 d: 270 | OR[270] = A 0x0071 (0x0000E2) 0x211C- f:00020 d: 284 | A = OR[284] 0x0072 (0x0000E4) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001) 0x0073 (0x0000E6) 0x2908- f:00024 d: 264 | OR[264] = A 0x0074 (0x0000E8) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x0075 (0x0000EA) 0x2708- f:00023 d: 264 | A = A - OR[264] 0x0076 (0x0000EC) 0x8607- f:00103 d: 7 | P = P + 7 (0x007D), A # 0 0x0077 (0x0000EE) 0x310E- f:00030 d: 270 | A = (OR[270]) 0x0078 (0x0000F0) 0x0A09- f:00005 d: 9 | A = A < 9 (0x0009) 0x0079 (0x0000F2) 0x250D- f:00022 d: 269 | A = A + OR[269] 0x007A (0x0000F4) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009) 0x007B (0x0000F6) 0x390E- f:00034 d: 270 | (OR[270]) = A 0x007C (0x0000F8) 0x7006- f:00070 d: 6 | P = P + 6 (0x0082) 0x007D (0x0000FA) 0x310E- f:00030 d: 270 | A = (OR[270]) 0x007E (0x0000FC) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00) 0x0080 (0x000100) 0x250D- f:00022 d: 269 | A = A + OR[269] 0x0081 (0x000102) 0x390E- f:00034 d: 270 | (OR[270]) = A 0x0082 (0x000104) 0x2D1C- f:00026 d: 284 | OR[284] = OR[284] + 1 @ Increment byte position 0x0083 (0x000106) 0x724C- f:00071 d: 76 | P = P - 76 (0x0037) @ Continue on with the next digit 0x0084 (0x000108) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ We get here if there's an error, that is a digit got greater than 9 0x0085 (0x00010A) 0x291C- f:00024 d: 284 | OR[284] = A 0x0086 (0x00010C) 0x2005- f:00020 d: 5 | A = OR[5] @ We get here after the conversion is done: Load the return value (Number of characters printed) into the return value location and return from overlay 0x0087 (0x00010E) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006) 0x0088 (0x000110) 0x2908- f:00024 d: 264 | OR[264] = A 0x0089 (0x000112) 0x211C- f:00020 d: 284 | A = OR[284] 0x008A (0x000114) 0x3908- f:00034 d: 264 | (OR[264]) = A 0x008B (0x000116) 0x102A- f:00010 d: 42 | A = 42 (0x002A) 0x008C (0x000118) 0x2927- f:00024 d: 295 | OR[295] = A 0x008D (0x00011A) 0x1127- f:00010 d: 295 | A = 295 (0x0127) 0x008E (0x00011C) 0x5800- f:00054 d: 0 | B = A 0x008F (0x00011E) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x0090 (0x000120) 0x7C09- f:00076 d: 9 | R = OR[9] @ 0-termination of the multiplication table 0x0091 (0x000122) 0x0000- f:00000 d: 0 | PASS @ This is a multiplication table. Values are: 0x00000001 1 0x0000000A 10 0x00000064 100 0x000003E8 1000 0x00002710 10000 0x000186A0 100000 0x000F4240 1000000 0x00989680 10000000 0x05F5E100 100000000 0x3B9ACA00 1000000000 0x0092 (0x000124) 0x0000- f:00000 d: 0 | PASS 0x0093 (0x000126) 0x0001- f:00000 d: 1 | PASS | **** non-standard encoding with D:0x0001 **** 0x0094 (0x000128) 0x0000- f:00000 d: 0 | PASS 0x0095 (0x00012A) 0x000A- f:00000 d: 10 | PASS | **** non-standard encoding with D:0x000A **** 0x0096 (0x00012C) 0x0000- f:00000 d: 0 | PASS 0x0097 (0x00012E) 0x0064- f:00000 d: 100 | PASS | **** non-standard encoding with D:0x0064 **** 0x0098 (0x000130) 0x0000- f:00000 d: 0 | PASS 0x0099 (0x000132) 0x03E8- f:00001 d: 488 | EXIT | **** non-standard encoding with D:0x01E8 **** 0x009A (0x000134) 0x0000- f:00000 d: 0 | PASS 0x009B (0x000136) 0x2710- f:00023 d: 272 | A = A - OR[272] 0x009C (0x000138) 0x0001- f:00000 d: 1 | PASS | **** non-standard encoding with D:0x0001 **** 0x009D (0x00013A) 0x86A0- f:00103 d: 160 | P = P + 160 (0x013D), A # 0 0x009E (0x00013C) 0x000F- f:00000 d: 15 | PASS | **** non-standard encoding with D:0x000F **** 0x009F (0x00013E) 0x4240- f:00041 d: 64 | C = 1, io 0100 = BZ 0x00A0 (0x000140) 0x0098- f:00000 d: 152 | PASS | **** non-standard encoding with D:0x0098 **** 0x00A1 (0x000142) 0x9680- f:00113 d: 128 | R = P + 128 (0x0121), A # 0 0x00A2 (0x000144) 0x05F5- f:00002 d: 501 | I = 0 | **** non-standard encoding with D:0x01F5 **** 0x00A3 (0x000146) 0xE100- f:00160 d: 256 | IOB , fn000 | **** non-standard encoding with D:0x0100 **** 0x00A4 (0x000148) 0x3B9A- f:00035 d: 410 | (OR[410]) = A + (OR[410]) 0x00A5 (0x00014A) 0xCA00- f:00145 d: 0 | io 0000 (IOR), fn005 | **** Undefined function **** 0x00A6 (0x00014C) 0x0000- f:00000 d: 0 | PASS 0x00A7 (0x00014E) 0x0000- f:00000 d: 0 | PASS
; A082804: Smallest multiple of 9 beginning with n. ; Submitted by Jon Maiga ; 18,27,36,45,54,63,72,81,9,108,117,126,135,144,153,162,171,18,198,207,216,225,234,243,252,261,27,288,297,306,315,324,333,342,351,36,378,387,396,405,414,423,432,441,45,468,477,486,495,504,513,522,531,54,558,567,576,585,594,603,612,621,63,648,657,666,675,684,693,702,711,72,738,747,756,765,774,783,792,801,81,828,837,846,855,864,873,882,891,90,918,927,936,945,954,963,972,981,99,1008 mul $0,10 div $0,9 add $0,2 dif $0,10 mul $0,9
// Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "obfuscation.h" #include "coincontrol.h" #include "init.h" #include "main.h" #include "masternodeman.h" #include "script/sign.h" #include "swifttx.h" #include "ui_interface.h" #include "util.h" #include <boost/algorithm/string/replace.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <algorithm> #include <boost/assign/list_of.hpp> #include <openssl/rand.h> using namespace std; using namespace boost; // The main object for accessing Obfuscation CObfuscationPool obfuScationPool; // A helper object for signing messages from Masternodes CObfuScationSigner obfuScationSigner; // The current Obfuscations in progress on the network std::vector<CObfuscationQueue> vecObfuscationQueue; // Keep track of the used Masternodes std::vector<CTxIn> vecMasternodesUsed; // Keep track of the scanning errors I've seen map<uint256, CObfuscationBroadcastTx> mapObfuscationBroadcastTxes; // Keep track of the active Masternode CActiveMasternode activeMasternode; /* *** BEGIN OBFUSCATION MAGIC - DEV ********** Copyright (c) 2014-2015, Dash Developers eduffield - evan@dashpay.io udjinm6 - udjinm6@dashpay.io */ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) { if (fLiteMode) return; //disable all Obfuscation/Masternode related functionality if (!masternodeSync.IsBlockchainSynced()) return; if (strCommand == "dsa") { //Obfuscation Accept Into Pool int errorID; if (pfrom->nVersion < ActiveProtocol()) { errorID = ERR_VERSION; LogPrintf("dsa -- incompatible version! \n"); pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if (!fMasterNode) { errorID = ERR_NOT_A_MN; LogPrintf("dsa -- not a Masternode! \n"); pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } int nDenom; CTransaction txCollateral; vRecv >> nDenom >> txCollateral; CMasternode* pmn = mnodeman.Find(activeMasternode.vin); if (pmn == NULL) { errorID = ERR_MN_LIST; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if (sessionUsers == 0) { if (pmn->nLastDsq != 0 && pmn->nLastDsq + mnodeman.CountEnabled(ActiveProtocol()) / 5 > mnodeman.nDsqCount) { LogPrintf("dsa -- last dsq too recent, must wait. %s \n", pfrom->addr.ToString()); errorID = ERR_RECENT; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } if (!IsCompatibleWithSession(nDenom, txCollateral, errorID)) { LogPrintf("dsa -- not compatible with existing transactions! \n"); pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } else { LogPrintf("dsa -- is compatible, please submit! \n"); pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, errorID); return; } } else if (strCommand == "dsq") { //Obfuscation Queue TRY_LOCK(cs_obfuscation, lockRecv); if (!lockRecv) return; if (pfrom->nVersion < ActiveProtocol()) { return; } CObfuscationQueue dsq; vRecv >> dsq; CService addr; if (!dsq.GetAddress(addr)) return; if (!dsq.CheckSignature()) return; if (dsq.IsExpired()) return; CMasternode* pmn = mnodeman.Find(dsq.vin); if (pmn == NULL) return; // if the queue is ready, submit if we can if (dsq.ready) { if (!pSubmittedToMasternode) return; if ((CNetAddr)pSubmittedToMasternode->addr != (CNetAddr)addr) { LogPrintf("dsq - message doesn't match current Masternode - %s != %s\n", pSubmittedToMasternode->addr.ToString(), addr.ToString()); return; } if (state == POOL_STATUS_QUEUE) { LogPrint("obfuscation", "Obfuscation queue is ready - %s\n", addr.ToString()); PrepareObfuscationDenominate(); } } else { BOOST_FOREACH (CObfuscationQueue q, vecObfuscationQueue) { if (q.vin == dsq.vin) return; } LogPrint("obfuscation", "dsq last %d last2 %d count %d\n", pmn->nLastDsq, pmn->nLastDsq + mnodeman.size() / 5, mnodeman.nDsqCount); //don't allow a few nodes to dominate the queuing process if (pmn->nLastDsq != 0 && pmn->nLastDsq + mnodeman.CountEnabled(ActiveProtocol()) / 5 > mnodeman.nDsqCount) { LogPrint("obfuscation", "dsq -- Masternode sending too many dsq messages. %s \n", pmn->addr.ToString()); return; } mnodeman.nDsqCount++; pmn->nLastDsq = mnodeman.nDsqCount; pmn->allowFreeTx = true; LogPrint("obfuscation", "dsq - new Obfuscation queue object - %s\n", addr.ToString()); vecObfuscationQueue.push_back(dsq); dsq.Relay(); dsq.time = GetTime(); } } else if (strCommand == "dsi") { //ObfuScation vIn int errorID; if (pfrom->nVersion < ActiveProtocol()) { LogPrintf("dsi -- incompatible version! \n"); errorID = ERR_VERSION; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if (!fMasterNode) { LogPrintf("dsi -- not a Masternode! \n"); errorID = ERR_NOT_A_MN; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } std::vector<CTxIn> in; CAmount nAmount; CTransaction txCollateral; std::vector<CTxOut> out; vRecv >> in >> nAmount >> txCollateral >> out; //do we have enough users in the current session? if (!IsSessionReady()) { LogPrintf("dsi -- session not complete! \n"); errorID = ERR_SESSION; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } //do we have the same denominations as the current session? if (!IsCompatibleWithEntries(out)) { LogPrintf("dsi -- not compatible with existing transactions! \n"); errorID = ERR_EXISTING_TX; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } //check it like a transaction { CAmount nValueIn = 0; CAmount nValueOut = 0; bool missingTx = false; CValidationState state; CMutableTransaction tx; BOOST_FOREACH (const CTxOut o, out) { nValueOut += o.nValue; tx.vout.push_back(o); if (o.scriptPubKey.size() != 25) { LogPrintf("dsi - non-standard pubkey detected! %s\n", o.scriptPubKey.ToString()); errorID = ERR_NON_STANDARD_PUBKEY; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if (!o.scriptPubKey.IsNormalPaymentScript()) { LogPrintf("dsi - invalid script! %s\n", o.scriptPubKey.ToString()); errorID = ERR_INVALID_SCRIPT; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } BOOST_FOREACH (const CTxIn i, in) { tx.vin.push_back(i); LogPrint("obfuscation", "dsi -- tx in %s\n", i.ToString()); CTransaction tx2; uint256 hash; if (GetTransaction(i.prevout.hash, tx2, hash, true)) { if (tx2.vout.size() > i.prevout.n) { nValueIn += tx2.vout[i.prevout.n].nValue; } } else { missingTx = true; } } if (nValueIn > OBFUSCATION_POOL_MAX) { LogPrintf("dsi -- more than Obfuscation pool max! %s\n", tx.ToString()); errorID = ERR_MAXIMUM; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if (!missingTx) { if (nValueIn - nValueOut > nValueIn * .01) { LogPrintf("dsi -- fees are too high! %s\n", tx.ToString()); errorID = ERR_FEES; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } else { LogPrintf("dsi -- missing input tx! %s\n", tx.ToString()); errorID = ERR_MISSING_TX; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } { LOCK(cs_main); if (!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL, false, true)) { LogPrintf("dsi -- transaction not valid! \n"); errorID = ERR_INVALID_TX; pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } } if (AddEntry(in, nAmount, txCollateral, out, errorID)) { pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, errorID); Check(); RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } else { pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); } } else if (strCommand == "dssu") { //Obfuscation status update if (pfrom->nVersion < ActiveProtocol()) { return; } if (!pSubmittedToMasternode) return; if ((CNetAddr)pSubmittedToMasternode->addr != (CNetAddr)pfrom->addr) { //LogPrintf("dssu - message doesn't match current Masternode - %s != %s\n", pSubmittedToMasternode->addr.ToString(), pfrom->addr.ToString()); return; } int sessionIDMessage; int state; int entriesCount; int accepted; int errorID; vRecv >> sessionIDMessage >> state >> entriesCount >> accepted >> errorID; LogPrint("obfuscation", "dssu - state: %i entriesCount: %i accepted: %i error: %s \n", state, entriesCount, accepted, GetMessageByID(errorID)); if ((accepted != 1 && accepted != 0) && sessionID != sessionIDMessage) { LogPrintf("dssu - message doesn't match current Obfuscation session %d %d\n", sessionID, sessionIDMessage); return; } StatusUpdate(state, entriesCount, accepted, errorID, sessionIDMessage); } else if (strCommand == "dss") { //Obfuscation Sign Final Tx if (pfrom->nVersion < ActiveProtocol()) { return; } vector<CTxIn> sigs; vRecv >> sigs; bool success = false; int count = 0; BOOST_FOREACH (const CTxIn item, sigs) { if (AddScriptSig(item)) success = true; LogPrint("obfuscation", " -- sigs count %d %d\n", (int)sigs.size(), count); count++; } if (success) { obfuScationPool.Check(); RelayStatus(obfuScationPool.sessionID, obfuScationPool.GetState(), obfuScationPool.GetEntriesCount(), MASTERNODE_RESET); } } else if (strCommand == "dsf") { //Obfuscation Final tx if (pfrom->nVersion < ActiveProtocol()) { return; } if (!pSubmittedToMasternode) return; if ((CNetAddr)pSubmittedToMasternode->addr != (CNetAddr)pfrom->addr) { //LogPrintf("dsc - message doesn't match current Masternode - %s != %s\n", pSubmittedToMasternode->addr.ToString(), pfrom->addr.ToString()); return; } int sessionIDMessage; CTransaction txNew; vRecv >> sessionIDMessage >> txNew; if (sessionID != sessionIDMessage) { LogPrint("obfuscation", "dsf - message doesn't match current Obfuscation session %d %d\n", sessionID, sessionIDMessage); return; } //check to see if input is spent already? (and probably not confirmed) SignFinalTransaction(txNew, pfrom); } else if (strCommand == "dsc") { //Obfuscation Complete if (pfrom->nVersion < ActiveProtocol()) { return; } if (!pSubmittedToMasternode) return; if ((CNetAddr)pSubmittedToMasternode->addr != (CNetAddr)pfrom->addr) { //LogPrintf("dsc - message doesn't match current Masternode - %s != %s\n", pSubmittedToMasternode->addr.ToString(), pfrom->addr.ToString()); return; } int sessionIDMessage; bool error; int errorID; vRecv >> sessionIDMessage >> error >> errorID; if (sessionID != sessionIDMessage) { LogPrint("obfuscation", "dsc - message doesn't match current Obfuscation session %d %d\n", obfuScationPool.sessionID, sessionIDMessage); return; } obfuScationPool.CompletedTransaction(error, errorID); } } int randomizeList(int i) { return std::rand() % i; } void CObfuscationPool::Reset() { cachedLastSuccess = 0; lastNewBlock = 0; txCollateral = CMutableTransaction(); vecMasternodesUsed.clear(); UnlockCoins(); SetNull(); } void CObfuscationPool::SetNull() { // MN side sessionUsers = 0; vecSessionCollateral.clear(); // Client side entriesCount = 0; lastEntryAccepted = 0; countEntriesAccepted = 0; sessionFoundMasternode = false; // Both sides state = POOL_STATUS_IDLE; sessionID = 0; sessionDenom = 0; entries.clear(); finalTransaction.vin.clear(); finalTransaction.vout.clear(); lastTimeChanged = GetTimeMillis(); // -- seed random number generator (used for ordering output lists) unsigned int seed = 0; RAND_bytes((unsigned char*)&seed, sizeof(seed)); std::srand(seed); } bool CObfuscationPool::SetCollateralAddress(std::string strAddress) { CBitcoinAddress address; if (!address.SetString(strAddress)) { LogPrintf("CObfuscationPool::SetCollateralAddress - Invalid Obfuscation collateral address\n"); return false; } collateralPubKey = GetScriptForDestination(address.Get()); return true; } // // Unlock coins after Obfuscation fails or succeeds // void CObfuscationPool::UnlockCoins() { if (!pwalletMain) return; while (true) { TRY_LOCK(pwalletMain->cs_wallet, lockWallet); if (!lockWallet) { MilliSleep(50); continue; } BOOST_FOREACH (CTxIn v, lockedCoins) pwalletMain->UnlockCoin(v.prevout); break; } lockedCoins.clear(); } std::string CObfuscationPool::GetStatus() { static int showingObfuScationMessage = 0; showingObfuScationMessage += 10; std::string suffix = ""; if (chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing || !masternodeSync.IsBlockchainSynced()) { return strAutoDenomResult; } switch (state) { case POOL_STATUS_IDLE: return _("Obfuscation is idle."); case POOL_STATUS_ACCEPTING_ENTRIES: if (entriesCount == 0) { showingObfuScationMessage = 0; return strAutoDenomResult; } else if (lastEntryAccepted == 1) { if (showingObfuScationMessage % 10 > 8) { lastEntryAccepted = 0; showingObfuScationMessage = 0; } return _("Obfuscation request complete:") + " " + _("Your transaction was accepted into the pool!"); } else { std::string suffix = ""; if (showingObfuScationMessage % 70 <= 40) return strprintf(_("Submitted following entries to masternode: %u / %d"), entriesCount, GetMaxPoolTransactions()); else if (showingObfuScationMessage % 70 <= 50) suffix = "."; else if (showingObfuScationMessage % 70 <= 60) suffix = ".."; else if (showingObfuScationMessage % 70 <= 70) suffix = "..."; return strprintf(_("Submitted to masternode, waiting for more entries ( %u / %d ) %s"), entriesCount, GetMaxPoolTransactions(), suffix); } case POOL_STATUS_SIGNING: if (showingObfuScationMessage % 70 <= 40) return _("Found enough users, signing ..."); else if (showingObfuScationMessage % 70 <= 50) suffix = "."; else if (showingObfuScationMessage % 70 <= 60) suffix = ".."; else if (showingObfuScationMessage % 70 <= 70) suffix = "..."; return strprintf(_("Found enough users, signing ( waiting %s )"), suffix); case POOL_STATUS_TRANSMISSION: return _("Transmitting final transaction."); case POOL_STATUS_FINALIZE_TRANSACTION: return _("Finalizing transaction."); case POOL_STATUS_ERROR: return _("Obfuscation request incomplete:") + " " + lastMessage + " " + _("Will retry..."); case POOL_STATUS_SUCCESS: return _("Obfuscation request complete:") + " " + lastMessage; case POOL_STATUS_QUEUE: if (showingObfuScationMessage % 70 <= 30) suffix = "."; else if (showingObfuScationMessage % 70 <= 50) suffix = ".."; else if (showingObfuScationMessage % 70 <= 70) suffix = "..."; return strprintf(_("Submitted to masternode, waiting in queue %s"), suffix); ; default: return strprintf(_("Unknown state: id = %u"), state); } } // // Check the Obfuscation progress and send client updates if a Masternode // void CObfuscationPool::Check() { if (fMasterNode) LogPrint("obfuscation", "CObfuscationPool::Check() - entries count %lu\n", entries.size()); //printf("CObfuscationPool::Check() %d - %d - %d\n", state, anonTx.CountEntries(), GetTimeMillis()-lastTimeChanged); if (fMasterNode) { LogPrint("obfuscation", "CObfuscationPool::Check() - entries count %lu\n", entries.size()); // If entries is full, then move on to the next phase if (state == POOL_STATUS_ACCEPTING_ENTRIES && (int)entries.size() >= GetMaxPoolTransactions()) { LogPrint("obfuscation", "CObfuscationPool::Check() -- TRYING TRANSACTION \n"); UpdateState(POOL_STATUS_FINALIZE_TRANSACTION); } } // create the finalized transaction for distribution to the clients if (state == POOL_STATUS_FINALIZE_TRANSACTION) { LogPrint("obfuscation", "CObfuscationPool::Check() -- FINALIZE TRANSACTIONS\n"); UpdateState(POOL_STATUS_SIGNING); if (fMasterNode) { CMutableTransaction txNew; // make our new transaction for (unsigned int i = 0; i < entries.size(); i++) { BOOST_FOREACH (const CTxOut& v, entries[i].vout) txNew.vout.push_back(v); BOOST_FOREACH (const CTxDSIn& s, entries[i].sev) txNew.vin.push_back(s); } // shuffle the outputs for improved anonymity std::random_shuffle(txNew.vin.begin(), txNew.vin.end(), randomizeList); std::random_shuffle(txNew.vout.begin(), txNew.vout.end(), randomizeList); LogPrint("obfuscation", "Transaction 1: %s\n", txNew.ToString()); finalTransaction = txNew; // request signatures from clients RelayFinalTransaction(sessionID, finalTransaction); } } // If we have all of the signatures, try to compile the transaction if (fMasterNode && state == POOL_STATUS_SIGNING && SignaturesComplete()) { LogPrint("obfuscation", "CObfuscationPool::Check() -- SIGNING\n"); UpdateState(POOL_STATUS_TRANSMISSION); CheckFinalTransaction(); } // reset if we're here for 10 seconds if ((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis() - lastTimeChanged >= 10000) { LogPrint("obfuscation", "CObfuscationPool::Check() -- timeout, RESETTING\n"); UnlockCoins(); SetNull(); if (fMasterNode) RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } } void CObfuscationPool::CheckFinalTransaction() { if (!fMasterNode) return; // check and relay final tx only on masternode CWalletTx txNew = CWalletTx(pwalletMain, finalTransaction); LOCK2(cs_main, pwalletMain->cs_wallet); { LogPrint("obfuscation", "Transaction 2: %s\n", txNew.ToString()); // See if the transaction is valid if (!txNew.AcceptToMemoryPool(false, true, true)) { LogPrintf("CObfuscationPool::Check() - CommitTransaction : Error: Transaction not valid\n"); SetNull(); // not much we can do in this case UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); RelayCompletedTransaction(sessionID, true, ERR_INVALID_TX); return; } LogPrintf("CObfuscationPool::Check() -- IS MASTER -- TRANSMITTING OBFUSCATION\n"); // sign a message int64_t sigTime = GetAdjustedTime(); std::string strMessage = txNew.GetHash().ToString() + std::to_string(sigTime); std::string strError = ""; std::vector<unsigned char> vchSig; CKey key2; CPubKey pubkey2; if (!obfuScationSigner.SetKey(strMasterNodePrivKey, strError, key2, pubkey2)) { LogPrintf("CObfuscationPool::Check() - ERROR: Invalid Masternodeprivkey: '%s'\n", strError); return; } if (!obfuScationSigner.SignMessage(strMessage, strError, vchSig, key2)) { LogPrintf("CObfuscationPool::Check() - Sign message failed\n"); return; } if (!obfuScationSigner.VerifyMessage(pubkey2, vchSig, strMessage, strError)) { LogPrintf("CObfuscationPool::Check() - Verify message failed\n"); return; } if (!mapObfuscationBroadcastTxes.count(txNew.GetHash())) { CObfuscationBroadcastTx dstx; dstx.tx = txNew; dstx.vin = activeMasternode.vin; dstx.vchSig = vchSig; dstx.sigTime = sigTime; mapObfuscationBroadcastTxes.insert(make_pair(txNew.GetHash(), dstx)); } CInv inv(MSG_DSTX, txNew.GetHash()); RelayInv(inv); // Tell the clients it was successful RelayCompletedTransaction(sessionID, false, MSG_SUCCESS); // Randomly charge clients ChargeRandomFees(); // Reset LogPrint("obfuscation", "CObfuscationPool::Check() -- COMPLETED -- RESETTING\n"); SetNull(); RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } } // // Charge clients a fee if they're abusive // // Why bother? Obfuscation uses collateral to ensure abuse to the process is kept to a minimum. // The submission and signing stages in Obfuscation are completely separate. In the cases where // a client submits a transaction then refused to sign, there must be a cost. Otherwise they // would be able to do this over and over again and bring the mixing to a hault. // // How does this work? Messages to Masternodes come in via "dsi", these require a valid collateral // transaction for the client to be able to enter the pool. This transaction is kept by the Masternode // until the transaction is either complete or fails. // void CObfuscationPool::ChargeFees() { if (!fMasterNode) return; //we don't need to charge collateral for every offence. int offences = 0; int r = rand() % 100; if (r > 33) return; if (state == POOL_STATUS_ACCEPTING_ENTRIES) { BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { bool found = false; BOOST_FOREACH (const CObfuScationEntry& v, entries) { if (v.collateral == txCollateral) { found = true; } } // This queue entry didn't send us the promised transaction if (!found) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't send transaction). Found offence.\n"); offences++; } } } if (state == POOL_STATUS_SIGNING) { // who didn't sign? BOOST_FOREACH (const CObfuScationEntry v, entries) { BOOST_FOREACH (const CTxDSIn s, v.sev) { if (!s.fHasSig) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). Found offence\n"); offences++; } } } } r = rand() % 100; int target = 0; //mostly offending? if (offences >= Params().PoolMaxTransactions() - 1 && r > 33) return; //everyone is an offender? That's not right if (offences >= Params().PoolMaxTransactions()) return; //charge one of the offenders randomly if (offences > 1) target = 50; //pick random client to charge r = rand() % 100; if (state == POOL_STATUS_ACCEPTING_ENTRIES) { BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { bool found = false; BOOST_FOREACH (const CObfuScationEntry& v, entries) { if (v.collateral == txCollateral) { found = true; } } // This queue entry didn't send us the promised transaction if (!found && r > target) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't send transaction). charging fees.\n"); CWalletTx wtxCollateral = CWalletTx(pwalletMain, txCollateral); // Broadcast if (!wtxCollateral.AcceptToMemoryPool(true)) { // This must not fail. The transaction has already been signed and recorded. LogPrintf("CObfuscationPool::ChargeFees() : Error: Transaction not valid"); } wtxCollateral.RelayWalletTransaction(); return; } } } if (state == POOL_STATUS_SIGNING) { // who didn't sign? BOOST_FOREACH (const CObfuScationEntry v, entries) { BOOST_FOREACH (const CTxDSIn s, v.sev) { if (!s.fHasSig && r > target) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). charging fees.\n"); CWalletTx wtxCollateral = CWalletTx(pwalletMain, v.collateral); // Broadcast if (!wtxCollateral.AcceptToMemoryPool(false)) { // This must not fail. The transaction has already been signed and recorded. LogPrintf("CObfuscationPool::ChargeFees() : Error: Transaction not valid"); } wtxCollateral.RelayWalletTransaction(); return; } } } } } // charge the collateral randomly // - Obfuscation is completely free, to pay miners we randomly pay the collateral of users. void CObfuscationPool::ChargeRandomFees() { if (fMasterNode) { int i = 0; BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { int r = rand() % 100; /* Collateral Fee Charges: Being that Obfuscation has "no fees" we need to have some kind of cost associated with using it to stop abuse. Otherwise it could serve as an attack vector and allow endless transaction that would bloat Deviant-Core and make it unusable. To stop these kinds of attacks 1 in 10 successful transactions are charged. This adds up to a cost of 0.001 DEV per transaction on average. */ if (r <= 10) { LogPrintf("CObfuscationPool::ChargeRandomFees -- charging random fees. %u\n", i); CWalletTx wtxCollateral = CWalletTx(pwalletMain, txCollateral); // Broadcast if (!wtxCollateral.AcceptToMemoryPool(true)) { // This must not fail. The transaction has already been signed and recorded. LogPrintf("CObfuscationPool::ChargeRandomFees() : Error: Transaction not valid"); } wtxCollateral.RelayWalletTransaction(); } } } } // // Check for various timeouts (queue objects, Obfuscation, etc) // void CObfuscationPool::CheckTimeout() { if (!fEnableZeromint && !fMasterNode) return; // catching hanging sessions if (!fMasterNode) { switch (state) { case POOL_STATUS_TRANSMISSION: LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session complete -- Running Check()\n"); Check(); break; case POOL_STATUS_ERROR: LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Pool error -- Running Check()\n"); Check(); break; case POOL_STATUS_SUCCESS: LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Pool success -- Running Check()\n"); Check(); break; } } // check Obfuscation queue objects for timeouts int c = 0; vector<CObfuscationQueue>::iterator it = vecObfuscationQueue.begin(); while (it != vecObfuscationQueue.end()) { if ((*it).IsExpired()) { LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() : Removing expired queue entry - %d\n", c); it = vecObfuscationQueue.erase(it); } else ++it; c++; } int addLagTime = 0; if (!fMasterNode) addLagTime = 10000; //if we're the client, give the server a few extra seconds before resetting. if (state == POOL_STATUS_ACCEPTING_ENTRIES || state == POOL_STATUS_QUEUE) { c = 0; // check for a timeout and reset if needed vector<CObfuScationEntry>::iterator it2 = entries.begin(); while (it2 != entries.end()) { if ((*it2).IsExpired()) { LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() : Removing expired entry - %d\n", c); it2 = entries.erase(it2); if (entries.size() == 0) { UnlockCoins(); SetNull(); } if (fMasterNode) { RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } } else ++it2; c++; } if (GetTimeMillis() - lastTimeChanged >= (OBFUSCATION_QUEUE_TIMEOUT * 1000) + addLagTime) { UnlockCoins(); SetNull(); } } else if (GetTimeMillis() - lastTimeChanged >= (OBFUSCATION_QUEUE_TIMEOUT * 1000) + addLagTime) { LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- resetting\n", OBFUSCATION_QUEUE_TIMEOUT); UnlockCoins(); SetNull(); UpdateState(POOL_STATUS_ERROR); lastMessage = _("Session timed out."); } if (state == POOL_STATUS_SIGNING && GetTimeMillis() - lastTimeChanged >= (OBFUSCATION_SIGNING_TIMEOUT * 1000) + addLagTime) { LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- restting\n", OBFUSCATION_SIGNING_TIMEOUT); ChargeFees(); UnlockCoins(); SetNull(); UpdateState(POOL_STATUS_ERROR); lastMessage = _("Signing timed out."); } } // // Check for complete queue // void CObfuscationPool::CheckForCompleteQueue() { if (!fEnableZeromint && !fMasterNode) return; /* Check to see if we're ready for submissions from clients */ // // After receiving multiple dsa messages, the queue will switch to "accepting entries" // which is the active state right before merging the transaction // if (state == POOL_STATUS_QUEUE && sessionUsers == GetMaxPoolTransactions()) { UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); CObfuscationQueue dsq; dsq.nDenom = sessionDenom; dsq.vin = activeMasternode.vin; dsq.time = GetTime(); dsq.ready = true; dsq.Sign(); dsq.Relay(); } } // check to see if the signature is valid bool CObfuscationPool::SignatureValid(const CScript& newSig, const CTxIn& newVin) { CMutableTransaction txNew; txNew.vin.clear(); txNew.vout.clear(); int found = -1; CScript sigPubKey = CScript(); unsigned int i = 0; BOOST_FOREACH (CObfuScationEntry& e, entries) { BOOST_FOREACH (const CTxOut& out, e.vout) txNew.vout.push_back(out); BOOST_FOREACH (const CTxDSIn& s, e.sev) { txNew.vin.push_back(s); if (s == newVin) { found = i; sigPubKey = s.prevPubKey; } i++; } } if (found >= 0) { //might have to do this one input at a time? int n = found; txNew.vin[n].scriptSig = newSig; LogPrint("obfuscation", "CObfuscationPool::SignatureValid() - Sign with sig %s\n", newSig.ToString().substr(0, 24)); if (!VerifyScript(txNew.vin[n].scriptSig, sigPubKey, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, MutableTransactionSignatureChecker(&txNew, n))) { LogPrint("obfuscation", "CObfuscationPool::SignatureValid() - Signing - Error signing input %u\n", n); return false; } } LogPrint("obfuscation", "CObfuscationPool::SignatureValid() - Signing - Successfully validated input\n"); return true; } // check to make sure the collateral provided by the client is valid bool CObfuscationPool::IsCollateralValid(const CTransaction& txCollateral) { if (txCollateral.vout.size() < 1) return false; if (txCollateral.nLockTime != 0) return false; int64_t nValueIn = 0; int64_t nValueOut = 0; bool missingTx = false; BOOST_FOREACH (const CTxOut o, txCollateral.vout) { nValueOut += o.nValue; if (!o.scriptPubKey.IsNormalPaymentScript()) { LogPrintf("CObfuscationPool::IsCollateralValid - Invalid Script %s\n", txCollateral.ToString()); return false; } } BOOST_FOREACH (const CTxIn i, txCollateral.vin) { CTransaction tx2; uint256 hash; if (GetTransaction(i.prevout.hash, tx2, hash, true)) { if (tx2.vout.size() > i.prevout.n) { nValueIn += tx2.vout[i.prevout.n].nValue; } } else { missingTx = true; } } if (missingTx) { LogPrint("obfuscation", "CObfuscationPool::IsCollateralValid - Unknown inputs in collateral transaction - %s\n", txCollateral.ToString()); return false; } //collateral transactions are required to pay out OBFUSCATION_COLLATERAL as a fee to the miners if (nValueIn - nValueOut < OBFUSCATION_COLLATERAL) { LogPrint("obfuscation", "CObfuscationPool::IsCollateralValid - did not include enough fees in transaction %d\n%s\n", nValueOut - nValueIn, txCollateral.ToString()); return false; } LogPrint("obfuscation", "CObfuscationPool::IsCollateralValid %s\n", txCollateral.ToString()); { LOCK(cs_main); CValidationState state; if (!AcceptableInputs(mempool, state, txCollateral, true, NULL)) { if (fDebug) LogPrintf("CObfuscationPool::IsCollateralValid - didn't pass IsAcceptable\n"); return false; } } return true; } // // Add a clients transaction to the pool // bool CObfuscationPool::AddEntry(const std::vector<CTxIn>& newInput, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector<CTxOut>& newOutput, int& errorID) { if (!fMasterNode) return false; BOOST_FOREACH (CTxIn in, newInput) { if (in.prevout.IsNull() || nAmount < 0) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - input not valid!\n"); errorID = ERR_INVALID_INPUT; sessionUsers--; return false; } } if (!IsCollateralValid(txCollateral)) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - collateral not valid!\n"); errorID = ERR_INVALID_COLLATERAL; sessionUsers--; return false; } if ((int)entries.size() >= GetMaxPoolTransactions()) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - entries is full!\n"); errorID = ERR_ENTRIES_FULL; sessionUsers--; return false; } BOOST_FOREACH (CTxIn in, newInput) { LogPrint("obfuscation", "looking for vin -- %s\n", in.ToString()); BOOST_FOREACH (const CObfuScationEntry& v, entries) { BOOST_FOREACH (const CTxDSIn& s, v.sev) { if ((CTxIn)s == in) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - found in vin\n"); errorID = ERR_ALREADY_HAVE; sessionUsers--; return false; } } } } CObfuScationEntry v; v.Add(newInput, nAmount, txCollateral, newOutput); entries.push_back(v); LogPrint("obfuscation", "CObfuscationPool::AddEntry -- adding %s\n", newInput[0].ToString()); errorID = MSG_ENTRIES_ADDED; return true; } bool CObfuscationPool::AddScriptSig(const CTxIn& newVin) { LogPrint("obfuscation", "CObfuscationPool::AddScriptSig -- new sig %s\n", newVin.scriptSig.ToString().substr(0, 24)); BOOST_FOREACH (const CObfuScationEntry& v, entries) { BOOST_FOREACH (const CTxDSIn& s, v.sev) { if (s.scriptSig == newVin.scriptSig) { LogPrint("obfuscation", "CObfuscationPool::AddScriptSig - already exists\n"); return false; } } } if (!SignatureValid(newVin.scriptSig, newVin)) { LogPrint("obfuscation", "CObfuscationPool::AddScriptSig - Invalid Sig\n"); return false; } LogPrint("obfuscation", "CObfuscationPool::AddScriptSig -- sig %s\n", newVin.ToString()); BOOST_FOREACH (CTxIn& vin, finalTransaction.vin) { if (newVin.prevout == vin.prevout && vin.nSequence == newVin.nSequence) { vin.scriptSig = newVin.scriptSig; vin.prevPubKey = newVin.prevPubKey; LogPrint("obfuscation", "CObfuScationPool::AddScriptSig -- adding to finalTransaction %s\n", newVin.scriptSig.ToString().substr(0, 24)); } } for (unsigned int i = 0; i < entries.size(); i++) { if (entries[i].AddSig(newVin)) { LogPrint("obfuscation", "CObfuScationPool::AddScriptSig -- adding %s\n", newVin.scriptSig.ToString().substr(0, 24)); return true; } } LogPrintf("CObfuscationPool::AddScriptSig -- Couldn't set sig!\n"); return false; } // Check to make sure everything is signed bool CObfuscationPool::SignaturesComplete() { BOOST_FOREACH (const CObfuScationEntry& v, entries) { BOOST_FOREACH (const CTxDSIn& s, v.sev) { if (!s.fHasSig) return false; } } return true; } // // Execute a Obfuscation denomination via a Masternode. // This is only ran from clients // void CObfuscationPool::SendObfuscationDenominate(std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, CAmount amount) { if (fMasterNode) { LogPrintf("CObfuscationPool::SendObfuscationDenominate() - Obfuscation from a Masternode is not supported currently.\n"); return; } if (txCollateral == CMutableTransaction()) { LogPrintf("CObfuscationPool:SendObfuscationDenominate() - Obfuscation collateral not set"); return; } // lock the funds we're going to use BOOST_FOREACH (CTxIn in, txCollateral.vin) lockedCoins.push_back(in); BOOST_FOREACH (CTxIn in, vin) lockedCoins.push_back(in); //BOOST_FOREACH(CTxOut o, vout) // LogPrintf(" vout - %s\n", o.ToString()); // we should already be connected to a Masternode if (!sessionFoundMasternode) { LogPrintf("CObfuscationPool::SendObfuscationDenominate() - No Masternode has been selected yet.\n"); UnlockCoins(); SetNull(); return; } if (!CheckDiskSpace()) { UnlockCoins(); SetNull(); fEnableZeromint = false; LogPrintf("CObfuscationPool::SendObfuscationDenominate() - Not enough disk space, disabling Obfuscation.\n"); return; } UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); LogPrintf("CObfuscationPool::SendObfuscationDenominate() - Added transaction to pool.\n"); ClearLastMessage(); //check it against the memory pool to make sure it's valid { CAmount nValueOut = 0; CValidationState state; CMutableTransaction tx; BOOST_FOREACH (const CTxOut& o, vout) { nValueOut += o.nValue; tx.vout.push_back(o); } BOOST_FOREACH (const CTxIn& i, vin) { tx.vin.push_back(i); LogPrint("obfuscation", "dsi -- tx in %s\n", i.ToString()); } LogPrintf("Submitting tx %s\n", tx.ToString()); while (true) { TRY_LOCK(cs_main, lockMain); if (!lockMain) { MilliSleep(50); continue; } if (!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL, false, true)) { LogPrintf("dsi -- transaction not valid! %s \n", tx.ToString()); UnlockCoins(); SetNull(); return; } break; } } // store our entry for later use CObfuScationEntry e; e.Add(vin, amount, txCollateral, vout); entries.push_back(e); RelayIn(entries[0].sev, entries[0].amount, txCollateral, entries[0].vout); Check(); } // Incoming message from Masternode updating the progress of Obfuscation // newAccepted: -1 mean's it'n not a "transaction accepted/not accepted" message, just a standard update // 0 means transaction was not accepted // 1 means transaction was accepted bool CObfuscationPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted, int& errorID, int newSessionID) { if (fMasterNode) return false; if (state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; UpdateState(newState); entriesCount = newEntriesCount; if (errorID != MSG_NOERR) strAutoDenomResult = _("Masternode:") + " " + GetMessageByID(errorID); if (newAccepted != -1) { lastEntryAccepted = newAccepted; countEntriesAccepted += newAccepted; if (newAccepted == 0) { UpdateState(POOL_STATUS_ERROR); lastMessage = GetMessageByID(errorID); } if (newAccepted == 1 && newSessionID != 0) { sessionID = newSessionID; LogPrintf("CObfuscationPool::StatusUpdate - set sessionID to %d\n", sessionID); sessionFoundMasternode = true; } } if (newState == POOL_STATUS_ACCEPTING_ENTRIES) { if (newAccepted == 1) { LogPrintf("CObfuscationPool::StatusUpdate - entry accepted! \n"); sessionFoundMasternode = true; //wait for other users. Masternode will report when ready UpdateState(POOL_STATUS_QUEUE); } else if (newAccepted == 0 && sessionID == 0 && !sessionFoundMasternode) { LogPrintf("CObfuscationPool::StatusUpdate - entry not accepted by Masternode \n"); UnlockCoins(); UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); DoAutomaticDenominating(); //try another Masternode } if (sessionFoundMasternode) return true; } return true; } // // After we receive the finalized transaction from the Masternode, we must // check it to make sure it's what we want, then sign it if we agree. // If we refuse to sign, it's possible we'll be charged collateral // bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node) { if (fMasterNode) return false; finalTransaction = finalTransactionNew; LogPrintf("CObfuscationPool::SignFinalTransaction %s", finalTransaction.ToString()); vector<CTxIn> sigs; //make sure my inputs/outputs are present, otherwise refuse to sign BOOST_FOREACH (const CObfuScationEntry e, entries) { BOOST_FOREACH (const CTxDSIn s, e.sev) { /* Sign my transaction and all outputs */ int mine = -1; CScript prevPubKey = CScript(); CTxIn vin = CTxIn(); for (unsigned int i = 0; i < finalTransaction.vin.size(); i++) { if (finalTransaction.vin[i] == s) { mine = i; prevPubKey = s.prevPubKey; vin = s; } } if (mine >= 0) { //might have to do this one input at a time? int foundOutputs = 0; CAmount nValue1 = 0; CAmount nValue2 = 0; for (unsigned int i = 0; i < finalTransaction.vout.size(); i++) { BOOST_FOREACH (const CTxOut& o, e.vout) { if (finalTransaction.vout[i] == o) { foundOutputs++; nValue1 += finalTransaction.vout[i].nValue; } } } BOOST_FOREACH (const CTxOut o, e.vout) nValue2 += o.nValue; int targetOuputs = e.vout.size(); if (foundOutputs < targetOuputs || nValue1 != nValue2) { // in this case, something went wrong and we'll refuse to sign. It's possible we'll be charged collateral. But that's // better then signing if the transaction doesn't look like what we wanted. LogPrintf("CObfuscationPool::Sign - My entries are not correct! Refusing to sign. %d entries %d target. \n", foundOutputs, targetOuputs); UnlockCoins(); SetNull(); return false; } const CKeyStore& keystore = *pwalletMain; LogPrint("obfuscation", "CObfuscationPool::Sign - Signing my input %i\n", mine); if (!SignSignature(keystore, prevPubKey, finalTransaction, mine, int(SIGHASH_ALL | SIGHASH_ANYONECANPAY))) { // changes scriptSig LogPrint("obfuscation", "CObfuscationPool::Sign - Unable to sign my own transaction! \n"); // not sure what to do here, it will timeout...? } sigs.push_back(finalTransaction.vin[mine]); LogPrint("obfuscation", " -- dss %d %d %s\n", mine, (int)sigs.size(), finalTransaction.vin[mine].scriptSig.ToString()); } } LogPrint("obfuscation", "CObfuscationPool::Sign - txNew:\n%s", finalTransaction.ToString()); } // push all of our signatures to the Masternode if (sigs.size() > 0 && node != NULL) node->PushMessage("dss", sigs); return true; } void CObfuscationPool::NewBlock() { LogPrint("obfuscation", "CObfuscationPool::NewBlock \n"); //we we're processing lots of blocks, we'll just leave if (GetTime() - lastNewBlock < 10) return; lastNewBlock = GetTime(); obfuScationPool.CheckTimeout(); } // Obfuscation transaction was completed (failed or successful) void CObfuscationPool::CompletedTransaction(bool error, int errorID) { if (fMasterNode) return; if (error) { LogPrintf("CompletedTransaction -- error \n"); UpdateState(POOL_STATUS_ERROR); Check(); UnlockCoins(); SetNull(); } else { LogPrintf("CompletedTransaction -- success \n"); UpdateState(POOL_STATUS_SUCCESS); UnlockCoins(); SetNull(); // To avoid race conditions, we'll only let DS run once per block cachedLastSuccess = chainActive.Tip()->nHeight; } lastMessage = GetMessageByID(errorID); } void CObfuscationPool::ClearLastMessage() { lastMessage = ""; } // // Passively run Obfuscation in the background to anonymize funds based on the given configuration. // // This does NOT run by default for daemons, only for QT. // bool CObfuscationPool::DoAutomaticDenominating(bool fDryRun) { return false; // Disabled until Obfuscation is completely removed if (!fEnableZeromint) return false; if (fMasterNode) return false; if (state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; if (GetEntriesCount() > 0) { strAutoDenomResult = _("Mixing in progress..."); return false; } TRY_LOCK(cs_obfuscation, lockDS); if (!lockDS) { strAutoDenomResult = _("Lock is already in place."); return false; } if (!masternodeSync.IsBlockchainSynced()) { strAutoDenomResult = _("Can't mix while sync in progress."); return false; } if (!fDryRun && pwalletMain->IsLocked()) { strAutoDenomResult = _("Wallet is locked."); return false; } if (chainActive.Tip()->nHeight - cachedLastSuccess < minBlockSpacing) { LogPrintf("CObfuscationPool::DoAutomaticDenominating - Last successful Obfuscation action was too recent\n"); strAutoDenomResult = _("Last successful Obfuscation action was too recent."); return false; } if (mnodeman.size() == 0) { LogPrint("obfuscation", "CObfuscationPool::DoAutomaticDenominating - No Masternodes detected\n"); strAutoDenomResult = _("No Masternodes detected."); return false; } // ** find the coins we'll use std::vector<CTxIn> vCoins; CAmount nValueMin = CENT; CAmount nValueIn = 0; CAmount nOnlyDenominatedBalance; CAmount nBalanceNeedsDenominated; // should not be less than fees in OBFUSCATION_COLLATERAL + few (lets say 5) smallest denoms CAmount nLowestDenom = OBFUSCATION_COLLATERAL + obfuScationDenominations[obfuScationDenominations.size() - 1] * 5; // if there are no OBF collateral inputs yet if (!pwalletMain->HasCollateralInputs()) // should have some additional amount for them nLowestDenom += OBFUSCATION_COLLATERAL * 4; CAmount nBalanceNeedsAnonymized = nAnonymizedeviantAmount * COIN - pwalletMain->GetAnonymizedBalance(); // if balanceNeedsAnonymized is more than pool max, take the pool max if (nBalanceNeedsAnonymized > OBFUSCATION_POOL_MAX) nBalanceNeedsAnonymized = OBFUSCATION_POOL_MAX; // if balanceNeedsAnonymized is more than non-anonymized, take non-anonymized CAmount nAnonymizableBalance = pwalletMain->GetAnonymizableBalance(); if (nBalanceNeedsAnonymized > nAnonymizableBalance) nBalanceNeedsAnonymized = nAnonymizableBalance; if (nBalanceNeedsAnonymized < nLowestDenom) { LogPrintf("DoAutomaticDenominating : No funds detected in need of denominating \n"); strAutoDenomResult = _("No funds detected in need of denominating."); return false; } LogPrint("obfuscation", "DoAutomaticDenominating : nLowestDenom=%d, nBalanceNeedsAnonymized=%d\n", nLowestDenom, nBalanceNeedsAnonymized); // select coins that should be given to the pool if (!pwalletMain->SelectCoinsDark(nValueMin, nBalanceNeedsAnonymized, vCoins, nValueIn, 0, nZeromintPercentage)) { nValueIn = 0; vCoins.clear(); if (pwalletMain->SelectCoinsDark(nValueMin, 9999999 * COIN, vCoins, nValueIn, -2, 0)) { nOnlyDenominatedBalance = pwalletMain->GetDenominatedBalance(true) + pwalletMain->GetDenominatedBalance() - pwalletMain->GetAnonymizedBalance(); nBalanceNeedsDenominated = nBalanceNeedsAnonymized - nOnlyDenominatedBalance; if (nBalanceNeedsDenominated > nValueIn) nBalanceNeedsDenominated = nValueIn; if (nBalanceNeedsDenominated < nLowestDenom) return false; // most likely we just waiting for denoms to confirm if (!fDryRun) return CreateDenominated(nBalanceNeedsDenominated); return true; } else { LogPrintf("DoAutomaticDenominating : Can't denominate - no compatible inputs left\n"); strAutoDenomResult = _("Can't denominate: no compatible inputs left."); return false; } } if (fDryRun) return true; nOnlyDenominatedBalance = pwalletMain->GetDenominatedBalance(true) + pwalletMain->GetDenominatedBalance() - pwalletMain->GetAnonymizedBalance(); nBalanceNeedsDenominated = nBalanceNeedsAnonymized - nOnlyDenominatedBalance; //check if we have should create more denominated inputs if (nBalanceNeedsDenominated > nOnlyDenominatedBalance) return CreateDenominated(nBalanceNeedsDenominated); //check if we have the collateral sized inputs if (!pwalletMain->HasCollateralInputs()) return !pwalletMain->HasCollateralInputs(false) && MakeCollateralAmounts(); std::vector<CTxOut> vOut; // initial phase, find a Masternode if (!sessionFoundMasternode) { // Clean if there is anything left from previous session UnlockCoins(); SetNull(); int nUseQueue = rand() % 100; UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); if (pwalletMain->GetDenominatedBalance(true) > 0) { //get denominated unconfirmed inputs LogPrintf("DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n"); strAutoDenomResult = _("Found unconfirmed denominated outputs, will wait till they confirm to continue."); return false; } //check our collateral nad create new if needed std::string strReason; CValidationState state; if (txCollateral == CMutableTransaction()) { if (!pwalletMain->CreateCollateralTransaction(txCollateral, strReason)) { LogPrintf("% -- create collateral error:%s\n", __func__, strReason); return false; } } else { if (!IsCollateralValid(txCollateral)) { LogPrintf("%s -- invalid collateral, recreating...\n", __func__); if (!pwalletMain->CreateCollateralTransaction(txCollateral, strReason)) { LogPrintf("%s -- create collateral error: %s\n", __func__, strReason); return false; } } } //if we've used 90% of the Masternode list then drop all the oldest first int nThreshold = (int)(mnodeman.CountEnabled(ActiveProtocol()) * 0.9); LogPrint("obfuscation", "Checking vecMasternodesUsed size %d threshold %d\n", (int)vecMasternodesUsed.size(), nThreshold); while ((int)vecMasternodesUsed.size() > nThreshold) { vecMasternodesUsed.erase(vecMasternodesUsed.begin()); LogPrint("obfuscation", " vecMasternodesUsed size %d threshold %d\n", (int)vecMasternodesUsed.size(), nThreshold); } //don't use the queues all of the time for mixing if (nUseQueue > 33) { // Look through the queues and see if anything matches BOOST_FOREACH (CObfuscationQueue& dsq, vecObfuscationQueue) { CService addr; if (dsq.time == 0) continue; if (!dsq.GetAddress(addr)) continue; if (dsq.IsExpired()) continue; int protocolVersion; if (!dsq.GetProtocolVersion(protocolVersion)) continue; if (protocolVersion < ActiveProtocol()) continue; //non-denom's are incompatible if ((dsq.nDenom & (1 << 4))) continue; bool fUsed = false; //don't reuse Masternodes BOOST_FOREACH (CTxIn usedVin, vecMasternodesUsed) { if (dsq.vin == usedVin) { fUsed = true; break; } } if (fUsed) continue; std::vector<CTxIn> vTempCoins; std::vector<COutput> vTempCoins2; // Try to match their denominations if possible if (!pwalletMain->SelectCoinsByDenominations(dsq.nDenom, nValueMin, nBalanceNeedsAnonymized, vTempCoins, vTempCoins2, nValueIn, 0, nZeromintPercentage)) { LogPrintf("DoAutomaticDenominating --- Couldn't match denominations %d\n", dsq.nDenom); continue; } CMasternode* pmn = mnodeman.Find(dsq.vin); if (pmn == NULL) { LogPrintf("DoAutomaticDenominating --- dsq vin %s is not in masternode list!", dsq.vin.ToString()); continue; } LogPrintf("DoAutomaticDenominating --- attempt to connect to masternode from queue %s\n", pmn->addr.ToString()); lastTimeChanged = GetTimeMillis(); // connect to Masternode and submit the queue request CNode* pnode = ConnectNode((CAddress)addr, NULL, true); if (pnode != NULL) { pSubmittedToMasternode = pmn; vecMasternodesUsed.push_back(dsq.vin); sessionDenom = dsq.nDenom; pnode->PushMessage("dsa", sessionDenom, txCollateral); LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %d - %s\n", sessionDenom, pnode->addr.ToString()); strAutoDenomResult = _("Mixing in progress..."); dsq.time = 0; //remove node return true; } else { LogPrintf("DoAutomaticDenominating --- error connecting \n"); strAutoDenomResult = _("Error connecting to Masternode."); dsq.time = 0; //remove node continue; } } } // do not initiate queue if we are a liquidity proveder to avoid useless inter-mixing if (nLiquidityProvider) return false; int i = 0; // otherwise, try one randomly while (i < 10) { CMasternode* pmn = mnodeman.FindRandomNotInVec(vecMasternodesUsed, ActiveProtocol()); if (pmn == NULL) { LogPrintf("DoAutomaticDenominating --- Can't find random masternode!\n"); strAutoDenomResult = _("Can't find random Masternode."); return false; } if (pmn->nLastDsq != 0 && pmn->nLastDsq + mnodeman.CountEnabled(ActiveProtocol()) / 5 > mnodeman.nDsqCount) { i++; continue; } lastTimeChanged = GetTimeMillis(); LogPrintf("DoAutomaticDenominating --- attempt %d connection to Masternode %s\n", i, pmn->addr.ToString()); CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, true); if (pnode != NULL) { pSubmittedToMasternode = pmn; vecMasternodesUsed.push_back(pmn->vin); std::vector<CAmount> vecAmounts; pwalletMain->ConvertList(vCoins, vecAmounts); // try to get a single random denom out of vecAmounts while (sessionDenom == 0) sessionDenom = GetDenominationsByAmounts(vecAmounts); pnode->PushMessage("dsa", sessionDenom, txCollateral); LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %d\n", sessionDenom); strAutoDenomResult = _("Mixing in progress..."); return true; } else { vecMasternodesUsed.push_back(pmn->vin); // postpone MN we wasn't able to connect to i++; continue; } } strAutoDenomResult = _("No compatible Masternode found."); return false; } strAutoDenomResult = _("Mixing in progress..."); return false; } bool CObfuscationPool::PrepareObfuscationDenominate() { std::string strError = ""; // Submit transaction to the pool if we get here // Try to use only inputs with the same number of rounds starting from lowest number of rounds possible for (int i = 0; i < nZeromintPercentage; i++) { strError = pwalletMain->PrepareObfuscationDenominate(i, i + 1); LogPrintf("DoAutomaticDenominating : Running Obfuscation denominate for %d rounds. Return '%s'\n", i, strError); if (strError == "") return true; } // We failed? That's strange but let's just make final attempt and try to mix everything strError = pwalletMain->PrepareObfuscationDenominate(0, nZeromintPercentage); LogPrintf("DoAutomaticDenominating : Running Obfuscation denominate for all rounds. Return '%s'\n", strError); if (strError == "") return true; // Should never actually get here but just in case strAutoDenomResult = strError; LogPrintf("DoAutomaticDenominating : Error running denominate, %s\n", strError); return false; } bool CObfuscationPool::SendRandomPaymentToSelf() { int64_t nBalance = pwalletMain->GetBalance(); int64_t nPayment = (nBalance * 0.35) + (rand() % nBalance); if (nPayment > nBalance) nPayment = nBalance - (0.1 * COIN); // make our change address CReserveKey reservekey(pwalletMain); CScript scriptChange; CPubKey vchPubKey; assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked scriptChange = GetScriptForDestination(vchPubKey.GetID()); CWalletTx wtx; CAmount nFeeRet = 0; std::string strFail = ""; vector<pair<CScript, CAmount> > vecSend; // ****** Add fees ************ / vecSend.push_back(make_pair(scriptChange, nPayment)); CCoinControl* coinControl = NULL; bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, strFail, coinControl, ONLY_DENOMINATED); if (!success) { LogPrintf("SendRandomPaymentToSelf: Error - %s\n", strFail); return false; } pwalletMain->CommitTransaction(wtx, reservekey); LogPrintf("SendRandomPaymentToSelf Success: tx %s\n", wtx.GetHash().GetHex()); return true; } // Split up large inputs or create fee sized inputs bool CObfuscationPool::MakeCollateralAmounts() { CWalletTx wtx; CAmount nFeeRet = 0; std::string strFail = ""; vector<pair<CScript, CAmount> > vecSend; CCoinControl coinControl; coinControl.fAllowOtherInputs = false; coinControl.fAllowWatchOnly = false; // make our collateral address CReserveKey reservekeyCollateral(pwalletMain); // make our change address CReserveKey reservekeyChange(pwalletMain); CScript scriptCollateral; CPubKey vchPubKey; assert(reservekeyCollateral.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked scriptCollateral = GetScriptForDestination(vchPubKey.GetID()); vecSend.push_back(make_pair(scriptCollateral, OBFUSCATION_COLLATERAL * 4)); // try to use non-denominated and not mn-like funds bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange, nFeeRet, strFail, &coinControl, ONLY_NONDENOMINATED_NOT10000IFMN); if (!success) { // if we failed (most likeky not enough funds), try to use all coins instead - // MN-like funds should not be touched in any case and we can't mix denominated without collaterals anyway CCoinControl* coinControlNull = NULL; LogPrintf("MakeCollateralAmounts: ONLY_NONDENOMINATED_NOT10000IFMN Error - %s\n", strFail); success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange, nFeeRet, strFail, coinControlNull, ONLY_NOT10000IFMN); if (!success) { LogPrintf("MakeCollateralAmounts: ONLY_NOT10000IFMN Error - %s\n", strFail); reservekeyCollateral.ReturnKey(); return false; } } reservekeyCollateral.KeepKey(); LogPrintf("MakeCollateralAmounts: tx %s\n", wtx.GetHash().GetHex()); // use the same cachedLastSuccess as for DS mixinx to prevent race if (!pwalletMain->CommitTransaction(wtx, reservekeyChange)) { LogPrintf("MakeCollateralAmounts: CommitTransaction failed!\n"); return false; } cachedLastSuccess = chainActive.Tip()->nHeight; return true; } // Create denominations bool CObfuscationPool::CreateDenominated(CAmount nTotalValue) { CWalletTx wtx; CAmount nFeeRet = 0; std::string strFail = ""; vector<pair<CScript, CAmount> > vecSend; CAmount nValueLeft = nTotalValue; // make our collateral address CReserveKey reservekeyCollateral(pwalletMain); // make our change address CReserveKey reservekeyChange(pwalletMain); // make our denom addresses CReserveKey reservekeyDenom(pwalletMain); CScript scriptCollateral; CPubKey vchPubKey; assert(reservekeyCollateral.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked scriptCollateral = GetScriptForDestination(vchPubKey.GetID()); // ****** Add collateral outputs ************ / if (!pwalletMain->HasCollateralInputs()) { vecSend.push_back(make_pair(scriptCollateral, OBFUSCATION_COLLATERAL * 4)); nValueLeft -= OBFUSCATION_COLLATERAL * 4; } // ****** Add denoms ************ / BOOST_REVERSE_FOREACH (CAmount v, obfuScationDenominations) { int nOutputs = 0; // add each output up to 10 times until it can't be added again while (nValueLeft - v >= OBFUSCATION_COLLATERAL && nOutputs <= 10) { CScript scriptDenom; CPubKey vchPubKey; //use a unique change address assert(reservekeyDenom.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked scriptDenom = GetScriptForDestination(vchPubKey.GetID()); // TODO: do not keep reservekeyDenom here reservekeyDenom.KeepKey(); vecSend.push_back(make_pair(scriptDenom, v)); //increment outputs and subtract denomination amount nOutputs++; nValueLeft -= v; LogPrintf("CreateDenominated1 %d\n", nValueLeft); } if (nValueLeft == 0) break; } LogPrintf("CreateDenominated2 %d\n", nValueLeft); // if we have anything left over, it will be automatically send back as change - there is no need to send it manually CCoinControl* coinControl = NULL; bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekeyChange, nFeeRet, strFail, coinControl, ONLY_NONDENOMINATED_NOT10000IFMN); if (!success) { LogPrintf("CreateDenominated: Error - %s\n", strFail); // TODO: return reservekeyDenom here reservekeyCollateral.ReturnKey(); return false; } // TODO: keep reservekeyDenom here reservekeyCollateral.KeepKey(); // use the same cachedLastSuccess as for DS mixinx to prevent race if (pwalletMain->CommitTransaction(wtx, reservekeyChange)) cachedLastSuccess = chainActive.Tip()->nHeight; else LogPrintf("CreateDenominated: CommitTransaction failed!\n"); LogPrintf("CreateDenominated: tx %s\n", wtx.GetHash().GetHex()); return true; } bool CObfuscationPool::IsCompatibleWithEntries(std::vector<CTxOut>& vout) { if (GetDenominations(vout) == 0) return false; BOOST_FOREACH (const CObfuScationEntry v, entries) { LogPrintf(" IsCompatibleWithEntries %d %d\n", GetDenominations(vout), GetDenominations(v.vout)); /* BOOST_FOREACH(CTxOut o1, vout) LogPrintf(" vout 1 - %s\n", o1.ToString()); BOOST_FOREACH(CTxOut o2, v.vout) LogPrintf(" vout 2 - %s\n", o2.ToString()); */ if (GetDenominations(vout) != GetDenominations(v.vout)) return false; } return true; } bool CObfuscationPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, int& errorID) { if (nDenom == 0) return false; LogPrintf("CObfuscationPool::IsCompatibleWithSession - sessionDenom %d sessionUsers %d\n", sessionDenom, sessionUsers); if (!unitTest && !IsCollateralValid(txCollateral)) { LogPrint("obfuscation", "CObfuscationPool::IsCompatibleWithSession - collateral not valid!\n"); errorID = ERR_INVALID_COLLATERAL; return false; } if (sessionUsers < 0) sessionUsers = 0; if (sessionUsers == 0) { sessionID = 1 + (rand() % 999999); sessionDenom = nDenom; sessionUsers++; lastTimeChanged = GetTimeMillis(); if (!unitTest) { //broadcast that I'm accepting entries, only if it's the first entry through CObfuscationQueue dsq; dsq.nDenom = nDenom; dsq.vin = activeMasternode.vin; dsq.time = GetTime(); dsq.Sign(); dsq.Relay(); } UpdateState(POOL_STATUS_QUEUE); vecSessionCollateral.push_back(txCollateral); return true; } if ((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE) || sessionUsers >= GetMaxPoolTransactions()) { if ((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE)) errorID = ERR_MODE; if (sessionUsers >= GetMaxPoolTransactions()) errorID = ERR_QUEUE_FULL; LogPrintf("CObfuscationPool::IsCompatibleWithSession - incompatible mode, return false %d %d\n", state != POOL_STATUS_ACCEPTING_ENTRIES, sessionUsers >= GetMaxPoolTransactions()); return false; } if (nDenom != sessionDenom) { errorID = ERR_DENOM; return false; } LogPrintf("CObfuScationPool::IsCompatibleWithSession - compatible\n"); sessionUsers++; lastTimeChanged = GetTimeMillis(); vecSessionCollateral.push_back(txCollateral); return true; } //create a nice string to show the denominations void CObfuscationPool::GetDenominationsToString(int nDenom, std::string& strDenom) { // Function returns as follows: // // bit 0 - 100DEV+1 ( bit on if present ) // bit 1 - 10DEV+1 // bit 2 - 1DEV+1 // bit 3 - .1DEV+1 // bit 3 - non-denom strDenom = ""; if (nDenom & (1 << 0)) { if (strDenom.size() > 0) strDenom += "+"; strDenom += "100"; } if (nDenom & (1 << 1)) { if (strDenom.size() > 0) strDenom += "+"; strDenom += "10"; } if (nDenom & (1 << 2)) { if (strDenom.size() > 0) strDenom += "+"; strDenom += "1"; } if (nDenom & (1 << 3)) { if (strDenom.size() > 0) strDenom += "+"; strDenom += "0.1"; } } int CObfuscationPool::GetDenominations(const std::vector<CTxDSOut>& vout) { std::vector<CTxOut> vout2; BOOST_FOREACH (CTxDSOut out, vout) vout2.push_back(out); return GetDenominations(vout2); } // return a bitshifted integer representing the denominations in this list int CObfuscationPool::GetDenominations(const std::vector<CTxOut>& vout, bool fSingleRandomDenom) { std::vector<pair<int64_t, int> > denomUsed; // make a list of denominations, with zero uses BOOST_FOREACH (int64_t d, obfuScationDenominations) denomUsed.push_back(make_pair(d, 0)); // look for denominations and update uses to 1 BOOST_FOREACH (CTxOut out, vout) { bool found = false; BOOST_FOREACH (PAIRTYPE(int64_t, int) & s, denomUsed) { if (out.nValue == s.first) { s.second = 1; found = true; } } if (!found) return 0; } int denom = 0; int c = 0; // if the denomination is used, shift the bit on. // then move to the next BOOST_FOREACH (PAIRTYPE(int64_t, int) & s, denomUsed) { int bit = (fSingleRandomDenom ? rand() % 2 : 1) * s.second; denom |= bit << c++; if (fSingleRandomDenom && bit) break; // use just one random denomination } // Function returns as follows: // // bit 0 - 100DEV+1 ( bit on if present ) // bit 1 - 10DEV+1 // bit 2 - 1DEV+1 // bit 3 - .1DEV+1 return denom; } int CObfuscationPool::GetDenominationsByAmounts(std::vector<CAmount>& vecAmount) { CScript e = CScript(); std::vector<CTxOut> vout1; // Make outputs by looping through denominations, from small to large BOOST_REVERSE_FOREACH (CAmount v, vecAmount) { CTxOut o(v, e); vout1.push_back(o); } return GetDenominations(vout1, true); } int CObfuscationPool::GetDenominationsByAmount(CAmount nAmount, int nDenomTarget) { CScript e = CScript(); CAmount nValueLeft = nAmount; std::vector<CTxOut> vout1; // Make outputs by looping through denominations, from small to large BOOST_REVERSE_FOREACH (CAmount v, obfuScationDenominations) { if (nDenomTarget != 0) { bool fAccepted = false; if ((nDenomTarget & (1 << 0)) && v == ((100 * COIN) + 100000)) { fAccepted = true; } else if ((nDenomTarget & (1 << 1)) && v == ((10 * COIN) + 10000)) { fAccepted = true; } else if ((nDenomTarget & (1 << 2)) && v == ((1 * COIN) + 1000)) { fAccepted = true; } else if ((nDenomTarget & (1 << 3)) && v == ((.1 * COIN) + 100)) { fAccepted = true; } if (!fAccepted) continue; } int nOutputs = 0; // add each output up to 10 times until it can't be added again while (nValueLeft - v >= 0 && nOutputs <= 10) { CTxOut o(v, e); vout1.push_back(o); nValueLeft -= v; nOutputs++; } LogPrintf("GetDenominationsByAmount --- %d nOutputs %d\n", v, nOutputs); } return GetDenominations(vout1); } std::string CObfuscationPool::GetMessageByID(int messageID) { switch (messageID) { case ERR_ALREADY_HAVE: return _("Already have that input."); case ERR_DENOM: return _("No matching denominations found for mixing."); case ERR_ENTRIES_FULL: return _("Entries are full."); case ERR_EXISTING_TX: return _("Not compatible with existing transactions."); case ERR_FEES: return _("Transaction fees are too high."); case ERR_INVALID_COLLATERAL: return _("Collateral not valid."); case ERR_INVALID_INPUT: return _("Input is not valid."); case ERR_INVALID_SCRIPT: return _("Invalid script detected."); case ERR_INVALID_TX: return _("Transaction not valid."); case ERR_MAXIMUM: return _("Value more than Obfuscation pool maximum allows."); case ERR_MN_LIST: return _("Not in the Masternode list."); case ERR_MODE: return _("Incompatible mode."); case ERR_NON_STANDARD_PUBKEY: return _("Non-standard public key detected."); case ERR_NOT_A_MN: return _("This is not a Masternode."); case ERR_QUEUE_FULL: return _("Masternode queue is full."); case ERR_RECENT: return _("Last Obfuscation was too recent."); case ERR_SESSION: return _("Session not complete!"); case ERR_MISSING_TX: return _("Missing input transaction information."); case ERR_VERSION: return _("Incompatible version."); case MSG_SUCCESS: return _("Transaction created successfully."); case MSG_ENTRIES_ADDED: return _("Your entries added successfully."); case MSG_NOERR: default: return ""; } } bool CObfuScationSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey) { CScript payee2; payee2 = GetScriptForDestination(pubkey.GetID()); CTransaction txVin; uint256 hash; if (GetTransaction(vin.prevout.hash, txVin, hash, true)) { BOOST_FOREACH (CTxOut out, txVin.vout) { if (out.nValue == Params().MasternodeCollateralLimit() * COIN) { if (out.scriptPubKey == payee2) return true; } } } return false; } bool CObfuScationSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey) { CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); if (!fGood) { errorMessage = _("Invalid private key."); return false; } key = vchSecret.GetKey(); pubkey = key.GetPubKey(); return true; } bool CObfuScationSigner::GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet) { CBitcoinSecret vchSecret; if (!vchSecret.SetString(strSecret)) return false; keyRet = vchSecret.GetKey(); pubkeyRet = keyRet.GetPubKey(); return true; } bool CObfuScationSigner::SignMessage(std::string strMessage, std::string& errorMessage, vector<unsigned char>& vchSig, CKey key) { CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; if (!key.SignCompact(ss.GetHash(), vchSig)) { errorMessage = _("Signing failed."); return false; } return true; } bool CObfuScationSigner::VerifyMessage(CPubKey pubkey, vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage) { CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; CPubKey pubkey2; if (!pubkey2.RecoverCompact(ss.GetHash(), vchSig)) { errorMessage = _("Error recovering public key."); return false; } if (fDebug && pubkey2.GetID() != pubkey.GetID()) LogPrintf("CObfuScationSigner::VerifyMessage -- keys don't match: %s %s\n", pubkey2.GetID().ToString(), pubkey.GetID().ToString()); return (pubkey2.GetID() == pubkey.GetID()); } bool CObfuscationQueue::Sign() { if (!fMasterNode) return false; std::string strMessage = vin.ToString() + std::to_string(nDenom) + std::to_string(time) + std::to_string(ready); CKey key2; CPubKey pubkey2; std::string errorMessage = ""; if (!obfuScationSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2)) { LogPrintf("CObfuscationQueue():Relay - ERROR: Invalid Masternodeprivkey: '%s'\n", errorMessage); return false; } if (!obfuScationSigner.SignMessage(strMessage, errorMessage, vchSig, key2)) { LogPrintf("CObfuscationQueue():Relay - Sign message failed"); return false; } if (!obfuScationSigner.VerifyMessage(pubkey2, vchSig, strMessage, errorMessage)) { LogPrintf("CObfuscationQueue():Relay - Verify message failed"); return false; } return true; } bool CObfuscationQueue::Relay() { LOCK(cs_vNodes); BOOST_FOREACH (CNode* pnode, vNodes) { // always relay to everyone pnode->PushMessage("dsq", (*this)); } return true; } bool CObfuscationQueue::CheckSignature() { CMasternode* pmn = mnodeman.Find(vin); if (pmn != NULL) { std::string strMessage = vin.ToString() + std::to_string(nDenom) + std::to_string(time) + std::to_string(ready); std::string errorMessage = ""; if (!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) { return error("CObfuscationQueue::CheckSignature() - Got bad Masternode address signature %s \n", vin.ToString().c_str()); } return true; } return false; } void CObfuscationPool::RelayFinalTransaction(const int sessionID, const CTransaction& txNew) { LOCK(cs_vNodes); BOOST_FOREACH (CNode* pnode, vNodes) { pnode->PushMessage("dsf", sessionID, txNew); } } void CObfuscationPool::RelayIn(const std::vector<CTxDSIn>& vin, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector<CTxDSOut>& vout) { if (!pSubmittedToMasternode) return; std::vector<CTxIn> vin2; std::vector<CTxOut> vout2; BOOST_FOREACH (CTxDSIn in, vin) vin2.push_back(in); BOOST_FOREACH (CTxDSOut out, vout) vout2.push_back(out); CNode* pnode = FindNode(pSubmittedToMasternode->addr); if (pnode != NULL) { LogPrintf("RelayIn - found master, relaying message - %s \n", pnode->addr.ToString()); pnode->PushMessage("dsi", vin2, nAmount, txCollateral, vout2); } } void CObfuscationPool::RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID) { LOCK(cs_vNodes); BOOST_FOREACH (CNode* pnode, vNodes) pnode->PushMessage("dssu", sessionID, newState, newEntriesCount, newAccepted, errorID); } void CObfuscationPool::RelayCompletedTransaction(const int sessionID, const bool error, const int errorID) { LOCK(cs_vNodes); BOOST_FOREACH (CNode* pnode, vNodes) pnode->PushMessage("dsc", sessionID, error, errorID); } //TODO: Rename/move to core void ThreadCheckObfuScationPool() { if (fLiteMode) return; //disable all Obfuscation/Masternode related functionality // Make this thread recognisable as the wallet flushing thread RenameThread("deviant-obfuscation"); unsigned int c = 0; while (true) { MilliSleep(1000); //LogPrintf("ThreadCheckObfuScationPool::check timeout\n"); // try to sync from all available nodes, one step at a time masternodeSync.Process(); if (masternodeSync.IsBlockchainSynced()) { c++; // check if we should activate or ping every few minutes, // start right after sync is considered to be done if (c % MASTERNODE_PING_SECONDS == 1) activeMasternode.ManageStatus(); if (c % 60 == 0) { mnodeman.CheckAndRemove(); mnodeman.ProcessMasternodeConnections(); masternodePayments.CleanPaymentList(); CleanTransactionLocksList(); } //if(c % MASTERNODES_DUMP_SECONDS == 0) DumpMasternodes(); obfuScationPool.CheckTimeout(); obfuScationPool.CheckForCompleteQueue(); if (obfuScationPool.GetState() == POOL_STATUS_IDLE && c % 15 == 0) { obfuScationPool.DoAutomaticDenominating(); } } } }
; A142356: Primes congruent to 4 mod 47. ; Submitted by Jamie Morken(w3) ; 239,521,709,991,1367,1931,2213,2683,2777,3529,3623,4093,4657,4751,5503,5879,6067,7477,7759,7853,8699,8887,9733,10391,10861,11519,11801,12553,12647,13399,13681,13963,14057,14621,15091,15373,15467,15749,15937,17159,17911,18287,18757,19603,19697,19979,20261,20543,20731,21013,21107,21577,21859,23081,23269,23833,25243,26183,26371,28439,28627,28909,29191,29473,29567,30319,30977,31259,31541,31729,33703,33797,34267,34361,34549,35677,35771,36241,36523,36899,37087,37181,37369,37463,38873,39343,39719 mov $1,41 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $1,16 sub $2,1 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,63 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 sub $0,89 mul $0,2 add $0,53