text
stringlengths
1
1.05M
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 4.1.4 #12246 (Mac OS X x86_64) ;-------------------------------------------------------- .module scene_6_triggers .optsdcc -mgbz80 ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _scene_6_triggers .globl ___bank_scene_6_triggers ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- .area _DATA ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- .area _INITIALIZED ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area _DABS (ABS) ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area _HOME .area _GSINIT .area _GSFINAL .area _GSINIT ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area _HOME .area _HOME ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area _CODE_255 .area _CODE_255 ___bank_scene_6_triggers = 0x00ff _scene_6_triggers: .db #0x00 ; 0 .db #0x0d ; 13 .db #0x01 ; 1 .db #0x01 ; 1 .byte ___bank_script_s6t0_interact .dw _script_s6t0_interact .db #0x13 ; 19 .db #0x0d ; 13 .db #0x01 ; 1 .db #0x01 ; 1 .byte ___bank_script_s6t1_interact .dw _script_s6t1_interact .area _INITIALIZER .area _CABS (ABS)
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r8 push %r9 push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x130f, %rsi lea addresses_WT_ht+0x15a5c, %rdi nop nop dec %r8 mov $84, %rcx rep movsb nop nop xor %rdi, %rdi lea addresses_normal_ht+0xfe19, %r14 nop nop add %rsi, %rsi movb $0x61, (%r14) nop nop nop nop sub $45417, %r8 lea addresses_WT_ht+0x83d1, %rsi clflush (%rsi) nop nop nop nop nop cmp $33001, %rbx movl $0x61626364, (%rsi) nop nop nop nop sub %rdi, %rdi lea addresses_WT_ht+0x19c09, %rbx nop nop nop add %r8, %r8 movl $0x61626364, (%rbx) nop nop sub %rcx, %rcx lea addresses_A_ht+0x329d, %rdi clflush (%rdi) nop xor $1418, %r8 movl $0x61626364, (%rdi) nop nop nop dec %r8 lea addresses_WC_ht+0x68b1, %rdi nop dec %r14 movw $0x6162, (%rdi) add %r10, %r10 lea addresses_D_ht+0x15815, %rsi nop sub $63758, %rbx movb (%rsi), %r8b nop nop nop nop nop and $58530, %rdi lea addresses_WC_ht+0xa8e9, %rsi lea addresses_normal_ht+0x10e29, %rdi nop nop nop xor %rbx, %rbx mov $55, %rcx rep movsw nop nop nop nop xor %rbx, %rbx lea addresses_A_ht+0x13ae9, %r8 add %rsi, %rsi mov (%r8), %edi nop nop nop nop nop sub %rdi, %rdi lea addresses_A_ht+0x10f01, %rdi nop xor $28469, %rsi mov (%rdi), %ecx nop add $16440, %r14 lea addresses_A_ht+0x16769, %rcx nop nop nop and $1551, %rsi mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop nop nop add $54969, %rbx lea addresses_normal_ht+0x138e9, %rsi xor $20173, %r14 vmovups (%rsi), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %rbx nop nop nop nop nop cmp $7250, %rcx lea addresses_UC_ht+0x11ae9, %r8 clflush (%r8) nop nop cmp %rbx, %rbx mov $0x6162636465666768, %rsi movq %rsi, (%r8) cmp %r14, %r14 lea addresses_WT_ht+0x10029, %rsi lea addresses_WT_ht+0x182b9, %rdi clflush (%rdi) nop nop nop sub $8891, %r9 mov $54, %rcx rep movsw nop nop nop nop cmp %r14, %r14 lea addresses_WC_ht+0x16109, %rsi lea addresses_normal_ht+0x11fe9, %rdi nop nop nop add $24742, %r10 mov $73, %rcx rep movsl nop nop cmp $5082, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi // Store lea addresses_UC+0x1b129, %r15 nop nop cmp %rdx, %rdx movb $0x51, (%r15) nop nop nop nop nop and %rbx, %rbx // Load lea addresses_UC+0x5769, %r15 nop nop and $6122, %r8 movb (%r15), %bl nop nop sub %rdi, %rdi // Store lea addresses_WC+0x15c1d, %r8 nop add $50546, %r10 mov $0x5152535455565758, %r15 movq %r15, (%r8) xor $63302, %rsi // REPMOV lea addresses_normal+0x6ee9, %rsi lea addresses_UC+0x4989, %rdi nop xor %rdx, %rdx mov $113, %rcx rep movsl nop nop nop cmp %r10, %r10 // Load lea addresses_A+0x6ae9, %rdi nop nop nop and $59280, %rsi mov (%rdi), %r15d sub %r15, %r15 // REPMOV lea addresses_WC+0x15f69, %rsi mov $0xf89, %rdi sub $5608, %r8 mov $26, %rcx rep movsb nop sub %rsi, %rsi // Store mov $0x7318240000000ce9, %rdi nop and %r15, %r15 movl $0x51525354, (%rdi) nop nop nop nop cmp %rsi, %rsi // Faulty Load lea addresses_RW+0x4ee9, %rbx nop sub %rsi, %rsi mov (%rbx), %ecx lea oracles, %r8 and $0xff, %rcx shlq $12, %rcx mov (%r8,%rcx,1), %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': True, 'AVXalign': True, 'size': 8, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_P'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 2}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 8, '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 */
section .text default rel global _0x40_set_rex global _0x41_set_rex global _0x42_set_rex global _0x43_set_rex global _0x44_set_rex global _0x45_set_rex global _0x46_set_rex global _0x47_set_rex global _0x48_set_rex global _0x49_set_rex global _0x4a_set_rex global _0x4b_set_rex global _0x4c_set_rex global _0x4d_set_rex global _0x4e_set_rex global _0x4f_set_rex extern _rip extern _context extern _context._rex extern _context._res extern _context._opcode extern _context._data_prefix extern _context._addr_prefix extern print extern _fetch8 extern _exec extern _exec_one _0x40_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x41_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x42_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x43_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x44_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x45_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x46_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x47_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x48_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec ret _0x49_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4a_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4b_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4c_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4d_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4e_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret _0x4f_set_rex: add dword [_rip],0x01 mov dl,[_context._opcode] mov byte [_context._rex],dl jmp _exec_one ret
;================================================================================================== ; Settings and tables which the front-end may write ;================================================================================================== ; 0x03481000: Item override table: ; ; This table changes the meaning of a given item ID within a given scene. It must be terminated with ; four 0x00 bytes (which will happen by default as long as you don't fill the allotted space). ; ; Row format (4 bytes): ; SSTTIINN ; SS = Scene ; TT = Override Type (0x00 = base item, 0x01 = chest, 0x02 = collectable) ; II = Override ID (base item or flag) ; NN = New item ID .area 0x800, 0 ITEM_OVERRIDES: .endarea ; 0x03481800: Initial Save Data table: ; ; This table describes what extra data should be written when a new save file is created. It must be terminated with ; four 0x00 bytes (which will happen by default as long as you don't fill the allotted space). ; ; Row format (4 bytes): ; AAAATTVV ; AAAA = Offset from the start of the save data ; TT = Type (0x00 = or value with current value, 0x01 = set the byte to the given value) ; VV = Value to write to the save .area 0x400, 0 INITIAL_SAVE_DATA: .endarea PLAYER_ID: .byte 0x00 QUICKBOOTS_ENABLE: .byte 0x00 ; 0x03481C00: Special items LIGHT_ARROW_ITEM: .byte 0x5A FAIRY_OCARINA_ITEM: .byte 0x3B FAIRY_ITEMS: .byte 0x5D ; Zora's Domain .byte 0x5C ; Hyrule Castle .byte 0x5E ; Desert Colossus .byte 0x51 ; Mountain Summit .byte 0x52 ; Crater .byte 0x53 ; Ganon's Castle .align 4
.data x: .word 5 z: .word 7 y: .word 0 # esse valor deverá ser sobrescrito após a execução do programa. .text # Referencia : lw = load word ; sw = save word. # Armazendo os valores do ".data" em variáveis temporárias lw $t0, x # t0/temp0 = x = 5 lw $t1, z # t1/temp1 = x = 7 # Armazenando os valores que seram usados para a multiplicacao addi $t4,$t4,127 addi $t5,$t5,65 #127x5 sll $t2,$t4,2 # $t2 = 127 x 4 add $t2,$t2,$t4 # $t2 += 127 #65x7 sll $t3,$t5,3 # $t3 = 65 x 8 sub $t3,$t3,$t5 # $t3 -= 65 #Conta final sub $t3,$t2,$t3 # 127x5 - 65x7 | $t2 - $t3 add $t3,$t3,1 # $t3 += 1 #salvando o valor em "y" sw $t3, y
; ; Copyright (c) 2014 The WebM 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 in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" %macro HIGH_GET_PARAM_4 0 mov rdx, arg(5) ;filter ptr mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr mov rcx, 0x00000040 movdqa xmm3, [rdx] ;load filters pshuflw xmm4, xmm3, 11111111b ;k3 psrldq xmm3, 8 pshuflw xmm3, xmm3, 0b ;k4 punpcklwd xmm4, xmm3 ;k3k4 movq xmm3, rcx ;rounding pshufd xmm3, xmm3, 0 mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm5, rdx movq xmm2, rcx pshufd xmm5, xmm5, 0b movdqa xmm1, xmm5 psllw xmm5, xmm2 psubw xmm5, xmm1 ;max value (for clamping) pxor xmm2, xmm2 ;min value (for clamping) movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch movsxd rcx, DWORD PTR arg(4) ;output_height %endm %macro HIGH_APPLY_FILTER_4 1 punpcklwd xmm0, xmm1 ;two row in one register pmaddwd xmm0, xmm4 ;multiply the filter factors paddd xmm0, xmm3 ;rounding psrad xmm0, 7 ;shift packssdw xmm0, xmm0 ;pack to word ;clamp the values pminsw xmm0, xmm5 pmaxsw xmm0, xmm2 %if %1 movq xmm1, [rdi] pavgw xmm0, xmm1 %endif movq [rdi], xmm0 lea rsi, [rsi + 2*rax] lea rdi, [rdi + 2*rdx] dec rcx %endm %if VPX_ARCH_X86_64 %macro HIGH_GET_PARAM 0 mov rdx, arg(5) ;filter ptr mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr mov rcx, 0x00000040 movdqa xmm6, [rdx] ;load filters pshuflw xmm7, xmm6, 11111111b ;k3 pshufhw xmm6, xmm6, 0b ;k4 psrldq xmm6, 8 punpcklwd xmm7, xmm6 ;k3k4k3k4k3k4k3k4 movq xmm4, rcx ;rounding pshufd xmm4, xmm4, 0 mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm8, rdx movq xmm5, rcx pshufd xmm8, xmm8, 0b movdqa xmm1, xmm8 psllw xmm8, xmm5 psubw xmm8, xmm1 ;max value (for clamping) pxor xmm5, xmm5 ;min value (for clamping) movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch movsxd rcx, DWORD PTR arg(4) ;output_height %endm %macro HIGH_APPLY_FILTER_8 1 movdqa xmm6, xmm0 punpckhwd xmm6, xmm1 punpcklwd xmm0, xmm1 pmaddwd xmm6, xmm7 pmaddwd xmm0, xmm7 paddd xmm6, xmm4 ;rounding paddd xmm0, xmm4 ;rounding psrad xmm6, 7 ;shift psrad xmm0, 7 ;shift packssdw xmm0, xmm6 ;pack back to word ;clamp the values pminsw xmm0, xmm8 pmaxsw xmm0, xmm5 %if %1 movdqu xmm1, [rdi] pavgw xmm0, xmm1 %endif movdqu [rdi], xmm0 ;store the result lea rsi, [rsi + 2*rax] lea rdi, [rdi + 2*rdx] dec rcx %endm %macro HIGH_APPLY_FILTER_16 1 movdqa xmm9, xmm0 movdqa xmm6, xmm2 punpckhwd xmm9, xmm1 punpckhwd xmm6, xmm3 punpcklwd xmm0, xmm1 punpcklwd xmm2, xmm3 pmaddwd xmm9, xmm7 pmaddwd xmm6, xmm7 pmaddwd xmm0, xmm7 pmaddwd xmm2, xmm7 paddd xmm9, xmm4 ;rounding paddd xmm6, xmm4 paddd xmm0, xmm4 paddd xmm2, xmm4 psrad xmm9, 7 ;shift psrad xmm6, 7 psrad xmm0, 7 psrad xmm2, 7 packssdw xmm0, xmm9 ;pack back to word packssdw xmm2, xmm6 ;pack back to word ;clamp the values pminsw xmm0, xmm8 pmaxsw xmm0, xmm5 pminsw xmm2, xmm8 pmaxsw xmm2, xmm5 %if %1 movdqu xmm1, [rdi] movdqu xmm3, [rdi + 16] pavgw xmm0, xmm1 pavgw xmm2, xmm3 %endif movdqu [rdi], xmm0 ;store the result movdqu [rdi + 16], xmm2 ;store the result lea rsi, [rsi + 2*rax] lea rdi, [rdi + 2*rdx] dec rcx %endm %endif SECTION .text global sym(vpx_highbd_filter_block1d4_v2_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_v2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 push rsi push rdi ; end prolog HIGH_GET_PARAM_4 .loop: movq xmm0, [rsi] ;load src movq xmm1, [rsi + 2*rax] HIGH_APPLY_FILTER_4 0 jnz .loop ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret %if VPX_ARCH_X86_64 global sym(vpx_highbd_filter_block1d8_v2_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_v2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 8 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;0 movdqu xmm1, [rsi + 2*rax] ;1 HIGH_APPLY_FILTER_8 0 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_v2_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_v2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 9 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;0 movdqu xmm2, [rsi + 16] movdqu xmm1, [rsi + 2*rax] ;1 movdqu xmm3, [rsi + 2*rax + 16] HIGH_APPLY_FILTER_16 0 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret %endif global sym(vpx_highbd_filter_block1d4_v2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_v2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 push rsi push rdi ; end prolog HIGH_GET_PARAM_4 .loop: movq xmm0, [rsi] ;load src movq xmm1, [rsi + 2*rax] HIGH_APPLY_FILTER_4 1 jnz .loop ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret %if VPX_ARCH_X86_64 global sym(vpx_highbd_filter_block1d8_v2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_v2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 8 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;0 movdqu xmm1, [rsi + 2*rax] ;1 HIGH_APPLY_FILTER_8 1 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_v2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_v2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 9 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;0 movdqu xmm1, [rsi + 2*rax] ;1 movdqu xmm2, [rsi + 16] movdqu xmm3, [rsi + 2*rax + 16] HIGH_APPLY_FILTER_16 1 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret %endif global sym(vpx_highbd_filter_block1d4_h2_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_h2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 push rsi push rdi ; end prolog HIGH_GET_PARAM_4 .loop: movdqu xmm0, [rsi] ;load src movdqa xmm1, xmm0 psrldq xmm1, 2 HIGH_APPLY_FILTER_4 0 jnz .loop ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret %if VPX_ARCH_X86_64 global sym(vpx_highbd_filter_block1d8_h2_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_h2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 8 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;load src movdqu xmm1, [rsi + 2] HIGH_APPLY_FILTER_8 0 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_h2_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_h2_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 9 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;load src movdqu xmm1, [rsi + 2] movdqu xmm2, [rsi + 16] movdqu xmm3, [rsi + 18] HIGH_APPLY_FILTER_16 0 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret %endif global sym(vpx_highbd_filter_block1d4_h2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d4_h2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 push rsi push rdi ; end prolog HIGH_GET_PARAM_4 .loop: movdqu xmm0, [rsi] ;load src movdqa xmm1, xmm0 psrldq xmm1, 2 HIGH_APPLY_FILTER_4 1 jnz .loop ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret %if VPX_ARCH_X86_64 global sym(vpx_highbd_filter_block1d8_h2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d8_h2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 8 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;load src movdqu xmm1, [rsi + 2] HIGH_APPLY_FILTER_8 1 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret global sym(vpx_highbd_filter_block1d16_h2_avg_sse2) PRIVATE sym(vpx_highbd_filter_block1d16_h2_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 9 push rsi push rdi ; end prolog HIGH_GET_PARAM .loop: movdqu xmm0, [rsi] ;load src movdqu xmm1, [rsi + 2] movdqu xmm2, [rsi + 16] movdqu xmm3, [rsi + 18] HIGH_APPLY_FILTER_16 1 jnz .loop ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret %endif
SFX_Battle_35_Ch5: execute_music vibrato 10, 2, 4 duty_cycle 2 note_type 10, 8, 7 octave 5 note G#, 8 octave 6 note F#, 4 note E_, 4 octave 5 note G#, 8 sound_ret SFX_Battle_35_Ch6: execute_music vibrato 10, 2, 3 duty_cycle 2 note_type 11, 6, 7 octave 5 note G#, 8 note_type 10, 6, 7 octave 6 note F#, 4 note E_, 4 octave 5 note G#, 8 sound_ret
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' PUBLIC pasta_add ALIGN 32 pasta_add PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_pasta_add:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx sub rsp,8 $L$SEH_body_pasta_add:: mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] $L$oaded_a_pasta_add:: add r8,QWORD PTR[rdx] adc r9,QWORD PTR[8+rdx] mov rax,r8 adc r10,QWORD PTR[16+rdx] mov rsi,r9 adc r11,QWORD PTR[24+rdx] sbb rdx,rdx mov rbx,r10 sub r8,QWORD PTR[rcx] sbb r9,QWORD PTR[8+rcx] sbb r10,QWORD PTR[16+rcx] mov rbp,r11 sbb r11,QWORD PTR[24+rcx] sbb rdx,0 cmovc r8,rax cmovc r9,rsi mov QWORD PTR[rdi],r8 cmovc r10,rbx mov QWORD PTR[8+rdi],r9 cmovc r11,rbp mov QWORD PTR[16+rdi],r10 mov QWORD PTR[24+rdi],r11 mov rbx,QWORD PTR[8+rsp] mov rbp,QWORD PTR[16+rsp] lea rsp,QWORD PTR[24+rsp] $L$SEH_epilogue_pasta_add:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_pasta_add:: pasta_add ENDP PUBLIC pasta_cneg ALIGN 32 pasta_cneg PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_pasta_cneg:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx push r12 $L$SEH_body_pasta_cneg:: mov r12,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r8,r12 mov r11,QWORD PTR[24+rsi] or r12,r9 or r12,r10 or r12,r11 mov rbp,-1 mov rax,QWORD PTR[rcx] cmovnz r12,rbp mov rsi,QWORD PTR[8+rcx] mov rbx,QWORD PTR[16+rcx] and rax,r12 mov rbp,QWORD PTR[24+rcx] and rsi,r12 and rbx,r12 and rbp,r12 sub rax,r8 sbb rsi,r9 sbb rbx,r10 sbb rbp,r11 or rdx,rdx cmovz rax,r8 cmovz rsi,r9 mov QWORD PTR[rdi],rax cmovz rbx,r10 mov QWORD PTR[8+rdi],rsi cmovz rbp,r11 mov QWORD PTR[16+rdi],rbx mov QWORD PTR[24+rdi],rbp mov r12,QWORD PTR[rsp] mov rbx,QWORD PTR[8+rsp] mov rbp,QWORD PTR[16+rsp] lea rsp,QWORD PTR[24+rsp] $L$SEH_epilogue_pasta_cneg:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_pasta_cneg:: pasta_cneg ENDP PUBLIC pasta_sub ALIGN 32 pasta_sub PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_pasta_sub:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx sub rsp,8 $L$SEH_body_pasta_sub:: mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] sub r8,QWORD PTR[rdx] mov rax,QWORD PTR[rcx] sbb r9,QWORD PTR[8+rdx] mov rsi,QWORD PTR[8+rcx] sbb r10,QWORD PTR[16+rdx] mov rbx,QWORD PTR[16+rcx] sbb r11,QWORD PTR[24+rdx] mov rbp,QWORD PTR[24+rcx] sbb rdx,rdx and rax,rdx and rsi,rdx and rbx,rdx and rbp,rdx add r8,rax adc r9,rsi mov QWORD PTR[rdi],r8 adc r10,rbx mov QWORD PTR[8+rdi],r9 adc r11,rbp mov QWORD PTR[16+rdi],r10 mov QWORD PTR[24+rdi],r11 mov rbx,QWORD PTR[8+rsp] mov rbp,QWORD PTR[16+rsp] lea rsp,QWORD PTR[24+rsp] $L$SEH_epilogue_pasta_sub:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_pasta_sub:: pasta_sub ENDP ALIGN 32 __lshift_mod_256 PROC PRIVATE DB 243,15,30,250 add r8,r8 adc r9,r9 mov rax,r8 adc r10,r10 mov rsi,r9 adc r11,r11 sbb r12,r12 mov rbx,r10 sub r8,QWORD PTR[rcx] sbb r9,QWORD PTR[8+rcx] sbb r10,QWORD PTR[16+rcx] mov rbp,r11 sbb r11,QWORD PTR[24+rcx] sbb r12,0 cmovc r8,rax cmovc r9,rsi cmovc r10,rbx cmovc r11,rbp DB 0F3h,0C3h ;repret __lshift_mod_256 ENDP PUBLIC pasta_lshift ALIGN 32 pasta_lshift PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_pasta_lshift:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx push r12 $L$SEH_body_pasta_lshift:: mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] $L$oop_lshift_mod_256:: call __lshift_mod_256 dec edx jnz $L$oop_lshift_mod_256 mov QWORD PTR[rdi],r8 mov QWORD PTR[8+rdi],r9 mov QWORD PTR[16+rdi],r10 mov QWORD PTR[24+rdi],r11 mov r12,QWORD PTR[rsp] mov rbx,QWORD PTR[8+rsp] mov rbp,QWORD PTR[16+rsp] lea rsp,QWORD PTR[24+rsp] $L$SEH_epilogue_pasta_lshift:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_pasta_lshift:: pasta_lshift ENDP PUBLIC pasta_rshift ALIGN 32 pasta_rshift PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_pasta_rshift:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx sub rsp,8 $L$SEH_body_pasta_rshift:: mov rbp,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] $L$oop_rshift_mod_256:: mov r8,rbp and rbp,1 mov rax,QWORD PTR[rcx] neg rbp mov rsi,QWORD PTR[8+rcx] mov rbx,QWORD PTR[16+rcx] and rax,rbp and rsi,rbp and rbx,rbp and rbp,QWORD PTR[24+rcx] add r8,rax adc r9,rsi adc r10,rbx adc r11,rbp sbb rax,rax shr r8,1 mov rbp,r9 shr r9,1 mov rbx,r10 shr r10,1 mov rsi,r11 shr r11,1 shl rbp,63 shl rbx,63 or rbp,r8 shl rsi,63 or r9,rbx shl rax,63 or r10,rsi or r11,rax dec edx jnz $L$oop_rshift_mod_256 mov QWORD PTR[rdi],rbp mov QWORD PTR[8+rdi],r9 mov QWORD PTR[16+rdi],r10 mov QWORD PTR[24+rdi],r11 mov rbx,QWORD PTR[8+rsp] mov rbp,QWORD PTR[16+rsp] lea rsp,QWORD PTR[24+rsp] $L$SEH_epilogue_pasta_rshift:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_pasta_rshift:: pasta_rshift ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_pasta_add DD imagerel $L$SEH_body_pasta_add DD imagerel $L$SEH_info_pasta_add_prologue DD imagerel $L$SEH_body_pasta_add DD imagerel $L$SEH_epilogue_pasta_add DD imagerel $L$SEH_info_pasta_add_body DD imagerel $L$SEH_epilogue_pasta_add DD imagerel $L$SEH_end_pasta_add DD imagerel $L$SEH_info_pasta_add_epilogue DD imagerel $L$SEH_begin_pasta_cneg DD imagerel $L$SEH_body_pasta_cneg DD imagerel $L$SEH_info_pasta_cneg_prologue DD imagerel $L$SEH_body_pasta_cneg DD imagerel $L$SEH_epilogue_pasta_cneg DD imagerel $L$SEH_info_pasta_cneg_body DD imagerel $L$SEH_epilogue_pasta_cneg DD imagerel $L$SEH_end_pasta_cneg DD imagerel $L$SEH_info_pasta_cneg_epilogue DD imagerel $L$SEH_begin_pasta_sub DD imagerel $L$SEH_body_pasta_sub DD imagerel $L$SEH_info_pasta_sub_prologue DD imagerel $L$SEH_body_pasta_sub DD imagerel $L$SEH_epilogue_pasta_sub DD imagerel $L$SEH_info_pasta_sub_body DD imagerel $L$SEH_epilogue_pasta_sub DD imagerel $L$SEH_end_pasta_sub DD imagerel $L$SEH_info_pasta_sub_epilogue DD imagerel $L$SEH_begin_pasta_lshift DD imagerel $L$SEH_body_pasta_lshift DD imagerel $L$SEH_info_pasta_lshift_prologue DD imagerel $L$SEH_body_pasta_lshift DD imagerel $L$SEH_epilogue_pasta_lshift DD imagerel $L$SEH_info_pasta_lshift_body DD imagerel $L$SEH_epilogue_pasta_lshift DD imagerel $L$SEH_end_pasta_lshift DD imagerel $L$SEH_info_pasta_lshift_epilogue DD imagerel $L$SEH_begin_pasta_rshift DD imagerel $L$SEH_body_pasta_rshift DD imagerel $L$SEH_info_pasta_rshift_prologue DD imagerel $L$SEH_body_pasta_rshift DD imagerel $L$SEH_epilogue_pasta_rshift DD imagerel $L$SEH_info_pasta_rshift_body DD imagerel $L$SEH_epilogue_pasta_rshift DD imagerel $L$SEH_end_pasta_rshift DD imagerel $L$SEH_info_pasta_rshift_epilogue .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_pasta_add_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_pasta_add_body:: DB 1,0,9,0 DB 000h,034h,001h,000h DB 000h,054h,002h,000h DB 000h,074h,004h,000h DB 000h,064h,005h,000h DB 000h,022h DB 000h,000h $L$SEH_info_pasta_add_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h $L$SEH_info_pasta_cneg_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_pasta_cneg_body:: DB 1,0,11,0 DB 000h,0c4h,000h,000h DB 000h,034h,001h,000h DB 000h,054h,002h,000h DB 000h,074h,004h,000h DB 000h,064h,005h,000h DB 000h,022h DB 000h,000h,000h,000h,000h,000h $L$SEH_info_pasta_cneg_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h $L$SEH_info_pasta_sub_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_pasta_sub_body:: DB 1,0,9,0 DB 000h,034h,001h,000h DB 000h,054h,002h,000h DB 000h,074h,004h,000h DB 000h,064h,005h,000h DB 000h,022h DB 000h,000h $L$SEH_info_pasta_sub_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h $L$SEH_info_pasta_lshift_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_pasta_lshift_body:: DB 1,0,11,0 DB 000h,0c4h,000h,000h DB 000h,034h,001h,000h DB 000h,054h,002h,000h DB 000h,074h,004h,000h DB 000h,064h,005h,000h DB 000h,022h DB 000h,000h,000h,000h,000h,000h $L$SEH_info_pasta_lshift_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h $L$SEH_info_pasta_rshift_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_pasta_rshift_body:: DB 1,0,9,0 DB 000h,034h,001h,000h DB 000h,054h,002h,000h DB 000h,074h,004h,000h DB 000h,064h,005h,000h DB 000h,022h DB 000h,000h $L$SEH_info_pasta_rshift_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h .xdata ENDS END
// Copyright 2016 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // 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. // //////////////////////////////////////////////////////////////////////////////// // #include "grpc_transcoding/request_message_translator.h" #include <string> #include "google/protobuf/stubs/bytestream.h" #include "google/protobuf/util/internal/error_listener.h" #include "google/protobuf/util/internal/protostream_objectwriter.h" #include "grpc_transcoding/prefix_writer.h" #include "grpc_transcoding/request_weaver.h" namespace pb = ::google::protobuf; namespace pbutil = ::google::protobuf::util; namespace pbconv = ::google::protobuf::util::converter; namespace google { namespace grpc { namespace transcoding { namespace { pbconv::ProtoStreamObjectWriter::Options GetProtoWriterOptions() { auto options = pbconv::ProtoStreamObjectWriter::Options::Defaults(); // Don't fail the translation if there are unknown fields in JSON. // This will make sure that we allow backward and forward compatible APIs. options.ignore_unknown_fields = true; return options; } } // namespace RequestMessageTranslator::RequestMessageTranslator( google::protobuf::util::TypeResolver& type_resolver, bool output_delimiter, RequestInfo request_info) : message_(), sink_(&message_), error_listener_(), proto_writer_(&type_resolver, *request_info.message_type, &sink_, &error_listener_, GetProtoWriterOptions()), request_weaver_(), prefix_writer_(), writer_pipeline_(&proto_writer_), output_delimiter_(output_delimiter), finished_(false) { // Relax Base64 decoding to support RFC 2045 Base64 proto_writer_.set_use_strict_base64_decoding(false); // Create a RequestWeaver if we have variable bindings to weave if (!request_info.variable_bindings.empty()) { request_weaver_.reset(new RequestWeaver( std::move(request_info.variable_bindings), writer_pipeline_)); writer_pipeline_ = request_weaver_.get(); } // Create a PrefixWriter if there is a prefix to write if (!request_info.body_field_path.empty() && "*" != request_info.body_field_path) { prefix_writer_.reset( new PrefixWriter(request_info.body_field_path, writer_pipeline_)); writer_pipeline_ = prefix_writer_.get(); } if (output_delimiter_) { // Reserve space for the delimiter at the begining of the message_ ReserveDelimiterSpace(); } } RequestMessageTranslator::~RequestMessageTranslator() {} bool RequestMessageTranslator::Finished() const { return finished_; } bool RequestMessageTranslator::NextMessage(std::string* message) { if (Finished()) { // Finished reading return false; } if (!proto_writer_.done()) { // No full message yet return false; } if (output_delimiter_) { WriteDelimiter(); } *message = std::move(message_); finished_ = true; return true; } void RequestMessageTranslator::ReserveDelimiterSpace() { static char reserved[kDelimiterSize] = {0}; sink_.Append(reserved, sizeof(reserved)); } namespace { void SizeToDelimiter(unsigned size, unsigned char* delimiter) { delimiter[0] = 0; // compression bit // big-endian 32-bit length delimiter[4] = 0xFF & size; size >>= 8; delimiter[3] = 0xFF & size; size >>= 8; delimiter[2] = 0xFF & size; size >>= 8; delimiter[1] = 0xFF & size; } } // namespace void RequestMessageTranslator::WriteDelimiter() { // Asumming that the message_.size() - kDelimiterSize is less than UINT_MAX SizeToDelimiter(static_cast<unsigned>(message_.size() - kDelimiterSize), reinterpret_cast<unsigned char*>(&message_[0])); } void RequestMessageTranslator::StatusErrorListener::InvalidName( const ::google::protobuf::util::converter::LocationTrackerInterface& loc, internal::string_view unknown_name, internal::string_view message) { status_ = ::google::protobuf::util::Status( ::google::protobuf::util::error::INVALID_ARGUMENT, loc.ToString() + ": " + std::string(message)); } void RequestMessageTranslator::StatusErrorListener::InvalidValue( const ::google::protobuf::util::converter::LocationTrackerInterface& loc, internal::string_view type_name, internal::string_view value) { status_ = ::google::protobuf::util::Status( ::google::protobuf::util::error::INVALID_ARGUMENT, loc.ToString() + ": invalid value " + std::string(value) + " for type " + std::string(type_name)); } void RequestMessageTranslator::StatusErrorListener::MissingField( const ::google::protobuf::util::converter::LocationTrackerInterface& loc, internal::string_view missing_name) { status_ = ::google::protobuf::util::Status( ::google::protobuf::util::error::INVALID_ARGUMENT, loc.ToString() + ": missing field " + std::string(missing_name)); } } // namespace transcoding } // namespace grpc } // namespace google
#include <iostream> #include <string> using namespace std; int main (){ string firstName, lastName, town; int age; cin >> firstName >> lastName; cin >> age; cin >> town; cout << "You are " << firstName << " " << lastName << ", a " << age << "-years old person from " << town << "." << endl; return 0; }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r15 push %r8 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xba1b, %r11 nop nop nop nop xor $56747, %r12 vmovups (%r11), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r9 nop nop and $3595, %rdx lea addresses_normal_ht+0x1618f, %r10 nop nop nop nop nop and $31594, %r15 mov (%r10), %r8d nop nop cmp $13236, %r8 lea addresses_WT_ht+0xdbbf, %r8 clflush (%r8) nop nop nop nop inc %r9 movb $0x61, (%r8) nop nop nop nop cmp %r12, %r12 lea addresses_WT_ht+0xcdbf, %rdx nop nop nop nop nop dec %r9 movb $0x61, (%rdx) nop nop xor %rdx, %rdx lea addresses_D_ht+0x11bf, %rsi lea addresses_D_ht+0x7187, %rdi clflush (%rdi) nop inc %r11 mov $79, %rcx rep movsb xor $28208, %r11 lea addresses_D_ht+0x1757f, %rsi lea addresses_UC_ht+0x95bf, %rdi clflush (%rdi) cmp $31086, %r12 mov $30, %rcx rep movsq nop lfence lea addresses_A_ht+0xfdbf, %rsi lea addresses_UC_ht+0x189bf, %rdi nop nop cmp $59902, %r12 mov $69, %rcx rep movsq nop nop nop lfence lea addresses_WT_ht+0x91bf, %rsi lea addresses_WT_ht+0xb9bf, %rdi nop nop nop add %r15, %r15 mov $97, %rcx rep movsl nop nop nop nop nop xor %r11, %r11 lea addresses_WC_ht+0x16a3f, %r11 clflush (%r11) nop nop nop nop nop xor %rdx, %rdx mov (%r11), %r12 nop xor $62628, %r10 lea addresses_WT_ht+0x2fff, %rsi lea addresses_A_ht+0x1d53f, %rdi nop add $53308, %r15 mov $13, %rcx rep movsq nop nop nop nop nop cmp %r10, %r10 lea addresses_A_ht+0xffbf, %rsi lea addresses_A_ht+0x175bf, %rdi nop nop nop nop nop cmp $7296, %r12 mov $51, %rcx rep movsw nop and %r15, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %rax push %rcx push %rdi push %rsi // REPMOV lea addresses_D+0x4733, %rsi lea addresses_WC+0x1a3bf, %rdi nop nop nop nop nop sub $33492, %rax mov $120, %rcx rep movsq nop nop nop nop nop sub %r13, %r13 // Store lea addresses_US+0xacbf, %rax xor $63281, %r10 movl $0x51525354, (%rax) nop nop sub %rcx, %rcx // Store lea addresses_PSE+0x15fbf, %rdi nop nop nop mfence mov $0x5152535455565758, %rsi movq %rsi, (%rdi) nop nop nop nop xor %r10, %r10 // REPMOV lea addresses_normal+0x19ea7, %rsi lea addresses_UC+0x145bf, %rdi clflush (%rsi) nop nop nop nop add %r11, %r11 mov $105, %rcx rep movsl nop nop and %rsi, %rsi // Store lea addresses_WT+0x186c9, %r11 nop nop nop nop nop sub $3019, %r13 movb $0x51, (%r11) // Exception!!! xor %r13, %r13 div %r13 nop nop nop nop dec %rdi // Load mov $0x1466ff000000067f, %rsi sub $7901, %rax mov (%rsi), %di nop nop nop xor %r13, %r13 // Store lea addresses_US+0x2c53, %rcx nop nop nop sub $52065, %r11 mov $0x5152535455565758, %rax movq %rax, %xmm7 vmovups %ymm7, (%rcx) nop nop nop nop and $48661, %rax // REPMOV mov $0x78562e0000000dbf, %rsi lea addresses_WC+0x33bf, %rdi clflush (%rsi) nop add $42199, %r11 mov $65, %rcx rep movsq // Exception!!! nop nop nop nop nop xor %rcx, %rcx div %rcx sub $37543, %r14 // REPMOV mov $0x78562e0000000dbf, %rsi lea addresses_UC+0xbdbf, %rdi nop nop nop nop sub %rax, %rax mov $79, %rcx rep movsl nop nop nop dec %rax // Store mov $0x37856e0000000d0f, %rax nop nop nop nop nop and $37338, %rdi movl $0x51525354, (%rax) nop nop nop nop inc %rax // Store lea addresses_A+0xf8bf, %r11 dec %r13 mov $0x5152535455565758, %r10 movq %r10, %xmm6 vmovups %ymm6, (%r11) // Exception!!! nop nop mov (0), %rsi nop nop nop nop add $53140, %r10 // Store mov $0x74a89000000004bf, %rcx nop nop nop nop nop cmp $28071, %rsi movb $0x51, (%rcx) nop nop cmp $51711, %rax // REPMOV lea addresses_WT+0x1c65f, %rsi lea addresses_normal+0x33bf, %rdi nop nop xor $56154, %r14 mov $109, %rcx rep movsw xor %r11, %r11 // Faulty Load mov $0x78562e0000000dbf, %r13 nop nop nop xor $44047, %r10 mov (%r13), %rcx lea oracles, %r11 and $0xff, %rcx shlq $12, %rcx mov (%r11,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_D'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WC'}} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_US', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 8}} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_NC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_US', 'AVXalign': False, 'size': 32}} {'src': {'same': True, 'congruent': 0, 'type': 'addresses_NC'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WC'}} {'src': {'same': True, 'congruent': 0, 'type': 'addresses_NC'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_UC'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_NC', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_A', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}} {'src': {'same': True, 'congruent': 5, 'type': 'addresses_WT'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal'}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}} {'src': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}} {'src': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}} {'src': {'same': True, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}} {'src': {'same': True, 'congruent': 5, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}} {'49': 1} 49 */
;------------------------------------------------------------------------------- ; ENVELOPE opcode: pushes an ADSR envelope value on stack [0,1] ;------------------------------------------------------------------------------- ; Mono: push the envelope value on stack ; Stereo: push the envelope valeu on stack twice ;------------------------------------------------------------------------------- %if ENVELOPE_ID > -1 SECT_TEXT(suenvelo) EXPORT MANGLE_FUNC(su_op_envelope,0) %ifdef INCLUDE_STEREO_ENVELOPE jnc su_op_envelope_mono call su_op_envelope_mono fld st0 ret su_op_envelope_mono: %endif mov eax, dword [INP-su_voice.inputs+su_voice.release] ; eax = su_instrument.release test eax, eax ; if (eax == 0) je su_op_envelope_process ; goto process mov dword [WRK+su_env_work.state], ENV_STATE_RELEASE ; [state]=RELEASE su_op_envelope_process: mov eax, dword [WRK+su_env_work.state] ; al=[state] fld dword [WRK+su_env_work.level] ; x=[level] cmp al, ENV_STATE_SUSTAIN ; if (al==SUSTAIN) je short su_op_envelope_leave2 ; goto leave2 su_op_envelope_attac: cmp al, ENV_STATE_ATTAC ; if (al!=ATTAC) jne short su_op_envelope_decay ; goto decay call su_nonlinear_map ; a x, where a=attack faddp st1, st0 ; a+x fld1 ; 1 a+x fucomi st1 ; if (a+x<=1) // is attack complete? fcmovnb st0, st1 ; a+x a+x jbe short su_op_envelope_statechange ; else goto statechange su_op_envelope_decay: cmp al, ENV_STATE_DECAY ; if (al!=DECAY) jne short su_op_envelope_release ; goto release call su_nonlinear_map ; d x, where d=decay fsubp st1, st0 ; x-d fld dword [INP+su_env_ports.sustain] ; s x-d, where s=sustain fucomi st1 ; if (x-d>s) // is decay complete? fcmovb st0, st1 ; x-d x-d jnc short su_op_envelope_statechange ; else goto statechange su_op_envelope_release: cmp al, ENV_STATE_RELEASE ; if (al!=RELEASE) jne short su_op_envelope_leave ; goto leave call su_nonlinear_map ; r x, where r=release fsubp st1, st0 ; x-r fldz ; 0 x-r fucomi st1 ; if (x-r>0) // is release complete? fcmovb st0, st1 ; x-r x-r, then goto leave jc short su_op_envelope_leave su_op_envelope_statechange: inc dword [WRK+su_env_work.state] ; [state]++ su_op_envelope_leave: fstp st1 ; x', where x' is the new value fst dword [WRK+su_env_work.level] ; [level]=x' su_op_envelope_leave2: fmul dword [INP+su_env_ports.gain] ; [gain]*x' ret %endif ; SU_USE_ENVELOPE ;------------------------------------------------------------------------------- ; NOISE opcode: creates noise ;------------------------------------------------------------------------------- ; Mono: push a random value [-1,1] value on stack ; Stereo: push two (differeent) random values on stack ;------------------------------------------------------------------------------- %if NOISE_ID > -1 SECT_TEXT(sunoise) EXPORT MANGLE_FUNC(su_op_noise,0) mov _CX,_SP %ifdef INCLUDE_STEREO_NOISE jnc su_op_noise_mono call su_op_noise_mono su_op_noise_mono: %endif imul eax, [_CX + su_stack.randseed],16007 mov [_CX + su_stack.randseed],eax fild dword [_CX + su_stack.randseed] do fidiv dword [,c_RandDiv,] fld dword [INP+su_noise_ports.shape] call su_waveshaper fld dword [INP+su_noise_ports.gain] fmulp st1, st0 ret %define SU_INCLUDE_WAVESHAPER %endif ;------------------------------------------------------------------------------- ; OSCILLAT opcode: oscillator, the heart of the synth ;------------------------------------------------------------------------------- ; Mono: push oscillator value on stack ; Stereo: push l r on stack, where l has opposite detune compared to r ;------------------------------------------------------------------------------- %if OSCILLAT_ID > -1 SECT_TEXT(suoscill) EXPORT MANGLE_FUNC(su_op_oscillat,0) lodsb ; load the flags fld dword [INP+su_osc_ports.detune] ; e, where e is the detune [0,1] do fsub dword [,c_0_5,] ; e-.5 fadd st0, st0 ; d=2*e-.5, where d is the detune [-1,1] %ifdef INCLUDE_STEREO_OSCILLAT jnc su_op_oscillat_mono fld st0 ; d d call su_op_oscillat_mono ; r d add WRK, 4 ; state vars: r1 l1 r2 l2 r3 l3 r4 l4, for the unison osc phases fxch ; d r fchs ; -d r, negate the detune for second round su_op_oscillat_mono: %endif %ifdef INCLUDE_UNISONS push_registers _AX, WRK, _AX fldz ; 0 d fxch ; d a=0, "accumulated signal" su_op_oscillat_unison_loop: fst dword [_SP] ; save the current detune, d. We could keep it in fpu stack but it was getting big. call su_op_oscillat_single ; s a faddp st1, st0 ; a+=s test al, UNISON4 je su_op_oscillat_unison_out add WRK, 8 fld dword [INP+su_osc_ports.phaseofs] ; p s do fadd dword [,c_i12,] ; p s, add some little phase offset to unison oscillators so they don't start in sync fstp dword [INP+su_osc_ports.phaseofs] ; s note that this changes the phase for second, possible stereo run. That's probably ok fld dword [_SP] ; d s do fmul dword [,c_0_5,] ; .5*d s // negate and halve the detune of each oscillator fchs ; -.5*d s // negate and halve the detune of each oscillator dec eax jmp short su_op_oscillat_unison_loop su_op_oscillat_unison_out: pop_registers _AX, WRK, _AX ret su_op_oscillat_single: %endif fld dword [INP+su_osc_ports.transpose] do fsub dword [,c_0_5,] do fdiv dword [,c_i128,] faddp st1 test al, byte LFO jnz su_op_oscillat_skipnote fiadd dword [INP-su_voice.inputs+su_voice.note] ; // st0 is note, st1 is t+d offset su_op_oscillat_skipnote: do fmul dword [,c_i12,] call MANGLE_FUNC(su_power,0) test al, byte LFO jz short su_op_oscillat_normalize_note do fmul dword [,c_lfo_normalize,] ; // st0 is now frequency for lfo jmp short su_op_oscillat_normalized su_op_oscillat_normalize_note: do fmul dword [,c_freq_normalize,] ; // st0 is now frequency su_op_oscillat_normalized: fadd dword [WRK+su_osc_wrk.phase] fst dword [WRK+su_osc_wrk.phase] fadd dword [INP+su_osc_ports.phaseofs] %ifdef INCLUDE_SAMPLES test al, byte SAMPLE jz short su_op_oscillat_not_sample call su_oscillat_sample jmp su_op_oscillat_shaping ; skip the rest to avoid color phase normalization and colorloading su_op_oscillat_not_sample: %endif fld1 fadd st1, st0 fxch fprem fstp st1 fld dword [INP+su_osc_ports.color] ; // c p ; every oscillator test included if needed %ifdef INCLUDE_SINE test al, byte SINE jz short su_op_oscillat_notsine call su_oscillat_sine su_op_oscillat_notsine: %endif %ifdef INCLUDE_TRISAW test al, byte TRISAW jz short su_op_oscillat_not_trisaw call su_oscillat_trisaw su_op_oscillat_not_trisaw: %endif %ifdef INCLUDE_PULSE test al, byte PULSE jz short su_op_oscillat_not_pulse call su_oscillat_pulse su_op_oscillat_not_pulse: %endif %ifdef INCLUDE_GATE test al, byte GATE jz short su_op_oscillat_not_gate call su_oscillat_gate jmp su_op_oscillat_gain ; skip waveshaping as the shape parameter is reused for gateshigh su_op_oscillat_not_gate: %endif su_op_oscillat_shaping: ; finally, shape the oscillator and apply gain fld dword [INP+su_osc_ports.shape] call su_waveshaper su_op_oscillat_gain: fld dword [INP+su_osc_ports.gain] fmulp st1, st0 ret %define SU_INCLUDE_WAVESHAPER %endif ; PULSE %ifdef INCLUDE_PULSE SECT_TEXT(supulse) su_oscillat_pulse: fucomi st1 ; // c p fld1 jnc short su_oscillat_pulse_up ; // +1 c p fchs ; // -1 c p su_oscillat_pulse_up: fstp st1 ; // +-1 p fstp st1 ; // +-1 ret %endif ; TRISAW %ifdef INCLUDE_TRISAW SECT_TEXT(sutrisaw) su_oscillat_trisaw: fucomi st1 ; // c p jnc short su_oscillat_trisaw_up fld1 ; // 1 c p fsubr st2, st0 ; // 1 c 1-p fsubrp st1, st0 ; // 1-c 1-p su_oscillat_trisaw_up: fdivp st1, st0 ; // tp'/tc fadd st0 ; // 2*'' fld1 ; // 1 2*'' fsubp st1, st0 ; // 2*''-1 ret %endif ; SINE %ifdef INCLUDE_SINE SECT_TEXT(susine) su_oscillat_sine: fucomi st1 ; // c p jnc short su_oscillat_sine_do fstp st1 fsub st0, st0 ; // 0 ret su_oscillat_sine_do fdivp st1, st0 ; // p/c fldpi ; // pi p fadd st0 ; // 2*pi p fmulp st1, st0 ; // 2*pi*p fsin ; // sin(2*pi*p) ret %endif %ifdef INCLUDE_GATE SECT_TEXT(sugate) su_oscillat_gate: fxch ; p c fstp st1 ; p do fmul dword [,c_16,] ; 16*p push _AX push _AX fistp dword [_SP] ; s=int(16*p), stack empty fld1 ; 1 pop _AX and al, 0xf ; ax=int(16*p) & 15, stack: 1 bt word [VAL-4],ax ; if bit ax of the gate word is set jc go4kVCO_gate_bit ; goto gate_bit fsub st0, st0 ; stack: 0 go4kVCO_gate_bit: ; stack: 0/1, let's call it x fld dword [WRK+su_osc_wrk.gatestate] ; g x, g is gatestate, x is the input to this filter 0/1 fsub st1 ; g-x x do fmul dword [,c_dc_const,] ; c(g-x) x faddp st1, st0 ; x+c(g-x) fst dword [WRK+su_osc_wrk.gatestate]; g'=x+c(g-x) pop _AX ; Another way to see this (c~0.996) ret ; g'=cg+(1-c)x ; This is a low-pass to smooth the gate transitions %define USE_C_16 %define USE_C_DC_CONST %endif ; SAMPLES %ifdef INCLUDE_SAMPLES SECT_TEXT(suoscsam) su_oscillat_sample: ; p push_registers _AX,_DX,_CX,_BX ; edx must be saved, eax & ecx if this is stereo osc push _AX mov al, byte [VAL-4] ; reuse "color" as the sample number do{lea _DI, [}, MANGLE_DATA(su_sample_offsets), _AX*8,]; edi points now to the sample table entry do fmul dword [,c_samplefreq_scaling,] ; p*r fistp dword [_SP] pop _DX ; edx is now the sample number movzx ebx, word [_DI + su_sample_offset.loopstart] ; ecx = loopstart sub edx, ebx ; if sample number < loop start jl su_oscillat_sample_not_looping ; then we're not looping yet mov eax, edx ; eax = sample number movzx ecx, word [_DI + su_sample_offset.looplength] ; edi is now the loop length xor edx, edx ; div wants edx to be empty div ecx ; edx is now the remainder su_oscillat_sample_not_looping: add edx, ebx ; sampleno += loopstart add edx, dword [_DI + su_sample_offset.start] do fild word [,MANGLE_DATA(su_sample_table),_DX*2,] do fdiv dword [,c_32767,] pop_registers _AX,_DX,_CX,_BX ret %define USE_C_32767 %define USE_C_SAMPLEFREQ_SCALING %endif ;------------------------------------------------------------------------------- ; LOADVAL opcode ;------------------------------------------------------------------------------- ; Mono: push 2*v-1 on stack, where v is the input to port "value" ; Stereo: push 2*v-1 twice on stack ;------------------------------------------------------------------------------- %if LOADVAL_ID > -1 SECT_TEXT(suloadvl) EXPORT MANGLE_FUNC(su_op_loadval,0) %ifdef INCLUDE_STEREO_LOADVAL jnc su_op_loadval_mono call su_op_loadval_mono su_op_loadval_mono: %endif fld dword [INP+su_load_val_ports.value] ; v do fsub dword [,c_0_5,] fadd st0 ; 2*v-1 ret %endif ; SU_USE_LOAD_VAL ;------------------------------------------------------------------------------- ; RECEIVE opcode ;------------------------------------------------------------------------------- ; Mono: push l on stack, where l is the left channel received ; Stereo: push l r on stack ;------------------------------------------------------------------------------- %if RECEIVE_ID > -1 SECT_TEXT(sureceiv) EXPORT MANGLE_FUNC(su_op_receive,0) lea _CX, [WRK+su_unit.ports] %ifdef INCLUDE_STEREO_RECEIVE jnc su_op_receive_mono xor eax,eax fld dword [_CX+su_receive_ports.right] mov dword [_CX+su_receive_ports.right],eax su_op_receive_mono: %else xor eax,eax %endif fld dword [_CX+su_receive_ports.left] mov dword [_CX+su_receive_ports.left],eax ret %endif ; RECEIVE_ID > -1 ;------------------------------------------------------------------------------- ; IN opcode: inputs and clears a global port ;------------------------------------------------------------------------------- ; Mono: push the left channel of a global port (out or aux) ; Stereo: also push the right channel (stack in l r order) ;------------------------------------------------------------------------------- %if IN_ID > -1 SECT_TEXT(suopin) EXPORT MANGLE_FUNC(su_op_in,0) lodsb %ifdef INCLUDE_STEREO_IN mov _DI, [_SP + su_stack.synth] jnc su_op_in_mono call su_op_in_right su_op_in_mono: sub _DI, 4 su_op_in_right: xor ecx, ecx fld dword [_DI + su_synth.right + _AX*4] mov dword [_DI + su_synth.right + _AX*4], ecx %else xor ecx, ecx mov _DI, [_SP + su_stack.synth] fld dword [_DI + su_synth.left + _AX*4] mov dword [_DI + su_synth.left + _AX*4], ecx %endif ret %endif ; SU_IN_ID > -1
; A021405: Decimal expansion of 1/401. ; Submitted by Jamie Morken(m2) ; 0,0,2,4,9,3,7,6,5,5,8,6,0,3,4,9,1,2,7,1,8,2,0,4,4,8,8,7,7,8,0,5,4,8,6,2,8,4,2,8,9,2,7,6,8,0,7,9,8,0,0,4,9,8,7,5,3,1,1,7,2,0,6,9,8,2,5,4,3,6,4,0,8,9,7,7,5,5,6,1,0,9,7,2,5,6,8,5,7,8,5,5,3,6,1,5,9,6,0 seq $0,83811 ; Numbers n such that 2n+1 is the digit reversal of n+1. div $0,1604 mod $0,10
; ; Copyright (c) 2014 The WebM 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 in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" section .text ;Note: tap3 and tap4 have to be applied and added after other taps to avoid ;overflow. %macro HIGH_GET_FILTERS_4 0 mov rdx, arg(5) ;filter ptr mov rcx, 0x00000040 movdqa xmm7, [rdx] ;load filters pshuflw xmm0, xmm7, 0b ;k0 pshuflw xmm1, xmm7, 01010101b ;k1 pshuflw xmm2, xmm7, 10101010b ;k2 pshuflw xmm3, xmm7, 11111111b ;k3 psrldq xmm7, 8 pshuflw xmm4, xmm7, 0b ;k4 pshuflw xmm5, xmm7, 01010101b ;k5 pshuflw xmm6, xmm7, 10101010b ;k6 pshuflw xmm7, xmm7, 11111111b ;k7 punpcklwd xmm0, xmm6 punpcklwd xmm2, xmm5 punpcklwd xmm3, xmm4 punpcklwd xmm1, xmm7 movdqa k0k6, xmm0 movdqa k2k5, xmm2 movdqa k3k4, xmm3 movdqa k1k7, xmm1 movq xmm6, rcx pshufd xmm6, xmm6, 0 movdqa krd, xmm6 ;Compute max and min values of a pixel mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm0, rdx movq xmm1, rcx pshufd xmm0, xmm0, 0b movdqa xmm2, xmm0 psllw xmm0, xmm1 psubw xmm0, xmm2 pxor xmm1, xmm1 movdqa max, xmm0 ;max value (for clamping) movdqa min, xmm1 ;min value (for clamping) %endm %macro HIGH_APPLY_FILTER_4 1 punpcklwd xmm0, xmm6 ;two row in one register punpcklwd xmm1, xmm7 punpcklwd xmm2, xmm5 punpcklwd xmm3, xmm4 pmaddwd xmm0, k0k6 ;multiply the filter factors pmaddwd xmm1, k1k7 pmaddwd xmm2, k2k5 pmaddwd xmm3, k3k4 paddd xmm0, xmm1 ;sum paddd xmm0, xmm2 paddd xmm0, xmm3 paddd xmm0, krd ;rounding psrad xmm0, 7 ;shift packssdw xmm0, xmm0 ;pack to word ;clamp the values pminsw xmm0, max pmaxsw xmm0, min %if %1 movq xmm1, [rdi] pavgw xmm0, xmm1 %endif movq [rdi], xmm0 %endm %macro HIGH_GET_FILTERS 0 mov rdx, arg(5) ;filter ptr mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr mov rcx, 0x00000040 movdqa xmm7, [rdx] ;load filters pshuflw xmm0, xmm7, 0b ;k0 pshuflw xmm1, xmm7, 01010101b ;k1 pshuflw xmm2, xmm7, 10101010b ;k2 pshuflw xmm3, xmm7, 11111111b ;k3 pshufhw xmm4, xmm7, 0b ;k4 pshufhw xmm5, xmm7, 01010101b ;k5 pshufhw xmm6, xmm7, 10101010b ;k6 pshufhw xmm7, xmm7, 11111111b ;k7 punpcklqdq xmm2, xmm2 punpcklqdq xmm3, xmm3 punpcklwd xmm0, xmm1 punpckhwd xmm6, xmm7 punpckhwd xmm2, xmm5 punpckhwd xmm3, xmm4 movdqa k0k1, xmm0 ;store filter factors on stack movdqa k6k7, xmm6 movdqa k2k5, xmm2 movdqa k3k4, xmm3 movq xmm6, rcx pshufd xmm6, xmm6, 0 movdqa krd, xmm6 ;rounding ;Compute max and min values of a pixel mov rdx, 0x00010001 movsxd rcx, DWORD PTR arg(6) ;bd movq xmm0, rdx movq xmm1, rcx pshufd xmm0, xmm0, 0b movdqa xmm2, xmm0 psllw xmm0, xmm1 psubw xmm0, xmm2 pxor xmm1, xmm1 movdqa max, xmm0 ;max value (for clamping) movdqa min, xmm1 ;min value (for clamping) %endm %macro LOAD_VERT_8 1 movdqu xmm0, [rsi + %1] ;0 movdqu xmm1, [rsi + rax + %1] ;1 movdqu xmm6, [rsi + rdx * 2 + %1] ;6 lea rsi, [rsi + rax] movdqu xmm7, [rsi + rdx * 2 + %1] ;7 movdqu xmm2, [rsi + rax + %1] ;2 movdqu xmm3, [rsi + rax * 2 + %1] ;3 movdqu xmm4, [rsi + rdx + %1] ;4 movdqu xmm5, [rsi + rax * 4 + %1] ;5 %endm %macro HIGH_APPLY_FILTER_8 2 movdqu temp, xmm4 movdqa xmm4, xmm0 punpcklwd xmm0, xmm1 punpckhwd xmm4, xmm1 movdqa xmm1, xmm6 punpcklwd xmm6, xmm7 punpckhwd xmm1, xmm7 movdqa xmm7, xmm2 punpcklwd xmm2, xmm5 punpckhwd xmm7, xmm5 movdqu xmm5, temp movdqu temp, xmm4 movdqa xmm4, xmm3 punpcklwd xmm3, xmm5 punpckhwd xmm4, xmm5 movdqu xmm5, temp pmaddwd xmm0, k0k1 pmaddwd xmm5, k0k1 pmaddwd xmm6, k6k7 pmaddwd xmm1, k6k7 pmaddwd xmm2, k2k5 pmaddwd xmm7, k2k5 pmaddwd xmm3, k3k4 pmaddwd xmm4, k3k4 paddd xmm0, xmm6 paddd xmm0, xmm2 paddd xmm0, xmm3 paddd xmm5, xmm1 paddd xmm5, xmm7 paddd xmm5, xmm4 paddd xmm0, krd ;rounding paddd xmm5, krd psrad xmm0, 7 ;shift psrad xmm5, 7 packssdw xmm0, xmm5 ;pack back to word ;clamp the values pminsw xmm0, max pmaxsw xmm0, min %if %1 movdqu xmm1, [rdi + %2] pavgw xmm0, xmm1 %endif movdqu [rdi + %2], xmm0 %endm SECTION .text ;void vpx_highbd_filter_block1d4_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d4_v8_sse2) sym(vpx_highbd_filter_block1d4_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movq xmm0, [rsi] ;load src: row 0 movq xmm1, [rsi + rax] ;1 movq xmm6, [rsi + rdx * 2] ;6 lea rsi, [rsi + rax] movq xmm7, [rsi + rdx * 2] ;7 movq xmm2, [rsi + rax] ;2 movq xmm3, [rsi + rax * 2] ;3 movq xmm4, [rsi + rdx] ;4 movq xmm5, [rsi + rax * 4] ;5 HIGH_APPLY_FILTER_4 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d8_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d8_v8_sse2) sym(vpx_highbd_filter_block1d8_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 0, 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d16_v8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pitch, ; unsigned char *output_ptr, ; unsigned int out_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d16_v8_sse2) sym(vpx_highbd_filter_block1d16_v8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 0, 0 sub rsi, rax LOAD_VERT_8 16 HIGH_APPLY_FILTER_8 0, 16 add rdi, rbx dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d4_v8_avg_sse2) sym(vpx_highbd_filter_block1d4_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movq xmm0, [rsi] ;load src: row 0 movq xmm1, [rsi + rax] ;1 movq xmm6, [rsi + rdx * 2] ;6 lea rsi, [rsi + rax] movq xmm7, [rsi + rdx * 2] ;7 movq xmm2, [rsi + rax] ;2 movq xmm3, [rsi + rax * 2] ;3 movq xmm4, [rsi + rdx] ;4 movq xmm5, [rsi + rax * 4] ;5 HIGH_APPLY_FILTER_4 1 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d8_v8_avg_sse2) sym(vpx_highbd_filter_block1d8_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 1, 0 lea rdi, [rdi + rbx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d16_v8_avg_sse2) sym(vpx_highbd_filter_block1d16_v8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi push rbx ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rbx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rbx, [rbx + rbx] lea rdx, [rax + rax * 2] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: LOAD_VERT_8 0 HIGH_APPLY_FILTER_8 1, 0 sub rsi, rax LOAD_VERT_8 16 HIGH_APPLY_FILTER_8 1, 16 add rdi, rbx dec rcx jnz .loop add rsp, 16 * 8 pop rsp pop rbx ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d4_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d4_h8_sse2) sym(vpx_highbd_filter_block1d4_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm4, [rsi + 2] movdqa xmm1, xmm0 movdqa xmm6, xmm4 movdqa xmm7, xmm4 movdqa xmm2, xmm0 movdqa xmm3, xmm0 movdqa xmm5, xmm4 psrldq xmm1, 2 psrldq xmm6, 4 psrldq xmm7, 6 psrldq xmm2, 4 psrldq xmm3, 6 psrldq xmm5, 2 HIGH_APPLY_FILTER_4 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d8_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d8_h8_sse2) sym(vpx_highbd_filter_block1d8_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 0, 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;void vpx_highbd_filter_block1d16_h8_sse2 ;( ; unsigned char *src_ptr, ; unsigned int src_pixels_per_line, ; unsigned char *output_ptr, ; unsigned int output_pitch, ; unsigned int output_height, ; short *filter ;) globalsym(vpx_highbd_filter_block1d16_h8_sse2) sym(vpx_highbd_filter_block1d16_h8_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 0, 0 movdqu xmm0, [rsi + 10] ;load src movdqu xmm1, [rsi + 12] movdqu xmm2, [rsi + 14] movdqu xmm3, [rsi + 16] movdqu xmm4, [rsi + 18] movdqu xmm5, [rsi + 20] movdqu xmm6, [rsi + 22] movdqu xmm7, [rsi + 24] HIGH_APPLY_FILTER_8 0, 16 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d4_h8_avg_sse2) sym(vpx_highbd_filter_block1d4_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 7 %define k0k6 [rsp + 16 * 0] %define k2k5 [rsp + 16 * 1] %define k3k4 [rsp + 16 * 2] %define k1k7 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define max [rsp + 16 * 5] %define min [rsp + 16 * 6] HIGH_GET_FILTERS_4 mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;output_ptr movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm4, [rsi + 2] movdqa xmm1, xmm0 movdqa xmm6, xmm4 movdqa xmm7, xmm4 movdqa xmm2, xmm0 movdqa xmm3, xmm0 movdqa xmm5, xmm4 psrldq xmm1, 2 psrldq xmm6, 4 psrldq xmm7, 6 psrldq xmm2, 4 psrldq xmm3, 6 psrldq xmm5, 2 HIGH_APPLY_FILTER_4 1 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 7 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d8_h8_avg_sse2) sym(vpx_highbd_filter_block1d8_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 1, 0 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret globalsym(vpx_highbd_filter_block1d16_h8_avg_sse2) sym(vpx_highbd_filter_block1d16_h8_avg_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 SAVE_XMM 7 push rsi push rdi ; end prolog ALIGN_STACK 16, rax sub rsp, 16 * 8 %define k0k1 [rsp + 16 * 0] %define k6k7 [rsp + 16 * 1] %define k2k5 [rsp + 16 * 2] %define k3k4 [rsp + 16 * 3] %define krd [rsp + 16 * 4] %define temp [rsp + 16 * 5] %define max [rsp + 16 * 6] %define min [rsp + 16 * 7] HIGH_GET_FILTERS movsxd rax, DWORD PTR arg(1) ;pixels_per_line movsxd rdx, DWORD PTR arg(3) ;out_pitch lea rax, [rax + rax] ;bytes per line lea rdx, [rdx + rdx] movsxd rcx, DWORD PTR arg(4) ;output_height .loop: movdqu xmm0, [rsi - 6] ;load src movdqu xmm1, [rsi - 4] movdqu xmm2, [rsi - 2] movdqu xmm3, [rsi] movdqu xmm4, [rsi + 2] movdqu xmm5, [rsi + 4] movdqu xmm6, [rsi + 6] movdqu xmm7, [rsi + 8] HIGH_APPLY_FILTER_8 1, 0 movdqu xmm0, [rsi + 10] ;load src movdqu xmm1, [rsi + 12] movdqu xmm2, [rsi + 14] movdqu xmm3, [rsi + 16] movdqu xmm4, [rsi + 18] movdqu xmm5, [rsi + 20] movdqu xmm6, [rsi + 22] movdqu xmm7, [rsi + 24] HIGH_APPLY_FILTER_8 1, 16 lea rsi, [rsi + rax] lea rdi, [rdi + rdx] dec rcx jnz .loop add rsp, 16 * 8 pop rsp ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret
/**************************************************************************** ** Meta object code from reading C++ file 'playerbuttons.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../../Code/Piezo/Headers/playerbuttons.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'playerbuttons.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.9.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_PlayerButtons_t { QByteArrayData data[3]; char stringdata0[23]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PlayerButtons_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PlayerButtons_t qt_meta_stringdata_PlayerButtons = { { QT_MOC_LITERAL(0, 0, 13), // "PlayerButtons" QT_MOC_LITERAL(1, 14, 7), // "setPlay" QT_MOC_LITERAL(2, 22, 0) // "" }, "PlayerButtons\0setPlay\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PlayerButtons[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 1, 19, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, QMetaType::Bool, 2, 0 // eod }; void PlayerButtons::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PlayerButtons *_t = static_cast<PlayerButtons *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->setPlay((*reinterpret_cast< bool(*)>(_a[1]))); break; default: ; } } } const QMetaObject PlayerButtons::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_PlayerButtons.data, qt_meta_data_PlayerButtons, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *PlayerButtons::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PlayerButtons::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_PlayerButtons.stringdata0)) return static_cast<void*>(const_cast< PlayerButtons*>(this)); return QWidget::qt_metacast(_clname); } int PlayerButtons::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
#include "quihelper.h" int QUIHelper::getScreenIndex() { //需要对多个屏幕进行处理 int screenIndex = 0; #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) int screenCount = qApp->screens().count(); #else int screenCount = qApp->desktop()->screenCount(); #endif if (screenCount > 1) { //找到当前鼠标所在屏幕 QPoint pos = QCursor::pos(); for (int i = 0; i < screenCount; ++i) { #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) if (qApp->screens().at(i)->geometry().contains(pos)) { #else if (qApp->desktop()->screenGeometry(i).contains(pos)) { #endif screenIndex = i; break; } } } return screenIndex; } QRect QUIHelper::getScreenRect(bool available) { QRect rect; int screenIndex = QUIHelper::getScreenIndex(); if (available) { #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) rect = qApp->screens().at(screenIndex)->availableGeometry(); #else rect = qApp->desktop()->availableGeometry(screenIndex); #endif } else { #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) rect = qApp->screens().at(screenIndex)->geometry(); #else rect = qApp->desktop()->screenGeometry(screenIndex); #endif } return rect; } int QUIHelper::deskWidth() { return getScreenRect().width(); } int QUIHelper::deskHeight() { return getScreenRect().height(); } QWidget *QUIHelper::centerBaseForm = 0; void QUIHelper::setFormInCenter(QWidget *form) { int formWidth = form->width(); int formHeight = form->height(); //如果=0表示采用系统桌面屏幕为参照 QRect rect; if (centerBaseForm == 0) { rect = getScreenRect(); } else { rect = centerBaseForm->geometry(); } int deskWidth = rect.width(); int deskHeight = rect.height(); QPoint movePoint(deskWidth / 2 - formWidth / 2 + rect.x(), deskHeight / 2 - formHeight / 2 + rect.y()); form->move(movePoint); } QString QUIHelper::appName() { //没有必要每次都获取,只有当变量为空时才去获取一次 static QString name; if (name.isEmpty()) { name = qApp->applicationFilePath(); //下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a QStringList list = name.split("/"); name = list.at(list.count() - 1).split(".").at(0); } return name; } QString QUIHelper::appPath() { #ifdef Q_OS_ANDROID //return QString("/sdcard/Android/%1").arg(appName()); return QString("/storage/emulated/0/%1").arg(appName()); #else return qApp->applicationDirPath(); #endif } QString QUIHelper::getUuid() { QString uuid = QUuid::createUuid().toString(); uuid.replace("{", ""); uuid.replace("}", ""); return uuid; } void QUIHelper::initRand() { //初始化随机数种子 QTime t = QTime::currentTime(); srand(t.msec() + t.second() * 1000); } void QUIHelper::newDir(const QString &dirName) { QString strDir = dirName; //如果路径中包含斜杠字符则说明是绝对路径 //linux系统路径字符带有 / windows系统 路径字符带有 :/ if (!strDir.startsWith("/") && !strDir.contains(":/")) { strDir = QString("%1/%2").arg(QUIHelper::appPath()).arg(strDir); } QDir dir(strDir); if (!dir.exists()) { dir.mkpath(strDir); } } void QUIHelper::sleep(int msec) { if (msec > 0) { #if (QT_VERSION < QT_VERSION_CHECK(5,7,0)) QTime endTime = QTime::currentTime().addMSecs(msec); while (QTime::currentTime() < endTime) { QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } #else QThread::msleep(msec); #endif } } void QUIHelper::setStyle() { //打印下所有内置风格的名字 qDebug() << "Qt内置的样式" << QStyleFactory::keys(); #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) qApp->setStyle(QStyleFactory::create("Fusion")); #else qApp->setStyle(QStyleFactory::create("Cleanlooks")); #endif //qApp->setPalette(QPalette("#FFFFFF")); } void QUIHelper::setFont(int fontSize) { QFont font; font.setFamily("MicroSoft Yahei"); #ifdef Q_OS_ANDROID font.setPixelSize(15); #elif __arm__ font.setPixelSize(25); #else font.setPixelSize(fontSize); #endif #ifndef rk3399 #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) qApp->setFont(font); #endif #endif } void QUIHelper::setCode(bool utf8) { #if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) #if _MSC_VER QTextCodec *codec = QTextCodec::codecForName("gbk"); #else QTextCodec *codec = QTextCodec::codecForName("utf-8"); #endif QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForTr(codec); #else //如果想要控制台打印信息中文正常就注释掉这个设置 if (utf8) { QTextCodec *codec = QTextCodec::codecForName("utf-8"); QTextCodec::setCodecForLocale(codec); } #endif } void QUIHelper::setTranslator(const QString &qmFile) { QTranslator *translator = new QTranslator(qApp); translator->load(qmFile); qApp->installTranslator(translator); } int QUIHelper::showMessageBox(const QString &info, int type, int closeSec, bool exec) { int result = 0; if (type == 0) { showMessageBoxInfo(info, closeSec, exec); } else if (type == 1) { showMessageBoxError(info, closeSec, exec); } else if (type == 2) { result = showMessageBoxQuestion(info); } return result; } void QUIHelper::showMessageBoxInfo(const QString &info, int closeSec, bool exec) { QMessageBox box(QMessageBox::Information, "提示", info); box.setStandardButtons(QMessageBox::Yes); box.setButtonText(QMessageBox::Yes, QString("确 定")); box.exec(); //QMessageBox::information(0, "提示", info, QMessageBox::Yes); } void QUIHelper::showMessageBoxError(const QString &info, int closeSec, bool exec) { QMessageBox box(QMessageBox::Critical, "错误", info); box.setStandardButtons(QMessageBox::Yes); box.setButtonText(QMessageBox::Yes, QString("确 定")); box.exec(); //QMessageBox::critical(0, "错误", info, QMessageBox::Yes); } int QUIHelper::showMessageBoxQuestion(const QString &info) { QMessageBox box(QMessageBox::Question, "询问", info); box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); box.setButtonText(QMessageBox::Yes, QString("确 定")); box.setButtonText(QMessageBox::No, QString("取 消")); return box.exec(); //return QMessageBox::question(0, "询问", info, QMessageBox::Yes | QMessageBox::No); } QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key) { //矫正范围外的数据 if (key < 0 || key >= 127) { key = 127; } QString result = value; int count = result.count(); for (int i = 0; i < count; i++) { result[i] = QChar(result.at(i).toLatin1() ^ key); } return result; } uchar QUIHelper::getOrCode(const QByteArray &data) { int len = data.length(); uchar result = 0; for (int i = 0; i < len; i++) { result ^= data.at(i); } return result; } uchar QUIHelper::getCheckCode(const QByteArray &data) { int len = data.length(); uchar temp = 0; for (uchar i = 0; i < len; i++) { temp += data.at(i); } return temp % 256; } void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast) { //取消自动换行 tableView->setWordWrap(false); //超出文本不显示省略号 tableView->setTextElideMode(Qt::ElideNone); //奇数偶数行颜色交替 tableView->setAlternatingRowColors(false); //垂直表头是否可见 tableView->verticalHeader()->setVisible(headVisible); //选中一行表头是否加粗 tableView->horizontalHeader()->setHighlightSections(false); //最后一行拉伸填充 tableView->horizontalHeader()->setStretchLastSection(stretchLast); //行标题最小宽度尺寸 tableView->horizontalHeader()->setMinimumSectionSize(0); //行标题最小高度,等同于和默认行高一致 tableView->horizontalHeader()->setFixedHeight(rowHeight); //默认行高 tableView->verticalHeader()->setDefaultSectionSize(rowHeight); //选中时一行整体选中 tableView->setSelectionBehavior(QAbstractItemView::SelectRows); //只允许选择单个 tableView->setSelectionMode(QAbstractItemView::SingleSelection); //表头不可单击 #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) tableView->horizontalHeader()->setSectionsClickable(false); #else tableView->horizontalHeader()->setClickable(false); #endif //鼠标按下即进入编辑模式 if (edit) { tableView->setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::DoubleClicked); } else { tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); } } void QUIHelper::openFile(const QString &fileName, const QString &msg) { #ifdef __arm__ return; #endif if (fileName.isEmpty()) { return; } if (QUIHelper::showMessageBoxQuestion(msg + "成功!确定现在就打开吗?") == QMessageBox::Yes) { QString url = QString("file:///%1").arg(fileName); QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode)); } } bool QUIHelper::checkIniFile(const QString &iniFile) { //如果配置文件大小为0,则以初始值继续运行,并生成配置文件 QFile file(iniFile); if (file.size() == 0) { return false; } //如果配置文件不完整,则以初始值继续运行,并生成配置文件 if (file.open(QFile::ReadOnly)) { bool ok = true; while (!file.atEnd()) { QString line = file.readLine(); line.replace("\r", ""); line.replace("\n", ""); QStringList list = line.split("="); if (list.count() == 2) { if (list.at(1) == "") { qDebug() << "ini node no value" << list.at(0); ok = false; break; } } } if (!ok) { return false; } } else { return false; } return true; }
#ifndef RA_API_UPLOAD_BADGE_HH #define RA_API_UPLOAD_BADGE_HH #pragma once #include "ApiCall.hh" #include "ra_fwd.h" namespace ra { namespace api { class UploadBadge { public: static constexpr const char* const Name() noexcept { return "UploadBadge"; } struct Response : ApiResponseBase { std::string BadgeId; }; struct Request : ApiRequestBase { std::wstring ImageFilePath; using Callback = std::function<void(const Response& response)>; Response Call() const; void CallAsync(Callback&& callback) const { ApiRequestBase::CallAsync<Request, Callback>(*this, std::move(callback)); } }; }; } // namespace api } // namespace ra #endif // !RA_API_UPLOAD_BADGE_HH
; A158274: Numerators of antiharmonic means of divisors of n. ; Submitted by Christian Krause ; 1,5,5,3,13,25,25,17,7,65,61,15,85,125,65,11,145,35,181,13,125,305,265,85,21,425,41,75,421,325,481,65,305,725,325,21,685,181,425,221,841,625,925,61,91,1325,1105,55,43,35,725,255,1405,205,793,425,181,421,1741,65,1861,2405,175,43,1105,1525,2245,145,1325,1625,2521,119,2665,3425,105,543,1525,2125,3121,143,61,4205,3445,375,1885,4625,421,1037,3961,455,2125,265,2405,5525,2353,325,4705,215,427,63 add $0,1 mov $2,$0 lpb $0 add $1,$4 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 add $4,$3 lpe add $4,1 add $4,$1 gcd $1,$4 div $4,$1 mov $0,$4
/* Copyright (C) 2013-2018 Draios Inc dba Sysdig. This file is part of sysdig. Licensed under the Apache License, Version 2.0 (the "License"); 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. */ // // k8s_api_handler.cpp // #if !defined(CYGWING_AGENT) && !defined(_WIN32) #ifdef HAS_CAPTURE #include "k8s_api_handler.h" #include "sinsp.h" #include "sinsp_int.h" // filters normalize state and event JSONs, so they can be processed generically: // event is turned into a single-entry array, state is turned into an array of ADDED events k8s_api_handler::k8s_api_handler(collector_ptr_t collector, const std::string& url, const std::string& path, const std::string& filter, const std::string& http_version #ifdef HAS_CAPTURE ,ssl_ptr_t ssl ,bt_ptr_t bt ,bool blocking_socket #endif // HAS_CAPTURE ): k8s_handler("k8s_api_handler", false, #ifdef HAS_CAPTURE url, path, filter, ".", "", collector, http_version, 1000L, ssl, bt, false, true, std::make_shared<k8s_dummy_handler>(), blocking_socket, #endif // HAS_CAPTURE ~0, nullptr) { } k8s_api_handler::~k8s_api_handler() { } bool k8s_api_handler::handle_component(const Json::Value& json, const msg_data* data) { m_error = false; if(!json.isNull()) { if(json.isArray()) { for(const auto& version : json) { if(version.isConvertibleTo(Json::stringValue)) { m_extensions.push_back(version.asString()); } else { g_logger.log("K8s API handler error: could not extract API versions or extensions from JSON.", sinsp_logger::SEV_ERROR); m_error = true; return false; } } } else if(json.isConvertibleTo(Json::stringValue)) { m_extensions.push_back(json.asString()); } else { g_logger.log("K8s API handler error: could not extract API versions or extensions from JSON.", sinsp_logger::SEV_ERROR); m_error = true; return false; } m_data_received = true; } else { g_logger.log("K8s API handler error: json is null.", sinsp_logger::SEV_ERROR); m_error = true; return false; } return true; } void k8s_api_handler::handle_json(Json::Value&& root) { if(g_logger.get_severity() >= sinsp_logger::SEV_TRACE) { g_logger.log("K8S API handler [" + json_as_string(root) + "] reply:\n", sinsp_logger::SEV_TRACE); } handle_component(root); } bool k8s_api_handler::has(const std::string& version) const { for(const auto& ver : m_extensions) { if(ver == version) { return true; } } return false; } #endif // HAS_CAPTURE #endif // CYGWING_AGENT
#include "GAMER.h" #ifdef GRAVITY //output the dimensionless power spectrum //#define DIMENSIONLESS_FORM static void GetBasePowerSpectrum( real *RhoK, const int j_start, const int dj, double *PS_total ); #ifdef SERIAL extern rfftwnd_plan FFTW_Plan_PS; #else extern rfftwnd_mpi_plan FFTW_Plan_PS; #endif //------------------------------------------------------------------------------------------------------- // Function : Output_BasePowerSpectrum // Description : Evaluate and output the base-level power spectrum by FFT // // Parameter : FileName : Name of the output file //------------------------------------------------------------------------------------------------------- void Output_BasePowerSpectrum( const char *FileName ) { if ( MPI_Rank == 0 ) Aux_Message( stdout, "%s (DumpID = %d) ...\n", __FUNCTION__, DumpID ); // 1. determine the FFT size const int Nx_Padded = NX0_TOT[0]/2+1; const int FFT_Size[3] = { NX0_TOT[0], NX0_TOT[1], NX0_TOT[2] }; // get the array indices using by FFTW int local_nz, local_z_start, local_ny_after_transpose, local_y_start_after_transpose, total_local_size; # ifdef SERIAL local_nz = FFT_Size[2]; local_z_start = 0; local_ny_after_transpose = NULL_INT; local_y_start_after_transpose = NULL_INT; total_local_size = 2*Nx_Padded*FFT_Size[1]*FFT_Size[2]; # else rfftwnd_mpi_local_sizes( FFTW_Plan_PS, &local_nz, &local_z_start, &local_ny_after_transpose, &local_y_start_after_transpose, &total_local_size ); # endif // collect "local_nz" from all ranks and set the corresponding list "List_z_start" int List_nz [MPI_NRank ]; // slab thickness of each rank in the FFTW slab decomposition int List_z_start[MPI_NRank+1]; // starting z coordinate of each rank in the FFTW slab decomposition MPI_Allgather( &local_nz, 1, MPI_INT, List_nz, 1, MPI_INT, MPI_COMM_WORLD ); List_z_start[0] = 0; for (int r=0; r<MPI_NRank; r++) List_z_start[r+1] = List_z_start[r] + List_nz[r]; if ( List_z_start[MPI_NRank] != FFT_Size[2] ) Aux_Error( ERROR_INFO, "List_z_start[%d] (%d) != expectation (%d) !!\n", MPI_NRank, List_z_start[MPI_NRank], FFT_Size[2] ); // 2. allocate memory const int NRecvSlice = MIN( List_z_start[MPI_Rank]+local_nz, NX0_TOT[2] ) - MIN( List_z_start[MPI_Rank], NX0_TOT[2] ); double *PS_total = NULL; real *RhoK = new real [ total_local_size ]; // array storing both density and potential real *SendBuf = new real [ amr->NPatchComma[0][1]*CUBE(PS1) ]; // MPI send buffer for density and potential real *RecvBuf = new real [ NX0_TOT[0]*NX0_TOT[1]*NRecvSlice ]; // MPI recv buffer for density and potentia long *SendBuf_SIdx = new long [ amr->NPatchComma[0][1]*PS1 ]; // MPI send buffer for 1D coordinate in slab long *RecvBuf_SIdx = new long [ NX0_TOT[0]*NX0_TOT[1]*NRecvSlice/SQR(PS1) ];// MPI recv buffer for 1D coordinate in slab int *List_PID [MPI_NRank]; // PID of each patch slice sent to each rank int *List_k [MPI_NRank]; // local z coordinate of each patch slice sent to each rank int List_NSend [MPI_NRank]; // size of data (density/potential) sent to each rank int List_NRecv [MPI_NRank]; // size of data (density/potential) received from each rank if ( MPI_Rank == 0 ) PS_total = new double [Nx_Padded]; // 3. initialize the particle density array (rho_ext) and collect particles to the target level # ifdef PARTICLE const bool TimingSendPar_No = false; const bool JustCountNPar_No = false; # ifdef LOAD_BALANCE const bool PredictPos = amr->Par->PredictPos; const bool SibBufPatch = true; const bool FaSibBufPatch = true; # else const bool PredictPos = false; const bool SibBufPatch = NULL_BOOL; const bool FaSibBufPatch = NULL_BOOL; # endif Prepare_PatchData_InitParticleDensityArray( 0 ); Par_CollectParticle2OneLevel( 0, _PAR_MASS|_PAR_POSX|_PAR_POSY|_PAR_POSZ, PredictPos, Time[0], SibBufPatch, FaSibBufPatch, JustCountNPar_No, TimingSendPar_No ); # endif // #ifdef PARTICLE // 4. rearrange data from patch to slab Patch2Slab( RhoK, SendBuf, RecvBuf, SendBuf_SIdx, RecvBuf_SIdx, List_PID, List_k, List_NSend, List_NRecv, List_z_start, local_nz, FFT_Size, NRecvSlice, Time[0] ); // 5. evaluate the base-level power spectrum by FFT GetBasePowerSpectrum( RhoK, local_y_start_after_transpose, local_ny_after_transpose, PS_total ); // 6. output the power spectrum if ( MPI_Rank == 0 ) { // check if the target file already exists if ( Aux_CheckFileExist(FileName) ) Aux_Message( stderr, "WARNING : file \"%s\" already exists and will be overwritten !!\n", FileName ); // output the power spectrum const double WaveK0 = 2.0*M_PI/amr->BoxSize[0]; FILE *File = fopen( FileName, "w" ); fprintf( File, "%13s%4s%13s\n", "k", "", "Power" ); // DC mode is not output for (int b=1; b<Nx_Padded; b++) fprintf( File, "%13.6e%4s%13.6e\n", WaveK0*b, "", PS_total[b] ); fclose( File ); } // if ( MPI_Rank == 0 ) // 7. free memory delete [] RhoK; delete [] SendBuf; delete [] RecvBuf; delete [] SendBuf_SIdx; delete [] RecvBuf_SIdx; if ( MPI_Rank == 0 ) delete [] PS_total; // free memory for collecting particles from other ranks and levels, and free density arrays with ghost zones (rho_ext) # ifdef PARTICLE Par_CollectParticle2OneLevel_FreeMemory( 0, SibBufPatch, FaSibBufPatch ); Prepare_PatchData_FreeParticleDensityArray( 0 ); # endif if ( MPI_Rank == 0 ) Aux_Message( stdout, "%s (DumpID = %d) ... done\n", __FUNCTION__, DumpID ); } // FUNCTION : Output_BasePowerSpectrum //------------------------------------------------------------------------------------------------------- // Function : GetBasePowerSpectrum // Description : Evaluate and base-level power spectrum by FFT // // Note : Invoked by the function "Output_BasePowerSpectrum" // // Parameter : RhoK : Array storing the input density and output potential // j_start : Starting j index // dj : Size of array in the j (y) direction after the forward FFT // PS_total : Power spectrum summed over all MPI ranks // // Return : PS_total //------------------------------------------------------------------------------------------------------- void GetBasePowerSpectrum( real *RhoK, const int j_start, const int dj, double *PS_total ) { // check if ( MPI_Rank == 0 && PS_total == NULL ) Aux_Error( ERROR_INFO, "PS_total == NULL at the root rank !!\n" ); const int Nx = NX0_TOT[0]; const int Ny = NX0_TOT[1]; const int Nz = NX0_TOT[2]; const int Nx_Padded = Nx/2 + 1; fftw_complex *cdata=NULL; double PS_local[Nx_Padded]; long Count_local[Nx_Padded], Count_total[Nx_Padded]; int bin, bin_i[Nx_Padded], bin_j[Ny], bin_k[Nz]; // forward FFT # ifdef SERIAL rfftwnd_one_real_to_complex( FFTW_Plan_PS, RhoK, NULL ); # else rfftwnd_mpi( FFTW_Plan_PS, 1, RhoK, NULL, FFTW_TRANSPOSED_ORDER ); # endif // the data are now complex, so typecast a pointer cdata = (fftw_complex*) RhoK; // set up the dimensionless wave number coefficients according to the FFTW data format for (int i=0; i<Nx_Padded; i++) bin_i[i] = i; for (int j=0; j<Ny; j++) bin_j[j] = ( j <= Ny/2 ) ? j : j-Ny; for (int k=0; k<Nz; k++) bin_k[k] = ( k <= Nz/2 ) ? k : k-Nz; // estimate the power spectrum long Idx; for (int b=0; b<Nx_Padded; b++) { PS_local [b] = 0.0; Count_local[b] = 0; } # ifdef SERIAL // serial mode for (int k=0; k<Nz; k++) { for (int j=0; j<Ny; j++) for (int i=0; i<Nx_Padded; i++) { Idx = ((long)k*Ny + j)*Nx_Padded + i; # else // parallel mode int j; for (int jj=0; jj<dj; jj++) { j = j_start + jj; for (int k=0; k<Nz; k++) for (int i=0; i<Nx_Padded; i++) { Idx = ((long)jj*Nz + k)*Nx_Padded + i; # endif // #ifdef SERIAL ... else ... // round to nearest bin // bin = int( SQRT( real( SQR(bin_i[i]) + SQR(bin_j[j]) + SQR(bin_k[k]) ) ) ); # ifdef FLOAT8 bin = lround ( SQRT( real( SQR(bin_i[i]) + SQR(bin_j[j]) + SQR(bin_k[k]) ) ) ); # else bin = lroundf( SQRT( real( SQR(bin_i[i]) + SQR(bin_j[j]) + SQR(bin_k[k]) ) ) ); # endif if ( bin < Nx_Padded ) { PS_local [bin] += double( SQR( cdata[Idx].re ) + SQR( cdata[Idx].im ) ); Count_local[bin] ++; } } // i,j,k } // i,j,k // sum over all ranks MPI_Reduce( PS_local, PS_total, Nx_Padded, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD ); MPI_Reduce( Count_local, Count_total, Nx_Padded, MPI_LONG, MPI_SUM, 0, MPI_COMM_WORLD ); // normalization: SQR(AveRho) accounts for Delta=Rho/AveRho // --> we have assumed that the total mass in the simulation is conserved (since we don't recalculate it here) const double Coeff = amr->BoxSize[0]*amr->BoxSize[1]*amr->BoxSize[2] / SQR( (double)Nx*(double)Ny*(double)Nz*AveDensity_Init ); double Norm; # ifdef DIMENSIONLESS_FORM const double k0 = 2.0*M_PI/amr->BoxSize[0]; // assuming cubic box double WaveK; # endif if ( MPI_Rank == 0 ) { for (int b=0; b<Nx_Padded; b++) { // average PS_total[b] /= (double)Count_total[b]; // normalization # ifdef DIMENSIONLESS_FORM WaveK = b*k0; Norm = Coeff*CUBE(WaveK)/(2.0*M_PI*M_PI); // dimensionless power spectrum # else Norm = Coeff; // dimensional power spectrum [Mpc^3/h^3] # endif PS_total[b] *= Norm; } } } // FUNCTION : GetBasePowerSpectrum #endif // #ifdef GRAVITY
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0xbb88, %rdx sub %rdi, %rdi movb (%rdx), %bl nop nop nop nop xor $36443, %r11 lea addresses_D_ht+0x102b8, %rsi lea addresses_A_ht+0xb488, %rdi nop nop nop nop and %rbp, %rbp mov $5, %rcx rep movsw nop nop nop add $53383, %rbp lea addresses_normal_ht+0x190c8, %rdx nop cmp %rbp, %rbp movb (%rdx), %cl nop nop xor $4580, %rbp lea addresses_D_ht+0xd6c8, %rsi lea addresses_normal_ht+0x3248, %rdi clflush (%rsi) add $35187, %r8 mov $53, %rcx rep movsq nop nop nop nop nop sub $25557, %rdx lea addresses_A_ht+0x1acc8, %rdi nop nop nop nop nop cmp %rbp, %rbp movl $0x61626364, (%rdi) nop nop nop nop nop and %rcx, %rcx lea addresses_WT_ht+0x1cec8, %rcx nop nop nop nop nop add $7409, %rbp mov (%rcx), %edx nop cmp %rbx, %rbx lea addresses_UC_ht+0x6048, %rsi lea addresses_normal_ht+0x15ac8, %rdi nop nop nop inc %rdx mov $115, %rcx rep movsw nop inc %r11 lea addresses_A_ht+0x132c8, %rsi lea addresses_WC_ht+0x18658, %rdi clflush (%rdi) nop sub %r8, %r8 mov $122, %rcx rep movsb and %rdx, %rdx lea addresses_D_ht+0x19748, %rbp nop nop nop nop sub $63189, %rbx mov (%rbp), %rsi nop nop nop xor %rdx, %rdx lea addresses_D_ht+0x1891d, %rcx nop nop nop nop add $51573, %rbx mov $0x6162636465666768, %rdi movq %rdi, %xmm3 movups %xmm3, (%rcx) add $31853, %r11 lea addresses_WT_ht+0x15ce8, %rsi lea addresses_UC_ht+0x16c8, %rdi nop nop nop cmp $5227, %rdx mov $121, %rcx rep movsq nop nop nop nop and $8024, %rdi lea addresses_A_ht+0x5ec8, %r11 nop nop nop nop sub $50262, %r8 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 and $0xffffffffffffffc0, %r11 movaps %xmm3, (%r11) nop nop nop nop and $10464, %r8 lea addresses_WC_ht+0x1a08, %rsi lea addresses_A_ht+0x2b48, %rdi nop nop nop nop nop dec %r8 mov $56, %rcx rep movsq nop nop nop nop xor $62169, %rcx lea addresses_WT_ht+0x32e8, %rsi lea addresses_WC_ht+0x1579f, %rdi nop nop add $49417, %rdx mov $57, %rcx rep movsb sub %r11, %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %r9 push %rbx push %rsi // Faulty Load mov $0x28b30f0000000ec8, %r13 nop nop nop and $23849, %r14 movups (%r13), %xmm4 vpextrq $0, %xmm4, %r8 lea oracles, %rsi and $0xff, %r8 shlq $12, %r8 mov (%rsi,%r8,1), %r8 pop %rsi pop %rbx pop %r9 pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': True, 'AVXalign': False, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': True, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_WC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
GetEmote2bpp: ld a, $1 ldh [rVBK], a call Get2bpp xor a ldh [rVBK], a ret _ReplaceKrisSprite:: call GetPlayerSprite ld a, [wUsedSprites] ldh [hUsedSpriteIndex], a ld a, [wUsedSprites + 1] ldh [hUsedSpriteTile], a call GetUsedSprite ret Function14146: ; mobile ld hl, wSpriteFlags ld a, [hl] push af res 7, [hl] set 6, [hl] call LoadUsedSpritesGFX pop af ld [wSpriteFlags], a ret Function14157: ; mobile ld hl, wSpriteFlags ld a, [hl] push af set 7, [hl] res 6, [hl] call LoadUsedSpritesGFX pop af ld [wSpriteFlags], a ret RefreshSprites:: call .Refresh call LoadUsedSpritesGFX ret .Refresh: xor a ld bc, wUsedSpritesEnd - wUsedSprites ld hl, wUsedSprites call ByteFill call GetPlayerSprite call AddMapSprites call LoadAndSortSprites ret GetPlayerSprite: ; Get Chris or Kris's sprite. ld hl, ChrisStateSprites ld a, [wPlayerSpriteSetupFlags] bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a jr nz, .go ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .go ld hl, KrisStateSprites .go ld a, [wPlayerState] ld c, a .loop ld a, [hli] cp c jr z, .good inc hl cp -1 jr nz, .loop ; Any player state not in the array defaults to Chris's sprite. xor a ; ld a, PLAYER_NORMAL ld [wPlayerState], a ld a, SPRITE_CHRIS jr .finish .good ld a, [hl] .finish ld [wUsedSprites + 0], a ld [wPlayerSprite], a ld [wPlayerObjectSprite], a ret INCLUDE "data/sprites/player_sprites.asm" AddMapSprites: call GetMapEnvironment call CheckOutdoorMap jr z, .outdoor call AddIndoorSprites ret .outdoor call AddOutdoorSprites ret AddIndoorSprites: ld hl, wMap1ObjectSprite ld a, 1 .loop push af ld a, [hl] call AddSpriteGFX ld de, OBJECT_LENGTH add hl, de pop af inc a cp NUM_OBJECTS jr nz, .loop ret AddOutdoorSprites: ld a, [wMapGroup] dec a ld c, a ld b, 0 ld hl, OutdoorSprites add hl, bc add hl, bc ld a, [hli] ld h, [hl] ld l, a ld c, MAX_OUTDOOR_SPRITES .loop push bc ld a, [hli] call AddSpriteGFX pop bc dec c jr nz, .loop ret LoadUsedSpritesGFX: ld a, MAPCALLBACK_SPRITES call RunMapCallback call GetUsedSprites call .LoadMiscTiles ret .LoadMiscTiles: ld a, [wSpriteFlags] bit 6, a ret nz ld c, EMOTE_SHADOW farcall LoadEmote call GetMapEnvironment call CheckOutdoorMap ld c, EMOTE_GRASS_RUSTLE jr z, .outdoor ld c, EMOTE_BOULDER_DUST .outdoor farcall LoadEmote ret SafeGetSprite: push hl call GetSprite pop hl ret GetSprite: call GetMonSprite ret c ld hl, OverworldSprites + SPRITEDATA_ADDR dec a ld c, a ld b, 0 ld a, NUM_SPRITEDATA_FIELDS call AddNTimes ; load the address into de ld a, [hli] ld e, a ld a, [hli] ld d, a ; load the length into c ld a, [hli] swap a ld c, a ; load the sprite bank into both b and h ld b, [hl] ld a, [hli] ; load the sprite type into l ld l, [hl] ld h, a ret GetMonSprite: ; Return carry if a monster sprite was loaded. cp SPRITE_POKEMON jr c, .Normal cp SPRITE_DAY_CARE_MON_1 jr z, .BreedMon1 cp SPRITE_DAY_CARE_MON_2 jr z, .BreedMon2 cp SPRITE_VARS jr nc, .Variable jr .Icon .Normal: and a ret .Icon: sub SPRITE_POKEMON ld e, a ld d, 0 ld hl, SpriteMons add hl, de ld a, [hl] jr .Mon .BreedMon1 ld a, [wBreedMon1Species] jr .Mon .BreedMon2 ld a, [wBreedMon2Species] .Mon: ld e, a and a jr z, .NoBreedmon farcall LoadOverworldMonIcon ld l, 1 ld h, 0 scf ret .Variable: sub SPRITE_VARS ld e, a ld d, 0 ld hl, wVariableSprites add hl, de ld a, [hl] and a jp nz, GetMonSprite .NoBreedmon: ld a, 1 ld l, 1 ld h, 0 and a ret _DoesSpriteHaveFacings:: ; Checks to see whether we can apply a facing to a sprite. ; Returns carry unless the sprite is a Pokemon or a Still Sprite. cp SPRITE_POKEMON jr nc, .only_down push hl push bc ld hl, OverworldSprites + SPRITEDATA_TYPE dec a ld c, a ld b, 0 ld a, NUM_SPRITEDATA_FIELDS call AddNTimes ld a, [hl] pop bc pop hl cp STILL_SPRITE jr nz, .only_down scf ret .only_down and a ret _GetSpritePalette:: ld a, c call GetMonSprite jr c, .is_pokemon ld hl, OverworldSprites + SPRITEDATA_PALETTE dec a ld c, a ld b, 0 ld a, NUM_SPRITEDATA_FIELDS call AddNTimes ld c, [hl] ret .is_pokemon xor a ld c, a ret LoadAndSortSprites: call LoadSpriteGFX call SortUsedSprites call ArrangeUsedSprites ret AddSpriteGFX: ; Add any new sprite ids to a list of graphics to be loaded. ; Return carry if the list is full. push hl push bc ld b, a ld hl, wUsedSprites + 2 ld c, SPRITE_GFX_LIST_CAPACITY - 1 .loop ld a, [hl] cp b jr z, .exists and a jr z, .new inc hl inc hl dec c jr nz, .loop pop bc pop hl scf ret .exists pop bc pop hl and a ret .new ld [hl], b pop bc pop hl and a ret LoadSpriteGFX: ld hl, wUsedSprites ld b, SPRITE_GFX_LIST_CAPACITY .loop ld a, [hli] and a jr z, .done push hl call .LoadSprite pop hl ld [hli], a dec b jr nz, .loop .done ret .LoadSprite: push bc call GetSprite pop bc ld a, l ret SortUsedSprites: ; Bubble-sort sprites by type. ; Run backwards through wUsedSprites to find the last one. ld c, SPRITE_GFX_LIST_CAPACITY ld de, wUsedSprites + (SPRITE_GFX_LIST_CAPACITY - 1) * 2 .FindLastSprite: ld a, [de] and a jr nz, .FoundLastSprite dec de dec de dec c jr nz, .FindLastSprite .FoundLastSprite: dec c jr z, .quit ; If the length of the current sprite is ; higher than a later one, swap them. inc de ld hl, wUsedSprites + 1 .CheckSprite: push bc push de push hl .CheckFollowing: ld a, [de] cp [hl] jr nc, .loop ; Swap the two sprites. ld b, a ld a, [hl] ld [hl], b ld [de], a dec de dec hl ld a, [de] ld b, a ld a, [hl] ld [hl], b ld [de], a inc de inc hl ; Keep doing this until everything's in order. .loop dec de dec de dec c jr nz, .CheckFollowing pop hl inc hl inc hl pop de pop bc dec c jr nz, .CheckSprite .quit ret ArrangeUsedSprites: ; Get the length of each sprite and space them out in VRAM. ; Crystal introduces a second table in VRAM bank 0. ld hl, wUsedSprites ld c, SPRITE_GFX_LIST_CAPACITY ld b, 0 .FirstTableLength: ; Keep going until the end of the list. ld a, [hli] and a jr z, .quit ld a, [hl] call GetSpriteLength ; Spill over into the second table after $80 tiles. add b cp $80 jr z, .loop jr nc, .SecondTable .loop ld [hl], b inc hl ld b, a ; Assumes the next table will be reached before c hits 0. dec c jr nz, .FirstTableLength .SecondTable: ; The second tile table starts at tile $80. ld b, $80 dec hl .SecondTableLength: ; Keep going until the end of the list. ld a, [hli] and a jr z, .quit ld a, [hl] call GetSpriteLength ; There are only two tables, so don't go any further than that. add b jr c, .quit ld [hl], b ld b, a inc hl dec c jr nz, .SecondTableLength .quit ret GetSpriteLength: ; Return the length of sprite type a in tiles. cp WALKING_SPRITE jr z, .AnyDirection cp STANDING_SPRITE jr z, .AnyDirection cp STILL_SPRITE jr z, .OneDirection ld a, 12 ret .AnyDirection: ld a, 12 ret .OneDirection: ld a, 4 ret GetUsedSprites: ld hl, wUsedSprites ld c, SPRITE_GFX_LIST_CAPACITY .loop ld a, [wSpriteFlags] res 5, a ld [wSpriteFlags], a ld a, [hli] and a jr z, .done ldh [hUsedSpriteIndex], a ld a, [hli] ldh [hUsedSpriteTile], a bit 7, a jr z, .dont_set ld a, [wSpriteFlags] set 5, a ; load VBank0 ld [wSpriteFlags], a .dont_set push bc push hl call GetUsedSprite pop hl pop bc dec c jr nz, .loop .done ret GetUsedSprite: ldh a, [hUsedSpriteIndex] call SafeGetSprite ldh a, [hUsedSpriteTile] call .GetTileAddr push hl push de push bc ld a, [wSpriteFlags] bit 7, a jr nz, .skip call .CopyToVram .skip pop bc ld l, c ld h, $0 rept 4 add hl, hl endr pop de add hl, de ld d, h ld e, l pop hl ld a, [wSpriteFlags] bit 5, a jr nz, .done bit 6, a jr nz, .done ldh a, [hUsedSpriteIndex] call _DoesSpriteHaveFacings jr c, .done ld a, h add HIGH(vTiles1 - vTiles0) ld h, a call .CopyToVram .done ret .GetTileAddr: ; Return the address of tile (a) in (hl). and $7f ld l, a ld h, 0 rept 4 add hl, hl endr ld a, l add LOW(vTiles0) ld l, a ld a, h adc HIGH(vTiles0) ld h, a ret .CopyToVram: ldh a, [rVBK] push af ld a, [wSpriteFlags] bit 5, a ld a, $1 jr z, .bankswitch ld a, $0 .bankswitch ldh [rVBK], a call Get2bpp pop af ldh [rVBK], a ret LoadEmote:: ; Get the address of the pointer to emote c. ld a, c ld bc, 6 ; sizeof(emote) ld hl, Emotes call AddNTimes ; Load the emote address into de ld e, [hl] inc hl ld d, [hl] ; load the length of the emote (in tiles) into c inc hl ld c, [hl] swap c ; load the emote pointer bank into b inc hl ld b, [hl] ; load the VRAM destination into hl inc hl ld a, [hli] ld h, [hl] ld l, a ; if the emote has a length of 0, do not proceed (error handling) ld a, c and a ret z call GetEmote2bpp ret INCLUDE "data/sprites/emotes.asm" INCLUDE "data/sprites/sprite_mons.asm" INCLUDE "data/maps/outdoor_sprites.asm" INCLUDE "data/sprites/sprites.asm"
; A245524: a(n) = n^2 - floor(n/2)*(-1)^n. ; 1,3,10,14,27,33,52,60,85,95,126,138,175,189,232,248,297,315,370,390,451,473,540,564,637,663,742,770,855,885,976,1008,1105,1139,1242,1278,1387,1425,1540,1580,1701,1743,1870,1914,2047,2093,2232,2280,2425,2475,2626,2678,2835,2889,3052,3108,3277,3335,3510,3570,3751,3813,4000,4064,4257,4323,4522,4590,4795,4865,5076,5148,5365,5439,5662,5738,5967,6045,6280,6360,6601,6683,6930,7014,7267,7353,7612,7700,7965,8055,8326,8418,8695,8789,9072,9168,9457,9555,9850,9950,10251,10353,10660,10764,11077,11183,11502,11610,11935,12045,12376,12488,12825,12939,13282,13398,13747,13865,14220,14340,14701,14823,15190,15314,15687,15813,16192,16320,16705,16835,17226,17358,17755,17889,18292,18428,18837,18975,19390,19530,19951,20093,20520,20664,21097,21243,21682,21830,22275,22425,22876,23028,23485,23639,24102,24258,24727,24885,25360,25520,26001,26163,26650,26814,27307,27473,27972,28140,28645,28815,29326,29498,30015,30189,30712,30888,31417,31595,32130,32310,32851,33033,33580,33764,34317,34503,35062,35250,35815,36005,36576,36768,37345,37539,38122,38318,38907,39105,39700,39900,40501,40703,41310,41514,42127,42333,42952,43160,43785,43995,44626,44838,45475,45689,46332,46548,47197,47415,48070,48290,48951,49173,49840,50064,50737,50963,51642,51870,52555,52785,53476,53708,54405,54639,55342,55578,56287,56525,57240,57480,58201,58443,59170,59414,60147,60393,61132,61380,62125,62375 mov $1,$0 add $1,$0 div $0,2 add $1,1 mul $0,$1 add $1,$0
; ; TI Gray Library Functions ; ; Written by Stefano Bodrato - Mar 2001 ; ; ; $Id: g_plot.asm,v 1.5 2017/01/02 22:57:58 aralbrec Exp $ ; ;Usage: g_plot(int x, int y, int GrayLevel) PUBLIC g_plot PUBLIC _g_plot EXTERN plotpixel EXTERN respixel EXTERN graypage .g_plot ._g_plot ld ix,0 add ix,sp ld a,(ix+2) ;GrayLevel ld l,(ix+4) ;y ld h,(ix+6) ;x push af xor a call graypage pop af rra jr nc,set1 push af push hl call respixel pop hl pop af jr page2 .set1 push af push hl call plotpixel pop hl pop af .page2 push af ld a,1 call graypage pop af rra jp nc,plotpixel jp respixel
; Compatibility for the old balloc library MODULE ba_Init SECTION code_alloc_balloc PUBLIC ba_Init PUBLIC _ba_Init ; Clears all memory queues to empty. ; ; enter: HL = number of queues ; uses : F,BC,DE,HL ba_Init: _ba_Init: add hl,hl ld c,l ld b,h ld hl,_ba_qtbl ld de,_ba_qtbl + 1 ld (hl),0 dec bc ldir ret SECTION data_alloc_balloc PUBLIC __balloc_array EXTERN _ba_qtbl __balloc_array: defw _ba_qtbl
@Icecube's fix to properly display weapon range on the stats menu @Paste at 16CC0 .thumb .org 0xA240 Function1: .org 0x16CC0 @r0 has item id/uses short push {r4-r7,r14} mov r7,#0x0 mov r1,#0xFF and r0,r1 lsl r1,r0,#0x3 add r1,r1,r0 lsl r1,r1,#0x2 ldr r0,ItemTable add r1,r1,r0 ldrb r6,[r1,#0x19] ldr r0,BlankTextID @actually 3 spaces, not blank, but blank for our purposes cmp r6,#0x0 beq GotoFunction1 cmp r6,#0xFF bne NotTotal sub r0,#0x1 @'Total' text id 52A GotoFunction1: mov r7,#0x1 @set flag b NotMagOver2 NotTotal: lsl r5,r6,#0x1C lsr r5,r5,#0x1C cmp r5,#0x0 bne NotMagOver2 sub r0,#0x9 @'MP/2' text id 522 mov r7,#0x1 @set flag NotMagOver2: bl Function1 @takes r0=text id as an argument, returns ram pointer to modify cmp r7,#0x1 @is flag set beq End lsr r4,r6,#0x4 @r4 has min, r5 has max cmp r5,r4 bne DiffMinMax mov r1,#0x0 strb r1,[r0,#0x6] mov r1,#0x1F strb r1,[r0,#0x5] mov r1,#0x7F strb r1,[r0,#0x2] mov r1,#0x20 strb r1,[r0] strb r1,[r0,#0x1] strb r1,[r0,#0x2] cmp r4,#0xA blt NotDoubleDigits sub r4,#0xA mov r1,#0x31 NotDoubleDigits: add r4,#0x30 strb r1,[r0,#0x3] strb r4,[r0,#0x4] b End @<space> <space> <space> <tens digit> <ones digit> <(I think this means 'ignore this character')> <terminator> DiffMinMax: mov r1,#0x0 strb r1,[r0,#0x5] mov r1,#0x7F strb r1,[r0,#0x2] cmp r4,#0xA blt MinNotDoubleDigits sub r4,#0xA mov r1,#0x31 strb r1,[r0] @if tens digit is not there, 0x20 is already written, so we are ok MinNotDoubleDigits: add r4,#0x30 strb r4,[r0,#0x1] mov r1,#0x1F add r5,#0x30 cmp r5,#0x3A blt MaxNotDoubleDigits sub r5,#0xA mov r1,r5 mov r5,#0x31 MaxNotDoubleDigits: strb r5,[r0,#0x3] strb r1,[r0,#0x4] @<min tens digit> <min ones digit> <dash> <max tens digit> <max ones digit> <terminator> (if max doesn't have a tens digit, write the ones digit there and 1F to 0x4) End: pop {r4-r7} pop {r1} bx r1 .align BlankTextID: .long 0x0000052B ItemTable: @.long 0x08B09B10
_main: ;test.c,2 :: void main() ;test.c,4 :: PORTB=0x00; CLRF PORTB+0 ;test.c,5 :: TRISC.RC6 = 0x00; //TX pin set as output BCF TRISC+0, 6 ;test.c,6 :: TRISC.RC7 = 0xFF; //RX pin set as input BSF TRISC+0, 7 ;test.c,7 :: UART1_Init(4800); // Initialize UART module at 9600 bps MOVLW 51 MOVWF SPBRG+0 BSF TXSTA+0, 2, 0 CALL _UART1_Init+0, 0 ;test.c,8 :: Delay_ms(1000); // Wait for UART module to stabilize MOVLW 6 MOVWF R11, 0 MOVLW 19 MOVWF R12, 0 MOVLW 173 MOVWF R13, 0 L_main0: DECFSZ R13, 1, 1 BRA L_main0 DECFSZ R12, 1, 1 BRA L_main0 DECFSZ R11, 1, 1 BRA L_main0 NOP NOP ;test.c,11 :: while (1) { // Endless loop L_main1: ;test.c,14 :: UART1_Write(output); // sends back text MOVF _output+0, 0 MOVWF FARG_UART1_Write_data_+0 CALL _UART1_Write+0, 0 ;test.c,15 :: Delay_ms(1000); MOVLW 6 MOVWF R11, 0 MOVLW 19 MOVWF R12, 0 MOVLW 173 MOVWF R13, 0 L_main3: DECFSZ R13, 1, 1 BRA L_main3 DECFSZ R12, 1, 1 BRA L_main3 DECFSZ R11, 1, 1 BRA L_main3 NOP NOP ;test.c,40 :: } GOTO L_main1 ;test.c,41 :: } GOTO $+0 ; end of _main
/**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "mainwindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mainwindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.7.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_MainWindow_t { QByteArrayData data[6]; char stringdata0[68]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = { { QT_MOC_LITERAL(0, 0, 10), // "MainWindow" QT_MOC_LITERAL(1, 11, 12), // "waitASecound" QT_MOC_LITERAL(2, 24, 0), // "" QT_MOC_LITERAL(3, 25, 19), // "activateShapewindow" QT_MOC_LITERAL(4, 45, 12), // "onStartTimer" QT_MOC_LITERAL(5, 58, 9) // "showshape" }, "MainWindow\0waitASecound\0\0activateShapewindow\0" "onStartTimer\0showshape" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_MainWindow[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 2, // signalCount // signals: name, argc, parameters, tag, flags 1, 0, 34, 2, 0x06 /* Public */, 3, 0, 35, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags 4, 0, 36, 2, 0x0a /* Public */, 5, 0, 37, 2, 0x0a /* Public */, // signals: parameters QMetaType::Void, QMetaType::Void, // slots: parameters QMetaType::Void, QMetaType::Void, 0 // eod }; void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { MainWindow *_t = static_cast<MainWindow *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->waitASecound(); break; case 1: _t->activateShapewindow(); break; case 2: _t->onStartTimer(); break; case 3: _t->showshape(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); void **func = reinterpret_cast<void **>(_a[1]); { typedef void (MainWindow::*_t)(); if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&MainWindow::waitASecound)) { *result = 0; return; } } { typedef void (MainWindow::*_t)(); if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&MainWindow::activateShapewindow)) { *result = 1; return; } } } Q_UNUSED(_a); } const QMetaObject MainWindow::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_MainWindow.data, qt_meta_data_MainWindow, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *MainWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MainWindow::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0)) return static_cast<void*>(const_cast< MainWindow*>(this)); return QWidget::qt_metacast(_clname); } int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 4) qt_static_metacall(this, _c, _id, _a); _id -= 4; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 4) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 4; } return _id; } // SIGNAL 0 void MainWindow::waitASecound() { QMetaObject::activate(this, &staticMetaObject, 0, Q_NULLPTR); } // SIGNAL 1 void MainWindow::activateShapewindow() { QMetaObject::activate(this, &staticMetaObject, 1, Q_NULLPTR); } QT_END_MOC_NAMESPACE
; A198395: Ceiling(n*sqrt(17)). ; 0,5,9,13,17,21,25,29,33,38,42,46,50,54,58,62,66,71,75,79,83,87,91,95,99,104,108,112,116,120,124,128,132,137,141,145,149,153,157,161,165,170,174,178,182,186,190,194,198,203,207,211,215,219,223,227,231,236,240,244,248,252,256,260,264,269,273,277,281,285,289,293,297,301,306,310,314,318,322,326,330,334,339,343,347,351,355,359,363,367,372,376,380,384,388,392,396,400,405,409,413,417,421,425,429,433,438,442,446,450,454,458,462,466,471,475,479,483,487,491,495,499,504,508,512,516,520,524,528,532,537,541,545,549,553,557,561,565,569,574,578,582,586,590,594,598,602,607,611,615,619,623,627,631,635,640,644,648,652,656,660,664,668,673,677,681,685,689,693,697,701,706,710,714,718,722,726,730,734,739,743,747,751,755,759,763,767,772,776,780,784,788,792,796,800,805,809,813,817,821,825,829,833,837,842,846,850,854,858,862,866,870,875,879,883,887,891,895,899,903,908,912,916,920,924,928,932,936,941,945,949,953,957,961,965,969,974,978,982,986,990,994,998,1002,1007,1011,1015,1019,1023,1027 mul $0,2 mov $1,$0 mov $3,$0 mul $0,2 mul $1,2 mov $2,1 lpb $2,1 mul $1,$0 add $2,$3 mov $4,1 lpb $1,1 trn $1,$2 add $2,2 lpe lpb $4,1 mov $1,$2 trn $4,$2 lpe mov $2,0 lpe div $1,2
#include "../.././Image/VideoIO/AviStream.hh"
; A130216: a(0) = 3; a(n) = a(n-1) + (number of multiples of 3 so far in the sequence). ; 3,4,5,6,8,10,12,15,19,23,27,32,37,42,48,55,62,69,77,85,93,102,112,122,132,143,154,165,177,190,203,216,230,244,258,273,289,305,321,338,355,372,390,409,428,447,467,487,507,528,550,572,594,617,640,663,687,712,737,762,788,814,840,867,895,923,951,980,1009,1038,1068,1099,1130,1161,1193,1225,1257,1290,1324,1358,1392,1427,1462,1497,1533,1570,1607,1644,1682,1720,1758,1797,1837,1877,1917,1958,1999,2040,2082,2125,2168,2211,2255,2299,2343,2388,2434,2480,2526,2573,2620,2667,2715,2764,2813,2862,2912,2962,3012,3063,3115,3167,3219,3272,3325,3378,3432,3487,3542,3597,3653,3709,3765,3822,3880,3938,3996,4055,4114,4173,4233,4294,4355,4416,4478,4540,4602,4665,4729,4793,4857,4922,4987,5052,5118,5185,5252,5319,5387,5455,5523,5592,5662,5732,5802,5873,5944,6015,6087,6160,6233,6306,6380,6454,6528,6603,6679,6755,6831,6908,6985,7062,7140,7219,7298,7377,7457,7537,7617,7698,7780,7862,7944,8027,8110,8193,8277,8362,8447,8532,8618,8704,8790,8877,8965,9053,9141,9230,9319,9408,9498,9589,9680,9771,9863,9955,10047,10140,10234,10328,10422,10517,10612,10707,10803,10900,10997,11094,11192,11290,11388,11487,11587,11687,11787,11888,11989,12090,12192,12295,12398,12501,12605,12709,12813,12918,13024,13130,13236,13343 lpb $0,1 add $1,$0 trn $0,3 add $1,$0 trn $0,3 add $1,$0 trn $0,1 lpe add $1,3
kp_song kp_reloc dc.w kp_song_registers dc.w kp_speed dc.w kp_grooveboxpos dc.w kp_grooveboxlen dc.w kp_groovebox dc.w kp_patternlen dc.w kp_patternmap_lo dc.w kp_patternmap_hi dc.w kp_insmap_lo dc.w kp_insmap_hi dc.w kp_volmap_lo dc.w kp_volmap_hi dc.w kp_sequence kp_song_registers kp_speed dc.b $02 kp_grooveboxpos dc.b $00 kp_grooveboxlen dc.b $04 kp_groovebox dc.b $04 dc.b $05 dc.b $07 dc.b $04 dc.b $05 dc.b $04 dc.b $06 dc.b $05 kp_patternlen dc.b $1F kp_patternmap_lo dc.b #<patnil dc.b #<pat1 dc.b #<pat2 dc.b #<pat3 dc.b #<pat4 dc.b #<pat5 dc.b #<pat6 dc.b #<pat7 dc.b #<pat8 dc.b #<pat9 dc.b #<pat10 dc.b #<pat11 dc.b #<pat12 dc.b #<pat13 kp_patternmap_hi dc.b #>patnil dc.b #>pat1 dc.b #>pat2 dc.b #>pat3 dc.b #>pat4 dc.b #>pat5 dc.b #>pat6 dc.b #>pat7 dc.b #>pat8 dc.b #>pat9 dc.b #>pat10 dc.b #>pat11 dc.b #>pat12 dc.b #>pat13 patnil kp_setinstrument 8,0 kp_settrackregister 0,16 kp_rewind $00 pat1 pat1loop kp_settrackregister $01,$9C kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_setinstrument $02,$01 kp_rewind [pat1loop-pat1] pat2 pat2loop kp_settrackregister $01,$98 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$90 kp_setinstrument $02,$01 kp_rewind [pat2loop-pat2] pat3 pat3loop kp_settrackregister $01,$98 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$7C kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_setinstrument $02,$01 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$AC kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$88 kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$0F kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_settrackregister $01,$98 kp_settrackregister $03,$09 kp_setinstrument $02,$01 kp_settrackregister $01,$9C kp_setinstrument $02,$01 kp_rewind [pat3loop-pat3] pat4 pat4loop kp_settrackregister $03,$0F kp_settrackregister $00,$0C kp_settrackregister $01,$00 kp_setinstrument $0C,$02 kp_setinstrument $08,$02 kp_rewind [pat4loop-pat4] pat5 pat5loop kp_settrackregister $00,$0C kp_settrackregister $01,$0C kp_settrackregister $03,$0F kp_setinstrument $0C,$02 kp_setinstrument $08,$02 kp_rewind [pat5loop-pat5] pat6 pat6loop kp_settrackregister $00,$0C kp_settrackregister $01,$1C kp_setinstrument $0C,$02 kp_settrackregister $01,$28 kp_setinstrument $08,$02 kp_rewind [pat6loop-pat6] pat7 pat7loop kp_settrackregister $00,$0E kp_settrackregister $03,$04 kp_setinstrument $02,$03 kp_setinstrument $02,$04 kp_settrackregister $03,$06 kp_setinstrument $02,$03 kp_setinstrument $02,$04 kp_settrackregister $03,$08 kp_setinstrument $02,$03 kp_setinstrument $02,$04 kp_settrackregister $03,$0A kp_setinstrument $02,$03 kp_setinstrument $02,$04 kp_settrackregister $03,$0C kp_setinstrument $02,$03 kp_setinstrument $00,$04 kp_rewind [pat7loop-pat7] pat8 pat8loop kp_settrackregister $03,$0F kp_setinstrument $04,$05 kp_setinstrument $04,$06 kp_setinstrument $04,$04 kp_setinstrument $06,$03 kp_setinstrument $02,$03 kp_setinstrument $04,$05 kp_setinstrument $06,$03 kp_setinstrument $02,$03 kp_rewind [pat8loop-pat8] pat9 pat9loop kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_settrackregister $03,$0A kp_setinstrument $02,$04 kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_setinstrument $04,$04 kp_setinstrument $02,$04 kp_setinstrument $02,$03 kp_settrackregister $03,$0A kp_setinstrument $04,$04 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$0F kp_setinstrument $04,$05 kp_setinstrument $02,$03 kp_setinstrument $02,$05 kp_setinstrument $04,$07 kp_rewind [pat9loop-pat9] pat10 pat10loop kp_setinstrument $02,$05 kp_setinstrument $04,$04 kp_setinstrument $02,$04 kp_setinstrument $04,$03 kp_setinstrument $06,$03 kp_setinstrument $02,$04 kp_setinstrument $02,$05 kp_setinstrument $02,$06 kp_setinstrument $04,$03 kp_setinstrument $02,$05 kp_setinstrument $02,$04 kp_rewind [pat10loop-pat10] pat11 pat11loop kp_setinstrument $04,$05 kp_setinstrument $02,$05 kp_setinstrument $02,$04 kp_setinstrument $04,$03 kp_settrackregister $03,$0C kp_setinstrument $02,$07 kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_setinstrument $02,$04 kp_setinstrument $02,$03 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_setinstrument $02,$06 kp_setinstrument $02,$03 kp_setinstrument $02,$05 kp_setinstrument $02,$06 kp_rewind [pat11loop-pat11] pat12 pat12loop kp_settrackregister $01,$00 kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_settrackregister $03,$0A kp_setinstrument $02,$06 kp_settrackregister $03,$0F kp_setinstrument $04,$06 kp_setinstrument $02,$03 kp_settrackregister $03,$0A kp_setinstrument $02,$06 kp_settrackregister $03,$0F kp_setinstrument $02,$06 kp_setinstrument $02,$05 kp_settrackregister $03,$0A kp_setinstrument $04,$06 kp_settrackregister $03,$0F kp_setinstrument $02,$06 kp_settrackregister $03,$0A kp_setinstrument $02,$06 kp_settrackregister $03,$0F kp_setinstrument $02,$03 kp_settrackregister $03,$0A kp_setinstrument $02,$06 kp_setinstrument $02,$06 kp_settrackregister $03,$0B kp_setinstrument $02,$05 kp_rewind [pat12loop-pat12] pat13 pat13loop kp_settrackregister $03,$0F kp_setinstrument $02,$05 kp_setinstrument $02,$06 kp_setinstrument $04,$05 kp_setinstrument $02,$03 kp_settrackregister $03,$0C kp_setinstrument $02,$06 kp_settrackregister $03,$0F kp_setinstrument $02,$06 kp_setinstrument $04,$05 kp_setinstrument $02,$05 kp_setinstrument $02,$06 kp_setinstrument $02,$05 kp_settrackregister $03,$0C kp_setinstrument $02,$06 kp_settrackregister $03,$0F kp_setinstrument $02,$06 kp_setinstrument $02,$03 kp_settrackregister $03,$0B kp_setinstrument $02,$05 kp_rewind [pat13loop-pat13] kp_insmap_lo dc.b #<insnil dc.b #<ins1 dc.b #<ins2 dc.b #<ins3 dc.b #<ins4 dc.b #<ins5 dc.b #<ins6 dc.b #<ins7 kp_insmap_hi dc.b #>insnil dc.b #>ins1 dc.b #>ins2 dc.b #>ins3 dc.b #>ins4 dc.b #>ins5 dc.b #>ins6 dc.b #>ins7 kp_volmap_lo dc.b #<volnil dc.b #<vol1 dc.b #<vol2 dc.b #<vol3 dc.b #<vol4 dc.b #<vol5 dc.b #<vol6 dc.b #<vol7 kp_volmap_hi dc.b #>volnil dc.b #>vol1 dc.b #>vol2 dc.b #>vol3 dc.b #>vol4 dc.b #>vol5 dc.b #>vol6 dc.b #>vol7 insnil KP_OSCV 0,0,0,0,15 KP_OSCJ 0 volnil KP_VOLV 0,15 KP_VOLJ 0 ins1 KP_OSCV $90,0,1,0,$00 ins1loop KP_OSCV $01,0,1,1,$00 KP_OSCV $00,0,1,1,$02 KP_OSCJ [ins1loop-ins1] vol1 KP_VOLV $0A,$00 KP_VOLV $0E,$00 KP_VOLV $0A,$00 KP_VOLV $07,$00 KP_VOLV $04,$00 KP_VOLV $03,$00 vol1loop KP_VOLV $02,$00 KP_VOLJ [vol1loop-vol1] ins2 ins2loop KP_OSCV $00,0,1,1,$01 KP_OSCV $01,0,1,1,$01 KP_OSCV $02,0,1,1,$01 KP_OSCV $01,0,1,1,$01 KP_OSCV $00,0,1,1,$01 KP_OSCJ [ins2loop-ins2] vol2 KP_VOLV $07,$05 KP_VOLV $08,$04 KP_VOLV $07,$01 KP_VOLV $06,$09 KP_VOLV $05,$0F KP_VOLV $05,$02 KP_VOLV $04,$09 KP_VOLV $03,$08 KP_VOLV $02,$08 KP_VOLV $01,$04 vol2loop KP_VOLV $00,$00 KP_VOLJ [vol2loop-vol2] ins3 KP_OSCV $F4,1,0,0,$00 KP_OSCV $60,0,1,0,$00 KP_OSCV $EF,1,0,0,$00 KP_OSCV $F2,1,0,0,$00 KP_OSCV $FC,1,0,0,$00 KP_OSCV $FA,1,0,0,$00 KP_OSCV $F8,1,0,0,$00 ins3loop KP_OSCV $FA,1,0,0,$00 KP_OSCJ [ins3loop-ins3] vol3 KP_VOLV $0F,$00 KP_VOLV $0E,$02 KP_VOLV $08,$00 KP_VOLV $06,$00 KP_VOLV $04,$00 KP_VOLV $02,$00 vol3loop KP_VOLV $01,$00 KP_VOLJ [vol3loop-vol3] ins4 KP_OSCV $FC,1,0,0,$00 KP_OSCV $3C,0,1,0,$00 KP_OSCV $FA,1,0,0,$00 KP_OSCV $FC,1,0,0,$00 KP_OSCV $FD,1,0,0,$00 KP_OSCV $F8,1,0,0,$00 ins4loop KP_OSCV $FA,1,0,0,$00 KP_OSCJ [ins4loop-ins4] vol4 KP_VOLV $0E,$00 KP_VOLV $0C,$00 KP_VOLV $0A,$00 KP_VOLV $06,$00 KP_VOLV $04,$00 vol4loop KP_VOLV $01,$03 KP_VOLJ [vol4loop-vol4] ins5 KP_OSCV $18,0,1,0,$00 KP_OSCV $0E,0,1,0,$00 KP_OSCV $0A,0,1,0,$00 KP_OSCV $05,0,1,0,$00 ins5loop KP_OSCV $00,0,1,0,$00 KP_OSCV $00,1,0,0,$00 KP_OSCJ [ins5loop-ins5] vol5 KP_VOLV $0C,$00 KP_VOLV $0A,$00 KP_VOLV $09,$00 KP_VOLV $08,$00 KP_VOLV $07,$00 KP_VOLV $06,$00 KP_VOLV $05,$00 KP_VOLV $04,$00 KP_VOLV $03,$00 vol5loop KP_VOLV $00,$00 KP_VOLJ [vol5loop-vol5] ins6 KP_OSCV $F9,1,0,0,$00 ins6loop KP_OSCV $E2,1,0,0,$00 KP_OSCJ [ins6loop-ins6] vol6 KP_VOLV $0C,$00 KP_VOLV $04,$00 vol6loop KP_VOLV $00,$00 KP_VOLJ [vol6loop-vol6] ins7 KP_OSCV $F2,1,0,0,$00 KP_OSCV $38,0,1,0,$00 KP_OSCV $F1,1,0,0,$00 KP_OSCV $F2,1,0,0,$00 KP_OSCV $F4,1,0,0,$00 ins7loop KP_OSCV $FC,1,0,0,$01 KP_OSCJ [ins7loop-ins7] vol7 vol7loop KP_VOLV $0E,$01 KP_VOLV $04,$00 KP_VOLV $02,$00 KP_VOLV $01,$01 KP_VOLV $00,$02 KP_VOLV $0E,$00 KP_VOLV $04,$00 KP_VOLV $02,$00 KP_VOLV $01,$01 KP_VOLV $00,$01 KP_VOLJ [vol7loop-vol7] kp_sequence dc.b $00,$01,$00,$00 dc.b $00,$02,$00,$00 dc.b $00,$01,$00,$00 dc.b $00,$03,$00,$00 dc.b $00,$01,$04,$00 dc.b $00,$02,$04,$00 dc.b $00,$01,$05,$00 dc.b $00,$03,$06,$07 dc.b $00,$01,$04,$08 dc.b $00,$02,$04,$09 dc.b $00,$01,$05,$0A dc.b $00,$03,$06,$0B dc.b $00,$01,$04,$08 dc.b $00,$02,$04,$09 dc.b $00,$01,$05,$0A dc.b $00,$03,$06,$0B dc.b $00,$01,$04,$0C dc.b $00,$02,$04,$0C dc.b $00,$01,$05,$0C dc.b $00,$03,$06,$0D dc.b $ff dc.w $0010
; size_t fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream) INCLUDE "config_private.inc" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _fwrite EXTERN asm_fwrite _fwrite: pop af pop hl pop bc pop de pop ix push hl push de push bc push hl push af jp asm_fwrite ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _fwrite EXTERN _fwrite_unlocked defc _fwrite = _fwrite_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Pokémon traded from RBY do not have held items, so GSC usually interprets the ; catch rate as an item. However, if the catch rate appears in this table, the ; item associated with the table entry is used instead. TimeCapsule_CatchRateItems: db ITEM_5A, BERRY db ITEM_64, BERRY db ITEM_78, BERRY db ITEM_87, BERRY db ITEM_BE, BERRY db ITEM_C3, BERRY db ITEM_DC, BERRY db ITEM_FA, BERRY db -1, BERRY db 0 ; end
.global s_prepare_buffers s_prepare_buffers: push %r12 push %rax push %rcx push %rdi lea addresses_D_ht+0x19cfa, %r12 clflush (%r12) nop nop sub %rax, %rax mov $0x6162636465666768, %rcx movq %rcx, %xmm1 movups %xmm1, (%r12) nop nop nop nop nop add $46606, %rdi pop %rdi pop %rcx pop %rax pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r8 push %rbp push %rdx push %rsi // Store lea addresses_normal+0x1513a, %r13 nop nop nop nop xor %r15, %r15 movw $0x5152, (%r13) nop nop nop cmp %r11, %r11 // Store lea addresses_RW+0x1d201, %r13 nop nop and $36523, %rdx mov $0x5152535455565758, %r15 movq %r15, %xmm4 vmovups %ymm4, (%r13) nop and %r8, %r8 // Store lea addresses_UC+0x5fca, %r8 nop nop xor %rdx, %rdx movw $0x5152, (%r8) nop nop dec %r13 // Faulty Load mov $0x3910b3000000013a, %rbp nop nop nop nop cmp %rsi, %rsi mov (%rbp), %r8 lea oracles, %r13 and $0xff, %r8 shlq $12, %r8 mov (%r13,%r8,1), %r8 pop %rsi pop %rdx pop %rbp pop %r8 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_NC', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_NC', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 21762, '52': 67} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Vladimír Vondruš <mosra@centrum.cz> 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 "MeshData.h" #include <Corrade/Utility/Algorithms.h> #ifndef CORRADE_NO_ASSERT #include <Corrade/Utility/Format.h> #endif #include "Magnum/Math/Color.h" #include "Magnum/Math/PackingBatch.h" #include "Magnum/Trade/Implementation/arrayUtilities.h" namespace Magnum { namespace Trade { MeshIndexData::MeshIndexData(const MeshIndexType type, const Containers::ArrayView<const void> data) noexcept: _type{type}, _data{data} { /* Yes, this calls into a constexpr function defined in the header -- because I feel that makes more sense than duplicating the full assert logic */ CORRADE_ASSERT(data.size()%meshIndexTypeSize(type) == 0, "Trade::MeshIndexData: view size" << data.size() << "does not correspond to" << type, ); } MeshIndexData::MeshIndexData(const Containers::StridedArrayView2D<const char>& data) noexcept { /* Second dimension being zero indicates a non-indexed mesh */ if(data.size()[1] == 0) { _type = MeshIndexType{}; return; } if(data.size()[1] == 4) _type = MeshIndexType::UnsignedInt; else if(data.size()[1] == 2) _type = MeshIndexType::UnsignedShort; else if(data.size()[1] == 1) _type = MeshIndexType::UnsignedByte; else CORRADE_ASSERT_UNREACHABLE("Trade::MeshIndexData: expected index type size 1, 2 or 4 but got" << data.size()[1], ); CORRADE_ASSERT(data.isContiguous(), "Trade::MeshIndexData: view is not contiguous", ); _data = data.asContiguous(); } MeshAttributeData::MeshAttributeData(const MeshAttribute name, const VertexFormat format, const Containers::StridedArrayView1D<const void>& data, UnsignedShort arraySize) noexcept: MeshAttributeData{nullptr, name, format, data, arraySize} { /* Yes, this calls into a constexpr function defined in the header -- because I feel that makes more sense than duplicating the full assert logic */ /** @todo support zero / negative stride? would be hard to transfer to GL */ CORRADE_ASSERT(data.empty() || isVertexFormatImplementationSpecific(format) || std::ptrdiff_t(vertexFormatSize(format))*(arraySize ? arraySize : 1) <= data.stride(), "Trade::MeshAttributeData: expected stride to be positive and enough to fit" << format << Debug::nospace << (arraySize ? Utility::format("[{}]", arraySize).data() : "") << Debug::nospace << ", got" << data.stride(), ); } MeshAttributeData::MeshAttributeData(const MeshAttribute name, const VertexFormat format, const Containers::StridedArrayView2D<const char>& data, UnsignedShort arraySize) noexcept: MeshAttributeData{nullptr, name, format, Containers::StridedArrayView1D<const void>{{data.data(), ~std::size_t{}}, data.size()[0], data.stride()[0]}, arraySize} { /* Yes, this calls into a constexpr function defined in the header -- because I feel that makes more sense than duplicating the full assert logic */ #ifndef CORRADE_NO_ASSERT if(arraySize) CORRADE_ASSERT(data.empty()[0] || isVertexFormatImplementationSpecific(format) || data.size()[1] == vertexFormatSize(format)*arraySize, "Trade::MeshAttributeData: second view dimension size" << data.size()[1] << "doesn't match" << format << "and array size" << arraySize, ); else CORRADE_ASSERT(data.empty()[0] || isVertexFormatImplementationSpecific(format) || data.size()[1] == vertexFormatSize(format), "Trade::MeshAttributeData: second view dimension size" << data.size()[1] << "doesn't match" << format, ); #endif CORRADE_ASSERT(data.isContiguous<1>(), "Trade::MeshAttributeData: second view dimension is not contiguous", ); } Containers::Array<MeshAttributeData> meshAttributeDataNonOwningArray(const Containers::ArrayView<const MeshAttributeData> view) { /* Ugly, eh? */ return Containers::Array<MeshAttributeData>{const_cast<MeshAttributeData*>(view.data()), view.size(), reinterpret_cast<void(*)(MeshAttributeData*, std::size_t)>(Implementation::nonOwnedArrayDeleter)}; } MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& indexData, const MeshIndexData& indices, Containers::Array<char>&& vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: _primitive{primitive}, _indexType{indices._type}, _indexDataFlags{DataFlag::Owned|DataFlag::Mutable}, _vertexDataFlags{DataFlag::Owned|DataFlag::Mutable}, _importerState{importerState}, _indices{static_cast<const char*>(indices._data.data())}, _attributes{std::move(attributes)}, _indexData{std::move(indexData)}, _vertexData{std::move(vertexData)} { /* Save index count, only if the indices are actually specified */ if(_indexType != MeshIndexType{}) _indexCount = UnsignedInt(indices._data.size()/meshIndexTypeSize(indices._type)); else _indexCount = 0; /* Save vertex count. If it's passed explicitly, use that (but still check that all attributes have the same vertex count for safety), otherwise expect at least one attribute */ #ifndef CORRADE_NO_ASSERT UnsignedInt expectedAttributeVertexCount; #endif if(_attributes.empty()) { CORRADE_ASSERT(vertexCount != ImplicitVertexCount, "Trade::MeshData: vertex count can't be implicit if there are no attributes", ); _vertexCount = vertexCount; /* No attributes, so we won't be checking anything */ } else if(vertexCount != ImplicitVertexCount) { _vertexCount = vertexCount; #ifndef CORRADE_NO_ASSERT expectedAttributeVertexCount = _attributes[0]._vertexCount; #endif } else { _vertexCount = _attributes[0]._vertexCount; #ifndef CORRADE_NO_ASSERT expectedAttributeVertexCount = _vertexCount; #endif } CORRADE_ASSERT(_indexCount || _indexData.empty(), "Trade::MeshData: indexData passed for a non-indexed mesh", ); CORRADE_ASSERT(!_indices || (_indices >= _indexData.begin() && _indices + indices._data.size() <= _indexData.end()), "Trade::MeshData: indices [" << Debug::nospace << static_cast<const void*>(_indices) << Debug::nospace << ":" << Debug::nospace << static_cast<const void*>(_indices + indices._data.size()) << Debug::nospace << "] are not contained in passed indexData array [" << Debug::nospace << static_cast<const void*>(_indexData.begin()) << Debug::nospace << ":" << Debug::nospace << static_cast<const void*>(_indexData.end()) << Debug::nospace << "]", ); #ifndef CORRADE_NO_ASSERT /* Not checking what's already checked in MeshIndexData / MeshAttributeData constructors */ for(std::size_t i = 0; i != _attributes.size(); ++i) { const MeshAttributeData& attribute = _attributes[i]; CORRADE_ASSERT(attribute._format != VertexFormat{}, "Trade::MeshData: attribute" << i << "doesn't specify anything", ); CORRADE_ASSERT(attribute._vertexCount == expectedAttributeVertexCount, "Trade::MeshData: attribute" << i << "has" << attribute._vertexCount << "vertices but" << expectedAttributeVertexCount << "expected", ); /* Check that the view fits into the provided vertex data array. For implementation-specific formats we don't know the size so use 0 to check at least partially. */ const UnsignedInt typeSize = isVertexFormatImplementationSpecific(attribute._format) ? 0 : vertexFormatSize(attribute._format); if(attribute._isOffsetOnly) { const std::size_t size = attribute._data.offset + (_vertexCount - 1)*attribute._stride + typeSize; CORRADE_ASSERT(!_vertexCount || size <= _vertexData.size(), "Trade::MeshData: offset attribute" << i << "spans" << size << "bytes but passed vertexData array has only" << _vertexData.size(), ); } else { const void* const begin = static_cast<const char*>(attribute._data.pointer); const void* const end = static_cast<const char*>(attribute._data.pointer) + (_vertexCount - 1)*attribute._stride + typeSize; CORRADE_ASSERT(!_vertexCount || (begin >= _vertexData.begin() && end <= _vertexData.end()), "Trade::MeshData: attribute" << i << "[" << Debug::nospace << begin << Debug::nospace << ":" << Debug::nospace << end << Debug::nospace << "] is not contained in passed vertexData array [" << Debug::nospace << static_cast<const void*>(_vertexData.begin()) << Debug::nospace << ":" << Debug::nospace << static_cast<const void*>(_vertexData.end()) << Debug::nospace << "]", ); } } #endif } MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& indexData, const MeshIndexData& indices, Containers::Array<char>&& vertexData, std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, std::move(indexData), indices, std::move(vertexData), Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, const DataFlags indexDataFlags, const Containers::ArrayView<const void> indexData, const MeshIndexData& indices, const DataFlags vertexDataFlags, const Containers::ArrayView<const void> vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(indexData.data())), indexData.size(), Implementation::nonOwnedArrayDeleter}, indices, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(vertexData.data())), vertexData.size(), Implementation::nonOwnedArrayDeleter}, std::move(attributes), vertexCount, importerState} { CORRADE_ASSERT(!(indexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned index data but" << indexDataFlags, ); CORRADE_ASSERT(!(vertexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned vertex data but" << vertexDataFlags, ); _indexDataFlags = indexDataFlags; _vertexDataFlags = vertexDataFlags; } MeshData::MeshData(const MeshPrimitive primitive, const DataFlags indexDataFlags, const Containers::ArrayView<const void> indexData, const MeshIndexData& indices, const DataFlags vertexDataFlags, const Containers::ArrayView<const void> vertexData, const std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, indexDataFlags, indexData, indices, vertexDataFlags, vertexData, Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, const DataFlags indexDataFlags, const Containers::ArrayView<const void> indexData, const MeshIndexData& indices, Containers::Array<char>&& vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(indexData.data())), indexData.size(), Implementation::nonOwnedArrayDeleter}, indices, std::move(vertexData), std::move(attributes), vertexCount, importerState} { CORRADE_ASSERT(!(indexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned index data but" << indexDataFlags, ); _indexDataFlags = indexDataFlags; } MeshData::MeshData(const MeshPrimitive primitive, const DataFlags indexDataFlags, const Containers::ArrayView<const void> indexData, const MeshIndexData& indices, Containers::Array<char>&& vertexData, const std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, indexDataFlags, indexData, indices, std::move(vertexData), Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& indexData, const MeshIndexData& indices, const DataFlags vertexDataFlags, Containers::ArrayView<const void> vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, std::move(indexData), indices, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(vertexData.data())), vertexData.size(), Implementation::nonOwnedArrayDeleter}, std::move(attributes), vertexCount, importerState} { CORRADE_ASSERT(!(vertexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned vertex data but" << vertexDataFlags, ); _vertexDataFlags = vertexDataFlags; } MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& indexData, const MeshIndexData& indices, const DataFlags vertexDataFlags, const Containers::ArrayView<const void> vertexData, const std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, std::move(indexData), indices, vertexDataFlags, vertexData, Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, {}, MeshIndexData{}, std::move(vertexData), std::move(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& vertexData, const std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, std::move(vertexData), Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, const DataFlags vertexDataFlags, Containers::ArrayView<const void> vertexData, Containers::Array<MeshAttributeData>&& attributes, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(vertexData.data())), vertexData.size(), Implementation::nonOwnedArrayDeleter}, std::move(attributes), vertexCount, importerState} { CORRADE_ASSERT(!(vertexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned vertex data but" << vertexDataFlags, ); _vertexDataFlags = vertexDataFlags; } MeshData::MeshData(const MeshPrimitive primitive, const DataFlags vertexDataFlags, Containers::ArrayView<const void> vertexData, std::initializer_list<MeshAttributeData> attributes, const UnsignedInt vertexCount, const void* const importerState): MeshData{primitive, vertexDataFlags, vertexData, Implementation::initializerListToArrayWithDefaultDeleter(attributes), vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, Containers::Array<char>&& indexData, const MeshIndexData& indices, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, std::move(indexData), indices, {}, {}, vertexCount, importerState} {} MeshData::MeshData(const MeshPrimitive primitive, const DataFlags indexDataFlags, const Containers::ArrayView<const void> indexData, const MeshIndexData& indices, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, Containers::Array<char>{const_cast<char*>(static_cast<const char*>(indexData.data())), indexData.size(), Implementation::nonOwnedArrayDeleter}, indices, vertexCount, importerState} { CORRADE_ASSERT(!(indexDataFlags & DataFlag::Owned), "Trade::MeshData: can't construct with non-owned index data but" << indexDataFlags, ); _indexDataFlags = indexDataFlags; } MeshData::MeshData(const MeshPrimitive primitive, const UnsignedInt vertexCount, const void* const importerState) noexcept: MeshData{primitive, {}, MeshIndexData{}, {}, {}, vertexCount, importerState} {} MeshData::~MeshData() = default; MeshData::MeshData(MeshData&&) noexcept = default; MeshData& MeshData::operator=(MeshData&&) noexcept = default; Containers::ArrayView<char> MeshData::mutableIndexData() & { CORRADE_ASSERT(_indexDataFlags & DataFlag::Mutable, "Trade::MeshData::mutableIndexData(): index data not mutable", {}); return _indexData; } Containers::ArrayView<char> MeshData::mutableVertexData() & { CORRADE_ASSERT(_vertexDataFlags & DataFlag::Mutable, "Trade::MeshData::mutableVertexData(): vertex data not mutable", {}); return _vertexData; } UnsignedInt MeshData::indexCount() const { CORRADE_ASSERT(isIndexed(), "Trade::MeshData::indexCount(): the mesh is not indexed", {}); return _indexCount; } MeshIndexType MeshData::indexType() const { CORRADE_ASSERT(isIndexed(), "Trade::MeshData::indexType(): the mesh is not indexed", {}); return _indexType; } std::size_t MeshData::indexOffset() const { CORRADE_ASSERT(isIndexed(), "Trade::MeshData::indexOffset(): the mesh is not indexed", {}); return _indices - _indexData.data(); } Containers::StridedArrayView2D<const char> MeshData::indices() const { /* For a non-indexed mesh returning zero size in both dimensions, indexed mesh with zero indices sill has the second dimension non-zero */ if(!isIndexed()) return {}; const std::size_t indexTypeSize = meshIndexTypeSize(_indexType); /* Build a 2D view using information about attribute type size */ return {{_indices, _indexCount*indexTypeSize}, {_indexCount, indexTypeSize}}; } Containers::StridedArrayView2D<char> MeshData::mutableIndices() { CORRADE_ASSERT(_indexDataFlags & DataFlag::Mutable, "Trade::MeshData::mutableIndices(): index data not mutable", {}); /* For a non-indexed mesh returning zero size in both dimensions, indexed mesh with zero indices sill has the second dimension non-zero */ if(!isIndexed()) return {}; const std::size_t indexTypeSize = meshIndexTypeSize(_indexType); /* Build a 2D view using information about index type size */ Containers::StridedArrayView2D<const char> out{{_indices, _indexCount*indexTypeSize}, {_indexCount, indexTypeSize}}; /** @todo some arrayConstCast? UGH */ return Containers::StridedArrayView2D<char>{ /* The view size is there only for a size assert, we're pretty sure the view is valid */ {static_cast<char*>(const_cast<void*>(out.data())), ~std::size_t{}}, out.size(), out.stride()}; } MeshAttributeData MeshData::attributeData(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeData(): index" << id << "out of range for" << _attributes.size() << "attributes", MeshAttributeData{}); const MeshAttributeData& attribute = _attributes[id]; return MeshAttributeData{attribute._name, attribute._format, attributeDataViewInternal(attribute)}; } MeshAttribute MeshData::attributeName(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeName(): index" << id << "out of range for" << _attributes.size() << "attributes", {}); return _attributes[id]._name; } VertexFormat MeshData::attributeFormat(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeFormat(): index" << id << "out of range for" << _attributes.size() << "attributes", {}); return _attributes[id]._format; } std::size_t MeshData::attributeOffset(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeOffset(): index" << id << "out of range for" << _attributes.size() << "attributes", {}); return _attributes[id]._isOffsetOnly ? _attributes[id]._data.offset : static_cast<const char*>(_attributes[id]._data.pointer) - _vertexData.data(); } UnsignedInt MeshData::attributeStride(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeStride(): index" << id << "out of range for" << _attributes.size() << "attributes", {}); return _attributes[id]._stride; } UnsignedShort MeshData::attributeArraySize(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attributeArraySize(): index" << id << "out of range for" << _attributes.size() << "attributes", {}); return _attributes[id]._arraySize; } UnsignedInt MeshData::attributeCount(const MeshAttribute name) const { UnsignedInt count = 0; for(const MeshAttributeData& attribute: _attributes) if(attribute._name == name) ++count; return count; } UnsignedInt MeshData::attributeFor(const MeshAttribute name, UnsignedInt id) const { for(std::size_t i = 0; i != _attributes.size(); ++i) { if(_attributes[i]._name != name) continue; if(id-- == 0) return i; } #ifdef CORRADE_NO_ASSERT CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ #else return ~UnsignedInt{}; #endif } UnsignedInt MeshData::attributeId(const MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attributeId(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attributeId; } VertexFormat MeshData::attributeFormat(MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attributeFormat(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attributeFormat(attributeId); } std::size_t MeshData::attributeOffset(MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attributeOffset(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attributeOffset(attributeId); } UnsignedInt MeshData::attributeStride(MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attributeStride(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attributeStride(attributeId); } UnsignedShort MeshData::attributeArraySize(MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attributeArraySize(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attributeArraySize(attributeId); } Containers::StridedArrayView1D<const void> MeshData::attributeDataViewInternal(const MeshAttributeData& attribute) const { return Containers::StridedArrayView1D<const void>{ /* We're *sure* the view is correct, so faking the view size */ /** @todo better ideas for the StridedArrayView API? */ {attribute._isOffsetOnly ? _vertexData.data() + attribute._data.offset : attribute._data.pointer, ~std::size_t{}}, /* Not using attribute._vertexCount because that gets stale after releaseVertexData() gets called, and then we would need to slice the result inside attribute() and elsewhere anyway */ _vertexCount, attribute._stride}; } Containers::StridedArrayView2D<const char> MeshData::attribute(UnsignedInt id) const { CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::attribute(): index" << id << "out of range for" << _attributes.size() << "attributes", nullptr); const MeshAttributeData& attribute = _attributes[id]; /* Build a 2D view using information about attribute type size */ return Containers::arrayCast<2, const char>( attributeDataViewInternal(attribute), isVertexFormatImplementationSpecific(attribute._format) ? attribute._stride : vertexFormatSize(attribute._format)* (attribute._arraySize ? attribute._arraySize : 1)); } Containers::StridedArrayView2D<char> MeshData::mutableAttribute(UnsignedInt id) { CORRADE_ASSERT(_vertexDataFlags & DataFlag::Mutable, "Trade::MeshData::mutableAttribute(): vertex data not mutable", {}); CORRADE_ASSERT(id < _attributes.size(), "Trade::MeshData::mutableAttribute(): index" << id << "out of range for" << _attributes.size() << "attributes", nullptr); const MeshAttributeData& attribute = _attributes[id]; /* Build a 2D view using information about attribute type size */ auto out = Containers::arrayCast<2, const char>( attributeDataViewInternal(attribute), isVertexFormatImplementationSpecific(attribute._format) ? attribute._stride : vertexFormatSize(attribute._format)* (attribute._arraySize ? attribute._arraySize : 1)); /** @todo some arrayConstCast? UGH */ return Containers::StridedArrayView2D<char>{ /* The view size is there only for a size assert, we're pretty sure the view is valid */ {static_cast<char*>(const_cast<void*>(out.data())), ~std::size_t{}}, out.size(), out.stride()}; } Containers::StridedArrayView2D<const char> MeshData::attribute(MeshAttribute name, UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::attribute(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return attribute(attributeId); } Containers::StridedArrayView2D<char> MeshData::mutableAttribute(MeshAttribute name, UnsignedInt id) { CORRADE_ASSERT(_vertexDataFlags & DataFlag::Mutable, "Trade::MeshData::mutableAttribute(): vertex data not mutable", {}); const UnsignedInt attributeId = attributeFor(name, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::mutableAttribute(): index" << id << "out of range for" << attributeCount(name) << name << "attributes", {}); return mutableAttribute(attributeId); } void MeshData::indicesInto(const Containers::StridedArrayView1D<UnsignedInt> destination) const { CORRADE_ASSERT(isIndexed(), "Trade::MeshData::indicesInto(): the mesh is not indexed", ); CORRADE_ASSERT(destination.size() == indexCount(), "Trade::MeshData::indicesInto(): expected a view with" << indexCount() << "elements but got" << destination.size(), ); auto destination1ui = Containers::arrayCast<2, UnsignedInt>(destination); if(_indexType == MeshIndexType::UnsignedInt) return Utility::copy(Containers::arrayView(reinterpret_cast<const UnsignedInt*>(_indices), _indexCount), destination); else if(_indexType == MeshIndexType::UnsignedShort) return Math::castInto(Containers::arrayCast<2, const UnsignedShort>(Containers::arrayView(reinterpret_cast<const UnsignedShort*>(_indices), _indexCount)), destination1ui); else if(_indexType == MeshIndexType::UnsignedByte) return Math::castInto(Containers::arrayCast<2, const UnsignedByte>(Containers::arrayView(reinterpret_cast<const UnsignedByte*>(_indices), _indexCount)), destination1ui); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } Containers::Array<UnsignedInt> MeshData::indicesAsArray() const { /* Repeating the assert here because otherwise it would fire in indexCount() which may be confusing */ CORRADE_ASSERT(isIndexed(), "Trade::MeshData::indicesAsArray(): the mesh is not indexed", {}); Containers::Array<UnsignedInt> output{indexCount()}; indicesInto(output); return output; } void MeshData::positions2DInto(const Containers::StridedArrayView1D<Vector2> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Position, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::positions2DInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Position) << "position attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::positions2DInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::positions2DInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const auto destination2f = Containers::arrayCast<2, Float>(destination); /* Copy 2D positions as-is, for 3D positions ignore Z */ if(attribute._format == VertexFormat::Vector2 || attribute._format == VertexFormat::Vector3) Utility::copy(Containers::arrayCast<const Vector2>(attributeData), destination); else if(attribute._format == VertexFormat::Vector2h || attribute._format == VertexFormat::Vector3h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ub || attribute._format == VertexFormat::Vector3ub) Math::castInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2b || attribute._format == VertexFormat::Vector3b) Math::castInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2us || attribute._format == VertexFormat::Vector3us) Math::castInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2s || attribute._format == VertexFormat::Vector3s) Math::castInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ubNormalized || attribute._format == VertexFormat::Vector3ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2bNormalized || attribute._format == VertexFormat::Vector3bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2usNormalized || attribute._format == VertexFormat::Vector3usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2sNormalized || attribute._format == VertexFormat::Vector3sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } Containers::Array<Vector2> MeshData::positions2DAsArray(const UnsignedInt id) const { Containers::Array<Vector2> out{_vertexCount}; positions2DInto(out, id); return out; } void MeshData::positions3DInto(const Containers::StridedArrayView1D<Vector3> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Position, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::positions3DInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Position) << "position attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::positions3DInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::positions3DInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const Containers::StridedArrayView2D<Float> destination2f = Containers::arrayCast<2, Float>(Containers::arrayCast<Vector2>(destination)); const Containers::StridedArrayView2D<Float> destination3f = Containers::arrayCast<2, Float>(destination); /* For 2D positions copy the XY part to the first two components */ if(attribute._format == VertexFormat::Vector2) Utility::copy(Containers::arrayCast<const Vector2>(attributeData), Containers::arrayCast<Vector2>(destination)); else if(attribute._format == VertexFormat::Vector2h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ub) Math::castInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2b) Math::castInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2us) Math::castInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2s) Math::castInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); /* Copy 3D positions as-is */ else if(attribute._format == VertexFormat::Vector3) Utility::copy(Containers::arrayCast<const Vector3>(attributeData), destination); else if(attribute._format == VertexFormat::Vector3h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3ub) Math::castInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3b) Math::castInto(Containers::arrayCast<2, const Byte>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3us) Math::castInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3s) Math::castInto(Containers::arrayCast<2, const Short>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 3), destination3f); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ /* For 2D positions finally fill the Z with a single value */ if(attribute._format == VertexFormat::Vector2 || attribute._format == VertexFormat::Vector2h || attribute._format == VertexFormat::Vector2ub || attribute._format == VertexFormat::Vector2b || attribute._format == VertexFormat::Vector2us || attribute._format == VertexFormat::Vector2s || attribute._format == VertexFormat::Vector2ubNormalized || attribute._format == VertexFormat::Vector2bNormalized || attribute._format == VertexFormat::Vector2usNormalized || attribute._format == VertexFormat::Vector2sNormalized) { constexpr Float z[1]{0.0f}; Utility::copy( Containers::stridedArrayView(z).broadcasted<0>(_vertexCount), destination3f.transposed<0, 1>()[2]); } } Containers::Array<Vector3> MeshData::positions3DAsArray(const UnsignedInt id) const { Containers::Array<Vector3> out{_vertexCount}; positions3DInto(out, id); return out; } namespace { void tangentsOrNormalsInto(const Containers::StridedArrayView1D<const void> attributeData, const Containers::StridedArrayView1D<Vector3> destination, VertexFormat format) { const auto destination3f = Containers::arrayCast<2, Float>(destination); if(format == VertexFormat::Vector3) Utility::copy(Containers::arrayCast<const Vector3>(attributeData), destination); else if(format == VertexFormat::Vector3h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); else if(format == VertexFormat::Vector3bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 3), destination3f); else if(format == VertexFormat::Vector3sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 3), destination3f); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } } void MeshData::tangentsInto(const Containers::StridedArrayView1D<Vector3> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Tangent, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::tangentsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Tangent) << "tangent attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::tangentsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::tangentsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); /* If the tangent is four-component, ignore the last component; otherwise copy/unpack given format directly */ VertexFormat format; if(attribute._format == VertexFormat::Vector4) format = VertexFormat::Vector3; else if(attribute._format == VertexFormat::Vector4h) format = VertexFormat::Vector3h; else if(attribute._format == VertexFormat::Vector4bNormalized) format = VertexFormat::Vector3bNormalized; else if(attribute._format == VertexFormat::Vector4sNormalized) format = VertexFormat::Vector3sNormalized; else format = attribute._format; tangentsOrNormalsInto(attributeDataViewInternal(attribute), destination, format); } Containers::Array<Vector3> MeshData::tangentsAsArray(const UnsignedInt id) const { Containers::Array<Vector3> out{_vertexCount}; tangentsInto(out, id); return out; } void MeshData::bitangentSignsInto(const Containers::StridedArrayView1D<Float> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Tangent, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::bitangentSignsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Tangent) << "tangent attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::bitangentSignsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::bitangentSignsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const auto destination1f = Containers::arrayCast<2, Float>(destination); if(attribute._format == VertexFormat::Vector4) Utility::copy(Containers::arrayCast<2, const Float>(attributeData, 4).transposed<0, 1>()[3], destination); else if(attribute._format == VertexFormat::Vector4h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 4).suffix({0, 3}), destination1f); else if(attribute._format == VertexFormat::Vector4bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 4).suffix({0, 3}), destination1f); else if(attribute._format == VertexFormat::Vector4sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 4).suffix({0, 3}), destination1f); else CORRADE_ASSERT_UNREACHABLE("Trade::MeshData::bitangentSignsInto(): expected four-component tangents, but got" << attribute._format, ); } Containers::Array<Float> MeshData::bitangentSignsAsArray(const UnsignedInt id) const { Containers::Array<Float> out{_vertexCount}; bitangentSignsInto(out, id); return out; } void MeshData::bitangentsInto(const Containers::StridedArrayView1D<Vector3> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Bitangent, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::bitangentsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Bitangent) << "bitangent attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::bitangentsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::bitangentsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); tangentsOrNormalsInto(attributeDataViewInternal(attribute), destination, attribute._format); } Containers::Array<Vector3> MeshData::bitangentsAsArray(const UnsignedInt id) const { Containers::Array<Vector3> out{_vertexCount}; bitangentsInto(out, id); return out; } void MeshData::normalsInto(const Containers::StridedArrayView1D<Vector3> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Normal, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::normalsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Normal) << "normal attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::normalsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::normalsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); tangentsOrNormalsInto(attributeDataViewInternal(attribute), destination, attribute._format); } Containers::Array<Vector3> MeshData::normalsAsArray(const UnsignedInt id) const { Containers::Array<Vector3> out{_vertexCount}; normalsInto(out, id); return out; } void MeshData::textureCoordinates2DInto(const Containers::StridedArrayView1D<Vector2> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::TextureCoordinates, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::textureCoordinates2DInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::TextureCoordinates) << "texture coordinate attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::textureCoordinates2DInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::textureCoordinatesInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const auto destination2f = Containers::arrayCast<2, Float>(destination); if(attribute._format == VertexFormat::Vector2) Utility::copy(Containers::arrayCast<const Vector2>(attributeData), destination); else if(attribute._format == VertexFormat::Vector2h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ub) Math::castInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2b) Math::castInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2us) Math::castInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2s) Math::castInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2bNormalized) Math::unpackInto(Containers::arrayCast<2, const Byte>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 2), destination2f); else if(attribute._format == VertexFormat::Vector2sNormalized) Math::unpackInto(Containers::arrayCast<2, const Short>(attributeData, 2), destination2f); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } Containers::Array<Vector2> MeshData::textureCoordinates2DAsArray(const UnsignedInt id) const { Containers::Array<Vector2> out{_vertexCount}; textureCoordinates2DInto(out, id); return out; } void MeshData::colorsInto(const Containers::StridedArrayView1D<Color4> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::Color, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::colorsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::Color) << "color attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::colorsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::colorsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const Containers::StridedArrayView2D<Float> destination3f = Containers::arrayCast<2, Float>(Containers::arrayCast<Vector3>(destination)); const Containers::StridedArrayView2D<Float> destination4f = Containers::arrayCast<2, Float>(destination); /* For three-component colors copy the RGB part to the first three components */ if(attribute._format == VertexFormat::Vector3) Utility::copy(Containers::arrayCast<const Vector3>(attributeData), Containers::arrayCast<Vector3>(destination)); else if(attribute._format == VertexFormat::Vector3h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 3), destination3f); else if(attribute._format == VertexFormat::Vector3usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 3), destination3f); /* Copy four-component colors as-is */ else if(attribute._format == VertexFormat::Vector4) Utility::copy(Containers::arrayCast<const Vector4>(attributeData), Containers::arrayCast<Vector4>(destination)); else if(attribute._format == VertexFormat::Vector4h) Math::unpackHalfInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 4), destination4f); else if(attribute._format == VertexFormat::Vector4ubNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 4), destination4f); else if(attribute._format == VertexFormat::Vector4usNormalized) Math::unpackInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 4), destination4f); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ /* For three-component colors finally fill the alpha with a single value */ if(attribute._format == VertexFormat::Vector3 || attribute._format == VertexFormat::Vector3h || attribute._format == VertexFormat::Vector3ubNormalized || attribute._format == VertexFormat::Vector3usNormalized) { constexpr Float alpha[1]{1.0f}; Utility::copy( Containers::stridedArrayView(alpha).broadcasted<0>(_vertexCount), destination4f.transposed<0, 1>()[3]); } } Containers::Array<Color4> MeshData::colorsAsArray(const UnsignedInt id) const { Containers::Array<Color4> out{_vertexCount}; colorsInto(out, id); return out; } void MeshData::objectIdsInto(const Containers::StridedArrayView1D<UnsignedInt> destination, const UnsignedInt id) const { const UnsignedInt attributeId = attributeFor(MeshAttribute::ObjectId, id); CORRADE_ASSERT(attributeId != ~UnsignedInt{}, "Trade::MeshData::objectIdsInto(): index" << id << "out of range for" << attributeCount(MeshAttribute::ObjectId) << "object ID attributes", ); CORRADE_ASSERT(destination.size() == _vertexCount, "Trade::MeshData::objectIdsInto(): expected a view with" << _vertexCount << "elements but got" << destination.size(), ); const MeshAttributeData& attribute = _attributes[attributeId]; CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), "Trade::MeshData::objectIdsInto(): can't extract data out of an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), ); const Containers::StridedArrayView1D<const void> attributeData = attributeDataViewInternal(attribute); const auto destination1ui = Containers::arrayCast<2, UnsignedInt>(destination); if(attribute._format == VertexFormat::UnsignedInt) Utility::copy(Containers::arrayCast<const UnsignedInt>(attributeData), destination); else if(attribute._format == VertexFormat::UnsignedShort) Math::castInto(Containers::arrayCast<2, const UnsignedShort>(attributeData, 1), destination1ui); else if(attribute._format == VertexFormat::UnsignedByte) Math::castInto(Containers::arrayCast<2, const UnsignedByte>(attributeData, 1), destination1ui); else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } Containers::Array<UnsignedInt> MeshData::objectIdsAsArray(const UnsignedInt id) const { Containers::Array<UnsignedInt> out{_vertexCount}; objectIdsInto(out, id); return out; } Containers::Array<char> MeshData::releaseIndexData() { _indexCount = 0; Containers::Array<char> out = std::move(_indexData); _indexData = Containers::Array<char>{out.data(), 0, Implementation::nonOwnedArrayDeleter}; return out; } Containers::Array<MeshAttributeData> MeshData::releaseAttributeData() { return std::move(_attributes); } Containers::Array<char> MeshData::releaseVertexData() { _vertexCount = 0; Containers::Array<char> out = std::move(_vertexData); _vertexData = Containers::Array<char>{out.data(), 0, Implementation::nonOwnedArrayDeleter}; return out; } Debug& operator<<(Debug& debug, const MeshAttribute value) { debug << "Trade::MeshAttribute" << Debug::nospace; if(UnsignedShort(value) >= UnsignedShort(MeshAttribute::Custom)) return debug << "::Custom(" << Debug::nospace << (UnsignedShort(value) - UnsignedShort(MeshAttribute::Custom)) << Debug::nospace << ")"; switch(value) { /* LCOV_EXCL_START */ #define _c(value) case MeshAttribute::value: return debug << "::" #value; _c(Position) _c(Tangent) _c(Bitangent) _c(Normal) _c(TextureCoordinates) _c(Color) _c(ObjectId) #undef _c /* LCOV_EXCL_STOP */ /* To silence compiler warning about unhandled values */ case MeshAttribute::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")"; } }}
; logical OR accumulator with memory; 0b01 | 0b11 = 0b11 LDI #1 ; 00010000 00000001 0x1001 STA #0x01 ; 00100000 00000001 0x2001 LDI #3 ; 00010000 00000011 0x1003 ORR #0x01 ; 11000000 00000001 0xC001
; int putchar_fastcall(int c) INCLUDE "clib_cfg.asm" SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _putchar_fastcall EXTERN asm_putchar defc _putchar = asm_putchar ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _putchar_fastcall EXTERN _putchar_unlocked_fastcall defc _putchar_fastcall = _putchar_unlocked_fastcall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MODULE __tms9918_pixeladdress SECTION code_clib PUBLIC __tms9918_pixeladdress PUBLIC __tms9918_pix_return EXTERN __tms9918_attribute EXTERN l_tms9918_disable_interrupts EXTERN l_tms9918_enable_interrupts INCLUDE "graphics/grafix.inc" INCLUDE "video/tms9918/vdp.inc" ; ; $Id: pixladdr.asm $ ; .__tms9918_pixeladdress ld c,h ; X ld b,l ; Y ld a,h ; X and @11111000 ld l,a ld a,b ; Y rra rra rra and @00011111 ld h,a ; + ((Y & @11111000) << 5) ld a,b ; Y and 7 ld e,a ld d,0 add hl,de ; + Y&7 ;------- call l_tms9918_disable_interrupts IF VDP_CMD < 0 ld a,l ld (-VDP_CMD),a ld a,h ;4 and @00111111 ;7 ld (-VDP_CMD),a push bc pop bc ld a,(-VDP_DATAIN) ELSE push bc ld bc,VDP_CMD out (c), l ; LSB of video memory ptr ld a,h ; MSB of video mem ptr and @00111111 ; masked with "read command" bits out (c), a ld bc,VDP_DATAIN push bc pop bc in a,(c) pop bc ENDIF ex de,hl ;de = VDP address ld hl,__tms9918_pixelbyte ld (hl),a call l_tms9918_enable_interrupts ;------- ld a,c and @00000111 xor @00000111 ret .__tms9918_pix_return ld (hl),a ; hl points to "__tms9918_pixelbyte" call l_tms9918_disable_interrupts IF VDP_CMD < 0 ld a,e ld (-VDP_CMD),a ld a,d and @00111111 or @01000000 ld (-VDP_CMD),a ld a,(__tms9918_pixelbyte) push bc pop bc ld (-VDP_DATA),a ; And support colour as well ld a,e ld (-VDP_CMD),a ld a,d add $20 ;Move to bitmap to colour and @00111111 or @01000000 ld (-VDP_CMD),a ld a,(__tms9918_attribute) push bc pop bc ld (-VDP_DATA),a ELSE ld bc,VDP_CMD out (c),e ld a,d ; MSB of video mem ptr and @00111111 ; masked with "write command" bits or @01000000 out (c),a ld a,(__tms9918_pixelbyte) ; Can it be optimized ? what about VDP timing ? ld bc,VDP_DATA push bc pop bc out (c),a ld bc,VDP_CMD push bc pop bc out (c),e ld a,d ; MSB of video mem ptr add $20 and @00111111 ; masked with "write command" bits or @01000000 out (c),a ld a,(__tms9918_attribute) ld bc,VDP_DATA out (c),a ENDIF call l_tms9918_enable_interrupts pop bc ret SECTION bss_clib PUBLIC __tms9918_pixelbyte .__tms9918_pixelbyte defb 0
; A125925: Sprague-Grundy values for octal game .351. ; 1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2,0,1,0,2,1,2,1,2 sub $2,$0 mov $0,1599 sub $0,$2 add $0,4 lpb $0 mul $0,15 mod $0,8 lpe seq $0,36577 ; Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b. add $0,8 mod $0,3
;Ricardo Chavez ;ricardc4975@student.vvc.edu ;December 4, 2019 ; ; file: asm_main.asm %include "asm_io.inc" ; ; initialized data is put in the .data segment ; segment .data syswrite: equ 4 stdout: equ 1 exit: equ 1 SUCCESS: equ 0 kernelcall: equ 80h array_1 dd 5,4,3,2,1 message1 dd "Old Array", 0 message2 dd "New Array", 0 ; uninitialized data is put in the .bss segment ; segment .bss ; ; code is put in the .text segment ; segment .text global asm_main asm_main: enter 0,0 ; setup routine pusha ; *********** Start Assignment Code ******************* mov eax, message1 call print_string call print_nl mov esi, array_1 mov ecx, 5 lop: lodsd call print_int call print_nl loop lop mov eax, array_1 ;parameter 1 push eax mov eax, 5 ;parameter 2 push eax mov eax, 2 ;parameter 3 push eax call stack mov eax, message2 call print_string call print_nl mov esi, array_1 mov ecx, 5 looop: lodsd call print_int call print_nl loop looop add esp, 12 ; *********** End Assignment Code ********************** popa mov eax, SUCCESS ; return back to the C program leave ret stack: push ebp mov ebp, esp mov eax,[ebp +16] mov ecx,[ebp +12] mov ebx,[ebp+8] cld mov esi, eax mov edi, eax lp: lodsd ; mul ebx,[eax + ecx * 4-4] mul ebx stosd loop lp pop ebp ret
MainMenu: ; Check save file call InitOptions xor a ld [wOptionsInitialized],a inc a ld [wSaveFileStatus],a call CheckForPlayerNameInSRAM jr nc,.mainMenuLoop predef LoadSAV .mainMenuLoop ld c,20 call DelayFrames xor a ; LINK_STATE_NONE ld [wLinkState],a ld hl,wPartyAndBillsPCSavedMenuItem ld [hli],a ld [hli],a ld [hli],a ld [hl],a ld [wDefaultMap],a ld hl,wd72e res 6,[hl] call ClearScreen call RunDefaultPaletteCommand call LoadTextBoxTilePatterns call LoadFontTilePatterns ld hl,wd730 set 6,[hl] ld a,[wSaveFileStatus] cp a,1 jr z,.noSaveFile ; there's a save file coord hl, 0, 0 lb bc, 6, 13 call TextBoxBorder coord hl, 2, 2 ld de,ContinueText call PlaceString jr .next2 .noSaveFile coord hl, 0, 0 lb bc, 4, 13 call TextBoxBorder coord hl, 2, 2 ld de,NewGameText call PlaceString .next2 ld hl,wd730 res 6,[hl] call UpdateSprites xor a ld [wCurrentMenuItem],a ld [wLastMenuItem],a ld [wMenuJoypadPollCount],a inc a ld [wTopMenuItemX],a inc a ld [wTopMenuItemY],a ld a,A_BUTTON | B_BUTTON | START ld [wMenuWatchedKeys],a ld a,[wSaveFileStatus] ld [wMaxMenuItem],a call HandleMenuInput bit 1,a ; pressed B? jp nz,DisplayTitleScreen ; if so, go back to the title screen ld c,20 call DelayFrames ld a,[wCurrentMenuItem] ld b,a ld a,[wSaveFileStatus] cp a,2 jp z,.skipInc ; If there's no save file, increment the current menu item so that the numbers ; are the same whether or not there's a save file. inc b .skipInc ld a,b and a jr z,.choseContinue cp a,1 jp z,StartNewGame call DisplayOptionMenu ld a,1 ld [wOptionsInitialized],a jp .mainMenuLoop .choseContinue call DisplayContinueGameInfo ld hl,wCurrentMapScriptFlags set 5,[hl] .inputLoop xor a ld [hJoyPressed],a ld [hJoyReleased],a ld [hJoyHeld],a call Joypad ld a,[hJoyHeld] bit 0,a jr nz,.pressedA bit 1,a jp nz,.mainMenuLoop ; pressed B jr .inputLoop .pressedA call GBPalWhiteOutWithDelay3 call ClearScreen ld a,PLAYER_DIR_DOWN ld [wPlayerDirection],a ld c,10 call DelayFrames ld a,[wNumHoFTeams] and a jp z,SpecialEnterMap ld a,[wCurMap] ; map ID cp a,HALL_OF_FAME jp nz,SpecialEnterMap xor a ld [wDestinationMap],a ld hl,wd732 set 2,[hl] ; fly warp or dungeon warp call SpecialWarpIn jp SpecialEnterMap InitOptions: ld a,1 ; no delay ld [wLetterPrintingDelayFlags],a ld a,3 ; medium speed ld [wOptions],a ld a,64 ; audio? ld [wPrinterSettings], a ret Func_5cc1: ; unused? ld a, $6d cp $80 ret c ; will always be executed ld hl, NotEnoughMemoryText call PrintText ret NotEnoughMemoryText: TX_FAR _NotEnoughMemoryText db "@" StartNewGame: ld hl, wd732 res 1, [hl] call OakSpeech ld a, $8 ld [wPlayerMovingDirection], a ld c, 20 call DelayFrames ; enter map after using a special warp or loading the game from the main menu SpecialEnterMap: xor a ld [hJoyPressed], a ld [hJoyHeld], a ld [hJoy5], a ld [wd72d], a ld hl, wd732 set 0, [hl] ; count play time call ResetPlayerSpriteData ld c, 20 call DelayFrames call Func_5cc1 ld a, [wEnteringCableClub] and a ret nz jp EnterMap ContinueText: db "CONTINUE", $4e NewGameText: db "NEW GAME", $4e db "OPTION@" DisplayContinueGameInfo: xor a ld [H_AUTOBGTRANSFERENABLED], a coord hl, 4, 7 lb bc, 8, 14 call TextBoxBorder coord hl, 5, 9 ld de, SaveScreenInfoText call PlaceString coord hl, 12, 9 ld de, wPlayerName call PlaceString coord hl, 17, 11 call PrintNumBadges coord hl, 16, 13 call PrintNumOwnedMons coord hl, 13, 15 call PrintPlayTime ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a ld c, 30 jp DelayFrames PrintSaveScreenText: xor a ld [H_AUTOBGTRANSFERENABLED], a coord hl, 4, 0 lb bc, 8, 14 call TextBoxBorder call LoadTextBoxTilePatterns call UpdateSprites coord hl, 5, 2 ld de, SaveScreenInfoText call PlaceString coord hl, 12, 2 ld de, wPlayerName call PlaceString coord hl, 17, 4 call PrintNumBadges coord hl, 16, 6 call PrintNumOwnedMons coord hl, 13, 8 call PrintPlayTime ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld c, 30 jp DelayFrames PrintNumBadges: push hl ld hl, wObtainedBadges ld b, $1 call CountSetBits pop hl ld de, wNumSetBits lb bc, 1, 2 jp PrintNumber PrintNumOwnedMons: push hl ld hl, wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned call CountSetBits pop hl ld de, wNumSetBits lb bc, 1, 3 jp PrintNumber PrintPlayTime: ld de, wPlayTimeHours lb bc, 1, 3 call PrintNumber ld [hl], $6d inc hl ld de, wPlayTimeMinutes lb bc, LEADING_ZEROES | 1, 2 jp PrintNumber SaveScreenInfoText: db "PLAYER" next "BADGES " next "#DEX " next "TIME@" DisplayOptionMenu: callab DisplayOptionMenu_ ; 10:5c70 ret CheckForPlayerNameInSRAM: ; Check if the player name data in SRAM has a string terminator character ; (indicating that a name may have been saved there) and return whether it does ; in carry. ld a, SRAM_ENABLE ld [MBC1SRamEnable], a ld a, $1 ld [MBC1SRamBankingMode], a ld [MBC1SRamBank], a ld b, NAME_LENGTH ld hl, sPlayerName .loop ld a, [hli] cp "@" jr z, .found dec b jr nz, .loop ; not found xor a ld [MBC1SRamEnable], a ld [MBC1SRamBankingMode], a and a ret .found xor a ld [MBC1SRamEnable], a ld [MBC1SRamBankingMode], a scf ret
; A138409: a(n) = prime(n)^6 - prime(n)^2. ; 60,720,15600,117600,1771440,4826640,24137280,47045520,148035360,594822480,887502720,2565725040,4750102560,6321361200,10779213120,22164358320,42180530160,51520370640,90458377680,128100278880,151334220960,243087449280,326940366480,496981283040,832971995520,1061520140400,1194052285920,1500730340400,1677100098960,2081951739840,4195872898560,5053913127120,6611856231840,7212549393840,10942526564400,11853911565600,14976071806800,18755369551440,21691961568480,26808753302160,32894113412880,35161828294320,48551226236160,51682540512000,58451728270320,62103840559200,88245939588240,122978496197760,136821750657360,144215816749680,160005726485280,186374892325440,195930594087360,250058907126000,288136807449600,330928743884640,378890468309520,396109944031680,451729667891760,492309163338720,513710701664880,632711491129200,837201991626000,904820296916640,940299110406240,1014741853129680,1315127813215920,1464803622085440,1745729089457520,1806976737963600,1934854145473920,2140753641492960,2443410216790080,2693103168304560,2963706958180080,3156404426734080,3464955073497840,3915101633659920,4157825282241600,4681013008481760,5411082279907920,5567914721831280,6410082527680320,6590636786623680,7157924635028640,7558269223830000,8193662024083200,9109555799575200,9598548249684240,9851127637391040,10372926088820880,12078502136983680,13340550994460640,14011639426893360,15438435003498000,16196005304226720,17390284781169360,19999831641547680,20464923860541360,25071688922164560 seq $0,40 ; The prime numbers. mov $2,$0 pow $2,5 sub $2,$0 mul $0,$2
#include <bits/stdc++.h> #define ll long long using namespace std; const int MAXN = 1010; ll getint(){ char c;ll flag = 1,num = 0; while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1; while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();} return num*=flag; } ll cal_X,double_number; ll cal_x(ll number){ cal_X = 1; double_number = number<<1; do{ if(cal_X > number && cal_X < double_number)return cal_X; else if(cal_X == number)return cal_X; }while( cal_X = cal_X<<1 ); return -1; } ll new_x; /** * func use to cal v in [1,ans) * @param ans * @param x , the smallest number greater equal than ans * @return x/2 - [x-ans-func(x-ans+1,new_x)] */ ll func(ll ans, ll x){ if(ans==1)return 0; if(ans==3)return 2; if(x==ans)return x/2; new_x = cal_x(x-ans+1); return -x/2+ans+func(x-ans+1,new_x); } ll n,l,r,tmp_l,tmp_r; int main(){ n = getint(); while(n--){ tmp_l = l = getint(),tmp_r = r = getint(); tmp_l = cal_x(l);tmp_r = cal_x(r+1); printf("%lld\n",func(r+1,tmp_r) - func(l,tmp_l)); } return 0; }
#include <iostream> #include <cstdlib> #include "Memory.h" using namespace std; int main() { // Create a memory Memory memory = Memory(); // Print the statistics memory.printStats(); /* Expected output: ================================== Available: 0x10000 bits Used: 0x10000 bits ================================== 0x0000: Free */ // Allocate 0x4000 bits of memory std::cout << "Allocating 4 chunks of memory..." << '\n'; size_t size = 0x4000; unsigned address1 = memory.allocate(size); unsigned address2 = memory.allocate(size); unsigned address3 = memory.allocate(size); unsigned address4 = memory.allocate(size); // Print statistics memory.printStats(); /* Expected output: ================================== Available: 0x0 bits Used: 0x0 bits ================================== 0x0000: InUse 0x4000: InUse 0x8000: InUse 0xc000: InUse */ std::cout << "Freeing the second chunk..." << '\n'; memory.free(address2); memory.printStats(); /* Expected output: Freeing the second chunk... ================================== Available: 0x4000 bits Used: 0x4000 bits ================================== 0x0000: InUse 0x4000: Free 0x8000: InUse 0xc000: InUse */ std::cout << "Freeing the third chunk..." << '\n'; memory.free(address3); memory.printStats(); /* Expected output: ================================== Available: 0x8000 bits Used: 0x8000 bits ================================== 0x0000: InUse 0x4000: Free 0xc000: InUse */ std::cout << "Defragmenting..." << '\n'; memory.defragment(); memory.printStats(); /* Expected output: ================================== Available: 0x8000 bits Used: 0x8000 bits ================================== 0x0000: InUse 0x4000: InUse 0x8000: Free */ return 0; }
; /***************************************************************************** ; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers * ; ***************************************************************************** ; * Copyright 2021-2022 Marco Spedaletti (asimov@mclink.it) ; * ; * Licensed under the Apache License, Version 2.0 (the "License"); ; * 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. ; *---------------------------------------------------------------------------- ; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0 ; * (la "Licenza"); è proibito usare questo file se non in conformità alla ; * Licenza. Una copia della Licenza è disponibile all'indirizzo: ; * ; * http://www.apache.org/licenses/LICENSE-2.0 ; * ; * Se non richiesto dalla legislazione vigente o concordato per iscritto, ; * il software distribuito nei termini della Licenza è distribuito ; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o ; * implicite. Consultare la Licenza per il testo specifico che regola le ; * autorizzazioni e le limitazioni previste dalla medesima. ; ****************************************************************************/ ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;* * ;* VERTICAL SCROLL ON EF936X * ;* * ;* by Marco Spedaletti * ;* * ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * VSCROLLT ANDCC #$FE LDA _PEN ANDA #$0F ASLA ASLA ASLA ASLA STA <MATHPTR5 LDA _PAPER ANDA #$0F ORA <MATHPTR5 STA <MATHPTR5 LDA CURRENTMODE CMPA #0 BNE VSCROLLT0X JMP VSCROLLT0 VSCROLLT0X CMPA #1 BNE VSCROLLT1X JMP VSCROLLT1 VSCROLLT1X CMPA #2 BNE VSCROLLT2X JMP VSCROLLT2 VSCROLLT2X CMPA #3 BNE VSCROLLT3X JMP VSCROLLT3 VSCROLLT3X CMPA #4 BNE VSCROLLT4X JMP VSCROLLT4 VSCROLLT4X RTS VSCROLLT0 VSCROLLT1 VSCROLLT2 VSCROLLT3 VSCROLLT4 PSHS A,B,X,Y,U LDA <DIRECTION CMPA #0 BGT VSCROLLTDOWN VSCROLLTUP LDX BITMAPADDRESS LDY BITMAPADDRESS LDA CURRENTSL LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y VSCROLLTUPYSCR LDA $a7c0 ORA #$01 STA $a7c0 VSCROLLTUPYSCR1 LDA ,Y+ STA ,X+ CMPY CURRENTFRAMESIZE BNE VSCROLLTUPYSCR1 LDA #0 VSCROLLTUPREFILL STA ,X+ CMPX CURRENTFRAMESIZE BNE VSCROLLTUPREFILL LDA $a7c0 ANDA #$fe STA $a7c0 LDX BITMAPADDRESS LDY BITMAPADDRESS LDA CURRENTSL LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y LEAY A, Y VSCROLLTUPYSCR1C LDA ,Y+ STA ,X+ CMPY CURRENTFRAMESIZE BNE VSCROLLTUPYSCR1C LDA <MATHPTR5 VSCROLLTUPREFILLC STA ,X+ CMPX CURRENTFRAMESIZE BNE VSCROLLTUPREFILLC JMP VSCROLLTE VSCROLLTDOWN LDX BITMAPADDRESS LDY BITMAPADDRESS LDA CURRENTFRAMESIZE LEAY A, Y LEAX A, X LDA CURRENTSL COMA LEAX A, X VSCROLLTDOWNYSCR LDA $a7c0 ORA #$01 STA $a7c0 VSCROLLTDOWNYSCR1 LDA ,-X STA ,-Y CMPX #$0 BNE VSCROLLTDOWNYSCR1 LDA #0 VSCROLLTDOWNREFILL STA ,-Y CMPY #$0 BNE VSCROLLTDOWNREFILL LDA $a7c0 ANDA #$fe STA $a7c0 VSCROLLTDOWNYSCR1C LDA ,-X STA ,-Y CMPX #$0 BNE VSCROLLTDOWNYSCR1C LDA <MATHPTR5 VSCROLLTDOWNREFILLC STA ,-Y CMPY #$0 BNE VSCROLLTDOWNREFILLC JMP VSCROLLTE VSCROLLTE PULS A,B,X,Y,U RTS
_kill: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char **argv) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 57 push %edi 4: 56 push %esi 5: 53 push %ebx int i; if(argc < 2){ 6: bb 01 00 00 00 mov $0x1,%ebx #include "stat.h" #include "user.h" int main(int argc, char **argv) { b: 83 e4 f0 and $0xfffffff0,%esp e: 83 ec 10 sub $0x10,%esp 11: 8b 75 08 mov 0x8(%ebp),%esi 14: 8b 7d 0c mov 0xc(%ebp),%edi int i; if(argc < 2){ 17: 83 fe 01 cmp $0x1,%esi 1a: 7e 23 jle 3f <main+0x3f> 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) kill(atoi(argv[i])); 20: 8b 04 9f mov (%edi,%ebx,4),%eax if(argc < 2){ printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) 23: 83 c3 01 add $0x1,%ebx kill(atoi(argv[i])); 26: 89 04 24 mov %eax,(%esp) 29: e8 f2 01 00 00 call 220 <atoi> 2e: 89 04 24 mov %eax,(%esp) 31: e8 7c 02 00 00 call 2b2 <kill> if(argc < 2){ printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) 36: 39 f3 cmp %esi,%ebx 38: 75 e6 jne 20 <main+0x20> kill(atoi(argv[i])); exit(); 3a: e8 43 02 00 00 call 282 <exit> main(int argc, char **argv) { int i; if(argc < 2){ printf(2, "usage: kill pid...\n"); 3f: c7 44 24 04 36 07 00 movl $0x736,0x4(%esp) 46: 00 47: c7 04 24 02 00 00 00 movl $0x2,(%esp) 4e: e8 7d 03 00 00 call 3d0 <printf> exit(); 53: e8 2a 02 00 00 call 282 <exit> 58: 66 90 xchg %ax,%ax 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, char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 8b 45 08 mov 0x8(%ebp),%eax 66: 8b 4d 0c mov 0xc(%ebp),%ecx 69: 53 push %ebx 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: 8b 55 08 mov 0x8(%ebp),%edx 96: 53 push %ebx 97: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9a: 0f b6 02 movzbl (%edx),%eax 9d: 84 c0 test %al,%al 9f: 74 2d je ce <strcmp+0x3e> a1: 0f b6 19 movzbl (%ecx),%ebx a4: 38 d8 cmp %bl,%al a6: 74 0e je b6 <strcmp+0x26> a8: eb 2b jmp d5 <strcmp+0x45> aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi b0: 38 c8 cmp %cl,%al b2: 75 15 jne c9 <strcmp+0x39> p++, q++; b4: 89 d9 mov %ebx,%ecx b6: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b9: 0f b6 02 movzbl (%edx),%eax p++, q++; bc: 8d 59 01 lea 0x1(%ecx),%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) bf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx c3: 84 c0 test %al,%al c5: 75 e9 jne b0 <strcmp+0x20> c7: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; c9: 29 c8 sub %ecx,%eax } cb: 5b pop %ebx cc: 5d pop %ebp cd: c3 ret ce: 0f b6 09 movzbl (%ecx),%ecx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) d1: 31 c0 xor %eax,%eax d3: eb f4 jmp c9 <strcmp+0x39> d5: 0f b6 cb movzbl %bl,%ecx d8: eb ef jmp c9 <strcmp+0x39> da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000000e0 <strlen>: return (uchar)*p - (uchar)*q; } uint strlen(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 12 je fd <strlen+0x1d> 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 uint strlen(char *s) { int n; for(n = 0; s[n]; n++) fd: 31 c0 xor %eax,%eax ; return n; } ff: 5d pop %ebp 100: c3 ret 101: eb 0d jmp 110 <memset> 103: 90 nop 104: 90 nop 105: 90 nop 106: 90 nop 107: 90 nop 108: 90 nop 109: 90 nop 10a: 90 nop 10b: 90 nop 10c: 90 nop 10d: 90 nop 10e: 90 nop 10f: 90 nop 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 8b 55 08 mov 0x8(%ebp),%edx 116: 57 push %edi } 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: 8b 45 08 mov 0x8(%ebp),%eax 136: 53 push %ebx 137: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 13a: 0f b6 18 movzbl (%eax),%ebx 13d: 84 db test %bl,%bl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d1 mov %edx,%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> } char* strchr(const char *s, char c) { 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> if(*s == c) 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 int i, cc; char c; for(i=0; i+1 < max; ){ 175: 31 f6 xor %esi,%esi return 0; } char* gets(char *buf, int max) { 177: 53 push %ebx 178: 83 ec 2c sub $0x2c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ cc = read(0, &c, 1); 17b: 8d 7d e7 lea -0x19(%ebp),%edi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 17e: eb 31 jmp 1b1 <gets+0x41> cc = read(0, &c, 1); 180: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 187: 00 188: 89 7c 24 04 mov %edi,0x4(%esp) 18c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 193: e8 02 01 00 00 call 29a <read> if(cc < 1) 198: 85 c0 test %eax,%eax 19a: 7e 1d jle 1b9 <gets+0x49> break; buf[i++] = c; 19c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1a0: 89 de mov %ebx,%esi cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 1a2: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 1a5: 3c 0d cmp $0xd,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 1a7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 1ab: 74 0c je 1b9 <gets+0x49> 1ad: 3c 0a cmp $0xa,%al 1af: 74 08 je 1b9 <gets+0x49> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1b1: 8d 5e 01 lea 0x1(%esi),%ebx 1b4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1b7: 7c c7 jl 180 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1b9: 8b 45 08 mov 0x8(%ebp),%eax 1bc: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1c0: 83 c4 2c add $0x2c,%esp 1c3: 5b pop %ebx 1c4: 5e pop %esi 1c5: 5f pop %edi 1c6: 5d pop %ebp 1c7: c3 ret 1c8: 90 nop 1c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001d0 <stat>: int stat(char *n, struct stat *st) { 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 56 push %esi 1d4: 53 push %ebx 1d5: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 1d8: 8b 45 08 mov 0x8(%ebp),%eax 1db: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1e2: 00 1e3: 89 04 24 mov %eax,(%esp) 1e6: e8 d7 00 00 00 call 2c2 <open> if(fd < 0) 1eb: 85 c0 test %eax,%eax stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 1ed: 89 c3 mov %eax,%ebx if(fd < 0) 1ef: 78 27 js 218 <stat+0x48> return -1; r = fstat(fd, st); 1f1: 8b 45 0c mov 0xc(%ebp),%eax 1f4: 89 1c 24 mov %ebx,(%esp) 1f7: 89 44 24 04 mov %eax,0x4(%esp) 1fb: e8 da 00 00 00 call 2da <fstat> close(fd); 200: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 203: 89 c6 mov %eax,%esi close(fd); 205: e8 a0 00 00 00 call 2aa <close> return r; 20a: 89 f0 mov %esi,%eax } 20c: 83 c4 10 add $0x10,%esp 20f: 5b pop %ebx 210: 5e pop %esi 211: 5d pop %ebp 212: c3 ret 213: 90 nop 214: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 218: b8 ff ff ff ff mov $0xffffffff,%eax 21d: eb ed jmp 20c <stat+0x3c> 21f: 90 nop 00000220 <atoi>: return r; } int atoi(const char *s) { 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 8b 4d 08 mov 0x8(%ebp),%ecx 226: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 227: 0f be 11 movsbl (%ecx),%edx 22a: 8d 42 d0 lea -0x30(%edx),%eax 22d: 3c 09 cmp $0x9,%al int atoi(const char *s) { int n; n = 0; 22f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 234: 77 17 ja 24d <atoi+0x2d> 236: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 238: 83 c1 01 add $0x1,%ecx 23b: 8d 04 80 lea (%eax,%eax,4),%eax 23e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 242: 0f be 11 movsbl (%ecx),%edx 245: 8d 5a d0 lea -0x30(%edx),%ebx 248: 80 fb 09 cmp $0x9,%bl 24b: 76 eb jbe 238 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 24d: 5b pop %ebx 24e: 5d pop %ebp 24f: c3 ret 00000250 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 250: 55 push %ebp char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 251: 31 d2 xor %edx,%edx return n; } void* memmove(void *vdst, void *vsrc, int n) { 253: 89 e5 mov %esp,%ebp 255: 56 push %esi 256: 8b 45 08 mov 0x8(%ebp),%eax 259: 53 push %ebx 25a: 8b 5d 10 mov 0x10(%ebp),%ebx 25d: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 260: 85 db test %ebx,%ebx 262: 7e 12 jle 276 <memmove+0x26> 264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 268: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 26c: 88 0c 10 mov %cl,(%eax,%edx,1) 26f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 272: 39 da cmp %ebx,%edx 274: 75 f2 jne 268 <memmove+0x18> *dst++ = *src++; return vdst; } 276: 5b pop %ebx 277: 5e pop %esi 278: 5d pop %ebp 279: c3 ret 0000027a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 27a: b8 01 00 00 00 mov $0x1,%eax 27f: cd 40 int $0x40 281: c3 ret 00000282 <exit>: SYSCALL(exit) 282: b8 02 00 00 00 mov $0x2,%eax 287: cd 40 int $0x40 289: c3 ret 0000028a <wait>: SYSCALL(wait) 28a: b8 03 00 00 00 mov $0x3,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <pipe>: SYSCALL(pipe) 292: b8 04 00 00 00 mov $0x4,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <read>: SYSCALL(read) 29a: b8 05 00 00 00 mov $0x5,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <write>: SYSCALL(write) 2a2: b8 10 00 00 00 mov $0x10,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <close>: SYSCALL(close) 2aa: b8 15 00 00 00 mov $0x15,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <kill>: SYSCALL(kill) 2b2: b8 06 00 00 00 mov $0x6,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <exec>: SYSCALL(exec) 2ba: b8 07 00 00 00 mov $0x7,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <open>: SYSCALL(open) 2c2: b8 0f 00 00 00 mov $0xf,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <mknod>: SYSCALL(mknod) 2ca: b8 11 00 00 00 mov $0x11,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <unlink>: SYSCALL(unlink) 2d2: b8 12 00 00 00 mov $0x12,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <fstat>: SYSCALL(fstat) 2da: b8 08 00 00 00 mov $0x8,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <link>: SYSCALL(link) 2e2: b8 13 00 00 00 mov $0x13,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mkdir>: SYSCALL(mkdir) 2ea: b8 14 00 00 00 mov $0x14,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <chdir>: SYSCALL(chdir) 2f2: b8 09 00 00 00 mov $0x9,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <dup>: SYSCALL(dup) 2fa: b8 0a 00 00 00 mov $0xa,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <getpid>: SYSCALL(getpid) 302: b8 0b 00 00 00 mov $0xb,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <sbrk>: SYSCALL(sbrk) 30a: b8 0c 00 00 00 mov $0xc,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <sleep>: SYSCALL(sleep) 312: b8 0d 00 00 00 mov $0xd,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <uptime>: SYSCALL(uptime) 31a: b8 0e 00 00 00 mov $0xe,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <lotto>: SYSCALL(lotto) 322: b8 16 00 00 00 mov $0x16,%eax 327: cd 40 int $0x40 329: c3 ret 32a: 66 90 xchg %ax,%ax 32c: 66 90 xchg %ax,%ax 32e: 66 90 xchg %ax,%ax 00000330 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 330: 55 push %ebp 331: 89 e5 mov %esp,%ebp 333: 57 push %edi 334: 56 push %esi 335: 89 c6 mov %eax,%esi 337: 53 push %ebx 338: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 33b: 8b 5d 08 mov 0x8(%ebp),%ebx 33e: 85 db test %ebx,%ebx 340: 74 09 je 34b <printint+0x1b> 342: 89 d0 mov %edx,%eax 344: c1 e8 1f shr $0x1f,%eax 347: 84 c0 test %al,%al 349: 75 75 jne 3c0 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 34b: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 34d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 354: 89 75 c0 mov %esi,-0x40(%ebp) x = -xx; } else { x = xx; } i = 0; 357: 31 ff xor %edi,%edi 359: 89 ce mov %ecx,%esi 35b: 8d 5d d7 lea -0x29(%ebp),%ebx 35e: eb 02 jmp 362 <printint+0x32> do{ buf[i++] = digits[x % base]; 360: 89 cf mov %ecx,%edi 362: 31 d2 xor %edx,%edx 364: f7 f6 div %esi 366: 8d 4f 01 lea 0x1(%edi),%ecx 369: 0f b6 92 51 07 00 00 movzbl 0x751(%edx),%edx }while((x /= base) != 0); 370: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 372: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 375: 75 e9 jne 360 <printint+0x30> if(neg) 377: 8b 55 c4 mov -0x3c(%ebp),%edx x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 37a: 89 c8 mov %ecx,%eax 37c: 8b 75 c0 mov -0x40(%ebp),%esi }while((x /= base) != 0); if(neg) 37f: 85 d2 test %edx,%edx 381: 74 08 je 38b <printint+0x5b> buf[i++] = '-'; 383: 8d 4f 02 lea 0x2(%edi),%ecx 386: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 38b: 8d 79 ff lea -0x1(%ecx),%edi 38e: 66 90 xchg %ax,%ax 390: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 395: 83 ef 01 sub $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 398: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 39f: 00 3a0: 89 5c 24 04 mov %ebx,0x4(%esp) 3a4: 89 34 24 mov %esi,(%esp) 3a7: 88 45 d7 mov %al,-0x29(%ebp) 3aa: e8 f3 fe ff ff call 2a2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3af: 83 ff ff cmp $0xffffffff,%edi 3b2: 75 dc jne 390 <printint+0x60> putc(fd, buf[i]); } 3b4: 83 c4 4c add $0x4c,%esp 3b7: 5b pop %ebx 3b8: 5e pop %esi 3b9: 5f pop %edi 3ba: 5d pop %ebp 3bb: c3 ret 3bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 3c0: 89 d0 mov %edx,%eax 3c2: f7 d8 neg %eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 3c4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 3cb: eb 87 jmp 354 <printint+0x24> 3cd: 8d 76 00 lea 0x0(%esi),%esi 000003d0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3d0: 55 push %ebp 3d1: 89 e5 mov %esp,%ebp 3d3: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 3d4: 31 ff xor %edi,%edi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3d6: 56 push %esi 3d7: 53 push %ebx 3d8: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3db: 8b 5d 0c mov 0xc(%ebp),%ebx char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 3de: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3e1: 8b 75 08 mov 0x8(%ebp),%esi char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 3e4: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 3e7: 0f b6 13 movzbl (%ebx),%edx 3ea: 83 c3 01 add $0x1,%ebx 3ed: 84 d2 test %dl,%dl 3ef: 75 39 jne 42a <printf+0x5a> 3f1: e9 c2 00 00 00 jmp 4b8 <printf+0xe8> 3f6: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 3f8: 83 fa 25 cmp $0x25,%edx 3fb: 0f 84 bf 00 00 00 je 4c0 <printf+0xf0> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 401: 8d 45 e2 lea -0x1e(%ebp),%eax 404: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 40b: 00 40c: 89 44 24 04 mov %eax,0x4(%esp) 410: 89 34 24 mov %esi,(%esp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; } else { putc(fd, c); 413: 88 55 e2 mov %dl,-0x1e(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 416: e8 87 fe ff ff call 2a2 <write> 41b: 83 c3 01 add $0x1,%ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 41e: 0f b6 53 ff movzbl -0x1(%ebx),%edx 422: 84 d2 test %dl,%dl 424: 0f 84 8e 00 00 00 je 4b8 <printf+0xe8> c = fmt[i] & 0xff; if(state == 0){ 42a: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 42c: 0f be c2 movsbl %dl,%eax if(state == 0){ 42f: 74 c7 je 3f8 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 431: 83 ff 25 cmp $0x25,%edi 434: 75 e5 jne 41b <printf+0x4b> if(c == 'd'){ 436: 83 fa 64 cmp $0x64,%edx 439: 0f 84 31 01 00 00 je 570 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 43f: 25 f7 00 00 00 and $0xf7,%eax 444: 83 f8 70 cmp $0x70,%eax 447: 0f 84 83 00 00 00 je 4d0 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 44d: 83 fa 73 cmp $0x73,%edx 450: 0f 84 a2 00 00 00 je 4f8 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 456: 83 fa 63 cmp $0x63,%edx 459: 0f 84 35 01 00 00 je 594 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 45f: 83 fa 25 cmp $0x25,%edx 462: 0f 84 e0 00 00 00 je 548 <printf+0x178> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 468: 8d 45 e6 lea -0x1a(%ebp),%eax 46b: 83 c3 01 add $0x1,%ebx 46e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 475: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 476: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 478: 89 44 24 04 mov %eax,0x4(%esp) 47c: 89 34 24 mov %esi,(%esp) 47f: 89 55 d0 mov %edx,-0x30(%ebp) 482: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 486: e8 17 fe ff ff call 2a2 <write> } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 48b: 8b 55 d0 mov -0x30(%ebp),%edx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48e: 8d 45 e7 lea -0x19(%ebp),%eax 491: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 498: 00 499: 89 44 24 04 mov %eax,0x4(%esp) 49d: 89 34 24 mov %esi,(%esp) } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 4a0: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4a3: e8 fa fd ff ff call 2a2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4a8: 0f b6 53 ff movzbl -0x1(%ebx),%edx 4ac: 84 d2 test %dl,%dl 4ae: 0f 85 76 ff ff ff jne 42a <printf+0x5a> 4b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, c); } state = 0; } } } 4b8: 83 c4 3c add $0x3c,%esp 4bb: 5b pop %ebx 4bc: 5e pop %esi 4bd: 5f pop %edi 4be: 5d pop %ebp 4bf: c3 ret ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 4c0: bf 25 00 00 00 mov $0x25,%edi 4c5: e9 51 ff ff ff jmp 41b <printf+0x4b> 4ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4d0: 8b 45 d4 mov -0x2c(%ebp),%eax 4d3: b9 10 00 00 00 mov $0x10,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4d8: 31 ff xor %edi,%edi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4da: c7 04 24 00 00 00 00 movl $0x0,(%esp) 4e1: 8b 10 mov (%eax),%edx 4e3: 89 f0 mov %esi,%eax 4e5: e8 46 fe ff ff call 330 <printint> ap++; 4ea: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 4ee: e9 28 ff ff ff jmp 41b <printf+0x4b> 4f3: 90 nop 4f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 4f8: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 4fb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 4ff: 8b 38 mov (%eax),%edi ap++; if(s == 0) s = "(null)"; 501: b8 4a 07 00 00 mov $0x74a,%eax 506: 85 ff test %edi,%edi 508: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 50b: 0f b6 07 movzbl (%edi),%eax 50e: 84 c0 test %al,%al 510: 74 2a je 53c <printf+0x16c> 512: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 518: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 51b: 8d 45 e3 lea -0x1d(%ebp),%eax ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 51e: 83 c7 01 add $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 521: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 528: 00 529: 89 44 24 04 mov %eax,0x4(%esp) 52d: 89 34 24 mov %esi,(%esp) 530: e8 6d fd ff ff call 2a2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 535: 0f b6 07 movzbl (%edi),%eax 538: 84 c0 test %al,%al 53a: 75 dc jne 518 <printf+0x148> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 53c: 31 ff xor %edi,%edi 53e: e9 d8 fe ff ff jmp 41b <printf+0x4b> 543: 90 nop 544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 548: 8d 45 e5 lea -0x1b(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 54b: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 54d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 554: 00 555: 89 44 24 04 mov %eax,0x4(%esp) 559: 89 34 24 mov %esi,(%esp) 55c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 560: e8 3d fd ff ff call 2a2 <write> 565: e9 b1 fe ff ff jmp 41b <printf+0x4b> 56a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 570: 8b 45 d4 mov -0x2c(%ebp),%eax 573: b9 0a 00 00 00 mov $0xa,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 578: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 57b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 582: 8b 10 mov (%eax),%edx 584: 89 f0 mov %esi,%eax 586: e8 a5 fd ff ff call 330 <printint> ap++; 58b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 58f: e9 87 fe ff ff jmp 41b <printf+0x4b> while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 594: 8b 45 d4 mov -0x2c(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 597: 31 ff xor %edi,%edi while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 599: 8b 00 mov (%eax),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 59b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5a2: 00 5a3: 89 34 24 mov %esi,(%esp) while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 5a6: 88 45 e4 mov %al,-0x1c(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5a9: 8d 45 e4 lea -0x1c(%ebp),%eax 5ac: 89 44 24 04 mov %eax,0x4(%esp) 5b0: e8 ed fc ff ff call 2a2 <write> putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 5b5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5b9: e9 5d fe ff ff jmp 41b <printf+0x4b> 5be: 66 90 xchg %ax,%ax 000005c0 <free>: static Header base; static Header *freep; void free(void *ap) { 5c0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5c1: a1 cc 09 00 00 mov 0x9cc,%eax static Header base; static Header *freep; void free(void *ap) { 5c6: 89 e5 mov %esp,%ebp 5c8: 57 push %edi 5c9: 56 push %esi 5ca: 53 push %ebx 5cb: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5ce: 8b 08 mov (%eax),%ecx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 5d0: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5d3: 39 d0 cmp %edx,%eax 5d5: 72 11 jb 5e8 <free+0x28> 5d7: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5d8: 39 c8 cmp %ecx,%eax 5da: 72 04 jb 5e0 <free+0x20> 5dc: 39 ca cmp %ecx,%edx 5de: 72 10 jb 5f0 <free+0x30> 5e0: 89 c8 mov %ecx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5e2: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5e4: 8b 08 mov (%eax),%ecx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5e6: 73 f0 jae 5d8 <free+0x18> 5e8: 39 ca cmp %ecx,%edx 5ea: 72 04 jb 5f0 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5ec: 39 c8 cmp %ecx,%eax 5ee: 72 f0 jb 5e0 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 5f0: 8b 73 fc mov -0x4(%ebx),%esi 5f3: 8d 3c f2 lea (%edx,%esi,8),%edi 5f6: 39 cf cmp %ecx,%edi 5f8: 74 1e je 618 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5fa: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 5fd: 8b 48 04 mov 0x4(%eax),%ecx 600: 8d 34 c8 lea (%eax,%ecx,8),%esi 603: 39 f2 cmp %esi,%edx 605: 74 28 je 62f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 607: 89 10 mov %edx,(%eax) freep = p; 609: a3 cc 09 00 00 mov %eax,0x9cc } 60e: 5b pop %ebx 60f: 5e pop %esi 610: 5f pop %edi 611: 5d pop %ebp 612: c3 ret 613: 90 nop 614: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 618: 03 71 04 add 0x4(%ecx),%esi 61b: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 61e: 8b 08 mov (%eax),%ecx 620: 8b 09 mov (%ecx),%ecx 622: 89 4b f8 mov %ecx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 625: 8b 48 04 mov 0x4(%eax),%ecx 628: 8d 34 c8 lea (%eax,%ecx,8),%esi 62b: 39 f2 cmp %esi,%edx 62d: 75 d8 jne 607 <free+0x47> p->s.size += bp->s.size; 62f: 03 4b fc add -0x4(%ebx),%ecx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 632: a3 cc 09 00 00 mov %eax,0x9cc bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 637: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 63a: 8b 53 f8 mov -0x8(%ebx),%edx 63d: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 63f: 5b pop %ebx 640: 5e pop %esi 641: 5f pop %edi 642: 5d pop %ebp 643: c3 ret 644: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 64a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000650 <malloc>: return freep; } void* malloc(uint nbytes) { 650: 55 push %ebp 651: 89 e5 mov %esp,%ebp 653: 57 push %edi 654: 56 push %esi 655: 53 push %ebx 656: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 659: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 65c: 8b 1d cc 09 00 00 mov 0x9cc,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 662: 8d 48 07 lea 0x7(%eax),%ecx 665: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 668: 85 db test %ebx,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 66a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 66d: 0f 84 9b 00 00 00 je 70e <malloc+0xbe> 673: 8b 13 mov (%ebx),%edx 675: 8b 7a 04 mov 0x4(%edx),%edi 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){ 678: 39 fe cmp %edi,%esi 67a: 76 64 jbe 6e0 <malloc+0x90> 67c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 683: bb 00 80 00 00 mov $0x8000,%ebx 688: 89 45 e4 mov %eax,-0x1c(%ebp) 68b: eb 0e jmp 69b <malloc+0x4b> 68d: 8d 76 00 lea 0x0(%esi),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 690: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 692: 8b 78 04 mov 0x4(%eax),%edi 695: 39 fe cmp %edi,%esi 697: 76 4f jbe 6e8 <malloc+0x98> 699: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 69b: 3b 15 cc 09 00 00 cmp 0x9cc,%edx 6a1: 75 ed jne 690 <malloc+0x40> morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 6a3: 8b 45 e4 mov -0x1c(%ebp),%eax 6a6: 81 fe 00 10 00 00 cmp $0x1000,%esi 6ac: bf 00 10 00 00 mov $0x1000,%edi 6b1: 0f 43 fe cmovae %esi,%edi 6b4: 0f 42 c3 cmovb %ebx,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 6b7: 89 04 24 mov %eax,(%esp) 6ba: e8 4b fc ff ff call 30a <sbrk> if(p == (char*)-1) 6bf: 83 f8 ff cmp $0xffffffff,%eax 6c2: 74 18 je 6dc <malloc+0x8c> return 0; hp = (Header*)p; hp->s.size = nu; 6c4: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 6c7: 83 c0 08 add $0x8,%eax 6ca: 89 04 24 mov %eax,(%esp) 6cd: e8 ee fe ff ff call 5c0 <free> return freep; 6d2: 8b 15 cc 09 00 00 mov 0x9cc,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 6d8: 85 d2 test %edx,%edx 6da: 75 b4 jne 690 <malloc+0x40> return 0; 6dc: 31 c0 xor %eax,%eax 6de: eb 20 jmp 700 <malloc+0xb0> if((prevp = freep) == 0){ 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){ 6e0: 89 d0 mov %edx,%eax 6e2: 89 da mov %ebx,%edx 6e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 6e8: 39 fe cmp %edi,%esi 6ea: 74 1c je 708 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 6ec: 29 f7 sub %esi,%edi 6ee: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 6f1: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 6f4: 89 70 04 mov %esi,0x4(%eax) } freep = prevp; 6f7: 89 15 cc 09 00 00 mov %edx,0x9cc return (void*)(p + 1); 6fd: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 700: 83 c4 1c add $0x1c,%esp 703: 5b pop %ebx 704: 5e pop %esi 705: 5f pop %edi 706: 5d pop %ebp 707: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 708: 8b 08 mov (%eax),%ecx 70a: 89 0a mov %ecx,(%edx) 70c: eb e9 jmp 6f7 <malloc+0xa7> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 70e: c7 05 cc 09 00 00 d0 movl $0x9d0,0x9cc 715: 09 00 00 base.s.size = 0; 718: ba d0 09 00 00 mov $0x9d0,%edx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 71d: c7 05 d0 09 00 00 d0 movl $0x9d0,0x9d0 724: 09 00 00 base.s.size = 0; 727: c7 05 d4 09 00 00 00 movl $0x0,0x9d4 72e: 00 00 00 731: e9 46 ff ff ff jmp 67c <malloc+0x2c>
/////////////////////////////////////////////////////////////////////////////// /// \file tags.hpp /// Contains the tags for all the overloadable operators in C++ // // Copyright 2007 Eric Niebler. 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) #ifndef BOOST_PROTO_TAGS_HPP_EAN_04_01_2005 #define BOOST_PROTO_TAGS_HPP_EAN_04_01_2005 #include <boost/xpressive/proto/detail/prefix.hpp> #include <boost/xpressive/proto/proto_fwd.hpp> #include <boost/xpressive/proto/detail/suffix.hpp> namespace boost { namespace proto { namespace tag { /// Tag type for terminals; aka, leaves in the expression tree. struct terminal {}; /// Tag type for the unary + operator. struct posit {}; /// Tag type for the unary - operator. struct negate {}; /// Tag type for the unary * operator. struct dereference {}; /// Tag type for the unary ~ operator. struct complement {}; /// Tag type for the unary & operator. struct address_of {}; /// Tag type for the unary ! operator. struct logical_not {}; /// Tag type for the unary prefix ++ operator. struct pre_inc {}; /// Tag type for the unary prefix -- operator. struct pre_dec {}; /// Tag type for the unary postfix ++ operator. struct post_inc {}; /// Tag type for the unary postfix -- operator. struct post_dec {}; /// Tag type for the binary \<\< operator. struct shift_left {}; /// Tag type for the binary \>\> operator. struct shift_right {}; /// Tag type for the binary * operator. struct multiplies {}; /// Tag type for the binary / operator. struct divides {}; /// Tag type for the binary % operator. struct modulus {}; /// Tag type for the binary + operator. struct plus {}; /// Tag type for the binary - operator. struct minus {}; /// Tag type for the binary \< operator. struct less {}; /// Tag type for the binary \> operator. struct greater {}; /// Tag type for the binary \<= operator. struct less_equal {}; /// Tag type for the binary \>= operator. struct greater_equal {}; /// Tag type for the binary == operator. struct equal_to {}; /// Tag type for the binary != operator. struct not_equal_to {}; /// Tag type for the binary || operator. struct logical_or {}; /// Tag type for the binary && operator. struct logical_and {}; /// Tag type for the binary & operator. struct bitwise_and {}; /// Tag type for the binary | operator. struct bitwise_or {}; /// Tag type for the binary ^ operator. struct bitwise_xor {}; /// Tag type for the binary , operator. struct comma {}; /// Tag type for the binary ->* operator. struct mem_ptr {}; /// Tag type for the binary = operator. struct assign {}; /// Tag type for the binary \<\<= operator. struct shift_left_assign {}; /// Tag type for the binary \>\>= operator. struct shift_right_assign {}; /// Tag type for the binary *= operator. struct multiplies_assign {}; /// Tag type for the binary /= operator. struct divides_assign {}; /// Tag type for the binary %= operator. struct modulus_assign {}; /// Tag type for the binary += operator. struct plus_assign {}; /// Tag type for the binary -= operator. struct minus_assign {}; /// Tag type for the binary &= operator. struct bitwise_and_assign {}; /// Tag type for the binary |= operator. struct bitwise_or_assign {}; /// Tag type for the binary ^= operator. struct bitwise_xor_assign {}; /// Tag type for the binary subscript operator. struct subscript {}; /// Tag type for the ternary ?: conditional operator. struct if_else_ {}; /// Tag type for the nary function call operator. struct function {}; }}} #endif
; A175485: Numerators of averages of squares of the first n positive integers. ; 1,5,14,15,11,91,20,51,95,77,46,325,63,145,248,187,105,703,130,287,473,345,188,1225,221,477,770,551,295,1891,336,715,1139,805,426,2701,475,1001,1580,1107,581,3655,638,1335,2093,1457,760,4753,825,1717,2678 mul $0,2 add $0,1 cal $0,27626 ; Denominator of n*(n+5)/((n+2)*(n+3)). dif $0,2 mov $1,$0
/****************************************************************************** * SOFA, Simulation Open-Framework Architecture, development version * * (c) 2006-2017 INRIA, USTL, UJF, CNRS, MGH * * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT * * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * * for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************* * Authors: The SOFA Team and external contributors (see Authors.txt) * * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include <SofaBaseTopology/HexahedronSetTopologyContainer.h> #include <sofa/core/visual/VisualParams.h> #include <sofa/core/ObjectFactory.h> namespace sofa { namespace component { namespace topology { using namespace std; using namespace sofa::defaulttype; SOFA_DECL_CLASS(HexahedronSetTopologyContainer) int HexahedronSetTopologyContainerClass = core::RegisterObject("Hexahedron set topology container") .add< HexahedronSetTopologyContainer >() ; const unsigned int edgesInHexahedronArray[12][2]= {{0,1},{0,3},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},{4,5},{4,7},{5,6},{6,7}}; ///convention quads in hexa (orientation interior) const unsigned int quadsInHexahedronArray[6][4]= {{0,1,2,3}, {4,7,6,5}, {1,0,4,5},{1,5,6,2}, {2,6,7,3}, {0,3,7,4}}; const unsigned int verticesInHexahedronArray[2][2][2]= {{{0,4},{3,7}},{{1,5},{2,6}}}; HexahedronSetTopologyContainer::HexahedronSetTopologyContainer() : QuadSetTopologyContainer() , d_createQuadArray(initData(&d_createQuadArray, bool(false),"createQuadArray", "Force the creation of a set of quads associated with the hexahedra")) , d_hexahedron(initData(&d_hexahedron, "hexahedra", "List of hexahedron indices")) { addAlias(&d_hexahedron, "hexas"); } void HexahedronSetTopologyContainer::addHexa( int a, int b, int c, int d, int e, int f, int g, int h ) { helper::WriteAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; m_hexahedron.push_back(Hexahedron(a,b,c,d,e,f,g,h)); if (a >= getNbPoints()) setNbPoints(a+1); if (b >= getNbPoints()) setNbPoints(b+1); if (c >= getNbPoints()) setNbPoints(c+1); if (d >= getNbPoints()) setNbPoints(d+1); if (e >= getNbPoints()) setNbPoints(e+1); if (f >= getNbPoints()) setNbPoints(f+1); if (g >= getNbPoints()) setNbPoints(g+1); if (h >= getNbPoints()) setNbPoints(h+1); } void HexahedronSetTopologyContainer::init() { QuadSetTopologyContainer::init(); d_hexahedron.updateIfDirty(); // make sure m_hexahedron is up to date // eventually force the creation of quads if (d_createQuadArray.getValue()) createQuadSetArray(); } void HexahedronSetTopologyContainer::createHexahedronSetArray() { #ifndef NDEBUG serr << "Error. [createHexahedronSetArray] This method must be implemented by a child topology." << sendl; #endif } void HexahedronSetTopologyContainer::createEdgeSetArray() { if(hasEdges()) { EdgeSetTopologyContainer::clear(); clearEdgesInQuad(); clearQuadsAroundEdge(); clearEdgesInHexahedron(); clearHexahedraAroundEdge(); } // create a temporary map to find redundant edges std::map<Edge,unsigned int> edgeMap; helper::WriteAccessor< Data< sofa::helper::vector<Edge> > > m_edge = d_edge; helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; /// create the m_edge array at the same time than it fills the m_edgesInHexahedron array for(unsigned int i=0; i<m_hexahedron.size(); ++i) { const Hexahedron &t = m_hexahedron[i]; for(unsigned int j=0; j<12; ++j) { unsigned int v1 = t[edgesInHexahedronArray[j][0]]; unsigned int v2 = t[edgesInHexahedronArray[j][1]]; const Edge e((v1<v2) ? Edge(v1,v2) : Edge(v2,v1)); if(edgeMap.find(e)==edgeMap.end()) { // edge not in edgeMap so create a new one const unsigned int edgeIndex = (unsigned int)edgeMap.size(); edgeMap[e] = edgeIndex; m_edge.push_back(e); } } } } void HexahedronSetTopologyContainer::createEdgesInHexahedronArray() { if(!hasEdges()) createEdgeSetArray(); if(hasEdgesInHexahedron()) clearEdgesInHexahedron(); m_edgesInHexahedron.resize( getNumberOfHexahedra()); helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; for(unsigned int i=0; i<m_hexahedron.size(); ++i) { const Hexahedron &t = m_hexahedron[i]; // adding edge i in the edge shell of both points for(unsigned int j=0; j<12; ++j) { const int edgeIndex = getEdgeIndex(t[edgesInHexahedronArray[j][0]], t[edgesInHexahedronArray[j][1]]); m_edgesInHexahedron[i][j] = edgeIndex; } } } void HexahedronSetTopologyContainer::createQuadSetArray() { d_quad.beginEdit(); if(hasQuads()) { QuadSetTopologyContainer::clear(); clearQuads(); clearQuadsInHexahedron(); clearHexahedraAroundQuad(); } // create a temporary map to find redundant quads std::map<Quad,unsigned int> quadMap; helper::WriteAccessor< Data< sofa::helper::vector<Quad> > > m_quad = d_quad; helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; for(unsigned int i=0; i<m_hexahedron.size(); ++i) { const Hexahedron &h = m_hexahedron[i]; unsigned int v[4], val; // Quad 0 : v[0]=h[0]; v[1]=h[3]; v[2]=h[2]; v[3]=h[1]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val = v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order unsigned int quadIndex; Quad qu(v[0],v[3],v[2],v[1]); std::map<Quad,unsigned int>::iterator itt = quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } // Quad 1 : v[0]=h[4]; v[1]=h[5]; v[2]=h[6]; v[3]=h[7]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val=v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order qu=Quad(v[0],v[3],v[2],v[1]); itt=quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } // Quad 2 : v[0]=h[0]; v[1]=h[1]; v[2]=h[5]; v[3]=h[4]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val=v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order qu=Quad(v[0],v[3],v[2],v[1]); itt=quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } // Quad 3 : v[0]=h[1]; v[1]=h[2]; v[2]=h[6]; v[3]=h[5]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val=v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order qu=Quad(v[0],v[3],v[2],v[1]); itt=quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } // Quad 4 : v[0]=h[2]; v[1]=h[3]; v[2]=h[7]; v[3]=h[6]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val=v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order qu=Quad(v[0],v[3],v[2],v[1]); itt=quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } // Quad 5 : v[0]=h[3]; v[1]=h[0]; v[2]=h[4]; v[3]=h[7]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2]) || (v[0]>v[3])) { val=v[0]; v[0]=v[1]; v[1]=v[2]; v[2]=v[3]; v[3]=val; } // sort vertices in lexicographics order qu=Quad(v[0],v[3],v[2],v[1]); itt=quadMap.find(qu); if(itt==quadMap.end()) { // quad not in edgeMap so create a new one quadIndex=(unsigned int)m_quad.size(); quadMap[qu]=quadIndex; qu=Quad(v[0],v[1],v[2],v[3]); quadMap[qu]=quadIndex; m_quad.push_back(qu); } } d_quad.endEdit(); } void HexahedronSetTopologyContainer::createQuadsInHexahedronArray() { if(!hasQuads()) createQuadSetArray(); if(hasQuadsInHexahedron()) clearQuadsInHexahedron(); m_quadsInHexahedron.resize( getNumberOfHexahedra()); helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; for(unsigned int i = 0; i < getNumberOfHexahedra(); ++i) { const Hexahedron &h=m_hexahedron[i]; int quadIndex; // adding the 6 quads in the quad list of the ith hexahedron i // Quad 0 : quadIndex=getQuadIndex(h[0],h[3],h[2],h[1]); assert(quadIndex!= -1); m_quadsInHexahedron[i][0]=quadIndex; // Quad 1 : quadIndex=getQuadIndex(h[4],h[5],h[6],h[7]); assert(quadIndex!= -1); m_quadsInHexahedron[i][1]=quadIndex; // Quad 2 : quadIndex=getQuadIndex(h[0],h[1],h[5],h[4]); assert(quadIndex!= -1); m_quadsInHexahedron[i][2]=quadIndex; // Quad 3 : quadIndex=getQuadIndex(h[1],h[2],h[6],h[5]); assert(quadIndex!= -1); m_quadsInHexahedron[i][3]=quadIndex; // Quad 4 : quadIndex=getQuadIndex(h[2],h[3],h[7],h[6]); assert(quadIndex!= -1); m_quadsInHexahedron[i][4]=quadIndex; // Quad 5 : quadIndex=getQuadIndex(h[3],h[0],h[4],h[7]); assert(quadIndex!= -1); m_quadsInHexahedron[i][5]=quadIndex; } } void HexahedronSetTopologyContainer::createHexahedraAroundVertexArray() { if(hasHexahedraAroundVertex()) clearHexahedraAroundVertex(); m_hexahedraAroundVertex.resize( getNbPoints() ); helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; for(unsigned int i=0; i<m_hexahedron.size(); ++i) { // adding vertex i in the vertex shell for(unsigned int j=0; j<8; ++j) m_hexahedraAroundVertex[ m_hexahedron[i][j] ].push_back( i ); } } void HexahedronSetTopologyContainer::createHexahedraAroundEdgeArray () { if(!hasEdgesInHexahedron()) createEdgesInHexahedronArray(); if(hasHexahedraAroundEdge()) clearHexahedraAroundEdge(); m_hexahedraAroundEdge.resize(getNumberOfEdges()); for(unsigned int i=0; i<getNumberOfHexahedra(); ++i) { // adding edge i in the edge shell for(unsigned int j=0; j<12; ++j) { m_hexahedraAroundEdge[ m_edgesInHexahedron[i][j] ].push_back( i ); } } } void HexahedronSetTopologyContainer::createHexahedraAroundQuadArray() { if(!hasQuadsInHexahedron()) createQuadsInHexahedronArray(); if(hasHexahedraAroundQuad()) clearHexahedraAroundQuad(); m_hexahedraAroundQuad.resize( getNumberOfQuads()); for(unsigned int i=0; i<getNumberOfHexahedra(); ++i) { // adding quad i in the edge shell of both points for(unsigned int j=0; j<6; ++j) { m_hexahedraAroundQuad[ m_quadsInHexahedron[i][j] ].push_back( i ); } } } const sofa::helper::vector<HexahedronSetTopologyContainer::Hexahedron> &HexahedronSetTopologyContainer::getHexahedronArray() { if(!hasHexahedra() && getNbPoints()>0) { #ifndef NDEBUG sout << "Warning. [HexahedronSetTopologyContainer::getHexahedronArray] creating hexahedron array." << sendl; #endif createHexahedronSetArray(); } return d_hexahedron.getValue (); } int HexahedronSetTopologyContainer::getHexahedronIndex(PointID v1, PointID v2, PointID v3, PointID v4, PointID v5, PointID v6, PointID v7, PointID v8) { if(!hasHexahedraAroundVertex()) createHexahedraAroundVertexArray(); sofa::helper::vector<unsigned int> set1 = getHexahedraAroundVertex(v1); sofa::helper::vector<unsigned int> set2 = getHexahedraAroundVertex(v2); sofa::helper::vector<unsigned int> set3 = getHexahedraAroundVertex(v3); sofa::helper::vector<unsigned int> set4 = getHexahedraAroundVertex(v4); sofa::helper::vector<unsigned int> set5 = getHexahedraAroundVertex(v5); sofa::helper::vector<unsigned int> set6 = getHexahedraAroundVertex(v6); sofa::helper::vector<unsigned int> set7 = getHexahedraAroundVertex(v7); sofa::helper::vector<unsigned int> set8 = getHexahedraAroundVertex(v8); sort(set1.begin(), set1.end()); sort(set2.begin(), set2.end()); sort(set3.begin(), set3.end()); sort(set4.begin(), set4.end()); sort(set5.begin(), set5.end()); sort(set6.begin(), set6.end()); sort(set7.begin(), set7.end()); sort(set8.begin(), set8.end()); // The destination vector must be large enough to contain the result. sofa::helper::vector<unsigned int> out1(set1.size()+set2.size()); sofa::helper::vector<unsigned int>::iterator result1; result1 = std::set_intersection(set1.begin(),set1.end(),set2.begin(),set2.end(),out1.begin()); out1.erase(result1,out1.end()); sofa::helper::vector<unsigned int> out2(set3.size()+out1.size()); sofa::helper::vector<unsigned int>::iterator result2; result2 = std::set_intersection(set3.begin(),set3.end(),out1.begin(),out1.end(),out2.begin()); out2.erase(result2,out2.end()); sofa::helper::vector<unsigned int> out3(set4.size()+out2.size()); sofa::helper::vector<unsigned int>::iterator result3; result3 = std::set_intersection(set4.begin(),set4.end(),out2.begin(),out2.end(),out3.begin()); out3.erase(result3,out3.end()); sofa::helper::vector<unsigned int> out4(set5.size()+out3.size()); sofa::helper::vector<unsigned int>::iterator result4; result4 = std::set_intersection(set5.begin(),set5.end(),out3.begin(),out3.end(),out4.begin()); out4.erase(result4,out4.end()); sofa::helper::vector<unsigned int> out5(set6.size()+out4.size()); sofa::helper::vector<unsigned int>::iterator result5; result5 = std::set_intersection(set6.begin(),set6.end(),out4.begin(),out4.end(),out5.begin()); out5.erase(result5,out5.end()); sofa::helper::vector<unsigned int> out6(set7.size()+out5.size()); sofa::helper::vector<unsigned int>::iterator result6; result6 = std::set_intersection(set7.begin(),set7.end(),out5.begin(),out5.end(),out6.begin()); out6.erase(result6,out6.end()); sofa::helper::vector<unsigned int> out7(set8.size()+out6.size()); sofa::helper::vector<unsigned int>::iterator result7; result7 = std::set_intersection(set8.begin(),set8.end(),out6.begin(),out6.end(),out7.begin()); out7.erase(result7,out7.end()); assert(out7.size()==0 || out7.size()==1); if(out7.size()==1) return (int) (out7[0]); else return -1; } const HexahedronSetTopologyContainer::Hexahedron HexahedronSetTopologyContainer::getHexahedron(HexaID i) { if(!hasHexahedra()) createHexahedronSetArray(); return (d_hexahedron.getValue())[i]; } unsigned int HexahedronSetTopologyContainer::getNumberOfHexahedra() const { return (unsigned int)d_hexahedron.getValue().size(); } unsigned int HexahedronSetTopologyContainer::getNumberOfElements() const { return this->getNumberOfHexahedra(); } const sofa::helper::vector< sofa::helper::vector<unsigned int> > &HexahedronSetTopologyContainer::getHexahedraAroundVertexArray() { if(!hasHexahedraAroundVertex()) createHexahedraAroundVertexArray(); return m_hexahedraAroundVertex; } const sofa::helper::vector< sofa::helper::vector<unsigned int> > &HexahedronSetTopologyContainer::getHexahedraAroundEdgeArray() { if(!hasHexahedraAroundEdge()) createHexahedraAroundEdgeArray(); return m_hexahedraAroundEdge; } const sofa::helper::vector< sofa::helper::vector<unsigned int> > &HexahedronSetTopologyContainer::getHexahedraAroundQuadArray() { if(!hasHexahedraAroundQuad()) createHexahedraAroundQuadArray(); return m_hexahedraAroundQuad; } const sofa::helper::vector< HexahedronSetTopologyContainer::EdgesInHexahedron> &HexahedronSetTopologyContainer::getEdgesInHexahedronArray() { if(!hasEdgesInHexahedron()) createEdgesInHexahedronArray(); return m_edgesInHexahedron; } HexahedronSetTopologyContainer::Edge HexahedronSetTopologyContainer::getLocalEdgesInHexahedron (const EdgeID i) const { assert(i<12); return Edge (edgesInHexahedronArray[i][0], edgesInHexahedronArray[i][1]); } HexahedronSetTopologyContainer::Quad HexahedronSetTopologyContainer::getLocalQuadsInHexahedron (const QuadID i) const { assert(i<6); return Quad (quadsInHexahedronArray[i][0], quadsInHexahedronArray[i][1], quadsInHexahedronArray[i][2], quadsInHexahedronArray[i][3]); } unsigned int HexahedronSetTopologyContainer::getLocalIndexFromBinaryIndex(const HexahedronBinaryIndex bi) const { return(verticesInHexahedronArray[bi[0]][bi[1]][bi[2]]); } HexahedronSetTopologyContainer::HexahedronBinaryIndex HexahedronSetTopologyContainer::getBinaryIndexFromLocalIndex(const unsigned int li) const { HexahedronBinaryIndex bi; if (li==0) bi[0]=0; else bi[0]=1-(((li-1)&2)/2); bi[1]=(li&2)/2; bi[2]=(li&4)/4; return bi; } QuadSetTopologyContainer::QuadID HexahedronSetTopologyContainer::getNextAdjacentQuad(const HexaID _hexaID, const QuadID _quadID, const EdgeID _edgeID) { assert(_hexaID < d_hexahedron.getValue().size()); assert(_quadID<6); assert(_edgeID<12); EdgeID the_edgeID = this->getEdgesInHexahedron(_hexaID)[_edgeID]; const QuadsAroundEdge QaroundE = this->getQuadsAroundEdge(the_edgeID); const QuadsInHexahedron QinH = this->getQuadsInHexahedron(_hexaID); QuadID the_quadID = QinH[_quadID]; QuadID nextQuad = 0; if (QaroundE.size() < 2) { #ifndef NDEBUG serr << "Error: getNextAdjacentQuad: no quad around edge: " << the_edgeID << sendl; #endif return nextQuad; } else if (QaroundE.size() == 2) { if (QaroundE[0] == the_quadID) return (this->getQuadIndexInHexahedron(QinH, QaroundE[1])); else return (this->getQuadIndexInHexahedron(QinH, QaroundE[0])); } else { for (unsigned int i=0; i<QaroundE.size(); ++i) { int res = this->getQuadIndexInHexahedron(QinH, QaroundE[i]); if (res != -1 && QaroundE[i] != the_quadID) return (unsigned int)res; } } return nextQuad; } const sofa::helper::vector< QuadSetTopologyContainer::QuadsInHexahedron> &HexahedronSetTopologyContainer::getQuadsInHexahedronArray() { if(!hasQuadsInHexahedron()) createQuadsInHexahedronArray(); return m_quadsInHexahedron; } const sofa::helper::vector< unsigned int > &HexahedronSetTopologyContainer::getHexahedraAroundVertex(const unsigned int i) { if(!hasHexahedraAroundVertex()) createHexahedraAroundVertexArray(); assert(i < m_hexahedraAroundVertex.size()); return m_hexahedraAroundVertex[i]; } const sofa::helper::vector< unsigned int > &HexahedronSetTopologyContainer::getHexahedraAroundEdge(const unsigned int i) { if(!hasHexahedraAroundEdge()) createHexahedraAroundEdgeArray(); assert(i < m_hexahedraAroundEdge.size()); return m_hexahedraAroundEdge[i]; } const sofa::helper::vector< unsigned int > &HexahedronSetTopologyContainer::getHexahedraAroundQuad(const unsigned int i) { if(!hasHexahedraAroundQuad()) createHexahedraAroundQuadArray(); assert(i < m_hexahedraAroundQuad.size()); return m_hexahedraAroundQuad[i]; } const QuadSetTopologyContainer::EdgesInHexahedron &HexahedronSetTopologyContainer::getEdgesInHexahedron(const QuadID i) { if(!hasEdgesInHexahedron()) createEdgesInHexahedronArray(); assert(i < m_edgesInHexahedron.size()); return m_edgesInHexahedron[i]; } const QuadSetTopologyContainer::QuadsInHexahedron &HexahedronSetTopologyContainer::getQuadsInHexahedron(const QuadID i) { if(!hasQuadsInHexahedron()) createQuadsInHexahedronArray(); assert(i < m_quadsInHexahedron.size()); return m_quadsInHexahedron[i]; } int HexahedronSetTopologyContainer::getVertexIndexInHexahedron(const Hexahedron &t,PointID vertexIndex) const { if(t[0]==vertexIndex) return 0; else if(t[1]==vertexIndex) return 1; else if(t[2]==vertexIndex) return 2; else if(t[3]==vertexIndex) return 3; else if(t[4]==vertexIndex) return 4; else if(t[5]==vertexIndex) return 5; else if(t[6]==vertexIndex) return 6; else if(t[7]==vertexIndex) return 7; else return -1; } int HexahedronSetTopologyContainer::getEdgeIndexInHexahedron(const EdgesInHexahedron &t, const unsigned int edgeIndex) const { if(t[0]==edgeIndex) return 0; else if(t[1]==edgeIndex) return 1; else if(t[2]==edgeIndex) return 2; else if(t[3]==edgeIndex) return 3; else if(t[4]==edgeIndex) return 4; else if(t[5]==edgeIndex) return 5; else if(t[6]==edgeIndex) return 6; else if(t[7]==edgeIndex) return 7; else if(t[8]==edgeIndex) return 8; else if(t[9]==edgeIndex) return 9; else if(t[10]==edgeIndex) return 10; else if(t[11]==edgeIndex) return 11; else return -1; } int HexahedronSetTopologyContainer::getQuadIndexInHexahedron(const QuadsInHexahedron &t, const QuadID quadIndex) const { if(t[0]==quadIndex) return 0; else if(t[1]==quadIndex) return 1; else if(t[2]==quadIndex) return 2; else if(t[3]==quadIndex) return 3; else if(t[4]==quadIndex) return 4; else if(t[5]==quadIndex) return 5; else return -1; } HexahedronSetTopologyContainer::HexahedraAroundEdge &HexahedronSetTopologyContainer::getHexahedraAroundEdgeForModification(const EdgeID i) { if(!hasHexahedraAroundEdge()) createHexahedraAroundEdgeArray(); assert( i < m_hexahedraAroundEdge.size()); return m_hexahedraAroundEdge[i]; } HexahedronSetTopologyContainer::HexahedraAroundVertex &HexahedronSetTopologyContainer::getHexahedraAroundVertexForModification(const PointID i) { if(!hasHexahedraAroundVertex()) createHexahedraAroundVertexArray(); assert( i < m_hexahedraAroundVertex.size()); return m_hexahedraAroundVertex[i]; } HexahedronSetTopologyContainer::HexahedraAroundQuad &HexahedronSetTopologyContainer::getHexahedraAroundQuadForModification(const QuadID i) { if(!hasHexahedraAroundQuad()) createHexahedraAroundQuadArray(); assert( i < m_hexahedraAroundQuad.size()); return m_hexahedraAroundQuad[i]; } bool HexahedronSetTopologyContainer::checkTopology() const { #ifndef NDEBUG bool ret = true; helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; if(hasHexahedraAroundVertex()) { for(unsigned int i=0; i<m_hexahedraAroundVertex.size(); ++i) { const sofa::helper::vector<unsigned int> &tvs = m_hexahedraAroundVertex[i]; for(unsigned int j=0; j<tvs.size(); ++j) { bool check_hexa_vertex_shell = (m_hexahedron[tvs[j]][0]==i) || (m_hexahedron[tvs[j]][1]==i) || (m_hexahedron[tvs[j]][2]==i) || (m_hexahedron[tvs[j]][3]==i) || (m_hexahedron[tvs[j]][4]==i) || (m_hexahedron[tvs[j]][5]==i) || (m_hexahedron[tvs[j]][6]==i) || (m_hexahedron[tvs[j]][7]==i); if(!check_hexa_vertex_shell) { std::cout << "*** CHECK FAILED : check_hexa_vertex_shell, i = " << i << " , j = " << j << std::endl; ret = false; } } } } if(hasHexahedraAroundEdge()) { for(unsigned int i=0; i<m_hexahedraAroundEdge.size(); ++i) { const sofa::helper::vector<unsigned int> &tes=m_hexahedraAroundEdge[i]; for(unsigned int j=0; j<tes.size(); ++j) { bool check_hexa_edge_shell = (m_edgesInHexahedron[tes[j]][0]==i) || (m_edgesInHexahedron[tes[j]][1]==i) || (m_edgesInHexahedron[tes[j]][2]==i) || (m_edgesInHexahedron[tes[j]][3]==i) || (m_edgesInHexahedron[tes[j]][4]==i) || (m_edgesInHexahedron[tes[j]][5]==i) || (m_edgesInHexahedron[tes[j]][6]==i) || (m_edgesInHexahedron[tes[j]][7]==i) || (m_edgesInHexahedron[tes[j]][8]==i) || (m_edgesInHexahedron[tes[j]][9]==i) || (m_edgesInHexahedron[tes[j]][10]==i) || (m_edgesInHexahedron[tes[j]][11]==i); if(!check_hexa_edge_shell) { std::cout << "*** CHECK FAILED : check_hexa_edge_shell, i = " << i << " , j = " << j << std::endl; ret = false; } } } } if(hasHexahedraAroundQuad()) { for(unsigned int i=0; i<m_hexahedraAroundQuad.size(); ++i) { const sofa::helper::vector<unsigned int> &tes=m_hexahedraAroundQuad[i]; for(unsigned int j=0; j<tes.size(); ++j) { bool check_hexa_quad_shell = (m_quadsInHexahedron[tes[j]][0]==i) || (m_quadsInHexahedron[tes[j]][1]==i) || (m_quadsInHexahedron[tes[j]][2]==i) || (m_quadsInHexahedron[tes[j]][3]==i) || (m_quadsInHexahedron[tes[j]][4]==i) || (m_quadsInHexahedron[tes[j]][5]==i); if(!check_hexa_quad_shell) { std::cout << "*** CHECK FAILED : check_hexa_quad_shell, i = " << i << " , j = " << j << std::endl; ret = false; } } } } return ret && QuadSetTopologyContainer::checkTopology(); #else return true; #endif } /// Get information about connexity of the mesh /// @{ bool HexahedronSetTopologyContainer::checkConnexity() { unsigned int nbr = this->getNbHexahedra(); if (nbr == 0) { #ifndef NDEBUG serr << "Warning. [HexahedronSetTopologyContainer::checkConnexity] Can't compute connexity as there are no Hexahedra" << sendl; #endif return false; } VecHexaID elemAll = this->getConnectedElement(0); if (elemAll.size() != nbr) { serr << "Warning: in computing connexity, Hexahedra are missings. There is more than one connexe component." << sendl; return false; } return true; } unsigned int HexahedronSetTopologyContainer::getNumberOfConnectedComponent() { unsigned int nbr = this->getNbHexahedra(); if (nbr == 0) { #ifndef NDEBUG serr << "Warning. [HexahedronSetTopologyContainer::getNumberOfConnectedComponent] Can't compute connexity as there are no Hexahedra" << sendl; #endif return 0; } VecHexaID elemAll = this->getConnectedElement(0); unsigned int cpt = 1; while (elemAll.size() < nbr) { std::sort(elemAll.begin(), elemAll.end()); HexaID other_HexaID = (HexaID)elemAll.size(); for (HexaID i = 0; i<elemAll.size(); ++i) if (elemAll[i] != i) { other_HexaID = i; break; } VecHexaID elemTmp = this->getConnectedElement(other_HexaID); cpt++; elemAll.insert(elemAll.begin(), elemTmp.begin(), elemTmp.end()); } return cpt; } const HexahedronSetTopologyContainer::VecHexaID HexahedronSetTopologyContainer::getConnectedElement(HexaID elem) { if(!hasHexahedraAroundVertex()) // this method should only be called when the shell array exists { #ifndef NDEBUG serr << "Warning. [HexahedronSetTopologyContainer::getConnectedElement] hexahedron vertex shell array is empty." << sendl; #endif createHexahedraAroundVertexArray(); } VecHexaID elemAll; VecHexaID elemOnFront, elemPreviousFront, elemNextFront; bool end = false; unsigned int cpt = 0; const unsigned int nbr = this->getNbHexahedra(); // init algo elemAll.push_back(elem); elemOnFront.push_back(elem); elemPreviousFront.clear(); cpt++; while (!end && cpt < nbr) { // First Step - Create new region elemNextFront = this->getElementAroundElements(elemOnFront); // for each HexaID on the propagation front // Second Step - Avoid backward direction for (unsigned int i = 0; i<elemNextFront.size(); ++i) { bool find = false; HexaID id = elemNextFront[i]; for (HexaID j = 0; j<elemAll.size(); ++j) if (id == elemAll[j]) { find = true; break; } if (!find) { elemAll.push_back(id); elemPreviousFront.push_back(id); } } // cpt for connexity cpt += (unsigned int)elemPreviousFront.size(); if (elemPreviousFront.empty()) { end = true; #ifndef NDEBUG serr << "Loop for computing connexity has reach end." << sendl; #endif } // iterate elemOnFront = elemPreviousFront; elemPreviousFront.clear(); } return elemAll; } const HexahedronSetTopologyContainer::VecHexaID HexahedronSetTopologyContainer::getElementAroundElement(HexaID elem) { VecHexaID elems; if (!hasHexahedraAroundVertex()) { #ifndef NDEBUG serr << "Warning. [HexahedronSetTopologyContainer::getElementAroundElement] hexahedron vertex shell array is empty." << sendl; #endif createHexahedraAroundVertexArray(); } Hexahedron the_hexa = this->getHexahedron(elem); for(unsigned int i = 0; i<8; ++i) // for each node of the hexahedron { HexahedraAroundVertex hexaAV = this->getHexahedraAroundVertex(the_hexa[i]); for (unsigned int j = 0; j<hexaAV.size(); ++j) // for each hexahedron around the node { bool find = false; HexaID id = hexaAV[j]; if (id == elem) continue; for (unsigned int k = 0; k<elems.size(); ++k) // check no redundancy if (id == elems[k]) { find = true; break; } if (!find) elems.push_back(id); } } return elems; } const HexahedronSetTopologyContainer::VecHexaID HexahedronSetTopologyContainer::getElementAroundElements(VecHexaID elems) { VecHexaID elemAll; VecHexaID elemTmp; if (!hasHexahedraAroundVertex()) { #ifndef NDEBUG serr << "Warning. [HexahedronSetTopologyContainer::getElementAroundElements] hexahedron vertex shell array is empty." << sendl; #endif createHexahedraAroundVertexArray(); } for (unsigned int i = 0; i <elems.size(); ++i) // for each HexaID of input vector { VecHexaID elemTmp2 = this->getElementAroundElement(elems[i]); elemTmp.insert(elemTmp.end(), elemTmp2.begin(), elemTmp2.end()); } for (unsigned int i = 0; i<elemTmp.size(); ++i) // for each hexahedron Id found { bool find = false; HexaID id = elemTmp[i]; for (unsigned int j = 0; j<elems.size(); ++j) // check no redundancy with input vector if (id == elems[j]) { find = true; break; } if (!find) { for (unsigned int j = 0; j<elemAll.size(); ++j) // check no redundancy in output vector if (id == elemAll[j]) { find = true; break; } } if (!find) elemAll.push_back(id); } return elemAll; } /// @} bool HexahedronSetTopologyContainer::hasHexahedra() const { d_hexahedron.updateIfDirty(); return !(d_hexahedron.getValue()).empty(); } bool HexahedronSetTopologyContainer::hasEdgesInHexahedron() const { return !m_edgesInHexahedron.empty(); } bool HexahedronSetTopologyContainer::hasQuadsInHexahedron() const { return !m_quadsInHexahedron.empty(); } bool HexahedronSetTopologyContainer::hasHexahedraAroundVertex() const { return !m_hexahedraAroundVertex.empty(); } bool HexahedronSetTopologyContainer::hasHexahedraAroundEdge() const { return !m_hexahedraAroundEdge.empty(); } bool HexahedronSetTopologyContainer::hasHexahedraAroundQuad() const { return !m_hexahedraAroundQuad.empty(); } void HexahedronSetTopologyContainer::clearHexahedra() { helper::WriteAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron; m_hexahedron.clear(); } void HexahedronSetTopologyContainer::clearEdgesInHexahedron() { m_edgesInHexahedron.clear(); } void HexahedronSetTopologyContainer::clearQuadsInHexahedron() { m_quadsInHexahedron.clear(); } void HexahedronSetTopologyContainer::clearHexahedraAroundVertex() { m_hexahedraAroundVertex.clear(); } void HexahedronSetTopologyContainer::clearHexahedraAroundEdge() { m_hexahedraAroundEdge.clear(); } void HexahedronSetTopologyContainer::clearHexahedraAroundQuad() { m_hexahedraAroundQuad.clear(); } void HexahedronSetTopologyContainer::clear() { clearHexahedraAroundVertex(); clearHexahedraAroundEdge(); clearHexahedraAroundQuad(); clearQuadsInHexahedron(); clearEdgesInHexahedron(); clearHexahedra(); QuadSetTopologyContainer::clear(); } void HexahedronSetTopologyContainer::updateTopologyEngineGraph() { // calling real update Data graph function implemented once in PointSetTopologyModifier this->updateDataEngineGraph(this->d_hexahedron, this->m_enginesList); // will concatenate with edges one: QuadSetTopologyContainer::updateTopologyEngineGraph(); } } // namespace topology } // namespace component } // namespace sofa
; A082761: Trinomial transform of the Fibonacci numbers (A000045). ; 1,4,20,104,544,2848,14912,78080,408832,2140672,11208704,58689536,307302400,1609056256,8425127936,44114542592,230986743808,1209462292480,6332826779648,33159111507968,173623361929216,909103725543424,4760128905543680 mov $1,1 lpb $0 sub $0,1 add $2,$1 add $1,$2 mul $1,2 mul $2,2 lpe
; A211466: Number of (n+1) X (n+1) -8..8 symmetric matrices with every 2 X 2 subblock having sum zero and one or two distinct values. ; 25,33,45,65,97,149,233,369,589,945,1521,2453,3961,6401,10349,16737,27073,43797,70857,114641,185485,300113,485585,785685,1271257,2056929,3328173,5385089,8713249,14098325,22811561,36909873,59721421,96631281,156352689,252983957,409336633,662320577,1071657197,1733977761,2805634945,4539612693,7345247625,11884860305,19230107917,31114968209,50345076113,81460044309,131805120409,213265164705,345070285101,558335449793,903405734881,1461741184661,2365146919529,3826888104177,6192035023693,10018923127857,16210958151537,26229881279381,42440839430905,68670720710273,111111560141165,179782280851425,290893840992577,470676121843989,761569962836553,1232246084680529,1993816047517069,3226062132197585,5219878179714641,8445940311912213,13665818491626841,22111758803539041,35777577295165869,57889336098704897,93666913393870753,151556249492575637,245223162886446377,396779412379022001,642002575265468365,1038781987644490353,1680784562909958705,2719566550554449045,4400351113464407737,7119917664018856769,11520268777483264493,18640186441502121249,30160455218985385729,48800641660487506965,78961096879472892681,127761738539960399633,206722835419433292301,334484573959393691921,541207409378826984209,875691983338220676117,1416899392717047660313,2292591376055268336417,3709490768772315996717,6002082144827584333121 mov $1,6 mov $2,4 lpb $0 sub $0,1 mov $3,$2 mov $2,$1 add $1,$3 lpe mul $1,2 add $1,13 mov $0,$1
; PEPE gerado por 'lcc' (IST: prs 2005, 2009) ; 'rl' serve como frame-pointer e 'r0' como acumulador ; os registos 'r1' a 'r10' sao preservados nas chamadas ; global main ; TEXT main: ; ncalls=10 PUSH r9 PUSH r10 PUSH rl MOV rl, sp ; P_argc EQU 8 ; P_argv EQU 10 SUB sp, 2 MOV r10,L2 PUSH r10 CALL prints ADD sp,2 MOV r10, [rl + 8] PUSH r10 CALL printi ADD sp,2 CALL printLN MOV r10,L3 PUSH r10 CALL prints ADD sp,2 MOV r10, 10 ADD r10, rl MOV r10,[r10] MOV r10,[r10] PUSH r10 CALL prints ADD sp,2 CALL printLN MOV r10,1 MOV [rl + -2],r10 JMP L7 L4: MOV r10, [rl + -2] PUSH r10 CALL printi ADD sp,2 MOV r10,L8 PUSH r10 CALL prints ADD sp,2 MOV r10, [rl + -2] SHLA r10,1 MOV r9, 10 ADD r9, rl MOV r9,[r9] MOV r10,[r10 + r9] PUSH r10 CALL prints ADD sp,2 CALL printLN L5: MOV r10, [rl + -2] ADD r10,1 MOV [rl + -2],r10 L7: MOV r10, [rl + -2] MOV r9, [rl + 8] CMP r10,r9 JLT L4 MOV r0, [rl + 8] L1: MOV sp, rl POP rl POP r10 POP r9 RET ; extern printLN ; extern printi ; extern prints ; RODATA L8: STRING " -> ", 0 L3: STRING "prog = ", 0 L2: STRING "argc = ", 0
;[]-----------------------------------------------------------------[] ;| CHECK.ASM -- string checking functions | ;[]-----------------------------------------------------------------[] ; ; $Copyright: 2005$ ; $Revision: 1.1.1.1 $ ; ;bool __fastcall IsDelimiter(const AnsiString& delimiters, int index) const; ;bool __fastcall IsEmpty() const; ;bool __fastcall IsPathDelimiter(int index) const; %include 'constant.inc' ; EXTERN GetSymbol ; EXTERN GetRutfSymbol ; EXTERN CompareSymbol ; EXTERN ConvertSymbol EXTERN ConvertSymbol_table EXTERN CompareSymbol_table GLOBAL @FastString@IsDelimiter$xqqrrx10FastStringui GLOBAL @FastString@IsEmpty$xqqrv GLOBAL @FastString@IsPathDelimiter$xqqrui GLOBAL IsEmpty section _TEXT IsEmpty: mov eax, [eax] or eax, eax jz IsEmpty_exit cmp dword [eax-SIZEOF_FASTSTRING+FastString.Length],0 IsEmpty_exit: ret @FastString@IsDelimiter$xqqrrx10FastStringui: ;in ;eax: this ;edx: delimiters fast string ;ecx: index call IsEmpty jz @FastString@IsDelimiter$xqqrrx10FastStringui_exit push ebx push esi push edi mov esi, [eax] mov edi, edx ; ; mov eax, [esi-SIZEOF_FASTSTRING+FastString.Locale] ; movzx eax, byte [eax-SIZEOF_LOCALE+Locale.Type] movzx eax, word [esi-SIZEOF_FASTSTRING+FastString.CP] shr eax, 12 and eax, 1100b movzx edx, word [edi-SIZEOF_FASTSTRING+FastString.CP] shr edx, 14 call [ConvertSymbol_table+edx*4+eax] ; call GetCPS call [CompareSymbol_table+edx*4] pop edi pop esi pop ebx @FastString@IsDelimiter$xqqrrx10FastStringui_exit: ret @FastString@IsEmpty$xqqrv: call IsEmpty setz al ret @FastString@IsPathDelimiter$xqqrui: ;in ;eax: this ;edx: index call IsEmpty jz @FastString@IsPathDelimiter$xqqrui_exit push ebx mov ebx, [eax] movzx eax, word [ebx-SIZEOF_FASTSTRING+FastString.CP] shr eax, 14 or eax, 1100b call [ConvertSymbol_table+eax] ; call GetRutfSymbol cmp eax, [PathDelimiter] setz al pop ebx @FastString@IsPathDelimiter$xqqrui_exit: ret section _DATA PathDelimiter: dd '/'
; A142006: Primes congruent to 2 mod 31. ; Submitted by Jon Maiga ; 2,157,281,467,653,839,1087,1459,1583,1831,2017,2141,2203,2389,2699,3257,3319,3691,3877,4001,4373,4621,4931,4993,5179,5303,5737,5861,5923,6047,6481,6791,6977,7039,7349,7411,7907,8093,8527,8713,8837,9209,9643,9767,9829,10139,10883,11069,11131,11317,11503,11689,11813,12433,12619,12743,13177,13487,13859,13921,14107,14293,14479,14851,15161,16091,16339,16649,17021,17207,17393,17579,17827,18013,18199,18757,19501,19687,19997,20183,20369,20431,22229,22291,22787,22973,23159,23531,23593,24151,24337,24709 mov $2,36 mul $2,$0 mov $4,1 lpb $2 mov $3,$4 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 mov $1,$0 max $1,0 cmp $1,$0 mul $2,$1 sub $2,1 add $4,31 lpe mov $0,$4 add $0,1
; ; Copyright (c) 2010 The WebM 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 in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" ;void vp9_short_inv_walsh4x4_1_mmx(short *input, short *output) global sym(vp9_short_inv_walsh4x4_1_mmx) PRIVATE sym(vp9_short_inv_walsh4x4_1_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 2 push rsi push rdi ; end prolog mov rsi, arg(0) mov rax, 3 mov rdi, arg(1) add rax, [rsi] ;input[0] + 3 movd mm0, eax punpcklwd mm0, mm0 ;x x val val punpckldq mm0, mm0 ;val val val val psraw mm0, 3 ;(input[0] + 3) >> 3 movq [rdi + 0], mm0 movq [rdi + 8], mm0 movq [rdi + 16], mm0 movq [rdi + 24], mm0 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret ;void vp9_short_inv_walsh4x4_mmx(short *input, short *output) global sym(vp9_short_inv_walsh4x4_mmx) PRIVATE sym(vp9_short_inv_walsh4x4_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 2 push rsi push rdi ; end prolog mov rax, 3 mov rsi, arg(0) mov rdi, arg(1) shl rax, 16 movq mm0, [rsi + 0] ;ip[0] movq mm1, [rsi + 8] ;ip[4] or rax, 3 ;00030003h movq mm2, [rsi + 16] ;ip[8] movq mm3, [rsi + 24] ;ip[12] movq mm7, rax movq mm4, mm0 punpcklwd mm7, mm7 ;0003000300030003h movq mm5, mm1 paddw mm4, mm3 ;ip[0] + ip[12] aka al paddw mm5, mm2 ;ip[4] + ip[8] aka bl movq mm6, mm4 ;temp al paddw mm4, mm5 ;al + bl psubw mm6, mm5 ;al - bl psubw mm0, mm3 ;ip[0] - ip[12] aka d1 psubw mm1, mm2 ;ip[4] - ip[8] aka c1 movq mm5, mm0 ;temp dl paddw mm0, mm1 ;dl + cl psubw mm5, mm1 ;dl - cl ; 03 02 01 00 ; 13 12 11 10 ; 23 22 21 20 ; 33 32 31 30 movq mm3, mm4 ; 03 02 01 00 punpcklwd mm4, mm0 ; 11 01 10 00 punpckhwd mm3, mm0 ; 13 03 12 02 movq mm1, mm6 ; 23 22 21 20 punpcklwd mm6, mm5 ; 31 21 30 20 punpckhwd mm1, mm5 ; 33 23 32 22 movq mm0, mm4 ; 11 01 10 00 movq mm2, mm3 ; 13 03 12 02 punpckldq mm0, mm6 ; 30 20 10 00 aka ip[0] punpckhdq mm4, mm6 ; 31 21 11 01 aka ip[4] punpckldq mm2, mm1 ; 32 22 12 02 aka ip[8] punpckhdq mm3, mm1 ; 33 23 13 03 aka ip[12] ;~~~~~~~~~~~~~~~~~~~~~ movq mm1, mm0 movq mm5, mm4 paddw mm1, mm3 ;ip[0] + ip[12] aka al paddw mm5, mm2 ;ip[4] + ip[8] aka bl movq mm6, mm1 ;temp al paddw mm1, mm5 ;al + bl psubw mm6, mm5 ;al - bl psubw mm0, mm3 ;ip[0] - ip[12] aka d1 psubw mm4, mm2 ;ip[4] - ip[8] aka c1 movq mm5, mm0 ;temp dl paddw mm0, mm4 ;dl + cl psubw mm5, mm4 ;dl - cl ;~~~~~~~~~~~~~~~~~~~~~ movq mm3, mm1 ; 03 02 01 00 punpcklwd mm1, mm0 ; 11 01 10 00 punpckhwd mm3, mm0 ; 13 03 12 02 movq mm4, mm6 ; 23 22 21 20 punpcklwd mm6, mm5 ; 31 21 30 20 punpckhwd mm4, mm5 ; 33 23 32 22 movq mm0, mm1 ; 11 01 10 00 movq mm2, mm3 ; 13 03 12 02 punpckldq mm0, mm6 ; 30 20 10 00 aka ip[0] punpckhdq mm1, mm6 ; 31 21 11 01 aka ip[4] punpckldq mm2, mm4 ; 32 22 12 02 aka ip[8] punpckhdq mm3, mm4 ; 33 23 13 03 aka ip[12] paddw mm0, mm7 paddw mm1, mm7 paddw mm2, mm7 paddw mm3, mm7 psraw mm0, 3 psraw mm1, 3 psraw mm2, 3 psraw mm3, 3 movq [rdi + 0], mm0 movq [rdi + 8], mm1 movq [rdi + 16], mm2 movq [rdi + 24], mm3 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret
; Z88 Small C+ Graphics Functions ; Draw a circle on the Z88 map ; Adapted from my Spectrum Routine ; (C) 1995-1998 D.J.Morris ; ; HiRez, NO radius correction square pixels assumed ; variant: no table on stack, only one index register is used ; ; $Id: w_dcircle.asm $ ; SECTION code_clib PUBLIC w_draw_circle EXTERN l_graphics_cmp ;Entry: ; de = x0, hl = y0, bc = radius, a = scale factor ; b=x0 c=y0, d=radius, e=scale factor ; ix=plot routine .w_draw_circle ;ld (w_pix+1),ix ; ld ix,-11 ;create buffer on stack ; add ix,sp ; ld sp,ix ld a,1 ld (scale),a ;step factor - usually 1 ld (x0l),de ld (y0l),hl ld (rlv),bc ;call l9900 ;ld hl,11 ;add hl,sp ;ld sp,hl ;ret ;Line 9900 .l9900 xor a ld (cxl),a ld (cxh),a srl b rr c ld (dal),bc ;Line 9905 .l9905 ld bc,(rlv) ld de,(cxl) ld h,b ld l,c call l_graphics_cmp ret nc ;Line 9910 ld a,(dahi) bit 7,a jr z,l9915 ld bc,(dal) ld hl,(rlv) add hl,bc ld b,h ld c,l ld (dal),bc ld de,(rlv) ld a,(scale) ld c,a ld b,0 ld h,d ld l,e or a; CY = 0 sbc hl,bc ld b,h ld c,l ld (rlv),bc ;Line 9915 .l9915 ld bc,(dal) dec bc ld h,b ld l,c ld de,(cxl) or a sbc hl,de ld b,h ld c,l ld (dal),bc .l9920 ld bc,(y0l) ld de,(rlv) srl d rr e ld h,b ld l,c add hl,de push hl ld bc,(x0l) ld de,(cxl) ld h,b ld l,c add hl,de pop de call do_w_plot; (cx,r) ld bc,(y0l) ld de,(rlv) srl d rr e ld h,b ld l,c add hl,de push hl ld bc,(x0l) ld de,(cxl) ld h,b ld l,c or a sbc hl,de pop de call do_w_plot; (-cx,r) ld bc,(y0l) ld de,(rlv) srl d rr e ld h,b ld l,c or a sbc hl,de push hl ld bc,(x0l) ld de,(cxl) ld h,b ld l,c add hl,de pop de call do_w_plot; (cx,-r) ld bc,(y0l) ld de,(rlv) srl d rr e ld h,b ld l,c or a sbc hl,de push hl ld bc,(x0l) ld de,(cxl) ld h,b ld l,c or a sbc hl,de pop de call do_w_plot; (-cx,-r) ld bc,(y0l) ld de,(cxl) srl d rr e ld h,b ld l,c add hl,de push hl ld bc,(x0l) ld de,(rlv) ld h,b ld l,c add hl,de pop de call do_w_plot; (r,cx) ld bc,(y0l) ld de,(cxl) srl d rr e ld h,b ld l,c add hl,de push hl ld bc,(x0l) ld de,(rlv) ld h,b ld l,c or a sbc hl,de pop de call do_w_plot; (-r,cx) ld bc,(y0l) ld de,(cxl) srl d rr e ld h,b ld l,c or a sbc hl,de push hl ld bc,(x0l) ld de,(rlv) ld h,b ld l,c add hl,de pop de call do_w_plot; (r,-cx) ld bc,(y0l) ld de,(cxl) srl d rr e ld h,b ld l,c or a sbc hl,de push hl ld bc,(x0l) ld de,(rlv) ld h,b ld l,c or a sbc hl,de pop de call do_w_plot ; (-r,-cx) ld bc,(cxl) ld a,(scale) ld e,a ld d,0 ld h,b ld l,c add hl,de ld b,h ld c,l ld (cxl),bc jp l9905 SECTION smc_clib .do_w_plot jp (ix) SECTION bss_clib .x0l defb 0 .x0h defb 0 .y0l defb 0 .y0h defb 0 .rlv defb 0 .rh defb 0 .cxl defb 0 .cxh defb 0 .dal defb 0 .dahi defb 0 .scale defb 0
; void z180_delay_tstate_fastcall(uint tstates) SECTION code_clib SECTION code_z180 PUBLIC _z180_delay_tstate_fastcall EXTERN asm_z180_delay_tstate defc _z180_delay_tstate_fastcall = asm_z180_delay_tstate
SECTION code_clib PUBLIC getmaxy PUBLIC _getmaxy EXTERN __console_h EXTERN __laser500_mode getmaxy: _getmaxy: ld hl,191 ld a,(__laser500_mode) cp 2 ret z ld a,(__console_h) add a dec a ld l,a ld h,0 ret
; A015513: a(1)=1, a(n) = sum_{k=1}^{k=n-1} (11^k-1)/10 a(k). ; Submitted by Jon Maiga ; 1,1,13,1742,2552030,41102995180,7281683317103260,14189947350338830620680,304174136317707285574697584520,71722670512982436329410134761448960400,186030135925835196854820049614502274473787544400 lpb $0 lpb $0 mov $0,10 lpe add $0,3 lpe sub $0,1 mov $1,1 mov $2,1 lpb $0 sub $0,1 mul $2,11 add $2,2 mul $1,$2 sub $2,1 lpe mov $0,$1
// (C) Copyright Jeremy Siek 2002. // 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) #ifndef BOOST_ITERATOR_CONCEPTS_HPP #define BOOST_ITERATOR_CONCEPTS_HPP #include "Utilogeny/lib/boost/concept_check.hpp" #include "Utilogeny/lib/boost/iterator/iterator_categories.hpp" #include "Utilogeny/lib/boost/type_traits/is_same.hpp" #include "Utilogeny/lib/boost/type_traits/is_integral.hpp" #include "Utilogeny/lib/boost/mpl/bool.hpp" #include "Utilogeny/lib/boost/mpl/if.hpp" #include "Utilogeny/lib/boost/mpl/and.hpp" #include "Utilogeny/lib/boost/mpl/or.hpp" #include "Utilogeny/lib/boost/static_assert.hpp" // Use Utilogeny/lib/boost/limits to work around missing limits headers on some compilers #include "Utilogeny/lib/boost/limits.hpp" #include "Utilogeny/lib/boost/config.hpp" #include <algorithm> #include <iterator> #include "Utilogeny/lib/boost/concept/detail/concept_def.hpp" namespace boost_concepts { // Used a different namespace here (instead of "boost") so that the // concept descriptions do not take for granted the names in // namespace boost. //=========================================================================== // Iterator Access Concepts BOOST_concept(ReadableIterator,(Iterator)) : boost::Assignable<Iterator> , boost::CopyConstructible<Iterator> { typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type value_type; typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference reference; BOOST_CONCEPT_USAGE(ReadableIterator) { value_type v = *i; boost::ignore_unused_variable_warning(v); } private: Iterator i; }; template < typename Iterator , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type > struct WritableIterator : boost::CopyConstructible<Iterator> { BOOST_CONCEPT_USAGE(WritableIterator) { *i = v; } private: ValueType v; Iterator i; }; template < typename Iterator , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type > struct WritableIteratorConcept : WritableIterator<Iterator,ValueType> {}; BOOST_concept(SwappableIterator,(Iterator)) { BOOST_CONCEPT_USAGE(SwappableIterator) { std::iter_swap(i1, i2); } private: Iterator i1; Iterator i2; }; BOOST_concept(LvalueIterator,(Iterator)) { typedef typename std::iterator_traits<Iterator>::value_type value_type; BOOST_CONCEPT_USAGE(LvalueIterator) { value_type& r = const_cast<value_type&>(*i); boost::ignore_unused_variable_warning(r); } private: Iterator i; }; //=========================================================================== // Iterator Traversal Concepts BOOST_concept(IncrementableIterator,(Iterator)) : boost::Assignable<Iterator> , boost::CopyConstructible<Iterator> { typedef typename boost::iterator_traversal<Iterator>::type traversal_category; BOOST_CONCEPT_ASSERT(( boost::Convertible< traversal_category , boost::incrementable_traversal_tag >)); BOOST_CONCEPT_USAGE(IncrementableIterator) { ++i; (void)i++; } private: Iterator i; }; BOOST_concept(SinglePassIterator,(Iterator)) : IncrementableIterator<Iterator> , boost::EqualityComparable<Iterator> { BOOST_CONCEPT_ASSERT(( boost::Convertible< BOOST_DEDUCED_TYPENAME SinglePassIterator::traversal_category , boost::single_pass_traversal_tag > )); }; BOOST_concept(ForwardTraversal,(Iterator)) : SinglePassIterator<Iterator> , boost::DefaultConstructible<Iterator> { typedef typename std::iterator_traits<Iterator>::difference_type difference_type; BOOST_MPL_ASSERT((boost::is_integral<difference_type>)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true); BOOST_CONCEPT_ASSERT(( boost::Convertible< BOOST_DEDUCED_TYPENAME ForwardTraversal::traversal_category , boost::forward_traversal_tag > )); }; BOOST_concept(BidirectionalTraversal,(Iterator)) : ForwardTraversal<Iterator> { BOOST_CONCEPT_ASSERT(( boost::Convertible< BOOST_DEDUCED_TYPENAME BidirectionalTraversal::traversal_category , boost::bidirectional_traversal_tag > )); BOOST_CONCEPT_USAGE(BidirectionalTraversal) { --i; (void)i--; } private: Iterator i; }; BOOST_concept(RandomAccessTraversal,(Iterator)) : BidirectionalTraversal<Iterator> { BOOST_CONCEPT_ASSERT(( boost::Convertible< BOOST_DEDUCED_TYPENAME RandomAccessTraversal::traversal_category , boost::random_access_traversal_tag > )); BOOST_CONCEPT_USAGE(RandomAccessTraversal) { i += n; i = i + n; i = n + i; i -= n; i = i - n; n = i - j; } private: typename BidirectionalTraversal<Iterator>::difference_type n; Iterator i, j; }; //=========================================================================== // Iterator Interoperability namespace detail { template <typename Iterator1, typename Iterator2> void interop_single_pass_constraints(Iterator1 const& i1, Iterator2 const& i2) { bool b; b = i1 == i2; b = i1 != i2; b = i2 == i1; b = i2 != i1; boost::ignore_unused_variable_warning(b); } template <typename Iterator1, typename Iterator2> void interop_rand_access_constraints( Iterator1 const& i1, Iterator2 const& i2, boost::random_access_traversal_tag, boost::random_access_traversal_tag) { bool b; typename std::iterator_traits<Iterator2>::difference_type n; b = i1 < i2; b = i1 <= i2; b = i1 > i2; b = i1 >= i2; n = i1 - i2; b = i2 < i1; b = i2 <= i1; b = i2 > i1; b = i2 >= i1; n = i2 - i1; boost::ignore_unused_variable_warning(b); boost::ignore_unused_variable_warning(n); } template <typename Iterator1, typename Iterator2> void interop_rand_access_constraints( Iterator1 const&, Iterator2 const&, boost::single_pass_traversal_tag, boost::single_pass_traversal_tag) { } } // namespace detail BOOST_concept(InteroperableIterator,(Iterator)(ConstIterator)) { private: typedef typename boost::iterators::pure_iterator_traversal<Iterator>::type traversal_category; typedef typename boost::iterators::pure_iterator_traversal<ConstIterator>::type const_traversal_category; public: BOOST_CONCEPT_ASSERT((SinglePassIterator<Iterator>)); BOOST_CONCEPT_ASSERT((SinglePassIterator<ConstIterator>)); BOOST_CONCEPT_USAGE(InteroperableIterator) { detail::interop_single_pass_constraints(i, ci); detail::interop_rand_access_constraints(i, ci, traversal_category(), const_traversal_category()); ci = i; } private: Iterator i; ConstIterator ci; }; } // namespace boost_concepts #include "Utilogeny/lib/boost/concept/detail/concept_undef.hpp" #endif // BOOST_ITERATOR_CONCEPTS_HPP
; A175068: a(n) = product of perfect divisors of n. ; 1,2,3,8,5,6,7,16,27,10,11,12,13,14,15,128,17,18,19,20,21,22,23,24,125,26,81,28,29,30,31,64,33,34,35,216,37,38,39,40,41,42,43,44,45,46,47,48,343,50,51,52,53,54,55,56,57,58,59,60,61,62,63,4096,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,2187,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,1000 add $0,1 mov $1,1 mov $2,2 mov $3,$0 mov $4,$0 lpb $3 mov $5,$4 lpb $5 mov $7,$0 div $0,$2 mod $7,$2 cmp $7,0 sub $5,$7 lpe cmp $6,0 div $6,$0 mov $0,$4 mov $7,$2 pow $7,$6 mul $1,$7 add $2,1 mov $7,$4 cmp $7,1 cmp $7,0 sub $3,$7 lpe mov $0,$1
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: UserInterface/Gen FILE: GenDynamicList.asm ROUTINES: Name Description ---- ----------- GLB GenDynamicListClass Dynamic list object REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 1/92 Initial version DESCRIPTION: This file contains routines to implement the dynamic list class. $Id: genDynamicList.asm,v 1.1 97/04/07 11:45:35 newdeal Exp $ ------------------------------------------------------------------------------@ ; see documentation in /staff/pcgeos/Library/User/Doc/GenDynamicList.doc UserClassStructures segment resource ; Declare the class record GenDynamicListClass UserClassStructures ends ;--------------------------------------------------- Build segment resource COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListBuild -- MSG_META_RESOLVE_VARIANT_SUPERCLASS for GenDynamicListClass DESCRIPTION: Return the correct specific class for an object PASS: *ds:si - instance data (for object in a GenXXXX class) es - segment of GenClass ax - MSG_META_RESOLVE_VARIANT_SUPERCLASS cx - master offset of variant class to build RETURN: cx:dx - class for specific UI part of object (cx = 0 for no build) ALLOWED TO DESTROY: ax, bp bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 5/89 Initial version ------------------------------------------------------------------------------@ GenDynamicListBuild method GenDynamicListClass, MSG_META_RESOLVE_VARIANT_SUPERCLASS mov ax, SPIR_BUILD_DYNAMIC_LIST GOTO GenQueryUICallSpecificUI GenDynamicListBuild endm COMMENT @---------------------------------------------------------------------- GenDynamicListRelocOrUnReloc DESCRIPTION: relocate or unrelocate dynamic list SPECIAL NOTE: This routine is run by the application's process thread. PASS: *ds:si - instance data ax - MSG_META_RELOCATE/MSG_META_UNRELOCATE cx - handle of block containing relocation dx - VMRelocType: VMRT_UNRELOCATE_BEFORE_WRITE VMRT_RELOCATE_AFTER_READ VMRT_RELOCATE_AFTER_WRITE bp - data to pass to ObjRelocOrUnRelocSuper RETURN: carry - set if error bp - unchanged RETURN: carry clear to indicate successful relocation! ALLOWED TO DESTROY: ax, cx, dx bx, si, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 7/89 Initial version ------------------------------------------------------------------------------@ GenDynamicListRelocOrUnReloc method GenDynamicListClass, reloc ; We only need to handle unrelocation, where ; this object is about to go out to a state ; file. cmp ax, MSG_META_UNRELOCATE je unrelocateDynamicList ;relocateDynamicList: EC < tst [di].GI_comp.CP_firstChild.handle > EC < ERROR_NZ UI_DYNAMIC_LIST_MAY_NOT_HAVE_STATIC_CHILDREN > jmp done unrelocateDynamicList: ; Clear out our generic child link. All ; generic children created by the specific UI ; should be created as IGNORE_DIRTY, so that ; they will be tossed before going into the ; state file. We do NOT want to leave ; a link in this object pointing ; off in to space, now, do we? No. clr ax mov [di].GI_comp.CP_firstChild.handle, ax mov [di].GI_comp.CP_firstChild.chunk, ax done: clc mov di, offset GenDynamicListClass call ObjRelocOrUnRelocSuper ret GenDynamicListRelocOrUnReloc endm Build ends DynaCommon segment resource DC_DerefGenDI proc near mov di, ds:[si] add di, ds:[di].Gen_offset ret DC_DerefGenDI endp DC_ObjCallInstanceNoLock proc near call ObjCallInstanceNoLock ret DC_ObjCallInstanceNoLock endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListGetItemClass -- MSG_GEN_DYNAMIC_LIST_GET_ITEM_CLASS for GenDynamicListClass DESCRIPTION: Returns item class. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_GET_ITEM_CLASS RETURN: cx:dx - class to use for item ax, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 4/13/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListGetItemClass method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_GET_ITEM_CLASS mov cx, segment GenItemClass mov dx, offset GenItemClass ret GenDynamicListGetItemClass endm COMMENT @---------------------------------------------------------------------- ROUTINE: ItemsChangedCallback SYNOPSIS: Validates items that need changing. CALLED BY: ObjCompProcessChildren(via GenDynamicListNumVisibleItemsChanged) (via GenDynamicListSetNumItems) PASS: *ds:si - item *es:di - parentu cx - generic position of item dx - position of first item needing changing bp - identifier of item RETURN: carry clear to do all children DESTROYED: ax, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ ItemsChangedCallback proc far class GenDynamicListClass .warn -unref_local numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word mov bx, bp .enter mov moveIdentifierFlag, si ;need to set this non-zero ; so identifiers will be set ; ; Validate all items past the first item needing changing. ; cmp cx, dx ;needs changing? jb skipItem ;no, skip item push dx mov dx, bx call ValidateItem ;else validate the item pop dx skipItem: inc cx ;bump position clc ;continue .leave inc bp ;bump identifier .warn @unref_local ret ItemsChangedCallback endp COMMENT @---------------------------------------------------------------------- ROUTINE: RemoveItemsCallback SYNOPSIS: Removes the appropriate number of items. CALLED BY: GenDynamicListNumVisibleItemsChanged PASS: *ds:si -- item cx -- position dx -- first item to remove RETURN: nothing DESTROYED: ax, bp, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ RemoveItemsCallback proc far class GenClass cmp cx, dx jb skipItem ;nothing to remove, continue push cx, dx clr bp ;shouldn't dirty mov ax, MSG_GEN_DESTROY mov dl, VUM_DELAYED_VIA_UI_QUEUE ; was VUM_NOW , but causes ; problems when initializes ; are done during UPDATE_UI,i.e. ; a VIS_OPEN. -cbh 3/ 9/93 call DC_ObjCallInstanceNoLock ;else remove ourselves ; mov dl, VUM_NOW ; mov bx, ds:[LMBH_handle] ; mov di, mask MF_FORCE_QUEUE or mask MF_INSERT_AT_FRONT ; call ObjMessage pop cx, dx skipItem: inc cx ;bump position clc ;continue ret RemoveItemsCallback endp COMMENT @---------------------------------------------------------------------- ROUTINE: ValidateItem SYNOPSIS: Validates an item, requesting its moniker, etc. CALLED BY: ItemsChangedCallback ForwardSetMkrs BackwardSetMkrs PASS: *ds:si -- item *es:di -- dynamic list dx -- item identifier RETURN: nothing DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ ValidateItem proc near uses ax, cx, dx, bp, si numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word class GenDynamicListClass .enter inherit ; ; Set the identifier for the item. ; tst moveIdentifierFlag ;not moving identifiers, branch jz 5$ push dx mov cx, dx mov ax, MSG_GEN_ITEM_SET_IDENTIFIER call DC_ObjCallInstanceNoLock pop dx 5$: ; ; First, see if this item should even be displayed (we may be at the ; end of the list, and we may not have enough items to fill the screen) ; call ItemEnsuredUsable jnc exit ;not usable, exit ; ; Nuke the existing moniker, set not interactable, and redraw. ; push di ;save list call NukeExistingMoniker clr cx mov ax, MSG_GEN_ITEM_SET_INTERACTABLE_STATE call GenCallSpecIfGrown ; ; Now assume the item will be enabled, and set it as such. The specific ; may (read: will) expect to get a MSG_SPEC_NOTIFY_NOT_ENABLED for the ; new item if it turns out to be disabled when the moniker comes in from ; the app, so it can deal with keyboard navigation correctly. ; -cbh 6/24/92 (Changed to VUM_DELAYED..., as updates aren't readily ; happening anymore. -cbh 5/19/93) ; mov dl, VUM_DELAYED_VIA_UI_QUEUE ;update done below... mov ax, MSG_GEN_SET_ENABLED ;assume enabled call ObjCallInstanceNoLock ;else set enabled ; ; Query for the item's moniker. ; call DC_DerefGenDI .warn -private mov bp, ds:[di].GII_identifier ;pass identifier (not necessary ; the same as that passed in!) .warn @private pop si ;restore list mov di, 700 call ThreadBorrowStackSpace push di mov cx, ds:[LMBH_handle] ;ourselves in ^lcx:dx mov dx, si mov bx, ds:[LMBH_handle] mov di, mask MF_FORCE_QUEUE ;don't do this immediately! ; my attempts to optimally ; draw when all items become ; interactable will fail.5/20/93 mov ax, MSG_GEN_DYNAMIC_LIST_QUERY_ITEM_MONIKER call ObjMessage pop di call ThreadReturnStackSpace exit: .leave ret ValidateItem endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListQueryItemMoniker -- MSG_GEN_DYNAMIC_LIST_QUERY_ITEM_MONIKER for GenDynamicListClass DESCRIPTION: A dynamic list sends this to itself to query for an item's moniker. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_QUERY_ITEM_MONIKER ^lcx:dx - calling dynamic list bp - item to get moniker for RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 4/ 1/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListQueryItemMoniker method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_QUERY_ITEM_MONIKER mov ax, ds:[di].GDLI_queryMsg ;get query message tst ax jz exit ;none specified, exit mov bx, offset GIGI_destination call GenGetDWord ; destination in ^lcx:dx push cx, dx ; push them for GenProcessAction mov cx, ds:[LMBH_handle] ; ^lcx:dx <- ourselves mov dx, si mov di, mask MF_FIXUP_DS call GenProcessAction ; send the message exit: ret GenDynamicListQueryItemMoniker endm COMMENT @---------------------------------------------------------------------- ROUTINE: ItemEnsuredUsable SYNOPSIS: Ensures that an item is usable. Sets the item usable or not usable as needed. An item is set not usable if its identifier is outside the number of items. CALLED BY: ValidateItem, StoreItemInfo PASS: *ds:si -- item *ds:di -- dynamic list dx -- item identifier RETURN: carry set if item should be usable DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ ItemEnsuredUsable proc near uses di, cx, ax class GenDynamicListClass .enter mov di, ds:[di] ;dynamic list instance add di, ds:[di].Gen_offset cmp dx, ds:[di].GDLI_numItems ;see if within number of items jae setNotUsable ;no, branch to set not usable mov ch, TRUE stc ;set usable jmp short finish setNotUsable: clr ch ;don't set usable clc ;return not usable finish: pushf mov cl, mask GS_USABLE call SetGenState popf .leave ret ItemEnsuredUsable endp COMMENT @---------------------------------------------------------------------- ROUTINE: SetGenState SYNOPSIS: Sets or clears a GenStates flag. CALLED BY: ValidateItem, ObjectEnsuredUsable, StoreItemInfo PASS: *ds:si -- item cl -- GS_ENABLED or GS_USABLE ch -- non-zero to set, zero to clear RETURN: nothing DESTROYED: ax, cx, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ SetGenState proc near class GenClass call DC_DerefGenDI tst ch jz clearing ;clearing, branch ;setting: mov ax, MSG_GEN_SET_ENABLED test cl, mask GS_ENABLED jnz 10$ mov ax, MSG_GEN_SET_USABLE 10$: test ds:[di].GI_states, cl jnz exit jmp short update clearing: mov ax, MSG_GEN_SET_NOT_ENABLED test cl, mask GS_ENABLED jnz 15$ mov ax, MSG_GEN_SET_NOT_USABLE 15$: test ds:[di].GI_states, cl jz exit update: push dx, bp mov dl, VUM_DELAYED_VIA_UI_QUEUE ;VUM_MANUAL doesn't seem to work ;VUM_NOW works, but causes ; problems when initializes ; are done during UPDATE_UI,i.e. ; a VIS_OPEN. -cbh 2/12/93 call DC_ObjCallInstanceNoLock ; mov dl, VUM_NOW ; mov bx, ds:[LMBH_handle] ; mov di, mask MF_FORCE_QUEUE or mask MF_INSERT_AT_FRONT ; call ObjMessage pop dx, bp exit: ret SetGenState endp COMMENT @---------------------------------------------------------------------- ROUTINE: NukeExistingMoniker SYNOPSIS: Nukes any moniker that's already there. CALLED BY: ValidateItem PASS: *ds:si -- item RETURN: nothing DESTROYED: di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ NukeExistingMoniker proc near uses ax class GenClass .enter call DC_DerefGenDI clr ax xchg ax, ds:[di].GI_visMoniker tst ax jz 10$ call LMemFree ;nuke the moniker 10$: .leave ret NukeExistingMoniker endp COMMENT @---------------------------------------------------------------------- ROUTINE: DoAllChildren SYNOPSIS: Processes all the dynamic list's generic children. CALLED BY: utility PASS: *ds:si -- parent di -- offset of routine to call cx, dx, bp -- anything passed RETURN: cx, dx, bp -- anything returned DESTROYED: ax, bx, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/16/92 Initial version ------------------------------------------------------------------------------@ DoAllChildren proc far class GenClass ; mov bx, ds:[si] ; add bx, ds:[bx].Gen_offset ; tst ds:[bx].GI_comp.CP_firstChild.handle ; jz exit ;no children, exit ; clr bx ;initial child (first push bx ; child of push bx ; composite) mov bx,offset GI_link ;pass offset to LinkPart push bx NOFXIP < push cs ;push call-back routine > FXIP < mov bx, SEGMENT_CS > FXIP < push bx > mov bx, di push bx ;pass callback routine (off) mov bx,offset Gen_offset ;pass offset to master part mov di,offset GI_comp ;pass offset to composite call ObjCompProcessChildren ;exit: ret DoAllChildren endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListReplaceItemMoniker -- MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER DESCRIPTION: Copys the moniker for the item passed. This is basically a preprocessor for MSG_GEN_REPLACE_VIS_MONIKER. It will first check to see if the dynamic list item the moniker is intended for is still on the screen. If not, then it will exit. If so, then it will first set any state flags for the item if it has any exclusives. Then it will pass the moniker through to MSG_GEN_REPLACE_VIS_MONIKER. It will always try to replace the moniker, since one will be created if there wasn't originally a moniker assigned to it. PASS: *ds:si - instance data es - segment of GenDynamicListClass ax - MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER dx - # of bytes on stack ss:bp - ReplaceItemMonikerFrame (For XIP'ed geodes, the fptrs in the ReplaceItemMonikerFrame *cannot* be pointing into the movable XIP code seg.) RETURN: nothing DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Clayton 12/89 Initial version ------------------------------------------------------------------------------@ GenDynamicListReplaceItemMoniker method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER uses ax,dx,si .enter if FULL_EXECUTE_IN_PLACE ; ; Make sure the fptr passed in is valid ; EC < cmp ss:[bp].RIMF_sourceType, VMST_FPTR > EC < jne xipSafe > EC < cmp ss:[bp].RIMF_dataType, VMDT_NULL > EC < je xipSafe > EC < pushdw bxsi > EC < movdw bxsi, ss:[bp].RIMF_source > EC < call ECAssertValidFarPointerXIP > EC < popdw bxsi > EC < xipSafe: > endif ; ; First, get the item being referenced in ^lbx:si. If the object ; isn't found, it probably got moved offscreen -- just exit. ; call GetItemOptr jnc done ;not found, done ; ; Enable the item if needed. ; push si, ax movdw bxsi, cxdx ;now in ^lbx:si mov ax, MSG_GEN_SET_ENABLED ;assume enabled test ss:[bp].RIMF_itemFlags, mask RIMF_NOT_ENABLED jz 10$ ;should enable, branch mov ax, MSG_GEN_SET_NOT_ENABLED 10$: mov dl, VUM_DELAYED_VIA_UI_QUEUE ;update no longer done below. mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessageBp ;else set enabled pop dx, ax ;*ds:dx <- item group ;ax <- identifier ; ; Alas, if we disabled the item, we must re-check our item's optr, ; since it might have caused the list to scroll around, changing things. ; test ss:[bp].RIMF_itemFlags, mask RIMF_NOT_ENABLED jz 20$ ;is enabled, branch mov si, dx ;*ds:si <- item group mov cx, ax ;cx <- identifier call GetItemOptr jnc done ;no longer visible, exit movdw bxsi, cxdx ;now in ^lbx:si 20$: ; ; Now copy the moniker to the object. ; ss:bp = ReplaceItemMonikerFrame (extension of ; ReplaceVisMonikerFrame) ; ; We will assume a VUM_DELAYED_VIA_UI_QUEUE on the assumption that we ; only want a single update to happen. The specific UI can (and will, ; for the scrolling version) subclass MSG_SPEC_UPDATE_VIS_MONIKER to ; change the update mode. ; mov ss:[bp].RVMF_updateMode, VUM_DELAYED_VIA_APP_QUEUE mov dx, size ReplaceVisMonikerFrame mov ax, MSG_GEN_REPLACE_VIS_MONIKER mov di, mask MF_STACK or mask MF_CALL or mask MF_FIXUP_DS call ObjMessageBp ; ; Mark the item interactable again. ; mov cx, si ;cx != 0 mov ax, MSG_GEN_ITEM_SET_INTERACTABLE_STATE mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessageBp done: .leave GOTO GenCallSpecIfGrown GenDynamicListReplaceItemMoniker endm ObjMessageBp proc near push bp call ObjMessage pop bp ret ObjMessageBp endp COMMENT @---------------------------------------------------------------------- ROUTINE: GetItemOptr SYNOPSIS: Returns item optr CALLED BY: GenDynamicListReplaceItemMoniker PASS: *ds:si -- item group ss:bp -- ReplaceItemMonikerFrame RETURN: ^lcx:dx -- item ax -- identifier carry set if not found DESTROYED: cx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/25/92 Initial version ------------------------------------------------------------------------------@ GetItemOptr proc near ; ; First, get the item being referenced in ^lbx:si. If the object ; isn't found, it probably got moved offscreen -- just exit. ; mov cx, ss:[bp].RIMF_item ;get the item number push bp push cx mov ax, MSG_GEN_ITEM_GROUP_GET_ITEM_OPTR call DC_ObjCallInstanceNoLock ;item in ^lcx:dx pop ax pop bp ret GetItemOptr endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListViewOriginChanged -- MSG_GEN_DYNAMIC_LIST_TOP_ITEM_CHANGED for GenDynamicListClass DESCRIPTION: View's origin changed. PASS: *ds:si - instance data ds:di - GenInstance es - segment of MetaClass ax - MSG_META_CONTENT_VIEW_ORIGIN_CHANGED cx - top item dx - previous top item bp - number of visible items RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/ 5/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListViewOriginChanged method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_TOP_ITEM_CHANGED clr ax ;scroll all the way up ; mov di, -1 ;need to move identifiers ; (di already non-zero by ; definition of method handler) call GenDynamicListScroll ret GenDynamicListViewOriginChanged endm COMMENT @---------------------------------------------------------------------- ROUTINE: GenDynamicListScroll SYNOPSIS: Scrolls some items in a dynamic list. CALLED BY: GenDynamicListTopItemChanged GenDynamicListDeleteItem GenDynamicListAddItems PASS: *ds:si -- dynamic list ax - items at the top to leave alone when scrolling cx - top item dx - top item before scroll (cx - scroll offset) bp - number of visible items di - move identifier flag (if non-zero, will reset identifiers for each item as the scrolling requires) RETURN: nothing DESTROYED: PSEUDO CODE/STRATEGY: the idea is to move monikers from the source to the destination KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/18/92 Initial version ------------------------------------------------------------------------------@ ; ; ItemInfo, used for moving item monikers and enabled states around. ; ItemInfo struct II_visMoniker lptr VisMoniker ;Pointer to the item's moniker II_state GenStates ;Item's GS_ENABLED flag ItemInfo ends GenDynamicListScroll proc near numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word mov bx, bp .enter mov leaveAlone, ax ;items to leave alone mov moveIdentifierFlag, di ;move identifier flag mov ax, bx mov numVisItems, ax ;keep number of items here ; ; Move monikers around as necessary. ; mov bx, cx ;bx <- newTop - prevTop, sub bx, dx ; or the "offset" mov scrollOffset, bx ;store it jz exit ;no change, exit js scrollBackwards ;scrolling backwards, branch ; ; Scrolling forward. In the first pass, nuke the first "offset" ; items, and collect monikers from the rest into a stack frame which ; we create. ; sub ax, bx ;subtract offset fr numVisItems mov di, offset ForwardGetMkrs ;first pass routine mov dx, offset ForwardSetMkrs jmp short scroll scrollBackwards: ; ; Scrolling backward. In the first pass, nuke the last "offset" ; items, and collect monikers from the rest into a stack frame which ; we create. ; add ax, bx ;add offset to numVisItems mov di, offset BackwardGetMkrs ;first pass routine mov dx, offset BackwardSetMkrs ;second pass routine scroll: ; ; Scroll away. ; ax -- size of ItemInfo buffer needed, before subtracting the ; items to leave alone ; cx -- new item item ; di -- first pass routine ; dx -- second pass routine ; sub ax, leaveAlone ;don't need these mov bx, sp tst ax ;too much to scroll, branch js 10$ sub sp, ax ;create a buffer for item info sub sp, ax sub sp, ax 10$: CheckHack <(size ItemInfo) eq 3> ;+0 = buffer on stack mov ax, sp ;ss:ax points to buffer push bx ;+1 save old stack pointer mov bx, ds:[LMBH_handle] push bx ;+2 save mem handle push ax, cx, dx ;+5 save start of buffer, new ; top item, second pass rout clr cx ;cx <- position call DoAllChildren ; get the monikers pop ax, dx, di ;-5 ; ; In the second pass, we'll set new monikers for the first items, ; and request monikers for the last "offset" items. ; ax - start of buffer ; dx - new top item (identifier of first item) ; di - routine to call for second pass ; push ax ;+6 start of buffer clr cx ;position call DoAllChildren ;shift monikers, ask for new pop di ;-6 di <- start of buffer ; ; Free any leftover, unused monikers ; pop bx ;-2 obj block handle call MemDerefDS ; restore Obj block pop bx ;-1 restore old stack pointer freeUnused: cmp di, bx jae allGone mov ax, ss:[di].II_visMoniker tst ax jz nextMoniker call LMemFree nextMoniker: add di, size ItemInfo jmp freeUnused allGone: mov sp, bx ;-0 nuke buffer ;Commented back in. Sigh. 6/22/93 cbh mov cx, leaveAlone push bp mov ax, MSG_GEN_ITEM_GROUP_REDRAW_ITEMS call DC_ObjCallInstanceNoLock pop bp exit: .leave ret GenDynamicListScroll endp COMMENT @---------------------------------------------------------------------- ROUTINE: ForwardGetMkrs SYNOPSIS: Stores and nukes monikers as needed for forward scrolling. CALLED BY: FAR PASS: ss:ax -- ItemInfo: next place to store moniker handle cx -- generic position of item ss:bp -- local vars: numVisItems -- number of items visible offset -- (newTopItem - oldTopItem) RETURN: cx, incremented DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ ForwardGetMkrs proc far numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word .enter inherit cmp cx, leaveAlone jb exit ;ignoring these mov bx, scrollOffset add bx, leaveAlone cmp cx, bx jae getMoniker ; ; Items at the top are being scrolled off. We'll nuke their monikers. ; call NukeExistingMoniker jmp short exit getMoniker: ; ; For most items, we'll grab their moniker chunk to be moved elsewhere. ; We'll also grab the enabled state of the item. ; call GetItemInfo ;get item info exit: inc cx ;bump position clc .leave ret ForwardGetMkrs endp COMMENT @---------------------------------------------------------------------- ROUTINE: GetItemInfo SYNOPSIS: Gets item moniker and enabled state. Clears item's reference to the moniker, since it will be used somewhere else and we don't want it to be nuked. CALLED BY: ForwardGetMkrs, BackwardGetMkrs PASS: *ds:si -- item ss:ax -- ItemInfo: buffer element to store stuff in RETURN: ax -- updated to point at next element DESTROYED: di, bx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ GetItemInfo proc near class GenClass mov di, ax segmov es, ss ;ItemInfo buffer in es:di mov bx, ds:[si] add bx, ds:[bx].Gen_offset clr ax xchg ax, ds:[bx].GI_visMoniker stosw ;store vis moniker in buffer mov al, ds:[bx].GI_states and al, mask GS_ENABLED ;keep enabled flag stosb ;store it mov ax, di ;update buffer pointer ret GetItemInfo endp COMMENT @---------------------------------------------------------------------- ROUTINE: ForwardSetMkrs SYNOPSIS: Stores and queries for monikers as needed for forward scrolling. CALLED BY: FAR PASS: ss:ax -- ItemInfo: next place to get moniker from cx -- generic position of item dx -- identifier of item ss:bp -- local vars: numVisItems -- number of items visible scrollOffset -- (newTopItem - oldTopItem) RETURN: cx, dx, ax -- updated as needed DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ ForwardSetMkrs proc far numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word .enter inherit cmp cx, leaveAlone jb exit ;ignoring these mov bx, numVisItems sub bx, scrollOffset cmp cx, bx ;pos < numVisItems-scrollOffset jge queryForMoniker ; ; ; For most of the items, we can just grab a moniker from our buffer. ; call StoreItemInfo ;store moniker, enabled flag jmp short exit queryForMoniker: ; ; For the items being scrolled on, we'll have to query for the ; monikers. ; call ValidateItem ;validate the thing exit: inc cx ;bump position inc dx ;bump identifier clc .leave ret ForwardSetMkrs endp COMMENT @---------------------------------------------------------------------- ROUTINE: BackwardGetMkrs SYNOPSIS: Stores and nukes monikers as needed for backward scrolling. CALLED BY: FAR PASS: ss:ax -- ItemInfo: next place to store moniker handle cx -- generic position of item ss:bp -- local vars: numVisItems -- number of items visible scrollOffset -- (newTopItem - oldTopItem) RETURN: cx, incremented DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ BackwardGetMkrs proc far numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word .enter inherit cmp cx, leaveAlone jb exit ;ignoring these mov bx, numVisItems add bx, scrollOffset cmp cx, bx ;pos >= numVisItems+scrollOffset jge nukeMoniker ; ; The first bunch of items are moving down. We'll grab their monikers. ; call GetItemInfo ;get item info jmp short exit nukeMoniker: ; ; There are items at the bottom that are moving offscreen. Nuke their ; monikers. ; call NukeExistingMoniker exit: inc cx ;bump position clc ;continue .leave ret BackwardGetMkrs endp COMMENT @---------------------------------------------------------------------- ROUTINE: BackwardSetMkrs SYNOPSIS: Stores and queries for monikers as needed for backward scrolling. CALLED BY: FAR PASS: ss:ax -- ItemInfo: next place to get moniker from cx -- generic position of item dx -- identifier of item ss:bp -- local vars: numVisItems -- number of items visible scrollOffset -- (newTopItem - oldTopItem) RETURN: cx, dx, ax -- updated as needed DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ BackwardSetMkrs proc far numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word .enter inherit mov bx, leaveAlone cmp cx, bx jb exit ;ignoring these sub bx, scrollOffset cmp cx, bx ;branch if pos >= - scrollOffset jae storeMoniker ; ; For the first few items, we'll be querying for a new moniker. ; call ValidateItem ;validate the thing jmp short exit storeMoniker: ; ; For the rest of the items, we'll store a moniker from our buffer. ; call StoreItemInfo ;store moniker, enabled flag exit: inc cx ;bump position inc dx ;bump identifier clc .leave ret BackwardSetMkrs endp COMMENT @---------------------------------------------------------------------- ROUTINE: StoreItemInfo SYNOPSIS: Stores item moniker and enabled state. CALLED BY: ForwardSetMkrs, BackwardSetMkrs PASS: *ds:si -- item ss:ax -- ItemInfo: buffer element to store from dx -- identifier RETURN: ax -- updated to point at next element DESTROYED: di, bx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 3/17/92 Initial version ------------------------------------------------------------------------------@ StoreItemInfo proc near numVisItems local word scrollOffset local word leaveAlone local word moveIdentifierFlag local word .enter inherit class GenClass call ItemEnsuredUsable jnc justSetIdentifier ; ; Store the vis moniker. ; push di ;save item group handle mov di, ax ;ss:di <- ItemInfo mov bx, ss:[di].II_visMoniker ;get vis moniker clr ss:[di].II_visMoniker ; mark ItemInfo as used mov di, bx mov bx, ds:[si] add bx, ds:[bx].Gen_offset mov ds:[bx].GI_visMoniker, di ;store it tst di ;see if there was a moniker pop di ;*es:di <- item group ; ; If there was some kind of moniker (i.e. we weren't just copying from ; an item that is still awaiting a moniker from the application), we'll ; set it interactable.n ; jz noMonikerToStore ;there was no moniker, branch push cx, dx, bp, ax mov cx, si ;cx != 0 mov ax, MSG_GEN_ITEM_SET_INTERACTABLE_STATE call DC_ObjCallInstanceNoLock pop cx, dx, bp, ax jmp short setIdentifier noMonikerToStore: ; ; There's no moniker to store. If we're not moving identifiers, what ; we really need to do is query for this moniker, as the moniker ; queried for from the source of the scroll is not not valid for this ; new object. ; tst moveIdentifierFlag ;moving identifiers, branch jnz setIdentifier push cx, dx, bp call ValidateItem ;query for new moniker jmp short 5$ ;and branch to copy enabled setIdentifier: ; ; Set the identifier for the item. ; push cx, dx, bp tst moveIdentifierFlag ;not moving identifiers, branch jz 5$ mov cx, dx push ax mov ax, MSG_GEN_ITEM_SET_IDENTIFIER call DC_ObjCallInstanceNoLock pop ax ;ss:ax <- ItemInfo 5$: ; ; Set enabled state properly. We're going to set the instance data ; directly, and expect that MSG_GEN_ITEM_REDRAW will deal with keeping ; the specific enabled state correct. (Otherwise we run into problems ; with moving the focus when the item receives a MSG_SPEC_NOTIFY_SET_- ; NOT_ENABLED message). ; mov bx, ds:[si] add bx, ds:[bx].Gen_offset or ds:[bx].GI_states, mask GS_ENABLED mov di, ax ;ss:di <- ItemInfo tst ss:[di].II_state jnz 10$ and ds:[bx].GI_states, not mask GS_ENABLED 10$: ; ; Redraw the item to reflect its new moniker. ; ; mov ax, MSG_GEN_ITEM_REDRAW ; call GenCallSpecIfGrown pop cx, dx, bp ; mov ax, di ;update buffer pointer add ax, size ItemInfo ;bump it exit: .leave ret justSetIdentifier: ; ; even if we are not usable, we need to set the identifier (just like ; ValidateItem) ; ; (should just move the SET_IDENTIFIER to the beginning of the routine) ; tst moveIdentifierFlag ;not moving identifiers, branch jz exit push ax, cx, dx, bp mov cx, dx ; cx = identifier mov ax, MSG_GEN_ITEM_SET_IDENTIFIER call DC_ObjCallInstanceNoLock pop ax, cx, dx, bp jmp short exit StoreItemInfo endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListAddItems -- MSG_GEN_DYNAMIC_LIST_ADD_ITEMS for GenDynamicListClass DESCRIPTION: Adds an items to the dynamic list. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_ADD_ITEMS cx - item identifier to add after dx - number of items to add RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/16/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListAddItems method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_ADD_ITEMS mov bx, dx GOTO FinishAddRemove GenDynamicListAddItems endm COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListRemoveItems -- MSG_GEN_DYNAMIC_LIST_REMOVE_ITEMS for GenDynamicListClass DESCRIPTION: Removes an item to the dynamic list. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_REMOVE_ITEMS cx - item identifier to remove dx - number of items to remove RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/16/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListRemoveItems method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_REMOVE_ITEMS EC < cmp dx, ds:[di].GDLI_numItems > EC < ERROR_A UI_VALUE_REMOVING_MORE_ITEMS_THAN_EXIST > mov bx, dx neg bx FinishAddRemove label far ; ; On adds, we'll limit cx to the last item + 1. ; On removes, we'll limit cx to the last item - numItemsRemoving + 1. ; ; cx -- position to add/remove from ; dx -- numItems to add or remove ; bx -- numItems for an add, -numItems for a remove ; tst bx ;removing? js 2$ ;yes, branch clr dx ;numItemsAdded dont affect limit 2$: neg dx ;calculate limit add dx, ds:[di].GDLI_numItems cmp cx, dx ;see if past limit jbe 5$ ;everything fine, branch mov cx, dx ;else limit cx 5$: ; ; Change the number of items. ; add ds:[di].GDLI_numItems, bx ;adjust number of items call ObjMarkDirty call AdjustSelectionsAsNeeded ;update current selection call InitItemChanges ;ax <- top item ;bp <- num visible items ;bx <- numItemsAdding for add, ; -numItemsRemoving for remove ;cx <- place to add/remove ; Make adjustments based on the new list height. ; cmp cx, ax ;item to remove above top item? jb scrollThings ;yes, go handle mov dx, ax ;top item in dx add dx, bp ;get bottom item dec dx cmp cx, dx ;below bottom item? ja exit ;no, nothing to do, exit scrollThings: ; ; Scroll anything below the item being added/removed. ; ax -- top item ; cx -- item identifier we're adding/removing ; bx -- numItemsAdding for an add, -numItemsRemoving for a remove ; sub cx, ax ;get number of items to ignore jae 10$ clr cx ;above top item, redraw all 10$: xchg ax, cx ;ax <- items to ignore, ;cx <- top item push ax ;save items to ignore mov dx, cx ;top item also in dx ; ; Scrolling "down" for a remove, "up" for an add. We'll fudge a ; previous "top" to produce the correct scroll offset. ; add dx, bx ;create a previous top ; (scr offset = cx - dx) clr di ;don't move identifiers! call GenDynamicListScroll ;scroll items as needed ; ; Add this in, since things are not guaranteed to update, and ; GenDynamicListScroll does not do this anymore. 6/ 2/93 cbh ; (Changed to ignore items that aren't changing. What I was thinking ; when I did a "clr cx", I don't know. 6/21/93 cbh) ; pop cx ;don't redraw ignored items ; clr cx push bp mov ax, MSG_GEN_ITEM_GROUP_REDRAW_ITEMS call DC_ObjCallInstanceNoLock pop bp exit: ret GenDynamicListRemoveItems endm CallFirstGenChild proc near ;ax <- message, ds:di <- generic part class GenClass call DC_DerefGenDI mov bx, ds:[di].GI_comp.CP_firstChild.chunk tst bx jz exit push si mov si, bx mov bx, ds:[di].GI_comp.CP_firstChild.handle mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop si exit: ret CallFirstGenChild endp COMMENT @---------------------------------------------------------------------- ROUTINE: AdjustSelectionsAsNeeded SYNOPSIS: Updates selections after the items being added/removed. CALLED BY: GenDynamicListRemoveItems PASS: *ds:si -- dynamic list cx -- first item being added/removed bx -- shift amount RETURN: nothing DESTROYED: dx, bp, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 5/ 7/92 Initial version ------------------------------------------------------------------------------@ AdjustSelectionsAsNeeded proc near uses ax, bx, cx, es class GenDynamicListClass .enter call DC_DerefGenDI mov dx, ds:[di].GIGI_numSelections tst dx jz exit ;no selections, exit shl dx, 1 ;else double for words sub sp, dx mov bp, sp ;buffer in ss:bp push dx ;save buffer size pushdw dssi ;save our object push cx ;save start of changes push bp xchg dx, bp shr bp, 1 ;pass num selections mov cx, ss ;pass buffer in cx:dx, bp=size mov ax, MSG_GEN_ITEM_GROUP_GET_MULTIPLE_SELECTIONS call DC_ObjCallInstanceNoLock ;selections in cx:dx pop bp ;now in ss:bp mov cx, ax ;num selections in cx ; ; Get the number of items being removed. ; clr dx ;assume no items removed tst bx ;removing items? jns 5$ ;no, branch mov dx, bx neg dx ;dx <- number of items removed 5$: mov di, ss mov ds, di mov si, bp ;source in ds:si mov es, di mov di, bp ;dest in es:di pop bp ;first selection that changes push di ;save pointer to first selection checkItems: ; ; For each currently selected item: ; if (itemsRemoved) && (item in itemsBeingAddedOrRemoved) ; don't keep in new selection list ; else if item > itemsBeingAddedOrRemoved ; add bx to item and store in new selection list ; else ; store in new selection list ; ; ax -- temporary storage of current item ; bx -- amount of change ; dx -- number of items being removed, if any ; bp -- first item being added/removed ; cx -- last item being added/removed ; ds:si -- source ; es:di -- destination ; push cx ;save count mov cx, bp ;have cx <- last item removed add cx, dx lodsw ;get a selection ; ; If selected item being removed, we won't keep it as a selection. ; tst dx ;removing items? jz 10$ ;no, branch cmp ax, bp ;see if below items removed jb 10$ ;yes, branch cmp ax, cx ;<= last item removed? jb doneWithItem ;yes, we won't keep this one 10$: ; ; All selected items above the items being removed must adjust their ; positions. ; cmp ax, cx ;<= last item added/removed? jb storeItem ;nope, store as is add ax, bx ;else adjust the position storeItem: stosw ;store selection as needed doneWithItem: pop cx ;restore count loop checkItems ;do another item pop dx ;restore pointer to selections mov cx, ds ;cx:dx <- selections sub di, dx ;di <- size of selection buffer mov bp, di ;now in bp shr bp, 1 ;halve for item count popdw dssi ;restore our object call SetMultiSelection ;set selection, no update pop dx ;restore buffer size add sp, dx ;restore stack exit: .leave ret AdjustSelectionsAsNeeded endp COMMENT @---------------------------------------------------------------------- ROUTINE: InitItemChanges SYNOPSIS: Does a bunch of stuff for item adding/removal, new num items. Rescrolls the dynamic list to make sure sufficient items are onscreen, and returns top item and num visible items. CALLED BY: GenDynamicListRemoveItems GenDynamicListSetNumItems PASS: *ds:si -- dynamic list RETURN: ax -- top item bp -- num visible items DESTROYED: dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 4/ 1/92 Initial version ------------------------------------------------------------------------------@ InitItemChanges proc near class GenDynamicListClass push cx, bx call DC_DerefGenDI mov cx, ds:[di].GDLI_numItems mov ax, MSG_GEN_DYNAMIC_LIST_NUM_ITEMS_CHANGED call GenCallSpecIfGrown ;not much point if not grown. ; 5/17/93 cbh ; ; Get the identifier of the top item, and the number of entries (i.e. ; the numVisibleItems) ; mov ax, MSG_GEN_ITEM_GET_IDENTIFIER call CallFirstGenChild ;identifier in ax push ax mov ax, MSG_GEN_COUNT_CHILDREN call DC_ObjCallInstanceNoLock ;num children in dx mov bp, dx ;now in bp pop ax ;ax <- top item pop cx, bx ret InitItemChanges endp COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListSetNumItems -- MSG_GEN_DYNAMIC_LIST_INITIALIZE for GenDynamicListClass DESCRIPTION: Sets a new number of items. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_INITIALIZE cx - new number of items RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 4/ 1/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListInitialize method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_INITIALIZE ; ; If we're not scrollable, we need to ensure that the new items will ; be visible. ; mov dx, ds:[di].GDLI_numItems ;get old number of items mov ax, HINT_ITEM_GROUP_SCROLLABLE call ObjVarFindData jc setNumItems push cx, dx clr bp ;no top item ; ; Tell GenDynamicListNumVisibleItemsChanged not to call ; ItemsChangedCallback for all of the items that it creates by ; putting TRUE in dx, since we are going to do that. IP 1/27/94 ; mov dx, TRUE mov ax, MSG_GEN_DYNAMIC_LIST_NUM_VISIBLE_ITEMS_CHANGED call DC_ObjCallInstanceNoLock pop cx, dx setNumItems: ; ; Use current number of items if passed GDLI_NO_CHANGE. ; ; cx -- new num items, dx -- old num items. ; cmp cx, GDLI_NO_CHANGE ;see if no change in num items jne 10$ ;nope, branch mov cx, dx ;else use GDLI_numItems 10$: mov bx, offset GDLI_numItems ;set instance data call GenSetWord call InitItemChanges ;ax <- top item ;bp <- num visible items mov bp, ax ;keep identifier here clr cx ;generic position of child mov dx, cx ;all the items need to change mov di, offset ItemsChangedCallback ;update routine call DoAllChildren ; ; Set none selected. We can modify the list without an update because ; we can count on REDRAW_ITEMS updating everything as needed. ; (I've removed the redraw, as it happens elsewhere now, so let's do it ; the old-fashioned way. Somehow this worked before, but now with ; the drawing being done later, it wreaks havoc with the selected ; item never getting updated (i.e. marked unselected) in the specific ; UI. -cbh 5/24/93) ; clr dx mov ax, MSG_GEN_ITEM_GROUP_SET_NONE_SELECTED call ObjCallInstanceNoLock ; mov dx, GIGS_NONE ;selection ; clr cx ;num selections ; mov bx, offset GIGI_selection ; call GenSetDWord ;set new selection ; ; Update all the items now. ; ; clr cx ;redraw all the items ; push bp ; mov ax, MSG_GEN_ITEM_GROUP_REDRAW_ITEMS ; call DC_ObjCallInstanceNoLock ; pop bp ; ret GenDynamicListInitialize endm COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListGetNumItems -- MSG_GEN_DYNAMIC_LIST_GET_NUM_ITEMS for GenDynamicListClass DESCRIPTION: Returns number of items. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_GET_NUM_ITEMS RETURN: cx - number of items ax, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/17/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListGetNumItems method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_GET_NUM_ITEMS mov cx, ds:[di].GDLI_numItems Destroy ax, dx, bp ret GenDynamicListGetNumItems endm DynaCommon ends ItemCommon segment resource COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListNumVisibleItemsChanged -- MSG_GEN_DYNAMIC_LIST_NUM_VISIBLE_ITEMS_CHANGED for GenDynamicListClass DESCRIPTION: Handles view size changing. We may need to create GenItems here to display more entries. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_META_CONTENT_VIEW_SIZE_CHANGED cx - num visible items dx - TRUE indicates do not initialze new items bp - current top item RETURN: ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: if dx is TRUE then any new items which are created, will not be initialized. This is an optimization for GenDynamicListInitialize since it will initalize the new items anyway KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/14/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListNumVisibleItemsChanged method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_NUM_VISIBLE_ITEMS_CHANGED ; ; This is for the benefit of non-scrolling dynamic lists. ; mov bx, dx ;bx init children flag cmp cx, -1 jne 10$ mov cx, ds:[di].GDLI_numItems 10$: push cx, bp mov ax, MSG_GEN_COUNT_CHILDREN call IC_ObjCallInstanceNoLock ;previous num children in dx pop cx, bp mov_tr ax, bx ;ax gets init children flag mov bx, cx ;save new numVisible in bx sub cx, dx ;need to add items? je exit ;nothing to be done, exit jb removeItems ;fewer items, branch to remove push ax push dx, bp ;save prev num items, top item addLoop: ; ; We need to add some items to the dynamic list. ; cx -- number of items to add ; push cx ;save count push si mov ax, MSG_GEN_DYNAMIC_LIST_GET_ITEM_CLASS call IC_ObjCallInstanceNoLock ;returns item class in cx:dx mov es, cx mov di, dx mov bx, ds:[LMBH_handle] call GenInstantiateIgnoreDirty ;instantiate an item mov bx, offset Gen_offset ; call ObjInitializePart ;initialize generic part. mov dx, si mov cx, ds:[LMBH_handle] ;new item in ^lcx:dx pop si ;parent in *ds:si mov bp, CCO_LAST ;put last, don't mark dirty mov ax, MSG_GEN_ADD_CHILD call IC_ObjCallInstanceNoLock pop cx ;restore count loop addLoop ; ; Having added the items to the generic tree, we'll make sure the ; items get monikers and stuff. ; pop dx, bp ;restore prevNumItems, top item ; ; test to see if whomever called this routine is going to ; update the children. If that is true, than lets not do it ; pop ax EC< cmp ax, TRUE > EC< je doneChecking > EC< cmp ax, FALSE > EC< je doneChecking > EC< ERROR GEN_DYNAMIC_LIST_NUM_VISIBLE_ITEMS_CHANGED_BAD_ARGUMENT > EC< doneChecking: > cmp ax, TRUE je redraw clr cx ;generic position of child mov di, offset ItemsChangedCallback ;update routine call DoAllChildren jmp short redraw removeItems: ; ; We have more items than we need currently. We'll remove items, so ; that the dynamic list can always get the current number of visible ; items by counting the children. ; bx - newNumItems ; clr cx ;generic child position mov dx, bx ;place to start removing items mov di, offset RemoveItemsCallback ;remove items call DoAllChildren redraw: ; clr cx ;redraw all the items ; mov ax, MSG_GEN_ITEM_GROUP_REDRAW_ITEMS ; call IC_ObjCallInstanceNoLock exit: ret GenDynamicListNumVisibleItemsChanged endm COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListScanItems -- MSG_GEN_ITEM_GROUP_SCAN_ITEMS for GenDynamicListClass DESCRIPTION: Scans for items. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_ITEM_GROUP_SCAN_ITEMS cl - GenScanItemsFlags dx - initial item bp - absolute scan amount RETURN: carry set if any item found, with: ax - resultant item cl - GenScanItemsFlags, possibly updated (in particular, GSIF_FORWARD flag reflects the direction to navigate if the result item turns out to be disabled) dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 3/19/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListScanItems method dynamic GenDynamicListClass, MSG_GEN_ITEM_GROUP_SCAN_ITEMS ; If we're just supposed to look through the existing items, then ; so be it. Do the superclass method. ; test cl, mask GSIF_EXISTING_ITEMS_ONLY jz doScan mov di, offset GenDynamicListClass GOTO ObjCallSuperNoLock doScan: ; ; First, do normal item group scan. In the simple cases, we will ; actually find what we want here. If so, exit. ; or cl, mask GSIF_DYNAMIC_LIST ;say we're a dynamic list mov di, offset GenDynamicListClass call ObjCallSuperNoLock ;do superclass stuff jc exit ;we found a result, exit ; ; Scan failed for currently usable items. Get some more info (the ; identifiers of the first and last usable children). ; push bp, dx ;save last, first enabled items push ax ;save destination position mov ax, -1 ;initialize first usable item mov bp, ax ;and last usable item mov di, offset GetFirstLastItems ;find child at this position call GenItemGroupProcessChildren pop bx ;restore dest position call IC_DerefGenDI mov di, ds:[di].GDLI_numItems dec di ;di <- identifier of last item ; ; We're now ready to return something outside the currently usable ; region. Keep the value returned within reasonable range, and use ; information returned from the original scan in certain situations. ; ; ax -- identifier of first usable item ; bx -- result of failed scan relative to top item ; cl -- GenScanItemsArgs ; bp -- identifier of last usable item ; di -- identifier of last item in dynamic list ; ; ; From-start -- just go to do out-of-range stuff. If you're looking ; for the beginning, the superclass returns -1, so if you`re scrolled ; into the list, it actually returns an onscreen value, which is ; totally wrong. This may be a problem with the algorithm, but for ; now I'll do this. -cbh 9/23/92 ; test cl, mask GSIF_FROM_START jnz outOfDynamicRange add bx, ax ;adjust position to be a dynamic ; list position. js outOfDynamicRange ;out of range, branch cmp bx, di jbe inDynamicRange outOfDynamicRange: ; ; Not in range, limit to first or last item in list based on whether ; we're going forward, whether we're wrapping, etc. The other thing ; we'll do here is toggle the GSIF_FORWARD flag if we're at the ends ; in a non-wrapping, non-from-start situation. The caller of this ; message will use the direction flag to decide which direction to go ; if the item we're returning turns out to be disabled, and if we're ; going to the end of the list and the item is disabled, we'll want to ; reverse our direction (and vice-versa for going to the beginning). ; mov dx, di ;dx <- numItems - 1 clr bx ;assume moving to start position test cl, mask GSIF_FORWARD ;going forward? jz 20$ ;no, branch xchg bx, dx ;else bx <- end position 20$: test cl, mask GSIF_FROM_START or mask GSIF_WRAP_AROUND jz inDynamicRange ;no, we're done xchg bx, dx ;else switch to opposite pos inDynamicRange: ; ; Within dynamic list's range, we'll see if the result end item was ; actually onscreen. If it was, we'll use the values returned from ; the superclass since the superclass had information about whether ; the desired item was disabled or not. We also may need to return ; a different direction based on various flags (see comment in Swap- ; DirectionsIfNotWrapping). ; pop dx ;restore first enabled item tst bx ;see if at beginning jnz checkEnd ;no, branch call SwapDirectionsIfNotWrapping ;may need this if item is dis'd add sp, 2 ;unload last enabled item tst ax ;are we currently at the top? jnz returnBx ;no, use this value mov bx, dx ;else use better value jmp short returnBx ;and we're done checkEnd: pop dx ;restore last enabled item cmp bx, di ;returning last item? jne returnBx ;no, done call SwapDirectionsIfNotWrapping ;may need this if item is dis'd cmp bp, di ;was last item onscreen? jne returnBx ;no, done mov bx, dx ;else use a better value returnBx: push bx, cx ;save final result, flags mov cx, bx mov ax, MSG_GEN_ITEM_GROUP_MAKE_ITEM_VISIBLE call GenCallSpecIfGrown ;make sure onscreen pop ax, cx ;ax <- final result, cl <- flags stc ;return carry set exit: Destroy dx, bp ret GenDynamicListScanItems endm SwapDirectionsIfNotWrapping proc near ; ; Called if we're going to return the beginning or end of the list, but ; don't actually know its enabled state yet. If it does turn out to ; be disabled, we'll have to navigate one direction or the other to ; find a new item. This routine ensures that the direction is reversed ; if we're not going to be wrapping or going from the start (i.e. if ; paging to the beginning of the list, and the item is disabled, we'll ; change direction to find the first non-disabled item in the list, ; rather than wrap.) ; ; Pass, return: cl -- GenItemsScanFlags ; test cl, mask GSIF_FROM_START or mask GSIF_WRAP_AROUND jnz 30$ xor cl, mask GSIF_FORWARD 30$: ret SwapDirectionsIfNotWrapping endp ItemCommon ends DynaCommon segment resource COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListReplaceItemMonikerOptr -- MSG_GEN_ITEM_LIST_REPLACE_ITEM_MONIKER_OPTR for GenClass DESCRIPTION: Replace item's current vis moniker with VisMoniker referenced by optr. PASS: *ds:si - instance data es - segment of GenClass ax - MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER_OPTR ^lcx:dx - source VisMoniker bp - item RETURN: ax - chunk handle of vis moniker cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 3/23/92 Initial version ------------------------------------------------------------------------------@ GenDynamicListReplaceItemMonikerOptr method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER_OPTR mov ax, bp ; al = VisUpdateMode sub sp, size ReplaceItemMonikerFrame mov bp, sp mov ss:[bp].RIMF_item, ax mov ss:[bp].RIMF_itemFlags, 0 mov ss:[bp].RIMF_source.handle, cx mov ss:[bp].RIMF_source.chunk, dx mov ss:[bp].RIMF_sourceType, VMST_OPTR mov ss:[bp].RIMF_dataType, VMDT_VIS_MONIKER mov dx, ReplaceItemMonikerFrame mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER call DC_ObjCallInstanceNoLock add sp, size ReplaceItemMonikerFrame ret GenDynamicListReplaceItemMonikerOptr endm COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListReplaceItemMonikerNullTermTextFPtr -- MSG_GEN_ITEM_LIST_REPLACE_ITEM_TEXT for GenDynamicListClass DESCRIPTION: Replace item's current vis moniker with null-terminated text. PASS: *ds:si - instance data es - segment of GenClass ax - MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT cx:dx - fptr to zero-terminated text (For XIP'ed geodes, cx:dx *cannot* be pointing into the XIP movable code segment.) bp - item RETURN: ax - chunk handle of vis moniker cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 3/23/92 Initial version ------------------------------------------------------------------------------@ GenDynamicListReplaceItemText method dynamic GenDynamicListClass, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT if FULL_EXECUTE_IN_PLACE ; ; Make sure the fptr (cx:dx) passed in is not pointing into the code ; segment of the routine/method which sent out this message ; EC < pushdw bxsi > EC < movdw bxsi, cxdx > EC < call ECAssertValidFarPointerXIP > EC < popdw bxsi > endif mov ax, bp ; bp = item sub sp, size ReplaceItemMonikerFrame mov bp, sp mov ss:[bp].RIMF_itemFlags, 0 mov ss:[bp].RIMF_item, ax mov ss:[bp].RIMF_source.handle, cx mov ss:[bp].RIMF_source.chunk, dx mov ss:[bp].RIMF_sourceType, VMST_FPTR mov ss:[bp].RIMF_dataType, VMDT_TEXT mov ss:[bp].RIMF_length, 0 mov dx, ReplaceItemMonikerFrame mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_MONIKER call DC_ObjCallInstanceNoLock add sp, size ReplaceItemMonikerFrame ret GenDynamicListReplaceItemText endm COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListRemoveItemList -- MSG_GEN_DYNAMIC_LIST_REMOVE_ITEM_LIST for GenDynamicListClass DESCRIPTION: Removes a list of items. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_DYNAMIC_LIST_REMOVE_ITEM_LIST cx:dx - list of items (For XIP'ed geodes, cx:dx *cannot* be pointing into the movable XIP cdoe segment.) bp - number of items RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 5/11/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListRemoveItemList method dynamic GenDynamicListClass, \ MSG_GEN_DYNAMIC_LIST_REMOVE_ITEM_LIST if FULL_EXECUTE_IN_PLACE ; ; Make sure the fptr passed in is not pointing into the code segment ; of the one who sent out this message ; EC < pushdw bxsi > EC < movdw bxsi, cxdx > EC < call ECAssertValidFarPointerXIP > EC < popdw bxsi > endif tst bp jz exit ;nothing to do, get out mov di, dx mov es, cx ;es:di <- list mov bx, bp ;bx <- count removeItem: ; ; Remove an item. es:di -- item, bx -- number of items left to do ; mov cx, {word} es:[di] push cx mov dx, 1 mov ax, MSG_GEN_DYNAMIC_LIST_REMOVE_ITEMS call DC_ObjCallInstanceNoLock pop cx add di, 2 ;next item dec bx jz exit ;no more items left, exit ; ; Having removed the item, update any subsequent items in the list ; whose identifiers would be affected by the removal of the last item. ; push bx, di ;save current position in list updateItem: cmp {word} es:[di], cx EC < ERROR_E GEN_DYNAMIC_LIST_SAME_ITEM_TWICE_IN_REMOVAL_LIST > jb 10$ ;not after deleted item, branch dec {word} es:[di] ;else update the identifier 10$: add di, 2 ;next item dec bx jnz updateItem ;not done, loop pop bx, di ;restore current list position jmp short removeItem ;go remove another one. exit: ret GenDynamicListRemoveItemList endm DynaCommon ends ItemExtended segment resource COMMENT @---------------------------------------------------------------------- METHOD: GenDynamicListUpdateExtendedSelection -- MSG_GEN_ITEM_GROUP_UPDATE_EXTENDED_SELECTION for GenDynamicListClass DESCRIPTION: Updates an extended selection appropriately. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_GEN_ITEM_GROUP_UPDATE_EXTENDED_SELECTION ss:bp - GenItemGroupUpdateExtSelParams RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 9/22/92 Initial Version ------------------------------------------------------------------------------@ GenDynamicListUpdateExtendedSelection method dynamic GenDynamicListClass, \ MSG_GEN_ITEM_GROUP_UPDATE_EXTENDED_SELECTION call SetupChangeItemArgs ;get item range to change jnc exit ;no change, get out. call GenDynamicListChangeItems exit: ret GenDynamicListUpdateExtendedSelection endm COMMENT @---------------------------------------------------------------------- ROUTINE: GenDynamicListChangeItems SYNOPSIS: Changes the items passed in the appropriate way. In normal selections, the changed items that are in the new selection are cleared, others are set. When xoring selections, all items are xor'ed. CALLED BY: ? PASS: *ds:si -- item group cx -- position of first item being changed dx -- position of last item being changed ax -- anchor item ss:bp -- GenItemGroupUpdateExtendedSelection RETURN: nothing DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 9/10/92 Initial version ------------------------------------------------------------------------------@ GenDynamicListChangeItems proc near class GenDynamicListClass ; ; We'll use bx as our current item, running through all the changed ; items. ; clr bx ;init running item itemLoop: push ax, bx, cx, dx, bp ; ; Figure out whether this item is changing from last time. (On ; an initial selection, nothing is changing from last time, or so ; we must treat it, as far as whether to clear an item no longer in ; the selection.) ; clr di ;assume not changing test ss:[bp].GIGUESP_flags, mask ESF_INITIAL_SELECTION jnz notChanged ;initial selection, no changes cmp bx, cx jb notChanged cmp bx, dx ja notChanged dec di ;changing notChanged: mov dx, di ;pass changed flag in dx mov cx, bx call ChangeItem ;change an item pop ax, bx, cx, dx, bp inc bx call IE_DerefGenDI cmp bx, ds:[di].GDLI_numItems ;are we done? jb itemLoop ;nope, move along ret GenDynamicListChangeItems endp ItemExtended ends
; A022348: Fibonacci sequence beginning 0, 14. ; 0,14,14,28,42,70,112,182,294,476,770,1246,2016,3262,5278,8540,13818,22358,36176,58534,94710,153244,247954,401198,649152,1050350,1699502,2749852,4449354,7199206,11648560,18847766,30496326,49344092,79840418,129184510,209024928,338209438,547234366,885443804,1432678170,2318121974,3750800144,6068922118,9819722262,15888644380,25708366642,41597011022,67305377664,108902388686,176207766350,285110155036,461317921386,746428076422,1207745997808,1954174074230,3161920072038,5116094146268,8278014218306,13394108364574,21672122582880,35066230947454,56738353530334,91804584477788,148542938008122,240347522485910,388890460494032,629237982979942,1018128443473974,1647366426453916,2665494869927890,4312861296381806,6978356166309696 mov $2,7 lpb $0,1 sub $0,1 mov $3,$2 mov $2,$1 add $1,$3 lpe mul $1,2
;************************************ ; written by: Stoffel van Aswegen ; for AVR: ATTiny85 ; clock frequency: 1 MHz ; Function: Night light controller with motion detection ; Ambient light level measured with LDR ; Switch lamp on for 3hrs at sunset ; Switch lamp on for 10mins when dark & motion detected .nolist .include "tn85def.inc" .list .include "defs.inc" .include "isr.inc" .include "subs.inc" SETUP: ;Setup Timer0 ; With the 1MHz clock prescaled by 1024, the effective rate is 976Hz ; 976 = 244 * 4 ; Setting the Output Compare Register to 244, the TIMER0_COMPA interrupt will fire every 250ms ; Count 4 interrupts to measure 1s ldi tmp,(1<<WGM01) out TCCR0A,tmp ;CTC mode ldi tmp,244 out OCR0A,tmp ;TIMER0 compare value ldi tmp,(1<<OCIE0A) out TIMSK,tmp ;Enable output compare interrupt ;Setup PORTB digital I/O ldi tmp,(1<<DDB0) out DDRB,tmp ;Outputs: lamp ldi tmp,(1<<DDB2) out PORTB,tmp ;Enable input pull-up on PB2 (motion detector) ;Setup INT0 external interrupt (Motion Detector) clr tmp out MCUCR,tmp ;Trigger INT0 interrupt on low level cbi PORTB,LAMP ;Lamp off clr system ;Clear flags rcall MotDetOff ;Disable Motion Detector sei ;Enable global interrupts LOOP: sbrc system,MOTION ;Did something move? rcall Movement rcall IsItDark sbrs system,DARK rjmp NOT_DARK IS_DARK: sbrs system,NIGHT ;Is it Night? rcall Sunset rjmp LOOP NOT_DARK: sbrc system,NIGHT ;Is it Day? rjmp Sunrise rjmp LOOP
/* ============================================================================== This file is part of the JUCE library. Copyright (c) 2020 - Raw Material Software Limited JUCE is an open source library subject to commercial or open-source licensing. By using JUCE, you agree to the terms of both the JUCE 6 End-User License Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). End User License Agreement: www.juce.com/juce-6-licence Privacy Policy: www.juce.com/juce-privacy-policy Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses). JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { class FileChooserDialogBox::ContentComponent : public Component { public: ContentComponent (const String& name, const String& desc, FileBrowserComponent& chooser) : Component (name), chooserComponent (chooser), okButton (chooser.getActionVerb()), cancelButton (TRANS ("Cancel")), newFolderButton (TRANS ("New Folder")), instructions (desc) { addAndMakeVisible (chooserComponent); addAndMakeVisible (okButton); okButton.addShortcut (KeyPress (KeyPress::returnKey)); addAndMakeVisible (cancelButton); cancelButton.addShortcut (KeyPress (KeyPress::escapeKey)); addChildComponent (newFolderButton); setInterceptsMouseClicks (false, true); } void paint (Graphics& g) override { text.draw (g, getLocalBounds().reduced (6) .removeFromTop ((int) text.getHeight()).toFloat()); } void resized() override { const int buttonHeight = 26; auto area = getLocalBounds(); text.createLayout (getLookAndFeel().createFileChooserHeaderText (getName(), instructions), (float) getWidth() - 12.0f); area.removeFromTop (roundToInt (text.getHeight()) + 10); chooserComponent.setBounds (area.removeFromTop (area.getHeight() - buttonHeight - 20)); auto buttonArea = area.reduced (16, 10); okButton.changeWidthToFitText (buttonHeight); okButton.setBounds (buttonArea.removeFromRight (okButton.getWidth() + 16)); buttonArea.removeFromRight (16); cancelButton.changeWidthToFitText (buttonHeight); cancelButton.setBounds (buttonArea.removeFromRight (cancelButton.getWidth())); newFolderButton.changeWidthToFitText (buttonHeight); newFolderButton.setBounds (buttonArea.removeFromLeft (newFolderButton.getWidth())); } FileBrowserComponent& chooserComponent; TextButton okButton, cancelButton, newFolderButton; String instructions; TextLayout text; }; //============================================================================== FileChooserDialogBox::FileChooserDialogBox (const String& name, const String& instructions, FileBrowserComponent& chooserComponent, bool shouldWarn, Colour backgroundColour, Component* parentComp) : ResizableWindow (name, backgroundColour, parentComp == nullptr), warnAboutOverwritingExistingFiles (shouldWarn) { content = new ContentComponent (name, instructions, chooserComponent); setContentOwned (content, false); setResizable (true, true); setResizeLimits (300, 300, 1200, 1000); content->okButton.onClick = [this] { okButtonPressed(); }; content->cancelButton.onClick = [this] { closeButtonPressed(); }; content->newFolderButton.onClick = [this] { createNewFolder(); }; content->chooserComponent.addListener (this); FileChooserDialogBox::selectionChanged(); if (parentComp != nullptr) parentComp->addAndMakeVisible (this); else setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); } FileChooserDialogBox::~FileChooserDialogBox() { content->chooserComponent.removeListener (this); } //============================================================================== #if JUCE_MODAL_LOOPS_PERMITTED bool FileChooserDialogBox::show (int w, int h) { return showAt (-1, -1, w, h); } bool FileChooserDialogBox::showAt (int x, int y, int w, int h) { if (w <= 0) w = getDefaultWidth(); if (h <= 0) h = 500; if (x < 0 || y < 0) centreWithSize (w, h); else setBounds (x, y, w, h); const bool ok = (runModalLoop() != 0); setVisible (false); return ok; } #endif void FileChooserDialogBox::centreWithDefaultSize (Component* componentToCentreAround) { centreAroundComponent (componentToCentreAround, getDefaultWidth(), 500); } int FileChooserDialogBox::getDefaultWidth() const { if (auto* previewComp = content->chooserComponent.getPreviewComponent()) return 400 + previewComp->getWidth(); return 600; } //============================================================================== void FileChooserDialogBox::closeButtonPressed() { setVisible (false); } void FileChooserDialogBox::selectionChanged() { content->okButton.setEnabled (content->chooserComponent.currentFileIsValid()); content->newFolderButton.setVisible (content->chooserComponent.isSaveMode() && content->chooserComponent.getRoot().isDirectory()); } void FileChooserDialogBox::fileDoubleClicked (const File&) { selectionChanged(); content->okButton.triggerClick(); } void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) {} void FileChooserDialogBox::browserRootChanged (const File&) {} void FileChooserDialogBox::okToOverwriteFileCallback (int result, FileChooserDialogBox* box) { if (result != 0 && box != nullptr) box->exitModalState (1); } void FileChooserDialogBox::okButtonPressed() { if (warnAboutOverwritingExistingFiles && content->chooserComponent.isSaveMode() && content->chooserComponent.getSelectedFile(0).exists()) { AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon, TRANS("File already exists"), TRANS("There's already a file called: FLNM") .replace ("FLNM", content->chooserComponent.getSelectedFile(0).getFullPathName()) + "\n\n" + TRANS("Are you sure you want to overwrite it?"), TRANS("Overwrite"), TRANS("Cancel"), this, ModalCallbackFunction::forComponent (okToOverwriteFileCallback, this)); } else { exitModalState (1); } } void FileChooserDialogBox::createNewFolderCallback (int result, FileChooserDialogBox* box, Component::SafePointer<AlertWindow> alert) { if (result != 0 && alert != nullptr && box != nullptr) { alert->setVisible (false); box->createNewFolderConfirmed (alert->getTextEditorContents ("Folder Name")); } } void FileChooserDialogBox::createNewFolder() { auto parent = content->chooserComponent.getRoot(); if (parent.isDirectory()) { auto* aw = new AlertWindow (TRANS("New Folder"), TRANS("Please enter the name for the folder"), MessageBoxIconType::NoIcon, this); aw->addTextEditor ("Folder Name", String(), String(), false); aw->addButton (TRANS("Create Folder"), 1, KeyPress (KeyPress::returnKey)); aw->addButton (TRANS("Cancel"), 0, KeyPress (KeyPress::escapeKey)); aw->enterModalState (true, ModalCallbackFunction::forComponent (createNewFolderCallback, this, Component::SafePointer<AlertWindow> (aw)), true); } } void FileChooserDialogBox::createNewFolderConfirmed (const String& nameFromDialog) { auto name = File::createLegalFileName (nameFromDialog); if (! name.isEmpty()) { auto parent = content->chooserComponent.getRoot(); if (! parent.getChildFile (name).createDirectory()) AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, TRANS ("New Folder"), TRANS ("Couldn't create the folder!")); content->chooserComponent.refresh(); } } } // namespace juce
; --- file: jcalg1_d_fast.asm --- ; ; JCALG1 r5.xx, (c)1999-2001 by Jeremy Collake - All Rights Reserved. ; *************************************************************** ; Please read license agreement in LICENSE.TXT, if this document ; is not included with this distribution, please email the author ; at collake@charter.net. ; *************************************************************** ; ; Fast decompressor source. ; ; ; notes: edx used as holder for bits read from the input (compressed) ; stream. It must be preserved throughout. ; include jccomp.inc ifndef NOCHANGETOCODE .code endif ifndef JCALG1_GetUncompressedSizeOfCompressedBlock include JCALG1_gusocb.asm endif ; ================================================================= ; support macros - macros have been used to reduce the overhead ; in call and ret instructions. ; ================================================================= ; returns bit in carry _getbit MACRO LOCAL _noload add edx,edx ; edx*2, equiv. to shl edx,1 ; if placeholder bit (1) is shifted ; off into carry then result is zero. jnz _noload ; if not, then return carry bit mov edx,dword ptr [esi] add esi,4 stc adc edx,edx ; -minimum ; value now one, lowest bit used ; as placeholder, highest bit shifted ; off for return _noload: ENDM ; returns byte in al _getbyte MACRO mov ecx,8 ; 8 bits _getbits ENDM ; on entry: ecx=number of bits to retrieve ; returns: eax=bits retrieved _getbits MACRO LOCAL _getbitsloop_ xor eax,eax align 16 _getbitsloop_: _getbit ; retrieve bit, result in carry adc eax,eax ; add bit to eax dec ecx jnz _getbitsloop_ ; speed optimized, preferred over loop ENDM ; decodes gamma encoded integer from input stream ; returns: ecx=decoded gamma integer _getgamma MACRO LOCAL _getgammaloop mov ecx,1 ; remember, it was assumed that at ; least one significant bit existed ; in the integer, this is it. align 16 _getgammaloop: _getbit ; retrieve a bit from the input stream adc ecx, ecx ; add it to destination _getbit ; retrieve another bit jc _getgammaloop ; if one, continue on, if zero, end of ; integer ENDM ; ================================================================= ; Entry: pSrc->compressed data ; pDest->uncompressed data ; Returns: eax=size of uncompressed data ; ; register usage: ; ebx=last encoded index. ; edx=holder for bits read from stream, with placeholder ; bit as least significant on bit. ; ================================================================= JCALG1_Decompress_Fast proc stdcall pSrc:DWORD, pDest:DWORD LOCAL IndexBase:DWORD ;-4 LOCAL LiteralBits:DWORD ;-8 LOCAL MinimumLiteral:BYTE ;-12 cld push ebx push edi push esi mov esi,[esp+8+18h] ;pSrc ; esi->source mov edi,[esp+0ch+18h] ;pDest ; edi->destination cmp (_JCALG1_HEADER ptr [esi]).wSig,'CJ' jnz DecompDone add esi,size _JCALG1_HEADER xor ebx,ebx ; zero ebx mov edx,80000000h ; initialize edx, placeholder bit at ; highest position, force load of ; new dword. mov dword ptr [esp-4+18h],INITIAL_BASE ;IndexBase,INITIAL_BASE inc ebx ; most recently encoded index assumed ; to be one at start. align 16 ; the main decompression loop DecodeLoop: _getbit ; retrieve bit jnc IsntLiteral ; if not zero bit, then is not literal DoLiteral: mov ecx,[esp-8+18h] _getbits add al,[esp-12+18h];MinimumLiteral DecodeZero: mov [edi],al inc edi jmp DecodeLoop ; loop IsntLiteral: _getbit ; grab next control bit jc NormalPhrase ; if 1, then normal phrase (01) _getbit ; else grab next control bit jnc ShortMatch ; if 0, then short phrase (000) ; else, one byte phrase or literal size change mov ecx,ONEBYTE_PHRASE_BITS _getbits ; get one byte phrase index dec eax jz DecodeZero jns docopy_inc _getbit jnc GetNewLiteralSize NextBlock: mov ebp,BLOCK_SIZE CopyMe: _getbyte mov byte ptr [edi],al inc edi dec ebp jnz CopyMe _getbit jc NextBlock jmp DecodeLoop GetNewLiteralSize: ; retrieve literal information mov ecx,LITERAL_BITSIZE _getbits add eax,7 mov [esp-8+18h],eax mov byte ptr [esp-12+18h],0 cmp eax,8 jz DecodeLoop _getbyte mov [esp-12+18h],al jmp DecodeLoop ShortMatch: mov ecx,SHORT_BITS _getbits mov ebp,eax mov ecx,2 _getbits mov ecx,eax mov eax,ebp add ecx,2 test eax,eax jz extendedshort mov ebx,eax ; store last used index jmp docopy ; go copy the phrase extendedshort: cmp ecx,2 jz DecompDone ; if carry flag nonzero, then ; decompression finished. inc ecx ; 3+1=4 _getbits ; retrieve new index base mov [esp-4+18h],eax ; store index base jmp DecodeLoop ; loop NormalPhrase: _getgamma ; get gamma encoded high index dec ecx ; decrement once ;loop notsamefull ; not preferred for speed dec ecx ; decrement twice jnz notsamefull ; if not zero, then low bits follow mov eax,ebx ; else, index is same as last used _getgamma ; decode the phrase length jmp docopy ; copy the phrase notsamefull: dec ecx ; third decrementation mov eax,ecx ; store the high bits of index in eax mov ecx,[esp-4+18h] ; ecx=current index base mov ebp,eax ; save the high bits of index xor eax,eax shl ebp,cl ; shift high bits CURRENT_BASE bits lt _getbits ; get CURRENT_BASE bits or eax,ebp ; or together high and low bits mov ebx,eax ; store last used index _getgamma ; retrieve the phrase length ; perform index range decremenation cmp eax,DecrementIndex3 jae docopy_threeincs cmp eax,DecrementIndex2 jae docopy_twoincs cmp eax,DecrementIndex1 jae docopy_inc cmp eax,SHORT_RANGE ja docopy inc ecx docopy_threeincs: inc ecx docopy_twoincs: inc ecx docopy_inc: inc ecx docopy: mov ebp,esi mov esi,edi ; esi=P sub esi,eax ; subtract relative index for absolute rep movsb mov esi,ebp jmp DecodeLoop ; loop DecompDone: lea ebp,[esp+18h] mov esi,[esp+8+18h] cmp (_JCALG1_HEADER ptr [esi]).dwChecksum,0 jz DecompGood mov ecx,(_JCALG1_HEADER ptr [esi]).dwUncompressedSize mov esi,[esp+0ch+18h] ;pDest CHECKSUM32_MACRO mov esi,[esp+8+18h] cmp eax,(_JCALG1_HEADER ptr [esi]).dwChecksum jz DecompGood DecompBad: xor eax,eax jmp DecompExit DecompGood: mov eax,edi ; eax->end of uncomprssed data sub eax,[esp+0ch+18h] ; eax=end of uncompressed data- ; start of uncompressed data ; =size of uncompressed data DecompExit: pop esi pop edi pop ebx ret JCALG1_Decompress_Fast endp JCALG1_Decompress_Fast_ends: ConditionalEnd
map<char, int> to[2*N]; int link[2*N], len[2*N], last = 0, sz = 1; void add_letter(char c){ int p = last; last = sz++; len[last] = len[p] + 1; for(; !to[p][c]; p = link[p]) to[p][c] = last; if(to[p][c] == last){ link[last] = 0; return; } int u = to[p][c]; if(len[u] == len[p]+1){ link[last] = u; return; } int c1 = sz++; to[c1] = to[u]; link[c1] = link[u]; len[c1] = len[p]+1; link[last] = link[u] = c1; for(; to[p][c] == u; p = link[p]) to[p][c] = c1; }
; A016208: Expansion of 1/((1-x)*(1-3*x)*(1-4*x)). ; 1,8,45,220,1001,4368,18565,77540,320001,1309528,5326685,21572460,87087001,350739488,1410132405,5662052980,22712782001,91044838248,364760483725,1460785327100,5848371485001,23409176469808,93683777468645,374876324642820,1499928942876001,6000986704418168,24007759616415165,96042476861888140,384204222636235001,1536919836110987328,6147988181142091285,24592879234662791060,98374296468934442001,393505524466587601288,1574047113638899905005,6296263501873248119580,25185279149445937977001,100741792023642588404048,402969194372146863104325,1611882856321316980881700,6447549661783456508920001,25790253356628391791859608,103161177554997264435977245,412645202605440149549525420,1650582287578113873614951001,6602333581781515320710351968,26409347621533240761593051765,105637430369354501482627138740,422549841127082621239273350001,1690199723457324330883387785128,6760799970676278861312434295885,27043203113246060058586386649660,108172822144607074074355494997001,432691317653296797817451825183088,1730765357837792695829896836317605,6923061693024987296999855952026180,27692247557121398729040229628372001,110768992583549943539283335974289848,443075977399392820026500596279564925 add $0,3 mov $1,4 pow $1,$0 mov $2,3 pow $2,$0 sub $1,$2 sub $1,$2 div $1,12 add $1,1 mov $0,$1
SFX_Fly_1_Ch8: noise_note 2, 15, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 10, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 13, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 8, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 11, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 6, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 9, 1, 18 noise_note 2, 0, 0, 0 noise_note 2, 4, 1, 18 noise_note 2, 0, 0, 0 sound_ret
; A004934: Floor of n*phi^19, where phi is the golden ratio, A001622. ; 0,9349,18698,28047,37396,46745,56094,65443,74792,84141,93490,102839,112188,121537,130886,140235,149584,158933,168282,177631,186980,196329,205678,215027,224376,233725 mul $0,9349
// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #define LOG_TAG "ArmnnDriver" #include "ArmnnDevice.hpp" #include <OperationsUtils.h> #include <log/log.h> #include <memory> #include <string> using namespace android; namespace { std::string GetBackendString(const armnn_driver::DriverOptions& options) { std::stringstream backends; for (auto&& b : options.GetBackends()) { backends << b << " "; } return backends.str(); } } // anonymous namespace namespace armnn_driver { ArmnnDevice::ArmnnDevice(DriverOptions options) : m_Runtime(nullptr, nullptr) , m_ClTunedParameters(nullptr) , m_Options(std::move(options)) { ALOGV("ArmnnDevice::ArmnnDevice()"); armnn::ConfigureLogging(false, m_Options.IsVerboseLoggingEnabled(), armnn::LogSeverity::Trace); if (m_Options.IsVerboseLoggingEnabled()) { SetMinimumLogSeverity(base::VERBOSE); } else { SetMinimumLogSeverity(base::INFO); } armnn::IRuntime::CreationOptions runtimeOptions; #if defined(ARMCOMPUTECL_ENABLED) try { if (!m_Options.GetClTunedParametersFile().empty()) { m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode(), m_Options.GetClTuningLevel()); try { m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); } catch (std::exception& error) { // This is only a warning because the file won't exist the first time you are generating it. ALOGW("ArmnnDevice: Failed to load CL tuned parameters file '%s': %s", m_Options.GetClTunedParametersFile().c_str(), error.what()); } runtimeOptions.m_GpuAccTunedParameters = m_ClTunedParameters; } } catch (const armnn::ClRuntimeUnavailableException& error) { ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what()); } catch (std::exception& error) { ALOGE("ArmnnDevice: Unknown exception: %s. Device will be unavailable.", error.what()); } #endif runtimeOptions.m_EnableGpuProfiling = m_Options.IsGpuProfilingEnabled(); m_Runtime = armnn::IRuntime::Create(runtimeOptions); std::vector<armnn::BackendId> backends; if (m_Runtime) { const armnn::BackendIdSet supportedDevices = m_Runtime->GetDeviceSpec().GetSupportedBackends(); for (auto &backend : m_Options.GetBackends()) { if (std::find(supportedDevices.cbegin(), supportedDevices.cend(), backend) == supportedDevices.cend()) { ALOGW("ArmnnDevice: Requested unknown backend %s", backend.Get().c_str()); } else { backends.push_back(backend); } } } if (backends.empty()) { // No known backend specified throw armnn::InvalidArgumentException("ArmnnDevice: No known backend specified."); } m_Options.SetBackends(backends); ALOGV("ArmnnDevice: Created device with the following backends: %s", GetBackendString(m_Options).c_str()); } } // namespace armnn_driver
; 16 bits, starting at 0x7C00. BITS 16 ORG 0x7C00 BSS EQU 0x504 ; The byte at 0x500 is also used, so align on next dword bound. BSS_SIZE EQU 438 CUR_TETRAMINO EQU BSS ; 16 bytes. ROT_TETRAMINO EQU BSS + 16 ; 16 bytes. OFFSET EQU BSS + 32 ; 2 bytes. STACK EQU BSS + 38 ; 4 bytes reserved in beginning, 400 bytes. LEFT_SCANCODE EQU 75 RIGHT_SCANCODE EQU 77 UP_SCANCODE EQU 72 DOWN_SCANCODE EQU 80 SCORE_DIGITS EQU 5 CPU 686 ; Entry point. ; cs:ip -> linear address (usually 0x7C00, but irrelevant because we are position independent). start: ; Set up segments. xor ax, ax ; Stack. mov ss, ax mov sp, 0xB800 ;why not mov ds, ax mov es, ax ; Clear direction flag. cld ; Clear BSS mov di, BSS mov cx, di ;at least BSS_SIZE rep stosb ; Set to mode 0x03, or 80x25 text mode (ah is zero from above). mov al, 0x03 int 0x10 ; Hide the hardware cursor. mov ch, 0x26 mov ax, 0x103 ; Some BIOS crash without the 03. int 0x10 mov es, sp mov fs, sp ; White spaces on black background. xor di, di mov ax, 0x0F00 mov cx, ax ; At least 80x25x2. rep stosw call pop_check ; Detects if CUR_TETRAMINO at OFFSET is colliding with any thing. ; si -> OFFSET. ; Output: ; Carry set if colliding. tetramino_collision_check: lea bx, [bp + check_collision - tetramino_collision_check] ; Processes the current tetramino, calling bx per "tetramino pixel". ; bx -> where to call to; al contains tetramino pixel, di the address into stack. tetramino_process: pusha ; Gets the offset into stack (i.e., address) into di. ; si -> points at OFFSET. ; Output: ; si -> points at CUR_TETRAMINO. ; di -> address into stack. ; Trashes ax. ; Calculate first index into screen. lodsw aad 0x10 cmp byte [si-1], 0x10 sbb ah, ah xchg bx, ax lea di, [si + (STACK - OFFSET) + 0xFE + bx] xchg bx, ax mov si, CUR_TETRAMINO mov cl, 0x10 .loop: test cl, 0x13;0b1011 jnz .load_loop ; Go to next line in stack. add di, 16 - 4 .load_loop: lodsb ; Call wherever the caller wants us to go. call bx inc di loop .loop popa ret check_collision: cmp al, 0xDB jnz .clear_carry cmp di, STACK + 400 jae .colliding cmp al, [di] .clear_carry: clc jne .next_iter ; Colliding! .colliding: stc mov cl, 1 .next_iter: ret ; Used by the stack joining part. merge: or [di], al ret ; All tetraminos in bitmap format. tetraminos: db 0xF0;0b11110000 ; I db 0xE2;0b11100010 ; J db 0x2E;0b00101110 ; L db 0x66;0b01100110 ; O db 0x36;0b00110110 ; S db 0xE4;0b11100100 ; T db 0x63;0b01100011 ; Z pop_check: pop bp ; Save some bytes. .borders: mov si, STACK - 3 mov ax, 0xDBDB .borders_init: mov [si], ax mov [si + 2], ax mov [si + 4], ax add si, 16 cmp si, STACK + 400 - 3 jbe .borders_init ; Cleared dl implies "load new tetramino". xor dl, dl .event_loop: mov si, OFFSET mov bx, [0x046C] inc bx inc bx ; Wait for 2 PIT ticks. .busy_loop: cmp [0x046C], bx jne .busy_loop ; If we don't need to load a new tetramino, yayy! test dl, dl jnz .input ; Load a tetramino to CUR_TETRAMINO, from the compressed bitmap format. .choose_tetramino: rdtsc ; Only 7 tetraminos, index as 1-7. and ax, 7 je .choose_tetramino ; Get the address of the tetramino (in bitmap format). cwd xchg di, ax ; Load tetramino bitmap in dl. mov dl, [cs:bp + di + (tetraminos - tetramino_collision_check) - 1] shl dx, 4 ; Convert from bitmap to array. mov di, CUR_TETRAMINO mov cl, 0x10 .loop_bitmap: shl dx, 1 ; If the bit we just shifted off was set, store 0xDB. sbb al, al and al, 0xDB mov [di], al inc di loop .loop_bitmap ; Loaded. mov dl, 6 mov word [si], dx jmp .link_next_iter ; Check for input. .input: ; Check for keystroke. mov ah, 0x01 int 0x16 ; If no keystroke, increment vertical offset. jz .vertical_increment ; Clear the keyboard buffer. xor ah, ah int 0x16 ; Go left. .left: cmp ah, LEFT_SCANCODE jne .right dec byte [si] jmp .call_bp ; Go right. .right: cmp ah, RIGHT_SCANCODE jne .rotate inc byte [si] .call_bp: xor ah, LEFT_SCANCODE ^ RIGHT_SCANCODE call bp jc .left ; Rotate it. .rotate: cmp ah, UP_SCANCODE jne .vertical_increment inc cx .rotate_loop: ; Rotates CUR_TETRAMINO 90 degrees clock-wise. ; Output: ; CUR_TETRAMINO -> rotated tetramino. pusha push es ; Reset ES. push ds pop es mov si, CUR_TETRAMINO mov di, ROT_TETRAMINO + 3 push si mov cl, 4 .loop: mov ch, 4 .tetramino_line: movsb scasw inc di dec ch jnz .tetramino_line sub di, 4*4+1 loop .loop pop di mov cl, 4*4/2 ; CH would be zero, from above. rep movsw pop es popa loop .rotate_loop call bp ; To restore, just rotate 3 more times. mov cl, 3 jc .rotate_loop .vertical_increment: mov cl, 1 call upd_score ; Check if we can go below one byte, successfully. inc byte [si + 1] call bp .link_next_iter: jnc .next_iter ; If we can't, we need a new tetramino. dec byte [si + 1] je $ ; Game Over cwd ; Joins the current tetramino to the stack, and any complete lines together. ; si -> OFFSET. push es push ds pop es lea bx, [bp + merge - tetramino_collision_check] call tetramino_process mov si, STACK + 15 std .loop_lines: push si mov cl, 16 .line: lodsb test al, al loopnz .line ; If it was a blank, exit loop to indicate failure. jz .next_line lea cx, [si - (STACK - 1)] lea di, [si + 16] rep movsb mov cl, 64 call upd_score .next_line: pop si add si, 16 cmp si, STACK + 15 + 400 jb .loop_lines cld pop es jmp .borders .next_iter: ; Display the stack. push si ; Add 24 characters padding in the front. mov ah, 0x0F mov di, 48 mov si, STACK .loop_stack_lines: ; Copy 32 characters. mov cl, 16 .stack_line: lodsb ; Store one character as two -- to make stack "squarish" on 80x25 display. stosw stosw loop .stack_line ; Handle remaining 24 characters in row, and starting 24 in next row. add di, 96 cmp di, (25 * 160) ; If we go beyond the last row, we're over. jb .loop_stack_lines pop si ; Displays CUR_TETRAMINO at current OFFSET. ; si -> OFFSET. ; Calculate first index into screen. mov bx, [si] mov al, 40 mul bh mov cl, 12 add cl, bl add ax, cx ; One character takes 2 bytes in video memory. shl ax, 2 xchg di, ax ; Loops for 16 input characters. mov cl, 0x10 mov si, CUR_TETRAMINO mov ah, 0x0F .loop_tetramino: test cl, 0x13;0b1011 jnz .load_tetramino ; Since each tetramino input is 4x4, we must go to next line ; at every multiple of 4. ; Since we output 2 characters for one input char, cover offset of 8. add di, (80 - 8) * 2 .load_tetramino: lodsb test al, al ; Output two characters for "squarish" output. cmovz ax, [es:di] stosw stosw loop .loop_tetramino jmp .event_loop upd_score: mov bx, SCORE_DIGITS * 2 .chk_score: dec bx dec bx js $ mov al, '0' xchg [fs:bx], al or al, 0x30 cmp al, '9' je .chk_score inc ax mov [fs:bx], al loop upd_score ret ; IT'S A SECRET TO EVERYBODY. db "ShNoXgSo" ; Padding. times 510 - ($ - $$) db 0 BIOS_signature: dw 0xAA55 ; Pad to floppy disk. times (1440 * 1024) - ($ - $$) db 0
############################################################################### # Copyright 2018 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 .p2align 4, 0x90 DECODE_DATA: TransFwdLO: .byte 0x0 .byte 0x1 .byte 0x2E .byte 0x2F .byte 0x49 .byte 0x48 .byte 0x67 .byte 0x66 .byte 0x43 .byte 0x42 .byte 0x6D .byte 0x6C .byte 0xA .byte 0xB .byte 0x24 .byte 0x25 TransFwdHI: .byte 0x0 .byte 0x35 .byte 0xD0 .byte 0xE5 .byte 0x3D .byte 0x8 .byte 0xED .byte 0xD8 .byte 0xE9 .byte 0xDC .byte 0x39 .byte 0xC .byte 0xD4 .byte 0xE1 .byte 0x4 .byte 0x31 TransInvLO: .byte 0x0 .byte 0x1 .byte 0x5C .byte 0x5D .byte 0xE0 .byte 0xE1 .byte 0xBC .byte 0xBD .byte 0x50 .byte 0x51 .byte 0xC .byte 0xD .byte 0xB0 .byte 0xB1 .byte 0xEC .byte 0xED TransInvHI: .byte 0x0 .byte 0x1F .byte 0xEE .byte 0xF1 .byte 0x55 .byte 0x4A .byte 0xBB .byte 0xA4 .byte 0x6A .byte 0x75 .byte 0x84 .byte 0x9B .byte 0x3F .byte 0x20 .byte 0xD1 .byte 0xCE GF16_csize: .byte 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF GF16_logTbl: .byte 0xC0, 0x0, 0x1, 0x4, 0x2, 0x8, 0x5, 0xA, 0x3, 0xE, 0x9, 0x7, 0x6, 0xD, 0xB, 0xC GF16_expTbl: .byte 0x1, 0x2, 0x4, 0x8, 0x3, 0x6, 0xC, 0xB, 0x5, 0xA, 0x7, 0xE, 0xF, 0xD, 0x9, 0x1 GF16_sqr1: .byte 0x0, 0x9, 0x2, 0xB, 0x8, 0x1, 0xA, 0x3, 0x6, 0xF, 0x4, 0xD, 0xE, 0x7, 0xC, 0x5 GF16_invLog: .byte 0xC0, 0x0, 0xE, 0xB, 0xD, 0x7, 0xA, 0x5, 0xC, 0x1, 0x6, 0x8, 0x9, 0x2, 0x4, 0x3 InvAffineLO: .byte 0x0 .byte 0x50 .byte 0x36 .byte 0x66 .byte 0x15 .byte 0x45 .byte 0x23 .byte 0x73 .byte 0x82 .byte 0xD2 .byte 0xB4 .byte 0xE4 .byte 0x97 .byte 0xC7 .byte 0xA1 .byte 0xF1 InvAffineHI: .byte 0x0 .byte 0x1 .byte 0x34 .byte 0x35 .byte 0x40 .byte 0x41 .byte 0x74 .byte 0x75 .byte 0x3E .byte 0x3F .byte 0xA .byte 0xB .byte 0x7E .byte 0x7F .byte 0x4A .byte 0x4B InvAffineCnt: .quad 0x4848484848484848, 0x4848484848484848 InvShiftRows: .byte 0,13,10,7,4,1,14,11,8,5,2,15,12,9,6,3 GF16mul_4_2x: .byte 0x0, 0x24, 0x48, 0x6C, 0x83, 0xA7, 0xCB, 0xEF, 0x36, 0x12, 0x7E, 0x5A, 0xB5, 0x91, 0xFD, 0xD9 GF16mul_1_6x: .byte 0x0, 0x61, 0xC2, 0xA3, 0xB4, 0xD5, 0x76, 0x17, 0x58, 0x39, 0x9A, 0xFB, 0xEC, 0x8D, 0x2E, 0x4F GF16mul_C_6x: .byte 0x0, 0x6C, 0xCB, 0xA7, 0xB5, 0xD9, 0x7E, 0x12, 0x5A, 0x36, 0x91, 0xFD, 0xEF, 0x83, 0x24, 0x48 GF16mul_3_Ax: .byte 0x0, 0xA3, 0x76, 0xD5, 0xEC, 0x4F, 0x9A, 0x39, 0xFB, 0x58, 0x8D, 0x2E, 0x17, 0xB4, 0x61, 0xC2 GF16mul_B_0x: .byte 0x0, 0xB, 0x5, 0xE, 0xA, 0x1, 0xF, 0x4, 0x7, 0xC, 0x2, 0x9, 0xD, 0x6, 0x8, 0x3 GF16mul_0_Bx: .byte 0x0, 0xB0, 0x50, 0xE0, 0xA0, 0x10, 0xF0, 0x40, 0x70, 0xC0, 0x20, 0x90, 0xD0, 0x60, 0x80, 0x30 GF16mul_2_4x: .byte 0x0, 0x42, 0x84, 0xC6, 0x38, 0x7A, 0xBC, 0xFE, 0x63, 0x21, 0xE7, 0xA5, 0x5B, 0x19, 0xDF, 0x9D GF16mul_2_6x: .byte 0x0, 0x62, 0xC4, 0xA6, 0xB8, 0xDA, 0x7C, 0x1E, 0x53, 0x31, 0x97, 0xF5, 0xEB, 0x89, 0x2F, 0x4D ColumnROR: .byte 1,2,3,0,5,6,7,4,9,10,11,8,13,14,15,12 .p2align 4, 0x90 .globl _n8_SafeDecrypt_RIJ128 _n8_SafeDecrypt_RIJ128: lea (,%rdx,4), %rax lea (%rcx,%rax,4), %rcx movdqu (%rdi), %xmm0 movdqa GF16_csize(%rip), %xmm7 movdqa TransFwdLO(%rip), %xmm2 movdqa TransFwdHI(%rip), %xmm1 movdqa %xmm0, %xmm3 psrlw $(4), %xmm0 pand %xmm7, %xmm3 pand %xmm7, %xmm0 pshufb %xmm3, %xmm2 pshufb %xmm0, %xmm1 pxor %xmm1, %xmm2 pxor (%rcx), %xmm2 sub $(16), %rcx sub $(1), %rdx .Ldecode_roundgas_1: movdqa InvAffineLO(%rip), %xmm0 movdqa InvAffineHI(%rip), %xmm1 movdqa %xmm2, %xmm3 psrlw $(4), %xmm2 pand %xmm7, %xmm3 pand %xmm7, %xmm2 pshufb %xmm3, %xmm0 pshufb %xmm2, %xmm1 pxor %xmm1, %xmm0 pxor InvAffineCnt(%rip), %xmm0 movdqa %xmm0, %xmm1 pand %xmm7, %xmm0 psrlw $(4), %xmm1 pand %xmm7, %xmm1 movdqa GF16_logTbl(%rip), %xmm5 pshufb %xmm0, %xmm5 pxor %xmm1, %xmm0 movdqa GF16_logTbl(%rip), %xmm2 pshufb %xmm0, %xmm2 movdqa GF16_sqr1(%rip), %xmm4 pshufb %xmm1, %xmm4 movdqa GF16_logTbl(%rip), %xmm3 pshufb %xmm1, %xmm3 paddb %xmm2, %xmm5 movdqa %xmm5, %xmm0 pcmpgtb %xmm7, %xmm5 psubb %xmm5, %xmm0 movdqa GF16_expTbl(%rip), %xmm5 pshufb %xmm0, %xmm5 pxor %xmm5, %xmm4 movdqa GF16_invLog(%rip), %xmm5 pshufb %xmm4, %xmm5 paddb %xmm5, %xmm2 paddb %xmm5, %xmm3 movdqa %xmm2, %xmm5 pcmpgtb %xmm7, %xmm2 psubb %xmm2, %xmm5 movdqa GF16_expTbl(%rip), %xmm0 pshufb %xmm5, %xmm0 movdqa %xmm3, %xmm5 pcmpgtb %xmm7, %xmm3 psubb %xmm3, %xmm5 movdqa GF16_expTbl(%rip), %xmm1 pshufb %xmm5, %xmm1 pshufb InvShiftRows(%rip), %xmm0 pshufb InvShiftRows(%rip), %xmm1 movdqa GF16mul_4_2x(%rip), %xmm2 pshufb %xmm0, %xmm2 pshufb ColumnROR(%rip), %xmm0 movdqa GF16mul_1_6x(%rip), %xmm3 pshufb %xmm1, %xmm3 pshufb ColumnROR(%rip), %xmm1 pxor %xmm3, %xmm2 movdqa GF16mul_C_6x(%rip), %xmm3 pshufb %xmm0, %xmm3 pshufb ColumnROR(%rip), %xmm0 pxor %xmm3, %xmm2 movdqa GF16mul_3_Ax(%rip), %xmm3 pshufb %xmm1, %xmm3 pshufb ColumnROR(%rip), %xmm1 pxor %xmm3, %xmm2 movdqa GF16mul_B_0x(%rip), %xmm3 pshufb %xmm0, %xmm3 pshufb ColumnROR(%rip), %xmm0 pxor %xmm3, %xmm2 movdqa GF16mul_0_Bx(%rip), %xmm3 pshufb %xmm1, %xmm3 pshufb ColumnROR(%rip), %xmm1 pxor %xmm3, %xmm2 movdqa GF16mul_2_4x(%rip), %xmm3 pshufb %xmm0, %xmm3 pxor %xmm3, %xmm2 movdqa GF16mul_2_6x(%rip), %xmm3 pshufb %xmm1, %xmm3 pxor %xmm3, %xmm2 pxor (%rcx), %xmm2 sub $(16), %rcx sub $(1), %rdx jg .Ldecode_roundgas_1 movdqa InvAffineLO(%rip), %xmm0 movdqa InvAffineHI(%rip), %xmm1 movdqa %xmm2, %xmm3 psrlw $(4), %xmm2 pand %xmm7, %xmm3 pand %xmm7, %xmm2 pshufb %xmm3, %xmm0 pshufb %xmm2, %xmm1 pxor %xmm1, %xmm0 pxor InvAffineCnt(%rip), %xmm0 movdqa %xmm0, %xmm1 pand %xmm7, %xmm0 psrlw $(4), %xmm1 pand %xmm7, %xmm1 movdqa GF16_logTbl(%rip), %xmm5 pshufb %xmm0, %xmm5 pxor %xmm1, %xmm0 movdqa GF16_logTbl(%rip), %xmm2 pshufb %xmm0, %xmm2 movdqa GF16_sqr1(%rip), %xmm4 pshufb %xmm1, %xmm4 movdqa GF16_logTbl(%rip), %xmm3 pshufb %xmm1, %xmm3 paddb %xmm2, %xmm5 movdqa %xmm5, %xmm0 pcmpgtb %xmm7, %xmm5 psubb %xmm5, %xmm0 movdqa GF16_expTbl(%rip), %xmm5 pshufb %xmm0, %xmm5 pxor %xmm5, %xmm4 movdqa GF16_invLog(%rip), %xmm5 pshufb %xmm4, %xmm5 paddb %xmm5, %xmm2 paddb %xmm5, %xmm3 movdqa %xmm2, %xmm5 pcmpgtb %xmm7, %xmm2 psubb %xmm2, %xmm5 movdqa GF16_expTbl(%rip), %xmm0 pshufb %xmm5, %xmm0 movdqa %xmm3, %xmm5 pcmpgtb %xmm7, %xmm3 psubb %xmm3, %xmm5 movdqa GF16_expTbl(%rip), %xmm1 pshufb %xmm5, %xmm1 psllw $(4), %xmm1 por %xmm0, %xmm1 pshufb InvShiftRows(%rip), %xmm1 pxor (%rcx), %xmm1 movdqa TransInvLO(%rip), %xmm0 movdqa TransInvHI(%rip), %xmm2 movdqa %xmm1, %xmm3 psrlw $(4), %xmm1 pand %xmm7, %xmm3 pand %xmm7, %xmm1 pshufb %xmm3, %xmm0 pshufb %xmm1, %xmm2 pxor %xmm2, %xmm0 movdqu %xmm0, (%rsi) ret
; A108047: Concatenation of the previous pair of numbers, with the first two terms both 1. ; Submitted by Jon Maiga ; 1,1,11,111,11111,11111111,1111111111111,111111111111111111111,1111111111111111111111111111111111,1111111111111111111111111111111111111111111111111111111,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 add $0,1 seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. mov $1,10 pow $1,$0 div $1,9 mov $0,$1
#include <algorithm> #if !defined(_WIN32) && !defined(__OpenBSD__) && !defined(__FreeBSD__) # include <alloca.h> #endif #if defined (__MINGW32__) # define alloca __builtin_alloca #endif #include <serial/SerialConnection.h> #ifdef _WIN32 #include <serial/impl/SerialConnectionWindows.h> #else #include <serial/impl/SerialConnectionUnix.h> #endif using std::invalid_argument; using std::min; using std::numeric_limits; using std::vector; using std::size_t; using std::string; using namespace Connection; class SerialConnection::ScopedReadLock { public: ScopedReadLock(SerialConnectionImpl* pimpl) : pimpl_(pimpl) { this->pimpl_->ReadLock(); } ~ScopedReadLock() { this->pimpl_->ReadUnlock(); } private: // Disable copy constructors ScopedReadLock(const ScopedReadLock&); const ScopedReadLock& operator=(ScopedReadLock); SerialConnectionImpl* pimpl_; }; class SerialConnection::ScopedWriteLock { public: ScopedWriteLock(SerialConnectionImpl* pimpl) : pimpl_(pimpl) { this->pimpl_->WriteLock(); } ~ScopedWriteLock() { this->pimpl_->WriteUnlock(); } private: // Disable copy constructors ScopedWriteLock(const ScopedWriteLock&); const ScopedWriteLock& operator=(ScopedWriteLock); SerialConnectionImpl* pimpl_; }; SerialConnection::SerialConnection(const string& port, uint32_t baudrate, Timeout timeout, bytesize_t bytesize, parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol) : pimpl_(new SerialConnectionImpl(port, baudrate, bytesize, parity, stopbits, flowcontrol)) { pimpl_->SetTimeout(timeout); } Connection::SerialConnection::~SerialConnection() { delete pimpl_; } void SerialConnection::Open() { pimpl_->Open(); } void SerialConnection::Close() { pimpl_->Close(); } bool SerialConnection::IsOpen() const { return pimpl_->IsOpen(); } size_t SerialConnection::Available() { return pimpl_->Available(); } bool SerialConnection::WaitReadable() { Timeout timeout(pimpl_->GetTimeout()); return pimpl_->WaitReadable(timeout.read_timeout_constant); } void SerialConnection::WaitByteTimes(size_t count) { pimpl_->WaitByteTimes(count); } size_t SerialConnection::Read(uint8_t* buffer, size_t size) { return this->pimpl_->Read(buffer, size); } size_t SerialConnection::read_(uint8_t* buffer, size_t size) { ScopedReadLock lock(this->pimpl_); return this->pimpl_->Read(buffer, size); } size_t SerialConnection::Read(std::vector<uint8_t>& buffer, size_t size) { ScopedReadLock lock(this->pimpl_); uint8_t* buffer_ = new uint8_t[size]; size_t bytes_read = 0; try { bytes_read = this->pimpl_->Read(buffer_, size); } catch (const std::exception& e) { delete[] buffer_; throw; } buffer.insert(buffer.end(), buffer_, buffer_ + bytes_read); delete[] buffer_; return bytes_read; } size_t SerialConnection::Read(std::string& buffer, size_t size) { ScopedReadLock lock(this->pimpl_); uint8_t* buffer_ = new uint8_t[size]; size_t bytes_read = 0; try { bytes_read = this->pimpl_->Read(buffer_, size); } catch (const std::exception& e) { delete[] buffer_; throw; } buffer.append(reinterpret_cast<const char*>(buffer_), bytes_read); delete[] buffer_; return bytes_read; } string SerialConnection::Read(size_t size) { std::string buffer; this->Read(buffer, size); return buffer; } size_t SerialConnection::Readline(string& buffer, size_t size, string eol) { ScopedReadLock lock(this->pimpl_); size_t eol_len = eol.length(); uint8_t* buffer_ = static_cast<uint8_t*> (alloca(size * sizeof(uint8_t))); size_t read_so_far = 0; while (true) { size_t bytes_read = this->read_(buffer_ + read_so_far, 1); read_so_far += bytes_read; if (bytes_read == 0) { break; // Timeout occured on reading 1 byte } if (string(reinterpret_cast<const char*> (buffer_ + read_so_far - eol_len), eol_len) == eol) { break; // EOL found } if (read_so_far == size) { break; // Reached the maximum read length } } buffer.append(reinterpret_cast<const char*> (buffer_), read_so_far); return read_so_far; } string SerialConnection::Readline(size_t size, string eol) { std::string buffer; this->Readline(buffer, size, eol); return buffer; } vector<string> SerialConnection::Readlines(size_t size, string eol) { ScopedReadLock lock(this->pimpl_); std::vector<std::string> lines; size_t eol_len = eol.length(); uint8_t* buffer_ = static_cast<uint8_t*> (alloca(size * sizeof(uint8_t))); size_t read_so_far = 0; size_t start_of_line = 0; while (read_so_far < size) { size_t bytes_read = this->read_(buffer_ + read_so_far, 1); read_so_far += bytes_read; if (bytes_read == 0) { if (start_of_line != read_so_far) { lines.push_back( string(reinterpret_cast<const char*> (buffer_ + start_of_line), read_so_far - start_of_line)); } break; // Timeout occured on reading 1 byte } if (string(reinterpret_cast<const char*> (buffer_ + read_so_far - eol_len), eol_len) == eol) { // EOL found lines.push_back( string(reinterpret_cast<const char*> (buffer_ + start_of_line), read_so_far - start_of_line)); start_of_line = read_so_far; } if (read_so_far == size) { if (start_of_line != read_so_far) { lines.push_back( string(reinterpret_cast<const char*> (buffer_ + start_of_line), read_so_far - start_of_line)); } break; // Reached the maximum read length } } return lines; } size_t SerialConnection::Write(const string& data) { ScopedWriteLock lock(this->pimpl_); return this->write_(reinterpret_cast<const uint8_t*>(data.c_str()), data.length()); } size_t SerialConnection::Write(const std::vector<uint8_t>& data) { ScopedWriteLock lock(this->pimpl_); return this->write_(&data[0], data.size()); } size_t SerialConnection::Write(const uint8_t* data, size_t size) { ScopedWriteLock lock(this->pimpl_); return this->write_(data, size); } size_t SerialConnection::write_(const uint8_t* data, size_t length) { return pimpl_->Write(data, length); } void SerialConnection::SetPortName(const string& port) { ScopedReadLock rlock(this->pimpl_); ScopedWriteLock wlock(this->pimpl_); bool was_open = pimpl_->IsOpen(); if (was_open) Close(); pimpl_->SetPortName(port); if (was_open) Open(); } string SerialConnection::GetPortName() const { return pimpl_->GetPortName(); } void SerialConnection::SetTimeout(Timeout timeout) { pimpl_->SetTimeout(timeout); } Connection::Timeout SerialConnection::GetTimeout() const { return pimpl_->GetTimeout(); } void SerialConnection::SetBaudrate(uint32_t baudrate) { pimpl_->SetBaudrate(baudrate); } uint32_t SerialConnection::GetBaudrate() const { return uint32_t(pimpl_->GetBaudrate()); } void SerialConnection::SetBytesize(bytesize_t bytesize) { pimpl_->SetBytesize(bytesize); } bytesize_t SerialConnection::GetBytesize() const { return pimpl_->GetBytesize(); } void SerialConnection::SetParity(parity_t parity) { pimpl_->SetParity(parity); } parity_t SerialConnection::GetParity() const { return pimpl_->GetParity(); } void SerialConnection::SetStopbits(stopbits_t stopbits) { pimpl_->SetStopbits(stopbits); } stopbits_t SerialConnection::GetStopbits() const { return pimpl_->GetStopbits(); } void SerialConnection::SetFlowcontrol(flowcontrol_t flowcontrol) { pimpl_->SetFlowcontrol(flowcontrol); } flowcontrol_t SerialConnection::GetFlowcontrol() const { return pimpl_->GetFlowcontrol(); } void SerialConnection::Flush() { ScopedReadLock rlock(this->pimpl_); ScopedWriteLock wlock(this->pimpl_); pimpl_->Flush(); } void SerialConnection::FlushInput() { ScopedReadLock lock(this->pimpl_); pimpl_->FlushInput(); } void SerialConnection::FlushOutput() { ScopedWriteLock lock(this->pimpl_); pimpl_->FlushOutput(); } void SerialConnection::SendBreak(int duration) { pimpl_->SendBreak(duration); } void SerialConnection::SetBreak(bool level) { pimpl_->SetBreak(level); } void SerialConnection::SetRTS(bool level) { pimpl_->SetRTS(level); } void SerialConnection::SetDTR(bool level) { pimpl_->SetDTR(level); } bool SerialConnection::WaitForChange() { return pimpl_->WaitForChange(); } bool SerialConnection::GetCTS() { return pimpl_->GetCTS(); } bool SerialConnection::GetDSR() { return pimpl_->GetDSR(); } bool SerialConnection::GetRI() { return pimpl_->GetRI(); } bool SerialConnection::GetCD() { return pimpl_->GetCD(); }
; ; Copyright (C) 2019 Assured Information Security, Inc. ; ; 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. bits 64 default rel section .text global _read_gdt _read_gdt: sgdt [rdi] ret global _write_gdt _write_gdt: lgdt [rdi] ret
; Copyright (c) Piotr Durlej ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; 2. 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. ; ; 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 HOLDER 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. ; int 0x19
############################################################################### # Copyright 2018 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. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 5, 0x90 ENCODE_DATA: u128_str: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 increment: .quad 1,0 .p2align 5, 0x90 .globl g9_AuthEncrypt_RIJ128_AES_NI .type g9_AuthEncrypt_RIJ128_AES_NI, @function g9_AuthEncrypt_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (28)(%ebp), %eax movdqa (%eax), %xmm0 movdqa (16)(%eax), %xmm2 movdqa (32)(%eax), %xmm1 call .L__0000gas_1 .L__0000gas_1: pop %eax sub $(.L__0000gas_1-ENCODE_DATA), %eax movdqa ((u128_str-ENCODE_DATA))(%eax), %xmm7 pshufb %xmm7, %xmm2 pshufb %xmm7, %xmm1 movdqa %xmm1, %xmm3 pandn %xmm2, %xmm3 pand %xmm1, %xmm2 movl (16)(%ebp), %edx movl (20)(%ebp), %ecx lea (,%edx,4), %edx lea (,%edx,4), %edx lea (%edx,%ecx), %ecx neg %edx mov %edx, %ebx movl (8)(%ebp), %esi movl (12)(%ebp), %edi .p2align 5, 0x90 .Lblk_loopgas_1: movdqu (%esi), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm3, %xmm5 paddq ((increment-ENCODE_DATA))(%eax), %xmm2 pand %xmm1, %xmm2 por %xmm2, %xmm5 pshufb %xmm7, %xmm5 movdqa (%edx,%ecx), %xmm6 add $(16), %edx pxor %xmm6, %xmm5 pxor %xmm6, %xmm0 movdqa (%edx,%ecx), %xmm6 .p2align 5, 0x90 .Lcipher_loopgas_1: aesenc %xmm6, %xmm5 aesenc %xmm6, %xmm0 movdqa (16)(%edx,%ecx), %xmm6 add $(16), %edx jnz .Lcipher_loopgas_1 aesenclast %xmm6, %xmm5 aesenclast %xmm6, %xmm0 pxor %xmm5, %xmm4 movdqu %xmm4, (%edi) mov %ebx, %edx add $(16), %esi add $(16), %edi subl $(16), (24)(%ebp) jnz .Lblk_loopgas_1 movl (28)(%ebp), %eax movdqu %xmm0, (%eax) movdqu %xmm5, (16)(%eax) pop %edi pop %esi pop %ebx pop %ebp ret .Lfe1: .size g9_AuthEncrypt_RIJ128_AES_NI, .Lfe1-(g9_AuthEncrypt_RIJ128_AES_NI) .p2align 5, 0x90 .globl g9_DecryptAuth_RIJ128_AES_NI .type g9_DecryptAuth_RIJ128_AES_NI, @function g9_DecryptAuth_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (28)(%ebp), %eax movdqa (%eax), %xmm0 movdqa (16)(%eax), %xmm2 movdqa (32)(%eax), %xmm1 call .L__0001gas_2 .L__0001gas_2: pop %eax sub $(.L__0001gas_2-ENCODE_DATA), %eax movdqa ((u128_str-ENCODE_DATA))(%eax), %xmm7 pshufb %xmm7, %xmm2 pshufb %xmm7, %xmm1 movdqa %xmm1, %xmm3 pandn %xmm2, %xmm3 pand %xmm1, %xmm2 movl (16)(%ebp), %edx movl (20)(%ebp), %ecx lea (,%edx,4), %edx lea (,%edx,4), %edx lea (%edx,%ecx), %ecx neg %edx mov %edx, %ebx movl (8)(%ebp), %esi movl (12)(%ebp), %edi .p2align 5, 0x90 .Lblk_loopgas_2: movdqu (%esi), %xmm4 movdqa %xmm3, %xmm5 paddq ((increment-ENCODE_DATA))(%eax), %xmm2 pand %xmm1, %xmm2 por %xmm2, %xmm5 pshufb %xmm7, %xmm5 movdqa (%edx,%ecx), %xmm6 add $(16), %edx pxor %xmm6, %xmm5 movdqa (%edx,%ecx), %xmm6 .p2align 5, 0x90 .Lcipher_loopgas_2: aesenc %xmm6, %xmm5 movdqa (16)(%edx,%ecx), %xmm6 add $(16), %edx jnz .Lcipher_loopgas_2 aesenclast %xmm6, %xmm5 pxor %xmm5, %xmm4 movdqu %xmm4, (%edi) mov %ebx, %edx movdqa (%edx,%ecx), %xmm6 add $(16), %edx pxor %xmm4, %xmm0 pxor %xmm6, %xmm0 movdqa (%edx,%ecx), %xmm6 .p2align 5, 0x90 .Lauth_loopgas_2: aesenc %xmm6, %xmm0 movdqa (16)(%edx,%ecx), %xmm6 add $(16), %edx jnz .Lauth_loopgas_2 aesenclast %xmm6, %xmm0 mov %ebx, %edx add $(16), %esi add $(16), %edi subl $(16), (24)(%ebp) jnz .Lblk_loopgas_2 movl (28)(%ebp), %eax movdqu %xmm0, (%eax) movdqu %xmm6, (16)(%eax) pop %edi pop %esi pop %ebx pop %ebp ret .Lfe2: .size g9_DecryptAuth_RIJ128_AES_NI, .Lfe2-(g9_DecryptAuth_RIJ128_AES_NI)
; A191762: Digital roots of the nonzero even squares. ; 4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9,4,7,9,1,1,9,7,4,9 sub $0,4 cal $0,191760 ; Digital root of the n-th odd square. mov $1,$0
; A258745: Order of general affine group AGL(n,2) (=A028365(n)) divided by (n+1). ; Submitted by Christian Krause ; 1,1,8,336,64512,53329920,184308203520,2621599886868480,152122702768688332800,35820150273699719298416640,34112245508649716682268134604800,131089993748184007771243790830298726400,2029650642403883210241235064170615545004032000,126462999028351383186939572421824895314601304915968000,31682075452091847967291074379573495550386268294497623972249600,31891248117924666849614642202485290865648850530482287965144145199104000,128912731924961260423363371404446449047517338056795587981481795641719830609920000 mov $2,$0 seq $0,28365 ; Order of general affine group over GF(2), AGL(n,2). add $2,1 div $0,$2
hlcoord EQUS "coord hl," bccoord EQUS "coord bc," decoord EQUS "coord de," coord: MACRO ; register, x, y[, origin] if _NARG < 4 ld \1, (\3) * SCREEN_WIDTH + (\2) + wTileMap else ld \1, (\3) * SCREEN_WIDTH + (\2) + \4 endc ENDM hlbgcoord EQUS "bgcoord hl," bcbgcoord EQUS "bgcoord bc," debgcoord EQUS "bgcoord de," bgcoord: MACRO ; register, x, y[, origin] if _NARG < 4 ld \1, (\3) * BG_MAP_WIDTH + (\2) + vBGMap0 else ld \1, (\3) * BG_MAP_WIDTH + (\2) + \4 endc ENDM dwcoord: MACRO ; x, y rept _NARG / 2 dw (\2) * SCREEN_WIDTH + (\1) + wTileMap shift shift endr ENDM ldcoord_a: MACRO ; x, y[, origin] if _NARG < 3 ld [(\2) * SCREEN_WIDTH + (\1) + wTileMap], a else ld [(\2) * SCREEN_WIDTH + (\1) + \3], a endc ENDM lda_coord: MACRO ; x, y[, origin] if _NARG < 3 ld a, [(\2) * SCREEN_WIDTH + (\1) + wTileMap] else ld a, [(\2) * SCREEN_WIDTH + (\1) + \3] endc ENDM
; A035250: Number of primes between n and 2n (inclusive). ; Submitted by Christian Krause ; 1,2,2,2,2,2,3,2,3,4,4,4,4,3,4,5,5,4,5,4,5,6,6,6,6,6,7,7,7,7,8,7,7,8,8,9,10,9,9,10,10,10,10,9,10,10,10,9,10,10,11,12,12,12,13,13,14,14,14,13,13,12,12,13,13,14,14,13,14,15,15,14,14,13,14,15,15,15,16,15,15,16,16,16,16,16,17,17,17,17,18,18,18,18,18,19,20,19,20,21 mov $3,$0 add $3,1 mov $5,$0 lpb $3 mov $2,$5 seq $2,80339 ; Characteristic function of {1} union {primes}: 1 if n is 1 or a prime, else 0. sub $3,1 add $4,$2 add $5,1 lpe mov $0,$4
; A199899: Number of -n..n arrays x(0..3) of 4 elements with zero sum, and adjacent elements not both strictly positive and not both strictly negative. ; 15,49,111,209,351,545,799,1121,1519,2001,2575,3249,4031,4929,5951,7105,8399,9841,11439,13201,15135,17249,19551,22049,24751,27665,30799,34161,37759,41601,45695,50049,54671,59569,64751,70225,75999,82081,88479,95201,102255,109649,117391,125489,133951,142785,151999,161601,171599,182001,192815,204049,215711,227809,240351,253345,266799,280721,295119,310001,325375,341249,357631,374529,391951,409905,428399,447441,467039,487201,507935,529249,551151,573649,596751,620465,644799,669761,695359,721601,748495 mov $2,$0 add $0,4 add $2,$0 bin $2,2 mul $0,$2 sub $0,24 div $0,3 mul $0,2 add $0,15
// Copyright 2015 The Chromium 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 "mojo/services/network/network_service_delegate.h" #include <utility> #include "base/at_exit.h" #include "base/base_paths.h" #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" #include "mojo/message_pump/message_pump_mojo.h" #include "mojo/services/network/cookie_store_impl.h" #include "mojo/services/network/network_service_delegate_observer.h" #include "mojo/services/network/network_service_impl.h" #include "mojo/services/network/url_loader_factory_impl.h" #include "mojo/services/network/web_socket_factory_impl.h" #include "mojo/shell/public/cpp/application_connection.h" #include "mojo/util/capture_util.h" #include "sql/mojo/mojo_vfs.h" namespace { const char kSQLThreadName[] = "SQL_IO_Thread"; const char kUserDataDir[] = "user-data-dir"; // SQL blocks on the filesystem service, so perform all SQL functions on a // separate thread. class SQLThread : public base::Thread { public: SQLThread(filesystem::DirectoryPtr directory) : base::Thread(kSQLThreadName), directory_info_(directory.PassInterface()) { base::Thread::Options options; options.message_pump_factory = base::Bind(&mojo::common::MessagePumpMojo::Create); StartWithOptions(options); } ~SQLThread() override { Stop(); } void Init() override { filesystem::DirectoryPtr directory; directory.Bind(std::move(directory_info_)); vfs_.reset(new sql::ScopedMojoFilesystemVFS(std::move(directory))); } void CleanUp() override { vfs_.reset(); } private: // Our VFS which wraps sqlite so that we can reuse the current sqlite code. scoped_ptr<sql::ScopedMojoFilesystemVFS> vfs_; // This member is used to safely pass data from one thread to another. It is // set in the constructor and is consumed in Init(). mojo::InterfacePtrInfo<filesystem::Directory> directory_info_; DISALLOW_COPY_AND_ASSIGN(SQLThread); }; } // namespace namespace mojo { NetworkServiceDelegate::NetworkServiceDelegate() : app_(nullptr), binding_(this) { } NetworkServiceDelegate::~NetworkServiceDelegate() { } void NetworkServiceDelegate::AddObserver( NetworkServiceDelegateObserver* observer) { observers_.AddObserver(observer); } void NetworkServiceDelegate::RemoveObserver( NetworkServiceDelegateObserver* observer) { observers_.RemoveObserver(observer); } void NetworkServiceDelegate::Initialize(ApplicationImpl* app) { app_ = app; #if !defined(OS_ANDROID) // TODO(erg): The following doesn't work when running the android // apptests. It works in the mandoline shell (on desktop and on android), and // in the apptests on desktop. However, on android, whenever we make the call // to OpenFileSystem, the entire mojo system hangs to the point where writes // to stderr that previously would have printed to our console aren't. The // apptests are also fairly resistant to being run under gdb on android. app_->ConnectToService("mojo:filesystem", &files_); filesystem::FileSystemClientPtr client; binding_.Bind(GetProxy(&client)); filesystem::FileError error = filesystem::FILE_ERROR_FAILED; filesystem::DirectoryPtr directory; files_->OpenFileSystem("origin", GetProxy(&directory), std::move(client), Capture(&error)); files_.WaitForIncomingResponse(); io_worker_thread_.reset(new SQLThread(std::move(directory))); #endif // TODO(erg): Find everything else that writes to the filesystem and // transition it to proxying mojo:filesystem. We shouldn't have any path // calculation code here, but sadly need it until the transition is done. In // the mean time, manually handle the user-data-dir switch (which gets set in // tests) so that tests are writing to a temp dir. base::FilePath base_path; const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(kUserDataDir)) { base_path = command_line->GetSwitchValuePath(kUserDataDir); } else { CHECK(PathService::Get(base::DIR_TEMP, &base_path)); base_path = base_path.Append(FILE_PATH_LITERAL("network_service")); } scoped_refptr<base::SequencedTaskRunner> worker_thread; #if !defined(OS_ANDROID) worker_thread = io_worker_thread_->task_runner(); #endif context_.reset(new NetworkContext(base_path, worker_thread, this)); tracing_.Initialize(app); } bool NetworkServiceDelegate::ConfigureIncomingConnection( ApplicationConnection* connection) { DCHECK(context_); connection->AddService<CookieStore>(this); connection->AddService<NetworkService>(this); connection->AddService<URLLoaderFactory>(this); connection->AddService<WebSocketFactory>(this); return true; } bool NetworkServiceDelegate::OnShellConnectionError() { EnsureIOThreadShutdown(); return true; } void NetworkServiceDelegate::Quit() { EnsureIOThreadShutdown(); // Destroy the NetworkContext now as it requires MessageLoop::current() upon // destruction and it is the last moment we know for sure that it is // running. context_.reset(); } void NetworkServiceDelegate::Create(ApplicationConnection* connection, InterfaceRequest<NetworkService> request) { new NetworkServiceImpl(app_->app_lifetime_helper()->CreateAppRefCount(), std::move(request)); } void NetworkServiceDelegate::Create(ApplicationConnection* connection, InterfaceRequest<CookieStore> request) { new CookieStoreImpl( context_.get(), GURL(connection->GetRemoteApplicationURL()).GetOrigin(), app_->app_lifetime_helper()->CreateAppRefCount(), std::move(request)); } void NetworkServiceDelegate::Create( ApplicationConnection* connection, InterfaceRequest<WebSocketFactory> request) { new WebSocketFactoryImpl(context_.get(), app_->app_lifetime_helper()->CreateAppRefCount(), std::move(request)); } void NetworkServiceDelegate::Create( ApplicationConnection* connection, InterfaceRequest<URLLoaderFactory> request) { new URLLoaderFactoryImpl(context_.get(), app_->app_lifetime_helper()->CreateAppRefCount(), std::move(request)); } void NetworkServiceDelegate::OnFileSystemShutdown() { EnsureIOThreadShutdown(); } void NetworkServiceDelegate::EnsureIOThreadShutdown() { if (io_worker_thread_) { // Broadcast to the entire system that we have to shut down anything // depending on the worker thread. Either we're shutting down or the // filesystem service is shutting down. FOR_EACH_OBSERVER(NetworkServiceDelegateObserver, observers_, OnIOWorkerThreadShutdown()); // Destroy the io worker thread here so that we can commit any pending // cookies here. io_worker_thread_.reset(); } } } // namespace mojo
; A190636: a(n)=(n^3+3*n^7)/4. ; 1,98,1647,12304,58625,210006,617743,1572992,3587409,7500250,14615711,26874288,47061937,79060814,128145375,201327616,307755233,459166482,670405519,960002000,1350818721,1870771078,2553622127,3439857024,4577640625,6023862026,7845269823,10119701872,12937413329,16402506750,20634468031,25769811968,31963841217,39392522434,48254483375,58773134736,71198920513,85811700662,102923269839,122880016000,146065722641,172904518458,203863978207,239458378544,280252112625,326863267246,379967366303,440301284352,508667334049,585937531250,673058041551,771053812048,881033392097,1004193946854,1141826467375,1295321181056,1466173166193,1655988174442,1866488664959,2099520054000,2357057183761,2641211014238,2954235541887,3298534948864,3676670986625,4091370597666,4545533779183,5042241692432,5584765021569,6176572585750,6821340208271,7522959846528,8285548986577,9113460306074,10011291609375,10983896038576,12036392564273,13174176759822,14402931862879,15728640128000,17157594474081,18696410430418,20352038385167,22131776139984,24043281774625,26094586825286,28294109780463,30650669898112,33173501347889,35872267682250,38757076640191,41838495287408,45127565496657,48635819772094,52375297421375,56358561079296,60598713586753,65109415228802,69904901335599,75000000250000 add $0,1 mov $1,$0 mul $1,2 mul $1,$0 mul $1,$0 mul $0,$1 mul $0,3 add $0,2 mul $0,$1 div $0,16
; ; ZX Spectrum specific routines ; by Stefano Bodrato, MAR 2010 ; ; int ulaplus_set(attribute,rgbvalue); ; ; ; $Id: ulaplus_set.asm,v 1.3 2016/06/10 21:14:23 dom Exp $ ; SECTION code_clib PUBLIC ulaplus_set PUBLIC _ulaplus_set ulaplus_set: _ulaplus_set: pop bc pop de pop hl push hl push de push bc ld bc,$bf3b ld a,l and 63 ; mask to be sure we're setting the palette out (c),a ld b,$ff ld a,e out (c),a ret
global _start section .text _start: xor eax,eax xor ebx,ebx mov al,0x2 int 0x80 cmp eax,ebx jnz _wait xor eax,eax push eax push word 0x462d mov esi,esp push eax push dword 0x73656c62 push dword 0x61747069 push dword 0x2f6e6962 push dword 0x732f2f2f mov ebx,esp lea edx,[esp+0x10] push eax push esi push esp mov ecx,esp mov al,0xb int 0x80 _wait: mov ebx,eax xor eax,eax xor ecx,ecx xor edx,edx mov al,0x7 int 0x80
#include "../hardware_api.h" #if defined(__arm__) && defined(__SAM3X8E__) #define _ADC_VOLTAGE 3.3f #define _ADC_RESOLUTION 1024.0f // function reading an ADC value and returning the read voltage void* _configureADCInline(const void* driver_params, const int pinA,const int pinB,const int pinC){ _UNUSED(driver_params); pinMode(pinA, INPUT); pinMode(pinB, INPUT); if( _isset(pinC) ) pinMode(pinC, INPUT); GenericCurrentSenseParams* params = new GenericCurrentSenseParams { .pins = { pinA, pinB, pinC }, .adc_voltage_conv = (_ADC_VOLTAGE)/(_ADC_RESOLUTION) }; return params; } #endif
; A117197: a(n) = (n^3 - 1)^3. ; 0,343,17576,250047,1906624,9938375,40001688,133432831,385828352,997002999,2352637000,5150827583,10590025536,20638466407,38409197624,68669157375,118515478528,198257271191,322546580712,511808023999 mov $1,$0 add $1,1 pow $1,3 sub $1,1 pow $1,3
// N64 Header db $80 db $37 db $12 db $40 // Clock Rate dw $0000000F dw Start dw $1444 db "CRC1" db "CRC2" dd 0 db "N64 Video 002 " // "123456789012345678901234567" db $00 // Dev Id db $00 // Cart Id db $00 db $00 db $00
// Optimise #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; // #define MULTI_TEST #ifdef LOCAL #define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__); #define pc(...) PC(#__VA_ARGS__, __VA_ARGS__); template <typename T, typename U> ostream &operator<<(ostream &out, const pair<T, U> &p) { out << '[' << p.first << ", " << p.second << ']'; return out; } template <typename Arg> void PC(const char *name, Arg &&arg) { while (*name == ',' || *name == ' ') name++; std::cerr << name << " { "; for (const auto &v : arg) cerr << v << ' '; cerr << " }\n"; } template <typename Arg1, typename... Args> void PC(const char *names, Arg1 &&arg1, Args &&... args) { while (*names == ',' || *names == ' ') names++; const char *comma = strchr(names, ','); std::cerr.write(names, comma - names) << " { "; for (const auto &v : arg1) cerr << v << ' '; cerr << " }\n"; PC(comma, args...); } template <typename Arg1> void ZZ(const char *name, Arg1 &&arg1) { std::cerr << name << " = " << arg1 << endl; } template <typename Arg1, typename... Args> void ZZ(const char *names, Arg1 &&arg1, Args &&... args) { const char *comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " = " << arg1; ZZ(comma, args...); } #else #define db(...) #define pc(...) #endif using ll = long long; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define f first #define s second #define pb push_back #define all(v) v.begin(), v.end() auto TimeStart = chrono::steady_clock::now(); auto seed = TimeStart.time_since_epoch().count(); std::mt19937 rng(seed); template <typename T> using Random = std::uniform_int_distribution<T>; const int NAX = 2e5 + 5, MOD = 1000000007; int add(int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int mul(int a, int b) { return ll(a) * b % MOD; } struct Node { long long val; Node(int one = 0) : val(one) {} Node operator+(const Node &rhs) { Node a = *this; a.val = add(a.val, rhs.val); return a; } }; ostream &operator<<(ostream &out, const Node &p) { out << p.val; return out; } istream &operator>>(istream &in, Node &p) { in >> p.val; return in; } struct Segtree { vector<Node> Seg, Lazy; vector<Node> Base; vector<bool> isLazy; int n; Segtree(int n = 2e5) { this->n = n; Seg.resize(4 * n + 10); Lazy.resize(4 * n + 10); isLazy.resize(4 * n + 10); } void merge(Node &curr, Node &l, Node &r) { curr = l + r; } void propagate(int node, int L, int R) { if (isLazy[node]) { isLazy[node] = false; Seg[node] = Seg[node] + Lazy[node]; if (L != R) { Lazy[2 * node] = Lazy[2 * node] + Lazy[node]; Lazy[2 * node + 1] = Lazy[2 * node + 1] + Lazy[node]; isLazy[2 * node] = true; isLazy[2 * node + 1] = true; } Lazy[node] = Node(); } } void build(int node, int start, int end) { if (start == end) { Seg[node] = Base[start]; return; } int mid = (start + end) / 2; build(2 * node, start, mid); build(2 * node + 1, mid + 1, end); merge(Seg[node], Seg[2 * node], Seg[2 * node + 1]); } void build(vector<Node> &Arr) { Base = Arr; n = Arr.size(); Seg.resize(4 * n + 10); Lazy.resize(4 * n + 10); isLazy.resize(4 * n + 10); build(1, 0, n - 1); } Node Query(int node, int start, int end, int qstart, int qend) { propagate(node, start, end); if (qend < start || qstart > end || start > end) return Node(); if (qstart <= start && end <= qend) return Seg[node]; int mid = (start + end) / 2; Node l = Query(2 * node, start, mid, qstart, qend); Node r = Query(2 * node + 1, mid + 1, end, qstart, qend); Node ret; merge(ret, l, r); return ret; } Node qQuery(int node, int start, int end, int pos) { propagate(node, start, end); if (start == end) return Seg[node]; int mid = (start + end) / 2; if (pos <= mid) return qQuery(2 * node, start, mid, pos); return qQuery(2 * node + 1, mid + 1, end, pos); } void Update(int node, int start, int end, int qstart, int qend, Node val) { propagate(node, start, end); if (qend < start || qstart > end || start > end) return; if (qstart <= start && end <= qend) { isLazy[node] = true; Lazy[node] = val; propagate(node, start, end); return; } int mid = (start + end) / 2; Update(2 * node, start, mid, qstart, qend, val); Update(2 * node + 1, mid + 1, end, qstart, qend, val); merge(Seg[node], Seg[2 * node], Seg[2 * node + 1]); } void pUpdate(int node, int start, int end, int pos, Node val) { propagate(node, start, end); if (start == end) { isLazy[node] = true; Seg[node] = Node(); Lazy[node] = val; propagate(node, start, end); return; } int mid = (start + end) / 2; if (pos <= mid) pUpdate(2 * node, start, mid, pos, val); else pUpdate(2 * node + 1, mid + 1, end, pos, val); merge(Seg[node], Seg[2 * node], Seg[2 * node + 1]); } Node query(int pos) { return qQuery(1, 0, n - 1, pos); } Node query(int left, int right) { return Query(1, 0, n - 1, left, right); } void update(int pos, Node val) { pUpdate(1, 0, n - 1, pos, val); } void update(int start, int end, Node val) { Update(1, 0, n - 1, start, end, val); } }; void solveCase() { int n; cin >> n; vector<int> v(n); for (auto &x : v) cin >> x; const int lim = *max_element(all(v)) + 1; Segtree S(lim); for (size_t i = 0; i < n; i++) { Node q = S.query(0, v[i]); S.update(v[i], mul(v[i], add(q.val, 1))); } cout << S.query(0, lim - 1) << '\n'; } int32_t main() { #ifndef LOCAL ios_base::sync_with_stdio(0); cin.tie(0); #endif int t = 1; #ifdef MULTI_TEST cin >> t; #endif for (int i = 1; i <= t; ++i) { solveCase(); #ifdef TIME cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n"; TimeStart = chrono::steady_clock::now(); #endif } return 0; }
#if !defined(_FUNCTIONS_FUNCTIONS_HPP_) #define _FUNCTIONS_FUNCTIONS_HPP_ #include <irafldef.h> #include <cmath> namespace IRAFLFunc { static double PI = atan(1.0) * 4; static double ColorNormal[256] = { 0.0, 0.00392156862745098, 0.00784313725490196, 0.011764705882352941, 0.01568627450980392, 0.0196078431372549, 0.023529411764705882, 0.027450980392156862, 0.03137254901960784, 0.03529411764705882, 0.0392156862745098, 0.043137254901960784, 0.047058823529411764, 0.050980392156862744, 0.054901960784313725, 0.058823529411764705, 0.06274509803921569, 0.06666666666666667, 0.07058823529411765, 0.07450980392156863, 0.0784313725490196, 0.08235294117647059, 0.08627450980392157, 0.09019607843137255, 0.09411764705882353, 0.09803921568627451, 0.10196078431372549, 0.10588235294117647, 0.10980392156862745, 0.11372549019607843, 0.11764705882352941, 0.12156862745098039, 0.12549019607843137, 0.12941176470588237, 0.13333333333333333, 0.13725490196078433, 0.1411764705882353, 0.1450980392156863, 0.14901960784313725, 0.15294117647058825, 0.1568627450980392, 0.1607843137254902, 0.16470588235294117, 0.16862745098039217, 0.17254901960784313, 0.17647058823529413, 0.1803921568627451, 0.1843137254901961, 0.18823529411764706, 0.19215686274509805, 0.19607843137254902, 0.2, 0.20392156862745098, 0.20784313725490197, 0.21176470588235294, 0.21568627450980393, 0.2196078431372549, 0.2235294117647059, 0.22745098039215686, 0.23137254901960785, 0.23529411764705882, 0.23921568627450981, 0.24313725490196078, 0.24705882352941178, 0.25098039215686274, 0.2549019607843137, 0.25882352941176473, 0.2627450980392157, 0.26666666666666666, 0.27058823529411763, 0.27450980392156865, 0.2784313725490196, 0.2823529411764706, 0.28627450980392155, 0.2901960784313726, 0.29411764705882354, 0.2980392156862745, 0.30196078431372547, 0.3058823529411765, 0.30980392156862746, 0.3137254901960784, 0.3176470588235294, 0.3215686274509804, 0.3254901960784314, 0.32941176470588235, 0.3333333333333333, 0.33725490196078434, 0.3411764705882353, 0.34509803921568627, 0.34901960784313724, 0.35294117647058826, 0.3568627450980392, 0.3607843137254902, 0.36470588235294116, 0.3686274509803922, 0.37254901960784315, 0.3764705882352941, 0.3803921568627451, 0.3843137254901961, 0.38823529411764707, 0.39215686274509803, 0.396078431372549, 0.4, 0.403921568627451, 0.40784313725490196, 0.4117647058823529, 0.41568627450980394, 0.4196078431372549, 0.4235294117647059, 0.42745098039215684, 0.43137254901960786, 0.43529411764705883, 0.4392156862745098, 0.44313725490196076, 0.4470588235294118, 0.45098039215686275, 0.4549019607843137, 0.4588235294117647, 0.4627450980392157, 0.4666666666666667, 0.47058823529411764, 0.4745098039215686, 0.47843137254901963, 0.4823529411764706, 0.48627450980392156, 0.49019607843137253, 0.49411764705882355, 0.4980392156862745, 0.5019607843137255, 0.5058823529411764, 0.5098039215686274, 0.5137254901960784, 0.5176470588235295, 0.5215686274509804, 0.5254901960784314, 0.5294117647058824, 0.5333333333333333, 0.5372549019607843, 0.5411764705882353, 0.5450980392156862, 0.5490196078431373, 0.5529411764705883, 0.5568627450980392, 0.5607843137254902, 0.5647058823529412, 0.5686274509803921, 0.5725490196078431, 0.5764705882352941, 0.5803921568627451, 0.5843137254901961, 0.5882352941176471, 0.592156862745098, 0.596078431372549, 0.6, 0.6039215686274509, 0.6078431372549019, 0.611764705882353, 0.615686274509804, 0.6196078431372549, 0.6235294117647059, 0.6274509803921569, 0.6313725490196078, 0.6352941176470588, 0.6392156862745098, 0.6431372549019608, 0.6470588235294118, 0.6509803921568628, 0.6549019607843137, 0.6588235294117647, 0.6627450980392157, 0.6666666666666666, 0.6705882352941176, 0.6745098039215687, 0.6784313725490196, 0.6823529411764706, 0.6862745098039216, 0.6901960784313725, 0.6941176470588235, 0.6980392156862745, 0.7019607843137254, 0.7058823529411765, 0.7098039215686275, 0.7137254901960784, 0.7176470588235294, 0.7215686274509804, 0.7254901960784313, 0.7294117647058823, 0.7333333333333333, 0.7372549019607844, 0.7411764705882353, 0.7450980392156863, 0.7490196078431373, 0.7529411764705882, 0.7568627450980392, 0.7607843137254902, 0.7647058823529411, 0.7686274509803922, 0.7725490196078432, 0.7764705882352941, 0.7803921568627451, 0.7843137254901961, 0.788235294117647, 0.792156862745098, 0.796078431372549, 0.8, 0.803921568627451, 0.807843137254902, 0.8117647058823529, 0.8156862745098039, 0.8196078431372549, 0.8235294117647058, 0.8274509803921568, 0.8313725490196079, 0.8352941176470589, 0.8392156862745098, 0.8431372549019608, 0.8470588235294118, 0.8509803921568627, 0.8549019607843137, 0.8588235294117647, 0.8627450980392157, 0.8666666666666667, 0.8705882352941177, 0.8745098039215686, 0.8784313725490196, 0.8823529411764706, 0.8862745098039215, 0.8901960784313725, 0.8941176470588236, 0.8980392156862745, 0.9019607843137255, 0.9058823529411765, 0.9098039215686274, 0.9137254901960784, 0.9176470588235294, 0.9215686274509803, 0.9254901960784314, 0.9294117647058824, 0.9333333333333333, 0.9372549019607843, 0.9411764705882353, 0.9450980392156862, 0.9490196078431372, 0.9529411764705882, 0.9568627450980393, 0.9607843137254902, 0.9647058823529412, 0.9686274509803922, 0.9725490196078431, 0.9764705882352941, 0.9803921568627451, 0.984313725490196, 0.9882352941176471, 0.9921568627450981, 0.996078431372549, 1.0, }; static const unsigned int crc32tab[] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; uint32_t CRC32Get(const void* vbuf, unsigned int size) { const unsigned char* buf = (const unsigned char*)vbuf; unsigned int i, crc; crc = 0xFFFFFFFF; for (i = 0; i < size; i++) crc = crc32tab[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); return crc ^ 0xFFFFFFFF; } } #endif
;******************************************************************************************************** ; uC/OS-III ; The Real-Time Kernel ; ; Copyright 2009-2021 Silicon Laboratories Inc. www.silabs.com ; ; SPDX-License-Identifier: APACHE-2.0 ; ; This software is subject to an open source license and is distributed by ; Silicon Laboratories Inc. pursuant to the terms of the Apache License, ; Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. ; ;******************************************************************************************************** ;******************************************************************************************************** ; ; ARMv7-M Port ; ; File : os_cpu_a.asm ; Version : V3.08.01 ;******************************************************************************************************** ; For : ARMv7-M Cortex-M ; Mode : Thumb-2 ISA ; Toolchain : IAR EWARM ;******************************************************************************************************** ; Note(s) : (1) This port supports the ARM Cortex-M3, Cortex-M4 and Cortex-M7 architectures. ; (2) It has been tested with the following Hardware Floating Point Unit. ; (a) Single-precision: FPv4-SP-D16-M and FPv5-SP-D16-M ; (b) Double-precision: FPv5-D16-M ;******************************************************************************************************** ; ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** ; External references. EXTERN OSPrioCur EXTERN OSPrioHighRdy EXTERN OSTCBCurPtr EXTERN OSTCBHighRdyPtr EXTERN OSIntExit EXTERN OSTaskSwHook EXTERN OS_CPU_ExceptStkBase EXTERN OS_KA_BASEPRI_Boundary PUBLIC OSStartHighRdy ; Functions declared in this file PUBLIC OSCtxSw PUBLIC OSIntCtxSw PUBLIC OS_CPU_PendSVHandler ;******************************************************************************************************** ; EQUATES ;******************************************************************************************************** NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state register. NVIC_SYSPRI14 EQU 0xE000ED22 ; System priority register (priority 14). NVIC_PENDSV_PRI EQU 0xFF ; PendSV priority value (lowest). NVIC_PENDSVSET EQU 0x10000000 ; Value to trigger PendSV exception. ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** RSEG CODE:CODE:NOROOT(2) THUMB ;******************************************************************************************************** ; START MULTITASKING ; void OSStartHighRdy(void) ; ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause ; the first task to start. ; ; 2) During task execution, PSP is used as the stack pointer. ; When an exception occurs, the core will switch to MSP until the exception return. ; ; 3) OSStartHighRdy() MUST: ; a) Setup PendSV exception priority to lowest; ; b) Set initial PSP to 0, to tell context switcher this is first run; ; c) Set the main stack to OS_CPU_ExceptStkBase ; d) Get current high priority, OSPrioCur = OSPrioHighRdy; ; e) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr; ; f) Get new process SP from TCB, SP = OSTCBHighRdyPtr->StkPtr; ; g) Restore R0-R11 and R14 from new process stack; ; h) Enable interrupts (tasks will run with interrupts enabled). ;******************************************************************************************************** OSStartHighRdy CPSID I ; Prevent interruption during context switch MOV32 R0, NVIC_SYSPRI14 ; Set the PendSV exception priority MOV32 R1, NVIC_PENDSV_PRI STRB R1, [R0] MOVS R0, #0 ; Set the PSP to 0 for initial context switch call MSR PSP, R0 MOV32 R0, OS_CPU_ExceptStkBase ; Initialize the MSP to the OS_CPU_ExceptStkBase LDR R1, [R0] MSR MSP, R1 BL OSTaskSwHook ; Call OSTaskSwHook() for FPU Push & Pop MOV32 R0, OSPrioCur ; OSPrioCur = OSPrioHighRdy; MOV32 R1, OSPrioHighRdy LDRB R2, [R1] STRB R2, [R0] MOV32 R0, OSTCBCurPtr ; OSTCBCurPtr = OSTCBHighRdyPtr; MOV32 R1, OSTCBHighRdyPtr LDR R2, [R1] STR R2, [R0] LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr; MSR PSP, R0 ; Load PSP with new process SP MRS R0, CONTROL ORR R0, R0, #2 BIC R0, R0, #4 ; Clear FPCA bit to indicate FPU is not in use MSR CONTROL, R0 ISB ; Sync instruction stream LDMFD SP!, {R4-R11, LR} ; Restore r4-11, lr from new process stack LDMFD SP!, {R0-R3} ; Restore r0, r3 LDMFD SP!, {R12, LR} ; Load R12 and LR LDMFD SP!, {R1, R2} ; Load PC and discard xPSR CPSIE I BX R1 ;******************************************************************************************************** ; PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw() ; PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw() ; ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch. This function ; triggers the PendSV exception which is where the real work is done. ; ; 2) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as ; the result of an interrupt. This function simply triggers a PendSV exception which will ; be handled when there are no more interrupts active and interrupts are enabled. ;******************************************************************************************************** OSCtxSw OSIntCtxSw LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR ;******************************************************************************************************** ; HANDLE PendSV EXCEPTION ; void OS_CPU_PendSVHandler(void) ; ; Note(s) : 1) PendSV is used to cause a context switch. This is a recommended method for performing ; context switches with Cortex-M. This is because the Cortex-M auto-saves half of the ; processor context on any exception, and restores same on return from exception. So only ; saving of R4-R11 & R14 is required and fixing up the stack pointers. Using the PendSV exception ; this way means that context saving and restoring is identical whether it is initiated from ; a thread or occurs due to an interrupt or exception. ; ; 2) Pseudo-code is: ; a) Get the process SP ; b) Save remaining regs r4-r11 & r14 on process stack; ; c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP; ; d) Call OSTaskSwHook(); ; e) Get current high priority, OSPrioCur = OSPrioHighRdy; ; f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr; ; g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr; ; h) Restore R4-R11 and R14 from new process stack; ; i) Perform exception return which will restore remaining context. ; ; 3) On entry into PendSV handler: ; a) The following have been saved on the process stack (by processor): ; xPSR, PC, LR, R12, R0-R3 ; b) Processor mode is switched to Handler mode (from Thread mode) ; c) Stack is Main stack (switched from Process stack) ; d) OSTCBCurPtr points to the OS_TCB of the task to suspend ; OSTCBHighRdyPtr points to the OS_TCB of the task to resume ; ; 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we ; know that it will only be run when no other exception or interrupt is active, and ; therefore safe to assume that context being switched out was using the process stack (PSP). ; ; 5) Increasing priority using a write to BASEPRI does not take effect immediately. ; (a) IMPLICATION This erratum means that the instruction after an MSR to boost BASEPRI ; might incorrectly be preempted by an insufficient high priority exception. ; ; (b) WORKAROUND The MSR to boost BASEPRI can be replaced by the following code sequence: ; ; CPSID i ; MSR to BASEPRI ; DSB ; ISB ; CPSIE i ;******************************************************************************************************** OS_CPU_PendSVHandler CPSID I ; Cortex-M7 errata notice. See Note #5 MOV32 R2, OS_KA_BASEPRI_Boundary ; Set BASEPRI priority level required for exception preemption LDR R1, [R2] MSR BASEPRI, R1 DSB ISB CPSIE I MRS R0, PSP ; PSP is process stack pointer #ifdef __ARMVFP__ ; Push high vfp registers if the task is using the FPU context TST R14, #0x10 IT EQ VSTMDBEQ R0!, {S16-S31} #endif STMFD R0!, {R4-R11, R14} ; Save remaining regs r4-11, R14 on process stack MOV32 R5, OSTCBCurPtr ; OSTCBCurPtr->StkPtr = SP; LDR R1, [R5] STR R0, [R1] ; R0 is SP of process being switched out ; At this point, entire context of process has been saved MOV R4, LR ; Save LR exc_return value BL OSTaskSwHook ; Call OSTaskSwHook() for FPU Push & Pop MOV32 R0, OSPrioCur ; OSPrioCur = OSPrioHighRdy; MOV32 R1, OSPrioHighRdy LDRB R2, [R1] STRB R2, [R0] MOV32 R1, OSTCBHighRdyPtr ; OSTCBCurPtr = OSTCBHighRdyPtr; LDR R2, [R1] STR R2, [R5] ORR LR, R4, #0x04 ; Ensure exception return uses process stack LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr; LDMFD R0!, {R4-R11, R14} ; Restore r4-11, R14 from new process stack #ifdef __ARMVFP__ ; Pop the high vfp registers if the next task is using the FPU context TST R14, #0x10 IT EQ VLDMIAEQ R0!, {S16-S31} #endif MSR PSP, R0 ; Load PSP with new process SP MOV32 R2, #0 ; Restore BASEPRI priority level to 0 CPSID I ; Cortex-M7 errata notice. See Note #5 MSR BASEPRI, R2 DSB ISB CPSIE I BX LR ; Exception return will restore remaining context END
// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/04/Mult.asm // Multiplies R0 and R1 and stores the result in R2. // (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.) // Put your code here. @sum M=0 //sum=0 @i M=0 //i=0 @R0 D=M @n M=D //n=RAM[0] @R1 D=M @m M=D //m=RAM[1] //while i<=n // sum+=m // i++ (LOOP) @i D=M @n D=D-M //i-n @STOP D;JGE //if i-n>=0 GOTO STOP @m D=M //m @sum M=M+D //sum=sum+D @i M=M+1 @LOOP 0;JMP (STOP) @sum D=M @R2 M=D //R2=sum (END) @END 0;JMP
; ************************************************************************************************ ; ************************************************************************************************ ; ; Name: dtprint.asm ; Purpose: Printing functions for detokenising. ; Created: 7th March 2021 ; Reviewed: 16th March 2021 ; Author: Paul Robson (paul@robsons.org.uk) ; ; ************************************************************************************************ ; ************************************************************************************************ .section storage tPrintCount: .fill 1 .send storage .section code ; ************************************************************************************************ ; ; Print integer at TOS,X in base A ; ; ************************************************************************************************ DTPrintInteger: pha ; save base set16 temp0,convertBuffer ; set convert buffer addr .puly ; base in Y and convert stack level in A. txa .main_inttostr tax ; then drop through here. ; ************************************************************************************************ ; ; Print length prefix string at temp0, with bit 7 stripped ; ; ************************************************************************************************ DTPrintLengthPrefix: tax ; A = 0 = don't case convert. .pshy ; save Y ldy #0 ; get string length = chars to print. lda (temp0),y sta tPrintCount beq _DTPLPExit ; empty string _DTPLPLoop: iny ; get next. lda (temp0),y and #$7F cpx #0 ; skip if not case converting beq _DTPLPNoCase cmp #"A" ; if converting UC -> LC bcc _DTPLPNoCase cmp #"Z"+1 bcs _DTPLPNoCase eor #"A"^"a" _DTPLPNoCase jsr ListOutputCharacter ; call handler dec tPrintCount ; do all the characters bne _DTPLPLoop _DTPLPExit: .puly rts ; ************************************************************************************************ ; ; Print for listing. Expects CR, ASCII and 1..9 for colour elements ; ; ************************************************************************************************ ListOutputCharacter: sta tempShort pha .pshx .pshy lda tempShort ; convert ASCII 6 bit (0-31) to 7 bit. cmp #32 bcs _LOCHiBit ora #64 ; conversion cmp #64 ; make l/c beq _LOCHiBit cmp #65+26 bcs _LOCHiBit adc #32 _LOCHiBit: jsr _LOCCallVector ; call o/p handler routine .puly .pulx pla _LOCExit: rts _LOCCallVector: ; allow detokenising to other places. jmp (deTokeniseVector) ; ************************************************************************************************ ; ; Printer for list to output device ; ; ************************************************************************************************ deTokenPrint: cmp #0 ; if bit 7 sets ink colour bmi _dtpInk .device_printascii rts _dtpInk:cmp #255 ; e.g. herhe, get ink and set it beq _dtpCR ; except $FF => CRLF and #7 .device_ink rts _dtpCR: .device_crlf rts ; ************************************************************************************************ ; ; Switch mode, punctuation or identifier constant, may need space ; ; ************************************************************************************************ DTSwitchMode: cmp LastCharacterClass ; if changed, update character class beq _DTSMNoChange sta LastCharacterClass _DTSMExit: rts _DTSMNoChange: cmp #1 ; if didn't change to punctuation, two identifiers so we beq _DTSMExit ; need a space. lda #" " jmp ListOutputCharacter .send code ; ************************************************************************************************ ; ; Changes and Updates ; ; ************************************************************************************************ ; ; Date Notes ; ==== ===== ; 07-Mar-21 Pre code read v0.01 ; ; ************************************************************************************************
; A228290: a(n) = n^6 + n^5 + n^4 + n^3 + n^2 + n. ; 0,6,126,1092,5460,19530,55986,137256,299592,597870,1111110,1948716,3257436,5229042,8108730,12204240,17895696,25646166,36012942,49659540,67368420,90054426,118778946,154764792,199411800,254313150,321272406,402321276,499738092,616067010,754137930,917087136,1108378656,1331826342,1591616670,1892332260,2238976116,2636996586,3092313042,3611342280,4201025640,4868856846,5622910566,6471871692,7425065340,8492487570,9684836826,11013546096,12490815792,14129647350,15943877550,17948213556,20158268676 mov $2,6 lpb $2 add $1,2 mul $1,$0 sub $2,1 lpe div $1,4 mul $1,2 mov $0,$1
/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // Copyright Gonzalo Brito Gadeschi 2014 // // Use, modification and distribution is subject to 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) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_NUMERIC_INNER_PRODUCT_HPP #define RANGES_V3_NUMERIC_INNER_PRODUCT_HPP #include <meta/meta.hpp> #include <range/v3/functional/arithmetic.hpp> #include <range/v3/functional/concepts.hpp> #include <range/v3/functional/identity.hpp> #include <range/v3/functional/invoke.hpp> #include <range/v3/iterator/concepts.hpp> #include <range/v3/iterator/traits.hpp> #include <range/v3/iterator/unreachable_sentinel.hpp> #include <range/v3/range/access.hpp> #include <range/v3/range/concepts.hpp> #include <range/v3/range/traits.hpp> #include <range/v3/utility/static_const.hpp> namespace ranges { /// \addtogroup group-numerics /// @{ // clang-format off CPP_def ( template(typename I1, typename I2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity) (concept inner_product_constraints)(I1, I2, T, BOp1, BOp2, P1, P2), input_iterator<I1> && input_iterator<I2> && invocable<P1&, iter_value_t<I1>> && invocable<P2&, iter_value_t<I2>> && invocable< BOp2&, invoke_result_t<P1&, iter_value_t<I1>>, invoke_result_t<P2&, iter_value_t<I2>>> && invocable< BOp1&, T, invoke_result_t< BOp2&, invoke_result_t<P1&, iter_value_t<I1>>, invoke_result_t<P2&, iter_value_t<I2>>>> && assignable_from< T&, invoke_result_t< BOp1&, T, invoke_result_t< BOp2&, invoke_result_t<P1&, iter_value_t<I1>>, invoke_result_t<P2&, iter_value_t<I2>>>>> ); // clang-format on struct inner_product_fn { template<typename I1, typename S1, typename I2, typename S2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity> auto operator()(I1 begin1, S1 end1, I2 begin2, S2 end2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const -> CPP_ret(T)( // requires sentinel_for<S1, I1> && sentinel_for<S2, I2> && inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>) { for(; begin1 != end1 && begin2 != end2; ++begin1, ++begin2) init = invoke(bop1, init, invoke(bop2, invoke(proj1, *begin1), invoke(proj2, *begin2))); return init; } template<typename I1, typename S1, typename I2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity> auto operator()(I1 begin1, S1 end1, I2 begin2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const -> CPP_ret(T)( // requires sentinel_for<S1, I1> && inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>) { return (*this)(std::move(begin1), std::move(end1), std::move(begin2), unreachable, std::move(init), std::move(bop1), std::move(bop2), std::move(proj1), std::move(proj2)); } template<typename Rng1, typename I2Ref, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity, typename I1 = iterator_t<Rng1>, typename I2 = uncvref_t<I2Ref>> auto operator()(Rng1 && rng1, I2Ref && begin2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const -> CPP_ret(T)( // requires range<Rng1> && inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>) { return (*this)(begin(rng1), end(rng1), static_cast<I2Ref &&>(begin2), std::move(init), std::move(bop1), std::move(bop2), std::move(proj1), std::move(proj2)); } template<typename Rng1, typename Rng2, typename T, typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity, typename I1 = iterator_t<Rng1>, typename I2 = iterator_t<Rng2>> auto operator()(Rng1 && rng1, Rng2 && rng2, T init, BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const -> CPP_ret(T)( // requires range<Rng1> && range<Rng2> && inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>) { return (*this)(begin(rng1), end(rng1), begin(rng2), end(rng2), std::move(init), std::move(bop1), std::move(bop2), std::move(proj1), std::move(proj2)); } }; RANGES_INLINE_VARIABLE(inner_product_fn, inner_product) /// @} } // namespace ranges #endif
#include <boost/config.hpp> #if defined(BOOST_MSVC) #pragma warning(disable: 4786) // identifier truncated in debug info #pragma warning(disable: 4710) // function not inlined #pragma warning(disable: 4711) // function selected for automatic inline expansion #pragma warning(disable: 4514) // unreferenced inline removed #endif // // bind_void_mf_test.cpp - test for bind<void> with member functions // // Copyright (c) 2008 Peter Dimov // Copyright (c) 2014 Agustin Berge // // 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/bind.hpp> #include <boost/ref.hpp> #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) #pragma warning(push, 3) #endif #include <iostream> #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) #pragma warning(pop) #endif #include <boost/detail/lightweight_test.hpp> // struct Z { int m; }; void member_data_test() { Z z = { 17041 }; Z * pz = &z; boost::bind<void>( &Z::m, _1 )( z ); boost::bind<void>( &Z::m, _1 )( pz ); boost::bind<void>( &Z::m, z )(); boost::bind<void>( &Z::m, pz )(); boost::bind<void>( &Z::m, boost::ref(z) )(); Z const cz = z; Z const * pcz = &cz; boost::bind<void>( &Z::m, _1 )( cz ); boost::bind<void>( &Z::m, _1 )( pcz ); boost::bind<void>( &Z::m, cz )(); boost::bind<void>( &Z::m, pcz )(); boost::bind<void>( &Z::m, boost::ref(cz) )(); } int main() { member_data_test(); return boost::report_errors(); }
// Copyright 2018 The Fuchsia 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 <fuchsia/pkg/cpp/fidl.h> #include <lib/async-loop/cpp/loop.h> #include <lib/async-loop/default.h> #include <lib/fidl/cpp/binding_set.h> #include <lib/sys/cpp/component_context.h> #include <lib/zx/channel.h> #include <memory> #include <vector> #include "lib/fdio/directory.h" namespace { // Mock out the package resolver, which is required with auto_update_packages. // We don't want to depend on the real package resolver because that would // make for a non-hermetic test. class PackageResolverMock : public fuchsia::pkg::PackageResolver { public: PackageResolverMock() : context_(sys::ComponentContext::CreateAndServeOutgoingDirectory()) { context_->outgoing()->AddPublicService(bindings_.GetHandler(this)); } void Resolve(::std::string package_uri, ::fidl::InterfaceRequest<fuchsia::io::Directory> dir, ResolveCallback callback) override { fdio_service_connect("/pkg", dir.TakeChannel().release()); callback(fuchsia::pkg::PackageResolver_Resolve_Result::WithResponse({})); } virtual void GetHash(fuchsia::pkg::PackageUrl package_url, GetHashCallback callback) override { callback(fuchsia::pkg::PackageResolver_GetHash_Result::WithErr(ZX_ERR_UNAVAILABLE)); } private: std::unique_ptr<sys::ComponentContext> context_; fidl::BindingSet<fuchsia::pkg::PackageResolver> bindings_; }; } // namespace int main(int argc, const char** argv) { async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread); PackageResolverMock service; loop.Run(); return 0; }