text
stringlengths
1
1.05M
#include <iostream> #include <fstream> #include <sstream> #include <gtest/gtest.h> #if defined(USE_STATIC) #include <botan_all.h> #else #include <botan/version.h> #include <botan/init.h> #endif int main(int argc, char **argv) { std::cerr << Botan::runtime_version_check(BOTAN_VERSION_MAJOR, BOTAN_VERSION_MINOR, BOTAN_VERSION_PATCH) << std::endl; ::testing::InitGoogleTest(&argc, argv); #if defined(MEMORY_LEAK_DETECT) _CrtMemState _checkpoint_start; _CrtMemState _checkpoint_end; _CrtMemState _checkpoint_diff; fprintf(stderr, "Memory leak detection enabled\n"); _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); _CrtMemCheckpoint(&_checkpoint_start); #endif auto ret = RUN_ALL_TESTS(); #if defined(MEMORY_LEAK_DETECT) _CrtMemCheckpoint(&_checkpoint_end); if (_CrtMemDifference(&_checkpoint_diff, &_checkpoint_start, &_checkpoint_end)) _CrtMemDumpStatistics( &_checkpoint_diff ); #endif return ret; }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2015 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; gf_3vect_dot_prod_avx512(len, vec, *g_tbls, **buffs, **dests); ;;; %include "reg_sizes.asm" %ifdef HAVE_AS_KNOWS_AVX512 %ifidn __OUTPUT_FORMAT__, elf64 %define arg0 rdi %define arg1 rsi %define arg2 rdx %define arg3 rcx %define arg4 r8 %define arg5 r9 %define tmp r11 %define tmp.w r11d %define tmp.b r11b %define tmp2 r10 %define tmp3 r13 ; must be saved and restored %define tmp4 r12 ; must be saved and restored %define return rax %define PS 8 %define LOG_PS 3 %define func(x) x: %macro FUNC_SAVE 0 push r12 push r13 %endmacro %macro FUNC_RESTORE 0 pop r13 pop r12 %endmacro %endif %ifidn __OUTPUT_FORMAT__, win64 %define arg0 rcx %define arg1 rdx %define arg2 r8 %define arg3 r9 %define arg4 r12 ; must be saved, loaded and restored %define arg5 r15 ; must be saved and restored %define tmp r11 %define tmp.w r11d %define tmp.b r11b %define tmp2 r10 %define tmp3 r13 ; must be saved and restored %define tmp4 r14 ; must be saved and restored %define return rax %define PS 8 %define LOG_PS 3 %define stack_size 9*16 + 5*8 ; must be an odd multiple of 8 %define arg(x) [rsp + stack_size + PS + PS*x] %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size vmovdqa [rsp + 0*16], xmm6 vmovdqa [rsp + 1*16], xmm7 vmovdqa [rsp + 2*16], xmm8 vmovdqa [rsp + 3*16], xmm9 vmovdqa [rsp + 4*16], xmm10 vmovdqa [rsp + 5*16], xmm11 vmovdqa [rsp + 6*16], xmm12 vmovdqa [rsp + 7*16], xmm13 vmovdqa [rsp + 8*16], xmm14 save_reg r12, 9*16 + 0*8 save_reg r13, 9*16 + 1*8 save_reg r14, 9*16 + 2*8 save_reg r15, 9*16 + 3*8 end_prolog mov arg4, arg(4) %endmacro %macro FUNC_RESTORE 0 vmovdqa xmm6, [rsp + 0*16] vmovdqa xmm7, [rsp + 1*16] vmovdqa xmm8, [rsp + 2*16] vmovdqa xmm9, [rsp + 3*16] vmovdqa xmm10, [rsp + 4*16] vmovdqa xmm11, [rsp + 5*16] vmovdqa xmm12, [rsp + 6*16] vmovdqa xmm13, [rsp + 7*16] vmovdqa xmm14, [rsp + 8*16] mov r12, [rsp + 9*16 + 0*8] mov r13, [rsp + 9*16 + 1*8] mov r14, [rsp + 9*16 + 2*8] mov r15, [rsp + 9*16 + 3*8] add rsp, stack_size %endmacro %endif %define len arg0 %define vec arg1 %define mul_array arg2 %define src arg3 %define dest1 arg4 %define ptr arg5 %define vec_i tmp2 %define dest2 tmp3 %define dest3 tmp4 %define pos return %ifndef EC_ALIGNED_ADDR ;;; Use Un-aligned load/store %define XLDR vmovdqu8 %define XSTR vmovdqu8 %else ;;; Use Non-temporal load/stor %ifdef NO_NT_LDST %define XLDR vmovdqa %define XSTR vmovdqa %else %define XLDR vmovntdqa %define XSTR vmovntdq %endif %endif %define xmask0f zmm11 %define xgft1_lo zmm10 %define xgft1_loy ymm10 %define xgft1_hi zmm9 %define xgft2_lo zmm8 %define xgft2_loy ymm8 %define xgft2_hi zmm7 %define xgft3_lo zmm6 %define xgft3_loy ymm6 %define xgft3_hi zmm5 %define x0 zmm0 %define xtmpa zmm1 %define xp1 zmm2 %define xp2 zmm3 %define xp3 zmm4 default rel [bits 64] section .text align 16 global gf_3vect_dot_prod_avx512:ISAL_SYM_TYPE_FUNCTION func(gf_3vect_dot_prod_avx512) FUNC_SAVE sub len, 64 jl .return_fail xor pos, pos mov tmp, 0x0f vpbroadcastb xmask0f, tmp ;Construct mask 0x0f0f0f... sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS mov dest2, [dest1+PS] mov dest3, [dest1+2*PS] mov dest1, [dest1] .loop64: vpxorq xp1, xp1, xp1 vpxorq xp2, xp2, xp2 vpxorq xp3, xp3, xp3 mov tmp, mul_array xor vec_i, vec_i .next_vect: mov ptr, [src+vec_i] XLDR x0, [ptr+pos] ;Get next source vector add vec_i, PS vpandq xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0 vpandq x0, x0, xmask0f ;Mask high src nibble in bits 4-0 vmovdqu8 xgft1_loy, [tmp] ;Load array Ax{00}..{0f}, Ax{00}..{f0} vmovdqu8 xgft2_loy, [tmp+vec*(32/PS)] ;Load array Bx{00}..{0f}, Bx{00}..{f0} vmovdqu8 xgft3_loy, [tmp+vec*(64/PS)] ;Load array Cx{00}..{0f}, Cx{00}..{f0} add tmp, 32 vshufi64x2 xgft1_hi, xgft1_lo, xgft1_lo, 0x55 vshufi64x2 xgft1_lo, xgft1_lo, xgft1_lo, 0x00 vshufi64x2 xgft2_hi, xgft2_lo, xgft2_lo, 0x55 vshufi64x2 xgft2_lo, xgft2_lo, xgft2_lo, 0x00 vpshufb xgft1_hi, xgft1_hi, x0 ;Lookup mul table of high nibble vpshufb xgft1_lo, xgft1_lo, xtmpa ;Lookup mul table of low nibble vpxorq xgft1_hi, xgft1_hi, xgft1_lo ;GF add high and low partials vpxorq xp1, xp1, xgft1_hi ;xp1 += partial vpshufb xgft2_hi, xgft2_hi, x0 ;Lookup mul table of high nibble vpshufb xgft2_lo, xgft2_lo, xtmpa ;Lookup mul table of low nibble vpxorq xgft2_hi, xgft2_hi, xgft2_lo ;GF add high and low partials vpxorq xp2, xp2, xgft2_hi ;xp2 += partial vshufi64x2 xgft3_hi, xgft3_lo, xgft3_lo, 0x55 vshufi64x2 xgft3_lo, xgft3_lo, xgft3_lo, 0x00 vpshufb xgft3_hi, xgft3_hi, x0 ;Lookup mul table of high nibble vpshufb xgft3_lo, xgft3_lo, xtmpa ;Lookup mul table of low nibble vpxorq xgft3_hi, xgft3_hi, xgft3_lo ;GF add high and low partials vpxorq xp3, xp3, xgft3_hi ;xp3 += partial cmp vec_i, vec jl .next_vect XSTR [dest1+pos], xp1 XSTR [dest2+pos], xp2 XSTR [dest3+pos], xp3 add pos, 64 ;Loop on 64 bytes at a time cmp pos, len jle .loop64 lea tmp, [len + 64] cmp pos, tmp je .return_pass ;; Tail len mov pos, len ;Overlapped offset length-64 jmp .loop64 ;Do one more overlap pass .return_pass: mov return, 0 FUNC_RESTORE ret .return_fail: mov return, 1 FUNC_RESTORE ret endproc_frame %else %ifidn __OUTPUT_FORMAT__, win64 global no_gf_3vect_dot_prod_avx512 no_gf_3vect_dot_prod_avx512: %endif %endif ; ifdef HAVE_AS_KNOWS_AVX512
;***************************************************************************** ;* MMX/SSE2/AVX-optimized H.264 deblocking code ;***************************************************************************** ;* Copyright (C) 2005-2011 x264 project ;* ;* Authors: Loren Merritt <lorenm@u.washington.edu> ;* Fiona Glaser <fiona@x264.com> ;* Oskar Arvidsson <oskar@irock.se> ;* ;* This file is part of FFmpeg. ;* ;* FFmpeg 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. ;* ;* FFmpeg 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 FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "libavutil/x86/x86util.asm" SECTION_RODATA pb_A1: times 16 db 0xA1 pb_3_1: times 4 db 3, 1 SECTION .text cextern pb_0 cextern pb_1 cextern pb_3 %define PASS8ROWS(base, base3, stride, stride3, offset) \ PASS8ROWS(base+offset, base3+offset, stride, stride3) ; in: 8 rows of 4 bytes in %4..%11 ; out: 4 rows of 8 bytes in m0..m3 %macro TRANSPOSE4x8_LOAD 11 movh m0, %4 movh m2, %5 movh m1, %6 movh m3, %7 punpckl%1 m0, m2 punpckl%1 m1, m3 mova m2, m0 punpckl%2 m0, m1 punpckh%2 m2, m1 movh m4, %8 movh m6, %9 movh m5, %10 movh m7, %11 punpckl%1 m4, m6 punpckl%1 m5, m7 mova m6, m4 punpckl%2 m4, m5 punpckh%2 m6, m5 punpckh%3 m1, m0, m4 punpckh%3 m3, m2, m6 punpckl%3 m0, m4 punpckl%3 m2, m6 %endmacro ; in: 4 rows of 8 bytes in m0..m3 ; out: 8 rows of 4 bytes in %1..%8 %macro TRANSPOSE8x4B_STORE 8 punpckhdq m4, m0, m0 punpckhdq m5, m1, m1 punpckhdq m6, m2, m2 punpcklbw m0, m1 punpcklbw m2, m3 punpcklwd m1, m0, m2 punpckhwd m0, m2 movh %1, m1 punpckhdq m1, m1 movh %2, m1 movh %3, m0 punpckhdq m0, m0 movh %4, m0 punpckhdq m3, m3 punpcklbw m4, m5 punpcklbw m6, m3 punpcklwd m5, m4, m6 punpckhwd m4, m6 movh %5, m5 punpckhdq m5, m5 movh %6, m5 movh %7, m4 punpckhdq m4, m4 movh %8, m4 %endmacro %macro TRANSPOSE4x8B_LOAD 8 TRANSPOSE4x8_LOAD bw, wd, dq, %1, %2, %3, %4, %5, %6, %7, %8 %endmacro %macro SBUTTERFLY3 4 punpckh%1 %4, %2, %3 punpckl%1 %2, %3 %endmacro ; in: 8 rows of 8 (only the middle 6 pels are used) in %1..%8 ; out: 6 rows of 8 in [%9+0*16] .. [%9+5*16] %macro TRANSPOSE6x8_MEM 9 RESET_MM_PERMUTATION movq m0, %1 movq m1, %2 movq m2, %3 movq m3, %4 movq m4, %5 movq m5, %6 movq m6, %7 SBUTTERFLY bw, 0, 1, 7 SBUTTERFLY bw, 2, 3, 7 SBUTTERFLY bw, 4, 5, 7 movq [%9+0x10], m3 SBUTTERFLY3 bw, m6, %8, m7 SBUTTERFLY wd, 0, 2, 3 SBUTTERFLY wd, 4, 6, 3 punpckhdq m0, m4 movq [%9+0x00], m0 SBUTTERFLY3 wd, m1, [%9+0x10], m3 SBUTTERFLY wd, 5, 7, 0 SBUTTERFLY dq, 1, 5, 0 SBUTTERFLY dq, 2, 6, 0 punpckldq m3, m7 movq [%9+0x10], m2 movq [%9+0x20], m6 movq [%9+0x30], m1 movq [%9+0x40], m5 movq [%9+0x50], m3 RESET_MM_PERMUTATION %endmacro ; in: 8 rows of 8 in %1..%8 ; out: 8 rows of 8 in %9..%16 %macro TRANSPOSE8x8_MEM 16 RESET_MM_PERMUTATION movq m0, %1 movq m1, %2 movq m2, %3 movq m3, %4 movq m4, %5 movq m5, %6 movq m6, %7 SBUTTERFLY bw, 0, 1, 7 SBUTTERFLY bw, 2, 3, 7 SBUTTERFLY bw, 4, 5, 7 SBUTTERFLY3 bw, m6, %8, m7 movq %9, m5 SBUTTERFLY wd, 0, 2, 5 SBUTTERFLY wd, 4, 6, 5 SBUTTERFLY wd, 1, 3, 5 movq %11, m6 movq m6, %9 SBUTTERFLY wd, 6, 7, 5 SBUTTERFLY dq, 0, 4, 5 SBUTTERFLY dq, 1, 6, 5 movq %9, m0 movq %10, m4 movq %13, m1 movq %14, m6 SBUTTERFLY3 dq, m2, %11, m0 SBUTTERFLY dq, 3, 7, 4 movq %11, m2 movq %12, m0 movq %15, m3 movq %16, m7 RESET_MM_PERMUTATION %endmacro ; out: %4 = |%1-%2|>%3 ; clobbers: %5 %macro DIFF_GT 5 %if avx_enabled == 0 mova %5, %2 mova %4, %1 psubusb %5, %1 psubusb %4, %2 %else psubusb %5, %2, %1 psubusb %4, %1, %2 %endif por %4, %5 psubusb %4, %3 %endmacro ; out: %4 = |%1-%2|>%3 ; clobbers: %5 %macro DIFF_GT2 5 %if ARCH_X86_64 psubusb %5, %2, %1 psubusb %4, %1, %2 %else mova %5, %2 mova %4, %1 psubusb %5, %1 psubusb %4, %2 %endif psubusb %5, %3 psubusb %4, %3 pcmpeqb %4, %5 %endmacro ; in: m0=p1 m1=p0 m2=q0 m3=q1 %1=alpha-1 %2=beta-1 ; out: m5=beta-1, m7=mask, %3=alpha-1 ; clobbers: m4,m6 %macro LOAD_MASK 2-3 movd m4, %1 movd m5, %2 SPLATW m4, m4 SPLATW m5, m5 packuswb m4, m4 ; 16x alpha-1 packuswb m5, m5 ; 16x beta-1 %if %0>2 mova %3, m4 %endif DIFF_GT m1, m2, m4, m7, m6 ; |p0-q0| > alpha-1 DIFF_GT m0, m1, m5, m4, m6 ; |p1-p0| > beta-1 por m7, m4 DIFF_GT m3, m2, m5, m4, m6 ; |q1-q0| > beta-1 por m7, m4 pxor m6, m6 pcmpeqb m7, m6 %endmacro ; in: m0=p1 m1=p0 m2=q0 m3=q1 m7=(tc&mask) ; out: m1=p0' m2=q0' ; clobbers: m0,3-6 %macro DEBLOCK_P0_Q0 0 pcmpeqb m4, m4 pxor m5, m1, m2 ; p0^q0 pxor m3, m4 pand m5, [pb_1] ; (p0^q0)&1 pavgb m3, m0 ; (p1 - q1 + 256)>>1 pxor m4, m1 pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 pavgb m4, m2 ; (q0 - p0 + 256)>>1 pavgb m3, m5 mova m6, [pb_A1] paddusb m3, m4 ; d+128+33 psubusb m6, m3 psubusb m3, [pb_A1] pminub m6, m7 pminub m3, m7 psubusb m1, m6 psubusb m2, m3 paddusb m1, m3 paddusb m2, m6 %endmacro ; in: m1=p0 m2=q0 ; %1=p1 %2=q2 %3=[q2] %4=[q1] %5=tc0 %6=tmp ; out: [q1] = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 ) ; clobbers: q2, tmp, tc0 %macro LUMA_Q1 6 pavgb %6, m1, m2 pavgb %2, %6 ; avg(p2,avg(p0,q0)) pxor %6, %3 pand %6, [pb_1] ; (p2^avg(p0,q0))&1 psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1 psubusb %6, %1, %5 paddusb %5, %1 pmaxub %2, %6 pminub %2, %5 mova %4, %2 %endmacro %if ARCH_X86_64 ;----------------------------------------------------------------------------- ; void ff_deblock_v_luma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- %macro DEBLOCK_LUMA 0 cglobal deblock_v_luma_8, 5,5,10, pix_, stride_, alpha_, beta_, base3_ movd m8, [r4] ; tc0 lea r4, [stride_q*3] dec alpha_d ; alpha-1 neg r4 dec beta_d ; beta-1 add base3_q, pix_q ; pix-3*stride mova m0, [base3_q + stride_q] ; p1 mova m1, [base3_q + 2*stride_q] ; p0 mova m2, [pix_q] ; q0 mova m3, [pix_q + stride_q] ; q1 LOAD_MASK r2d, r3d punpcklbw m8, m8 punpcklbw m8, m8 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0] pcmpeqb m9, m9 pcmpeqb m9, m8 pandn m9, m7 pand m8, m9 movdqa m3, [base3_q] ; p2 DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m9 psubb m7, m8, m6 pand m6, m8 LUMA_Q1 m0, m3, [base3_q], [base3_q + stride_q], m6, m4 movdqa m4, [pix_q + 2*stride_q] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 pand m6, m9 pand m8, m6 psubb m7, m6 mova m3, [pix_q + stride_q] LUMA_Q1 m3, m4, [pix_q + 2*stride_q], [pix_q + stride_q], m8, m6 DEBLOCK_P0_Q0 mova [base3_q + 2*stride_q], m1 mova [pix_q], m2 RET ;----------------------------------------------------------------------------- ; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- INIT_MMX cpuname cglobal deblock_h_luma_8, 5,9,0,0x60+16*WIN64 movsxd r7, r1d lea r8, [r7+r7*2] lea r6, [r0-4] lea r5, [r0-4+r8] %if WIN64 %define pix_tmp rsp+0x30 ; shadow space + r4 %else %define pix_tmp rsp %endif ; transpose 6x16 -> tmp space TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r7, r8), pix_tmp lea r6, [r6+r7*8] lea r5, [r5+r7*8] TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r7, r8), pix_tmp+8 ; vertical filter ; alpha, beta, tc0 are still in r2d, r3d, r4 ; don't backup r6, r5, r7, r8 because deblock_v_luma_sse2 doesn't use them lea r0, [pix_tmp+0x30] mov r1d, 0x10 %if WIN64 mov [rsp+0x20], r4 %endif call deblock_v_luma_8 ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter) add r6, 2 add r5, 2 movq m0, [pix_tmp+0x18] movq m1, [pix_tmp+0x28] movq m2, [pix_tmp+0x38] movq m3, [pix_tmp+0x48] TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8) shl r7, 3 sub r6, r7 sub r5, r7 shr r7, 3 movq m0, [pix_tmp+0x10] movq m1, [pix_tmp+0x20] movq m2, [pix_tmp+0x30] movq m3, [pix_tmp+0x40] TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8) RET %endmacro %macro DEBLOCK_H_LUMA_MBAFF 0 cglobal deblock_h_luma_mbaff_8, 5, 9, 10, 8*16, pix_, stride_, alpha_, beta_, tc0_, base3_, stride3_ movsxd stride_q, stride_d dec alpha_d dec beta_d mov base3_q, pix_q lea stride3_q, [3*stride_q] add base3_q, stride3_q movq m0, [pix_q - 4] movq m1, [pix_q + stride_q - 4] movq m2, [pix_q + 2*stride_q - 4] movq m3, [base3_q - 4] movq m4, [base3_q + stride_q - 4] movq m5, [base3_q + 2*stride_q - 4] movq m6, [base3_q + stride3_q - 4] movq m7, [base3_q + 4*stride_q - 4] TRANSPOSE_8X8B 0,1,2,3,4,5,6,7 %assign i 0 %rep 8 movq [rsp + 16*i], m %+ i %assign i i+1 %endrep ; p2 = m1 [rsp + 16] ; p1 = m2 [rsp + 32] ; p0 = m3 [rsp + 48] ; q0 = m4 [rsp + 64] ; q1 = m5 [rsp + 80] ; q2 = m6 [rsp + 96] SWAP 0, 2 SWAP 1, 3 SWAP 2, 4 SWAP 3, 5 LOAD_MASK alpha_d, beta_d movd m8, [tc0_q] punpcklbw m8, m8 pcmpeqb m9, m9 pcmpeqb m9, m8 pandn m9, m7 pand m8, m9 movdqa m3, [rsp + 16] ; p2 DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m9 psubb m7, m8, m6 pand m6, m8 LUMA_Q1 m0, m3, [rsp + 16], [rsp + 32], m6, m4 movdqa m4, [rsp + 96] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 pand m6, m9 pand m8, m6 psubb m7, m6 mova m3, [rsp + 80] LUMA_Q1 m3, m4, [rsp + 96], [rsp + 80], m8, m6 DEBLOCK_P0_Q0 SWAP 1, 3 SWAP 2, 4 movq m0, [rsp] movq m1, [rsp + 16] movq m2, [rsp + 32] movq m5, [rsp + 80] movq m6, [rsp + 96] movq m7, [rsp + 112] TRANSPOSE_8X8B 0,1,2,3,4,5,6,7 movq [pix_q - 4], m0 movq [pix_q + stride_q - 4], m1 movq [pix_q + 2*stride_q - 4], m2 movq [base3_q - 4], m3 movq [base3_q + stride_q - 4], m4 movq [base3_q + 2*stride_q - 4], m5 movq [base3_q + stride3_q - 4], m6 movq [base3_q + 4*stride_q - 4], m7 RET %endmacro INIT_XMM sse2 DEBLOCK_H_LUMA_MBAFF DEBLOCK_LUMA %if HAVE_AVX_EXTERNAL INIT_XMM avx DEBLOCK_H_LUMA_MBAFF DEBLOCK_LUMA %endif %else %macro DEBLOCK_LUMA 2 ;----------------------------------------------------------------------------- ; void ff_deblock_v8_luma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- cglobal deblock_%1_luma_8, 5,5,8,2*%2 lea r4, [r1*3] dec r2 ; alpha-1 neg r4 dec r3 ; beta-1 add r4, r0 ; pix-3*stride mova m0, [r4+r1] ; p1 mova m1, [r4+2*r1] ; p0 mova m2, [r0] ; q0 mova m3, [r0+r1] ; q1 LOAD_MASK r2, r3 mov r3, r4mp pcmpeqb m3, m3 movd m4, [r3] ; tc0 punpcklbw m4, m4 punpcklbw m4, m4 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0] mova [esp+%2], m4 ; tc pcmpgtb m4, m3 mova m3, [r4] ; p2 pand m4, m7 mova [esp], m4 ; mask DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m4 pand m4, [esp+%2] ; tc psubb m7, m4, m6 pand m6, m4 LUMA_Q1 m0, m3, [r4], [r4+r1], m6, m4 mova m4, [r0+2*r1] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 pand m6, [esp] ; mask mova m5, [esp+%2] ; tc psubb m7, m6 pand m5, m6 mova m3, [r0+r1] LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m5, m6 DEBLOCK_P0_Q0 mova [r4+2*r1], m1 mova [r0], m2 RET ;----------------------------------------------------------------------------- ; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- INIT_MMX cpuname cglobal deblock_h_luma_8, 0,5,8,0x60+12 mov r0, r0mp mov r3, r1m lea r4, [r3*3] sub r0, 4 lea r1, [r0+r4] %define pix_tmp esp+12 ; transpose 6x16 -> tmp space TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp lea r0, [r0+r3*8] lea r1, [r1+r3*8] TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp+8 ; vertical filter lea r0, [pix_tmp+0x30] PUSH dword r4m PUSH dword r3m PUSH dword r2m PUSH dword 16 PUSH dword r0 call deblock_%1_luma_8 %ifidn %1, v8 add dword [esp ], 8 ; pix_tmp+0x38 add dword [esp+16], 2 ; tc0+2 call deblock_%1_luma_8 %endif ADD esp, 20 ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter) mov r0, r0mp sub r0, 2 movq m0, [pix_tmp+0x10] movq m1, [pix_tmp+0x20] lea r1, [r0+r4] movq m2, [pix_tmp+0x30] movq m3, [pix_tmp+0x40] TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4) lea r0, [r0+r3*8] lea r1, [r1+r3*8] movq m0, [pix_tmp+0x18] movq m1, [pix_tmp+0x28] movq m2, [pix_tmp+0x38] movq m3, [pix_tmp+0x48] TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4) RET %endmacro ; DEBLOCK_LUMA INIT_MMX mmxext DEBLOCK_LUMA v8, 8 INIT_XMM sse2 DEBLOCK_LUMA v, 16 %if HAVE_AVX_EXTERNAL INIT_XMM avx DEBLOCK_LUMA v, 16 %endif %endif ; ARCH %macro LUMA_INTRA_P012 4 ; p0..p3 in memory %if ARCH_X86_64 pavgb t0, p2, p1 pavgb t1, p0, q0 %else mova t0, p2 mova t1, p0 pavgb t0, p1 pavgb t1, q0 %endif pavgb t0, t1 ; ((p2+p1+1)/2 + (p0+q0+1)/2 + 1)/2 mova t5, t1 %if ARCH_X86_64 paddb t2, p2, p1 paddb t3, p0, q0 %else mova t2, p2 mova t3, p0 paddb t2, p1 paddb t3, q0 %endif paddb t2, t3 mova t3, t2 mova t4, t2 psrlw t2, 1 pavgb t2, mpb_0 pxor t2, t0 pand t2, mpb_1 psubb t0, t2 ; p1' = (p2+p1+p0+q0+2)/4; %if ARCH_X86_64 pavgb t1, p2, q1 psubb t2, p2, q1 %else mova t1, p2 mova t2, p2 pavgb t1, q1 psubb t2, q1 %endif paddb t3, t3 psubb t3, t2 ; p2+2*p1+2*p0+2*q0+q1 pand t2, mpb_1 psubb t1, t2 pavgb t1, p1 pavgb t1, t5 ; (((p2+q1)/2 + p1+1)/2 + (p0+q0+1)/2 + 1)/2 psrlw t3, 2 pavgb t3, mpb_0 pxor t3, t1 pand t3, mpb_1 psubb t1, t3 ; p0'a = (p2+2*p1+2*p0+2*q0+q1+4)/8 pxor t3, p0, q1 pavgb t2, p0, q1 pand t3, mpb_1 psubb t2, t3 pavgb t2, p1 ; p0'b = (2*p1+p0+q0+2)/4 pxor t1, t2 pxor t2, p0 pand t1, mask1p pand t2, mask0 pxor t1, t2 pxor t1, p0 mova %1, t1 ; store p0 mova t1, %4 ; p3 paddb t2, t1, p2 pavgb t1, p2 pavgb t1, t0 ; (p3+p2+1)/2 + (p2+p1+p0+q0+2)/4 paddb t2, t2 paddb t2, t4 ; 2*p3+3*p2+p1+p0+q0 psrlw t2, 2 pavgb t2, mpb_0 pxor t2, t1 pand t2, mpb_1 psubb t1, t2 ; p2' = (2*p3+3*p2+p1+p0+q0+4)/8 pxor t0, p1 pxor t1, p2 pand t0, mask1p pand t1, mask1p pxor t0, p1 pxor t1, p2 mova %2, t0 ; store p1 mova %3, t1 ; store p2 %endmacro %macro LUMA_INTRA_SWAP_PQ 0 %define q1 m0 %define q0 m1 %define p0 m2 %define p1 m3 %define p2 q2 %define mask1p mask1q %endmacro %macro DEBLOCK_LUMA_INTRA 1 %define p1 m0 %define p0 m1 %define q0 m2 %define q1 m3 %define t0 m4 %define t1 m5 %define t2 m6 %define t3 m7 %if ARCH_X86_64 %define p2 m8 %define q2 m9 %define t4 m10 %define t5 m11 %define mask0 m12 %define mask1p m13 %if WIN64 %define mask1q [rsp] %else %define mask1q [rsp-24] %endif %define mpb_0 m14 %define mpb_1 m15 %else %define spill(x) [esp+16*x] %define p2 [r4+r1] %define q2 [r0+2*r1] %define t4 spill(0) %define t5 spill(1) %define mask0 spill(2) %define mask1p spill(3) %define mask1q spill(4) %define mpb_0 [pb_0] %define mpb_1 [pb_1] %endif ;----------------------------------------------------------------------------- ; void ff_deblock_v_luma_intra(uint8_t *pix, int stride, int alpha, int beta) ;----------------------------------------------------------------------------- %if WIN64 cglobal deblock_%1_luma_intra_8, 4,6,16,0x10 %else cglobal deblock_%1_luma_intra_8, 4,6,16,ARCH_X86_64*0x50-0x50 %endif lea r4, [r1*4] lea r5, [r1*3] ; 3*stride dec r2d ; alpha-1 jl .end neg r4 dec r3d ; beta-1 jl .end add r4, r0 ; pix-4*stride mova p1, [r4+2*r1] mova p0, [r4+r5] mova q0, [r0] mova q1, [r0+r1] %if ARCH_X86_64 pxor mpb_0, mpb_0 mova mpb_1, [pb_1] LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 SWAP 7, 12 ; m12=mask0 pavgb t5, mpb_0 pavgb t5, mpb_1 ; alpha/4+1 movdqa p2, [r4+r1] movdqa q2, [r0+2*r1] DIFF_GT2 p0, q0, t5, t0, t3 ; t0 = |p0-q0| > alpha/4+1 DIFF_GT2 p0, p2, m5, t2, t5 ; mask1 = |p2-p0| > beta-1 DIFF_GT2 q0, q2, m5, t4, t5 ; t4 = |q2-q0| > beta-1 pand t0, mask0 pand t4, t0 pand t2, t0 mova mask1q, t4 mova mask1p, t2 %else LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 mova m4, t5 mova mask0, m7 pavgb m4, [pb_0] pavgb m4, [pb_1] ; alpha/4+1 DIFF_GT2 p0, q0, m4, m6, m7 ; m6 = |p0-q0| > alpha/4+1 pand m6, mask0 DIFF_GT2 p0, p2, m5, m4, m7 ; m4 = |p2-p0| > beta-1 pand m4, m6 mova mask1p, m4 DIFF_GT2 q0, q2, m5, m4, m7 ; m4 = |q2-q0| > beta-1 pand m4, m6 mova mask1q, m4 %endif LUMA_INTRA_P012 [r4+r5], [r4+2*r1], [r4+r1], [r4] LUMA_INTRA_SWAP_PQ LUMA_INTRA_P012 [r0], [r0+r1], [r0+2*r1], [r0+r5] .end: RET INIT_MMX cpuname %if ARCH_X86_64 ;----------------------------------------------------------------------------- ; void ff_deblock_h_luma_intra(uint8_t *pix, int stride, int alpha, int beta) ;----------------------------------------------------------------------------- cglobal deblock_h_luma_intra_8, 4,9,0,0x80 movsxd r7, r1d lea r8, [r7*3] lea r6, [r0-4] lea r5, [r0-4+r8] %if WIN64 %define pix_tmp rsp+0x20 ; shadow space %else %define pix_tmp rsp %endif ; transpose 8x16 -> tmp space TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r7, r8), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30) lea r6, [r6+r7*8] lea r5, [r5+r7*8] TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r7, r8), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30) lea r0, [pix_tmp+0x40] mov r1, 0x10 call deblock_v_luma_intra_8 ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8) lea r5, [r6+r8] TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8) shl r7, 3 sub r6, r7 sub r5, r7 shr r7, 3 TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8) RET %else cglobal deblock_h_luma_intra_8, 2,4,8,0x80 lea r3, [r1*3] sub r0, 4 lea r2, [r0+r3] %define pix_tmp rsp ; transpose 8x16 -> tmp space TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30) lea r0, [r0+r1*8] lea r2, [r2+r1*8] TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30) lea r0, [pix_tmp+0x40] PUSH dword r3m PUSH dword r2m PUSH dword 16 PUSH r0 call deblock_%1_luma_intra_8 %ifidn %1, v8 add dword [rsp], 8 ; pix_tmp+8 call deblock_%1_luma_intra_8 %endif ADD esp, 16 mov r1, r1m mov r0, r0mp lea r3, [r1*3] sub r0, 4 lea r2, [r0+r3] ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8) TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3) lea r0, [r0+r1*8] lea r2, [r2+r1*8] TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3) RET %endif ; ARCH_X86_64 %endmacro ; DEBLOCK_LUMA_INTRA INIT_XMM sse2 DEBLOCK_LUMA_INTRA v %if HAVE_AVX_EXTERNAL INIT_XMM avx DEBLOCK_LUMA_INTRA v %endif %if ARCH_X86_64 == 0 INIT_MMX mmxext DEBLOCK_LUMA_INTRA v8 %endif INIT_MMX mmxext %macro CHROMA_V_START 0 dec r2d ; alpha-1 dec r3d ; beta-1 mov t5, r0 sub t5, r1 sub t5, r1 %endmacro %macro CHROMA_H_START 0 dec r2d dec r3d sub r0, 2 lea t6, [r1*3] mov t5, r0 add r0, t6 %endmacro %define t5 r5 %define t6 r6 ;----------------------------------------------------------------------------- ; void ff_deblock_v_chroma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- cglobal deblock_v_chroma_8, 5,6 CHROMA_V_START movq m0, [t5] movq m1, [t5+r1] movq m2, [r0] movq m3, [r0+r1] call ff_chroma_inter_body_mmxext movq [t5+r1], m1 movq [r0], m2 RET ;----------------------------------------------------------------------------- ; void ff_deblock_h_chroma(uint8_t *pix, int stride, int alpha, int beta, ; int8_t *tc0) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_8, 5,7 %if ARCH_X86_64 ; This could use the red zone on 64 bit unix to avoid the stack pointer ; readjustment, but valgrind assumes the red zone is clobbered on ; function calls and returns. sub rsp, 16 %define buf0 [rsp] %define buf1 [rsp+8] %else %define buf0 r0m %define buf1 r2m %endif CHROMA_H_START TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6) movq buf0, m0 movq buf1, m3 LOAD_MASK r2d, r3d movd m6, [r4] ; tc0 punpcklbw m6, m6 pand m7, m6 DEBLOCK_P0_Q0 movq m0, buf0 movq m3, buf1 TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) %if ARCH_X86_64 add rsp, 16 %endif RET ALIGN 16 ff_chroma_inter_body_mmxext: LOAD_MASK r2d, r3d movd m6, [r4] ; tc0 punpcklbw m6, m6 pand m7, m6 DEBLOCK_P0_Q0 ret %define t5 r4 %define t6 r5 cglobal deblock_h_chroma422_8, 5, 6 SUB rsp, (1+ARCH_X86_64*2)*mmsize %if ARCH_X86_64 %define buf0 [rsp+16] %define buf1 [rsp+8] %else %define buf0 r0m %define buf1 r2m %endif movd m6, [r4] punpcklbw m6, m6 movq [rsp], m6 CHROMA_H_START TRANSPOSE4x8B_LOAD PASS8ROWS(t5, r0, r1, t6) movq buf0, m0 movq buf1, m3 LOAD_MASK r2d, r3d movd m6, [rsp] punpcklwd m6, m6 pand m7, m6 DEBLOCK_P0_Q0 movq m0, buf0 movq m3, buf1 TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) lea r0, [r0+r1*8] lea t5, [t5+r1*8] TRANSPOSE4x8B_LOAD PASS8ROWS(t5, r0, r1, t6) movq buf0, m0 movq buf1, m3 LOAD_MASK r2d, r3d movd m6, [rsp+4] punpcklwd m6, m6 pand m7, m6 DEBLOCK_P0_Q0 movq m0, buf0 movq m3, buf1 TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) ADD rsp, (1+ARCH_X86_64*2)*mmsize RET ; in: %1=p0 %2=p1 %3=q1 ; out: p0 = (p0 + q1 + 2*p1 + 2) >> 2 %macro CHROMA_INTRA_P0 3 movq m4, %1 pxor m4, %3 pand m4, [pb_1] ; m4 = (p0^q1)&1 pavgb %1, %3 psubusb %1, m4 pavgb %1, %2 ; dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) %endmacro ;------------------------------------------------------------------------------ ; void ff_deblock_v_chroma_intra(uint8_t *pix, int stride, int alpha, int beta) ;------------------------------------------------------------------------------ cglobal deblock_v_chroma_intra_8, 4,5 CHROMA_V_START movq m0, [t5] movq m1, [t5+r1] movq m2, [r0] movq m3, [r0+r1] call ff_chroma_intra_body_mmxext movq [t5+r1], m1 movq [r0], m2 RET ;------------------------------------------------------------------------------ ; void ff_deblock_h_chroma_intra(uint8_t *pix, int stride, int alpha, int beta) ;------------------------------------------------------------------------------ cglobal deblock_h_chroma_intra_8, 4,6 CHROMA_H_START TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6) call ff_chroma_intra_body_mmxext TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) RET cglobal deblock_h_chroma422_intra_8, 4, 6 CHROMA_H_START TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6) call ff_chroma_intra_body_mmxext TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) lea r0, [r0+r1*8] lea t5, [t5+r1*8] TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6) call ff_chroma_intra_body_mmxext TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6) RET ALIGN 16 ff_chroma_intra_body_mmxext: LOAD_MASK r2d, r3d movq m5, m1 movq m6, m2 CHROMA_INTRA_P0 m1, m0, m3 CHROMA_INTRA_P0 m2, m3, m0 psubb m1, m5 psubb m2, m6 pand m1, m7 pand m2, m7 paddb m1, m5 paddb m2, m6 ret %macro LOAD_8_ROWS 8 movd m0, %1 movd m1, %2 movd m2, %3 movd m3, %4 movd m4, %5 movd m5, %6 movd m6, %7 movd m7, %8 %endmacro %macro STORE_8_ROWS 8 movd %1, m0 movd %2, m1 movd %3, m2 movd %4, m3 movd %5, m4 movd %6, m5 movd %7, m6 movd %8, m7 %endmacro %macro TRANSPOSE_8x4B_XMM 0 punpcklbw m0, m1 punpcklbw m2, m3 punpcklbw m4, m5 punpcklbw m6, m7 punpcklwd m0, m2 punpcklwd m4, m6 punpckhdq m2, m0, m4 punpckldq m0, m4 MOVHL m1, m0 MOVHL m3, m2 %endmacro %macro TRANSPOSE_4x8B_XMM 0 punpcklbw m0, m1 punpcklbw m2, m3 punpckhwd m4, m0, m2 punpcklwd m0, m2 MOVHL m6, m4 MOVHL m2, m0 pshufd m1, m0, 1 pshufd m3, m2, 1 pshufd m5, m4, 1 pshufd m7, m6, 1 %endmacro %macro CHROMA_INTER_BODY_XMM 1 LOAD_MASK alpha_d, beta_d movd m6, [tc0_q] %rep %1 punpcklbw m6, m6 %endrep pand m7, m6 DEBLOCK_P0_Q0 %endmacro %macro CHROMA_INTRA_BODY_XMM 0 LOAD_MASK alpha_d, beta_d mova m5, m1 mova m6, m2 pxor m4, m1, m3 pand m4, [pb_1] pavgb m1, m3 psubusb m1, m4 pavgb m1, m0 pxor m4, m2, m0 pand m4, [pb_1] pavgb m2, m0 psubusb m2, m4 pavgb m2, m3 psubb m1, m5 psubb m2, m6 pand m1, m7 pand m2, m7 paddb m1, m5 paddb m2, m6 %endmacro %macro CHROMA_V_START_XMM 1 movsxdifnidn stride_q, stride_d dec alpha_d dec beta_d mov %1, pix_q sub %1, stride_q sub %1, stride_q %endmacro %macro CHROMA_H_START_XMM 2 movsxdifnidn stride_q, stride_d dec alpha_d dec beta_d lea %2, [3*stride_q] mov %1, pix_q add %1, %2 %endmacro %macro DEBLOCK_CHROMA_XMM 1 INIT_XMM %1 cglobal deblock_v_chroma_8, 5, 6, 8, pix_, stride_, alpha_, beta_, tc0_ CHROMA_V_START_XMM r5 movq m0, [r5] movq m1, [r5 + stride_q] movq m2, [pix_q] movq m3, [pix_q + stride_q] CHROMA_INTER_BODY_XMM 1 movq [r5 + stride_q], m1 movq [pix_q], m2 RET cglobal deblock_h_chroma_8, 5, 7, 8, 0-16, pix_, stride_, alpha_, beta_, tc0_ CHROMA_H_START_XMM r5, r6 LOAD_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) TRANSPOSE_8x4B_XMM movq [rsp], m0 movq [rsp + 8], m3 CHROMA_INTER_BODY_XMM 1 movq m0, [rsp] movq m3, [rsp + 8] TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) RET cglobal deblock_h_chroma422_8, 5, 7, 8, 0-16, pix_, stride_, alpha_, beta_, tc0_ CHROMA_H_START_XMM r5, r6 LOAD_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) TRANSPOSE_8x4B_XMM movq [rsp], m0 movq [rsp + 8], m3 CHROMA_INTER_BODY_XMM 2 movq m0, [rsp] movq m3, [rsp + 8] TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) lea pix_q, [pix_q + 8*stride_q] lea r5, [r5 + 8*stride_q] add tc0_q, 2 LOAD_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) TRANSPOSE_8x4B_XMM movq [rsp], m0 movq [rsp + 8], m3 CHROMA_INTER_BODY_XMM 2 movq m0, [rsp] movq m3, [rsp + 8] TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r5 - 2, stride_q, r6) RET cglobal deblock_v_chroma_intra_8, 4, 5, 8, pix_, stride_, alpha_, beta_ CHROMA_V_START_XMM r4 movq m0, [r4] movq m1, [r4 + stride_q] movq m2, [pix_q] movq m3, [pix_q + stride_q] CHROMA_INTRA_BODY_XMM movq [r4 + stride_q], m1 movq [pix_q], m2 RET cglobal deblock_h_chroma_intra_8, 4, 6, 8, pix_, stride_, alpha_, beta_ CHROMA_H_START_XMM r4, r5 LOAD_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) TRANSPOSE_8x4B_XMM CHROMA_INTRA_BODY_XMM TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) RET cglobal deblock_h_chroma422_intra_8, 4, 6, 8, pix_, stride_, alpha_, beta_ CHROMA_H_START_XMM r4, r5 LOAD_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) TRANSPOSE_8x4B_XMM CHROMA_INTRA_BODY_XMM TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) lea pix_q, [pix_q + 8*stride_q] lea r4, [r4 + 8*stride_q] LOAD_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) TRANSPOSE_8x4B_XMM CHROMA_INTRA_BODY_XMM TRANSPOSE_4x8B_XMM STORE_8_ROWS PASS8ROWS(pix_q - 2, r4 - 2, stride_q, r5) RET %endmacro ; DEBLOCK_CHROMA_XMM DEBLOCK_CHROMA_XMM sse2 DEBLOCK_CHROMA_XMM avx ;----------------------------------------------------------------------------- ; void ff_h264_loop_filter_strength(int16_t bs[2][4][4], uint8_t nnz[40], ; int8_t ref[2][40], int16_t mv[2][40][2], ; int bidir, int edges, int step, ; int mask_mv0, int mask_mv1, int field); ; ; bidir is 0 or 1 ; edges is 1 or 4 ; step is 1 or 2 ; mask_mv0 is 0 or 3 ; mask_mv1 is 0 or 1 ; field is 0 or 1 ;----------------------------------------------------------------------------- %macro loop_filter_strength_iteration 7 ; edges, step, mask_mv, ; dir, d_idx, mask_dir, bidir %define edgesd %1 %define stepd %2 %define mask_mvd %3 %define dir %4 %define d_idx %5 %define mask_dir %6 %define bidir %7 xor b_idxd, b_idxd ; for (b_idx = 0; b_idx < edges; b_idx += step) %%.b_idx_loop: %if mask_dir == 0 pxor m0, m0 %endif test b_idxd, dword mask_mvd jnz %%.skip_loop_iter ; if (!(b_idx & mask_mv)) %if bidir == 1 movd m2, [refq+b_idxq+d_idx+12] ; { ref0[bn] } punpckldq m2, [refq+b_idxq+d_idx+52] ; { ref0[bn], ref1[bn] } pshufw m0, [refq+b_idxq+12], 0x44 ; { ref0[b], ref0[b] } pshufw m1, [refq+b_idxq+52], 0x44 ; { ref1[b], ref1[b] } pshufw m3, m2, 0x4E ; { ref1[bn], ref0[bn] } psubb m0, m2 ; { ref0[b] != ref0[bn], ; ref0[b] != ref1[bn] } psubb m1, m3 ; { ref1[b] != ref1[bn], ; ref1[b] != ref0[bn] } por m0, m1 mova m1, [mvq+b_idxq*4+(d_idx+12)*4] mova m2, [mvq+b_idxq*4+(d_idx+12)*4+mmsize] mova m3, m1 mova m4, m2 psubw m1, [mvq+b_idxq*4+12*4] psubw m2, [mvq+b_idxq*4+12*4+mmsize] psubw m3, [mvq+b_idxq*4+52*4] psubw m4, [mvq+b_idxq*4+52*4+mmsize] packsswb m1, m2 packsswb m3, m4 paddb m1, m6 paddb m3, m6 psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit psubusb m3, m5 packsswb m1, m3 por m0, m1 mova m1, [mvq+b_idxq*4+(d_idx+52)*4] mova m2, [mvq+b_idxq*4+(d_idx+52)*4+mmsize] mova m3, m1 mova m4, m2 psubw m1, [mvq+b_idxq*4+12*4] psubw m2, [mvq+b_idxq*4+12*4+mmsize] psubw m3, [mvq+b_idxq*4+52*4] psubw m4, [mvq+b_idxq*4+52*4+mmsize] packsswb m1, m2 packsswb m3, m4 paddb m1, m6 paddb m3, m6 psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit psubusb m3, m5 packsswb m1, m3 pshufw m1, m1, 0x4E por m0, m1 pshufw m1, m0, 0x4E pminub m0, m1 %else ; bidir == 0 movd m0, [refq+b_idxq+12] psubb m0, [refq+b_idxq+d_idx+12] ; ref[b] != ref[bn] mova m1, [mvq+b_idxq*4+12*4] mova m2, [mvq+b_idxq*4+12*4+mmsize] psubw m1, [mvq+b_idxq*4+(d_idx+12)*4] psubw m2, [mvq+b_idxq*4+(d_idx+12)*4+mmsize] packsswb m1, m2 paddb m1, m6 psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit packsswb m1, m1 por m0, m1 %endif ; bidir == 1/0 %%.skip_loop_iter: movd m1, [nnzq+b_idxq+12] por m1, [nnzq+b_idxq+d_idx+12] ; nnz[b] || nnz[bn] pminub m1, m7 pminub m0, m7 psllw m1, 1 pxor m2, m2 pmaxub m1, m0 punpcklbw m1, m2 movq [bsq+b_idxq+32*dir], m1 add b_idxd, dword stepd cmp b_idxd, dword edgesd jl %%.b_idx_loop %endmacro INIT_MMX mmxext cglobal h264_loop_filter_strength, 9, 9, 0, bs, nnz, ref, mv, bidir, edges, \ step, mask_mv0, mask_mv1, field %define b_idxq bidirq %define b_idxd bidird cmp dword fieldm, 0 mova m7, [pb_1] mova m5, [pb_3] je .nofield mova m5, [pb_3_1] .nofield: mova m6, m5 paddb m5, m5 shl dword stepd, 3 shl dword edgesd, 3 %if ARCH_X86_32 %define mask_mv0d mask_mv0m %define mask_mv1d mask_mv1m %endif shl dword mask_mv1d, 3 shl dword mask_mv0d, 3 cmp dword bidird, 0 jne .bidir loop_filter_strength_iteration edgesd, stepd, mask_mv1d, 1, -8, 0, 0 loop_filter_strength_iteration 32, 8, mask_mv0d, 0, -1, -1, 0 mova m0, [bsq+mmsize*0] mova m1, [bsq+mmsize*1] mova m2, [bsq+mmsize*2] mova m3, [bsq+mmsize*3] TRANSPOSE4x4W 0, 1, 2, 3, 4 mova [bsq+mmsize*0], m0 mova [bsq+mmsize*1], m1 mova [bsq+mmsize*2], m2 mova [bsq+mmsize*3], m3 RET .bidir: loop_filter_strength_iteration edgesd, stepd, mask_mv1d, 1, -8, 0, 1 loop_filter_strength_iteration 32, 8, mask_mv0d, 0, -1, -1, 1 mova m0, [bsq+mmsize*0] mova m1, [bsq+mmsize*1] mova m2, [bsq+mmsize*2] mova m3, [bsq+mmsize*3] TRANSPOSE4x4W 0, 1, 2, 3, 4 mova [bsq+mmsize*0], m0 mova [bsq+mmsize*1], m1 mova [bsq+mmsize*2], m2 mova [bsq+mmsize*3], m3 RET
; A218657: Hilltop maps: number of n X 2 binary arrays indicating the locations of corresponding elements not exceeded by any king-move neighbor in a random 0..1 n X 2 array. ; Submitted by Jamie Morken(s4) ; 3,15,57,225,891,3519,13905,54945,217107,857871,3389769,13394241,52925643,209128959,826346529,3265203393,12902036643,50980759695,201443999193,795980386593,3145215436443,12427919466687,49107345869169,194041442316897,766730122958259,3029636733432975,11971224896124393,47302775257546881,186910910661312747,738554732444952063,2918305255091435073,11531312694593099649,45564518046388460355,180042407988218985231,711414716187601635705,2811064926666627243873,11107566152527343594427,43890137386144717422015 mov $1,1 mov $2,1 lpb $0 sub $0,1 add $1,1 mul $1,3 add $1,$4 add $1,$3 add $1,1 mul $2,3 mov $4,$3 mov $3,$2 mov $2,$1 lpe mov $0,$1 sub $0,1 mul $0,2 add $0,3
_video_ = "8000,8600,20,20,6,000000,ffffff,880000,aaffee,cc44cc,00cc55,0000aa,eeee77,dd8855,664400,ff7777,333333,777777,aaff66,0088ff,bbbbbb" _stdioChar_ = "8601" chio = $8601 key = $8600 org $9000 start lda key beq start sta chio lda #'\n' sta chio lda #0 sta key jmp start org $FFFC dw start
;******************************************************************************************************** ; uC/OS-II ; The Real-Time Kernel ; ; Copyright 1992-2020 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. ; ;******************************************************************************************************** ;******************************************************************************************************** ; ; TI C28x Port ; ; Filename : os_cpu_a.asm ; Version : V2.93.00 ;******************************************************************************************************** ; For : TI C28x ; Mode : C28 Object mode ; Toolchain : TI C/C++ Compiler ;******************************************************************************************************** ;******************************************************************************************************** ; INCLUDE FILES ;******************************************************************************************************** .include "os_cpu_i.asm" ;******************************************************************************************************** ; EXTERNAL GLOBAL VARIABLES ;******************************************************************************************************** ; External references .ref _OSRunning .ref _OSPrioCur .ref _OSPrioHighRdy .ref _OSTCBCur .ref _OSTCBHighRdy .ref _OSIntExit .ref _OSTaskSwHook .ref _OS_CPU_IntHandler ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** ; Functions declared in this file .def _OS_CPU_GetST0 .def _OS_CPU_GetST1 .def _OS_CPU_SR_Save .def _OS_CPU_SR_Restore .def _OSStartHighRdy .def _OS_CPU_RTOSINT_Handler .def _OS_CPU_INT_Handler ;******************************************************************************************************** ; EQUATES ;******************************************************************************************************** ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** ; Set text section and reset local labels. .text .newblock ;******************************************************************************************************** ; GET ST0 and ST1 ; ; Description : Wrapper function to get ST0 and ST1 registers from a C function. ; ; Prototypes : INT16U OS_CPU_GetST0(void); ; INT16U OS_CPU_GetST1(void); ;******************************************************************************************************** .asmfunc _OS_CPU_GetST0: PUSH ST0 POP AL LRETR .endasmfunc .asmfunc _OS_CPU_GetST1: PUSH ST1 POP AL LRETR .endasmfunc ;******************************************************************************************************** ; CRITICAL SECTION METHOD 3 FUNCTIONS ; ; Description: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you ; would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then ; disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to ; disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr' ; into the CPU's status register. ; ; Prototypes : OS_CPU_SR OS_CPU_SR_Save(void); ; void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr); ; ; ; Note(s) : 1) These functions are used in general like this: ; ; void Task (void *p_arg) ; { ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ ; OS_CPU_SR cpu_sr; ; #endif ; ; : ; : ; OS_ENTER_CRITICAL(); /* cpu_sr = OS_CPU_SaveSR(); */ ; : ; : ; OS_EXIT_CRITICAL(); /* OS_CPU_RestoreSR(cpu_sr); */ ; : ; : ; } ;******************************************************************************************************** .asmfunc _OS_CPU_SR_Save: PUSH ST1 DINT POP @AL AND AL, #1 LRETR .endasmfunc .asmfunc _OS_CPU_SR_Restore: PUSH ST1 POP AR0 AND AR0, #0xFFFE OR AL, AR0 PUSH AL POP ST1 LRETR .endasmfunc ;******************************************************************************************************** ; 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) OSStartHighRdy() MUST: ; a) Call OSTaskSwHook(). ; b) Set OSRunning to TRUE; ; c) Restore context for OSTCBCurPtr. ; d) IRET into highest ready task. ;******************************************************************************************************** .asmfunc _OSStartHighRdy: ; Call OSTaskSwHook() LCR #_OSTaskSwHook ; Set OSRunning to TRUE. MOVL XAR0, #_OSRunning MOV *AR0, #1 ; Restore context. MOVL XAR0, #_OSTCBCur ; Get the process's SP. MOVL XAR1, *XAR0 MOV AL , *AR1 MOV @SP , AL ; Restore registers. OS_CTX_RESTORE ; IRET into task. IRET .endasmfunc ; Catch start high failure. OSStartHang: SB OSStartHang, UNC ;******************************************************************************************************** ; GENERIC INTERRUPT HANDLER ; void OS_CPU_INT_Handler(void) ; ; Note(s) : 1) Assembly wrapper for ISRs. ; ; 2) Saves task context before servicing the interrupt and maintains the value of IER across ; interrupts. ;******************************************************************************************************** .asmfunc _OS_CPU_INT_Handler: OS_CTX_SAVE ASP LCR #_OS_CPU_IntHandler NASP OS_CTX_RESTORE IRET .endasmfunc ;******************************************************************************************************** ; HANDLE RTOSINT INTERRUPT ; void OS_CPU_RTOSINT_Handler(void) ; ; Note(s) : 1) The RTOSINT interrupt is used to perform a context switch. The C28x core saves the ; ST0, T, ACC, P, AR0, AR1, ST1, DP, IER, DBGSTAT (shadow) registers and the Return ; Address. ; The remaining registers AR1H, AR0H, XAR2..XAR7, XT and RPC are saved by the handler. ; ; 2) The context switching RTOSINT handler pseudo-code is: ; a) Save remaining registers on the process stack; ; b) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP; ; c) Call OSTaskSwHook(); ; d) Get current high priority, OSPrioCur = OSPrioHighRdy; ; e) Get current ready thread TCB, OSTCBCur = OSTCBHighRdy; ; f) Get new process SP from TCB, SP = OSTCBHighRdy->OSTCBStkPtr; ; g) Restore AR1H, AR0H, XAR2..XAR7, XT and RPC registers from the new process stack; ; h) Overwrite the previously saved (at context switch out) IER register with current IER. ; i) Perform exception return which will restore remaining context. ; ; 3) On entry into RTOSINT handler: ; a) The following have been saved on the process stack (by processor): ; ST0, T, ACC, P, AR0, AR1, ST1, DP, IER, DBGSTAT (shadow) registers and the Return ; Address. ; b) OSTCBCurPtr points to the OS_TCB of the task to suspend ; OSTCBHighRdyPtr points to the OS_TCB of the task to resume ; ; 4) This function MUST be placed in entry 16 (for RTOSINT) of the C28x interrupt table. ;******************************************************************************************************** .asmfunc _OS_CPU_RTOSINT_Handler: ; Save registers. OS_CTX_SAVE ; Save SP to current process. MOVL XAR0, #_OSTCBCur ; Get the process's SP. MOVL XAR1, *XAR0 MOV AL , @SP MOV *AR1, AL ASP ; Align the stack pointer. ; Call OSTaskSwHook. LCR #_OSTaskSwHook NASP ; Restore alignement of the stack pointer. ; OSPrioCur = OSPrioHighRdy MOVL XAR0, #_OSPrioHighRdy MOVL XAR1, #_OSPrioCur MOV ACC, *XAR0 MOV *XAR1, ACC ; OSTCBCur = OSTCBHighRdy MOVL XAR0, #_OSTCBHighRdy MOVL XAR1, #_OSTCBCur MOVL ACC, *XAR0 MOVL *XAR1, ACC ; Get SP from new process. MOVL XAR0, *XAR1 MOV AL , *AR0 MOV @SP , AL OS_CTX_RESTORE ; Return from interrupt to restore remaining registers. IRET .endasmfunc ;******************************************************************************************************** ; OS-II ASSEMBLY PORT FILE END ;******************************************************************************************************** .end
.text .global _start _start: add $5, %al int $0x80
section utility xdef mes_msleft xref mes_zero mes_msleft dc.w $0100,$0000 dc.w 7,8,0,0 dc.l mcs_msright-* dc.l mes_zero-* dc.l 0 mcs_msright dc.w $7C00,$0000 dc.w $F260,$0000 dc.w $F260,$0000 dc.w $FE00,$0000 dc.w $8200,$0000 dc.w $8200,$0000 dc.w $8200,$0000 dc.w $7C00,$0000 * end
; Speed scene after Dodongo's Cavern .orga 0x2221E88 :: .word 0x000C003B, 0x003C003C .orga 0x2223308 :: .word 0x00810000, 0x003A0000 ; Speed scene after Jabu Jabu's Belly .orga 0xCA3530 :: .word 0x00000000 .orga 0x2113340 :: .word 0x000D003B, 0x003C003C .orga 0x2113C18 :: .word 0x00820000, 0x003A0000 .orga 0x21131D0 :: .word 0x00010000, 0x003C003C ; Speed scene after Forest Temple .orga 0xD4ED68 :: .word 0x0045003B, 0x003C003C .orga 0xD4ED78 :: .word 0x003E0000, 0x003A0000 .orga 0x207B9D4 :: .word 0xFFFFFFFF ; Speed scene after Fire Temple .orga 0x2001848 :: .word 0x001E0001, 0x00020002 .orga 0xD100B4 :: .word 0x0062003B, 0x003C003C .orga 0xD10134 :: .word 0x003C0000, 0x003A0000 ; Speed scene after Water Temple .orga 0xD5A458 :: .word 0x0015003B, 0x003C003C .orga 0xD5A3A8 :: .word 0x003D0000, 0x003A0000 .orga 0x20D0D20 :: .word 0x002900C7, 0x00C800C8 ; Speed scene after Shadow Temple .orga 0xD13EC8 :: .word 0x0061003B, 0x003C003C .orga 0xD13E18 :: .word 0x00410000, 0x003A0000 ; Speed scene after Spirit Temple .orga 0xD3A0A8 :: .word 0x0060003B, 0x003C003C .orga 0xD39FF0 :: .word 0x003F0000, 0x003A0000 ; Speed Phantom Ganon defeat scene .orga 0xC944D8 :: .word 0x00000000 .orga 0xC94548 :: .word 0x00000000 .orga 0xC94730 :: .word 0x00000000 .orga 0xC945A8 :: .word 0x00000000 .orga 0xC94594 :: .word 0x00000000 ; Speed up the Nabooru defeat cutscene .orga 0x2F5AF84 :: .word 0x00000005 .orga 0x2F5C7DA :: .word 0x00010002 .orga 0x2F5C7A2 :: .word 0x00030004 .orga 0x2F5B369 :: .byte 0x09 .orga 0x2F5B491 :: .byte 0x04 .orga 0x2F5B559 :: .byte 0x04 .orga 0x2F5B621 :: .byte 0x04 .orga 0x2F5B761 :: .byte 0x07 .orga 0x2F5B840 :: .word 0x00050001, 0x00050005 ; shorten white flash ; Speed up twinrova defeat cutscene .orga 0xD678CC :: .word 0x240103A2, 0xA6010142 .orga 0xD67BA4 :: .halfword 0x10, 0x00 ; Speed up Zelda descending after defeating Ganondorf .orga 0xD82AB3 :: .byte 0x66 .orga 0xD82FAF :: .byte 0x65 .orga 0xD82D2E :: .halfword 0x041F .orga 0xD83142 :: .halfword 0x006B .orga 0xD82DD8 :: .word 0x00000000 .orga 0xD82ED4 :: .word 0x00000000 .orga 0xD82FDF :: .byte 0x33 ; Speed completion of the trials in Ganon's Castle .orga 0x31A8090 :: .halfword 0x006B, 0x0001, 0x0002, 0x0002 ; Forest .orga 0x31A9E00 :: .halfword 0x006E, 0x0001, 0x0002, 0x0002 ; Fire .orga 0x31A8B18 :: .halfword 0x006C, 0x0001, 0x0002, 0x0002 ; Water .orga 0x31A9430 :: .halfword 0x006D, 0x0001, 0x0002, 0x0002 ; Shadow .orga 0x31AB200 :: .halfword 0x0070, 0x0001, 0x0002, 0x0002 ; Spirit .orga 0x31AA830 :: .halfword 0x006F, 0x0001, 0x0002, 0x0002 ; Light ; Speed obtaining Fairy Ocarina .orga 0x2151230 :: .word 0x0072003C, 0x003D003D .orga 0x2151240 :: .word 0x004A0000, 0x003A0000, 0xFFFFFFFF, 0xFFFF003C, 0x0081FFFF .orga 0x2150E20 :: .word 0xFFFFFA4C ; Remove remaining owls - Note: Might be good to label these .orga 0x1FE30CE :: .byte 0x01, 0x4B .orga 0x1FE30DE :: .byte 0x01, 0x4B .orga 0x1FE30EE :: .byte 0x01, 0x4B .orga 0x205909E :: .byte 0x00, 0x3F .orga 0x2059094 :: .byte 0x80 ; Speed up opening the royal tomb for both child and adult .orga 0x2025026 :: .byte 0x00, 0x01 .orga 0x2023C86 :: .byte 0x00, 0x01 .orga 0x2025159 :: .byte 0x02 .orga 0x2023E19 :: .byte 0x02 ; Speed opening of Door of Time .orga 0xE0A176 :: .byte 0x00, 0x02 .orga 0xE0A35A :: .byte 0x00, 0x01, 0x00, 0x02 ; Speed up owl flights .orga 0x20E60D2 :: .byte 0x00, 0x01 ; Lake Hylia .orga 0x223B6B2 :: .byte 0x00, 0x01 ; Death Mountain Trail ; Remove disruptive text from Gerudo Training Ground and early Shadow Temple (vanilla) .orga 0x27C00BC :: .byte 0xFB .orga 0x27C00CC :: .byte 0xFB .orga 0x27C00DC :: .byte 0xFB .orga 0x27C00EC :: .byte 0xFB .orga 0x27C00FC :: .byte 0xFB .orga 0x27C010C :: .byte 0xFB .orga 0x27C011C :: .byte 0xFB .orga 0x27C012C :: .byte 0xFB .orga 0x27CE080 :: .byte 0xFB .orga 0x27CE090 :: .byte 0xFB .orga 0x2887070 :: .byte 0xFB .orga 0x2887080 :: .byte 0xFB .orga 0x2887090 :: .byte 0xFB .orga 0x2897070 :: .byte 0xFB .orga 0x28C7134 :: .byte 0xFB .orga 0x28D91BC :: .byte 0xFB .orga 0x28A60F4 :: .byte 0xFB .orga 0x28AE084 :: .byte 0xFB .orga 0x28B9174 :: .byte 0xFB .orga 0x28BF168 :: .byte 0xFB .orga 0x28BF178 :: .byte 0xFB .orga 0x28BF188 :: .byte 0xFB .orga 0x28A1144 :: .byte 0xFB .orga 0x28A6104 :: .byte 0xFB .orga 0x28D0094 :: .byte 0xFB ; Fix proximity textboxes (Navi) .orga 0xDF8B84 :: .byte 0x00, 0x00, 0x00, 0x00 ; Not ported ; anything before the next one ; Speed scene after Deku Tree ; Darunia won't dance ; King Zora moves quickly ; Speed Jabu Jabu swallowing Link ; Ruto no longer points to Zora Sapphire ; Speed up Epona race start ; Speed up Epona escape ; Speed up draining the well ; Poacher's Saw no longer messes up Forest Stage ; Tell Sheik at Ice Cavern we are always an Adult
lda {m1} sta $fc clc sty $fe adc $fe sta $fe lda {m1}+1 sta $fd adc #00 sta $ff ldy #0 !: lda ($fe),y sta ($fc),y iny dex bne !-
dnl AMD K7 mpn_divexact_1 -- mpn by limb exact division. dnl Copyright 2001, 2002, 2004, 2007 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C Athlon: 11.0 C Hammer: 9.0 C void mpn_divexact_1 (mp_ptr dst, mp_srcptr src, mp_size_t size, C mp_limb_t divisor); C C The dependent chain is mul+imul+sub for 11 cycles and that speed is C achieved with no special effort. The load and shrld latencies are hidden C by out of order execution. C C It's a touch faster on size==1 to use the mul-by-inverse than divl. defframe(PARAM_DIVISOR,16) defframe(PARAM_SIZE, 12) defframe(PARAM_SRC, 8) defframe(PARAM_DST, 4) defframe(SAVE_EBX, -4) defframe(SAVE_ESI, -8) defframe(SAVE_EDI, -12) defframe(SAVE_EBP, -16) defframe(VAR_INVERSE, -20) defframe(VAR_DST_END, -24) deflit(STACK_SPACE, 24) TEXT ALIGN(16) PROLOGUE(mpn_divexact_1) deflit(`FRAME',0) movl PARAM_DIVISOR, %eax subl $STACK_SPACE, %esp deflit(`FRAME',STACK_SPACE) movl $-1, %ecx C shift count movl %ebp, SAVE_EBP movl PARAM_SIZE, %ebp movl %esi, SAVE_ESI movl %edi, SAVE_EDI C If there's usually only one or two trailing zero bits then this C should be faster than bsfl. L(strip_twos): incl %ecx shrl %eax jnc L(strip_twos) movl %ebx, SAVE_EBX leal 1(%eax,%eax), %ebx C d without twos andl $127, %eax C d/2, 7 bits ifdef(`PIC',` LEA( binvert_limb_table, %edx) movzbl (%eax,%edx), %eax C inv 8 bits ',` movzbl binvert_limb_table(%eax), %eax C inv 8 bits ') leal (%eax,%eax), %edx C 2*inv movl %ebx, PARAM_DIVISOR C d without twos imull %eax, %eax C inv*inv movl PARAM_SRC, %esi movl PARAM_DST, %edi imull %ebx, %eax C inv*inv*d subl %eax, %edx C inv = 2*inv - inv*inv*d leal (%edx,%edx), %eax C 2*inv imull %edx, %edx C inv*inv leal (%esi,%ebp,4), %esi C src end leal (%edi,%ebp,4), %edi C dst end negl %ebp C -size imull %ebx, %edx C inv*inv*d subl %edx, %eax C inv = 2*inv - inv*inv*d ASSERT(e,` C expect d*inv == 1 mod 2^GMP_LIMB_BITS pushl %eax FRAME_pushl() imull PARAM_DIVISOR, %eax cmpl $1, %eax popl %eax FRAME_popl()') movl %eax, VAR_INVERSE movl (%esi,%ebp,4), %eax C src[0] incl %ebp jz L(one) movl (%esi,%ebp,4), %edx C src[1] shrdl( %cl, %edx, %eax) movl %edi, VAR_DST_END xorl %ebx, %ebx jmp L(entry) ALIGN(8) L(top): C eax q C ebx carry bit, 0 or 1 C ecx shift C edx C esi src end C edi dst end C ebp counter, limbs, negative mull PARAM_DIVISOR C carry limb in edx movl -4(%esi,%ebp,4), %eax movl (%esi,%ebp,4), %edi shrdl( %cl, %edi, %eax) subl %ebx, %eax C apply carry bit setc %bl movl VAR_DST_END, %edi subl %edx, %eax C apply carry limb adcl $0, %ebx L(entry): imull VAR_INVERSE, %eax movl %eax, -4(%edi,%ebp,4) incl %ebp jnz L(top) mull PARAM_DIVISOR C carry limb in edx movl -4(%esi), %eax C src high limb shrl %cl, %eax movl SAVE_ESI, %esi subl %ebx, %eax C apply carry bit movl SAVE_EBX, %ebx movl SAVE_EBP, %ebp subl %edx, %eax C apply carry limb imull VAR_INVERSE, %eax movl %eax, -4(%edi) movl SAVE_EDI, %edi addl $STACK_SPACE, %esp ret L(one): shrl %cl, %eax movl SAVE_ESI, %esi movl SAVE_EBX, %ebx imull VAR_INVERSE, %eax movl SAVE_EBP, %ebp movl %eax, -4(%edi) movl SAVE_EDI, %edi addl $STACK_SPACE, %esp ret EPILOGUE()
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: TEdit (Sample PC GEOS application) FILE: tedit.asm REVISION HISTORY: Name Date Description ---- ---- ----------- tony 7/91 Initial version TESCRIPTION: This file source code for the TEdit application. This code will be assembled by ESP, and then linked by the GLUE linker to produce a runnable .geo application file. IMPORTANT NOTE: This sample application is primarily intended to demonstrate a model for handling documents. Basic parts of a PC/GEOS application are not documented heavily here. See the "Hello" sample application for more detailed documentation on the standard parts of a PC/GEOS application. RCS STAMP: $Id: tedit.asm,v 1.2 98/02/15 19:57:52 gene Exp $ ------------------------------------------------------------------------------@ ;------------------------------------------------------------------------------ ; Include files ;------------------------------------------------------------------------------ include geos.def include heap.def include geode.def include resource.def include ec.def include assert.def include vm.def include object.def include graphics.def include gstring.def ;------------------------------------------------------------------------------ ; Libraries used ;------------------------------------------------------------------------------ UseLib ui.def UseLib spool.def UseLib Objects/vTextC.def UseLib Objects/vLTextC.def UseLib Objects/Text/tCtrlC.def UseLib spell.def include Internal/prodFeatures.def ; ; Add mailbox support for all but PIZZA systems and PENELOPE. ; if FAX_SUPPORT UseLib Internal/spoolInt.def UseLib mailbox.def include Mailbox/vmtree.def include Mailbox/spooltd.def include Mailbox/faxsendtd.def include initfile.def endif ;------------------------------------------------------------------------------ ; Class & Method Definitions ;------------------------------------------------------------------------------ TEProcessClass class GenProcessClass TEProcessClass endc idata segment TEProcessClass mask CLASSF_NEVER_SAVED idata ends ;---------------------- ; TEDocument class is our subclass of GenDocument that we use to add ; behavior to the GenDocument TEDocumentClass class GenDocumentClass TEDocumentClass endc idata segment TEDocumentClass idata ends ;---------------------- ; TELargeTextClass adds some functionality for pasting non-dos characters ; into the SBCS version of TEdit. TELargeTextClass class VisLargeTextClass TELargeTextClass endc idata segment TELargeTextClass idata ends ifdef EXCELSIOR include eqeditDialog.def endif ;---------------------- if FAX_SUPPORT ; TEPrintControlClass adds some functionality for detecting if the print ; destination is to a fax printer, so the font can be made more legible. TEMailboxPrintControlClass class PrintControlClass MSG_TEMPC_CHECK_FOR_FAX message ; ; Checks the destination of a print job to see if the destination print ; driver is a fax print driver. ; ; Pass: nothing ; ; Return: ax - TRUE if the destination is a fax print driver ; - FALSE if the destination is not a fax print ; driver, or if there is no way to tell. ; TEMailboxPrintControlClass endc idata segment TEMailboxPrintControlClass idata ends endif ; FAX_SUPPORT ;------------------------------------------------------------------------------ ; Constants and structures ;------------------------------------------------------------------------------ READ_WRITE_BLOCK_SIZE equ 4000 BAD_OFFSET_IN_TRANSFER_TEXT_HUGE_ARRAY enum FatalErrors EXPECTED_ELEMENT_SIZE_OF_ONE_IN_TEXT_HUGE_ARRAY enum FatalErrors if DBCS_PCGEOS UNEXPECTED_BYTE_OFFSET_FROM_LOCAL_DOS_TO_GEOS enum FatalErrors ; LocalDosToGeos() returned a byte offset other than 1 when using the ; SJIS code page. Since SJIS is only 1 and 2 byte codes, the byte ; offset should only ever be 1. endif ;------------------------------------------------------------------------------ ; Variables ;------------------------------------------------------------------------------ udata segment defaultPointSize word ; default point size for next document udata ends ;------------------------------------------------------------------------------ ; Resources ;------------------------------------------------------------------------------ include tedit.rdef ;include compiled UI definitions ;------------------------------------------------------------------------------ ; Code for TEDocumentClass ;------------------------------------------------------------------------------ CommonCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEOpenApplication %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Open the TextEdit application CALLED BY: UI (MSG_GEN_PROCESS_OPEN_APPLICATION) PASS: AX = Method CX = AppAttachFlags DX = Handle to AppLaunchBlock BP = Block handle DS, ES = DGroup RETURN: Nothing DESTROYED: AX, BX, CX, DX, SI, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TEOpenApplication method TEProcessClass, MSG_GEN_PROCESS_OPEN_APPLICATION .enter ; Call our superclass ; push cx mov di, offset TEProcessClass ; class of SuperClass we call call ObjCallSuperNoLock ; Add process to point-size notification ; mov ax, MSG_META_GCN_LIST_ADD mov cx, GAGCNLT_APP_TARGET_NOTIFY_TEXT_CHAR_ATTR_CHANGE call TESendToAppGCNList ; Set the default point size, unless we are restoring from state ; pop cx ; ; even if restoring from state, set point size if none set yet. ; GWNT_TEXT_CHAR_ATTR_CHANGE will come in and overwrite our value, ; if it wants - brianc 5/3/94 ; tst ds:[defaultPointSize] jz setPointSize test cx, mask AAF_RESTORING_FROM_STATE jnz exit setPointSize: call UserGetDefaultMonikerFont ; default point size => DX mov ax, 9 cmp dx, 10 jle storePointSize mov ax, 12 cmp dx, 13 jle storePointSize SBCS < mov ax, 14 > DBCS < mov ax, 16 > storePointSize: mov ds:[defaultPointSize], ax exit: .leave ret TEOpenApplication endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TECloseApplication %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Close the TextEdit application CALLED BY: UI (MSG_GEN_PROCESS_CLOSE_APPLICATION) PASS: Nothing RETURN: CX = Handle of extra block to save to state DESTROYED: AX, BX, DX, SI, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TECloseApplication method TEProcessClass, MSG_GEN_PROCESS_CLOSE_APPLICATION .enter ; Remove process from point-size notification ; mov ax, MSG_META_GCN_LIST_REMOVE mov cx, GAGCNLT_APP_TARGET_NOTIFY_TEXT_CHAR_ATTR_CHANGE call TESendToAppGCNList clr cx ; no extra state block .leave ret TECloseApplication endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TESendToAppGCNList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sends an add or remove message to the application object's GCN list CALLED BY: INTERNAL PASS: AX = Message to send CX = GCN list to work with RETURN: BX:SI = Application object's OD DESTROYED: AX, DX, BP, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 11/ 1/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TESendToAppGCNList proc near .enter mov dx, size GCNListParams sub sp, dx mov bp, sp ; GCNListParams => SS:BP call GeodeGetProcessHandle ; process handle => BX mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS mov ss:[bp].GCNLP_ID.GCNLT_type, cx mov ss:[bp].GCNLP_optr.handle, bx clr ss:[bp].GCNLP_optr.chunk clr bx ; get this geode's application call GeodeGetAppObject ; ... object OD => BX:SI mov di, mask MF_STACK call ObjMessage ; send it!! add sp, dx ; clean up the stack .leave ret TESendToAppGCNList endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TENotifyWithDataBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Notify the process that some change has occurred on a GCN list. CALLED BY: GLOBAL (MSG_META_NOTIFY_WITH_DATA_BLOCK) PASS: DS, ES = DGroup CX:DX = NotificationType BP = Data block handle RETURN: Nothing DESTROYED: AX, CX, DX, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 11/ 1/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TENotifyWithDataBlock method dynamic TEProcessClass, MSG_META_NOTIFY_WITH_DATA_BLOCK ; See if this is one we are interested in ; tst bp jz callSuper ; no data, so we're done cmp cx, MANUFACTURER_ID_GEOWORKS jne callSuper cmp dx, GWNT_TEXT_CHAR_ATTR_CHANGE jne callSuper ; Access the new point size, and store it away ; push ax, es mov bx, bp call MemLock mov es, ax ;VisTextNotifyCharAttrChange->ES mov ax, es:[VTNCAC_charAttr.VTCA_pointSize.WBF_int] mov ds:[defaultPointSize], ax call MemUnlock pop ax, es ; Now call our superclass callSuper: mov di, offset TEProcessClass GOTO ObjCallSuperNoLock TENotifyWithDataBlock endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentAttach -- MSG_META_ATTACH for TEDocumentClass DESCRIPTION: ... PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/27/93 Initial version ------------------------------------------------------------------------------@ TEDocumentAttach method dynamic TEDocumentClass, MSG_META_ATTACH ; Set up the VM file (so that we always have it) push si mov bx, ds:[di].GDI_display mov si, offset TETextEdit ;bxsi = text object push bx call ClipboardGetClipboardFile mov cx, bx pop bx mov ax, MSG_VIS_TEXT_SET_VM_FILE mov di, mask MF_FIXUP_DS call ObjMessage pop si mov ax, MSG_META_ATTACH mov di, offset TEDocumentClass GOTO ObjCallSuperNoLock TEDocumentAttach endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentPhysicalSave -- MSG_GEN_DOCUMENT_PHYSICAL_SAVE for TEDocumentClass DESCRIPTION: ... PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: carry - set if error ax - error code (if any) TESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO COTE/STRATEGY: KNOWN BUGS/SITE EFFECTS/CAVEATS/ITEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 7/30/92 Initial version ------------------------------------------------------------------------------@ TEDocumentPhysicalSave method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_PHYSICAL_SAVE ; Save the data in the file mov bx, ds:[di].GDI_fileHandle ;save file handle call WriteDataToFile ret TEDocumentPhysicalSave endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentPhysicalSaveAsFileHandle -- MSG_GEN_DOCUMENT_PHYSICAL_SAVE_AS_FILE_HANDLE for TEDocumentClass TESCRIPTION: Write the document data to a new file handle PASS: *ds:si - instance data (GDI_fileHandle is *old* file handle) es - segment of TEDocumentClass ax - The message cx - new file handle RETURN: carry - set if error ax - error code TESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO COTE/STRATEGY: KNOWN BUGS/SITE EFFECTS/CAVEATS/ITEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 8/25/92 Initial version ------------------------------------------------------------------------------@ TEDocumentPhysicalSaveAsFileHandle method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_PHYSICAL_SAVE_AS_FILE_HANDLE mov bx, cx call WriteDataToFile ret TEDocumentPhysicalSaveAsFileHandle endm COMMENT @---------------------------------------------------------------------- FUNCTION: WriteDataToFile TESCRIPTION: Write the data to the document file CALLED BY: INTERNAL PASS: *ds:si - document object bx - file handle RETURN: carry - set if error ax - error code DESTROYED: cx, dx, di REGISTER/STACK USAGE: PSEUDO COTE/STRATEGY: KNOWN BUGS/SITE EFFECTS/CAVEATS/ITEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 8/25/92 Initial version dloft 4/25/93 added bufferHandle checks ------------------------------------------------------------------------------@ WriteDataToFile proc near uses si file local hptr push bx bufferHandle local hptr textHandle local hptr blockSize local word range local VisTextRange params local VisTextGetTextRangeParameters class TEDocumentClass .enter ; clear bufferHandle so we can tell later if we've allocated one clr ss:[bufferHandle] ; get the file and position at the beginning of it mov di, ds:[si] add di, ds:[di].Gen_offset mov ax, ds:[di].GDI_display mov textHandle, ax tst ax LONG jz exit clrdw cxdx clr ax call FileTruncate LONG jc doneError ; get text size (into range.VTR_end) push bp clrdw range.VTR_start movdw range.VTR_end, TEXT_ADDRESS_PAST_END mov ax, MSG_VIS_TEXT_GET_RANGE clr cx ;no context mov dx, ss mov bx, textHandle mov si, offset TETextEdit clr di lea bp, range call ObjMessage pop bp mov ax, READ_WRITE_BLOCK_SIZE mov cx, ALLOC_DYNAMIC_NO_ERR_LOCK call MemAlloc ;allocate a buffer to read into mov bufferHandle, bx mov ds, ax ;ds = buffer writeLoop: ; get a chunk of text movdw dxax, range.VTR_end movdw cxbx, range.VTR_start cmpdw dxax, cxbx LONG jz doneNoError movdw params.VTGTRP_range.VTR_start, cxbx subdw dxax, cxbx SBCS < cmpdw dxax, READ_WRITE_BLOCK_SIZE/2 > DBCS < cmpdw dxax, (READ_WRITE_BLOCK_SIZE/4)-1 > ; allow for CR-LF expansion jbe gotSize SBCS < movdw dxax, READ_WRITE_BLOCK_SIZE/2 > DBCS < movdw dxax, (READ_WRITE_BLOCK_SIZE/4)-1 > gotSize: mov blockSize, ax adddw dxax, cxbx movdw params.VTGTRP_range.VTR_end, dxax movdw range.VTR_start, dxax clr ax movdw params.VTGTRP_textReference.TR_type, TRT_POINTER movdw params.VTGTRP_textReference.TR_ref.TRU_pointer.TRP_pointer, dsax mov params.VTGTRP_flags, al push bp mov ax, MSG_VIS_TEXT_GET_TEXT_RANGE mov bx, textHandle mov si, offset TETextEdit clr di lea bp, params call ObjMessage pop bp mov cx, blockSize cmpdw range.VTR_start, range.VTR_end, ax clc jnz gotFlag stc gotFlag: call ConvertBufferToDos clr dx clr ax ;allow errors mov bx, file call FileWrite jc doneError jmp writeLoop doneError: mov ax, offset FileWriteErrorString call DisplayErrorDialog stc jmp done doneNoError: mov ax, MSG_VIS_TEXT_SET_NOT_USER_MODIFIED mov bx, textHandle mov si, offset TETextEdit clr di call ObjMessage clc done: pushf mov bx, bufferHandle tst bx ; if we've not allocated a jz noFree ; buffer, don't free it! call MemFree noFree: popf jc exit clr al mov bx, file call FileCommit exit: .leave ret WriteDataToFile endp COMMENT @---------------------------------------------------------------------- FUNCTION: ConvertBufferToDos DESCRIPTION: Convert a buffer from GEOS to DOS CALLED BY: INTERNAL PASS: ds:0 - buffer SBCS: cx - size DBCS: cx - # of chars carry - set if this is the last block RETURN: cx - new size DESTROYED: ax, bx, dx, si, di, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: NOTE: The DBCS version has been changed to do all its character manipulation before converting to the DOS character set, since the size of a DOS character is unknown. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 8/92 Initial version ------------------------------------------------------------------------------@ ConvertBufferToDos proc near pushf if DBCS_PCGEOS ; ; move data to end of block ; segmov es, ds push cx mov di, READ_WRITE_BLOCK_SIZE/2 clr si rep movsw pop cx ; ; Replace all CRs with CR/LF. ; mov si, READ_WRITE_BLOCK_SIZE/2 ;ds:si <- source clr di ;es:di <- dest fooLoop: LocalGetChar ax, dssi ;get char LocalCmpChar ax, C_CR ;see if <CR> jnz store ;branch if not LocalPutChar esdi, ax LocalLoadChar ax, C_LF store: LocalPutChar esdi, ax loop fooLoop ;loop while more bytes ; ; if this is the last block make sure that it ends in a CR-LF ; popf jnc notLast ;branch if not last block cmp {wchar} es:[di-2], C_LF je notLast LocalLoadChar ax, C_CR LocalPutChar esdi, ax LocalLoadChar ax, C_LF LocalPutChar esdi, ax notLast: shr di, 1 mov cx, di ;cx <- new length ; ; move data to end of block (move backwards to deal with overlap) ; push cx mov di, READ_WRITE_BLOCK_SIZE dec di dec di ;es:di = last char of dest mov si, cx ;ds:si = last char of source dec si shl si, 1 std ;move backwards rep movsw cld ;forwards again pop cx mov si, READ_WRITE_BLOCK_SIZE sub si, cx sub si, cx ;ds:si <- source for convert endif ; ; convert to the DOS character set, replacing all unknown characters ; with '_' (this should never happen) SBCS < clr si > DBCS < clr di ;es:di <- dest > mov ax, '_' ;replacement character DBCS < clr bx, dx ;bx <- cur code page, disk> call LocalGeosToDos if not DBCS_PCGEOS ; move the data to the end of the block segmov es, ds ;es:di <- dest ptr push cx mov di, READ_WRITE_BLOCK_SIZE/2 rep movsb pop cx mov si, READ_WRITE_BLOCK_SIZE/2 ;source clr di ;dest fooLoop: lodsb ;get byte cmp al, C_CR ;see if <LF> jnz store ;add linefeeds stosb mov al, C_LF store: stosb ;else store byte loop fooLoop ;loop while more bytes ; if this is the last block make sure that it ends in a CR-LF popf jnc done cmp {char} es:[di-1], C_LF jz done mov al, C_CR stosb mov al, C_LF stosb done: mov cx, di ;return new size endif ret ConvertBufferToDos endp COMMENT @---------------------------------------------------------------------- FUNCTION: ReadDataFromFile DESCRIPTION: Read the data from the document file CALLED BY: INTERNAL PASS: *ds:si - document object RETURN: none DESTROYED: ax, bx, cx, dx, di REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 8/92 Initial version ------------------------------------------------------------------------------@ ReadDataFromFile proc near uses si documentObj local optr push ds:[LMBH_handle], si file local hptr bufferHandle local hptr textHandle local hptr textSize local dword modifiedFlag local word class TEDocumentClass .enter mov modifiedFlag, 0 movdw textSize, 0 ; get the file and position at the beginning of it mov di, ds:[si] add di, ds:[di].Gen_offset mov ax, ds:[di].GDI_display mov textHandle, ax mov bx, ds:[di].GDI_fileHandle mov file, bx clrdw cxdx mov al, FILE_POS_START call FilePos mov cx, 1 ;flush actions mov ax, MSG_GEN_PROCESS_UNDO_IGNORE_ACTIONS call sendToProcess mov ax, MSG_META_SUSPEND call sendToTextObject mov ax, MSG_VIS_TEXT_DELETE_ALL call sendToTextObject mov ax, READ_WRITE_BLOCK_SIZE mov cx, ALLOC_DYNAMIC_NO_ERR_LOCK call MemAlloc ;allocate a buffer to read into mov bufferHandle, bx mov ds, ax ;ds = buffer mov al, FILE_POS_START mov bx, file clrdw cxdx call FilePos readLoop: ; Read in the data from the document mov bx, file SBCS < clr dx > DBCS < mov dx, READ_WRITE_BLOCK_SIZE/2 > SBCS < mov cx, READ_WRITE_BLOCK_SIZE > DBCS < mov cx, READ_WRITE_BLOCK_SIZE/2 > clr ax ;allow errors call FileRead jnc readOK cmp ax, ERROR_SHORT_READ_WRITE jnz errorDone readOK: jcxz done call ConvertBufferToGeos ;cx <- string length or modifiedFlag, dx jcxz readLoop add textSize.low, cx ;add buffer size to adc textSize.high, 0 ; cumulative textSize ; append the data to the text object mov ax, MSG_VIS_TEXT_APPEND_BLOCK mov dx, bufferHandle call sendToTextObject mov ax, MSG_VIS_TEXT_GET_TEXT_SIZE mov di, mask MF_CALL mov bx, textHandle call sendToTextObjectLow ;dx.ax <- text size cmpdw dxax, textSize je readLoop mov ax, offset FileTooBigString jmp displayError errorDone: mov ax, offset FileReadErrorString jmp displayError done: tst modifiedFlag jz afterModified mov ax, offset CharactersFilteredString displayError: movdw bxsi, documentObj call MemDerefDS call DisplayErrorDialog afterModified: mov bx, bufferHandle call MemFree mov ax, MSG_VIS_TEXT_SELECT_START call sendToTextObject ; Change to the default point size mov ax, MSG_VIS_TEXT_SET_USER_MODIFIED call sendToTextObject mov cx, es:[defaultPointSize] push bp mov bx, textHandle mov dx, size VisTextSetPointSizeParams sub sp, dx mov bp, sp clr ax clrwwf ss:[bp].VTSPSP_range.VTR_start, ax movwwf ss:[bp].VTSPSP_range.VTR_end, TEXT_ADDRESS_PAST_END movwwf ss:[bp].VTSPSP_pointSize, cxax mov ax, MSG_VIS_TEXT_SET_POINT_SIZE mov di, mask MF_CALL or mask MF_STACK call sendToTextObjectLow add sp, size VisTextSetPointSizeParams pop bp mov ax, MSG_VIS_TEXT_SET_NOT_USER_MODIFIED call sendToTextObject ; clear modified bit, so ; actual changes later ; will enable SAVE trigger mov ax, MSG_META_UNSUSPEND call sendToTextObject mov ax, MSG_GEN_PROCESS_UNDO_ACCEPT_ACTIONS call sendToProcess .leave ret ;--- sendToTextObject: mov bx, textHandle clr di sendToTextObjectLow: mov si, offset TETextEdit call ObjMessage retn ;--- sendToProcess: clr bx call GeodeGetProcessHandle clr di call ObjMessage retn ReadDataFromFile endp COMMENT @---------------------------------------------------------------------- FUNCTION: ConvertBufferToGeos DESCRIPTION: Convert a buffer from DOS to GEOS CALLED BY: INTERNAL PASS: DBCS: ds:READ_WRITE_BLOCK_SIZE/2 - buffer bx - file handle SBCS: ds:0 - buffer cx - size RETURN: DBCS: cx - new length SBCS: cx - new size dx - non-zero if buffer was changed (control characters removed) DESTROYED: ax, bx, dx, si, di, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 8/92 Initial version ------------------------------------------------------------------------------@ ConvertBufferToGeos proc near uses es .enter ; convert to the GEOS character set, replacing all unknown characters ; with C_CTRL_A DBCS < push bx ;save file handle > SBCS < clr si > DBCS < segmov es, ds > DBCS < clr di ;es:di <- dest ptr > DBCS < mov si, READ_WRITE_BLOCK_SIZE/2 ;ds:si <- source buffer > mov ax, C_CTRL_A ;replacement character DBCS < clr bx, dx ;bx <- cur code page, disk> call LocalDosToGeos DBCS < pop bx ;bx <- file handle > if DBCS_PCGEOS ; ; In multi-byte versions of DOS, it is possible we split the ; last character. If so, adjust the file pointer back ; so we re-read the correct # of bytes. Not particularly ; efficient but easier than adjusting ptrs, buffer sizes, etc. ; cmp al, DTGSS_CHARACTER_INCOMPLETE ;split character? jne noAdjust ;branch if not EC < cmp ah, 1 ;has to be 1 > EC < ERROR_NE UNEXPECTED_BYTE_OFFSET_FROM_LOCAL_DOS_TO_GEOS > push cx ;save # of chars clrdw cxdx mov dl, ah ;# of bytes to backup negdw cxdx mov al, FILE_POS_RELATIVE ;al <- FilePosMode call FilePos pop cx ;cx <- # of chars noAdjust: endif SBCS < clr di > DBCS < clr si > clr dx ;modified flag SBCS < segmov es, ds ;es:di <- dest ptr > jcxz doneChars fooLoop: LocalGetChar ax, dssi ;get char LocalCmpChar ax, C_CTRL_Z ;skip Ctrl-Z, but don't warn jnz notCtrlZ ;the user if at the end of the cmp cx, 1 ;file since DOS programs jz skip ;often do this jmp skipAndMark notCtrlZ: LocalCmpChar ax, C_PAGE_BREAK ;allow page-breaks je store LocalCmpChar ax, C_LF ;see if <LF> je skip ;ignore linefeeds LocalCmpChar ax, C_TAB jz store LocalCmpChar ax, C_CR jz store LocalCmpChar ax, ' ' jb skipAndMark store: LocalPutChar esdi, ax ;else store character jmp skip skipAndMark: inc dx skip: loop fooLoop ;loop while more bytes doneChars: mov cx, di ;return new size DBCS < shr cx, 1 ;cx <- new length > .leave ret ConvertBufferToGeos endp COMMENT @---------------------------------------------------------------------- FUNCTION: DisplayErrorDialog DESCRIPTION: Display an error dialog CALLED BY: INTERNAL PASS: *ds:si - document object ax - offset of string (in StringsUI) RETURN: none DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/10/92 Initial version ------------------------------------------------------------------------------@ DisplayErrorDialog proc near uses ax, bx, cx, di, bp, es class TEDocumentClass .enter clr di pushdw didi ;SDP_helpContext mov di, ds:[si] add di, ds:[di].Gen_offset lea cx, ds:[di].GDI_fileName ;dscx = name mov_tr bp, ax ;bp = string GetResourceHandleNS StringsUI, bx call MemLock mov di, ax mov es, ax mov bp, es:[bp] ;di:bp = string .assert (offset SDP_customTriggers eq offset SDP_stringArg2+4) pushdw axax ; don't care about SDP_customTriggers .assert (offset SDP_stringArg2 eq offset SDP_stringArg1+4) pushdw axax ; don't care about SDP_stringArg2 .assert (offset SDP_stringArg1 eq offset SDP_customString+4) pushdw dscx ; save SDP_stringArg1 (document name) .assert (offset SDP_stringArg1 eq offset SDP_customString+4) pushdw dibp ; save SDP_customString (di:bp) .assert (offset SDP_customString eq offset SDP_customFlags+2) .assert (offset SDP_customFlags eq 0) mov ax, CustomDialogBoxFlags \ <FALSE, CDT_NOTIFICATION, GIT_NOTIFICATION,0> push ax call UserStandardDialog call MemUnlock .leave ret DisplayErrorDialog endp COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentCreateUIForDocument -- MSG_GEN_DOCUMENT_CREATE_UI_FOR_DOCUMENT for TEDocumentClass DESCRIPTION: Create the UI used to display the document (the text object) PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 8/92 Initial version ------------------------------------------------------------------------------@ TEDocumentCreateUIForDocument method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_CREATE_UI_FOR_DOCUMENT mov di, offset TEDocumentClass call ObjCallSuperNoLock push si mov di, ds:[si] add di, ds:[di].Gen_offset mov bx, ds:[di].GDI_display mov si, offset TETextEdit ;bxsi = text object ; We need a VM file -- use the clipboard push bx call ClipboardGetClipboardFile mov cx, bx pop bx ; Make the text object large mov ax, MSG_VIS_TEXT_SET_VM_FILE mov di, mask MF_FIXUP_DS call ObjMessage mov ax, MSG_VIS_LARGE_TEXT_CREATE_DATA_STRUCTURES mov di, mask MF_FIXUP_DS call ObjMessage mov ax, MSG_VIS_NOTIFY_GEOMETRY_VALID mov di, mask MF_FIXUP_DS call ObjMessage pop si call ReadDataFromFile ret TEDocumentCreateUIForDocument endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentAttachUIToDocument -- MSG_GEN_DOCUMENT_ATTACH_UI_TO_DOCUMENT for TEDocumentClass DESCRIPTION: Attach the UI used to display the document (the text object) into the visual tree PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 8/92 Initial version ------------------------------------------------------------------------------@ TEDocumentAttachUIToDocument method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_ATTACH_UI_TO_DOCUMENT mov di, offset TEDocumentClass call ObjCallSuperNoLock mov di, ds:[si] add di, ds:[di].Gen_offset mov cx, ds:[di].GDI_display mov dx, offset TETextEdit ;cxdx = text object ; add the object as a child pushdw cxdx ;save text object mov ax, MSG_VIS_ADD_CHILD clr bp call ObjCallInstanceNoLock popdw bxsi ;bxsi = text object ; We need a VM file -- use the clipboard push bx call ClipboardGetClipboardFile mov cx, bx pop bx mov ax, MSG_VIS_TEXT_SET_VM_FILE mov di, mask MF_FIXUP_DS call ObjMessage mov ax, MSG_META_GRAB_TARGET_EXCL mov di, mask MF_FIXUP_DS call ObjMessage mov ax, MSG_META_GRAB_FOCUS_EXCL mov di, mask MF_FIXUP_DS call ObjMessage ret TEDocumentAttachUIToDocument endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentDetachUIFromDocument -- MSG_GEN_DOCUMENT_DETACH_UI_FROM_DOCUMENT for TEDocumentClass DESCRIPTION: Detach the UI for the document from the visual world PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 3/92 Initial version ------------------------------------------------------------------------------@ TEDocumentDetachUIFromDocument method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_DETACH_UI_FROM_DOCUMENT ; remove the object as a child push si mov bx, ds:[di].GDI_display mov si, offset TETextEdit ;bxsi = text object mov ax, MSG_VIS_REMOVE mov dl, VUM_NOW mov di, mask MF_FIXUP_DS call ObjMessage pop si mov ax, MSG_GEN_DOCUMENT_DETACH_UI_FROM_DOCUMENT mov di, offset TEDocumentClass GOTO ObjCallSuperNoLock TEDocumentDetachUIFromDocument endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentDestroyUIForDocument -- MSG_GEN_DOCUMENT_DESTROY_UI_FOR_DOCUMENT for TEDocumentClass DESCRIPTION: Destroy the UI for the document PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/ 3/92 Initial version ------------------------------------------------------------------------------@ TEDocumentDestroyUIForDocument method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_DESTROY_UI_FOR_DOCUMENT push si mov bx, ds:[di].GDI_display mov si, offset TETextEdit ;bxsi = text object mov ax, MSG_VIS_TEXT_FREE_ALL_STORAGE mov cx, TRUE ;cx <- destroy elements, too mov di, mask MF_FORCE_QUEUE call ObjMessage pop si mov ax, MSG_GEN_DOCUMENT_DESTROY_UI_FOR_DOCUMENT mov di, offset TEDocumentClass GOTO ObjCallSuperNoLock TEDocumentDestroyUIForDocument endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentFileChangedReinitializeCreatedUI -- MSG_GEN_DOCUMENT_FILE_CHANGED_REINITIALIZE_CREATED_UI for TEDocumentClass DESCRIPTION: Revert PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 12/ 9/92 Initial version ------------------------------------------------------------------------------@ TEDocumentFileChangedReinitializeCreatedUI method dynamic TEDocumentClass, MSG_GEN_DOCUMENT_FILE_CHANGED_REINITIALIZE_CREATED_UI call ReadDataFromFile ret TEDocumentFileChangedReinitializeCreatedUI endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentStartPrinting -- MSG_PRINT_START_PRINTING for TEDocumentClass DESCRIPTION: Start printing PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message cx:dx - spool print control bp - gstate RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/10/92 Initial version JDM 93.02.15 push-/pob-wbf modifications. ------------------------------------------------------------------------------@ TEDocumentStartPrinting method dynamic TEDocumentClass, MSG_PRINT_START_PRINTING gstate local hptr push bp displayHandle local hptr push ds:[di].GDI_display leftMargin local word topMargin local word horizMargins local word vertMargins local word oldSize local XYSize newSize local XYSize counter local word regionNum local word ;;;tmatrix local TransMatrix getParams local VisTextGetAttrParams charAttr local VisTextCharAttr diffs local VisTextCharAttrDiffs setParams local VisTextSetCharAttrParams userModified local word NPZ <ifFax local word > .enter push ax, cx, dx, bp mov ax, MSG_GEN_APPLICATION_MARK_BUSY call UserCallApplication pop ax, cx, dx, bp if FAX_SUPPORT ; ; If this is a fax, change the font to something readable. URW_MONO is ; too thin to make out. ; mov ax, MSG_TEMPC_CHECK_FOR_FAX call callSpoolPrintControl ; ax <- TRUE if this is a fax mov ss:[ifFax], ax endif ;FAX_SUPPORT ; Get the margins the printer is using push bp mov ax, MSG_PRINT_CONTROL_GET_PRINTER_MARGINS mov dx, TRUE ; set the margins too call callSpoolPrintControl ; margins => AX, CX, DX, BP mov di, bp pop bp mov leftMargin, ax mov topMargin, cx add dx, ax add di, cx mov horizMargins, dx mov vertMargins, di ; Get and set the paper size the user has selected push bp mov ax, MSG_PRINT_CONTROL_GET_PAPER_SIZE call callSpoolPrintControl ; paper dimmensions => CX, DX push cx, dx mov ax, MSG_PRINT_CONTROL_SET_DOC_SIZE call callSpoolPrintControl pop cx, dx pop bp sub cx, horizMargins sub dx, vertMargins mov newSize.XYS_width, cx mov newSize.XYS_height, dx ; get the user modified state of text object, then mark it as user ; modified so that we don't bogusly mark the document as dirty mov ax, MSG_VIS_TEXT_GET_USER_MODIFIED_STATE call callTextObject ;cx = user modified state mov userModified, cx mov ax, MSG_VIS_TEXT_SET_USER_MODIFIED call callTextObject ; change the font and point size to MONO 12 mov ax, MSG_META_SUSPEND call callTextObject lea ax, charAttr movdw getParams.VTGAP_attr, ssax lea ax, diffs movdw getParams.VTGAP_return, ssax clr getParams.VTGAP_flags mov ax, MSG_VIS_TEXT_GET_CHAR_ATTR lea bx, getParams mov dx, size getParams call callTextObject push charAttr.VTCA_fontID mov al, charAttr.VTCA_textStyles push ax ; save text styles pushwbf charAttr.VTCA_pointSize, ax NPZ < mov charAttr.VTCA_fontID, FID_DTC_URW_MONO > PZ < mov charAttr.VTCA_fontID, FID_BITSTREAM_KANJI_HON_MINCHO > mov charAttr.VTCA_pointSize.WBF_int, 12 mov charAttr.VTCA_pointSize.WBF_frac, 0 if FAX_SUPPORT CheckHack <FALSE eq 0> tst ss:[ifFax] jz setAttrs ; It's a fax. Make the characters legible. ornf charAttr.VTCA_textStyles, mask TS_BOLD setAttrs: endif lea ax, charAttr movdw setParams.VTSCAP_charAttr, ssax mov ax, MSG_VIS_TEXT_SET_CHAR_ATTR lea bx, setParams mov dx, size setParams call callTextObject popwbf charAttr.VTCA_pointSize, ax pop ax ; al <- styles mov charAttr.VTCA_textStyles, al pop charAttr.VTCA_fontID ; change the page size of the text object mov ax, MSG_VIS_LARGE_TEXT_GET_DRAFT_REGION_SIZE call callTextObject mov oldSize.XYS_width, cx mov oldSize.XYS_height, dx mov cx, newSize.XYS_width mov dx, newSize.XYS_height mov ax, MSG_VIS_LARGE_TEXT_SET_DRAFT_REGION_SIZE call callTextObject mov ax, MSG_META_UNSUSPEND call callTextObject ; now loop through printing the regions mov ax, MSG_VIS_LARGE_TEXT_GET_REGION_COUNT call callTextObject ;cx = count mov counter, cx clr regionNum ; tell the PrintControl how many pages we have to print push bp mov dx, cx mov cx, 1 mov ax, MSG_PRINT_CONTROL_SET_TOTAL_PAGE_RANGE call callSpoolPrintControl pop bp ; We use the default translation matrix as the text object ; applies additional transformations to it. Each loop: ; 1) Assume the default transform is correct ; 2) Return to the top of the page ; 3) Re-position for the next page ; 4) Re-initialize the default transformation ; 5) Account for margins printLoop: mov di, gstate call GrSaveState ;;; call GrSetDefaultTransform ;;; segmov ds, ss ;;; lea si, tmatrix ;;; call GrGetTransform ;;; movdw dxcx, ds:[si].TM_e31.DWF_int ;;; movdw bxax, ds:[si].TM_e32.DWF_int ;;; negdw dxcx ;dxcx = x translation ;;; negdw bxax ;bxax = y translation ;;; call GrApplyTranslationDWord ; Get this page's position mov ax, MSG_VIS_LARGE_TEXT_GET_REGION_POS mov cx, regionNum call callTextObject ;dxax = pos, cx = height pushdw dxax ;save y pos ; Set a clip rectangle so that all of the text in the ; document will not be drawn into the spool file (for this page) mov dx, cx ;dx = height mov ax, leftMargin mov bx, topMargin mov cx, newSize.XYS_width add cx, ax add dx, bx ; ; adjust bottom of clip rect to fix problem where top pixel of next ; line (on next page) appears on this page ; PZ < dec dx > mov si, PCT_REPLACE call GrSetClipRect ; Translate to the location of the page (including the margins) popdw bxax ;bxax = y pos negdw bxax add ax, topMargin adc bx, 0 clr dx mov cx, leftMargin ;dxcx = x pos call GrApplyTranslationDWord call GrInitDefaultTransform ; Now actually print mov ax, MSG_VIS_DRAW mov cl, mask DF_EXPOSED or mask DF_PRINT mov bx, di ;bx = GState (passed in BP) call callTextObject ; Must be present at the end of each page mov di, gstate call GrRestoreState mov al, PEC_FORM_FEED call GrNewPage inc regionNum dec counter LONG jnz printLoop ; Tell the PrintControl object that we're done push bp mov ax, MSG_PRINT_CONTROL_PRINTING_COMPLETED call callSpoolPrintControl pop bp mov ax, MSG_META_SUSPEND call callTextObject lea ax, charAttr movdw setParams.VTSCAP_charAttr, ssax mov ax, MSG_VIS_TEXT_SET_CHAR_ATTR lea bx, setParams mov dx, size setParams call callTextObject mov cx, oldSize.XYS_width mov dx, oldSize.XYS_height mov ax, MSG_VIS_LARGE_TEXT_SET_DRAFT_REGION_SIZE call callTextObject mov ax, MSG_META_UNSUSPEND call callTextObject tst userModified jnz afterUserModified mov ax, MSG_VIS_TEXT_SET_NOT_USER_MODIFIED call callTextObject afterUserModified: clr bx call GeodeGetAppObject mov di, mask MF_FORCE_QUEUE mov ax, MSG_GEN_APPLICATION_MARK_NOT_BUSY call ObjMessage .leave ret ;--- callSpoolPrintControl: push bx, si, di GetResourceHandleNS TEPrintControl, bx mov si, offset TEPrintControl mov di, mask MF_CALL call ObjMessage pop bx, si, di retn ;--- ; bx - value to pass in bp callTextObject: push bx, si, di, bp push bx mov bx, displayHandle mov si, offset TETextEdit mov di, mask MF_CALL pop bp call ObjMessage pop bx, si, di, bp retn TEDocumentStartPrinting endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEDocumentSetPointSize -- MSG_VIS_TEXT_SET_POINT_SIZE for TEDocumentClass DESCRIPTION: Set the point size PASS: *ds:si - instance data es - segment of TEDocumentClass ax - The message ss:bp - VisTextSetPointSizeParams RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 12/18/92 Initial version ------------------------------------------------------------------------------@ TEDocumentSetPointSize method dynamic TEDocumentClass, MSG_VIS_TEXT_SET_POINT_SIZE ; get the user modified state of text object, then mark it as user ; modified so that we don't bogusly mark the document as dirty mov ax, MSG_VIS_TEXT_GET_USER_MODIFIED_STATE call callTextObject ;cx = user modified state push cx mov ax, MSG_VIS_TEXT_SET_USER_MODIFIED call callTextObject mov ax, MSG_VIS_TEXT_SET_POINT_SIZE mov dx, size VisTextSetPointSizeParams call callTextObject pop cx tst cx jnz afterUserModified mov ax, MSG_VIS_TEXT_SET_NOT_USER_MODIFIED call callTextObject afterUserModified: ret ;--- ; bx - value to pass in bp callTextObject: push si, bp mov di, ds:[si] add di, ds:[di].Gen_offset mov bx, ds:[di].GDI_display mov si, offset TETextEdit mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop si, bp retn TEDocumentSetPointSize endm COMMENT @---------------------------------------------------------------------- MESSAGE: TEProcessTextUserModified -- MSG_META_TEXT_USER_MODIFIED for TEProcessClass DESCRIPTION: Notification that the user has modified the text PASS: *ds:si - instance data es - segment of TEProcessClass ax - The message cx:dx = text object RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/10/92 Initial version ------------------------------------------------------------------------------@ TEProcessTextUserModified method dynamic TEProcessClass, MSG_META_TEXT_USER_MODIFIED ; sending a MSG_GEN_DOCUMENT_MARK_DIRTY to the MODEL does not ; always work since the MODEL might not be updated yet. Instead, ; we want to send to the document associated with this text ; object pushdw cxdx mov ax, MSG_GEN_DOCUMENT_MARK_DIRTY mov bx, segment GenDocumentClass mov si, offset GenDocumentClass mov di, mask MF_RECORD call ObjMessage ;di = message mov cx, di popdw bxsi mov ax, MSG_META_SEND_CLASSED_EVENT mov cx, di mov dx, TO_OBJ_BLOCK_OUTPUT clr di call ObjMessage ;cxdx = document ret TEProcessTextUserModified endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TELargeTextReplaceWithTextTransferFormat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Message sent when the text object is pasted to. This will essentially clean up the incoming text, making sure that all characters are legal dos characters. CALLED BY: MSG_VIS_TEXT_REPLACE_WITH_TEXT_TRANSFER_FORMAT PASS: *ds:si = TELargeTextClass object ds:di = TELargeTextClass instance data ds:bx = TELargeTextClass object (same as *ds:si) es = segment of TELargeTextClass ax = message # dx = size CommonTransferParams (if called remotely) ss:bp = CommonTransferParams structure RETURN: none DESTROYED: ax, cx, dx SIDE EFFECTS: PSEUDO CODE/STRATEGY: The text from the clipboard come in as a huge array. Thus, for each block, we lock it down, copy it into a temporary memory block, clean up that block, and have the text object insert that block into itself. REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/14/94 Initial version PT 5/26/95 Functions with QuickMove now %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not DBCS_PCGEOS TELargeTextReplaceWithTextTransferFormat method dynamic TELargeTextClass, MSG_VIS_TEXT_REPLACE_WITH_TEXT_TRANSFER_FORMAT transferParamsPtr local word push bp objectChunk local lptr push si replace local VisTextReplaceParameters elementsRemaining local dword arrayIndex local dword vmFile local word arrayDirectoryBlock local word allDosChars local byte .enter ; Assume all dos chars mov ss:[allDosChars], TRUE ; Suspend the text object so that the possibly multiple updates ; will be seen as one update. push bp ; locals stack frame mov ax, MSG_META_SUSPEND call ObjCallInstanceNoLock ; Destroys: ax, cx, dx, bp pop bp ; locals stack frame ; Before doing anything, we should see if this is a QuickMove. ; If it is, then TEQuickMove special will remove the "old ; range" before we start pasting. push bp ; locals stack frame mov bp, ss:[transferParamsPtr] call TEQuickMoveSpecial pop bp ; locals stack frame LONG jc done ; quick move failed mov bx, ss:[transferParamsPtr] ; Initialize the replacement parameters. The first time we do this, ; we replace the range given in the transfer params. After that, we ; set the start to the end. movdw ss:[replace].VTRP_range.VTR_start, \ ss:[bx].CTP_range.VTR_start, ax movdw ss:[replace].VTRP_range.VTR_end, \ ss:[bx].CTP_range.VTR_end, ax clr ss:[replace].VTRP_insCount.high ; always < 64K mov ss:[replace].VTRP_flags, mask VTRF_USER_MODIFICATION mov ss:[replace].VTRP_textReference.TR_type, TRT_POINTER ; pointer offset is always 0 clr ss:[replace].VTRP_textReference.TR_ref.TRU_pointer.TRP_pointer.offset ; Lock down the block containing the TextTransferBlockHeader struct mov ax, ss:[bx].CTP_vmBlock mov bx, ss:[bx].CTP_vmFile push bp call VMLock ; ax = segment, bp = handle mov es, ax ; Get VMblock of Huge Array directory block for text data. mov di, es:[TTBH_text].high ; Unlock this block.. don't need it anymore. We don't care about ; the attribute runs for this application. call VMUnlock pop bp ; bp = locals ptr mov ss:[vmFile], bx mov ss:[arrayDirectoryBlock], di ; bx = VMfile handle, di = VMblock handle of directory block call HugeArrayGetCount ; dxax = number of elements tst dx ; if there are 0 or 1 elements jnz beginLoop ; then just skip the loop. cmp ax, 1 ; the 1 element would just be LONG jbe endLoop ; a zero byte anyway. beginLoop: decdw dxax ; don't count NULL movdw ss:[elementsRemaining], dxax clrdw ss:[arrayIndex] ; start at 0 blockLoop: push ds ; save object block addr movdw dxax, ss:[arrayIndex] mov bx, ss:[vmFile] mov di, ss:[arrayDirectoryBlock] call HugeArrayLock ; ds:si = ptr to element ; ax <- count after (incl 1st) ; cx <- count before ; dx <- element size EC < tst ax > EC < ERROR_Z BAD_OFFSET_IN_TRANSFER_TEXT_HUGE_ARRAY > EC < cmp dx, 1 > EC < ERROR_NE EXPECTED_ELEMENT_SIZE_OF_ONE_IN_TEXT_HUGE_ARRAY > ; Take minimum of the count after in this array block and of the ; elements remaining as the number of bytes to copy. This basically ; ensures that we don't copy the zero byte at the end of the string ; since elementsRemaining has been decremented to take care of the ; zero byte. clr dx cmpdw dxax, ss:[elementsRemaining] jbe gotCount mov ax, ss:[elementsRemaining].low ;high must be zero! gotCount: ; Allocate and LOCK temporary buffer mov cx, (mask HAF_LOCK or mask HAF_NO_ERR) shl 8 or mask HF_SWAPABLE ; HeapFlags/HeapAllocFlags mov dx, ax ; save size of block call MemAlloc ; bx = handle, ax = segment mov es, ax ; Copy data from the VMblock into our new buffer. mov cx, dx ; size of block clr di shr cx, 1 rep movsw ; copy words jnc doneWithCopy movsb ; copy extra byte doneWithCopy: call HugeArrayUnlock call TECleanUpNonDosChars andnf ss:[allDosChars], ch ; keep track if any non-dos ; chars were substituted ; with the underscore. pop ds ; restore object block addr ; Load up the replace parameters and do the replace! mov ss:[replace].VTRP_textReference.TR_ref.TRU_pointer.TRP_pointer.segment, es mov ss:[replace].VTRP_insCount.low, dx mov si, ss:[objectChunk] mov ax, MSG_VIS_TEXT_REPLACE_TEXT ; carry set if error push bp lea bp, ss:[replace] call ObjCallInstanceNoLock pop bp ; bx = local buffer memory handle, still! pushf call MemFree popf jc endLoop ; Retrieve size of this last replacement. mov ax, ss:[replace].VTRP_insCount.low clr bx subdw ss:[elementsRemaining], bxax adddw ss:[arrayIndex], bxax ; make start and end the same for next replacements ; since they both come back pointing to the start of the last ; replacement, add in the length of the replacement to get the ; position for the next call. adddw bxax, ss:[replace].VTRP_range.VTR_start movdw ss:[replace].VTRP_range.VTR_start, bxax movdw ss:[replace].VTRP_range.VTR_end, bxax tstdw ss:[elementsRemaining] ; done? LONG jnz blockLoop endLoop: ; Let the text object update itself! mov si, ss:[objectChunk] mov ax, MSG_META_UNSUSPEND push bp call ObjCallInstanceNoLock ; Destroys: ax, cx, dx, bp pop bp tst ss:[allDosChars] LONG jnz done ; Okay, give the user a notification that they pasted non dos ; characters into the TFE: push bp sub sp, size StandardDialogOptrParams mov bp, sp mov ss:[bp].SDOP_customFlags, (CDT_NOTIFICATION shl offset CDBF_DIALOG_TYPE) or \ (GIT_NOTIFICATION shl offset CDBF_INTERACTION_TYPE) mov ss:[bp].SDOP_customString.handle, handle nonDosCharsString mov ss:[bp].SDOP_customString.offset, offset nonDosCharsString clr ax mov ss:[bp].SDOP_stringArg1.handle, ax mov ss:[bp].SDOP_stringArg2.handle, ax mov ss:[bp].SDOP_customTriggers.handle, ax mov ss:[bp].SDOP_helpContext.segment, ax ; Pops this thing off the stack call UserStandardDialogOptr pop bp ; Restore local ptr done: .leave ret TELargeTextReplaceWithTextTransferFormat endm endif ;not DBCS_PCGEOS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEQuickMoveSpecial %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Called right before a inserting a graphic or pasting in a transfer item. NOTE: Taken out of ttQuick.asm, QuickMoveSpecial. CALLED BY: TELargeTextReplaceWithTextTransferFormat PASS: *ds:si = text object we are going to paste into. ss:bp = CommonTransferParams structure Assumes the pasteFrame and quickFrame are on the stack. RETURN: *ds:si = object we ought to paste into. VTRP_range.VTR_start set correctly for the paste. CF SET if the operation can't succeed DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- PT 5/26/95 Initial version gene 3/22/00 Removed hack, use ...PREP_FOR_QUICK_TRANSFER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not DBCS_PCGEOS TEQuickMoveSpecial proc near uses ax,bx,cx,dx,di,bp .enter mov ax, MSG_VIS_TEXT_PREP_FOR_QUICK_TRANSFER call ObjCallInstanceNoLock .leave ret TEQuickMoveSpecial endp endif ;not DBCS_PCGEOS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TECleanUpNonDosChars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Makes all characters in buffer DOS compatible characters. Converts some GEOS characters (e.g., smart quotes) to DOS characters, but if other GEOS characters are encountered, they are replaced by an underscore. CALLED BY: TELargeTextReplaceWithTextTransferFromat PASS: es:0 = points to block to be cleaned up dx = number of chars (bytes) to be cleaned up RETURN: es:0 = points to cleaned up block ch = Non-zero value if all chars were DOS chars or replaced by acceptable DOS character. Zero if at least one char was a non-DOS char that was replaced by an underscore. DESTROYED: ds, si, ax, cl SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/15/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not DBCS_PCGEOS TECleanUpNonDosChars proc near uses dx .enter segmov ds, es, si clr si clr ax mov cx, dx mov dh, TRUE ; assume all DOS-ok chars cleanUpLoop: lodsb ; get char into al call LocalIsDosChar jz notADosChar ; ; check for some nasty control chars ; cmp al, C_SPACE jae continueLoop cmp al, C_GRAPHIC je doReplacement cmp al, C_SECTION_BREAK je doReplacement cmp al, C_PAGE_BREAK je doReplacement continueLoop: loop cleanUpLoop mov ch, dh .leave ret notADosChar: ; Check for smart double quotes mov dl, C_QUOTE cmp al, C_QUOTEDBLLEFT je gotTheReplacementChar cmp al, C_QUOTEDBLRIGHT je gotTheReplacementChar ; Check for smart single quotes mov dl, C_SNG_QUOTE cmp al, C_QUOTESNGLEFT je gotTheReplacementChar cmp al, C_QUOTESNGRIGHT je gotTheReplacementChar ; Oh well.. just give 'em an underscore. clr dh ; oops, had to replace with '_' doReplacement: mov dl, C_UNDERSCORE gotTheReplacementChar: ; replace the character (no longer pointer to by si since si was ; automatically incremented by the lodsb). mov ds:[si-1], dl jmp continueLoop TECleanUpNonDosChars endp endif ;not DBCS_PCGEOS ;=========================================================================== ; Mailbox system-specific code ;=========================================================================== if FAX_SUPPORT COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEMPCCheckForFax %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This routine checks to see if the destination of a print job is a fax print driver or not. It is recommended that this be called from the MSG_PRINT_START_PRINTING handler. CALLED BY: MSG_TEMPC_CHECK_FOR_FAX PASS: *ds:si - instance data of TEMailboxPrintControlClass ds:di - *ds:si es - seg addr of TEMailboxPrintControlClass ax - MSG_TEMPC_CHECK_FOR_FAX RETURN: ax - TRUE if the destination is a fax print driver - FALSE if the destination is not a fax print driver, or if there is no way to tell. DESTROYED: bx, si, di, ds, es (method handler) REVISION HISTORY: Name Date Description ---- ---- ----------- jdashe 3/23/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PRINTER_TYPE_KEY equ "type" LocalDefNLString faxPrinterKey <PRINTER_TYPE_KEY, 0> TEMPCCheckForFax method dynamic TEMailboxPrintControlClass, MSG_TEMPC_CHECK_FOR_FAX uses cx, dx .enter ; ; Hack: check to see if there is a temp varadata block. If so, it ; contains the file name of the print driver being used. ; mov ax, TEMP_PRINT_CONTROL_INSTANCE call ObjVarFindData ; ds:bx <- vardata jnc notAFaxNoBlock ; jump if no vardata ; ; Found the vardata. Get the JobParameters block. ; mov bx, ds:[bx].TPCI_jobParHandle tst bx jz notAFax ; jump if no JobParams call MemLock ; ax <- seg of JP jc notAFax ; ; Got the JobParams. Read the type from the ini file. ; mov ds, ax ; ds:0 <- JobParams mov si, offset JP_printerName ; ds:si <- printer name mov cx, cs ; cx:dx <- type key mov dx, offset faxPrinterKey call InitFileReadInteger ; ax <- printer type jc notAFax cmp ax, PDT_FACSIMILE jne notAFax ; jump if no match mov ax, TRUE ; it's a fax. done: tst bx jz exit call MemUnlock ; unlock JobParams exit: .leave ret notAFaxNoBlock: ; ; There's no fax, and we don't have a JobParams block to unlock. ; clr bx notAFax: mov ax, FALSE jmp done TEMPCCheckForFax endm endif ;FAX_SUPPORT CommonCode ends ;end of CommonCode resource
; A140303: Triangle T(n,k) = 3^(n-k) read by rows. ; 1,3,1,9,3,1,27,9,3,1,81,27,9,3,1,243,81,27,9,3,1,729,243,81,27,9,3,1,2187,729,243,81,27,9,3,1,6561,2187,729,243,81,27,9,3,1,19683,6561,2187,729,243,81,27,9,3,1,59049,19683,6561,2187,729,243,81,27,9,3,1 seq $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j. mov $1,3 pow $1,$0 mov $0,$1
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: FILE: titleManager.asm AUTHOR: John Wedgwood, Oct 8, 1991 METHODS: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- John 10/ 8/91 Initial revision DESCRIPTION: Manager for the Title module. $Id: titleManager.asm,v 1.1 97/04/04 17:47:17 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ include chartGeode.def ChartClassStructures segment resource TitleClass ChartClassStructures ends ChartMiscCode segment resource include titleBuild.asm include titleGeometry.asm include titleRealize.asm include titleGrObj.asm ChartMiscCode ends
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; EnableInterrupts.Asm ; ; Abstract: ; ; EnableInterrupts function ; ; Notes: ; ;------------------------------------------------------------------------------ DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; EnableInterrupts ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(EnableInterrupts) ASM_PFX(EnableInterrupts): sti ret ; MS_CHANGE - START ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; EnableInterruptsAndSleep ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(EnableInterruptsAndSleep) ASM_PFX(EnableInterruptsAndSleep): sti hlt ret ; MS_CHANGE - END
////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2007-2015, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // * Neither the name of Image Engine Design nor the names of any // other contributors to this software may be used to endorse or // promote products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////// #include "boost/python.hpp" #include <iostream> #include <cassert> #include "boost/format.hpp" #include "maya/MPxNode.h" #include "maya/MPlugArray.h" #include "maya/MFnDependencyNode.h" #include "maya/MFnAttribute.h" #include "maya/MDGModifier.h" #include "maya/MGlobal.h" #include "maya/MFnNumericAttribute.h" #include "IECoreMaya/OpHolder.h" #include "IECoreMaya/ParameterHandler.h" #include "IECoreMaya/MayaTypeIds.h" #include "IECore/MessageHandler.h" #include "IECore/CompoundParameter.h" #include "IECore/Object.h" #include "IECore/TypedParameter.h" #include "IECore/Parameterised.h" #include "IECorePython/ScopedGILLock.h" using namespace IECore; using namespace IECoreMaya; template<typename B> MObject OpHolder<B>::aResultDependency; // this post load callback is used to dirty the result plug // following loading - see further comments in initialize. template<typename B> class OpHolder<B>::PostLoadCallback : public IECoreMaya::PostLoadCallback { public : PostLoadCallback( OpHolder<B> *node ) : m_node( node ) { } protected : OpHolder<B> *m_node; virtual void postLoad() { MFnDependencyNode fnDN( m_node->thisMObject() ); MPlug plug = fnDN.findPlug( aResultDependency, false ); plug.setValue( 1 ); m_node->m_postLoadCallback = 0; // remove this callback } }; template<typename B> OpHolder<B>::OpHolder() { m_postLoadCallback = new PostLoadCallback( this ); } template<typename B> OpHolder<B>::~OpHolder() { } template<typename B> void *OpHolder<B>::creator() { return new OpHolder<B>(); } template<typename B> MStatus OpHolder<B>::initialize() { MStatus s = OpHolder<B>::inheritAttributesFrom( ParameterisedHolder<B>::typeName ); if( !s ) { return s; } // when we create the result attribute in createResultAttribute(), we make it // non-storable. it's common for the result to be a large object such as a mesh so // storing it would be prohibitively expensive, and in any case it doesn't make sense to // store something which can be recomputed. // // however, that causes problems because maya seems incapable of realising that because // it didn't save the attribute in the file, it can't possibly have a valid value. // maya also doesn't call setDependentsDirty() during scene open, so we don't get a // chance to dirty the result at that point either. to work around this, we create this dummy dependency // attribute, which we change the value of in a post load callback. this value change // triggers setDependentsDirty and we're able to dirty the result before anyone tries to use // it. see FnParameterisedHolderTest.testResultAttrSaveLoad() for a test case exercising this // workaround. MFnNumericAttribute fnNAttr; aResultDependency = fnNAttr.create( "resultDependency", "rdep", MFnNumericData::kInt, 0 ); fnNAttr.setStorable( false ); fnNAttr.setHidden( true ); return B::addAttribute( aResultDependency ); } template<typename B> MStatus OpHolder<B>::setDependentsDirty( const MPlug &plug, MPlugArray &plugArray ) { /// This isn't the best way of doing it, but at this point we can't even be sure that the Op has been loaded, /// so calling plugParameter() may not work. We can't call getOp() or getParameterised() here, as it seems /// we can't do things such as adding/removing attributes within this function if( std::string( plug.partialName().substring( 0, 4 ).asChar() ) == ParameterisedHolder<B>::g_attributeNamePrefix || plug==aResultDependency ) { MFnDependencyNode fnDN( B::thisMObject() ); MStatus s; MPlug resultPlug = fnDN.findPlug( "result" , false, &s); if ( s && !resultPlug.isNull() ) { plugArray.append( resultPlug ); } } return ParameterisedHolder<B>::setDependentsDirty( plug, plugArray ); } template<typename B> MStatus OpHolder<B>::compute( const MPlug &plug, MDataBlock &block ) { IECore::OpPtr op = getOp(); if (op) { MFnDependencyNode fnDN( B::thisMObject() ); MPlug resultPlug( B::thisMObject(), fnDN.attribute( "result" ) ); if (plug != resultPlug) { return MS::kUnknownParameter; } IECore::ObjectPtr result; try { ParameterisedHolder<B>::setParameterisedValues( true /* lazy */ ); result = op->operate(); if (!result) { return MS::kFailure; } } catch( std::exception &e ) { MGlobal::displayError( e.what() ); return MS::kFailure; } catch( boost::python::error_already_set & ) { IECorePython::ScopedGILLock lock; PyErr_Print(); return MS::kFailure; } catch (...) { return MS::kFailure; } assert( result ); MStatus s = ParameterHandler::setValue( op->resultParameter(), resultPlug ); block.setClean( resultPlug ); return s; } return MS::kFailure; } template<typename B> MStatus OpHolder<B>::setParameterised( IECore::RunTimeTypedPtr p ) { MStatus s = ParameterisedHolder<B>::setParameterised( p ); if( !s ) { return s; } return createResultAttribute(); } template<typename B> IECore::RunTimeTypedPtr OpHolder<B>::getParameterised( std::string *classNameOut, int *classVersionOut, std::string *searchPathEnvVarOut ) { bool mustCreateResultAttribute = !ParameterisedHolder<B>::m_parameterised; IECore::RunTimeTypedPtr result = ParameterisedHolder<B>::getParameterised( classNameOut, classVersionOut, searchPathEnvVarOut ); if( result && mustCreateResultAttribute ) { MStatus s = createResultAttribute(); if( !s ) { ParameterisedHolder<B>::m_parameterised = 0; ParameterisedHolder<B>::m_failedToLoad = true; } } return result; } template<typename B> MStatus OpHolder<B>::createResultAttribute() { IECore::OpPtr op = IECore::runTimeCast<IECore::Op>( ParameterisedHolder<B>::m_parameterised ); if( !op ) { MString nodeName = ParameterisedHolder<B>::name(); msg( Msg::Error, "OpHolder::createResultAttribute", boost::format( "No Op found on node \"%s\"." ) % nodeName.asChar() ); return MStatus::kFailure; } MStatus s = ParameterisedHolder<B>::createOrUpdateAttribute( const_cast<IECore::Parameter *>( op->resultParameter() ), "result" ); if( !s ) { MString nodeName = ParameterisedHolder<B>::name(); msg( Msg::Error, "OpHolder::createResultAttribute", boost::format( "Unable to update result attribute to represent class \"%s\" on node \"%s\"." ) % op->typeName() % nodeName.asChar() ); return s; } MFnDependencyNode fnDN( B::thisMObject() ); MObject attribute = fnDN.attribute( "result" ); MFnAttribute fnAttr( attribute ); fnAttr.setWritable( false ); fnAttr.setStorable( false ); return MStatus::kSuccess; } template<typename B> MStatus OpHolder<B>::setOp( const std::string &className, int classVersion ) { return ParameterisedHolder<B>::setParameterised( className, classVersion, "IECORE_OP_PATHS"); } template<typename B> IECore::OpPtr OpHolder<B>::getOp( std::string *className, int *classVersion, std::string *searchPathEnvVar ) { return IECore::runTimeCast<IECore::Op>( getParameterised( className, classVersion, searchPathEnvVar ) ); } template<> MTypeId OpHolderNode::id( OpHolderNodeId ); template class OpHolder<MPxNode>;
; A037583: Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 3,1. ; 3,13,55,221,887,3549,14199,56797,227191,908765,3635063,14540253,58161015,232644061,930576247,3722304989,14889219959,59556879837,238227519351,952910077405,3811640309623,15246561238493,60986244953975 mov $1,4 pow $1,$0 mul $1,52 div $1,15
; A002454: Central factorial numbers: a(n) = 4^n (n!)^2. ; 1,4,64,2304,147456,14745600,2123366400,416179814400,106542032486400,34519618525593600,13807847410237440000,6682998146554920960000,3849406932415634472960000,2602199086312968903720960000,2040124083669367620517232640000,1836111675302430858465509376000000 mul $0,2 mov $1,1 lpb $0 mul $1,$0 mul $1,$0 sub $0,2 lpe mov $0,$1
#include "stdafx.h" #include "Collider.h" #include "../../../GlobalObjects/Physix/Manifold.h" #include "../Transform2D.h" #include "../../../../Global/MathTools/utils.h" #include "CircleCollider.h" #include "RectCollider.h" //Circle vs Circle with Manifold hit Collition bool Collider::checkCircleCircle(const Vec2& pos1, float radius1, const Vec2& pos2, float radius2, Manifold& hit) const { Vec2 posinit = pos1; Vec2 n = pos2 - pos1; //To perform actual lenght float centerDistance = Vec2::get_squared_dist(pos2, posinit); float radiussum = radius1 + radius2; //Early Acces if (centerDistance > radiussum) { hit.contacts_count = 0; return false; } hit.contacts_count = 1; //There is a collision and we add //There is a collition now Compute The Manifold Hit float d = n.Lenght(); // If distance between circles is not zero if (d != 0) { // Distance is difference between radius and distance hit.penetration = radiussum - d; float nx = (pos2.x - pos1.x) / centerDistance; float ny = (pos2.y - pos1.y) / centerDistance; hit.normal = Vec2(nx, ny); hit.contacts[0] = hit.normal * radius1 + pos1; } // Circles are on same position else { // Choose random (but consistent) values hit.penetration = radius1; hit.normal = Vec2(1, 0); } return true; } //Rect vs Circle with Manifold hit Collition bool Collider::checkCircleRect(const Vec2& circlePos, float circleRadius, const Vec2& rectPos, const Vec2& rectSize, Manifold& hit) const { Vec2 rectPos2 = Vec2(0, 0); Vec2 rectSize2 = Vec2(0, 0); Vec2 circlePos2 = Vec2(0,0); float circleRadius2 = 0; if (hit.bodie1->m_shape->colliderType == ColliderType::CIRCLE_COLLIDER && hit.bodie2->m_shape->colliderType == ColliderType::RECT_COLLIDER) { //Setting circle Bodie Variables CircleCollider* circle_collider = static_cast<CircleCollider*>(hit.bodie1->m_shape); circlePos2 = circle_collider->m_transform_2d->GetPos(); circleRadius2 = circle_collider->getRadius(); //Setting Rect Variables RectCollider* rect_collider = static_cast<RectCollider*>(hit.bodie2->m_shape); rectPos2 = rect_collider->m_transform_2d->GetPos(); rectSize2 = rect_collider->getSize(); float XMin = rectPos2.GetX() - (rectSize2.GetX() / 2); float XMax = rectPos2.GetX() + (rectSize2.GetX() / 2); float YMin = rectPos2.GetY() - (rectSize2.GetY() / 2); float YMax = rectPos2.GetY() + (rectSize2.GetY() / 2); /*//****************/ float closestX = Utils::clamp(circlePos2.x, XMin, XMax); float closestY = Utils::clamp(circlePos2.y, YMin, YMax); Vec2 closestpoint = Vec2(closestX, closestY); float distanceBetween = Vec2::get_squared_dist(circlePos2, closestpoint); if (distanceBetween > circleRadius2) { return false; } Vec2 n; n = circlePos2 - closestpoint; //Direction of the closese point n.Normalize(); float penetration = circleRadius2 - distanceBetween; hit.contacts_count = 1; //hit.penetration = penetration; hit.normal = -n; //hit.contacts[0] = hit.normal * circleRadius + circlePos; return true; } if (hit.bodie1->m_shape->colliderType == ColliderType::RECT_COLLIDER && hit.bodie2->m_shape->colliderType == ColliderType::CIRCLE_COLLIDER) { //Setting Rect Variables RectCollider* rect_collider = static_cast<RectCollider*>(hit.bodie1->m_shape); rectPos2 = rect_collider->m_transform_2d->GetPos(); rectSize2 = rect_collider->getSize(); CircleCollider* circle_collider = static_cast<CircleCollider*>(hit.bodie2->m_shape); circlePos2 = circle_collider->m_transform_2d->GetPos(); circleRadius2 = circle_collider->getRadius(); float XMin = rectPos2.GetX() - (rectSize2.GetX() / 2); float XMax = rectPos2.GetX() + (rectSize2.GetX() / 2); float YMin = rectPos2.GetY() - (rectSize2.GetY() / 2); float YMax = rectPos2.GetY() + (rectSize2.GetY() / 2); /*//****************/ float closestX = Utils::clamp(circlePos2.x, XMin, XMax); float closestY = Utils::clamp(circlePos2.y, YMin, YMax); Vec2 closestpoint = Vec2(closestX, closestY); float distanceBetween = Vec2::get_squared_dist(circlePos2, closestpoint); if (distanceBetween > circleRadius2) { return false; } Vec2 n; n = circlePos2 - closestpoint; //Direction of the closese point n.Normalize(); float penetration = circleRadius2 - distanceBetween; hit.contacts_count = 1; //hit.penetration = penetration; hit.normal = n; //hit.contacts[0] = hit.normal * circleRadius + circlePos; return true; } } //Cuadrado Cuadrado bool Collider::checkRectRect(const Vec2& rectPos1, const Vec2& rectSize1, const Vec2& rectPos2, const Vec2& rectSize2, Manifold& hit) const { //Struct to Handle First Object struct AABB_1 { Vec2 min = Vec2(0, 0); Vec2 max = Vec2(0, 0); }; //Second Object struct AABB_2 { Vec2 min = Vec2(0, 0); Vec2 max = Vec2(0, 0); }; hit.contacts_count = 0; //Extents and half extents of each object float topLeftX = rectPos1.GetX() - rectSize1.x / 2; float bottomRightX(rectPos1.GetX() + rectSize1.x / 2); //Point 2 float topLeftY = rectPos1.GetY() - rectSize1.y / 2; float bottomRightY(rectPos1.GetY() + rectSize1.y / 2); AABB_1 square_1; square_1.min = Vec2(topLeftX, topLeftY); square_1.max = Vec2(bottomRightX, bottomRightY); //Point 1 float topLeftX2(rectPos2.GetX() - rectSize2.GetX() / 2); float topLeftY2(rectPos2.GetY() - rectSize2.GetY() / 2); //Point2 float bottomRightX2(rectPos2.GetX() + rectSize2.GetX() / 2); float bottomRightY2(rectPos2.GetY() + rectSize2.GetY() / 2); AABB_2 square_2; square_2.min = Vec2(topLeftX2, topLeftY2); square_2.max = Vec2(bottomRightX2, bottomRightY2); //With Excluiyent Operations -- Better //-Exit with no intersection if found separated along an axis if (square_1.max.x < square_2.min.x || square_1.min.x > square_2.max.x)return false; if (square_1.max.y < square_2.min.y || square_1.min.y > square_2.max.y)return false; // Vector from A to B Vec2 deltaDistance = rectPos2 - rectPos1; // Calculate half extents along x axis for each object float square1_extentX = (square_1.max.x - square_1.min.x) / 2; //Half extent float square2_extentX = (square_2.max.x - square_2.min.x) / 2; //Delta distance X //float dx = square1_extentX + square2_extentX; // Calculate overlap on x axis float x_overlap = (square1_extentX + square2_extentX) - abs(deltaDistance.x); // Calculate half extents along x axis for each object float square1_extentY = (square_1.max.y - square_1.min.y) / 2; //Half extent float square2_extentY = (square_2.max.y - square_2.min.y) / 2; //Delta distance Y //float dy = square1_extentY + square2_extentY; // Calculate overlap on x axis float y_overlap = (square1_extentY + square2_extentY) - abs(deltaDistance.y); int cp = 0; //Collision en X if (x_overlap > 0) { if (y_overlap > 0) { if (y_overlap > x_overlap) { if (deltaDistance.x < 0) { hit.normal = Vec2(-1, 0); } else { hit.normal = Vec2(0, 0); } //Aqui va el hit.contacts hit.penetration = x_overlap; } else { if (deltaDistance.y < 0) { hit.normal = Vec2(0, -1); } else { hit.normal = Vec2(0, 1); } hit.penetration = y_overlap; } //Aqui va el hit.contacts hit.contacts_count=1; } } return true; } //Todas las de pixels bool Collider::checkPixelsPixels(const Vec2& pixelsPos1, const Vec2& pixelsSize1, const uint8_t* pixels1, const Vec2& pixelsPos2, const Vec2& pixelsSize2, const uint8_t* pixels2, Manifold& hit)const { return false; } //falta bool Collider::checkPixelsRect(const Vec2& pixelsPos, const Vec2& pixelsSize, const uint8_t* pixels, const Vec2& rectPos, const Vec2& rectSize, Manifold& hit)const { return false; } //falta bool Collider::checkCirclePixels(const Vec2& circlePos, float circleRadius, const Vec2& pixelsPos, const Vec2& pixelsSize, const uint8_t* pixels, Manifold& hit)const { return false; } //Optional comprobations bool Collider::CircleCircleUnoptimized(const Vec2& pos1, float radius1, const Vec2& pos2, float radius2, Manifold& hit) const { float dist = Vec2::get_squared_dist(pos2, pos1); float radiusSum = radius1 + radius2; return radiusSum < dist; } bool Collider::CircleCircleOptimized(const Vec2& pos1, float radius1, const Vec2& pos2, float radius2, Manifold& hit) const { float radiusSum = radius1 + radius2; radiusSum *= radiusSum; return radiusSum < powf(pos1.GetX() + pos2.GetX(),2) + powf(pos1.GetY() + pos2.GetY(),2); }
/* Copyright (c) 2019 vesoft inc. All rights reserved. * * This source code is licensed under Apache 2.0 License, * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ #include "meta/processors/admin/AdminClient.h" #include "meta/MetaServiceUtils.h" #include "meta/processors/Common.h" #include "meta/ActiveHostsMan.h" #include "kvstore/Part.h" DEFINE_int32(max_retry_times_admin_op, 30, "max retry times for admin request!"); namespace nebula { namespace meta { folly::Future<Status> AdminClient::transLeader(GraphSpaceID spaceId, PartitionID partId, const HostAddr& leader, const HostAddr& dst) { if (injector_) { return injector_->transLeader(); } storage::cpp2::TransLeaderReq req; req.set_space_id(spaceId); req.set_part_id(partId); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } auto& peers = ret.value(); auto it = std::find(peers.begin(), peers.end(), leader); if (it == peers.end()) { LOG(WARNING) << "Can't find part " << partId << " on " << leader; return Status::PartNotFound(); } auto target = dst; if (dst == kRandomPeer) { for (auto& p : peers) { if (p != leader && ActiveHostsMan::isLived(kv_, p)) { target = p; break; } } } req.set_new_leader(toThriftHost(target)); return getResponse(leader, std::move(req), [] (auto client, auto request) { return client->future_transLeader(request); }, [] (auto&& resp) -> Status { switch (resp.get_code()) { case storage::cpp2::ErrorCode::SUCCEEDED: case storage::cpp2::ErrorCode::E_LEADER_CHANGED: { return Status::OK(); } case storage::cpp2::ErrorCode::E_PART_NOT_FOUND: { return Status::PartNotFound(); } default: return Status::Error("Unknown code %d", static_cast<int32_t>(resp.get_code())); } }); } folly::Future<Status> AdminClient::addPart(GraphSpaceID spaceId, PartitionID partId, const HostAddr& host, bool asLearner) { if (injector_) { return injector_->addPart(); } storage::cpp2::AddPartReq req; req.set_space_id(spaceId); req.set_part_id(partId); req.set_as_learner(asLearner); return getResponse(host, std::move(req), [] (auto client, auto request) { return client->future_addPart(request); }, [] (auto&& resp) -> Status { if (resp.get_code() == storage::cpp2::ErrorCode::SUCCEEDED) { return Status::OK(); } else { return Status::Error("Add part failed! code=%d", static_cast<int32_t>(resp.get_code())); } }); } folly::Future<Status> AdminClient::addLearner(GraphSpaceID spaceId, PartitionID partId, const HostAddr& learner) { if (injector_) { return injector_->addLearner(); } storage::cpp2::AddLearnerReq req; req.set_space_id(spaceId); req.set_part_id(partId); req.set_learner(toThriftHost(learner)); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } folly::Promise<Status> pro; auto f = pro.getFuture(); getResponse(ret.value(), 0, std::move(req), [] (auto client, auto request) { return client->future_addLearner(request); }, 0, std::move(pro), FLAGS_max_retry_times_admin_op); return f; } folly::Future<Status> AdminClient::waitingForCatchUpData(GraphSpaceID spaceId, PartitionID partId, const HostAddr& target) { if (injector_) { return injector_->waitingForCatchUpData(); } storage::cpp2::CatchUpDataReq req; req.set_space_id(spaceId); req.set_part_id(partId); req.set_target(toThriftHost(target)); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } folly::Promise<Status> pro; auto f = pro.getFuture(); getResponse(ret.value(), 0, std::move(req), [] (auto client, auto request) { return client->future_waitingForCatchUpData(request); }, 0, std::move(pro), 3); return f; } folly::Future<Status> AdminClient::memberChange(GraphSpaceID spaceId, PartitionID partId, const HostAddr& peer, bool added) { if (injector_) { return injector_->memberChange(); } storage::cpp2::MemberChangeReq req; req.set_space_id(spaceId); req.set_part_id(partId); req.set_add(added); req.set_peer(toThriftHost(peer)); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } folly::Promise<Status> pro; auto f = pro.getFuture(); getResponse(ret.value(), 0, std::move(req), [] (auto client, auto request) { return client->future_memberChange(request); }, 0, std::move(pro), FLAGS_max_retry_times_admin_op); return f; } folly::Future<Status> AdminClient::updateMeta(GraphSpaceID spaceId, PartitionID partId, const HostAddr& src, const HostAddr& dst) { if (injector_) { return injector_->updateMeta(); } CHECK_NOTNULL(kv_); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } auto peers = std::move(ret).value(); auto strHosts = [] (const std::vector<HostAddr>& hosts) -> std::string { std::stringstream peersStr; for (auto& h : hosts) { peersStr << h << ","; } return peersStr.str(); }; LOG(INFO) << "[space:" << spaceId << ", part:" << partId << "] Update original peers " << strHosts(peers) << " remove " << src << ", add " << dst; auto it = std::find(peers.begin(), peers.end(), src); if (it == peers.end()) { LOG(INFO) << "src " << src << " has been removed in [" << spaceId << ", " << partId << "]"; // In this case, the dst should be existed in peers. if (std::find(peers.begin(), peers.end(), dst) == peers.end()) { LOG(ERROR) << "[space:" << spaceId << ", part:" << partId << "] dst " << dst << "should be existed in peers!"; return Status::Error("dst not exist in peers"); } return Status::OK(); } peers.erase(it); if (std::find(peers.begin(), peers.end(), dst) != peers.end()) { LOG(ERROR) << "[space:" << spaceId << ", part:" << partId << "] dst " << dst << " has been existed!"; return Status::Error("dst has been existed in peers"); } peers.emplace_back(dst); std::vector<nebula::cpp2::HostAddr> thriftPeers; thriftPeers.resize(peers.size()); std::transform(peers.begin(), peers.end(), thriftPeers.begin(), [this](const auto& h) { return toThriftHost(h); }); auto partRet = kv_->part(kDefaultSpaceId, kDefaultPartId); CHECK(ok(partRet)); auto part = nebula::value(partRet); folly::Promise<Status> pro; auto f = pro.getFuture(); std::vector<kvstore::KV> data; data.emplace_back(MetaServiceUtils::partKey(spaceId, partId), MetaServiceUtils::partVal(thriftPeers)); part->asyncMultiPut(std::move(data), [] (kvstore::ResultCode) {}); part->sync([this, p = std::move(pro)] (kvstore::ResultCode code) mutable { // To avoid dead lock, we call future callback in ioThreadPool_ folly::via(ioThreadPool_.get(), [code, p = std::move(p)] () mutable { if (code == kvstore::ResultCode::SUCCEEDED) { p.setValue(Status::OK()); } else { p.setValue(Status::Error("Access kv failed, code:%d", static_cast<int32_t>(code))); } }); }); return f; } folly::Future<Status> AdminClient::removePart(GraphSpaceID spaceId, PartitionID partId, const HostAddr& host) { if (injector_) { return injector_->removePart(); } storage::cpp2::RemovePartReq req; req.set_space_id(spaceId); req.set_part_id(partId); return getResponse(host, std::move(req), [] (auto client, auto request) { return client->future_removePart(request); }, [] (auto&& resp) -> Status { if (resp.get_code() == storage::cpp2::ErrorCode::SUCCEEDED) { return Status::OK(); } else { return Status::Error("Remove part failed! code=%d", static_cast<int32_t>(resp.get_code())); } }); } folly::Future<Status> AdminClient::checkPeers(GraphSpaceID spaceId, PartitionID partId) { if (injector_) { return injector_->checkPeers(); } storage::cpp2::CheckPeersReq req; req.set_space_id(spaceId); req.set_part_id(partId); auto ret = getPeers(spaceId, partId); if (!ret.ok()) { return ret.status(); } auto peers = std::move(ret).value(); std::vector<nebula::cpp2::HostAddr> thriftPeers; thriftPeers.resize(peers.size()); std::transform(peers.begin(), peers.end(), thriftPeers.begin(), [this](const auto& h) { return toThriftHost(h); }); req.set_peers(std::move(thriftPeers)); folly::Promise<Status> pro; auto fut = pro.getFuture(); std::vector<folly::Future<Status>> futures; for (auto& p : peers) { auto f = getResponse(p, req, [] (auto client, auto request) { return client->future_checkPeers(request); }, [] (auto&& resp) -> Status { if (resp.get_code() == storage::cpp2::ErrorCode::SUCCEEDED) { return Status::OK(); } else { return Status::Error("Add part failed! code=%d", static_cast<int32_t>(resp.get_code())); } }); futures.emplace_back(std::move(f)); } folly::collectAll(std::move(futures)).thenTry([p = std::move(pro)] (auto&& t) mutable { if (t.hasException()) { p.setValue(Status::Error("Check failed!")); } else { auto v = std::move(t).value(); for (auto& resp : v) { // The exception has been catched inside getResponse. CHECK(!resp.hasException()); auto st = std::move(resp).value(); if (!st.ok()) { p.setValue(st); return; } } p.setValue(Status::OK()); } }); return fut; } template<typename Request, typename RemoteFunc, typename RespGenerator> folly::Future<Status> AdminClient::getResponse( const HostAddr& host, Request req, RemoteFunc remoteFunc, RespGenerator respGen) { folly::Promise<Status> pro; auto f = pro.getFuture(); auto* evb = ioThreadPool_->getEventBase(); auto partId = req.get_part_id(); folly::via(evb, [evb, pro = std::move(pro), host, req = std::move(req), partId, remoteFunc = std::move(remoteFunc), respGen = std::move(respGen), this] () mutable { auto client = clientsMan_->client(host, evb); remoteFunc(client, std::move(req)).via(evb) .then([p = std::move(pro), partId, respGen = std::move(respGen)]( folly::Try<storage::cpp2::AdminExecResp>&& t) mutable { // exception occurred during RPC if (t.hasException()) { p.setValue(Status::Error(folly::stringPrintf("RPC failure in AdminClient: %s", t.exception().what().c_str()))); return; } auto&& result = std::move(t).value().get_result(); if (result.get_failed_codes().empty()) { storage::cpp2::ResultCode resultCode; resultCode.set_code(storage::cpp2::ErrorCode::SUCCEEDED); resultCode.set_part_id(partId); p.setValue(respGen(resultCode)); } else { auto resp = result.get_failed_codes().front(); p.setValue(respGen(std::move(resp))); } }); }); return f; } template<typename Request, typename RemoteFunc> void AdminClient::getResponse( std::vector<HostAddr> hosts, int32_t index, Request req, RemoteFunc remoteFunc, int32_t retry, folly::Promise<Status> pro, int32_t retryLimit) { auto* evb = ioThreadPool_->getEventBase(); CHECK_GE(index, 0); CHECK_LT(index, hosts.size()); folly::via(evb, [evb, hosts = std::move(hosts), index, req = std::move(req), remoteFunc = std::move(remoteFunc), retry, pro = std::move(pro), retryLimit, this] () mutable { auto client = clientsMan_->client(hosts[index], evb); remoteFunc(client, req).via(evb) .then([p = std::move(pro), hosts = std::move(hosts), index, req = std::move(req), remoteFunc = std::move(remoteFunc), retry, retryLimit, this] (folly::Try<storage::cpp2::AdminExecResp>&& t) mutable { // exception occurred during RPC if (t.hasException()) { if (retry < retryLimit) { LOG(INFO) << "Rpc failure to " << hosts[index] << ", retry " << retry << ", limit " << retryLimit; index = (index + 1) % hosts.size(); getResponse(std::move(hosts), index, std::move(req), remoteFunc, retry + 1, std::move(p), retryLimit); return; } p.setValue(Status::Error(folly::stringPrintf("RPC failure in AdminClient: %s", t.exception().what().c_str()))); return; } auto&& result = std::move(t).value().get_result(); if (result.get_failed_codes().empty()) { p.setValue(Status::OK()); return; } auto resp = result.get_failed_codes().front(); switch (resp.get_code()) { case storage::cpp2::ErrorCode::E_LEADER_CHANGED: { if (retry < retryLimit) { HostAddr leader(0, 0); if (resp.get_leader() != nullptr) { leader = HostAddr(resp.get_leader()->get_ip(), resp.get_leader()->get_port()); } if (leader == HostAddr(0, 0)) { usleep(1000 * 50); LOG(INFO) << "The leader is in election" << ", retry " << retry << ", limit " << retryLimit; index = (index + 1) % hosts.size(); getResponse(std::move(hosts), index, std::move(req), std::move(remoteFunc), retry + 1, std::move(p), retryLimit); return; } int32_t leaderIndex = 0; for (auto& h : hosts) { if (h == leader) { break; } leaderIndex++; } if (leaderIndex == (int32_t)hosts.size()) { // In some cases (e.g. balance task is failed in member change remove // phase, and the new host is elected as leader somehow), the peers of // this partition in meta doesn't include new host, which will make // this task failed forever. index = leaderIndex; hosts.emplace_back(leader); } LOG(INFO) << "Return leader change from " << hosts[index] << ", new leader is " << leader << ", retry " << retry << ", limit " << retryLimit; CHECK_LT(leaderIndex, hosts.size()); getResponse(std::move(hosts), leaderIndex, std::move(req), std::move(remoteFunc), retry + 1, std::move(p), retryLimit); return; } p.setValue(Status::Error("Leader changed!")); return; } default: { if (retry < retryLimit) { LOG(INFO) << "Unknown code " << static_cast<int32_t>(resp.get_code()) << " from " << hosts[index] << ", retry " << retry << ", limit " << retryLimit; index = (index + 1) % hosts.size(); getResponse(std::move(hosts), index, std::move(req), std::move(remoteFunc), retry + 1, std::move(p), retryLimit); return; } p.setValue(Status::Error("Unknown code %d", static_cast<int32_t>(resp.get_code()))); return; } } }); // then }); // via } nebula::cpp2::HostAddr AdminClient::toThriftHost(const HostAddr& addr) { nebula::cpp2::HostAddr thriftAddr; thriftAddr.set_ip(addr.first); thriftAddr.set_port(addr.second); return thriftAddr; } StatusOr<std::vector<HostAddr>> AdminClient::getPeers(GraphSpaceID spaceId, PartitionID partId) { CHECK_NOTNULL(kv_); auto partKey = MetaServiceUtils::partKey(spaceId, partId); std::string value; auto code = kv_->get(kDefaultSpaceId, kDefaultPartId, partKey, &value); switch (code) { case kvstore::ResultCode::SUCCEEDED: { auto partHosts = MetaServiceUtils::parsePartVal(value); std::vector<HostAddr> hosts; hosts.resize(partHosts.size()); std::transform(partHosts.begin(), partHosts.end(), hosts.begin(), [](const auto& h) { return HostAddr(h.get_ip(), h.get_port()); }); return hosts; } case kvstore::ResultCode::ERR_KEY_NOT_FOUND: return Status::Error("Key Not Found"); default: LOG(WARNING) << "Get peers failed, error " << static_cast<int32_t>(code); break; } return Status::Error("Get Failed"); } void AdminClient::getLeaderDist(const HostAddr& host, folly::Promise<StatusOr<storage::cpp2::GetLeaderResp>>&& pro, int32_t retry, int32_t retryLimit) { auto* evb = ioThreadPool_->getEventBase(); folly::via(evb, [evb, host, pro = std::move(pro), retry, retryLimit, this] () mutable { storage::cpp2::GetLeaderReq req; auto client = clientsMan_->client(host, evb); client->future_getLeaderPart(std::move(req)).via(evb) .then([pro = std::move(pro), host, retry, retryLimit, this] (folly::Try<storage::cpp2::GetLeaderResp>&& t) mutable { if (t.hasException()) { LOG(ERROR) << folly::stringPrintf("RPC failure in AdminClient: %s", t.exception().what().c_str()); if (retry < retryLimit) { usleep(1000 * 50); getLeaderDist(host, std::move(pro), retry + 1, retryLimit); } else { pro.setValue(Status::Error("RPC failure in AdminClient")); } return; } auto&& resp = std::move(t).value(); LOG(INFO) << "Get leader for host " << host; pro.setValue(std::move(resp)); }); }); } folly::Future<Status> AdminClient::getLeaderDist(HostLeaderMap* result) { if (injector_) { return injector_->getLeaderDist(result); } folly::Promise<Status> promise; auto future = promise.getFuture(); auto allHosts = ActiveHostsMan::getActiveHosts(kv_); std::vector<folly::Future<StatusOr<storage::cpp2::GetLeaderResp>>> hostFutures; for (const auto& h : allHosts) { folly::Promise<StatusOr<storage::cpp2::GetLeaderResp>> pro; auto fut = pro.getFuture(); getLeaderDist(h, std::move(pro), 0, 3); hostFutures.emplace_back(std::move(fut)); } folly::collectAll(std::move(hostFutures)).thenValue([p = std::move(promise), result, allHosts] (std::vector<folly::Try<StatusOr<storage::cpp2::GetLeaderResp>>>&& tries) mutable { size_t idx = 0; for (auto& t : tries) { if (t.hasException()) { ++idx; continue; } auto&& status = std::move(t.value()); if (!status.ok()) { ++idx; continue; } auto resp = status.value(); result->emplace(allHosts[idx], std::move(resp.leader_parts)); ++idx; } p.setValue(Status::OK()); }).thenError([p = std::move(promise)] (auto&& e) mutable { p.setValue(Status::Error("Get leader failed, %s", e.what().c_str())); }); return future; } folly::Future<Status> AdminClient::createSnapshot(GraphSpaceID spaceId, const std::string& name) { auto allHosts = ActiveHostsMan::getActiveHosts(kv_); storage::cpp2::CreateCPRequest req; req.set_space_id(spaceId); req.set_name(name); folly::Promise<Status> pro; auto f = pro.getFuture(); /** * Don't need retry. * Because existing checkpoint directories leads to fail again. **/ getResponse(allHosts, 0, std::move(req), [] (auto client, auto request) { return client->future_createCheckpoint(request); }, 0, std::move(pro), 0); return f; } folly::Future<Status> AdminClient::dropSnapshot(GraphSpaceID spaceId, const std::string& name, const std::vector<HostAddr>& hosts) { storage::cpp2::DropCPRequest req; req.set_space_id(spaceId); req.set_name(name); folly::Promise<Status> pro; auto f = pro.getFuture(); getResponse(hosts, 0, std::move(req), [] (auto client, auto request) { return client->future_dropCheckpoint(request); }, 0, std::move(pro), 1 /*The snapshot operation only needs to be retried twice*/); return f; } folly::Future<Status> AdminClient::blockingWrites(GraphSpaceID spaceId, storage::cpp2::EngineSignType sign) { auto allHosts = ActiveHostsMan::getActiveHosts(kv_); storage::cpp2::BlockingSignRequest req; req.set_space_id(spaceId); req.set_sign(sign); folly::Promise<Status> pro; auto f = pro.getFuture(); getResponse(allHosts, 0, std::move(req), [] (auto client, auto request) { return client->future_blockingWrites(request); }, 0, std::move(pro), 1 /*The blocking needs to be retried twice*/); return f; } } // namespace meta } // namespace nebula
; A033505: Expansion of 1/(1 - 3*x - x^2 + x^3). ; 1,3,10,32,103,331,1064,3420,10993,35335,113578,365076,1173471,3771911,12124128,38970824,125264689,402640763,1294216154,4160024536,13371648999,42980755379,138153890600,444070778180,1427385469761,4588073296863,14747534582170,47403291573612,152369336006143,489763765009871,1574257339462144,5060166447390160,16264992916622753,52280887857796275,168047490042621418,540158365069037776,1736241697391938471,5580835967202231771,17938591233929596008,57660367971599081324,185338859181524608209,595738354282243309943,1914893554056655456714,6155080157270685071876,19784395671586467362399,63593373617973431702359,204409436368236077397600,657037287051095196532760,2111927923903548235293521,6788411622393503825015723,21820125504032964513807930,70136860210588849131145992,225442294513406008082230183,724643618246773908864028611,2329236289043138885543170024,7486910190862784557411308500,24065323243384718648913066913,77353643631973801618607339215,248639343948443338947323776058,799206352233919099811665600476,2568904757018226836763713238271,8257281279340156271155481539231,26541542242804776550418492255488,85313003250736259085647245067424,274223270715673397536204745918529,881441273154951675143842990567523,2833234086929792163882086472553674,9106920263228654769253897662310016,29272553603460804796499936468916199,94091346986681276994871620596504939,302439674300275981011860900596121000,972137816284048415233954385915951740 mul $0,2 mov $1,1 mov $3,1 lpb $0 sub $0,2 add $2,$1 add $2,$1 add $1,$2 mov $4,$3 mov $3,$2 mov $2,$4 lpe mov $0,$1
#include <iostream> using namespace std; int main(){ int s,t,n; cin>>s>>t>>n; int walks[n+1]; int wt; for (int i = 0; i < n+1; i++){ cin>>wt; walks[i]=wt; } int buses[n]; int bt; for (int i = 0; i<n; i++){ cin>>bt; buses[i]=bt; } int intervals[n]; int it; for (int i = 0; i < n; i++){ cin>>it; intervals[i] = it; } int buscount = 0; bool started = false; bool walked = false; int time = 0; string can = "no"; while(time<=t) { if(time == s){// starts journey started = true; } if(started == false){ time++; } if(started){ if(walked == false){ time += walks[buscount]; // walks walked = true; } else{ time++; } if(time>t){ break; } if(buscount==n){ can = "yes"; break; } if(time%intervals[buscount]==0){ // if bus is ready time+=buses[buscount]; buscount++; walked = false; } } } cout<<can; return 0; }
; int cpm_bdos(unsigned int func,unsigned int arg) ; callee SECTION code_clib SECTION code_arch PUBLIC _cpm_bdos_callee EXTERN asm_cpm_bdos _cpm_bdos_callee: pop af pop bc pop de push af jp asm_cpm_bdos
; ; ZX IF1 & Microdrive functions ; ; Pick a sector with a given sector number ; ; int if1_load_sector (int drive, int sector, struct M_CHAN buffer); ; ; 4/5 drive: 1-8 for microdrive number ; 2/3 sector number ; 0/1 buffer ; ; $Id: if1_load_sector.asm,v 1.3 2016-07-01 22:08:20 dom Exp $ ; SECTION code_clib PUBLIC if1_load_sector PUBLIC _if1_load_sector EXTERN if1_rommap EXTERN mdvbuffer EXTERN if1_checkblock EXTERN if1_sect_read EXTERN MAKE_M EXTERN CLOSE_M EXTERN FETCH_H EXTERN MOTOR EXTERN RD_BUFF if1_load_sector: _if1_load_sector: push ix ;save callers ld ix,4 add ix,sp ld a,(ix+4) ld hl,-1 and a ; drive no. = 0 ? jp z,if_load_sector_exit ; yes, return -1 dec a cp 8 ; drive no. >8 ? jr nc,if_load_sector_exit ; yes, return -1 inc a ld (driveno),a ; drive number selected (d_str1) ld a,(ix+2) ; sector number ld (sector),a ld l,(ix+0) ; buffer ld h,(ix+1) ld (mdvbuffer),hl call if1_rommap ld hl,(driveno) ; drive number selected ld (5CD6h),hl ; d_str1 ld a,'M' ld (5CD9h),A ; l_str1 (device type = "M") ld hl,0 ; force to zero (otherwise it hangs) ld (5CDAh),hl ; n_str1 (lenght of file name) call MAKE_M ; Copy parameters from work buffer to actual channel ld a,(driveno) ; drive number selected ld (ix+19h),A ; CHDRIV ld a,(sector) ld (ix+0Dh),a ; CHREC res 0,(ix+18h) ; set CHFLAG to "read" mode xor a ld (if1_sect_read),a ; flag for "sector read" ld hl,04FBh ld (5CC9h),hl ; SECTOR ; *** scelta routine *** ld a,(driveno) ; drive number selected call MOTOR ; select drive motor IF !OLDIF1MOTOR jr nz,error_exit ENDIF nxtsector: call FETCH_H ; fetch header ld a,(ix+29h) ; HDNUMB: sector number cp (ix+0Dh) ; CHREC jr nz,nextrec ld de,001Bh add hl,de call RD_BUFF ; get buffer call if1_checkblock ; various checks cp 4 jr z,ok_close nextrec: call next_sector jr nz,nxtsector ; ld a,(flags) ; bit 2,a ; "verify mode" flag ; ; jp z,noverify ; ;; close, return with "VERIFICATION ERROR" code ; call CLOSE_M ; close file ; call 1 ; unpage ; ei ; ld hl,-2 ; verify error ; ret ;noverify: ld a,(if1_sect_read) ; flag for "sector read" or a jr z,sect_notfound sectread: call CLOSE_M ; close file call 1 ; unpage ei ld a,(sector) ld l,a ld h,0 ; Return the sector number if_load_sector_exit: pop ix ; restore callers ret sect_notfound: call CLOSE_M ; close file error_exit: call 1 ; unpage ei ld hl,-1 ; sector not found jr if_load_sector_exit ; close file, and go back to main ok_close: call 1 ; unpage ei ld a,(sector) ld l,a ld h,0 ; Return the sector number jr if_load_sector_exit ; Decrease sector counter and check if we reached zero next_sector: ld hl,(5CC9h) ; SECTOR dec hl ld (5CC9h),hl ld a,l or h ret SECTION bss_clib ;; various flags ;flags: defb 0 ; parameters and variables driveno: defb 0 sector: defb 0
//================================================================================================= /*! // \file src/mathtest/smatdvecmult/MCaV6a.cpp // \brief Source file for the MCaV6a sparse matrix/dense vector multiplication math test // // Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. 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. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT 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. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/CompressedMatrix.h> #include <blaze/math/StaticVector.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/smatdvecmult/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MCaV6a'..." << std::endl; using blazetest::mathtest::TypeA; try { // Matrix type definitions typedef blaze::CompressedMatrix<TypeA> MCa; typedef blaze::StaticVector<TypeA,6UL> V6a; // Creator type definitions typedef blazetest::Creator<MCa> CMCa; typedef blazetest::Creator<V6a> CV6a; // Running the tests for( size_t i=0UL; i<=8UL; ++i ) { for( size_t j=0UL; j<=i; ++j ) { RUN_SMATDVECMULT_OPERATION_TEST( CMCa( i, 6UL, j ), CV6a() ); } } } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during sparse matrix/dense vector multiplication:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
;****************************************************************************** ;* 36 point SSE-optimized IMDCT transform ;* Copyright (c) 2011 Vitor Sessak ;* ;* This file is part of Libav. ;* ;* Libav 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. ;* ;* Libav 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 Libav; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "libavutil/x86/x86inc.asm" %include "libavutil/x86/x86util.asm" SECTION_RODATA align 16 ps_mask: dd 0, ~0, ~0, ~0 ps_mask2: dd 0, ~0, 0, ~0 ps_mask3: dd 0, 0, 0, ~0 ps_mask4: dd 0, ~0, 0, 0 ps_val1: dd -0.5, -0.5, -0.8660254038, -0.8660254038 ps_val2: dd 1.0, 1.0, 0.8660254038, 0.8660254038 ps_val3: dd 0.1736481777, 0.1736481777, 0.3420201433, 0.3420201433 ps_val4: dd -0.7660444431, -0.7660444431, 0.8660254038, 0.8660254038 ps_val5: dd -0.9396926208, -0.9396926208, -0.9848077530, -0.9848077530 ps_val6: dd 0.5, 0.5, -0.6427876097, -0.6427876097 ps_val7: dd 1.0, 1.0, -0.6427876097, -0.6427876097 ps_p1p1m1m1: dd 0, 0, 0x80000000, 0x80000000 ps_p1m1p1m1: dd 0, 0x80000000, 0, 0x80000000 ps_cosh: dd 1.0, 0.50190991877167369479, 1.0, 5.73685662283492756461 dd 1.0, 0.51763809020504152469, 1.0, 1.93185165257813657349 dd 1.0, 0.55168895948124587824, -1.0, -1.18310079157624925896 dd 1.0, 0.61038729438072803416, -1.0, -0.87172339781054900991 dd 1.0, 0.70710678118654752439, 0.0, 0.0 ps_cosh_sse3: dd 1.0, -0.50190991877167369479, 1.0, -5.73685662283492756461 dd 1.0, -0.51763809020504152469, 1.0, -1.93185165257813657349 dd 1.0, -0.55168895948124587824, -1.0, 1.18310079157624925896 dd 1.0, -0.61038729438072803416, -1.0, 0.87172339781054900991 dd 1.0, 0.70710678118654752439, 0.0, 0.0 costabs: times 4 dd 0.98480773 times 4 dd 0.93969262 times 4 dd 0.86602539 times 4 dd -0.76604444 times 4 dd -0.64278764 times 4 dd 0.50000000 times 4 dd -0.50000000 times 4 dd -0.34202015 times 4 dd -0.17364818 times 4 dd 0.50190992 times 4 dd 0.51763808 times 4 dd 0.55168896 times 4 dd 0.61038726 times 4 dd 0.70710677 times 4 dd 0.87172341 times 4 dd 1.18310082 times 4 dd 1.93185163 times 4 dd 5.73685646 %define SBLIMIT 32 SECTION_TEXT %macro PSHUFD 3 %if cpuflag(sse2) && notcpuflag(avx) pshufd %1, %2, %3 %else shufps %1, %2, %2, %3 %endif %endmacro ; input %2={x1,x2,x3,x4}, %3={y1,y2,y3,y4} ; output %1={x3,x4,y1,y2} %macro BUILDINVHIGHLOW 3 %if cpuflag(avx) shufps %1, %2, %3, 0x4e %else movlhps %1, %3 movhlps %1, %2 %endif %endmacro ; input %2={x1,x2,x3,x4}, %3={y1,y2,y3,y4} ; output %1={x4,y1,y2,y3} %macro ROTLEFT 3 %if cpuflag(ssse3) palignr %1, %3, %2, 12 %else BUILDINVHIGHLOW %1, %2, %3 shufps %1, %1, %3, 0x99 %endif %endmacro %macro INVERTHL 2 %if cpuflag(sse2) PSHUFD %1, %2, 0x4e %else movhlps %1, %2 movlhps %1, %2 %endif %endmacro %macro BUTTERF 3 INVERTHL %2, %1 xorps %1, [ps_p1p1m1m1] addps %1, %2 %if cpuflag(sse3) mulps %1, %1, [ps_cosh_sse3 + %3] PSHUFD %2, %1, 0xb1 addsubps %1, %1, %2 %else mulps %1, [ps_cosh + %3] PSHUFD %2, %1, 0xb1 xorps %1, [ps_p1m1p1m1] addps %1, %2 %endif %endmacro %macro STORE 4 movhlps %2, %1 movss [%3 ], %1 movss [%3 + 2*%4], %2 shufps %1, %1, 0xb1 movss [%3 + %4], %1 movhlps %2, %1 movss [%3 + 3*%4], %2 %endmacro %macro LOAD 4 movlps %1, [%3 ] movhps %1, [%3 + %4] movlps %2, [%3 + 2*%4] movhps %2, [%3 + 3*%4] shufps %1, %2, 0x88 %endmacro %macro LOADA64 2 %if cpuflag(avx) movu %1, [%2] %else movlps %1, [%2] movhps %1, [%2 + 8] %endif %endmacro %macro DEFINE_IMDCT 0 cglobal imdct36_float, 4,4,9, out, buf, in, win ; for(i=17;i>=1;i--) in[i] += in[i-1]; LOADA64 m0, inq LOADA64 m1, inq + 16 ROTLEFT m5, m0, m1 PSHUFD m6, m0, 0x93 andps m6, m6, [ps_mask] addps m0, m0, m6 LOADA64 m2, inq + 32 ROTLEFT m7, m1, m2 addps m1, m1, m5 LOADA64 m3, inq + 48 ROTLEFT m5, m2, m3 xorps m4, m4, m4 movlps m4, [inq+64] BUILDINVHIGHLOW m6, m3, m4 shufps m6, m6, m4, 0xa9 addps m4, m4, m6 addps m2, m2, m7 addps m3, m3, m5 ; for(i=17;i>=3;i-=2) in[i] += in[i-2]; movlhps m5, m5, m0 andps m5, m5, [ps_mask3] BUILDINVHIGHLOW m7, m0, m1 andps m7, m7, [ps_mask2] addps m0, m0, m5 BUILDINVHIGHLOW m6, m1, m2 andps m6, m6, [ps_mask2] addps m1, m1, m7 BUILDINVHIGHLOW m7, m2, m3 andps m7, m7, [ps_mask2] addps m2, m2, m6 movhlps m6, m6, m3 andps m6, m6, [ps_mask4] addps m3, m3, m7 addps m4, m4, m6 ; Populate tmp[] movlhps m6, m1, m5 ; zero out high values subps m6, m6, m4 subps m5, m0, m3 %ifdef ARCH_X86_64 SWAP m5, m8 %endif mulps m7, m2, [ps_val1] %ifdef ARCH_X86_64 mulps m5, m8, [ps_val2] %else mulps m5, m5, [ps_val2] %endif addps m7, m7, m5 mulps m5, m6, [ps_val1] subps m7, m7, m5 %ifdef ARCH_X86_64 SWAP m5, m8 %else subps m5, m0, m3 %endif subps m5, m5, m6 addps m5, m5, m2 shufps m6, m4, m3, 0xe4 subps m6, m6, m2 mulps m6, m6, [ps_val3] addps m4, m4, m1 mulps m4, m4, [ps_val4] shufps m1, m1, m0, 0xe4 addps m1, m1, m2 mulps m1, m1, [ps_val5] mulps m3, m3, [ps_val6] mulps m0, m0, [ps_val7] addps m0, m0, m3 xorps m2, m1, [ps_p1p1m1m1] subps m2, m2, m4 addps m2, m2, m0 addps m3, m4, m0 subps m3, m3, m6 xorps m3, m3, [ps_p1p1m1m1] shufps m0, m0, m4, 0xe4 subps m0, m0, m1 addps m0, m0, m6 BUILDINVHIGHLOW m4, m2, m3 shufps m3, m3, m2, 0x4e ; we have tmp = {SwAPLH(m0), SwAPLH(m7), m3, m4, m5} BUTTERF m0, m1, 0 BUTTERF m7, m2, 16 BUTTERF m3, m6, 32 BUTTERF m4, m1, 48 mulps m5, m5, [ps_cosh + 64] PSHUFD m1, m5, 0xe1 xorps m5, m5, [ps_p1m1p1m1] addps m5, m5, m1 ; permutates: ; m0 0 1 2 3 => 2 6 10 14 m1 ; m7 4 5 6 7 => 3 7 11 15 m2 ; m3 8 9 10 11 => 17 13 9 5 m3 ; m4 12 13 14 15 => 16 12 8 4 m5 ; m5 16 17 xx xx => 0 1 xx xx m0 unpckhps m1, m0, m7 unpckhps m6, m3, m4 movhlps m2, m6, m1 movlhps m1, m1, m6 unpcklps m5, m5, m4 unpcklps m3, m3, m7 movhlps m4, m3, m5 movlhps m5, m5, m3 SWAP m4, m3 ; permutation done PSHUFD m6, m2, 0xb1 movss m4, [bufq + 4*68] movss m7, [bufq + 4*64] unpcklps m7, m7, m4 mulps m6, m6, [winq + 16*4] addps m6, m6, m7 movss [outq + 64*SBLIMIT], m6 shufps m6, m6, m6, 0xb1 movss [outq + 68*SBLIMIT], m6 mulps m6, m3, [winq + 4*4] LOAD m4, m7, bufq + 4*16, 16 addps m6, m6, m4 STORE m6, m7, outq + 16*SBLIMIT, 4*SBLIMIT shufps m4, m0, m3, 0xb5 mulps m4, m4, [winq + 8*4] LOAD m7, m6, bufq + 4*32, 16 addps m4, m4, m7 STORE m4, m6, outq + 32*SBLIMIT, 4*SBLIMIT shufps m3, m3, m2, 0xb1 mulps m3, m3, [winq + 12*4] LOAD m7, m6, bufq + 4*48, 16 addps m3, m3, m7 STORE m3, m7, outq + 48*SBLIMIT, 4*SBLIMIT mulps m2, m2, [winq] LOAD m6, m7, bufq, 16 addps m2, m2, m6 STORE m2, m7, outq, 4*SBLIMIT mulps m4, m1, [winq + 20*4] STORE m4, m7, bufq, 16 mulps m3, m5, [winq + 24*4] STORE m3, m7, bufq + 4*16, 16 shufps m0, m0, m5, 0xb0 mulps m0, m0, [winq + 28*4] STORE m0, m7, bufq + 4*32, 16 shufps m5, m5, m1, 0xb1 mulps m5, m5, [winq + 32*4] STORE m5, m7, bufq + 4*48, 16 shufps m1, m1, m1, 0xb1 mulps m1, m1, [winq + 36*4] movss [bufq + 4*64], m1 shufps m1, m1, 0xb1 movss [bufq + 4*68], m1 RET %endmacro INIT_XMM sse DEFINE_IMDCT INIT_XMM sse2 DEFINE_IMDCT INIT_XMM sse3 DEFINE_IMDCT INIT_XMM ssse3 DEFINE_IMDCT %ifdef HAVE_AVX INIT_XMM avx DEFINE_IMDCT %endif INIT_XMM sse %ifdef ARCH_X86_64 %define SPILL SWAP %define UNSPILL SWAP %define SPILLED(x) m %+ x %else %define SPILLED(x) [tmpq+(x-8)*16 + 32*4] %macro SPILL 2 ; xmm#, mempos movaps SPILLED(%2), m%1 %endmacro %macro UNSPILL 2 movaps m%1, SPILLED(%2) %endmacro %endif %macro DEFINE_FOUR_IMDCT 0 cglobal four_imdct36_float, 5,5,8, out, buf, in, win, tmp movlps m0, [inq+64] movhps m0, [inq+64 + 72] movlps m3, [inq+64 + 2*72] movhps m3, [inq+64 + 3*72] shufps m5, m0, m3, 0xdd shufps m0, m0, m3, 0x88 mova m1, [inq+48] movu m6, [inq+48 + 72] mova m7, [inq+48 + 2*72] movu m3, [inq+48 + 3*72] TRANSPOSE4x4PS 1, 6, 7, 3, 4 addps m4, m6, m7 mova [tmpq+4*28], m4 addps m7, m3 addps m6, m1 addps m3, m0 addps m0, m5 addps m0, m7 addps m7, m6 mova [tmpq+4*12], m7 SPILL 3, 12 mova m4, [inq+32] movu m5, [inq+32 + 72] mova m2, [inq+32 + 2*72] movu m7, [inq+32 + 3*72] TRANSPOSE4x4PS 4, 5, 2, 7, 3 addps m1, m7 SPILL 1, 11 addps m3, m5, m2 SPILL 3, 13 addps m7, m2 addps m5, m4 addps m6, m7 mova [tmpq], m6 addps m7, m5 mova [tmpq+4*16], m7 mova m2, [inq+16] movu m7, [inq+16 + 72] mova m1, [inq+16 + 2*72] movu m6, [inq+16 + 3*72] TRANSPOSE4x4PS 2, 7, 1, 6, 3 addps m4, m6 addps m6, m1 addps m1, m7 addps m7, m2 addps m5, m6 SPILL 5, 15 addps m6, m7 mulps m6, [costabs + 16*2] mova [tmpq+4*8], m6 SPILL 1, 10 SPILL 0, 14 mova m1, [inq] movu m6, [inq + 72] mova m3, [inq + 2*72] movu m5, [inq + 3*72] TRANSPOSE4x4PS 1, 6, 3, 5, 0 addps m2, m5 addps m5, m3 addps m7, m5 addps m3, m6 addps m6, m1 SPILL 7, 8 addps m5, m6 SPILL 6, 9 addps m6, m4, SPILLED(12) subps m6, m2 UNSPILL 7, 11 SPILL 5, 11 subps m5, m1, m7 mulps m7, [costabs + 16*5] addps m7, m1 mulps m0, m6, [costabs + 16*6] addps m0, m5 mova [tmpq+4*24], m0 addps m6, m5 mova [tmpq+4*4], m6 addps m6, m4, m2 mulps m6, [costabs + 16*1] subps m4, SPILLED(12) mulps m4, [costabs + 16*8] addps m2, SPILLED(12) mulps m2, [costabs + 16*3] subps m5, m7, m6 subps m5, m2 addps m6, m7 addps m6, m4 addps m7, m2 subps m7, m4 mova [tmpq+4*20], m7 mova m2, [tmpq+4*28] mova [tmpq+4*28], m5 UNSPILL 7, 13 subps m5, m7, m2 mulps m5, [costabs + 16*7] UNSPILL 1, 10 mulps m1, [costabs + 16*2] addps m4, m3, m2 mulps m4, [costabs + 16*4] addps m2, m7 addps m7, m3 mulps m7, [costabs] subps m3, m2 mulps m3, [costabs + 16*2] addps m2, m7, m5 addps m2, m1 SPILL 2, 10 addps m7, m4 subps m7, m1 SPILL 7, 12 subps m5, m4 subps m5, m1 UNSPILL 0, 14 SPILL 5, 13 addps m1, m0, SPILLED(15) subps m1, SPILLED(8) mova m4, [costabs + 16*5] mulps m4, [tmpq] UNSPILL 2, 9 addps m4, m2 subps m2, [tmpq] mulps m5, m1, [costabs + 16*6] addps m5, m2 SPILL 5, 9 addps m2, m1 SPILL 2, 14 UNSPILL 5, 15 subps m7, m5, m0 addps m5, SPILLED(8) mulps m5, [costabs + 16*1] mulps m7, [costabs + 16*8] addps m0, SPILLED(8) mulps m0, [costabs + 16*3] subps m2, m4, m5 subps m2, m0 SPILL 2, 15 addps m5, m4 addps m5, m7 addps m4, m0 subps m4, m7 SPILL 4, 8 mova m7, [tmpq+4*16] mova m2, [tmpq+4*12] addps m0, m7, m2 subps m0, SPILLED(11) mulps m0, [costabs + 16*2] addps m4, m7, SPILLED(11) mulps m4, [costabs] subps m7, m2 mulps m7, [costabs + 16*7] addps m2, SPILLED(11) mulps m2, [costabs + 16*4] addps m1, m7, [tmpq+4*8] addps m1, m4 addps m4, m2 subps m4, [tmpq+4*8] SPILL 4, 11 subps m7, m2 subps m7, [tmpq+4*8] addps m4, m6, SPILLED(10) subps m6, SPILLED(10) addps m2, m5, m1 mulps m2, [costabs + 16*9] subps m5, m1 mulps m5, [costabs + 16*17] subps m1, m4, m2 addps m4, m2 mulps m2, m1, [winq+4*36] addps m2, [bufq+4*36] mova [outq+1152], m2 mulps m1, [winq+4*32] addps m1, [bufq+4*32] mova [outq+1024], m1 mulps m1, m4, [winq+4*116] mova [bufq+4*36], m1 mulps m4, [winq+4*112] mova [bufq+4*32], m4 addps m2, m6, m5 subps m6, m5 mulps m1, m6, [winq+4*68] addps m1, [bufq+4*68] mova [outq+2176], m1 mulps m6, [winq] addps m6, [bufq] mova [outq], m6 mulps m1, m2, [winq+4*148] mova [bufq+4*68], m1 mulps m2, [winq+4*80] mova [bufq], m2 addps m5, m3, [tmpq+4*24] mova m2, [tmpq+4*24] subps m2, m3 mova m1, SPILLED(9) subps m1, m0 mulps m1, [costabs + 16*10] addps m0, SPILLED(9) mulps m0, [costabs + 16*16] addps m6, m5, m1 subps m5, m1 mulps m3, m5, [winq+4*40] addps m3, [bufq+4*40] mova [outq+1280], m3 mulps m5, [winq+4*28] addps m5, [bufq+4*28] mova [outq+896], m5 mulps m1, m6, [winq+4*120] mova [bufq+4*40], m1 mulps m6, [winq+4*108] mova [bufq+4*28], m6 addps m1, m2, m0 subps m2, m0 mulps m5, m2, [winq+4*64] addps m5, [bufq+4*64] mova [outq+2048], m5 mulps m2, [winq+4*4] addps m2, [bufq+4*4] mova [outq+128], m2 mulps m0, m1, [winq+4*144] mova [bufq+4*64], m0 mulps m1, [winq+4*84] mova [bufq+4*4], m1 mova m1, [tmpq+4*28] mova m5, m1 addps m1, SPILLED(13) subps m5, SPILLED(13) UNSPILL 3, 15 addps m2, m7, m3 mulps m2, [costabs + 16*11] subps m3, m7 mulps m3, [costabs + 16*15] addps m0, m2, m1 subps m1, m2 SWAP m0, m2 mulps m6, m1, [winq+4*44] addps m6, [bufq+4*44] mova [outq+1408], m6 mulps m1, [winq+4*24] addps m1, [bufq+4*24] mova [outq+768], m1 mulps m0, m2, [winq+4*124] mova [bufq+4*44], m0 mulps m2, [winq+4*104] mova [bufq+4*24], m2 addps m0, m5, m3 subps m5, m3 mulps m1, m5, [winq+4*60] addps m1, [bufq+4*60] mova [outq+1920], m1 mulps m5, [winq+4*8] addps m5, [bufq+4*8] mova [outq+256], m5 mulps m1, m0, [winq+4*140] mova [bufq+4*60], m1 mulps m0, [winq+4*88] mova [bufq+4*8], m0 mova m1, [tmpq+4*20] addps m1, SPILLED(12) mova m2, [tmpq+4*20] subps m2, SPILLED(12) UNSPILL 7, 8 subps m0, m7, SPILLED(11) addps m7, SPILLED(11) mulps m4, m7, [costabs + 16*12] mulps m0, [costabs + 16*14] addps m5, m1, m4 subps m1, m4 mulps m7, m1, [winq+4*48] addps m7, [bufq+4*48] mova [outq+1536], m7 mulps m1, [winq+4*20] addps m1, [bufq+4*20] mova [outq+640], m1 mulps m1, m5, [winq+4*128] mova [bufq+4*48], m1 mulps m5, [winq+4*100] mova [bufq+4*20], m5 addps m6, m2, m0 subps m2, m0 mulps m1, m2, [winq+4*56] addps m1, [bufq+4*56] mova [outq+1792], m1 mulps m2, [winq+4*12] addps m2, [bufq+4*12] mova [outq+384], m2 mulps m0, m6, [winq+4*136] mova [bufq+4*56], m0 mulps m6, [winq+4*92] mova [bufq+4*12], m6 UNSPILL 0, 14 mulps m0, [costabs + 16*13] mova m3, [tmpq+4*4] addps m2, m0, m3 subps m3, m0 mulps m0, m3, [winq+4*52] addps m0, [bufq+4*52] mova [outq+1664], m0 mulps m3, [winq+4*16] addps m3, [bufq+4*16] mova [outq+512], m3 mulps m0, m2, [winq+4*132] mova [bufq+4*52], m0 mulps m2, [winq+4*96] mova [bufq+4*16], m2 RET %endmacro INIT_XMM sse DEFINE_FOUR_IMDCT %ifdef HAVE_AVX INIT_XMM avx DEFINE_FOUR_IMDCT %endif
; A102715: Triangle read by rows: T(n,k) is phi(binomial(n,k)), where phi is Euler's totient function (0 <= k <= n). ; 1,1,1,1,1,1,1,2,2,1,1,2,2,2,1,1,4,4,4,4,1,1,2,8,8,8,2,1,1,6,12,24,24,12,6,1,1,4,12,24,24,24,12,4,1,1,6,12,24,36,36,24,12,6,1,1,4,24,32,48,72,48,32,24,4,1,1,10,40,80,80,120,120,80,80,40,10,1,1,4,20,80,240,240 cal $0,132044 ; Triangle T(n,k) = binomial(n, k) - 1 with T(n,0) = T(n,n) = 1, read by rows. cal $0,10 ; Euler totient function phi(n): count numbers <= n and prime to n. add $0,2 mov $1,$0 mov $0,9 mul $0,$1 mov $1,$0 sub $1,27 div $1,9 add $1,1
/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "Potamos.h" #include "AvinationUtils.h" const float ONE_OVER_U16_MAX = 1.0f / (float)USHRT_MAX; AvinationUtils::AvinationUtils() { } AvinationUtils::~AvinationUtils() { } float AvinationUtils::uint16tofloat(uint16_t val, float lower, float upper) { float fval = (float)val * ONE_OVER_U16_MAX; float delta = upper - lower; fval *= delta; fval += lower; float maxError = delta * ONE_OVER_U16_MAX; if (fabs(fval) < maxError) fval = 0.0f; return fval; }
DOSSEG .MODEL small .CODE salc macro db 0d6h endm PUBLIC _cga_draw_hline _cga_draw_hline PROC ARG buff:DWORD, x0:WORD, x1:WORD, y:WORD, colour:BYTE ; draw a line from (x0, y) - (x1, y) including endpoints in the given colour (0-3) push bp mov bp, sp push di les di, buff ; get buffer address in es:di mov ax, [y] ; set dx to offset of CGA bank (odd/even) shr ax, 1 sbb dx, dx and dx, 8192 shl ax, 1 ; set di to offset address of line y shl ax, 1 shl ax, 1 shl ax, 1 add dx, ax shl ax, 1 shl ax, 1 add dx, ax add di, dx mov ax, [x0] ; set bh to left mask based on x0 mod 2 shr ax, 1 sbb bh, bh not bh or bh, 0fh mov dx, [x1] ; set bl to right mask based on x1 mod 2 shr dx, 1 sbb bl, bl or bl, 0f0h add di, ax ; add x0/2 to offset sub dx, ax ; set dx to x1/2 - x0/2 (final offset - initial offset) mov ah, [colour] ; put solid colour in ah shr ah, 1 salc and al, 055h shr ah, 1 sbb ah, ah and ah, 0aah add ah, al mov al, ah ; copy colour in al dec dl ; if first and last pixels are not in the same byte jns hline_long_line and bl, bh ; compute overlapped mask and put masked colour in al and al, bl not bl and bl, es:[di] ; draw pixels or al, bl stosb pop di pop bp ret hline_long_line: and al, bh ; put left hand mask in bh and colour in al not bh and bh, es:[di] ; draw pixels on left side of line or al, bh stosb mov al, ah ; draw full colour bytes mov cx, dx shr cx, 1 jnc hline_even_iter stosb hline_even_iter: rep stosw mov al, ah ; put right hand mask in bl and colour in al and al, bl not bl and bl, es:[di] ; draw right hand pixels or al, bl stosb pop di pop bp ret _cga_draw_hline ENDP END
; A157130: Partial sums of A128201. ; 1,4,8,13,20,29,40,53,68,84,101,120,141,164,189,216,245,276,309,344,380,417,456,497,540,585,632,681,732,785,840,897,956,1017,1080,1144,1209,1276,1345,1416,1489,1564,1641,1720,1801,1884,1969,2056,2145,2236,2329 lpb $0 mov $2,$0 sub $0,1 seq $2,128201 ; Union of positive squares and the odd numbers. add $1,$2 lpe add $1,1 mov $0,$1
#ifndef _RECORD_LIST #define _RECORD_LIST #include "record.hpp" typedef struct RecordNode* RecordNodePtr; struct RecordNode { RecordNodePtr next; Record* item; RecordNode(RecordNodePtr _next, Record* _item) { next = _next; item = _item; } ~RecordNode(void) { delete item; } }; class RecordList { private: RecordNodePtr head; uint64_t size; void _remove(size_t pos); public: RecordList(void); ~RecordList(void); void insert(Record* item); bool in(const std::string& _id); Record* get(const std::string& _id); void print(void); }; #endif
#include <iostream> #include <sstream> #include <string> #include <ctime> #include <cstdio> #include <opencv2/core.hpp> #include <opencv2/core/utility.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/calib3d.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/videoio.hpp> #include <opencv2/highgui.hpp> using namespace cv; using namespace std; class Settings { public: Settings() : goodInput(false) {} enum Pattern { NOT_EXISTING, CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID }; enum InputType { INVALID, CAMERA, VIDEO_FILE, IMAGE_LIST }; void write(FileStorage& fs) const //Write serialization for this class { fs << "{" << "BoardSize_Width" << boardSize.width << "BoardSize_Height" << boardSize.height << "Square_Size" << squareSize << "Calibrate_Pattern" << patternToUse << "Calibrate_NrOfFrameToUse" << nrFrames << "Calibrate_FixAspectRatio" << aspectRatio << "Calibrate_AssumeZeroTangentialDistortion" << calibZeroTangentDist << "Calibrate_FixPrincipalPointAtTheCenter" << calibFixPrincipalPoint << "Write_DetectedFeaturePoints" << writePoints << "Write_extrinsicParameters" << writeExtrinsics << "Write_gridPoints" << writeGrid << "Write_outputFileName" << outputFileName << "Show_UndistortedImage" << showUndistorsed << "Input_FlipAroundHorizontalAxis" << flipVertical << "Input_Delay" << delay << "Input" << input << "}"; } void read(const FileNode& node) //Read serialization for this class { node["BoardSize_Width" ] >> boardSize.width; node["BoardSize_Height"] >> boardSize.height; node["Calibrate_Pattern"] >> patternToUse; node["Square_Size"] >> squareSize; node["Calibrate_NrOfFrameToUse"] >> nrFrames; node["Calibrate_FixAspectRatio"] >> aspectRatio; node["Write_DetectedFeaturePoints"] >> writePoints; node["Write_extrinsicParameters"] >> writeExtrinsics; node["Write_gridPoints"] >> writeGrid; node["Write_outputFileName"] >> outputFileName; node["Calibrate_AssumeZeroTangentialDistortion"] >> calibZeroTangentDist; node["Calibrate_FixPrincipalPointAtTheCenter"] >> calibFixPrincipalPoint; node["Calibrate_UseFisheyeModel"] >> useFisheye; node["Input_FlipAroundHorizontalAxis"] >> flipVertical; node["Show_UndistortedImage"] >> showUndistorsed; node["Input"] >> input; node["Input_Delay"] >> delay; node["Fix_K1"] >> fixK1; node["Fix_K2"] >> fixK2; node["Fix_K3"] >> fixK3; node["Fix_K4"] >> fixK4; node["Fix_K5"] >> fixK5; validate(); } void validate() { goodInput = true; if (boardSize.width <= 0 || boardSize.height <= 0) { cerr << "Invalid Board size: " << boardSize.width << " " << boardSize.height << endl; goodInput = false; } if (squareSize <= 10e-6) { cerr << "Invalid square size " << squareSize << endl; goodInput = false; } if (nrFrames <= 0) { cerr << "Invalid number of frames " << nrFrames << endl; goodInput = false; } if (input.empty()) // Check for valid input inputType = INVALID; else { if (input[0] >= '0' && input[0] <= '9') { stringstream ss(input); ss >> cameraID; inputType = CAMERA; } else { if (isListOfImages(input) && readStringList(input, imageList)) { inputType = IMAGE_LIST; nrFrames = (nrFrames < (int)imageList.size()) ? nrFrames : (int)imageList.size(); } else inputType = VIDEO_FILE; } if (inputType == CAMERA) inputCapture.open(cameraID); if (inputType == VIDEO_FILE) inputCapture.open(input); if (inputType != IMAGE_LIST && !inputCapture.isOpened()) inputType = INVALID; } if (inputType == INVALID) { cerr << " Input does not exist: " << input; goodInput = false; } flag = 0; if(calibFixPrincipalPoint) flag |= CALIB_FIX_PRINCIPAL_POINT; if(calibZeroTangentDist) flag |= CALIB_ZERO_TANGENT_DIST; if(aspectRatio) flag |= CALIB_FIX_ASPECT_RATIO; if(fixK1) flag |= CALIB_FIX_K1; if(fixK2) flag |= CALIB_FIX_K2; if(fixK3) flag |= CALIB_FIX_K3; if(fixK4) flag |= CALIB_FIX_K4; if(fixK5) flag |= CALIB_FIX_K5; if (useFisheye) { // the fisheye model has its own enum, so overwrite the flags flag = fisheye::CALIB_FIX_SKEW | fisheye::CALIB_RECOMPUTE_EXTRINSIC; if(fixK1) flag |= fisheye::CALIB_FIX_K1; if(fixK2) flag |= fisheye::CALIB_FIX_K2; if(fixK3) flag |= fisheye::CALIB_FIX_K3; if(fixK4) flag |= fisheye::CALIB_FIX_K4; if (calibFixPrincipalPoint) flag |= fisheye::CALIB_FIX_PRINCIPAL_POINT; } calibrationPattern = NOT_EXISTING; if (!patternToUse.compare("CHESSBOARD")) calibrationPattern = CHESSBOARD; if (!patternToUse.compare("CIRCLES_GRID")) calibrationPattern = CIRCLES_GRID; if (!patternToUse.compare("ASYMMETRIC_CIRCLES_GRID")) calibrationPattern = ASYMMETRIC_CIRCLES_GRID; if (calibrationPattern == NOT_EXISTING) { cerr << " Camera calibration mode does not exist: " << patternToUse << endl; goodInput = false; } atImageList = 0; } Mat nextImage() { Mat result; if( inputCapture.isOpened() ) { Mat view0; inputCapture >> view0; view0.copyTo(result); } else if( atImageList < imageList.size() ) result = imread(imageList[atImageList++], IMREAD_COLOR); return result; } static bool readStringList( const string& filename, vector<string>& l ) { l.clear(); FileStorage fs(filename, FileStorage::READ); if( !fs.isOpened() ) return false; FileNode n = fs.getFirstTopLevelNode(); if( n.type() != FileNode::SEQ ) return false; FileNodeIterator it = n.begin(), it_end = n.end(); for( ; it != it_end; ++it ) l.push_back((string)*it); return true; } static bool isListOfImages( const string& filename) { string s(filename); // Look for file extension if( s.find(".xml") == string::npos && s.find(".yaml") == string::npos && s.find(".yml") == string::npos ) return false; else return true; } public: Size boardSize; // The size of the board -> Number of items by width and height Pattern calibrationPattern; // One of the Chessboard, circles, or asymmetric circle pattern float squareSize; // The size of a square in your defined unit (point, millimeter,etc). int nrFrames; // The number of frames to use from the input for calibration float aspectRatio; // The aspect ratio int delay; // In case of a video input bool writePoints; // Write detected feature points bool writeExtrinsics; // Write extrinsic parameters bool writeGrid; // Write refined 3D target grid points bool calibZeroTangentDist; // Assume zero tangential distortion bool calibFixPrincipalPoint; // Fix the principal point at the center bool flipVertical; // Flip the captured images around the horizontal axis string outputFileName; // The name of the file where to write bool showUndistorsed; // Show undistorted images after calibration string input; // The input -> bool useFisheye; // use fisheye camera model for calibration bool fixK1; // fix K1 distortion coefficient bool fixK2; // fix K2 distortion coefficient bool fixK3; // fix K3 distortion coefficient bool fixK4; // fix K4 distortion coefficient bool fixK5; // fix K5 distortion coefficient int cameraID; vector<string> imageList; size_t atImageList; VideoCapture inputCapture; InputType inputType; bool goodInput; int flag; private: string patternToUse; }; static inline void read(const FileNode& node, Settings& x, const Settings& default_value = Settings()) { if(node.empty()) x = default_value; else x.read(node); } enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 }; bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector<vector<Point2f> > imagePoints, float grid_width, bool release_object); int main(int argc, char* argv[]) { const String keys = "{help h usage ? | | print this message }" "{@settings |default.xml| input setting file }" "{d | | actual distance between top-left and top-right corners of " "the calibration grid }" "{winSize | 11 | Half of search window for cornerSubPix }"; CommandLineParser parser(argc, argv, keys); parser.about("This is a camera calibration sample.\n" "Usage: camera_calibration [configuration_file -- default ./default.xml]\n" "Near the sample file you'll find the configuration file, which has detailed help of " "how to edit it. It may be any OpenCV supported file format XML/YAML."); if (!parser.check()) { parser.printErrors(); return 0; } if (parser.has("help")) { parser.printMessage(); return 0; } //! [file_read] Settings s; const string inputSettingsFile = parser.get<string>(0); FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings if (!fs.isOpened()) { cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl; parser.printMessage(); return -1; } fs["Settings"] >> s; fs.release(); // close Settings file //! [file_read] //FileStorage fout("settings.yml", FileStorage::WRITE); // write config as YAML //fout << "Settings" << s; if (!s.goodInput) { cout << "Invalid input detected. Application stopping. " << endl; return -1; } int winSize = parser.get<int>("winSize"); float grid_width = s.squareSize * (s.boardSize.width - 1); bool release_object = false; if (parser.has("d")) { grid_width = parser.get<float>("d"); release_object = true; } vector<vector<Point2f> > imagePoints; Mat cameraMatrix, distCoeffs; Size imageSize; int mode = s.inputType == Settings::IMAGE_LIST ? CAPTURING : DETECTION; clock_t prevTimestamp = 0; const Scalar RED(0,0,255), GREEN(0,255,0); const char ESC_KEY = 27; //! [get_input] for(;;) { Mat view; bool blinkOutput = false; view = s.nextImage(); //----- If no more image, or got enough, then stop calibration and show result ------------- if( mode == CAPTURING && imagePoints.size() >= (size_t)s.nrFrames ) { if(runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width, release_object)) mode = CALIBRATED; else mode = DETECTION; } if(view.empty()) // If there are no more images stop the loop { // if calibration threshold was not reached yet, calibrate now if( mode != CALIBRATED && !imagePoints.empty() ) runCalibrationAndSave(s, imageSize, cameraMatrix, distCoeffs, imagePoints, grid_width, release_object); break; } //! [get_input] imageSize = view.size(); // Format input image. if( s.flipVertical ) flip( view, view, 0 ); //! [find_pattern] vector<Point2f> pointBuf; bool found; int chessBoardFlags = CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE; if(!s.useFisheye) { // fast check erroneously fails with high distortions like fisheye chessBoardFlags |= CALIB_CB_FAST_CHECK; } switch( s.calibrationPattern ) // Find feature points on the input format { case Settings::CHESSBOARD: found = findChessboardCorners( view, s.boardSize, pointBuf, chessBoardFlags); break; case Settings::CIRCLES_GRID: found = findCirclesGrid( view, s.boardSize, pointBuf ); break; case Settings::ASYMMETRIC_CIRCLES_GRID: found = findCirclesGrid( view, s.boardSize, pointBuf, CALIB_CB_ASYMMETRIC_GRID ); break; default: found = false; break; } //! [find_pattern] //! [pattern_found] if ( found) // If done with success, { // improve the found corners' coordinate accuracy for chessboard if( s.calibrationPattern == Settings::CHESSBOARD) { Mat viewGray; cvtColor(view, viewGray, COLOR_BGR2GRAY); cornerSubPix( viewGray, pointBuf, Size(winSize,winSize), Size(-1,-1), TermCriteria( TermCriteria::EPS+TermCriteria::COUNT, 30, 0.0001 )); } if( mode == CAPTURING && // For camera only take new samples after delay time (!s.inputCapture.isOpened() || clock() - prevTimestamp > s.delay*1e-3*CLOCKS_PER_SEC) ) { imagePoints.push_back(pointBuf); prevTimestamp = clock(); blinkOutput = s.inputCapture.isOpened(); } // Draw the corners. drawChessboardCorners( view, s.boardSize, Mat(pointBuf), found ); } //! [pattern_found] //----------------------------- Output Text ------------------------------------------------ //! [output_text] string msg = (mode == CAPTURING) ? "100/100" : mode == CALIBRATED ? "Calibrated" : "Press 'g' to start"; int baseLine = 0; Size textSize = getTextSize(msg, 1, 1, 1, &baseLine); Point textOrigin(view.cols - 2*textSize.width - 10, view.rows - 2*baseLine - 10); if( mode == CAPTURING ) { if(s.showUndistorsed) msg = format( "%d/%d Undist", (int)imagePoints.size(), s.nrFrames ); else msg = format( "%d/%d", (int)imagePoints.size(), s.nrFrames ); } putText( view, msg, textOrigin, 1, 1, mode == CALIBRATED ? GREEN : RED); if( blinkOutput ) bitwise_not(view, view); //! [output_text] //------------------------- Video capture output undistorted ------------------------------ //! [output_undistorted] if( mode == CALIBRATED && s.showUndistorsed ) { Mat temp = view.clone(); if (s.useFisheye) { Mat newCamMat; fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCamMat, 1); cv::fisheye::undistortImage(temp, view, cameraMatrix, distCoeffs, newCamMat); } else undistort(temp, view, cameraMatrix, distCoeffs); } //! [output_undistorted] //------------------------------ Show image and check for input commands ------------------- //! [await_input] imshow("Image View", view); char key = (char)waitKey(s.inputCapture.isOpened() ? 50 : s.delay); if( key == ESC_KEY ) break; if( key == 'u' && mode == CALIBRATED ) s.showUndistorsed = !s.showUndistorsed; if( s.inputCapture.isOpened() && key == 'g' ) { mode = CAPTURING; imagePoints.clear(); } //! [await_input] } // -----------------------Show the undistorted image for the image list ------------------------ //! [show_results] if( s.inputType == Settings::IMAGE_LIST && s.showUndistorsed && !cameraMatrix.empty()) { Mat view, rview, map1, map2; if (s.useFisheye) { Mat newCamMat; fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCamMat, 1); fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, Matx33d::eye(), newCamMat, imageSize, CV_16SC2, map1, map2); } else { initUndistortRectifyMap( cameraMatrix, distCoeffs, Mat(), getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0), imageSize, CV_16SC2, map1, map2); } for(size_t i = 0; i < s.imageList.size(); i++ ) { view = imread(s.imageList[i], IMREAD_COLOR); if(view.empty()) continue; remap(view, rview, map1, map2, INTER_LINEAR); imshow("Image View", rview); char c = (char)waitKey(); if( c == ESC_KEY || c == 'q' || c == 'Q' ) break; } } //! [show_results] return 0; } //! [compute_errors] static double computeReprojectionErrors( const vector<vector<Point3f> >& objectPoints, const vector<vector<Point2f> >& imagePoints, const vector<Mat>& rvecs, const vector<Mat>& tvecs, const Mat& cameraMatrix , const Mat& distCoeffs, vector<float>& perViewErrors, bool fisheye) { vector<Point2f> imagePoints2; size_t totalPoints = 0; double totalErr = 0, err; perViewErrors.resize(objectPoints.size()); for(size_t i = 0; i < objectPoints.size(); ++i ) { if (fisheye) { fisheye::projectPoints(objectPoints[i], imagePoints2, rvecs[i], tvecs[i], cameraMatrix, distCoeffs); } else { projectPoints(objectPoints[i], rvecs[i], tvecs[i], cameraMatrix, distCoeffs, imagePoints2); } err = norm(imagePoints[i], imagePoints2, NORM_L2); size_t n = objectPoints[i].size(); perViewErrors[i] = (float) std::sqrt(err*err/n); totalErr += err*err; totalPoints += n; } return std::sqrt(totalErr/totalPoints); } //! [compute_errors] //! [board_corners] static void calcBoardCornerPositions(Size boardSize, float squareSize, vector<Point3f>& corners, Settings::Pattern patternType /*= Settings::CHESSBOARD*/) { corners.clear(); switch(patternType) { case Settings::CHESSBOARD: case Settings::CIRCLES_GRID: for( int i = 0; i < boardSize.height; ++i ) for( int j = 0; j < boardSize.width; ++j ) corners.push_back(Point3f(j*squareSize, i*squareSize, 0)); break; case Settings::ASYMMETRIC_CIRCLES_GRID: for( int i = 0; i < boardSize.height; i++ ) for( int j = 0; j < boardSize.width; j++ ) corners.push_back(Point3f((2*j + i % 2)*squareSize, i*squareSize, 0)); break; default: break; } } //! [board_corners] static bool runCalibration( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector<vector<Point2f> > imagePoints, vector<Mat>& rvecs, vector<Mat>& tvecs, vector<float>& reprojErrs, double& totalAvgErr, vector<Point3f>& newObjPoints, float grid_width, bool release_object) { //! [fixed_aspect] cameraMatrix = Mat::eye(3, 3, CV_64F); if( !s.useFisheye && s.flag & CALIB_FIX_ASPECT_RATIO ) cameraMatrix.at<double>(0,0) = s.aspectRatio; //! [fixed_aspect] if (s.useFisheye) { distCoeffs = Mat::zeros(4, 1, CV_64F); } else { distCoeffs = Mat::zeros(8, 1, CV_64F); } vector<vector<Point3f> > objectPoints(1); calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern); objectPoints[0][s.boardSize.width - 1].x = objectPoints[0][0].x + grid_width; newObjPoints = objectPoints[0]; objectPoints.resize(imagePoints.size(),objectPoints[0]); //Find intrinsic and extrinsic camera parameters double rms; if (s.useFisheye) { Mat _rvecs, _tvecs; rms = fisheye::calibrate(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, _rvecs, _tvecs, s.flag); rvecs.reserve(_rvecs.rows); tvecs.reserve(_tvecs.rows); for(int i = 0; i < int(objectPoints.size()); i++){ rvecs.push_back(_rvecs.row(i)); tvecs.push_back(_tvecs.row(i)); } } else { int iFixedPoint = -1; if (release_object) iFixedPoint = s.boardSize.width - 1; rms = calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints, s.flag | CALIB_USE_LU); } if (release_object) { cout << "New board corners: " << endl; cout << newObjPoints[0] << endl; cout << newObjPoints[s.boardSize.width - 1] << endl; cout << newObjPoints[s.boardSize.width * (s.boardSize.height - 1)] << endl; cout << newObjPoints.back() << endl; } cout << "Re-projection error reported by calibrateCamera: "<< rms << endl; bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs); objectPoints.clear(); objectPoints.resize(imagePoints.size(), newObjPoints); totalAvgErr = computeReprojectionErrors(objectPoints, imagePoints, rvecs, tvecs, cameraMatrix, distCoeffs, reprojErrs, s.useFisheye); return ok; } // Print camera parameters to the output file static void saveCameraParams( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat& distCoeffs, const vector<Mat>& rvecs, const vector<Mat>& tvecs, const vector<float>& reprojErrs, const vector<vector<Point2f> >& imagePoints, double totalAvgErr, const vector<Point3f>& newObjPoints ) { FileStorage fs( s.outputFileName, FileStorage::WRITE ); time_t tm; time( &tm ); struct tm *t2 = localtime( &tm ); char buf[1024]; strftime( buf, sizeof(buf), "%c", t2 ); fs << "calibration_time" << buf; if( !rvecs.empty() || !reprojErrs.empty() ) fs << "nr_of_frames" << (int)std::max(rvecs.size(), reprojErrs.size()); fs << "image_width" << imageSize.width; fs << "image_height" << imageSize.height; fs << "board_width" << s.boardSize.width; fs << "board_height" << s.boardSize.height; fs << "square_size" << s.squareSize; if( !s.useFisheye && s.flag & CALIB_FIX_ASPECT_RATIO ) fs << "fix_aspect_ratio" << s.aspectRatio; if (s.flag) { std::stringstream flagsStringStream; if (s.useFisheye) { flagsStringStream << "flags:" << (s.flag & fisheye::CALIB_FIX_SKEW ? " +fix_skew" : "") << (s.flag & fisheye::CALIB_FIX_K1 ? " +fix_k1" : "") << (s.flag & fisheye::CALIB_FIX_K2 ? " +fix_k2" : "") << (s.flag & fisheye::CALIB_FIX_K3 ? " +fix_k3" : "") << (s.flag & fisheye::CALIB_FIX_K4 ? " +fix_k4" : "") << (s.flag & fisheye::CALIB_RECOMPUTE_EXTRINSIC ? " +recompute_extrinsic" : ""); } else { flagsStringStream << "flags:" << (s.flag & CALIB_USE_INTRINSIC_GUESS ? " +use_intrinsic_guess" : "") << (s.flag & CALIB_FIX_ASPECT_RATIO ? " +fix_aspectRatio" : "") << (s.flag & CALIB_FIX_PRINCIPAL_POINT ? " +fix_principal_point" : "") << (s.flag & CALIB_ZERO_TANGENT_DIST ? " +zero_tangent_dist" : "") << (s.flag & CALIB_FIX_K1 ? " +fix_k1" : "") << (s.flag & CALIB_FIX_K2 ? " +fix_k2" : "") << (s.flag & CALIB_FIX_K3 ? " +fix_k3" : "") << (s.flag & CALIB_FIX_K4 ? " +fix_k4" : "") << (s.flag & CALIB_FIX_K5 ? " +fix_k5" : ""); } fs.writeComment(flagsStringStream.str()); } fs << "flags" << s.flag; fs << "fisheye_model" << s.useFisheye; fs << "camera_matrix" << cameraMatrix; fs << "distortion_coefficients" << distCoeffs; fs << "avg_reprojection_error" << totalAvgErr; if (s.writeExtrinsics && !reprojErrs.empty()) fs << "per_view_reprojection_errors" << Mat(reprojErrs); if(s.writeExtrinsics && !rvecs.empty() && !tvecs.empty() ) { CV_Assert(rvecs[0].type() == tvecs[0].type()); Mat bigmat((int)rvecs.size(), 6, CV_MAKETYPE(rvecs[0].type(), 1)); bool needReshapeR = rvecs[0].depth() != 1 ? true : false; bool needReshapeT = tvecs[0].depth() != 1 ? true : false; for( size_t i = 0; i < rvecs.size(); i++ ) { Mat r = bigmat(Range(int(i), int(i+1)), Range(0,3)); Mat t = bigmat(Range(int(i), int(i+1)), Range(3,6)); if(needReshapeR) rvecs[i].reshape(1, 1).copyTo(r); else { //*.t() is MatExpr (not Mat) so we can use assignment operator CV_Assert(rvecs[i].rows == 3 && rvecs[i].cols == 1); r = rvecs[i].t(); } if(needReshapeT) tvecs[i].reshape(1, 1).copyTo(t); else { CV_Assert(tvecs[i].rows == 3 && tvecs[i].cols == 1); t = tvecs[i].t(); } } fs.writeComment("a set of 6-tuples (rotation vector + translation vector) for each view"); fs << "extrinsic_parameters" << bigmat; } if(s.writePoints && !imagePoints.empty() ) { Mat imagePtMat((int)imagePoints.size(), (int)imagePoints[0].size(), CV_32FC2); for( size_t i = 0; i < imagePoints.size(); i++ ) { Mat r = imagePtMat.row(int(i)).reshape(2, imagePtMat.cols); Mat imgpti(imagePoints[i]); imgpti.copyTo(r); } fs << "image_points" << imagePtMat; } if( s.writeGrid && !newObjPoints.empty() ) { fs << "grid_points" << newObjPoints; } } //! [run_and_save] bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector<vector<Point2f> > imagePoints, float grid_width, bool release_object) { vector<Mat> rvecs, tvecs; vector<float> reprojErrs; double totalAvgErr = 0; vector<Point3f> newObjPoints; bool ok = runCalibration(s, imageSize, cameraMatrix, distCoeffs, imagePoints, rvecs, tvecs, reprojErrs, totalAvgErr, newObjPoints, grid_width, release_object); cout << (ok ? "Calibration succeeded" : "Calibration failed") << ". avg re projection error = " << totalAvgErr << endl; if (ok) saveCameraParams(s, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, reprojErrs, imagePoints, totalAvgErr, newObjPoints); return ok; } //! [run_and_save]
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r13 push %r14 push %r8 push %rcx lea addresses_normal_ht+0xa560, %rcx nop nop add $20893, %r14 movb (%rcx), %r11b inc %rcx lea addresses_WT_ht+0x16634, %r10 cmp $15479, %r14 mov $0x6162636465666768, %r12 movq %r12, %xmm1 vmovups %ymm1, (%r10) add %r10, %r10 lea addresses_UC_ht+0x188f4, %r13 nop nop nop inc %r8 mov (%r13), %r14w nop nop nop xor $39577, %r10 lea addresses_WC_ht+0x19fe4, %r11 nop nop nop nop nop xor $46813, %r12 movb (%r11), %r13b nop add $9505, %r14 lea addresses_UC_ht+0x10f4, %r8 sub $58115, %r12 movups (%r8), %xmm7 vpextrq $0, %xmm7, %r11 nop nop nop nop nop cmp $46164, %r10 lea addresses_UC_ht+0x92f4, %r10 nop xor %r11, %r11 movups (%r10), %xmm1 vpextrq $1, %xmm1, %r12 nop nop nop nop sub $29218, %r10 pop %rcx pop %r8 pop %r14 pop %r13 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r8 push %rax push %rbp push %rdi // Load lea addresses_normal+0x7af4, %rdi and $30388, %r15 mov (%rdi), %ebp nop nop nop nop xor $46991, %rdi // Store lea addresses_WC+0x8af4, %r15 sub %r10, %r10 movl $0x51525354, (%r15) add %r15, %r15 // Store lea addresses_WC+0x18cf4, %r14 nop nop sub %r8, %r8 mov $0x5152535455565758, %rbp movq %rbp, (%r14) xor %rax, %rax // Load lea addresses_WT+0x74f4, %r10 nop nop nop nop nop sub %rbp, %rbp mov (%r10), %rdi nop nop nop add $49379, %rax // Store lea addresses_UC+0xf38c, %rbp clflush (%rbp) nop nop nop dec %r10 mov $0x5152535455565758, %r14 movq %r14, (%rbp) nop nop nop xor %r14, %r14 // Store lea addresses_A+0x1f3d4, %rdi xor $43928, %r8 movl $0x51525354, (%rdi) nop cmp %r14, %r14 // Faulty Load lea addresses_RW+0x1b4f4, %rdi sub %r14, %r14 mov (%rdi), %r8w lea oracles, %r15 and $0xff, %r8 shlq $12, %r8 mov (%r15,%r8,1), %r8 pop %rdi pop %rbp pop %rax pop %r8 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 3, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': True, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 10, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': False}} {'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 */
/* * If not stated otherwise in this file or this component's Licenses.txt file * the following copyright and licenses apply: * * Copyright 2020 RDK Management * * 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 "gtest/gtest.h" #include <sys/time.h> #include <time.h> #include <unistd.h> #include <rbus.h> #include "rbusProviderConsumer.h" static void exec_func_test(rbusGtest_t test) { int runtime = 0; switch(test) { case RBUS_GTEST_METHOD_ASYNC: { runtime = 5; break; } case RBUS_GTEST_FILTER2: case RBUS_GTEST_ASYNC_SUB4: { runtime = 15; break; } default: { runtime = 3; break; } } usleep(25000); pid_t pid = fork(); if (0 == pid) { int ret = 0; ret = rbusConsumer(test, 0, runtime); exit(ret); } else { int ret = 0; int consumer_status; int expected_consumer_status = RBUS_ERROR_SUCCESS; /* Run the appropriate provider */ switch(test) { case RBUS_GTEST_GET13: case RBUS_GTEST_GET14: case RBUS_GTEST_GET15: case RBUS_GTEST_GET16: case RBUS_GTEST_GET17: case RBUS_GTEST_GET18: case RBUS_GTEST_GET19: case RBUS_GTEST_GET20: case RBUS_GTEST_GET21: case RBUS_GTEST_GET22: case RBUS_GTEST_GET23: case RBUS_GTEST_GET24: ret = rbuscoreProvider(test, pid, &consumer_status); break; case RBUS_GTEST_ASYNC_SUB5: { pid_t pid1 = fork(); if(0 == pid1){ printf("Provider1 starts.\n"); ret = rbusProvider1((runtime/3),0); exit(ret); } else { printf("Provider2 starts.\n"); waitpid(pid1, &consumer_status, 0); ret = rbusProvider1((runtime/2),1); } } break; default: ret = rbusProvider(test, pid, &consumer_status); break; } printf("Consumer result %d\n",WEXITSTATUS(consumer_status)); if((WIFSIGNALED(consumer_status)) && (WTERMSIG(consumer_status) != SIGUSR1)) { printf("/******************************************/\n"); printf("/******************************************/\n"); printf(" \n"); printf("ABNORMAL EXIT by %d: %s\n",WTERMSIG(consumer_status),strsignal(WTERMSIG(consumer_status))); printf(" \n"); printf("/******************************************/\n"); printf("/******************************************/\n"); expected_consumer_status = RBUS_ERROR_BUS_ERROR; } else { /* Update the expected_consumer_status */ switch(test) { case RBUS_GTEST_GET1: case RBUS_GTEST_GET2: case RBUS_GTEST_GET3: case RBUS_GTEST_SET5: case RBUS_GTEST_SET6: case RBUS_GTEST_SET7: case RBUS_GTEST_SET8: case RBUS_GTEST_UNREG_ROW: case RBUS_GTEST_DISC_COMP2: case RBUS_GTEST_DISC_COMP3: case RBUS_GTEST_DISC_COMP4: case RBUS_GTEST_SET_MULTI2: expected_consumer_status = RBUS_ERROR_INVALID_INPUT; break; case RBUS_GTEST_SET_MULTI3: case RBUS_GTEST_SET3: expected_consumer_status = RBUS_ERROR_DESTINATION_NOT_REACHABLE; break; case RBUS_GTEST_SET_MULTI5: case RBUS_GTEST_SET2: expected_consumer_status = RBUS_ERROR_INVALID_OPERATION; break; case RBUS_GTEST_GET24: expected_consumer_status = RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION; break; case RBUS_GTEST_GET29: expected_consumer_status = RBUS_ERROR_ACCESS_NOT_ALLOWED; break; case RBUS_GTEST_GET28: expected_consumer_status = RBUS_ERROR_BUS_ERROR; break; } } EXPECT_EQ(WEXITSTATUS(consumer_status),expected_consumer_status); EXPECT_EQ(ret,0); } } TEST(rbusApiGetExt, test1) { exec_func_test(RBUS_GTEST_GET_EXT1); } TEST(rbusApiGetExt, test2) { int j = 0; pid_t pid_arr[3]; for(j = 0 ; j < 3 ; j++ ) { pid_arr[j] = fork(); if (0 == pid_arr[j]) { int ret = 0; ret = rbusMultiProvider(j); exit(ret); } else { int ret = 0; ret = rbusConsumer(RBUS_GTEST_GET_EXT2, pid_arr[j], 0); } } for(j = 0 ; j < 3 ; j++ ) wait(NULL); } TEST(rbusApiGet, test1) { exec_func_test(RBUS_GTEST_GET1); } TEST(rbusApiGet, test2) { exec_func_test(RBUS_GTEST_GET2); } TEST(rbusApiGet, test3) { exec_func_test(RBUS_GTEST_GET3); } TEST(rbusApiGet, test4) { exec_func_test(RBUS_GTEST_GET4); } TEST(rbusApiGet, test5) { exec_func_test(RBUS_GTEST_GET5); } TEST(rbusApiGet, test6) { exec_func_test(RBUS_GTEST_GET6); } TEST(rbusApiGet, test7) { exec_func_test(RBUS_GTEST_GET7); } TEST(rbusApiGet, test8) { exec_func_test(RBUS_GTEST_GET8); } TEST(rbusApiGet, test9) { exec_func_test(RBUS_GTEST_GET9); } TEST(rbusApiGet, test10) { exec_func_test(RBUS_GTEST_GET10); } TEST(rbusApiGet, test11) { exec_func_test(RBUS_GTEST_GET11); } TEST(rbusApiGet, test12) { exec_func_test(RBUS_GTEST_GET12); } TEST(rbusApiGet, test13) { exec_func_test(RBUS_GTEST_GET13); } TEST(rbusApiGet, test14) { exec_func_test(RBUS_GTEST_GET14); } TEST(rbusApiGet, test15) { exec_func_test(RBUS_GTEST_GET15); } TEST(rbusApiGet, test16) { exec_func_test(RBUS_GTEST_GET16); } TEST(rbusApiGet, test17) { exec_func_test(RBUS_GTEST_GET17); } TEST(rbusApiGet, test18) { exec_func_test(RBUS_GTEST_GET18); } TEST(rbusApiGet, test19) { exec_func_test(RBUS_GTEST_GET19); } TEST(rbusApiGet, test20) { exec_func_test(RBUS_GTEST_GET20); } TEST(rbusApiGet, test21) { exec_func_test(RBUS_GTEST_GET21); } TEST(rbusApiGet, test22) { exec_func_test(RBUS_GTEST_GET22); } TEST(rbusApiGet, test23) { exec_func_test(RBUS_GTEST_GET23); } TEST(rbusApiGet, test24) { exec_func_test(RBUS_GTEST_GET24); } TEST(rbusApiGet, test25) { exec_func_test(RBUS_GTEST_GET25); } TEST(rbusApiGet, test26) { exec_func_test(RBUS_GTEST_GET26); } TEST(rbusApiGet, test27) { exec_func_test(RBUS_GTEST_GET27); } TEST(rbusApiGet, test28) { exec_func_test(RBUS_GTEST_GET28); } TEST(rbusApiGet, test29) { exec_func_test(RBUS_GTEST_GET29); } TEST(rbusApiGet, test30) { exec_func_test(RBUS_GTEST_GET30); } TEST(rbusApiGet, test31) { exec_func_test(RBUS_GTEST_GET31); } TEST(rbusApiSet, test1) { exec_func_test(RBUS_GTEST_SET1); } TEST(rbusApiSet, test2) { exec_func_test(RBUS_GTEST_SET2); } TEST(rbusApiSet, test3) { exec_func_test(RBUS_GTEST_SET3); } TEST(rbusApiSet, test4) { exec_func_test(RBUS_GTEST_SET4); } TEST(rbusApiSet, test5) { exec_func_test(RBUS_GTEST_SET5); } TEST(rbusApiSet, test6) { exec_func_test(RBUS_GTEST_SET6); } TEST(rbusApiSet, test7) { exec_func_test(RBUS_GTEST_SET7); } TEST(rbusApiSet, test8) { exec_func_test(RBUS_GTEST_SET8); } TEST(rbusApiSet, test9) { exec_func_test(RBUS_GTEST_SET9); } TEST(rbusApiSet, test10) { exec_func_test(RBUS_GTEST_SET10); } TEST(rbusApiSet, test11) { exec_func_test(RBUS_GTEST_SET11); } TEST(rbusApiSetMulti, test1) { exec_func_test(RBUS_GTEST_SET_MULTI1); } TEST(rbusApiSetMulti, test2) { exec_func_test(RBUS_GTEST_SET_MULTI2); } TEST(rbusApiSetMulti, test3) { exec_func_test(RBUS_GTEST_SET_MULTI3); } TEST(rbusApiSetMulti, test4) { exec_func_test(RBUS_GTEST_SET_MULTI4); } TEST(rbusApiSetMulti, test5) { exec_func_test(RBUS_GTEST_SET_MULTI5); } TEST(rbusApiDiscoverComp, test1) { exec_func_test(RBUS_GTEST_DISC_COMP1); } TEST(rbusApiDiscoverComp, test2) { exec_func_test(RBUS_GTEST_DISC_COMP2); } TEST(rbusApiDiscoverComp, test3) { exec_func_test(RBUS_GTEST_DISC_COMP3); } TEST(rbusApiDiscoverComp, test4) { exec_func_test(RBUS_GTEST_DISC_COMP4); } TEST(rbusApiMethod, test1) { exec_func_test(RBUS_GTEST_METHOD1); } TEST(rbusApiMethod, test2) { exec_func_test(RBUS_GTEST_METHOD2); } TEST(rbusApiMethodAsync, test) { exec_func_test(RBUS_GTEST_METHOD_ASYNC); } TEST(rbusApiValueChangeTest, test1) { exec_func_test(RBUS_GTEST_FILTER1); } TEST(rbusApiValueChangeTest, test2) { exec_func_test(RBUS_GTEST_FILTER2); } TEST(rbusAsyncSubTest, test1) { exec_func_test(RBUS_GTEST_ASYNC_SUB1); } TEST(rbusAsyncSubTest, test2) { exec_func_test(RBUS_GTEST_ASYNC_SUB2); } TEST(rbusAsyncSubTest, test3) { exec_func_test(RBUS_GTEST_ASYNC_SUB3); } TEST(rbusAsyncSubTest, test4) { exec_func_test(RBUS_GTEST_ASYNC_SUB4); } TEST(rbusAsyncSubTest, test5) { exec_func_test(RBUS_GTEST_ASYNC_SUB5); } TEST(rbusRegRowTest, test) { exec_func_test(RBUS_GTEST_REG_ROW); } TEST(rbusUnRegRowTest, test) { exec_func_test(RBUS_GTEST_UNREG_ROW); }
; A047507: Numbers that are congruent to {0, 4, 6, 7} mod 8. ; 0,4,6,7,8,12,14,15,16,20,22,23,24,28,30,31,32,36,38,39,40,44,46,47,48,52,54,55,56,60,62,63,64,68,70,71,72,76,78,79,80,84,86,87,88,92,94,95,96,100,102,103,104,108,110,111,112,116,118,119,120,124 add $0,6 mov $1,$0 div $1,4 mov $2,$0 lpb $2 mov $3,$0 add $3,3 mov $0,$3 sub $2,4 lpe add $1,$0 sub $1,10
#include "basic_includes.hpp" using namespace std; // Keep current max/min because min might become max with next num! // Remember to reset when meeting 0 class Solution { public: int maxProduct(vector<int>& nums) { int best_sum = nums[0], max_sum = 1, min_sum = 1; for (auto num: nums) { max_sum *= num; min_sum *= num; if (min_sum > max_sum) { swap(min_sum, max_sum); } if (num > max_sum) { max_sum = num; } if (num < min_sum) { min_sum = num; } if (max_sum > best_sum) { best_sum = max_sum; } if (num == 0) { max_sum = 1; min_sum = 1; } } return best_sum; } }; void test_case(vector<int> &in) { Solution sol; cout << "result: " << sol.maxProduct(in) << endl;; } int main() { vector<int> test = {2,3,-2,4}; test_case(test); vector<int> test2 = {-2,0,3}; test_case(test2); vector<int> test3 = {-2,-1,-3, -1}; test_case(test3); vector<int> test4 = {-2,0}; test_case(test4); vector<int> test5 = {3, -1, 4}; test_case(test5); vector<int> test6 = {2, -5, -2, -4, 3}; test_case(test6); return 0; }
; A033655: Trajectory of 19 under map x->x + (x-with-digits-reversed). ; Submitted by Jamie Morken(s4) ; 19,110,121,242,484,968,1837,9218,17347,91718,173437,907808,1716517,8872688,17735476,85189247,159487405,664272356,1317544822,3602001953,7193004016,13297007933,47267087164 mov $2,$0 lpb $2 mov $0,$1 add $0,19 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences). add $1,$0 sub $2,1 lpe mov $0,$1 add $0,19
; A047450: Numbers that are congruent to {0, 1, 2, 3, 5, 6} mod 8. ; 0,1,2,3,5,6,8,9,10,11,13,14,16,17,18,19,21,22,24,25,26,27,29,30,32,33,34,35,37,38,40,41,42,43,45,46,48,49,50,51,53,54,56,57,58,59,61,62,64,65,66,67,69,70,72,73,74,75,77,78,80,81,82,83,85,86,88 mov $1,$0 div $0,2 mul $0,2 div $0,3 add $1,$0
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 <tencentcloud/sqlserver/v20180328/model/DescribeDBsNormalRequest.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using namespace TencentCloud::Sqlserver::V20180328::Model; using namespace std; DescribeDBsNormalRequest::DescribeDBsNormalRequest() : m_instanceIdHasBeenSet(false) { } string DescribeDBsNormalRequest::ToJsonString() const { rapidjson::Document d; d.SetObject(); rapidjson::Document::AllocatorType& allocator = d.GetAllocator(); if (m_instanceIdHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "InstanceId"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, rapidjson::Value(m_instanceId.c_str(), allocator).Move(), allocator); } rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); d.Accept(writer); return buffer.GetString(); } string DescribeDBsNormalRequest::GetInstanceId() const { return m_instanceId; } void DescribeDBsNormalRequest::SetInstanceId(const string& _instanceId) { m_instanceId = _instanceId; m_instanceIdHasBeenSet = true; } bool DescribeDBsNormalRequest::InstanceIdHasBeenSet() const { return m_instanceIdHasBeenSet; }
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Set/Reset the couple of vectors being part of a "stencil" ; Basic concept by Rafael de Oliveira Jannone (calculate_side) ; ; Stefano Bodrato - 13/3/2009 ; ; ; $Id: stencil_init.asm,v 1.4 2016-04-22 20:29:52 dom Exp $ ; INCLUDE "graphics/grafix.inc" SECTION code_graphics PUBLIC stencil_init PUBLIC _stencil_init .stencil_init ._stencil_init ; __FASTCALL__ means no need to pick HL ptr from stack ld d,h ld e,l inc de ld (hl),255 ld bc,maxy push bc ldir pop bc dec bc ld (hl),0 ldir ret
; A042302: Numerators of continued fraction convergents to sqrt(678). ; Submitted by Jon Maiga ; 26,677,35230,916657,47701394,1241152901,64587652246,1680520111297,87451633439690,2275422989543237,118409447089688014,3080921047321431601,160326303907804131266,4171564822650228844517,217081697081719704046150,5648295688947362534044417,293928457522344571474355834,7647788191269906220867296101,397978914403557468056573753086,10355099562683764075691784876337,538863156173959289404029387322610,14020797160085625288580455855264197,729620315480626474295587733861060854,18984148999656373956973861536242846401 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 dif $2,2 mul $2,26 add $3,$2 lpe mov $0,$3
/* * ===================================================================================== * * Filename: st.cpp * * Description: * * Version: 1.0 * Created: 02/26/2020 11:32:13 AM * Revision: none * Compiler: gcc * * Author: José Cleiton Borges Correia (JCBC), jcleitonbc@gmail.com * Organization: UNEB * * ===================================================================================== */ #include "stable.hpp" #include <cmath> #include "constexpr.hpp" #include "enum/tipo_dado.hpp" namespace AnaliseSemantica { TipoDado lexemaTipo(const std::string_view lexema) { if (lexema == "INTEIRO") { return TipoDado::INTEIRO; } else if (lexema == "QUEBRADO") { return TipoDado::QUEBRADO; } else { return TipoDado::LOGICO; } } std::string tipoLexema(const TipoDado t) { switch (t) { case TipoDado::INTEIRO: return "INTEIRO"; case TipoDado::LOGICO: return "LOGICO"; case TipoDado::QUEBRADO: return "QUEBRADO"; default: return "NULO"; } } Dado::Dado(const TipoDado t, const double v) : tipo(t), valor(v) {} Dado::Dado(const Dado &d) : tipo(d.tipo), valor(d.valor) { if (tipo == TipoDado::NULO) { preencheTipo(); } } Dado::Dado(const double v) : valor(v) { preencheTipo(); } Dado::Dado(const Dado &d1, const Dado &d2) { if (d1 == TipoDado::QUEBRADO) { tipo = d1; } else if (d1 == TipoDado::INTEIRO) { if (d2 == TipoDado::QUEBRADO) { tipo = d2; } else { tipo = d1; } } else { tipo = d2; } } void Dado::preencheTipo(void) { if (valor == 1 or valor == 0.0f) { tipo = TipoDado::LOGICO; } else if (valor == ceilf(valor)) { tipo = TipoDado::INTEIRO; } else { tipo = TipoDado::QUEBRADO; } } Dado &Dado::operator=(const Dado &other) { if (this != &other) { if (bool valido = tipoSaoCompativeis(tipo, other); !valido) { throw std::domain_error("Tipos incompatíveis"); } tipo = other.tipo; valor = other.valor; } return *this; } } // namespace AnaliseSemantica
;++ ; CpuInfo ; Copyright (c) 2017-2018, Aidan Khoury. 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. ; ; @file cpuid.asm ; @author Aidan Khoury (ajkhoury) ; @date 11/15/2018 ; ; @brief Cpuid functions for the i386 (32-bit) architecture. ;-- [BITS 32] SECTION .text ; ; void __cdecl __cpuid( int _Info[4], int _Level ); ; global ASM_PFX(__cpuid) ASM_PFX(__cpuid): push ebp mov ebp, dword [esp + 8] mov eax, dword [esp + 0Ch] xor ecx, ecx cpuid mov dword [ebp + 0], eax mov dword [ebp + 4], ebx mov dword [ebp + 8], ecx mov dword [ebp + 0Ch], edx pop ebp ret ; ; void __cdecl __cpuidex( int _Info[4], int _Level, int _Ecx ); ; global ASM_PFX(__cpuidex) ASM_PFX(__cpuidex): push ebp mov ebp, dword [esp + 8] mov eax, dword [esp + 0Ch] mov ecx, dword [esp + 10h] cpuid mov dword [ebp + 0], eax mov dword [ebp + 4], ebx mov dword [ebp + 8], ecx mov dword [ebp + 0Ch], edx pop ebp ret
; Substitute for z80 cpir instruction ; aralbrec 02.2008 ; flag-perfect emulation of cpir PUBLIC rcmx_cpir .rcmx_cpir jr nc, enterloop call enterloop scf ret .loop inc hl .enterloop dec bc cp (hl) jr z, match inc c dec c jr nz, loop inc b djnz loop .nomatch cp (hl) inc hl push af .joinbc0 ex (sp),hl res 0,l res 2,l ex (sp),hl pop af ret .match inc hl push af ld a,b or c jr z, joinbc0 ex (sp),hl res 0,l set 2,l ex (sp),hl pop af ret
SECTION code_clib PUBLIC pointxy_MODE0 .pointxy_MODE0 defc NEEDpoint = 1 INCLUDE "gfx/gencon/pixel.inc"
# ================================================================================================ # extern uint8_t hex_to_char(const char* from) __z88dk_fastcall __z88dk_callee; # ================================================================================================ public _hex_to_char # hl contains a pointer to two chars # result is returned through register l _hex_to_char: ld a,(hl) inc hl call hex1 add a,a add a,a add a,a add a,a ld d,a ld a,(hl) call hex1 and 0x0F or d ld h, 0 ld l, a ret hex1: # 0..9 sub a, '0' cp 10 ret c # A..F sub a, 0x07 cp 16 ret c # a..f sub a, 0x20 ret # ================================================================================================ # extern void char_to_hex(char* res, uint8_t c) __z88dk_fastcall __z88dk_callee; # ================================================================================================ public _char_to_hex _char_to_hex: # ret pop bc # char* res pop de # restore ret push bc ld h, l ld a, l rra rra rra rra and 0x0F call _hex_a_to_hex ld (de), a inc de ld a, l and 0x0F call _hex_a_to_hex ld (de), a ret _hex_a_to_hex: cp 10 jp nc, _hex_af add a, '0' ret _hex_af: add a, 'A'-10 ret
#include "../../MacAddress.hpp" #include "./WifiP2pConfig.hpp" #include "../../../../JString.hpp" #include "./WifiP2pConfig_Builder.hpp" namespace android::net::wifi::p2p { // Fields // QJniObject forward WifiP2pConfig_Builder::WifiP2pConfig_Builder(QJniObject obj) : JObject(obj) {} // Constructors WifiP2pConfig_Builder::WifiP2pConfig_Builder() : JObject( "android.net.wifi.p2p.WifiP2pConfig$Builder", "()V" ) {} // Methods android::net::wifi::p2p::WifiP2pConfig WifiP2pConfig_Builder::build() const { return callObjectMethod( "build", "()Landroid/net/wifi/p2p/WifiP2pConfig;" ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::enablePersistentMode(jboolean arg0) const { return callObjectMethod( "enablePersistentMode", "(Z)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0 ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::setDeviceAddress(android::net::MacAddress arg0) const { return callObjectMethod( "setDeviceAddress", "(Landroid/net/MacAddress;)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0.object() ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::setGroupOperatingBand(jint arg0) const { return callObjectMethod( "setGroupOperatingBand", "(I)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0 ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::setGroupOperatingFrequency(jint arg0) const { return callObjectMethod( "setGroupOperatingFrequency", "(I)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0 ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::setNetworkName(JString arg0) const { return callObjectMethod( "setNetworkName", "(Ljava/lang/String;)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0.object<jstring>() ); } android::net::wifi::p2p::WifiP2pConfig_Builder WifiP2pConfig_Builder::setPassphrase(JString arg0) const { return callObjectMethod( "setPassphrase", "(Ljava/lang/String;)Landroid/net/wifi/p2p/WifiP2pConfig$Builder;", arg0.object<jstring>() ); } } // namespace android::net::wifi::p2p
SECTION code_fp_math32 PUBLIC _f32_fam9511_fastcall EXTERN m32_f32_fam9511 defc _f32_fam9511_fastcall = m32_f32_fam9511 PUBLIC _f32_fam9511 EXTERN cm32_sdcc_f32_fam9511 defc _f32_fam9511 = cm32_sdcc_f32_fam9511 PUBLIC _fam9511_f32_fastcall EXTERN m32_fam9511_f32 defc _fam9511_f32_fastcall = m32_fam9511_f32 PUBLIC _fam9511_f32 EXTERN cm32_sdcc_fam9511_f32 defc _fam9511_f32 = cm32_sdcc_fam9511_f32
; A141596: Triangle T(n,k) = 4*binomial(n,k)^2-3, read by rows, 0<=k<=n. ; 1,1,1,1,13,1,1,33,33,1,1,61,141,61,1,1,97,397,397,97,1,1,141,897,1597,897,141,1,1,193,1761,4897,4897,1761,193,1,1,253,3133,12541,19597,12541,3133,253,1,1,321,5181,28221,63501,63501,28221,5181,321,1,1,397,8097,57597,176397,254013,176397,57597,8097,397,1,1,481,12097,108897,435597,853773,853773,435597,108897,12097,481,1,1,573,17421,193597,980097,2509053,3415101,2509053,980097,193597,17421,573,1,1,673,24333,327181,2044897,6625473,11778621,11778621,6625473 seq $0,28326 ; Twice Pascal's triangle A007318: T(n,k) = 2*C(n,k). pow $0,2 sub $0,3
// Computes R2 = max(R0, R1) // R0, R1, R2 refer to RAM[0], RAM[1], RAM[2] @R0 D=M // D = first number @R1 D=D-M // D = first number - second number @OUTPUT_FIRST D;JGT // if D>0 (first is greater) goto output_first @R1 D=M // D = second number @OUTPUT_D 0;JMP // goto output_d (OUTPUT_FIRST) @R0 D=M // D = first number (OUTPUT_D) @R2 M=D // M[2] = D (greatest number) (INFINITE_LOOP) @INFINITE_LOOP 0;JMP // infinite loop
// license:BSD-3-Clause // copyright-holders:Sergey Svishchev /********************************************************************** formats/dvk_mx_dsk.cpp Floppies used by DVK MX: controller http://torlus.com/floppy/forum/viewtopic.php?f=19&t=1384 Track format is almost entirely driver-dependent (only sync word 0x00f3 is mandatory), because hardware always reads or writes entire track. 'old' format is used by stock driver, 'new' -- by 3rd party one. Formatting tools produce yet other variants... Floppy drives were 40- and 80-track, double-sided. 'new' driver also supports single-sided floppies. ************************************************************************/ #include "formats/dvk_mx_dsk.h" #include "ioprocs.h" const floppy_image_format_t::desc_e dvk_mx_format::dvk_mx_new_desc[] = { /* 01 */ { FM, 0x00, 8*2 }, // eight 0x0000 words /* 03 */ { FM, 0x00, 1 }, /* 02 */ { FM, 0xf3, 1 }, // word 0x00f3 /* 05 */ { FM, 0x00, 1 }, /* 04 */ { TRACK_ID_FM }, // track number word /* 05 */ { SECTOR_LOOP_START, 0, 10 }, // 11 sectors /* 07 */ { SECTOR_DATA_MX, -1 }, /* 10 */ { SECTOR_LOOP_END }, /* 13 */ { FM, 0x83, 1 }, /* 12 */ { OFFSET_ID_FM }, /* 15 */ { FM, 0x83, 1 }, /* 14 */ { OFFSET_ID_FM }, /* 17 */ { FM, 0x83, 1 }, /* 16 */ { OFFSET_ID_FM }, /* 18 */ { END } }; const floppy_image_format_t::desc_e dvk_mx_format::dvk_mx_old_desc[] = { /* 01 */ { FM, 0x00, 30*2 }, /* 03 */ { FM, 0x00, 1 }, /* 02 */ { FM, 0xf3, 1 }, // word 0x00f3 /* 05 */ { FM, 0x00, 1 }, /* 04 */ { TRACK_ID_FM }, // track number word /* 06 */ { SECTOR_LOOP_START, 0, 10 }, // 11 sectors /* 07 */ { SECTOR_DATA_MX, -1 }, /* 10 */ { SECTOR_LOOP_END }, /* 13 */ { FM, 0x83, 1 }, /* 11 */ { FM, 0x01, 1 }, /* 15 */ { FM, 0x83, 1 }, /* 14 */ { FM, 0x01, 1 }, /* 16 */ { END } }; dvk_mx_format::dvk_mx_format() { } const char *dvk_mx_format::name() const { return "mx"; } const char *dvk_mx_format::description() const { return "DVK MX: floppy image"; } const char *dvk_mx_format::extensions() const { return "mx"; } bool dvk_mx_format::supports_save() const { return false; } void dvk_mx_format::find_size(util::random_read &io, uint8_t &track_count, uint8_t &head_count, uint8_t &sector_count) { uint64_t size; if (io.length(size)) { track_count = head_count = sector_count = 0; return; } switch (size) { case 112640: track_count = 40; sector_count = 11; head_count = 1; break; case 225280: track_count = 40; sector_count = 11; head_count = 2; break; case 450560: track_count = 80; sector_count = 11; head_count = 2; break; default: track_count = head_count = sector_count = 0; break; } } int dvk_mx_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); if (track_count) { uint8_t sectdata[512]; size_t actual; io.read_at(512, sectdata, 512, actual); // check value in RT-11 home block. see src/tools/imgtool/modules/rt11.cpp if (pick_integer_le(sectdata, 0724, 2) == 6) return 100; else return 75; } return 0; } bool dvk_mx_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); if (track_count == 0) return false; uint8_t sectdata[11 * 256]; desc_s sectors[11]; for (int i = 0; i < sector_count; i++) { sectors[i].data = sectdata + 256 * i; sectors[i].size = 256; sectors[i].sector_id = i; } int track_size = sector_count * 256; for (int track = 0; track < track_count; track++) { for (int head = 0; head < head_count; head++) { size_t actual; io.read_at((track * head_count + head) * track_size, sectdata, track_size, actual); generate_track(dvk_mx_new_desc, track, head, sectors, sector_count, 45824, image); } } if (head_count == 1) { image->set_variant(floppy_image::SSDD); } else { if (track_count > 40) { image->set_variant(floppy_image::DSQD); } else { image->set_variant(floppy_image::DSDD); } } return true; } const floppy_format_type FLOPPY_DVK_MX_FORMAT = &floppy_image_format_creator<dvk_mx_format>;
; void *balloc_addmem(unsigned char q, size_t num, size_t size, void *addr) SECTION code_alloc_balloc PUBLIC _balloc_addmem EXTERN l0_balloc_addmem_callee _balloc_addmem: pop af exx pop bc exx pop bc pop hl pop de push de push hl push bc push bc push af jp l0_balloc_addmem_callee
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x1eb99, %rsi lea addresses_WC_ht+0xf799, %rdi clflush (%rsi) nop nop nop nop xor $51993, %r11 mov $60, %rcx rep movsb nop nop nop sub %r8, %r8 lea addresses_WT_ht+0x2799, %rsi lea addresses_WC_ht+0x12999, %rdi nop nop nop nop nop add %rdx, %rdx mov $122, %rcx rep movsq xor $7930, %r8 lea addresses_WC_ht+0x731, %rsi nop xor $40830, %r11 movb $0x61, (%rsi) nop sub $61246, %r11 lea addresses_D_ht+0xa399, %rdx clflush (%rdx) nop nop nop add %r11, %r11 movl $0x61626364, (%rdx) nop nop nop xor %rsi, %rsi lea addresses_WT_ht+0x9b99, %rdx nop nop nop nop nop cmp %rcx, %rcx movw $0x6162, (%rdx) nop nop nop nop dec %rdi lea addresses_A_ht+0x1c799, %r11 sub $5248, %r10 movw $0x6162, (%r11) nop nop nop nop dec %rdx lea addresses_A_ht+0x4cd5, %rdx nop nop nop and %r10, %r10 and $0xffffffffffffffc0, %rdx movaps (%rdx), %xmm1 vpextrq $1, %xmm1, %rdi nop nop nop nop nop sub %rdx, %rdx lea addresses_D_ht+0x19afd, %r11 clflush (%r11) nop nop nop nop nop cmp %rdx, %rdx movb $0x61, (%r11) nop nop nop nop xor $428, %r8 lea addresses_A_ht+0xbd89, %rcx nop nop nop nop nop cmp %rsi, %rsi mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop nop cmp $42666, %rdi lea addresses_A_ht+0x82a3, %rcx nop nop nop nop add %rdx, %rdx movw $0x6162, (%rcx) inc %rcx lea addresses_WT_ht+0x16c99, %rsi nop nop nop inc %r8 mov (%rsi), %r11w nop nop nop nop nop xor %r10, %r10 lea addresses_WC_ht+0xf819, %rsi nop nop nop nop nop sub $28544, %rdx movb (%rsi), %cl nop nop nop nop dec %rdx lea addresses_WT_ht+0x4f99, %rsi lea addresses_WC_ht+0x2a99, %rdi nop dec %r14 mov $22, %rcx rep movsw cmp $65124, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r15 push %r9 push %rbp push %rbx // Store lea addresses_D+0xa799, %r12 nop and %r11, %r11 movw $0x5152, (%r12) nop nop nop and $7486, %r11 // Faulty Load mov $0x3cad3c0000000999, %rbp nop nop nop nop cmp %r15, %r15 vmovntdqa (%rbp), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %r14 lea oracles, %r12 and $0xff, %r14 shlq $12, %r14 mov (%r12,%r14,1), %r14 pop %rbx pop %rbp pop %r9 pop %r15 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 9}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': True, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': True, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 8}} {'8f': 1, '49': 15755, '8e': 1, '45': 6029, '00': 42, '47': 1} 00 49 45 49 49 45 49 45 49 45 49 45 49 49 45 49 45 49 45 49 49 49 49 45 49 45 49 49 49 49 45 49 45 49 49 49 49 45 49 45 49 49 49 49 45 49 49 45 49 49 49 49 45 49 49 49 45 49 45 49 49 49 49 49 49 49 45 49 49 49 45 49 45 45 49 45 49 49 45 49 49 45 49 45 49 49 49 45 49 49 49 49 49 49 45 49 49 49 45 49 45 49 49 45 45 49 45 49 49 45 49 49 45 49 49 49 49 45 49 49 45 49 45 49 45 45 49 45 49 49 45 49 45 45 45 45 49 49 49 49 49 49 45 49 49 45 49 49 49 45 45 49 45 49 49 45 49 49 45 49 45 49 49 49 49 49 45 49 45 49 45 49 49 45 49 45 49 49 45 49 49 49 45 49 45 49 49 45 49 49 49 45 45 49 45 49 45 49 49 45 49 45 49 49 45 49 45 49 45 49 49 49 45 49 45 49 45 49 45 49 49 49 49 49 45 49 45 49 49 49 45 49 45 49 49 45 45 49 45 49 45 49 49 49 45 49 49 49 49 45 45 45 49 45 49 49 49 45 45 45 49 45 49 45 49 45 49 45 49 45 49 49 49 49 49 49 45 49 49 49 49 49 45 49 49 45 49 45 49 45 45 49 45 49 45 49 45 49 49 49 45 49 49 49 45 45 49 45 49 49 45 49 49 45 49 45 49 49 49 49 45 49 49 45 49 45 49 49 45 49 45 49 45 49 45 49 49 45 45 49 45 49 49 49 45 49 49 45 49 49 45 49 45 49 45 49 45 49 49 49 45 49 49 45 49 49 49 49 49 45 49 45 49 45 49 45 49 45 49 49 45 49 45 49 45 49 45 49 45 49 49 45 49 49 45 45 49 45 49 49 45 49 49 45 49 45 45 49 49 49 45 49 49 49 45 49 49 49 45 49 49 45 49 45 49 49 49 49 45 49 49 45 49 49 45 49 49 45 49 49 45 49 45 49 45 49 45 49 49 49 49 49 45 49 45 49 49 49 45 49 49 45 49 49 45 49 49 49 45 49 49 49 49 49 49 45 45 49 49 49 45 49 49 49 49 49 45 49 45 49 45 49 45 49 49 49 49 49 45 49 49 45 45 49 49 45 49 49 49 45 49 49 49 45 49 49 49 45 49 49 45 49 49 49 49 49 45 49 49 49 49 49 49 45 49 45 49 49 49 45 49 49 49 49 49 49 45 45 49 49 49 49 49 49 49 49 49 49 49 49 49 45 45 49 49 49 49 49 49 49 49 49 45 49 49 45 49 49 45 45 49 49 49 45 49 45 45 45 45 45 45 49 49 49 45 49 49 49 49 49 49 49 45 45 45 49 49 49 45 49 49 45 49 45 49 49 45 49 49 49 45 45 49 45 49 49 49 45 45 45 49 49 49 49 49 49 49 49 49 49 45 45 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 45 45 45 45 49 49 49 49 49 49 45 49 49 45 49 45 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 45 49 45 49 49 45 49 49 45 49 49 49 49 49 45 49 45 49 45 49 49 49 45 49 49 45 49 49 49 45 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 49 49 49 45 45 49 45 49 49 49 49 45 49 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 49 45 45 45 49 49 45 45 45 49 49 49 45 49 49 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 49 49 49 49 49 45 49 49 45 45 49 49 45 45 45 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 49 49 49 45 49 49 49 49 45 49 49 49 49 49 49 45 49 49 49 45 49 49 45 45 45 45 45 45 49 49 49 49 45 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 45 49 45 49 49 49 49 49 45 49 49 49 49 49 49 49 49 49 49 49 45 49 49 49 49 49 45 49 49 49 49 49 49 45 49 45 49 49 49 45 49 49 49 49 49 49 45 45 49 49 49 49 49 49 49 49 45 49 49 49 45 49 45 49 49 49 45 45 49 45 45 45 49 49 49 49 45 49 49 49 49 49 49 49 49 49 49 49 45 49 45 49 49 49 49 49 49 45 49 49 49 45 49 49 49 49 45 49 45 49 49 45 49 49 49 49 49 */
push ebp ; Save old bp mov ebp, esp ; Set stack location push edi ; Save old edi mov edi, [ebp+8] ; Move param info edi xor ecx, ecx ; Zeroize counter not ecx ; Maximize counter xor al, al ; Zero byte for comparison repne scasb ; Scan string repeating sub edi, [ebp+8] ; Calculate distance mov eax, edi ; Set retval dec eax ; Subtract one (don't count \0) pop edi ; Restore edi mov esp, ebp ; Restore stack frame pop ebp ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x11502, %r11 nop nop add %rdx, %rdx mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%r11) nop nop nop nop nop add $36203, %rdx lea addresses_A_ht+0x508a, %r15 xor $25238, %r8 mov $0x6162636465666768, %rax movq %rax, %xmm4 and $0xffffffffffffffc0, %r15 vmovntdq %ymm4, (%r15) nop inc %rsi lea addresses_normal_ht+0xfbca, %rsi lea addresses_UC_ht+0x1106a, %rdi nop nop cmp $32755, %rdx mov $7, %rcx rep movsb nop sub $25672, %rcx lea addresses_WT_ht+0x1c48a, %rax nop nop nop nop nop sub $1165, %r8 movb $0x61, (%rax) nop nop nop xor $1010, %rcx lea addresses_UC_ht+0xce0a, %rsi lea addresses_WT_ht+0x4822, %rdi nop nop nop add $59425, %rdx mov $64, %rcx rep movsb nop nop nop and %rax, %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_D+0x910a, %rsi nop nop nop nop and %rbp, %rbp movb $0x51, (%rsi) nop nop nop cmp %rdi, %rdi // Store lea addresses_normal+0x1ff8a, %r8 nop and %rbx, %rbx mov $0x5152535455565758, %rsi movq %rsi, %xmm3 vmovups %ymm3, (%r8) nop nop add $6529, %rdi // Store lea addresses_normal+0x1ff8a, %rdi nop sub $42588, %rsi movw $0x5152, (%rdi) nop nop nop add %rcx, %rcx // Store lea addresses_normal+0x1778a, %rcx clflush (%rcx) nop inc %rbp mov $0x5152535455565758, %rdi movq %rdi, %xmm1 movups %xmm1, (%rcx) and $60350, %rbx // Store lea addresses_UC+0x1c37a, %rbx and $35627, %r12 movl $0x51525354, (%rbx) nop nop nop add %r12, %r12 // Store lea addresses_normal+0x1ba8a, %r12 nop nop xor %rsi, %rsi mov $0x5152535455565758, %rdi movq %rdi, %xmm6 movups %xmm6, (%r12) sub %rbp, %rbp // Store lea addresses_D+0x62ce, %rsi nop xor %r12, %r12 mov $0x5152535455565758, %rbx movq %rbx, %xmm6 movups %xmm6, (%rsi) cmp %rbx, %rbx // Store lea addresses_RW+0x6a0a, %rbp nop nop sub $19131, %rbx mov $0x5152535455565758, %r8 movq %r8, (%rbp) dec %rdi // Faulty Load lea addresses_normal+0x1ff8a, %r8 nop nop nop nop and %rdi, %rdi movups (%r8), %xmm2 vpextrq $1, %xmm2, %rcx lea oracles, %rdi and $0xff, %rcx shlq $12, %rcx mov (%rdi,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_normal', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_A_ht', 'same': True, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'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 */
; A121240: Numerator of sum_{k=1..n} 1/2^prime(k). ; Submitted by Christian Krause ; 1,3,13,53,849,3397,54353,217413,3478609,222630977,890523909,56993530177,911896482833,3647585931333,58361374901329,3735127993685057,239048191595843649,956192766383374597,61196337048535974209 seq $0,40 ; The prime numbers. sub $0,1 seq $0,72762 ; n coded as binary word of length=n with k-th bit set iff k is prime (1<=k<=n), decimal value.
; ; Small C+ Runtime Library ; ; CP/M functions ; ; CPM Plus "userf" custom Amstrad calls, for Amstrad CPC & PCW and ZX Spectrum +3 ; ; ; $Id: a_biosver.asm,v 1.2 2017-01-02 20:06:48 aralbrec Exp $ ; SECTION code_clib PUBLIC a_biosver PUBLIC _a_biosver EXTERN subuserf INCLUDE "target/cpc/def/amstrad_userf.def" a_biosver: _a_biosver: call subuserf defw CD_VERSION ld h,b ld l,c ret
; A276960: a(n) = A000262(n)^2. ; 1,1,9,169,5329,251001,16410601,1416242689,155514288609,21128299481809,3474052208270281,679096541717605881,155504946117339546289,41199419449380747871369,12496348897836314700506409 seq $0,262 ; Number of "sets of lists": number of partitions of {1,...,n} into any number of lists, where a list means an ordered subset. pow $0,2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xc68f, %rsi lea addresses_A_ht+0x1b4db, %rdi nop nop nop nop nop add %rbp, %rbp mov $42, %rcx rep movsq nop nop nop nop and $64098, %rcx lea addresses_A_ht+0x12a5b, %r8 nop nop nop nop nop add $527, %r12 mov (%r8), %r11w nop nop xor $62120, %rsi lea addresses_WT_ht+0xfe1b, %rsi lea addresses_UC_ht+0x109db, %rdi nop nop nop xor %rbp, %rbp mov $40, %rcx rep movsw nop nop xor $49650, %r11 lea addresses_WC_ht+0x1c2bb, %rsi lea addresses_WC_ht+0x1b436, %rdi nop nop nop sub $41957, %r12 mov $82, %rcx rep movsq cmp %rcx, %rcx lea addresses_A_ht+0xe2db, %rsi lea addresses_normal_ht+0x10e39, %rdi nop nop nop nop xor $31512, %rdx mov $37, %rcx rep movsb sub %r8, %r8 lea addresses_normal_ht+0x191db, %rcx nop nop dec %r8 and $0xffffffffffffffc0, %rcx movaps (%rcx), %xmm6 vpextrq $1, %xmm6, %rsi nop nop nop sub %rcx, %rcx lea addresses_WC_ht+0xe3db, %rsi nop nop nop cmp $35582, %r11 vmovups (%rsi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %rdi nop nop nop nop and %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r14 push %rax push %rbp push %rbx push %rcx push %rdi // Store lea addresses_D+0x1db, %rdi nop nop and $7222, %rax movw $0x5152, (%rdi) nop nop nop nop nop add %rbx, %rbx // Faulty Load lea addresses_D+0x1db, %rbx nop add $38662, %rdi mov (%rbx), %eax lea oracles, %rbx and $0xff, %rax shlq $12, %rax mov (%rbx,%rax,1), %rax pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}} [Faulty Load] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': True}} {'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'} {'52': 21829} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
; A010914: Pisot sequence E(5,17), a(n) = floor(a(n-1)^2 / a(n-2) + 1/2). ; 5,17,58,198,676,2308,7880,26904,91856,313616,1070752,3655776,12481600,42614848,145496192,496755072,1696027904,5790601472,19770350080,67500197376,230460089344,786839962624,2686439671808,9172078761984,31315435704320,106917585293312,365039469764608,1246322708471808,4255211894358016 mov $1,5 mov $2,2 lpb $0,1 sub $0,1 add $2,$1 mul $1,2 add $1,$2 lpe
; subtracts the amount the player paid from their money ; sets carry flag if there is enough money and unsets carry flag if not SubtractAmountPaidFromMoney_: ld de,wPlayerMoney ld hl,hMoney ; total price of items ld c,3 ; length of money in bytes call StringCmp ret c ld de,wPlayerMoney + 2 ld hl,hMoney + 2 ; total price of items ld c,3 ; length of money in bytes predef SubBCDPredef ; subtract total price from money ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID ; redraw money text box and a ret
; A017723: Binomial coefficients C(n,59). ; 1,60,1830,37820,595665,7624512,82598880,778789440,6522361560,49280065120,340032449328,2163842859360,12802736917880,70907466006720,369731787035040,1824010149372864,8550047575185300,38223742100828400,163512674542432600,671262558647881200,2651487106659130740,10100903263463355200,37189689288205989600,132589327027517006400,458538089303496313800,1540687980059747614368,5036864550195328739280,16043346345066602651040,49848969000742658237160,151265836967770824995520,448755316337720114153376,1302838015174026137864640,3704945605651136829552570,10328939264239532979358680,28252686811008134325892860,75878644578136132189540824,200235312081192571055732730,519529458372823968144603840,1326167301635892760790172960,3332420398982499757882998720,8247740487481686900760421832,20116440213369968050635175200,48375249084532542217003635600,114750590851681844328706298400,268620701311891590133107925800,620812287476371674974293872960,1417071525761283171136975144800,3195948547461617364691901390400,7124301970383188708792363516100,15702543118395599603052556321200,34231543998102407134654572780216,73832741956691466368862804035760,157604506869091399364303293230180,333051033383740315637772997014720,696940125414123253093858308567840,1444566805403819106412724494122432,2966521118239985664954702086144280,6037130696769093633942902491100640,12178349853827309571919303301013360,24356699707654619143838606602026720,48307454420181661301946569760686328,95031057875767202561206366742333760,185463838757545669514612425416490080,359152195689215423504487553981139520,690245626090210892047687017807502515 add $0,59 bin $0,59
; ; MSX specific routines ; by Stefano Bodrato, December 2007 ; ; int msx_break(); ; ; Checks if the Ctrl-STOP key is being pressed (1 = pressed, 0 = not pressed) ; ; ; $Id: msx_break.asm,v 1.5 2016-06-16 19:30:25 dom Exp $ ; SECTION code_clib PUBLIC msx_break PUBLIC _msx_break EXTERN msxbios IF FORmsx INCLUDE "target/msx/def/msxbios.def" ELSE INCLUDE "target/svi/def/svibios.def" ENDIF msx_break: _msx_break: push ix ld ix,BREAKX call msxbios sbc a,a and 1 ; if pressed, BREAKX returns $FF ld l,a ld h,0 pop ix ret
/* * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #include <Kernel/Debug.h> #include <Kernel/Locking/Mutex.h> #include <Kernel/Locking/MutexProtected.h> #include <Kernel/Net/ARP.h> #include <Kernel/Net/EtherType.h> #include <Kernel/Net/EthernetFrameHeader.h> #include <Kernel/Net/ICMP.h> #include <Kernel/Net/IPv4.h> #include <Kernel/Net/IPv4Socket.h> #include <Kernel/Net/LoopbackAdapter.h> #include <Kernel/Net/NetworkTask.h> #include <Kernel/Net/NetworkingManagement.h> #include <Kernel/Net/Routing.h> #include <Kernel/Net/TCP.h> #include <Kernel/Net/TCPSocket.h> #include <Kernel/Net/UDP.h> #include <Kernel/Net/UDPSocket.h> #include <Kernel/Process.h> namespace Kernel { static void handle_arp(EthernetFrameHeader const&, size_t frame_size); static void handle_ipv4(EthernetFrameHeader const&, size_t frame_size, Time const& packet_timestamp); static void handle_icmp(EthernetFrameHeader const&, IPv4Packet const&, Time const& packet_timestamp); static void handle_udp(IPv4Packet const&, Time const& packet_timestamp); static void handle_tcp(IPv4Packet const&, Time const& packet_timestamp); static void send_delayed_tcp_ack(RefPtr<TCPSocket> socket); static void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, RefPtr<NetworkAdapter> adapter); static void flush_delayed_tcp_acks(); static void retransmit_tcp_packets(); static Thread* network_task = nullptr; static HashTable<RefPtr<TCPSocket>>* delayed_ack_sockets; [[noreturn]] static void NetworkTask_main(void*); void NetworkTask::spawn() { RefPtr<Thread> thread; auto name = KString::try_create("NetworkTask"); if (name.is_error()) TODO(); (void)Process::create_kernel_process(thread, name.release_value(), NetworkTask_main, nullptr); network_task = thread; } bool NetworkTask::is_current() { return Thread::current() == network_task; } void NetworkTask_main(void*) { delayed_ack_sockets = new HashTable<RefPtr<TCPSocket>>; WaitQueue packet_wait_queue; int pending_packets = 0; NetworkingManagement::the().for_each([&](auto& adapter) { dmesgln("NetworkTask: {} network adapter found: hw={}", adapter.class_name(), adapter.mac_address().to_string()); if (adapter.class_name() == "LoopbackAdapter"sv) { adapter.set_ipv4_address({ 127, 0, 0, 1 }); adapter.set_ipv4_netmask({ 255, 0, 0, 0 }); adapter.set_ipv4_gateway({ 0, 0, 0, 0 }); } adapter.on_receive = [&]() { pending_packets++; packet_wait_queue.wake_all(); }; }); auto dequeue_packet = [&pending_packets](u8* buffer, size_t buffer_size, Time& packet_timestamp) -> size_t { if (pending_packets == 0) return 0; size_t packet_size = 0; NetworkingManagement::the().for_each([&](auto& adapter) { if (packet_size || !adapter.has_queued_packets()) return; packet_size = adapter.dequeue_packet(buffer, buffer_size, packet_timestamp); pending_packets--; dbgln_if(NETWORK_TASK_DEBUG, "NetworkTask: Dequeued packet from {} ({} bytes)", adapter.name(), packet_size); }); return packet_size; }; size_t buffer_size = 64 * KiB; auto region_or_error = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Memory::Region::Access::ReadWrite); if (region_or_error.is_error()) TODO(); auto buffer_region = region_or_error.release_value(); auto buffer = (u8*)buffer_region->vaddr().get(); Time packet_timestamp; for (;;) { flush_delayed_tcp_acks(); retransmit_tcp_packets(); size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp); if (!packet_size) { auto timeout_time = Time::from_milliseconds(500); auto timeout = Thread::BlockTimeout { false, &timeout_time }; [[maybe_unused]] auto result = packet_wait_queue.wait_on(timeout, "NetworkTask"); continue; } if (packet_size < sizeof(EthernetFrameHeader)) { dbgln("NetworkTask: Packet is too small to be an Ethernet packet! ({})", packet_size); continue; } auto& eth = *(EthernetFrameHeader const*)buffer; dbgln_if(ETHERNET_DEBUG, "NetworkTask: From {} to {}, ether_type={:#04x}, packet_size={}", eth.source().to_string(), eth.destination().to_string(), eth.ether_type(), packet_size); switch (eth.ether_type()) { case EtherType::ARP: handle_arp(eth, packet_size); break; case EtherType::IPv4: handle_ipv4(eth, packet_size, packet_timestamp); break; case EtherType::IPv6: // ignore break; default: dbgln_if(ETHERNET_DEBUG, "NetworkTask: Unknown ethernet type {:#04x}", eth.ether_type()); } } } void handle_arp(EthernetFrameHeader const& eth, size_t frame_size) { constexpr size_t minimum_arp_frame_size = sizeof(EthernetFrameHeader) + sizeof(ARPPacket); if (frame_size < minimum_arp_frame_size) { dbgln("handle_arp: Frame too small ({}, need {})", frame_size, minimum_arp_frame_size); return; } auto& packet = *static_cast<ARPPacket const*>(eth.payload()); if (packet.hardware_type() != 1 || packet.hardware_address_length() != sizeof(MACAddress)) { dbgln("handle_arp: Hardware type not ethernet ({:#04x}, len={})", packet.hardware_type(), packet.hardware_address_length()); return; } if (packet.protocol_type() != EtherType::IPv4 || packet.protocol_address_length() != sizeof(IPv4Address)) { dbgln("handle_arp: Protocol type not IPv4 ({:#04x}, len={})", packet.protocol_type(), packet.protocol_address_length()); return; } dbgln_if(ARP_DEBUG, "handle_arp: operation={:#04x}, sender={}/{}, target={}/{}", packet.operation(), packet.sender_hardware_address().to_string(), packet.sender_protocol_address().to_string(), packet.target_hardware_address().to_string(), packet.target_protocol_address().to_string()); if (!packet.sender_hardware_address().is_zero() && !packet.sender_protocol_address().is_zero()) { // Someone has this IPv4 address. I guess we can try to remember that. // FIXME: Protect against ARP spamming. update_arp_table(packet.sender_protocol_address(), packet.sender_hardware_address(), UpdateArp::Set); } if (packet.operation() == ARPOperation::Request) { // Who has this IP address? if (auto adapter = NetworkingManagement::the().from_ipv4_address(packet.target_protocol_address())) { // We do! dbgln("handle_arp: Responding to ARP request for my IPv4 address ({})", adapter->ipv4_address()); ARPPacket response; response.set_operation(ARPOperation::Response); response.set_target_hardware_address(packet.sender_hardware_address()); response.set_target_protocol_address(packet.sender_protocol_address()); response.set_sender_hardware_address(adapter->mac_address()); response.set_sender_protocol_address(adapter->ipv4_address()); adapter->send(packet.sender_hardware_address(), response); } return; } } void handle_ipv4(EthernetFrameHeader const& eth, size_t frame_size, Time const& packet_timestamp) { constexpr size_t minimum_ipv4_frame_size = sizeof(EthernetFrameHeader) + sizeof(IPv4Packet); if (frame_size < minimum_ipv4_frame_size) { dbgln("handle_ipv4: Frame too small ({}, need {})", frame_size, minimum_ipv4_frame_size); return; } auto& packet = *static_cast<IPv4Packet const*>(eth.payload()); if (packet.length() < sizeof(IPv4Packet)) { dbgln("handle_ipv4: IPv4 packet too short ({}, need {})", packet.length(), sizeof(IPv4Packet)); return; } size_t actual_ipv4_packet_length = frame_size - sizeof(EthernetFrameHeader); if (packet.length() > actual_ipv4_packet_length) { dbgln("handle_ipv4: IPv4 packet claims to be longer than it is ({}, actually {})", packet.length(), actual_ipv4_packet_length); return; } dbgln_if(IPV4_DEBUG, "handle_ipv4: source={}, destination={}", packet.source(), packet.destination()); NetworkingManagement::the().for_each([&](auto& adapter) { if (adapter.link_up()) { auto my_net = adapter.ipv4_address().to_u32() & adapter.ipv4_netmask().to_u32(); auto their_net = packet.source().to_u32() & adapter.ipv4_netmask().to_u32(); if (my_net == their_net) update_arp_table(packet.source(), eth.source(), UpdateArp::Set); } }); switch ((IPv4Protocol)packet.protocol()) { case IPv4Protocol::ICMP: return handle_icmp(eth, packet, packet_timestamp); case IPv4Protocol::UDP: return handle_udp(packet, packet_timestamp); case IPv4Protocol::TCP: return handle_tcp(packet, packet_timestamp); default: dbgln_if(IPV4_DEBUG, "handle_ipv4: Unhandled protocol {:#02x}", packet.protocol()); break; } } void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet, Time const& packet_timestamp) { auto& icmp_header = *static_cast<ICMPHeader const*>(ipv4_packet.payload()); dbgln_if(ICMP_DEBUG, "handle_icmp: source={}, destination={}, type={:#02x}, code={:#02x}", ipv4_packet.source().to_string(), ipv4_packet.destination().to_string(), icmp_header.type(), icmp_header.code()); { NonnullRefPtrVector<IPv4Socket> icmp_sockets; IPv4Socket::all_sockets().with_exclusive([&](auto& sockets) { for (auto& socket : sockets) { if (socket.protocol() == (unsigned)IPv4Protocol::ICMP) icmp_sockets.append(socket); } }); for (auto& socket : icmp_sockets) socket.did_receive(ipv4_packet.source(), 0, { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp); } auto adapter = NetworkingManagement::the().from_ipv4_address(ipv4_packet.destination()); if (!adapter) return; if (icmp_header.type() == ICMPType::EchoRequest) { auto& request = reinterpret_cast<ICMPEchoPacket const&>(icmp_header); dbgln("handle_icmp: EchoRequest from {}: id={}, seq={}", ipv4_packet.source(), (u16)request.identifier, (u16)request.sequence_number); size_t icmp_packet_size = ipv4_packet.payload_size(); if (icmp_packet_size < sizeof(ICMPEchoPacket)) { dbgln("handle_icmp: EchoRequest packet is too small, ignoring."); return; } auto ipv4_payload_offset = adapter->ipv4_payload_offset(); auto packet = adapter->acquire_packet_buffer(ipv4_payload_offset + icmp_packet_size); if (!packet) { dbgln("Could not allocate packet buffer while sending ICMP packet"); return; } adapter->fill_in_ipv4_header(*packet, adapter->ipv4_address(), eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, icmp_packet_size, 0, 64); memset(packet->buffer->data() + ipv4_payload_offset, 0, sizeof(ICMPEchoPacket)); auto& response = *(ICMPEchoPacket*)(packet->buffer->data() + ipv4_payload_offset); response.header.set_type(ICMPType::EchoReply); response.header.set_code(0); response.identifier = request.identifier; response.sequence_number = request.sequence_number; if (size_t icmp_payload_size = icmp_packet_size - sizeof(ICMPEchoPacket)) memcpy(response.payload(), request.payload(), icmp_payload_size); response.header.set_checksum(internet_checksum(&response, icmp_packet_size)); // FIXME: What is the right TTL value here? Is 64 ok? Should we use the same TTL as the echo request? adapter->send_packet(packet->bytes()); adapter->release_packet_buffer(*packet); } } void handle_udp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp) { if (ipv4_packet.payload_size() < sizeof(UDPPacket)) { dbgln("handle_udp: Packet too small ({}, need {})", ipv4_packet.payload_size(), sizeof(UDPPacket)); return; } auto& udp_packet = *static_cast<UDPPacket const*>(ipv4_packet.payload()); dbgln_if(UDP_DEBUG, "handle_udp: source={}:{}, destination={}:{}, length={}", ipv4_packet.source(), udp_packet.source_port(), ipv4_packet.destination(), udp_packet.destination_port(), udp_packet.length()); auto socket = UDPSocket::from_port(udp_packet.destination_port()); if (!socket) { dbgln_if(UDP_DEBUG, "handle_udp: No local UDP socket for {}:{}", ipv4_packet.destination(), udp_packet.destination_port()); return; } VERIFY(socket->type() == SOCK_DGRAM); VERIFY(socket->local_port() == udp_packet.destination_port()); auto& destination = ipv4_packet.destination(); if (destination == IPv4Address(255, 255, 255, 255) || NetworkingManagement::the().from_ipv4_address(destination) || socket->multicast_memberships().contains_slow(destination)) socket->did_receive(ipv4_packet.source(), udp_packet.source_port(), { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp); } void send_delayed_tcp_ack(RefPtr<TCPSocket> socket) { VERIFY(socket->mutex().is_locked()); if (!socket->should_delay_next_ack()) { [[maybe_unused]] auto result = socket->send_ack(); return; } delayed_ack_sockets->set(move(socket)); } void flush_delayed_tcp_acks() { Vector<RefPtr<TCPSocket>, 32> remaining_sockets; for (auto& socket : *delayed_ack_sockets) { MutexLocker locker(socket->mutex()); if (socket->should_delay_next_ack()) { remaining_sockets.append(socket); continue; } [[maybe_unused]] auto result = socket->send_ack(); } if (remaining_sockets.size() != delayed_ack_sockets->size()) { delayed_ack_sockets->clear(); if (remaining_sockets.size() > 0) dbgln("flush_delayed_tcp_acks: {} sockets remaining", remaining_sockets.size()); for (auto&& socket : remaining_sockets) delayed_ack_sockets->set(move(socket)); } } void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, RefPtr<NetworkAdapter> adapter) { auto routing_decision = route_to(ipv4_packet.source(), ipv4_packet.destination(), adapter); if (routing_decision.is_zero()) return; auto ipv4_payload_offset = routing_decision.adapter->ipv4_payload_offset(); const size_t options_size = 0; const size_t tcp_header_size = sizeof(TCPPacket) + options_size; const size_t buffer_size = ipv4_payload_offset + tcp_header_size; auto packet = routing_decision.adapter->acquire_packet_buffer(buffer_size); if (!packet) return; routing_decision.adapter->fill_in_ipv4_header(*packet, ipv4_packet.destination(), routing_decision.next_hop, ipv4_packet.source(), IPv4Protocol::TCP, buffer_size - ipv4_payload_offset, 0, 64); auto& rst_packet = *(TCPPacket*)(packet->buffer->data() + ipv4_payload_offset); rst_packet = {}; rst_packet.set_source_port(tcp_packet.destination_port()); rst_packet.set_destination_port(tcp_packet.source_port()); rst_packet.set_window_size(0); rst_packet.set_sequence_number(0); rst_packet.set_ack_number(tcp_packet.sequence_number() + 1); rst_packet.set_data_offset(tcp_header_size / sizeof(u32)); rst_packet.set_flags(TCPFlags::RST | TCPFlags::ACK); rst_packet.set_checksum(TCPSocket::compute_tcp_checksum(ipv4_packet.source(), ipv4_packet.destination(), rst_packet, 0)); routing_decision.adapter->send_packet(packet->bytes()); routing_decision.adapter->release_packet_buffer(*packet); } void handle_tcp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp) { if (ipv4_packet.payload_size() < sizeof(TCPPacket)) { dbgln("handle_tcp: IPv4 payload is too small to be a TCP packet ({}, need {})", ipv4_packet.payload_size(), sizeof(TCPPacket)); return; } auto& tcp_packet = *static_cast<TCPPacket const*>(ipv4_packet.payload()); size_t minimum_tcp_header_size = 5 * sizeof(u32); size_t maximum_tcp_header_size = 15 * sizeof(u32); if (tcp_packet.header_size() < minimum_tcp_header_size || tcp_packet.header_size() > maximum_tcp_header_size) { dbgln("handle_tcp: TCP packet header has invalid size {}", tcp_packet.header_size()); } if (ipv4_packet.payload_size() < tcp_packet.header_size()) { dbgln("handle_tcp: IPv4 payload is smaller than TCP header claims ({}, supposedly {})", ipv4_packet.payload_size(), tcp_packet.header_size()); return; } size_t payload_size = ipv4_packet.payload_size() - tcp_packet.header_size(); dbgln_if(TCP_DEBUG, "handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}", ipv4_packet.source().to_string(), tcp_packet.source_port(), ipv4_packet.destination().to_string(), tcp_packet.destination_port(), tcp_packet.sequence_number(), tcp_packet.ack_number(), tcp_packet.flags(), tcp_packet.has_syn() ? "SYN " : "", tcp_packet.has_ack() ? "ACK " : "", tcp_packet.has_fin() ? "FIN " : "", tcp_packet.has_rst() ? "RST " : "", tcp_packet.window_size(), payload_size); auto adapter = NetworkingManagement::the().from_ipv4_address(ipv4_packet.destination()); if (!adapter) { dbgln("handle_tcp: this packet is not for me, it's for {}", ipv4_packet.destination()); return; } IPv4SocketTuple tuple(ipv4_packet.destination(), tcp_packet.destination_port(), ipv4_packet.source(), tcp_packet.source_port()); dbgln_if(TCP_DEBUG, "handle_tcp: looking for socket; tuple={}", tuple.to_string()); auto socket = TCPSocket::from_tuple(tuple); if (!socket) { if (!tcp_packet.has_rst()) { dbgln("handle_tcp: No TCP socket for tuple {}. Sending RST.", tuple.to_string()); send_tcp_rst(ipv4_packet, tcp_packet, adapter); } return; } MutexLocker locker(socket->mutex()); VERIFY(socket->type() == SOCK_STREAM); VERIFY(socket->local_port() == tcp_packet.destination_port()); dbgln_if(TCP_DEBUG, "handle_tcp: got socket {}; state={}", socket->tuple().to_string(), TCPSocket::to_string(socket->state())); socket->receive_tcp_packet(tcp_packet, ipv4_packet.payload_size()); switch (socket->state()) { case TCPSocket::State::Closed: dbgln("handle_tcp: unexpected flags in Closed state"); // TODO: we may want to send an RST here, maybe as a configurable option return; case TCPSocket::State::TimeWait: dbgln("handle_tcp: unexpected flags in TimeWait state"); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; case TCPSocket::State::Listen: switch (tcp_packet.flags()) { case TCPFlags::SYN: { dbgln_if(TCP_DEBUG, "handle_tcp: incoming connection"); auto& local_address = ipv4_packet.destination(); auto& peer_address = ipv4_packet.source(); auto client_or_error = socket->try_create_client(local_address, tcp_packet.destination_port(), peer_address, tcp_packet.source_port()); if (client_or_error.is_error()) { dmesgln("handle_tcp: couldn't create client socket: {}", client_or_error.error()); return; } auto client = client_or_error.release_value(); MutexLocker locker(client->mutex()); dbgln_if(TCP_DEBUG, "handle_tcp: created new client socket with tuple {}", client->tuple().to_string()); client->set_sequence_number(1000); client->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); [[maybe_unused]] auto rc2 = client->send_tcp_packet(TCPFlags::SYN | TCPFlags::ACK); client->set_state(TCPSocket::State::SynReceived); return; } default: dbgln("handle_tcp: unexpected flags in Listen state ({:x})", tcp_packet.flags()); // socket->send_tcp_packet(TCPFlags::RST); return; } case TCPSocket::State::SynSent: switch (tcp_packet.flags()) { case TCPFlags::SYN: socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); (void)socket->send_ack(true); socket->set_state(TCPSocket::State::SynReceived); return; case TCPFlags::ACK | TCPFlags::SYN: socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); (void)socket->send_ack(true); socket->set_state(TCPSocket::State::Established); socket->set_setup_state(Socket::SetupState::Completed); socket->set_connected(true); return; case TCPFlags::ACK | TCPFlags::FIN: socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); send_delayed_tcp_ack(socket); socket->set_state(TCPSocket::State::Closed); socket->set_error(TCPSocket::Error::FINDuringConnect); socket->set_setup_state(Socket::SetupState::Completed); return; case TCPFlags::ACK | TCPFlags::RST: socket->set_state(TCPSocket::State::Closed); socket->set_error(TCPSocket::Error::RSTDuringConnect); socket->set_setup_state(Socket::SetupState::Completed); return; default: dbgln("handle_tcp: unexpected flags in SynSent state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); socket->set_error(TCPSocket::Error::UnexpectedFlagsDuringConnect); socket->set_setup_state(Socket::SetupState::Completed); return; } case TCPSocket::State::SynReceived: switch (tcp_packet.flags()) { case TCPFlags::ACK: socket->set_ack_number(tcp_packet.sequence_number() + payload_size); switch (socket->direction()) { case TCPSocket::Direction::Incoming: if (!socket->has_originator()) { dbgln("handle_tcp: connection doesn't have an originating socket; maybe it went away?"); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } socket->set_state(TCPSocket::State::Established); socket->set_setup_state(Socket::SetupState::Completed); socket->release_to_originator(); return; case TCPSocket::Direction::Outgoing: socket->set_state(TCPSocket::State::Established); socket->set_setup_state(Socket::SetupState::Completed); socket->set_connected(true); return; default: dbgln("handle_tcp: got ACK in SynReceived state but direction is invalid ({})", TCPSocket::to_string(socket->direction())); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } VERIFY_NOT_REACHED(); case TCPFlags::SYN: dbgln("handle_tcp: ignoring SYN for partially established connection"); return; default: dbgln("handle_tcp: unexpected flags in SynReceived state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::CloseWait: switch (tcp_packet.flags()) { default: dbgln("handle_tcp: unexpected flags in CloseWait state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::LastAck: switch (tcp_packet.flags()) { case TCPFlags::ACK: socket->set_ack_number(tcp_packet.sequence_number() + payload_size); socket->set_state(TCPSocket::State::Closed); return; default: dbgln("handle_tcp: unexpected flags in LastAck state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::FinWait1: switch (tcp_packet.flags()) { case TCPFlags::ACK: socket->set_ack_number(tcp_packet.sequence_number() + payload_size); socket->set_state(TCPSocket::State::FinWait2); return; case TCPFlags::FIN: socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); socket->set_state(TCPSocket::State::Closing); return; default: dbgln("handle_tcp: unexpected flags in FinWait1 state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::FinWait2: switch (tcp_packet.flags()) { case TCPFlags::FIN: socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); socket->set_state(TCPSocket::State::TimeWait); return; case TCPFlags::ACK | TCPFlags::RST: socket->set_state(TCPSocket::State::Closed); return; default: dbgln("handle_tcp: unexpected flags in FinWait2 state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::Closing: switch (tcp_packet.flags()) { case TCPFlags::ACK: socket->set_ack_number(tcp_packet.sequence_number() + payload_size); socket->set_state(TCPSocket::State::TimeWait); return; default: dbgln("handle_tcp: unexpected flags in Closing state ({:x})", tcp_packet.flags()); (void)socket->send_tcp_packet(TCPFlags::RST); socket->set_state(TCPSocket::State::Closed); return; } case TCPSocket::State::Established: if (tcp_packet.has_rst()) { socket->set_state(TCPSocket::State::Closed); return; } if (tcp_packet.sequence_number() != socket->ack_number()) { dbgln_if(TCP_DEBUG, "Discarding out of order packet: seq {} vs. ack {}", tcp_packet.sequence_number(), socket->ack_number()); if (socket->duplicate_acks() < TCPSocket::maximum_duplicate_acks) { dbgln_if(TCP_DEBUG, "Sending ACK with same ack number to trigger fast retransmission"); socket->set_duplicate_acks(socket->duplicate_acks() + 1); [[maybe_unused]] auto result = socket->send_ack(true); } return; } socket->set_duplicate_acks(0); if (tcp_packet.has_fin()) { if (payload_size != 0) socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp); socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); send_delayed_tcp_ack(socket); socket->set_state(TCPSocket::State::CloseWait); socket->set_connected(false); return; } if (payload_size) { if (socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp)) { socket->set_ack_number(tcp_packet.sequence_number() + payload_size); dbgln_if(TCP_DEBUG, "Got packet with ack_no={}, seq_no={}, payload_size={}, acking it with new ack_no={}, seq_no={}", tcp_packet.ack_number(), tcp_packet.sequence_number(), payload_size, socket->ack_number(), socket->sequence_number()); send_delayed_tcp_ack(socket); } } } } void retransmit_tcp_packets() { // We must keep the sockets alive until after we've unlocked the hash table // in case retransmit_packets() realizes that it wants to close the socket. NonnullRefPtrVector<TCPSocket, 16> sockets; TCPSocket::sockets_for_retransmit().for_each_shared([&](const auto& socket) { sockets.append(socket); }); for (auto& socket : sockets) { MutexLocker socket_locker(socket.mutex()); socket.retransmit_packets(); } } }
SendToBack PROTO :DWORD UpdateRAEdit PROTO :DWORD CreateDlg PROTO :HWND MakeDialog PROTO :DWORD,:DWORD DlgEnumProc PROTO :DWORD,:DWORD PGM_FIRST equ 1400h PGM_SETCHILD equ PGM_FIRST+1 PGM_RECALCSIZE equ PGM_FIRST+2 PGM_FORWARDMOUSE equ PGM_FIRST+3 PGM_SETBKCOLOR equ PGM_FIRST+4 PGM_GETBKCOLOR equ PGM_FIRST+5 PGM_SETBORDER equ PGM_FIRST+6 PGM_GETBORDER equ PGM_FIRST+7 PGM_SETPOS equ PGM_FIRST+8 PGM_GETPOS equ PGM_FIRST+9 PGM_SETBUTTONSIZE equ PGM_FIRST+10 PGM_GETBUTTONSIZE equ PGM_FIRST+11 PGM_GETBUTTONSTATE equ PGM_FIRST+12 PGM_GETDROPTARGET equ CCM_GETDROPTARGET ID_DIALOG equ 65502 WS_ALWAYS equ WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN MAXMULSEL equ 256 MODE_NOTHING equ 0 MODE_DRAWING equ 1 MODE_MOVING equ 2 MODE_SIZING equ 3 MODE_MULTISEL equ 4 MODE_MULTISELMOVE equ 5 MODE_SELECT equ 6 MODE_MOVINIT equ 7 MODE_MULTISELMOVEINIT equ 8 INIT_NPR equ 32+32+8 .data szPos db 'Pos: X:',32 dup(0) DlgX dd 10 DlgY dd 10 szICODLG db '#32106',0 DlgFN db 'MS Sans Serif',0 DlgFS dd 8 DlgID db 'IDD_DLG',0 EdtID db 'IDC_EDT',0 StcID db 'IDC_STC',0 GrbID db 'IDC_GRP',0 BtnID db 'IDC_BTN',0 ChkID db 'IDC_CHK',0 RbtID db 'IDC_RBN',0 CboID db 'IDC_CBO',0 LstID db 'IDC_LST',0 ScbID db 'IDC_SCB',0 TabID db 'IDC_TAB',0 PrbID db 'IDC_PGB',0 TrvID db 'IDC_TRV',0 LsvID db 'IDC_LSV',0 TrbID db 'IDC_TRB',0 UdnID db 'IDC_UDN',0 IcoID db 'IDC_IMG',0 TbrID db 'IDC_TBR',0 SbrID db 'IDC_SBR',0 DtpID db 'IDC_DTP',0 MviID db 'IDC_MVI',0 RedID db 'IDC_RED',0 UdcID db 'IDC_UDC',0 CbeID db 'IDC_CBE',0 ShpID db 'IDC_SHP',0 IpaID db 'IDC_IPA',0 AniID db 'IDC_ANI',0 HotID db 'IDC_HOT',0 PgrID db 'IDC_PGR',0 RebID db 'IDC_REB',0 HdrID db 'IDC_HDR',0 LnkID db 'IDC_LNK',0 LnkCAP db '<a></a>',0 szMnu db ' &File , &Edit , &Help ',0 nPr dd INIT_NPR PrAll db '(Name),(ID),Left,Top,Width,Height,Caption,Border,SysMenu,MaxButton,MinButton,Enabled,Visible,Clipping,ScrollBar,Default,Auto,Alignment,Mnemonic,WordWrap,MultiLine,Type,Locked,Child,SizeBorder,TabStop,Font,Menu,Class,Notify,AutoScroll,WantCr,' db 'Sort,Flat,(StartID),TabIndex,Format,SizeGrip,Group,Icon,UseTabs,StartupPos,Orientation,SetBuddy,MultiSelect,HideSel,TopMost,xExStyle,xStyle,IntegralHgt,Image,Buttons,PopUp,OwnerDraw,Transp,Timer,AutoPlay,WeekNum,AviClip,AutoSize,ToolTip,Wrap,' db 'Divider,DragDrop,' db 'Smooth,Ellipsis,Language,HasStrings,(HelpID),File,MenuEx,SaveSel' PrCust db 512 dup(0) ;0-Dialog ctltypes dd 0 ; dd offset szDlgChildClass dd offset szNULL dd 0 ;Keep size dd WS_VISIBLE or WS_CAPTION or WS_MAXIMIZEBOX or WS_MINIMIZEBOX or WS_SYSMENU or WS_SIZEBOX dd 0C00000h ;Typemask dd 0 ;ExStyle dd offset DlgID dd offset DlgID dd offset szDIALOGEX dd 200 ;xsize dd 300 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111111111100000000110111000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00100000010000111000100000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00101000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;1-Edit dd 1 dd offset szEditClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or ES_LEFT dd 0 ;Typemask dd WS_EX_CLIENTEDGE dd offset EdtID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000111100100111001000011b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000001011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;2-Static dd 2 dd offset szStaticClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or SS_LEFT dd SS_TYPEMASK ;Typemask dd 0 ;ExStyle dd offset StcID dd offset StcID dd offset szCONTROL dd 82 ;xsize dd 16 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000111000111000000000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 01001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;3-GroupBox dd 3 dd offset szButtonClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or BS_GROUPBOX dd 0Fh ;Typemask dd 0 ;ExStyle dd offset GrbID dd offset GrbID dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000111000000000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;4-Pushbutton dd 4 dd offset szButtonClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or BS_PUSHBUTTON dd 0Fh ;Typemask dd 0 ;ExStyle dd offset BtnID dd offset BtnID dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000111010100110001000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;5-CheckBox dd 5 dd offset szButtonClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or BS_AUTOCHECKBOX dd 0Fh ;Typemask dd 0 ;ExStyle dd offset ChkID dd offset ChkID dd offset szCONTROL dd 82 ;xsize dd 16 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111110000111001100100001000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010010000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;6-RadioButton dd 6 dd offset szButtonClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or BS_AUTORADIOBUTTON dd 0Fh ;Typemask dd 0 ;ExStyle dd offset RbtID dd offset RbtID dd offset szCONTROL dd 82 ;xsize dd 16 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111110000111001100100001000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010010000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;7-ComboBox dd 7 dd offset szComboBoxClass dd 1 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or CBS_DROPDOWNLIST dd 03h ;Typemask dd 0 ;ExStyle dd offset CboID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111100000010001000010b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 10010000000000011100010000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00011000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;8-ListBox dd 8 dd offset szListBoxClass dd 1 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or LBS_HASSTRINGS or LBS_NOINTEGRALHEIGHT or LBS_NOTIFY dd 0 ;Typemask dd WS_EX_CLIENTEDGE dd offset LstID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111100000000001000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 10010000100010011100010000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00011000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;9-HScrollBar dd 9 dd offset szScrollBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or SBS_HORZ dd 0 ;Typemask dd 0 ;ExStyle dd offset ScbID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 16 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;10-VScrollBar dd 10 dd offset szScrollBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or SBS_VERT dd 0 ;Typemask dd 0 ;ExStyle dd offset ScbID dd offset szNULL dd offset szCONTROL dd 16 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;11-TabControl dd 11 dd offset szTabControlClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or TCS_FOCUSNEVER dd 0 ;Typemask dd 0 ;ExStyle dd offset TabID dd offset szNULL dd offset szCONTROL dd 150 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000100100001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011001000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;12-ProgressBar dd 12 dd offset szProgressBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset PrbID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 16 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000001000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 10001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;13-TreeView dd 13 dd offset szTreeViewClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or TVS_HASLINES or TVS_LINESATROOT or TVS_HASBUTTONS dd 0 ;Typemask dd WS_EX_CLIENTEDGE dd offset TrvID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000010001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000001011001000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;14-ListViev dd 14 dd offset szListViewClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or LVS_LIST dd LVS_TYPEMASK ;Typemask dd WS_EX_CLIENTEDGE dd offset LsvID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000100010001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 10010000000001011000010000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;15-TrackBar dd 15 dd offset szTrackBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset TrbID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;16-UpDown dd 16 dd offset szUpDownClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset UdnID dd offset szNULL dd offset szCONTROL dd 16 ;xsize dd 19 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111001100000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000001100011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;17-Image dd 17 dd offset szStaticClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or SS_ICON or SS_CENTERIMAGE dd SS_TYPEMASK ;Typemask dd 0 ;ExStyle dd offset IcoID dd offset szNULL dd offset szCONTROL dd 31 ;xsize dd 31 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000100010000000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011010000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;18-ToolBar dd 18 dd offset szToolBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or CCS_TOP dd 0 ;Typemask dd 0 ;ExStyle dd offset TbrID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000100000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 01010000000000011000000000011110b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;19-StatusBar dd 19 dd offset szStatusBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or CCS_BOTTOM dd 0 ;Typemask dd 0 ;ExStyle dd offset SbrID dd offset SbrID dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11000010000111000100000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010100000000011000000000011000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;20-DateTimePicker dd 20 dd offset szDateTimeClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or 4 dd 0 ;Typemask dd 0 ;ExStyle dd offset DtpID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000010001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00011000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;21-MonthView dd 21 dd offset szMonthViewClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd WS_EX_CLIENTEDGE ;ExStyle dd offset MviID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000010011000000001000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;22-RichEdit dd 22 dd offset szRichEditClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP dd 0 ;Typemask dd WS_EX_CLIENTEDGE ;ExStyle dd offset RedID dd offset RedID dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000111100000101001000011b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000001011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001001000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;23-UserDefinedControl dd 23 dd offset szStaticClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset UdcID dd offset UdcID dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111111000101100000000001001000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;24-ComboBoxEx dd 24 dd offset szComboBoxExClass dd 1 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP or CBS_DROPDOWNLIST dd 03h ;Typemask dd 0 ;ExStyle dd offset CbeID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111100000111000000010001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;25-Static Rect & Line dd 25 dd offset szStaticClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or SS_BLACKRECT dd SS_TYPEMASK ;Typemask dd 0 ;ExStyle dd offset ShpID dd offset szNULL dd offset szCONTROL dd 22 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000010000000100b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;26-IP Address dd 26 dd offset szIPAddressClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP dd 0 ;Typemask dd 0 ;ExStyle dd offset IpaID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;27-Animate dd 27 dd offset szAnimateClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset AniID dd offset szNULL dd offset szCONTROL dd 22 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000100000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000001110100000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;28-HotKey dd 28 dd offset szHotKeyClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or WS_TABSTOP dd 0 ;Typemask dd 0 ;ExStyle dd offset HotID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;29-HPager dd 29 dd offset szPagerClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or PGS_HORZ dd 0 ;Typemask dd 0 ;ExStyle dd offset PgrID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;30-VPager dd 30 dd offset szPagerClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or PGS_VERT dd 0 ;Typemask dd 0 ;ExStyle dd offset PgrID dd offset szNULL dd offset szCONTROL dd 22 ;xsize dd 82 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;31-ReBar dd 31 dd offset szReBarClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD dd 0 ;Typemask dd 0 ;ExStyle dd offset RebID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 22 ;ysize dd 0 ;nmethod dd 0 ;methods dd 11111101000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;32-Header dd 32 dd offset szHeaderClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or HDS_BUTTONS dd 0 ;Typemask dd 0 ;ExStyle dd offset HdrID dd offset szNULL dd offset szCONTROL dd 82 ;xsize dd 19 ;ysize dd 0 ;nMethod dd 0 ;Methods dd 11111101000111000000000000000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011001000000000001b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; ;33-SysLink dd 33 dd offset szSysLinkClass dd 0 ;Keep size dd WS_VISIBLE or WS_CHILD or LWS_TRANSPARENT dd 0 ;Typemask dd 0 ;ExStyle dd offset LnkID dd offset LnkCAP dd offset szCONTROL dd 82 ;xsize dd 19 ;ysize dd 0 ;nMethod dd 0 ;Methods dd 11111111000111000000000001000000b ; NILTWHCBCMMEVCSDAAMWMTLCSTFMCNAW dd 00010000000000011000000000000000b ; SFSTFSGIUSOSMHTxxIIBPOTTAWAATWDD dd 00001000000000000000000000000000b ; SELHHFMS dd 00000000000000000000000000000000b ; custtypes TYPES 32 dup(<?>) dwNOTStyle dd WS_VISIBLE align 4 dlgdata dd WS_CAPTION or DS_SETFONT ;style dd 00000000h ;exstyle dw 0000h ;cdit dw 4096 ;x dw 3072 ;y dw 0060h ;cx dw 0040h ;cy dw 0000h ;menu dw 0000h ;class dw 0000h ;caption dlgps dw 0 ;point size dlgfn dw 33 dup(0) ;face name .data? fGrid dd ? fRSnapToGrid dd ? fSnapToGrid dd ? fShowSizePos dd ? fStyleHex dd ? fSizeToFont dd ? fNoDefines dd ? fSimpleProperty dd ? fNoResetToolbox dd ? hSizeing dd 8 dup(?) hMultiSel dd ? hReSize dd ? OldPt POINT <?> MousePtDown POINT <?> OldSizeingProc dd ? dlgpaste DIALOG MAXMULSEL dup(<?>) SizeRect RECT <?> ;Dialog menu MnuInx dd ? hWinBmp HBITMAP ? dfntwt dd ? dfntht dd ? fntwt dd ? fntht dd ? mpt POINT <?> .code CaptureWin proc LOCAL rect:RECT LOCAL hDC:HDC LOCAL hMemDC:HDC invoke GetDC,hInvisible mov hDC,eax invoke GetClientRect,hDEd,addr rect invoke GetWindowLong,hDEd,DEWM_SCROLLX shl eax,3 mov rect.left,eax invoke GetWindowLong,hDEd,DEWM_SCROLLY shl eax,3 mov rect.top,eax invoke CreateCompatibleDC,hDC mov hMemDC,eax invoke CreateCompatibleBitmap,hDC,rect.right,rect.bottom mov hWinBmp,eax invoke SelectObject,hMemDC,hWinBmp push eax invoke BitBlt,hMemDC,0,0,rect.right,rect.bottom,hDC,rect.left,rect.top,SRCCOPY pop eax invoke SelectObject,hMemDC,eax invoke DeleteDC,hMemDC invoke ReleaseDC,hInvisible,hDC ret CaptureWin endp RestoreWin proc LOCAL rect:RECT LOCAL hDC:HDC LOCAL hMemDC:HDC invoke GetDC,hInvisible mov hDC,eax invoke GetClientRect,hDEd,addr rect invoke GetWindowLong,hDEd,DEWM_SCROLLX shl eax,3 mov rect.left,eax add rect.right,eax invoke GetWindowLong,hDEd,DEWM_SCROLLY shl eax,3 mov rect.top,eax add rect.bottom,eax invoke CreateCompatibleDC,hDC mov hMemDC,eax invoke SelectObject,hMemDC,hWinBmp push eax invoke BitBlt,hDC,rect.left,rect.top,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY pop eax invoke SelectObject,hMemDC,eax invoke DeleteDC,hMemDC invoke ReleaseDC,hInvisible,hDC ret RestoreWin endp GetFreeDlg proc hDlgMem:DWORD mov eax,hDlgMem add eax,sizeof DLGHEAD sub eax,sizeof DIALOG @@: add eax,sizeof DIALOG cmp [eax].DIALOG.hwnd,0 jne @b ret GetFreeDlg endp GetFreeID proc uses esi edi invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax mov eax,[esi].DLGHEAD.ctlid add esi,sizeof DLGHEAD sub esi,sizeof DIALOG mov edi,esi @@: add esi,sizeof DIALOG cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b cmp eax,[esi].DIALOG.id jne @b mov esi,edi inc eax jmp @b @@: .endif ret GetFreeID endp IsFreeID proc uses esi,nID:DWORD invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax add esi,sizeof DLGHEAD sub esi,sizeof DIALOG mov eax,nID @@: add esi,sizeof DIALOG cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b cmp eax,[esi].DIALOG.id jne @b mov eax,0 @@: .endif .if eax ;ID is free mov eax,TRUE .else mov eax,FALSE .endif ret IsFreeID endp GetFreeTab proc uses esi edi LOCAL nTab:DWORD invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax add esi,sizeof DLGHEAD mov edi,esi mov nTab,0 @@: add esi,sizeof DIALOG cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b mov eax,nTab cmp eax,[esi].DIALOG.tab jne @b mov esi,edi inc nTab jmp @b @@: mov eax,nTab .endif ret GetFreeTab endp ;0 1 2 3 4 5 6 7 ;0 1 2 5 3 4 6 7 ;if new>old ; if t>old and t<=new then t=t-1 ;0 1 2 3 4 5 6 7 ;0 2 3 1 4 5 6 7 ;if new<old ; if t<old and t>=new then t=t+1 SetNewTab proc uses esi edi,hCtl:HWND,nTab:DWORD LOCAL nOld:DWORD invoke GetCtrlMem,hCtl .if eax mov esi,eax invoke GetFreeTab .if eax<=nTab .if eax dec eax .endif mov nTab,eax .endif mov eax,[esi].DIALOG.tab mov nOld,eax mov edi,esi invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax add esi,sizeof DLGHEAD @@: add esi,sizeof DIALOG cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b mov eax,nTab .if eax>nOld mov eax,[esi].DIALOG.tab .if eax>nOld && eax<=nTab dec [esi].DIALOG.tab .endif .else mov eax,[esi].DIALOG.tab .if eax<nOld && eax>=nTab inc [esi].DIALOG.tab .endif .endif jmp @b @@: mov eax,nTab mov [edi].DIALOG.tab,eax .endif .endif ret SetNewTab endp InsertTab proc uses esi,nTab:DWORD invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax add esi,sizeof DLGHEAD @@: add esi,sizeof DIALOG cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b mov eax,nTab .if eax<=[esi].DIALOG.tab inc [esi].DIALOG.tab .endif jmp @b @@: .endif ret InsertTab endp DeleteTab proc uses esi,nTab:DWORD invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax lea esi,[eax+sizeof DLGHEAD] @@: lea esi,[esi+sizeof DIALOG] cmp [esi].DIALOG.hwnd,0 je @f cmp [esi].DIALOG.hwnd,-1 je @b mov eax,nTab .if eax<[esi].DIALOG.tab dec [esi].DIALOG.tab .endif jmp @b @@: .endif ret DeleteTab endp SetChanged proc fChanged:DWORD invoke GetWindowLong,hDEd,DEWM_PROJECT .if eax mov edx,fChanged mov [eax].PROJECT.changed,edx .endif invoke NotifyParent ret SetChanged endp DestroySizeingRect proc uses edi LOCAL rect:RECT mov edi,offset hSizeing mov ecx,8 @@: mov edx,[edi] .if edx push ecx push edx invoke GetWindowRect,edx,addr rect invoke ScreenToClient,hDEd,addr rect.left invoke ScreenToClient,hDEd,addr rect.right invoke InvalidateRect,hDEd,addr rect,TRUE pop edx invoke DestroyWindow,edx pop ecx .endif xor eax,eax mov [edi],eax add edi,4 loop @b invoke UpdateWindow,hDEd mov hReSize,0 invoke PropertyList,0 ret DestroySizeingRect endp DialogTltSize proc uses esi,ccx:DWORD,ccy:DWORD,cdx:DWORD,cdy:DWORD ; *** MOD add: cdx, cdy LOCAL buffer[64]:BYTE LOCAL pt:POINT LOCAL hDC:HDC LOCAL len:DWORD LOCAL hOldFont:DWORD .if fShowSizePos invoke GetCursorPos,addr mpt add mpt.y,15 add mpt.x,15 lea esi,buffer mov [esi],dword ptr ':L ' ; *** MOD add esi,3 invoke ConvertToDux,ccx invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ':T ' ; *** MOD add esi,3 invoke ConvertToDuy,ccy invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ' ' ; *** MOD add esi,4 mov [esi],dword ptr ':R ' ; *** MOD add esi,3 invoke ConvertToDux,cdx invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ':B ' ; *** MOD add esi,3 invoke ConvertToDuy,cdy invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ' ' ; *** MOD add esi,4 mov [esi],dword ptr ':W ' ; *** MOD add esi,3 mov eax,cdx sub eax,ccx invoke ConvertToDux,eax invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ':H ' ; *** MOD add esi,3 mov eax,cdy sub eax,ccy invoke ConvertToDuy,eax invoke ResEdBinToDec,eax,esi invoke strlen,esi add esi,eax mov [esi],dword ptr ' ' ; *** MOD invoke GetDC,hTlt mov hDC,eax invoke SendMessage,hTlt,WM_GETFONT,0,0 invoke SelectObject,hDC,eax mov hOldFont,eax invoke strlen,addr buffer mov len,eax invoke GetTextExtentPoint32,hDC,addr buffer,len,addr pt invoke SelectObject,hDC,hOldFont invoke ReleaseDC,hTlt,hDC invoke SetWindowText,hTlt,addr buffer invoke MoveWindow,hTlt,mpt.x,mpt.y,pt.x,nPropHt,TRUE invoke ShowWindow,hTlt,SW_SHOWNA invoke InvalidateRect,hTlt,NULL,TRUE invoke UpdateWindow,hTlt .endif ret DialogTltSize endp SizeingProc proc uses edi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL nInx:DWORD LOCAL pt:POINT LOCAL hDC:HDC LOCAL rect:RECT ; *** MOD add LOCAL rect1:RECT ; *** MOD add mov eax,uMsg .if eax>=WM_MOUSEFIRST && eax<=WM_MOUSELAST invoke GetWindowLong,hWin,GWL_USERDATA movzx edx,ax shr eax,16 mov nInx,eax .if edx mov eax,uMsg .if eax==WM_LBUTTONDOWN invoke GetFocus .if eax==hPrpEdtDlgCld invoke SetFocus,hDEd mov eax,nInx mov edi,offset hSizeing mov eax,[edi+eax*4] invoke PostMessage,eax,uMsg,wParam,lParam .else mov des.fmode,MODE_SIZING invoke PropertyList,0 mov eax,lParam movsx edx,ax mov MousePtDown.x,edx shr eax,16 cwde mov MousePtDown.y,eax invoke GetWindowRect,hReSize,addr des.ctlrect invoke ScreenToClient,hInvisible,addr des.ctlrect.left invoke ScreenToClient,hInvisible,addr des.ctlrect.right invoke GetCtrlMem,hReSize mov edi,eax mov eax,[edi].DIALOG.ntype invoke GetTypePtr,eax mov eax,[eax].TYPES.keepsize and eax,1 .if eax invoke ConvertDuyToPix,[edi].DIALOG.duccy add eax,des.ctlrect.top mov des.ctlrect.bottom,eax .endif invoke CaptureWin invoke SetCapture,hWin invoke SendMessage,hWin,WM_MOUSEMOVE,wParam,lParam .endif .elseif eax==WM_LBUTTONUP && des.fmode==MODE_SIZING mov eax,hReSize mov des.hselected,eax invoke SendMessage,hInvisible,WM_LBUTTONUP,0,0 .elseif eax==WM_MOUSEMOVE && des.fmode==MODE_SIZING invoke CopyRect,addr SizeRect,addr des.ctlrect mov eax,lParam movsx edx,ax sub edx,MousePtDown.x mov pt.x,edx shr eax,16 cwde sub eax,MousePtDown.y mov pt.y,eax mov eax,nInx .if eax==0 ;Left,Top mov eax,pt.x add SizeRect.left,eax mov eax,pt.y add SizeRect.top,eax invoke SnapPtDu,addr SizeRect.left .elseif eax==1 ;Center,Top push SizeRect.left mov eax,pt.y add SizeRect.top,eax invoke SnapPtDu,addr SizeRect.left pop SizeRect.left .elseif eax==2 ;Right,Top push SizeRect.left push SizeRect.bottom mov eax,pt.y add SizeRect.top,eax invoke SnapPtDu,addr SizeRect.left mov eax,pt.x add SizeRect.right,eax invoke SnapPtDu,addr SizeRect.right pop SizeRect.bottom pop SizeRect.left .elseif eax==3 ;Left,Middle push SizeRect.top mov eax,pt.x add SizeRect.left,eax invoke SnapPtDu,addr SizeRect.left pop SizeRect.top .elseif eax==4 ;Right,Middle push SizeRect.bottom mov eax,pt.x add SizeRect.right,eax invoke SnapPtDu,addr SizeRect.right pop SizeRect.bottom .elseif eax==5 ;Left,Bottom push SizeRect.top push SizeRect.right mov eax,pt.y add SizeRect.bottom,eax invoke SnapPtDu,addr SizeRect.right mov eax,pt.x add SizeRect.left,eax invoke SnapPtDu,addr SizeRect.left pop SizeRect.right pop SizeRect.top .elseif eax==6 ;Center,Bottom push SizeRect.right mov eax,pt.y add SizeRect.bottom,eax invoke SnapPtDu,addr SizeRect.right pop SizeRect.right .elseif eax==7 ;Right,Bottom mov eax,pt.x add SizeRect.right,eax mov eax,pt.y add SizeRect.bottom,eax invoke SnapPtDu,addr SizeRect.right .endif invoke RestoreWin invoke GetDC,hInvisible mov hDC,eax invoke GetStockObject,BLACK_BRUSH invoke FrameRect,hDC,addr SizeRect,eax invoke ReleaseDC,hInvisible,hDC ; *** MOD ;mov eax,SizeRect.right ;sub eax,SizeRect.left ;mov pt.x,eax ;mov eax,SizeRect.bottom ;sub eax,SizeRect.top ;mov pt.y,eax ;invoke ScreenToClient,des.hdlg,addr SizeRect.left invoke GetCtrlMem,hReSize mov edi,eax mov eax,[edi].DIALOG.ntype .if eax == 0 ; only dialogboxes invoke GetClientRect,des.hdlg,addr rect invoke GetWindowRect,des.hdlg,addr rect1 mov eax,rect.right add eax,SizeRect.right sub eax,SizeRect.left add eax,rect1.left sub eax,rect1.right ; = SizeRectWdt - non client area mov ecx,rect.bottom add ecx,SizeRect.bottom sub ecx,SizeRect.top add ecx,rect1.top sub ecx,rect1.bottom ; = SizeRectHgt - non client area invoke DialogTltSize,0,0,eax,ecx ; *** MOD .else invoke CopyRect,addr rect,addr SizeRect ; *** MOD invoke MapWindowPoints,hInvisible,des.hdlg,addr rect,2 ; *** MOD invoke DialogTltSize,rect.left,rect.top,rect.right,rect.bottom ; *** MOD .endif ; ================ .endif .endif .elseif eax==WM_SETCURSOR invoke GetWindowLong,hWin,GWL_USERDATA movzx eax,ax .if eax invoke LoadCursor,0,eax .else invoke LoadCursor,0,IDC_ARROW .endif invoke SetCursor,eax .else invoke CallWindowProc,OldSizeingProc,hWin,uMsg,wParam,lParam ret .endif xor eax,eax ret SizeingProc endp DrawSizeingItem proc uses edi,xP:DWORD,yP:DWORD,nInx:DWORD,hCur:DWORD,hPar:DWORD,fLocked:DWORD LOCAL hWin:HWND mov eax,nInx shl eax,2 mov edi,offset hSizeing add edi,eax mov eax,[edi] .if eax invoke DestroyWindow,eax .endif invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax!=0 && fLocked==FALSE push [eax].DLGHEAD.locked pop fLocked .endif invoke GetWindowLong,hDEd,DEWM_READONLY .if eax mov fLocked,TRUE .endif .if fLocked mov hCur,NULL .endif .if hCur invoke CreateWindowEx,0, addr szStaticClass,0, WS_CHILD or WS_VISIBLE or SS_WHITERECT or WS_BORDER or SS_NOTIFY, xP,yP,6,6, hPar,0,hInstance,0 .else invoke CreateWindowEx,0, addr szStaticClass,0, WS_CHILD or WS_VISIBLE or SS_GRAYRECT or WS_BORDER or SS_NOTIFY or WS_CLIPSIBLINGS or WS_CLIPCHILDREN, xP,yP,6,6, hPar,0,hInstance,0 .endif mov hWin,eax mov [edi],eax mov eax,nInx shl eax,16 or eax,hCur invoke SetWindowLong,hWin,GWL_USERDATA,eax invoke SetWindowLong,hWin,GWL_WNDPROC,offset SizeingProc mov OldSizeingProc,eax invoke SetWindowPos,hWin,HWND_TOP,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE ret DrawSizeingItem endp DrawMultiSelItem proc xP:DWORD,yP:DWORD,hPar:HWND,fLocked:DWORD,hPrv:HWND LOCAL hWin:HWND .if !fLocked mov edx,WS_CHILD or WS_CLIPSIBLINGS or WS_VISIBLE or SS_WHITERECT or WS_BORDER .else mov edx,WS_CHILD or WS_CLIPSIBLINGS or WS_VISIBLE or SS_GRAYRECT or WS_BORDER .endif invoke CreateWindowEx,0,addr szStaticClass,0,edx,xP,yP,6,6,hPar,0,hInstance,0 mov hWin,eax invoke SetWindowLong,hWin,GWL_USERDATA,hPrv invoke SetWindowPos,hWin,HWND_TOP,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE mov eax,hWin ret DrawMultiSelItem endp DestroyMultiSel proc uses ebx,hSel:HWND LOCAL rect:RECT .if hSel mov ebx,8 .while ebx invoke GetWindowRect,hSel,addr rect invoke ScreenToClient,hDEd,addr rect.left invoke ScreenToClient,hDEd,addr rect.right invoke InvalidateRect,hDEd,addr rect,TRUE invoke GetWindowLong,hSel,GWL_USERDATA push eax invoke DestroyWindow,hSel pop hSel dec ebx .endw .endif mov eax,hSel ret DestroyMultiSel endp MultiSelRect proc uses ebx,hWin:HWND,fLocked:DWORD LOCAL rect:RECT LOCAL ctlrect:RECT LOCAL pt:POINT LOCAL hSel:HWND mov hSel,0 mov ebx,hMultiSel .while ebx invoke GetParent,ebx .if eax==hWin invoke DestroyMultiSel,ebx mov ebx,eax .if hSel invoke SetWindowLong,hSel,GWL_USERDATA,ebx .else mov hMultiSel,ebx .endif xor ebx,ebx .else mov ecx,8 .while ecx push ecx mov hSel,ebx invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop ecx dec ecx .endw .endif .endw mov des.parpt.x,0 mov des.parpt.y,0 invoke ClientToScreen,hWin,addr des.parpt invoke GetWindowRect,hWin,addr rect invoke CopyRect,addr des.ctlrect,addr rect mov eax,des.parpt.x sub rect.left,eax sub rect.right,eax mov eax,des.parpt.y sub rect.top,eax sub rect.bottom,eax invoke CopyRect,addr ctlrect,addr rect sub rect.right,6 sub rect.bottom,6 mov eax,rect.right sub eax,rect.left shr eax,1 add eax,rect.left mov pt.x,eax mov eax,rect.bottom sub eax,rect.top shr eax,1 add eax,rect.top mov pt.y,eax invoke DrawMultiSelItem,rect.left,rect.top,hWin,fLocked,hMultiSel invoke DrawMultiSelItem,pt.x,rect.top,hWin,fLocked,eax invoke DrawMultiSelItem,rect.right,rect.top,hWin,fLocked,eax invoke DrawMultiSelItem,rect.left,pt.y,hWin,fLocked,eax invoke DrawMultiSelItem,rect.right,pt.y,hWin,fLocked,eax invoke DrawMultiSelItem,rect.left,rect.bottom,hWin,fLocked,eax invoke DrawMultiSelItem,pt.x,rect.bottom,hWin,fLocked,eax invoke DrawMultiSelItem,rect.right,rect.bottom,hWin,fLocked,eax mov hMultiSel,eax ret MultiSelRect endp SizeingRect proc uses esi,hWin:HWND,fLocked:DWORD LOCAL fDlg:DWORD LOCAL rect:RECT LOCAL pt:POINT invoke GetCtrlMem,hWin mov esi,eax .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw mov eax,hWin mov hReSize,eax mov fDlg,FALSE mov eax,(DIALOG ptr [esi]).ntype .if !eax mov fDlg,TRUE .elseif eax==18 || eax==19 test [esi].DIALOG.style,CCS_NORESIZE .if ZERO? mov fLocked,TRUE .endif .endif mov des.parpt.x,0 mov des.parpt.y,0 invoke ClientToScreen,hInvisible,addr des.parpt invoke GetWindowRect,hWin,addr rect mov eax,[esi].DIALOG.ntype invoke GetTypePtr,eax mov eax,[eax].TYPES.keepsize and eax,1 .if eax invoke ConvertDuyToPix,[esi].DIALOG.duccy add eax,rect.top mov rect.bottom,eax .endif invoke CopyRect,addr des.ctlrect,addr rect mov eax,des.parpt.x sub rect.left,eax sub rect.right,eax mov eax,des.parpt.y sub rect.top,eax sub rect.bottom,eax sub rect.left,6 sub rect.top,6 mov eax,rect.right sub eax,rect.left shr eax,1 add eax,rect.left mov pt.x,eax mov eax,rect.bottom sub eax,rect.top shr eax,1 add eax,rect.top mov pt.y,eax .if fDlg invoke DrawSizeingItem,rect.left,rect.top,0,0,hInvisible,fLocked invoke DrawSizeingItem,pt.x,rect.top,1,0,hInvisible,fLocked invoke DrawSizeingItem,rect.right,rect.top,2,0,hInvisible,fLocked invoke DrawSizeingItem,rect.left,pt.y,3,0,hInvisible,fLocked invoke DrawSizeingItem,rect.left,rect.bottom,5,0,hInvisible,fLocked .else invoke DrawSizeingItem,rect.left,rect.top,0,IDC_SIZENWSE,hInvisible,fLocked invoke DrawSizeingItem,pt.x,rect.top,1,IDC_SIZENS,hInvisible,fLocked invoke DrawSizeingItem,rect.right,rect.top,2,IDC_SIZENESW,hInvisible,fLocked invoke DrawSizeingItem,rect.left,pt.y,3,IDC_SIZEWE,hInvisible,fLocked invoke DrawSizeingItem,rect.left,rect.bottom,5,IDC_SIZENESW,hInvisible,fLocked .endif invoke DrawSizeingItem,rect.right,pt.y,4,IDC_SIZEWE,hInvisible,fLocked invoke DrawSizeingItem,pt.x,rect.bottom,6,IDC_SIZENS,hInvisible,fLocked invoke DrawSizeingItem,rect.right,rect.bottom,7,IDC_SIZENWSE,hInvisible,fLocked invoke PropertyList,hWin ret SizeingRect endp SnapToGrid proc uses edi,hWin:HWND,lpRect:DWORD LOCAL hPar:HWND call RSnapToGrid .if fRSnapToGrid mov edi,lpRect invoke GetParent,hWin mov hPar,eax mov des.parpt.x,0 mov des.parpt.y,0 invoke ClientToScreen,hPar,addr des.parpt mov eax,[edi].RECT.left sub eax,des.parpt.x cdq idiv Gridcx imul Gridcx add eax,des.parpt.x sub eax,[edi].RECT.left add [edi].RECT.left,eax add [edi].RECT.right,eax mov eax,[edi].RECT.right sub eax,[edi].RECT.left cdq idiv Gridcx imul Gridcx add eax,[edi].RECT.left inc eax mov [edi].RECT.right,eax mov eax,[edi].RECT.top sub eax,des.parpt.y cdq idiv Gridcy imul Gridcy add eax,des.parpt.y sub eax,[edi].RECT.top add [edi].RECT.top,eax add [edi].RECT.bottom,eax mov eax,[edi].RECT.bottom sub eax,[edi].RECT.top cdq idiv Gridcy imul Gridcy add eax,[edi].RECT.top inc eax mov [edi].RECT.bottom,eax .endif ret SnapToGrid endp CtlMultiSelect proc hWin:HWND .if hReSize invoke GetCtrlMem,hWin mov eax,[eax].DIALOG.ntype .if eax && eax!=18 && eax!=19 mov eax,hReSize .if eax!=hWin push eax invoke DestroySizeingRect pop eax invoke MultiSelRect,eax,TRUE invoke MultiSelRect,hWin,FALSE .endif .endif xor eax,eax ret .endif .if hMultiSel invoke GetParent,hMultiSel .if eax==hWin invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax invoke GetParent,eax push eax invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax pop eax .if hMultiSel invoke MultiSelRect,eax,FALSE .else invoke SizeingRect,eax,FALSE .endif xor eax,eax ret .else push eax invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax pop eax invoke MultiSelRect,eax,TRUE .endif .endif invoke MultiSelRect,hWin,FALSE ret CtlMultiSelect endp DesignDummyProc proc uses ebx,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL rect:RECT LOCAL hDlg:HWND LOCAL buffer[16]:BYTE LOCAL pt:POINT LOCAL hMem:DWORD mov eax,uMsg .if eax==WM_CREATE invoke GetWindowLong,hWin,GWL_ID .if eax==123456789 invoke GetWindowLong,hDEd,DEWM_MEMORY mov ebx,eax lea ebx,[ebx+sizeof DLGHEAD+sizeof DIALOG] .while [ebx].DIALOG.hwnd .if [ebx].DIALOG.hwnd!=-1 invoke GetCtrlID,ebx invoke GetDlgItem,des.hdlg,eax mov edx,eax invoke GetWindowRect,edx,addr rect invoke ScreenToClient,hWin,addr rect.left invoke GetCtrlID,ebx invoke CreateWindowEx,NULL,addr szStaticClass,NULL,WS_CHILD or WS_VISIBLE or SS_CENTER or SS_NOTIFY,rect.left,rect.top,22,18,hWin,eax,hInstance,0 push eax invoke SendMessage,hTlt,WM_GETFONT,0,0 pop edx invoke SendMessage,edx,WM_SETFONT,eax,FALSE .endif lea ebx,[ebx+sizeof DIALOG] .endw call SetTabText .endif .elseif eax==WM_CTLCOLORSTATIC invoke SetBkMode,wParam,TRANSPARENT invoke SetTextColor,wParam,0FFFFFFh invoke GetStockObject,BLACK_BRUSH ret .elseif eax==WM_COMMAND invoke GetAsyncKeyState,VK_CONTROL and eax,8000h .if eax invoke GetDlgItem,des.hdlg,wParam invoke GetCtrlMem,eax mov eax,[eax].DIALOG.tab mov nTabSet,eax .else invoke GetDlgItem,des.hdlg,wParam invoke SetNewTab,eax,nTabSet call SetTabText invoke SetChanged,TRUE .endif inc nTabSet .elseif eax==WM_LBUTTONDOWN invoke GetWindowLong,hWin,GWL_ID .if eax==123456789 mov eax,lParam movsx eax,ax mov pt.x,eax mov eax,lParam shr eax,16 movsx eax,ax mov pt.y,eax invoke ClientToScreen,hWin,addr pt invoke GetWindowLong,hDEd,DEWM_MEMORY mov ebx,eax add ebx,sizeof DLGHEAD invoke ScreenToClient,des.hdlg,addr pt mov hDlg,0 .while [ebx].DIALOG.hwnd .if [ebx].DIALOG.hwnd!=-1 invoke GetCtrlID,ebx .if eax invoke GetDlgItem,des.hdlg,eax .else mov eax,des.hdlg .endif mov edx,eax invoke GetWindowRect,edx,addr rect invoke ScreenToClient,des.hdlg,addr rect.left invoke ScreenToClient,des.hdlg,addr rect.right mov eax,pt.x mov edx,pt.y .if sdword ptr eax>=rect.left && sdword ptr eax<=rect.right && sdword ptr edx>=rect.top && sdword ptr edx<=rect.bottom invoke GetCtrlID,ebx .if eax invoke GetDlgItem,des.hdlg,eax .else mov eax,des.hdlg .endif mov hDlg,eax mov hMem,ebx .endif .endif add ebx,sizeof DIALOG .endw .if hDlg mov ebx,hMem .if ![ebx].DIALOG.ntype invoke DestroyWindow,hTabSet invoke ShowWindow,hInvisible,SW_SHOWNA invoke SizeingRect,des.hdlg,FALSE xor eax,eax mov hTabSet,eax ret .endif .endif .endif xor eax,eax .else ExDef: invoke DefWindowProc,hWin,uMsg,wParam,lParam .endif ret SetTabText: mov ecx,1 .while TRUE push ecx push ecx invoke GetDlgItem,hWin,ecx pop ecx .if !eax pop ecx .break .endif push eax invoke GetDlgItem,des.hdlg,ecx invoke GetCtrlMem,eax mov ebx,eax invoke ResEdBinToDec,[ebx].DIALOG.tab,addr buffer pop edx invoke SetWindowText,edx,addr buffer pop ecx inc ecx .endw retn DesignDummyProc endp CreateNewCtl proc uses esi edi,hOwner:DWORD,nType:DWORD,x:DWORD,y:DWORD,ccx:DWORD,ccy:DWORD LOCAL buffer[MaxName]:BYTE invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax invoke GetFreeDlg,eax mov edi,eax invoke GetTypePtr,nType mov esi,eax ;Set default ctl data mov [edi].DIALOG.hwnd,1 mov eax,nType mov [edi].DIALOG.ntype,eax mov eax,(TYPES ptr [esi]).ID mov [edi].DIALOG.ntypeid,eax mov eax,(TYPES ptr [esi]).style mov [edi].DIALOG.style,eax mov eax,(TYPES ptr [esi]).exstyle mov [edi].DIALOG.exstyle,eax mov eax,x mov [edi].DIALOG.dux,eax mov eax,y mov [edi].DIALOG.duy,eax .if ccx<3 && ccy<3 invoke ConvertToDux,[esi].TYPES.xsize invoke SizeX mov ccx,eax invoke ConvertToDuy,[esi].TYPES.ysize invoke SizeY mov ccy,eax .endif mov eax,ccx mov [edi].DIALOG.duccx,eax mov eax,ccy mov [edi].DIALOG.duccy,eax invoke strcpyn,addr buffer,[esi].TYPES.lpidname,MaxName invoke GetUnikeName,addr buffer invoke strcpyn,addr [edi].DIALOG.idname,addr buffer,MaxName invoke strcpyn,addr [edi].DIALOG.caption,[esi].TYPES.lpcaption,MaxCap .if !nType invoke GetFreeProjectitemID,TPE_DIALOG mov [edi].DIALOG.id,eax ;Set default DLGHEAD info mov esi,edi sub esi,sizeof DLGHEAD inc eax mov [esi].DLGHEAD.ctlid,eax mov [esi].DLGHEAD.class,0 mov [esi].DLGHEAD.menuid,0 invoke strcpy,addr [esi].DLGHEAD.font,addr DlgFN mov eax,DlgFS mov [esi].DLGHEAD.fontsize,eax mov [edi].DIALOG.tab,0 .else invoke GetFreeID mov [edi].DIALOG.id,eax mov [edi].DIALOG.tab,-1 invoke GetFreeTab mov [edi].DIALOG.tab,eax .if nType==23 invoke strcpy,addr [edi].DIALOG.class,addr szUserControlClass .endif .endif invoke GetWindowLong,hDEd,DEWM_MEMORY mov esi,eax invoke GetCtrlID,edi push eax invoke MakeDialog,esi,eax invoke SetChanged,TRUE pop edx .if edx invoke GetDlgItem,des.hdlg,edx .endif push eax invoke NotifyParent pop eax .endif ret CreateNewCtl endp DesignInvisibleProc proc uses ebx,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL pt:POINT LOCAL rect:RECT LOCAL rect1:RECT LOCAL hCld:HWND LOCAL hDC:HDC LOCAL parpt:POINT LOCAL fShift:DWORD LOCAL fControl:DWORD LOCAL fChanged:DWORD LOCAL nInx:DWORD LOCAL dblclk:CTLDBLCLICK mov eax,uMsg .if eax==WM_MOUSEMOVE .if des.fmode==MODE_DRAWING call SnapPt invoke RestoreWin mov eax,pt.x mov des.ctlrect.right,eax mov eax,pt.y mov des.ctlrect.bottom,eax invoke CopyRect,addr rect,addr des.ctlrect mov eax,rect.right .if sdword ptr eax<rect.left inc eax xchg rect.left,eax mov rect.right,eax .endif mov eax,rect.bottom .if sdword ptr eax<rect.top inc eax xchg rect.top,eax mov rect.bottom,eax .endif call DrawRect ; *** MOD ;mov eax,rect.right ;sub eax,rect.left ;mov edx,rect.bottom ;sub edx,rect.top invoke MapWindowPoints,hInvisible,des.hdlg,addr rect,2 invoke DialogTltSize,rect.left,rect.top,rect.right,rect.bottom ; =========== .elseif des.fmode==MODE_MOVING || des.fmode==MODE_MOVINIT call SnapPt invoke RestoreWin mov eax,des.ctlrect.right sub eax,des.ctlrect.left ;Width push eax mov eax,des.ctlrect.bottom sub eax,des.ctlrect.top ;Height push eax invoke SnapPtDu,addr des.ctlrect.left pop eax add eax,des.ctlrect.top mov des.ctlrect.bottom,eax pop eax add eax,des.ctlrect.left mov des.ctlrect.right,eax invoke CopyRect,addr rect,addr des.ctlrect mov eax,pt.x sub eax,MousePtDown.x add rect.left,eax mov eax,pt.y sub eax,MousePtDown.y add rect.top,eax invoke SnapPtDu,addr rect.left mov eax,des.ctlrect.right sub eax,des.ctlrect.left add eax,rect.left mov rect.right,eax mov eax,des.ctlrect.bottom sub eax,des.ctlrect.top add eax,rect.top mov rect.bottom,eax call DrawRect mov eax,pt.x sub eax,MousePtDown.x mov edx,pt.y sub edx,MousePtDown.y .if sdword ptr eax<-1 || sdword ptr eax>1 || sdword ptr edx<-1 || sdword ptr edx>1 || des.fmode==MODE_MOVING mov des.fmode,MODE_MOVING ; *** MOD ;invoke ClientToScreen,hInvisible,addr rect.left ;invoke ScreenToClient,des.hdlg,addr rect.left invoke MapWindowPoints,hInvisible,des.hdlg,addr rect,2 invoke DialogTltSize,rect.left,rect.top,rect.right,rect.bottom ; ============= .endif .elseif des.fmode==MODE_MULTISELMOVE || des.fmode==MODE_MULTISELMOVEINIT call SnapPt mov eax,pt.x mov edx,pt.y .if eax!=OldPt.x || edx!=OldPt.y mov des.fmode,MODE_MULTISELMOVE mov OldPt.x,eax mov OldPt.y,edx invoke RestoreWin call DrawMultisel .endif .elseif des.fmode==MODE_SELECT call SnapPt invoke RestoreWin mov eax,pt.x mov des.ctlrect.right,eax mov eax,pt.y mov des.ctlrect.bottom,eax invoke CopyRect,addr rect,addr des.ctlrect mov eax,rect.right .if sdword ptr eax<rect.left inc eax xchg rect.left,eax mov rect.right,eax .endif mov eax,rect.bottom .if sdword ptr eax<rect.top inc eax xchg rect.top,eax mov rect.bottom,eax .endif call DrawRect .elseif !ToolBoxID mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax invoke ClientToScreen,hWin,addr pt invoke GetWindowRect,des.hdlg,addr rect mov eax,rect.left sub pt.x,eax mov eax,rect.top sub pt.y,eax mov eax,pt.x mov edx,pt.y .if eax!=des.dlgpt.x || edx!=des.dlgpt.y mov des.dlgpt.x,eax mov des.dlgpt.y,edx .if (eax>=des.mnurect.left && eax<=des.mnurect.right && edx>=des.mnurect.top && edx <=des.mnurect.bottom) || des.nmnu shl edx,16 movzx eax,ax or eax,edx invoke SendMessage,des.hdlg,WM_NCMOUSEMOVE,wParam,eax .endif .endif .endif .if hStatus invoke GetCursorPos,addr pt invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax invoke ScreenToClient,des.hdlg,addr pt invoke ConvertToDux,pt.x invoke ResEdBinToDec,eax,offset szPos+7 invoke strlen,offset szPos mov dword ptr szPos[eax],':Y ' add eax,4 push eax invoke ConvertToDuy,pt.y mov edx,eax pop eax invoke ResEdBinToDec,edx,addr szPos[eax] invoke SendMessage,hStatus,SB_SETTEXT,nStatus,offset szPos .endif .endif .elseif eax==WM_LBUTTONDOWN .if des.nmnu dec des.dlgpt.x invoke SendMessage,hWin,WM_MOUSEMOVE,wParam,lParam .else mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax invoke SetCapture,hWin mov ebx,des.hdlg call IsInWindow .if eax mov fShift,FALSE mov fControl,FALSE mov eax,wParam test eax,MK_SHIFT .if !ZERO? mov fShift,TRUE .endif ;Control key test eax,MK_CONTROL .if !ZERO? mov fControl,TRUE .endif mov eax,hReSize mov des.hselected,eax .if hSizeing invoke DestroySizeingRect .endif .if ToolBoxID ;Is readOnly invoke GetWindowLong,hDEd,DEWM_READONLY .if !eax invoke CaptureWin call SnapPt mov eax,pt.x mov MousePtDown.x,eax mov eax,pt.y mov MousePtDown.y,eax mov eax,pt.x mov des.ctlrect.left,eax mov des.ctlrect.right,eax mov eax,pt.y mov des.ctlrect.top,eax mov des.ctlrect.bottom,eax mov des.fmode,MODE_DRAWING .endif .else push ebx call GetCtrl pop eax .if eax!=hCld ; Control .if !fShift && !fControl invoke GetWindowLong,hDEd,DEWM_READONLY .if !eax mov eax,hMultiSel .if eax call IsMultisel .if eax mov des.fmode,MODE_MULTISELMOVEINIT invoke CaptureWin call SnapPt mov eax,pt.x mov MousePtDown.x,eax mov eax,pt.y mov MousePtDown.y,eax call DrawMultisel ret .endif .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw invoke UpdateWindow,hDEd .endif invoke GetWindowLong,hDEd,DEWM_MEMORY .if ![eax].DLGHEAD.locked mov eax,hCld mov des.hselected,eax invoke CaptureWin call SnapPt mov eax,pt.x mov MousePtDown.x,eax mov eax,pt.y mov MousePtDown.y,eax invoke GetWindowRect,hCld,addr des.ctlrect invoke ScreenToClient,hInvisible,addr des.ctlrect.left invoke ScreenToClient,hInvisible,addr des.ctlrect.right invoke MapWindowPoints,hInvisible,des.hdlg,addr rect,2 ; *** MOD invoke DialogTltSize,rect.left,rect.top,rect.right,rect.bottom ; *** MOD mov des.fmode,MODE_MOVINIT .endif .endif .elseif !fShift && fControl .if hMultiSel invoke CtlMultiSelect,hCld .else call GetCtrl mov edx,des.hdlg mov eax,hCld .if eax!=des.hselected && edx!=des.hselected invoke CtlMultiSelect,des.hselected invoke CtlMultiSelect,hCld .endif .endif .if hMultiSel mov des.fmode,MODE_MULTISEL invoke PropertyList,-1 .endif .elseif fShift && !fControl .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw invoke UpdateWindow,hDEd invoke CaptureWin call SnapPt mov eax,pt.x mov MousePtDown.x,eax mov eax,pt.y mov MousePtDown.y,eax mov eax,pt.x mov des.ctlrect.left,eax mov des.ctlrect.right,eax mov eax,pt.y mov des.ctlrect.top,eax mov des.ctlrect.bottom,eax mov des.fmode,MODE_SELECT .endif .else ; Dialog .if hMultiSel .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw invoke UpdateWindow,hDEd .endif mov des.fmode,MODE_NOTHING mov eax,hCld .if eax==des.hselected || (fShift && !fControl) invoke CaptureWin call SnapPt mov eax,pt.x mov MousePtDown.x,eax mov eax,pt.y mov MousePtDown.y,eax mov eax,pt.x mov des.ctlrect.left,eax mov des.ctlrect.right,eax mov eax,pt.y mov des.ctlrect.top,eax mov des.ctlrect.bottom,eax mov des.fmode,MODE_SELECT .endif .endif .endif invoke NotifyParent .endif .endif .elseif eax==WM_LBUTTONUP mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax invoke ReleaseCapture .if des.fmode==MODE_DRAWING invoke RestoreWin invoke DeleteObject,hWinBmp invoke ShowWindow,hTlt,SW_HIDE mov des.fmode,MODE_NOTHING invoke CopyRect,addr rect,addr des.ctlrect mov eax,rect.right .if sdword ptr eax<rect.left inc eax xchg rect.left,eax mov rect.right,eax .endif mov eax,rect.bottom .if sdword ptr eax<rect.top inc eax xchg rect.top,eax mov rect.bottom,eax .endif invoke ClientToScreen,hInvisible,addr rect.left invoke ClientToScreen,hInvisible,addr rect.right mov ebx,des.hdlg invoke ScreenToClient,ebx,addr rect.left invoke ScreenToClient,ebx,addr rect.right mov eax,rect.right sub eax,rect.left mov rect.right,eax mov eax,rect.bottom sub eax,rect.top mov rect.bottom,eax invoke ConvertToDux,rect.left invoke SizeX mov rect.left,eax invoke ConvertToDux,rect.right invoke SizeX mov rect.right,eax invoke ConvertToDuy,rect.top invoke SizeY mov rect.top,eax invoke ConvertToDuy,rect.bottom invoke SizeY mov rect.bottom,eax mov edx,ToolBoxID invoke CreateNewCtl,des.hdlg,edx,rect.left,rect.top,rect.right,rect.bottom .if !fNoResetToolbox invoke ToolBoxReset .endif .elseif des.fmode==MODE_MOVING || des.fmode==MODE_MOVINIT invoke RestoreWin invoke DeleteObject,hWinBmp invoke ShowWindow,hTlt,SW_HIDE call SnapPt mov eax,pt.x mov edx,pt.y mov fChanged,FALSE .if (eax!=MousePtDown.x || edx!=MousePtDown.y) && des.fmode==MODE_MOVING invoke CopyRect,addr rect,addr des.ctlrect mov eax,pt.x sub eax,MousePtDown.x add rect.left,eax add rect.right,eax mov eax,pt.y sub eax,MousePtDown.y add rect.top,eax add rect.bottom,eax invoke ClientToScreen,hInvisible,addr rect.left invoke ClientToScreen,hInvisible,addr rect.right invoke ScreenToClient,des.hdlg,addr rect.left invoke ScreenToClient,des.hdlg,addr rect.right invoke GetCtrlMem,des.hselected mov ebx,eax invoke ConvertToDux,rect.left invoke SizeX .if eax!=[ebx].DIALOG.dux mov [ebx].DIALOG.dux,eax mov fChanged,TRUE .endif invoke ConvertToDuy,rect.top invoke SizeY .if eax!=[ebx].DIALOG.duy mov [ebx].DIALOG.duy,eax mov fChanged,TRUE .endif .endif .if fChanged invoke GetWindowLong,des.hselected,GWL_ID push eax invoke GetWindowLong,hDEd,DEWM_MEMORY pop edx invoke MakeDialog,eax,edx invoke SetChanged,TRUE .else invoke SizeingRect,des.hselected,FALSE .endif mov des.fmode,MODE_NOTHING .elseif des.fmode==MODE_SIZING invoke RestoreWin invoke DeleteObject,hWinBmp invoke ShowWindow,hTlt,SW_HIDE xor eax,eax mov des.fmode,eax mov fChanged,eax invoke CopyRect,addr rect,addr SizeRect invoke ClientToScreen,hInvisible,addr rect.left invoke ClientToScreen,hInvisible,addr rect.right invoke ScreenToClient,des.hdlg,addr rect.left invoke ScreenToClient,des.hdlg,addr rect.right mov eax,des.hdlg .if eax==des.hselected ;Dialog mov eax,rect.left sub rect.right,eax mov eax,rect.top sub rect.bottom,eax xor eax,eax mov rect.left,eax mov rect.top,eax mov rect1.left,eax mov rect1.top,eax mov rect1.right,eax mov rect1.bottom,eax invoke GetWindowLong,hDEd,DEWM_MEMORY xor edx,edx .if [eax].DLGHEAD.menuid inc edx .endif invoke AdjustWindowRectEx,addr rect1,[eax+sizeof DLGHEAD].DIALOG.style,edx,[eax+sizeof DLGHEAD].DIALOG.exstyle mov eax,rect1.right sub eax,rect1.left sub rect.right,eax mov eax,rect1.bottom sub eax,rect1.top sub rect.bottom,eax .endif invoke GetWindowLong,des.hselected,GWL_ID push eax invoke GetCtrlMem,des.hselected mov ebx,eax mov eax,des.hdlg .if eax!=des.hselected ;Control invoke ConvertToDux,rect.left .if eax!=[ebx].DIALOG.dux mov [ebx].DIALOG.dux,eax inc fChanged .endif invoke ConvertToDuy,rect.top .if eax!=[ebx].DIALOG.duy mov [ebx].DIALOG.duy,eax inc fChanged .endif invoke ConvertToDux,rect.right invoke SizeX sub eax,[ebx].DIALOG.dux .if eax!=[ebx].DIALOG.duccx mov [ebx].DIALOG.duccx,eax inc fChanged .endif invoke ConvertToDuy,rect.bottom invoke SizeY sub eax,[ebx].DIALOG.duy .if eax!=[ebx].DIALOG.duccy mov [ebx].DIALOG.duccy,eax inc fChanged .endif .else ;Dialog invoke ConvertToDux,rect.right invoke SizeX .if eax!=[ebx].DIALOG.duccx mov [ebx].DIALOG.duccx,eax inc fChanged .endif invoke ConvertToDuy,rect.bottom invoke SizeY .if eax!=[ebx].DIALOG.duccy mov [ebx].DIALOG.duccy,eax inc fChanged .endif .endif invoke GetWindowLong,hDEd,DEWM_MEMORY pop edx .if fChanged invoke MakeDialog,eax,edx invoke SetChanged,TRUE .else invoke PropertyList,des.hselected .endif .elseif des.fmode==MODE_MULTISEL .if !hMultiSel mov des.fmode,MODE_NOTHING .endif .elseif des.fmode==MODE_MULTISELMOVE || des.fmode==MODE_MULTISELMOVEINIT mov OldPt.x,0FFFFh mov OldPt.y,0FFFFh invoke RestoreWin invoke DeleteObject,hWinBmp invoke ShowWindow,hTlt,SW_HIDE mov des.fmode,MODE_NOTHING call SnapPt mov eax,pt.x sub eax,MousePtDown.x invoke ConvertToDux,eax invoke SizeX mov pt.x,eax mov eax,pt.y sub eax,MousePtDown.y invoke ConvertToDuy,eax invoke SizeY mov pt.y,eax .if pt.x || pt.y mov eax,hMultiSel @@: push eax invoke GetParent,eax invoke GetCtrlMem,eax mov edx,eax mov eax,pt.x add [edx].DIALOG.dux,eax mov eax,pt.y add [edx].DIALOG.duy,eax pop eax mov ecx,8 .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw or eax,eax jne @b invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,-1 invoke PropertyList,-1 invoke SetChanged,TRUE .endif .elseif des.fmode==MODE_SELECT invoke RestoreWin invoke DeleteObject,hWinBmp mov des.fmode,MODE_NOTHING .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw invoke UpdateWindow,hDEd invoke CopyRect,addr rect,addr des.ctlrect mov eax,rect.right .if sdword ptr eax<rect.left inc eax xchg rect.left,eax mov rect.right,eax .endif mov eax,rect.bottom .if sdword ptr eax<rect.top inc eax xchg rect.top,eax mov rect.bottom,eax .endif invoke ClientToScreen,hWin,addr rect.left invoke ClientToScreen,hWin,addr rect.right invoke GetWindowLong,hDEd,DEWM_MEMORY lea ebx,[eax+sizeof DLGHEAD+sizeof DIALOG] mov nInx,0 .while [ebx].DIALOG.hwnd .if [ebx].DIALOG.hwnd!=-1 invoke GetCtrlID,ebx invoke GetDlgItem,des.hdlg,eax mov hCld,eax invoke GetWindowRect,hCld,addr rect1 mov eax,rect1.left mov ecx,rect1.right .if (eax>=rect.left && eax<=rect.right) || (ecx>=rect.left && ecx<=rect.right) || (rect.left>=eax && rect.right<=ecx) mov eax,rect1.top mov ecx,rect1.bottom .if (eax>=rect.top && eax<=rect.bottom) || (ecx>=rect.top && ecx<=rect.bottom) || (rect.top>=eax && rect.bottom<=ecx) mov eax,[ebx].DIALOG.ntype .if eax!=18 && eax!=19 invoke CtlMultiSelect,hCld inc nInx .endif .endif .endif .endif lea ebx,[ebx+sizeof DIALOG] .endw .if nInx==1 && hMultiSel invoke GetParent,hMultiSel invoke SizeingRect,eax,FALSE .elseif hMultiSel invoke PropertyList,-1 .else invoke SizeingRect,des.hdlg,FALSE .endif .else mov hCld,0 mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax mov ebx,des.hdlg call IsInWindow .if eax call GetCtrl invoke SizeingRect,hCld,FALSE .endif .endif invoke NotifyParent invoke SetFocus,hDEd .elseif eax==WM_LBUTTONDBLCLK mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax mov ebx,des.hdlg call IsInWindow .if eax push ebx push esi push edi invoke GetWindowLong,hDEd,DEWM_MEMORY mov esi,eax mov edi,eax lea esi,[esi+sizeof DLGHEAD] .while [esi].DIALOG.hwnd lea esi,[esi+sizeof DIALOG] .endw lea esi,[esi-sizeof DIALOG] .while esi>edi invoke GetCtrlID,esi .if eax invoke GetDlgItem,des.hdlg,eax mov ebx,eax .else mov ebx,des.hdlg .endif call IsInWindow .break .if eax lea esi,[esi-sizeof DIALOG] .endw pop edi pop esi pop eax invoke GetCtrlMem,hCld mov ebx,eax mov eax,hRes mov dblclk.nmhdr.hwndFrom,eax invoke GetWindowLong,hRes,GWL_ID push eax mov dblclk.nmhdr.idFrom,eax mov dblclk.nmhdr.code,NM_CLICK mov eax,[ebx].DIALOG.id mov dblclk.nCtlId,eax lea eax,[ebx].DIALOG.idname mov dblclk.lpCtlName,eax invoke GetCtrlMem,des.hdlg mov edx,eax mov dblclk.lpDlgMem,edx mov eax,[edx].DIALOG.id mov dblclk.nDlgId,eax lea eax,[edx].DIALOG.idname mov dblclk.lpDlgName,eax invoke GetParent,hRes pop edx mov ecx,eax invoke SendMessage,ecx,WM_NOTIFY,edx,addr dblclk .endif .elseif eax==WM_SETCURSOR invoke GetCursorPos,addr pt invoke ScreenToClient,hInvisible,addr pt mov ebx,des.hdlg call IsInWindow .if ToolBoxID && (eax || des.fmode==MODE_DRAWING) invoke LoadCursor,0,IDC_CROSS .else invoke LoadCursor,0,IDC_ARROW .endif invoke SetCursor,eax .else invoke DefWindowProc,hWin,uMsg,wParam,lParam ret .endif xor eax,eax ret IsMultisel: mov eax,hMultiSel .if eax @@: push eax invoke GetParent,eax pop edx .if eax==hCld retn .endif mov eax,edx mov ecx,8 .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw or eax,eax jne @b .endif retn SnapPt: mov eax,lParam movsx edx,ax shr eax,16 cwde mov pt.x,edx mov pt.y,eax invoke SnapPtDu,addr pt retn IsInWindow: invoke GetWindowRect,ebx,addr rect invoke ScreenToClient,hInvisible,addr rect.left invoke ScreenToClient,hInvisible,addr rect.right mov eax,pt.x mov edx,pt.y .if sdword ptr eax>=rect.left && sdword ptr eax<=rect.right && sdword ptr edx>=rect.top && sdword ptr edx<=rect.bottom mov hCld,ebx mov eax,TRUE .else xor eax,eax .endif retn GetCtrl: push esi push edi invoke GetWindowLong,hDEd,DEWM_MEMORY mov esi,eax mov edi,eax lea esi,[esi+sizeof DLGHEAD] .while [esi].DIALOG.hwnd lea esi,[esi+sizeof DIALOG] .endw lea esi,[esi-sizeof DIALOG] .while esi>edi .if [esi].DIALOG.hwnd!=-1 invoke GetCtrlID,esi .if eax invoke GetDlgItem,des.hdlg,eax mov ebx,eax .else mov ebx,des.hdlg .endif call IsInWindow .break .if eax .endif lea esi,[esi-sizeof DIALOG] .endw pop edi pop esi retn DrawMultisel: mov eax,hMultiSel @@: push eax invoke GetParent,eax push eax mov edx,eax invoke GetWindowRect,edx,addr rect mov eax,pt.x sub eax,MousePtDown.x add rect.left,eax add rect.right,eax mov eax,pt.y sub eax,MousePtDown.y add rect.top,eax add rect.bottom,eax invoke ScreenToClient,hInvisible,addr rect.left invoke ScreenToClient,hInvisible,addr rect.right call DrawRect invoke GetParent,hMultiSel pop edx .if eax==edx && (des.fmode==MODE_MULTISELMOVE || des.fmode==MODE_MULTISELMOVEINIT) ; *** MOD ; *** MOD ;invoke ConvertToDlgPt,addr rect.left invoke MapWindowPoints,hInvisible,des.hdlg,addr rect,2 invoke DialogTltSize,rect.left,rect.top,rect.right,rect.bottom ; ============= .endif mov ecx,8 pop eax .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw or eax,eax jne @b retn DrawRect: invoke GetDC,hWin mov hDC,eax invoke GetStockObject,BLACK_BRUSH invoke FrameRect,hDC,addr rect,eax invoke ReleaseDC,hWin,hDC retn DesignInvisibleProc endp CopyCtl proc uses esi edi ebx LOCAL hCtl:HWND .if hReSize invoke GetCtrlMem,hReSize .if eax mov esi,eax mov edi,offset dlgpaste mov ecx,sizeof DIALOG rep movsb xor eax,eax stosd .endif .elseif hMultiSel mov edi,offset dlgpaste mov ebx,hMultiSel .while ebx invoke GetParent,ebx mov hCtl,eax mov eax,8 .while eax push eax invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop eax dec eax .endw invoke GetCtrlMem,hCtl .if eax mov esi,eax mov ecx,sizeof DIALOG rep movsb .endif .endw xor eax,eax stosd .endif invoke SendMessage,hDEd,WM_LBUTTONDOWN,0,0 ret CopyCtl endp PasteCtl proc uses esi edi LOCAL px:DWORD LOCAL py:DWORD LOCAL nbr:DWORD mov nbr,0 mov esi,offset dlgpaste mov px,9999 mov py,9999 push esi @@: mov eax,[esi].DIALOG.hwnd .if eax mov eax,[esi].DIALOG.dux .if (px<80000000 && eax<80000000 && eax<px) || (px>80000000 && eax>80000000 && eax<px) || (px<80000000 && eax>80000000) mov px,eax .endif mov eax,[esi].DIALOG.duy .if (py<80000000 && eax<80000000 && eax<py) || (py>80000000 && eax>80000000 && eax<py) || (py<80000000 && eax>80000000) mov py,eax .endif add esi,sizeof DIALOG jmp @b .endif pop esi @@: mov eax,[esi].DIALOG.hwnd .if eax invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax push eax mov edx,eax mov edx,[edx].DLGHEAD.ctlid add eax,sizeof DLGHEAD mov [esi].DIALOG.id,edx invoke IsFreeID,edx .if eax==FALSE invoke GetFreeID mov [esi].DIALOG.id,eax .endif pop eax invoke GetFreeDlg,eax mov edi,eax push esi push eax mov ecx,sizeof DIALOG rep movsb pop esi mov eax,px sub [esi].DIALOG.dux,eax mov eax,py sub [esi].DIALOG.duy,eax xor eax,eax mov [esi].DIALOG.himg,eax invoke GetTypePtr,[esi].DIALOG.ntype invoke strcpyn,addr [esi].DIALOG.idname,(TYPES ptr [eax]).lpidname,MaxName invoke GetUnikeName,addr [esi].DIALOG.idname mov [esi].DIALOG.tab,-1 invoke GetFreeTab mov [esi].DIALOG.tab,eax pop esi add esi,sizeof DIALOG inc nbr jmp @b .endif .endif .if nbr invoke DestroySizeingRect .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,-2 invoke SetChanged,TRUE .if nbr>1 .while nbr sub edi,sizeof DIALOG invoke GetCtrlID,edi invoke GetDlgItem,des.hdlg,eax invoke CtlMultiSelect,eax dec nbr .endw .else sub edi,sizeof DIALOG invoke GetCtrlID,edi invoke GetDlgItem,des.hdlg,eax invoke SizeingRect,eax,FALSE .endif invoke NotifyParent .endif ret PasteCtl endp DeleteCtl proc uses esi LOCAL hCtl:HWND .if hReSize invoke GetCtrlMem,hReSize .if eax mov esi,eax mov eax,[esi].DIALOG.ntype ;Don't delete DialogBox .if eax mov [esi].DIALOG.hwnd,-1 invoke DeleteTab,[esi].DIALOG.tab invoke DestroySizeingRect invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,0 invoke SetChanged,TRUE .endif .endif .elseif hMultiSel .while hMultiSel invoke GetParent,hMultiSel mov hCtl,eax mov eax,8 .while eax push eax invoke GetWindowLong,hMultiSel,GWL_USERDATA push eax invoke DestroyWindow,hMultiSel pop eax mov hMultiSel,eax pop eax dec eax .endw invoke GetCtrlMem,hCtl .if eax mov esi,eax mov eax,[esi].DIALOG.ntype ;Don't delete DialogBox .if eax mov [esi].DIALOG.hwnd,-1 invoke DeleteTab,[esi].DIALOG.tab .endif .endif .endw invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,0 invoke SetChanged,TRUE .endif invoke NotifyParent ret DeleteCtl endp AlignSizeCtl proc uses esi ebx,nFun:DWORD LOCAL xp:DWORD LOCAL yp:DWORD LOCAL wt:DWORD LOCAL ht:DWORD LOCAL hCtl:HWND LOCAL fChanged:DWORD LOCAL xpmin:DWORD LOCAL ypmin:DWORD LOCAL xpmax:DWORD LOCAL ypmax:DWORD LOCAL rect:RECT mov ebx,hMultiSel .if ebx ;Multi select mov eax,nFun .if eax==ALIGN_DLGVCENTER || eax==ALIGN_DLGHCENTER mov eax,99999 mov xpmin,eax mov ypmin,eax neg eax mov xpmax,eax mov ypmax,eax .while ebx invoke GetParent,ebx invoke GetCtrlMem,eax mov esi,eax mov eax,[esi].DIALOG.dux .if sdword ptr eax<xpmin mov xpmin,eax .endif add eax,[esi].DIALOG.duccx .if sdword ptr eax>xpmax mov xpmax,eax .endif mov eax,[esi].DIALOG.duy .if sdword ptr eax<ypmin mov ypmin,eax .endif add eax,[esi].DIALOG.duccy .if sdword ptr eax>ypmax mov ypmax,eax .endif mov ecx,8 .while ecx push ecx invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop ecx dec ecx .endw .endw invoke GetCtrlMem,des.hdlg mov edx,[eax].DIALOG.duccx mov rect.right,edx mov edx,[eax].DIALOG.duccy mov rect.bottom,edx mov rect.left,0 mov rect.top,0 mov eax,xpmax sub eax,xpmin mov edx,rect.right sub edx,eax shr edx,1 sub xpmin,edx mov eax,ypmax sub eax,ypmin mov edx,rect.bottom sub edx,eax shr edx,1 sub ypmin,edx mov ebx,hMultiSel .while ebx mov fChanged,FALSE invoke GetParent,ebx mov hCtl,eax invoke GetCtrlMem,hCtl mov esi,eax mov eax,nFun .if eax==ALIGN_DLGVCENTER mov eax,ypmin .if eax sub [esi].DIALOG.duy,eax inc fChanged .endif .elseif eax==ALIGN_DLGHCENTER mov eax,xpmin .if eax sub [esi].DIALOG.dux,eax inc fChanged .endif .endif call SnapGrid mov ecx,8 .while ecx push ecx invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop ecx dec ecx .endw .endw .else invoke GetParent,ebx invoke GetCtrlMem,eax mov esi,eax mov eax,[esi].DIALOG.dux mov xp,eax mov eax,[esi].DIALOG.duy mov yp,eax mov eax,[esi].DIALOG.duccx mov wt,eax mov eax,[esi].DIALOG.duccy mov ht,eax .while ebx mov fChanged,FALSE invoke GetParent,ebx mov hCtl,eax invoke GetCtrlMem,hCtl mov esi,eax mov eax,nFun .if eax==ALIGN_LEFT mov eax,xp .if eax!=[esi].DIALOG.dux mov [esi].DIALOG.dux,eax inc fChanged .endif .elseif eax==ALIGN_CENTER mov eax,wt shr eax,1 add eax,xp mov edx,[esi].DIALOG.duccx shr edx,1 add edx,[esi].DIALOG.dux sub eax,edx .if eax add [esi].DIALOG.dux,eax inc fChanged .endif .elseif eax==ALIGN_RIGHT mov eax,xp add eax,wt sub eax,[esi].DIALOG.duccx .if eax!=[esi].DIALOG.dux mov [esi].DIALOG.dux,eax inc fChanged .endif .elseif eax==ALIGN_TOP mov eax,yp .if eax!=[esi].DIALOG.duy mov [esi].DIALOG.duy,eax inc fChanged .endif .elseif eax==ALIGN_MIDDLE mov eax,ht shr eax,1 add eax,yp mov edx,[esi].DIALOG.duccy shr edx,1 add edx,[esi].DIALOG.duy sub eax,edx .if eax add [esi].DIALOG.duy,eax inc fChanged .endif .elseif eax==ALIGN_BOTTOM mov eax,yp add eax,ht sub eax,[esi].DIALOG.duccy .if eax!=[esi].DIALOG.duy mov [esi].DIALOG.duy,eax inc fChanged .endif .elseif eax==SIZE_WIDTH mov eax,wt .if eax!=[esi].DIALOG.duccx mov [esi].DIALOG.duccx,eax inc fChanged .endif .elseif eax==SIZE_HEIGHT mov eax,ht .if eax!=[esi].DIALOG.duccy mov [esi].DIALOG.duccy,eax inc fChanged .endif .elseif eax==SIZE_BOTH mov eax,wt .if eax!=[esi].DIALOG.duccx mov [esi].DIALOG.duccx,eax inc fChanged .endif mov eax,ht .if eax!=[esi].DIALOG.duccy mov [esi].DIALOG.duccy,eax inc fChanged .endif .endif call SnapGrid mov ecx,8 .while ecx push ecx invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop ecx dec ecx .endw .endw .endif invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,-1 invoke SetChanged,TRUE .else mov eax,nFun .if (eax==ALIGN_DLGVCENTER || eax==ALIGN_DLGHCENTER) && hReSize ;Single select mov eax,hReSize mov hCtl,eax invoke GetCtrlMem,hCtl mov esi,eax mov eax,[esi].DIALOG.dux mov xpmin,eax mov eax,[esi].DIALOG.duy mov ypmin,eax mov eax,[esi].DIALOG.duccx add eax,[esi].DIALOG.dux mov xpmax,eax mov eax,[esi].DIALOG.duccy add eax,[esi].DIALOG.duy mov ypmax,eax invoke GetCtrlMem,des.hdlg mov edx,[eax].DIALOG.duccx mov rect.right,edx mov edx,[eax].DIALOG.duccy mov rect.bottom,edx mov rect.left,0 mov rect.top,0 mov eax,xpmax sub eax,xpmin mov edx,rect.right sub edx,eax shr edx,1 sub xpmin,edx mov eax,ypmax sub eax,ypmin mov edx,rect.bottom sub edx,eax shr edx,1 sub ypmin,edx mov eax,nFun .if eax==ALIGN_DLGVCENTER mov eax,ypmin .if eax sub [esi].DIALOG.duy,eax inc fChanged .endif .elseif eax==ALIGN_DLGHCENTER mov eax,xpmin .if eax sub [esi].DIALOG.dux,eax inc fChanged .endif .endif call SnapGrid invoke GetWindowLong,hCtl,GWL_ID push eax invoke GetWindowLong,hDEd,DEWM_MEMORY pop edx invoke MakeDialog,eax,edx invoke SetChanged,TRUE .endif .endif invoke NotifyParent ret SnapGrid: retn call RSnapToGrid .if fRSnapToGrid ; mov eax,[esi].x ; xor edx,edx ; idiv Gridcx ; imul Gridcx ; .if eax!=[esi].x ; mov [esi].x,eax ; inc fChanged ; .endif ; mov eax,[esi].ccx ; add eax,[esi].x ; xor edx,edx ; idiv Gridcx ; imul Gridcx ; sub eax,[esi].x ; inc eax ; .if eax!=[esi].ccx ; mov [esi].ccx,eax ; inc fChanged ; .endif ; mov eax,[esi].y ; xor edx,edx ; idiv Gridcy ; imul Gridcy ; .if eax!=[esi].y ; mov [esi].y,eax ; inc fChanged ; .endif ; mov eax,[esi].ccy ; add eax,[esi].y ; xor edx,edx ; idiv Gridcy ; imul Gridcy ; sub eax,[esi].y ; inc eax ; .if eax!=[esi].ccy ; mov [esi].ccy,eax ; inc fChanged ; .endif .endif retn AlignSizeCtl endp MoveMultiSel proc uses esi,x:DWORD,y:DWORD mov eax,hMultiSel .while eax push eax invoke GetParent,eax invoke GetCtrlMem,eax mov esi,eax .if x mov eax,(DIALOG ptr [esi]).dux add eax,x xor edx,edx idiv x imul x mov (DIALOG ptr [esi]).dux,eax .endif .if y mov eax,(DIALOG ptr [esi]).duy add eax,y xor edx,edx idiv y imul y mov (DIALOG ptr [esi]).duy,eax .endif mov ecx,8 pop eax .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw .endw invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,-1 invoke SetChanged,TRUE invoke NotifyParent ret MoveMultiSel endp SizeMultiSel proc uses esi,x:DWORD,y:DWORD mov eax,hMultiSel .while eax push eax invoke GetParent,eax invoke GetCtrlMem,eax mov esi,eax .if x mov eax,(DIALOG ptr [esi]).duccx add eax,x .if sdword ptr eax>0 xor edx,edx idiv x imul x mov (DIALOG ptr [esi]).duccx,eax .endif .endif .if y mov eax,(DIALOG ptr [esi]).duccy add eax,y .if sdword ptr eax>0 xor edx,edx idiv y imul y mov (DIALOG ptr [esi]).duccy,eax .endif .endif mov ecx,8 pop eax .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw .endw invoke GetWindowLong,hDEd,DEWM_MEMORY invoke MakeDialog,eax,-1 invoke SetChanged,TRUE invoke NotifyParent ret SizeMultiSel endp AutoIDMultiSel proc uses esi LOCAL MinID:DWORD LOCAL MinTab:DWORD LOCAL MaxTab:DWORD LOCAL TabPtr:DWORD mov eax,hMultiSel .if eax mov MinID,7FFFFFFFh mov MinTab,7FFFFFFFh .while eax push eax invoke GetParent,eax invoke GetCtrlMem,eax mov esi,eax mov eax,(DIALOG ptr [esi]).id .if sdword ptr eax>0 .if eax<MinID mov MinID,eax .endif .endif mov eax,(DIALOG ptr [esi]).tab .if eax<MinTab mov MinTab,eax .endif mov ecx,8 pop eax .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw .endw invoke GetParent,hMultiSel invoke GetCtrlMem,eax mov eax,(DIALOG ptr [eax]).id .if sdword ptr eax>0 mov MinID,eax .endif .while TRUE call GetNextTab mov esi,TabPtr .break .if !esi .if sdword ptr (DIALOG ptr [esi]).id>0 mov eax,MinID mov (DIALOG ptr [esi]).id,eax inc MinID .endif inc MinTab .endw invoke SetChanged,TRUE .endif invoke GetWindowLong,hDEd,DEWM_MEMORY invoke UpdateRAEdit,eax invoke NotifyParent ret GetNextTab: mov MaxTab,7FFFFFFFh mov TabPtr,0 mov eax,hMultiSel .while eax push eax invoke GetParent,eax invoke GetCtrlMem,eax mov esi,eax mov eax,(DIALOG ptr [esi]).tab .if eax>=MinTab .if eax<MaxTab mov MaxTab,eax mov TabPtr,esi .endif .endif mov ecx,8 pop eax .while ecx push ecx invoke GetWindowLong,eax,GWL_USERDATA pop ecx dec ecx .endw .endw retn AutoIDMultiSel endp SendToBack proc uses esi edi,hCtl:HWND LOCAL buffer[512]:BYTE LOCAL lpSt:DWORD LOCAL lpFirst:DWORD LOCAL nID:DWORD invoke GetCtrlMem,hCtl mov lpSt,eax mov esi,eax invoke GetWindowLong,hDEd,DEWM_MEMORY add eax,sizeof DLGHEAD+sizeof DIALOG .while [eax].DIALOG.hwnd==-1 add eax,sizeof DIALOG .endw .if [esi].DIALOG.ntype!=11 .while ([eax].DIALOG.ntype==3 || [eax].DIALOG.ntype==11 || [eax].DIALOG.hwnd==-1) && [eax].DIALOG.hwnd add eax,sizeof DIALOG .endw .endif mov lpFirst,eax .if eax<lpSt lea edi,buffer mov ecx,sizeof DIALOG rep movsb mov esi,lpSt @@: mov edi,esi mov ecx,sizeof DIALOG sub esi,ecx rep movsb sub esi,sizeof DIALOG cmp esi,lpFirst jge @b invoke GetCtrlID,lpFirst mov nID,eax lea esi,buffer mov edi,lpFirst mov ecx,sizeof DIALOG rep movsb invoke GetWindowLong,hDEd,DEWM_MEMORY mov esi,eax invoke MakeDialog,esi,nID .endif ret SendToBack endp BringToFront proc uses esi edi,hCtl:HWND LOCAL buffer[512]:BYTE LOCAL lpSt:DWORD LOCAL nID:DWORD invoke GetCtrlMem,hCtl mov lpSt,eax mov esi,eax lea edi,buffer mov ecx,sizeof DIALOG rep movsb mov edi,esi sub edi,sizeof DIALOG @@: mov ecx,sizeof DIALOG rep movsb mov eax,dword ptr [esi] or eax,eax jne @b invoke GetCtrlID,edi mov nID,eax lea esi,buffer mov ecx,sizeof DIALOG rep movsb invoke GetWindowLong,hDEd,DEWM_MEMORY mov esi,eax invoke MakeDialog,esi,nID ret BringToFront endp GetMnuString proc uses ebx esi edi,lpName:DWORD,lpBuff:DWORD invoke GetWindowLong,hPrj,0 mov esi,eax mov edi,lpName xor ebx,ebx .if byte ptr [edi]>='0' && byte ptr [edi]<='9' invoke ResEdDecToBin,edi mov ebx,eax .endif .while [esi].PROJECT.hmem .if [esi].PROJECT.ntype==TPE_MENU mov edx,[esi].PROJECT.hmem .if ebx cmp ebx,[edx].MNUHEAD.menuid .break .if ZERO? .else invoke strcmp,lpName,addr [edx].MNUHEAD.menuname .break .if !eax .endif .endif lea esi,[esi+sizeof PROJECT] .endw .if [esi].PROJECT.ntype==TPE_MENU mov esi,[esi].PROJECT.hmem push esi mov edi,lpBuff mov byte ptr [edi],0 add esi,sizeof MNUHEAD @@: mov eax,(MNUITEM ptr [esi]).itemflag .if eax .if eax!=-1 mov eax,(MNUITEM ptr [esi]).level .if !eax .if edi!=lpBuff mov byte ptr [edi],',' inc edi .endif mov byte ptr [edi],' ' inc edi mov byte ptr [edi],' ' inc edi invoke strcpy,edi,addr (MNUITEM ptr [esi]).itemcaption invoke strlen,edi add edi,eax mov byte ptr [edi],' ' inc edi mov byte ptr [edi],' ' inc edi mov byte ptr [edi],0 .endif .endif add esi,sizeof MNUITEM jmp @b .endif pop eax .else invoke strcpy,lpBuff,addr szMnu xor eax,eax .endif ret GetMnuString endp TestProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL rect:RECT LOCAL fnt:LOGFONT mov eax,uMsg .if eax==WM_INITDIALOG invoke GetClientRect,hWin,addr rect push rect.right pop fntwt push rect.bottom pop fntht invoke SendMessage,hWin,WM_GETFONT,0,0 mov edx,eax invoke GetObject,edx,sizeof LOGFONT,addr fnt mov eax,fnt.lfHeight mov lfntht,eax mov eax,FALSE ret .else mov eax,FALSE ret .endif mov eax,TRUE ret TestProc endp DlgResize proc uses esi edi,hMem:DWORD,lpOldFont:DWORD,nOldSize:DWORD,lpNewFont:DWORD,nNewSize:DWORD mov eax,nOldSize mov dlgps,ax invoke ConvFontToUnicode,offset dlgfn,lpOldFont invoke CreateDialogIndirectParam,hInstance,offset dlgdata,hDEd,offset TestProc,0 invoke DestroyWindow,eax push fntwt pop dfntwt push fntht pop dfntht mov eax,nNewSize mov dlgps,ax invoke ConvFontToUnicode,offset dlgfn,lpNewFont invoke CreateDialogIndirectParam,hInstance,offset dlgdata,hDEd,offset TestProc,0 invoke DestroyWindow,eax mov esi,hMem add esi,sizeof DLGHEAD mov edi,esi .while [esi].DIALOG.hwnd .if [esi].DIALOG.hwnd!=-1 ; Dont move dialog .if edi!=esi mov eax,[esi].DIALOG.dux call getx .if fSnapToGrid xor edx,edx idiv Gridcx imul Gridcx .endif mov [esi].DIALOG.dux,eax mov eax,[esi].DIALOG.duy call gety .if fSnapToGrid xor edx,edx idiv Gridcy imul Gridcy .endif mov [esi].DIALOG.duy,eax .endif mov eax,[esi].DIALOG.duccx call getx .if fSnapToGrid xor edx,edx idiv Gridcx imul Gridcx ;inc eax .endif mov [esi].DIALOG.duccx,eax mov eax,[esi].DIALOG.duccy call gety .if fSnapToGrid xor edx,edx idiv Gridcy imul Gridcy ;inc eax .endif mov [esi].DIALOG.duccy,eax .endif add esi,sizeof DIALOG .endw ret getx: .if sdword ptr eax<0 neg eax shl eax,1 imul dfntwt xor edx,edx idiv fntwt shr eax,1 ; adc eax,0 neg eax .else shl eax,1 imul dfntwt xor edx,edx idiv fntwt shr eax,1 ; adc eax,0 .endif retn gety: .if sdword ptr eax<0 neg eax shl eax,1 imul dfntht xor edx,edx idiv fntht shr eax,1 ; adc eax,0 neg eax .else shl eax,1 imul dfntht xor edx,edx idiv fntht shr eax,1 ; adc eax,0 .endif retn DlgResize endp GetType proc uses ebx esi,lpDlg:DWORD mov esi,lpDlg mov eax,[esi].DIALOG.ntypeid .if eax mov ebx,offset ctltypes xor ecx,ecx .while ecx<nButtons .if eax==[ebx].TYPES.ID mov [esi].DIALOG.ntype,ecx xor eax,eax .break .endif add ebx,sizeof TYPES inc ecx .endw .if eax mov [esi].DIALOG.ntype,2 mov [esi].DIALOG.ntypeid,2 .endif .else mov eax,[esi].DIALOG.ntype mov [esi].DIALOG.ntypeid,eax xor eax,eax .endif ret GetType endp UpdateRAEdit proc uses ebx esi edi,hMem:DWORD mov ebx,hMem invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,256*1024 mov edi,eax invoke ExportDialogNames,ebx mov esi,eax invoke strcpy,edi,esi invoke GlobalUnlock,esi invoke GlobalFree,esi invoke ExportDialog,ebx mov esi,eax invoke strcat,edi,esi invoke GlobalUnlock,esi invoke GlobalFree,esi invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,256*1024 mov esi,eax invoke SaveToMem,[ebx].DLGHEAD.hred,esi invoke strcmp,esi,edi .if eax invoke SendMessage,[ebx].DLGHEAD.hred,REM_LOCKUNDOID,TRUE,0 invoke SendMessage,[ebx].DLGHEAD.hred,EM_SETSEL,0,-1 invoke SendMessage,[ebx].DLGHEAD.hred,EM_REPLACESEL,TRUE,edi invoke SendMessage,[ebx].DLGHEAD.hred,REM_LOCKUNDOID,FALSE,0 .endif invoke GlobalFree,esi invoke GlobalFree,edi ret UpdateRAEdit endp CloseDialog proc uses esi invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov esi,eax .if [esi].DLGHEAD.ftextmode invoke ShowWindow,[esi].DLGHEAD.hred,SW_HIDE .else invoke DestroySizeingRect .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw .endif invoke GetWindowLong,hDEd,DEWM_DIALOG invoke DestroyWindow,eax mov des.hdlg,0 invoke SetWindowLong,hDEd,DEWM_MEMORY,0 invoke SetWindowLong,hDEd,DEWM_DIALOG,0 invoke SetWindowLong,hDEd,DEWM_PROJECT,0 invoke ShowWindow,hInvisible,SW_HIDE .if hTabSet invoke DestroyWindow,hTabSet mov hTabSet,0 .endif .elseif hDialog invoke SendMessage,hDialog,WM_COMMAND,BN_CLICKED shl 16 or IDOK,0 invoke SendMessage,hDialog,WM_COMMAND,BN_CLICKED shl 16 or IDCANCEL,0 mov hDialog,0 .endif ret CloseDialog endp GetMnuName proc uses ebx esi,lpDlgMem:DWORD,nid:DWORD mov esi,lpDlgMem mov eax,[esi].DLGHEAD.lpmnu .if eax mov esi,eax add esi,sizeof MNUHEAD @@: mov eax,(MNUITEM ptr [esi]).itemflag .if eax .if eax!=-1 mov eax,(MNUITEM ptr [esi]).itemid .if eax==nid lea eax,(MNUITEM ptr [esi]).itemname jmp Ex .endif .endif add esi,sizeof MNUITEM jmp @b .endif .endif xor eax,eax Ex: ret GetMnuName endp MakeDlgProc proc uses esi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL rect:RECT LOCAL dblclk:CTLDBLCLICK mov eax,uMsg .if eax==WM_INITDIALOG invoke GetWindowRect,hWin,addr rect invoke GetWindowLong,hDEd,DEWM_MEMORY .if [eax].DLGHEAD.menuid invoke GetSystemMetrics,SM_CYMENU add rect.bottom,eax .endif invoke GetWindowLong,hDEd,DEWM_SCROLLY push eax invoke GetWindowLong,hDEd,DEWM_SCROLLX shl eax,3 neg eax add eax,DlgX pop edx shl edx,3 neg edx add edx,DlgY mov ecx,rect.bottom sub ecx,rect.top mov rect.bottom,ecx mov ecx,rect.left sub rect.right,ecx invoke SetWindowPos,hWin,0,eax,edx,rect.right,rect.bottom,SWP_NOZORDER invoke EnumChildWindows,hWin,addr DlgEnumProc,hWin mov eax,FALSE ret .elseif eax==WM_COMMAND mov edx,wParam movzx eax,dx shr edx,16 .if !edx push ebx mov eax,hRes mov dblclk.nmhdr.hwndFrom,eax invoke GetWindowLong,hRes,GWL_ID push eax mov dblclk.nmhdr.idFrom,eax mov dblclk.nmhdr.code,NM_CLICK mov eax,wParam mov dblclk.nCtlId,eax push eax invoke GetWindowLong,hDEd,DEWM_MEMORY pop edx invoke GetMnuName,eax,edx mov dblclk.lpCtlName,eax invoke GetCtrlMem,des.hdlg mov edx,eax mov dblclk.lpDlgMem,edx mov eax,[edx].DIALOG.id mov dblclk.nDlgId,eax lea eax,[edx].DIALOG.idname mov dblclk.lpDlgName,eax invoke GetParent,hRes pop edx mov ecx,eax invoke SendMessage,ecx,WM_NOTIFY,edx,addr dblclk pop ebx .endif .elseif eax==WM_DRAWITEM mov esi,lParam invoke GetStockObject,GRAY_BRUSH invoke FillRect,[esi].DRAWITEMSTRUCT.hdc,addr [esi].DRAWITEMSTRUCT.rcItem,eax xor eax,eax inc eax ret .else mov eax,FALSE ret .endif mov eax,TRUE ret MakeDlgProc endp MakeDlgClassProc proc uses ebx,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL buffer[512]:BYTE LOCAL buffer1[128]:BYTE LOCAL rect:RECT LOCAL rect1:RECT LOCAL rect2:RECT LOCAL hDC:HDC LOCAL mDC:HDC LOCAL nInx:DWORD LOCAL pt:POINT LOCAL fMnu:DWORD mov eax,uMsg .if eax==WM_NCCALCSIZE invoke GetWindowLong,hDEd,DEWM_MEMORY .if [eax].DLGHEAD.menuid mov ebx,lParam invoke GetSystemMetrics,SM_CYMENU add [ebx].NCCALCSIZE_PARAMS.rgrc.top,eax .if !wParam add [ebx].NCCALCSIZE_PARAMS.rgrc.bottom,eax .endif .endif .elseif eax==WM_CREATE .if hGridBr invoke DeleteObject,hGridBr mov hGridBr,0 .endif invoke CreateGridBrush,hWin .elseif eax==WM_NCPAINT xor eax,eax mov des.mnurect.left,eax mov des.mnurect.top,eax mov des.mnurect.right,eax mov des.mnurect.bottom,eax mov rect1.left,eax mov rect1.top,eax mov rect1.right,eax mov rect1.bottom,eax mov nInx,eax mov des.nmnu,eax mov fMnu,eax mov rect2.left,eax mov rect2.top,eax invoke GetWindowLong,hDEd,DEWM_MEMORY mov ebx,eax .if [ebx].DLGHEAD.menuid invoke GetMnuString,addr [ebx].DLGHEAD.menuid,addr buffer mov [ebx].DLGHEAD.lpmnu,eax invoke GetWindowDC,hWin mov hDC,eax invoke CreateCompatibleDC,hDC mov mDC,eax invoke GetWindowLong,hWin,GWL_STYLE push eax invoke GetWindowLong,hWin,GWL_EXSTYLE pop edx invoke AdjustWindowRectEx,addr rect1,edx,FALSE,eax invoke GetWindowRect,hWin,addr rect mov eax,rect.left sub rect.right,eax mov rect.left,0 mov eax,rect.top sub rect.bottom,eax mov rect.top,0 mov eax,rect1.left sub rect.left,eax mov eax,rect1.right sub rect.right,eax mov eax,rect1.top sub rect.top,eax mov eax,rect1.bottom sub rect.bottom,eax invoke GetSystemMetrics,SM_CYMENU add eax,rect.top .if eax<rect.bottom mov rect.bottom,eax .endif invoke CopyRect,addr des.mnurect,addr rect mov eax,rect.right sub eax,rect.left mov rect2.right,eax mov edx,rect.bottom sub edx,rect.top mov rect2.bottom,edx invoke CreateCompatibleBitmap,hDC,eax,edx invoke SelectObject,mDC,eax push eax invoke FillRect,mDC,addr rect2,COLOR_BTNFACE+1 invoke SetBkMode,mDC,TRANSPARENT invoke SelectObject,mDC,hMnuFont push eax mov eax,rect2.left mov rect2.right,eax @@: invoke GetStrItem,addr buffer,addr buffer1 .if buffer1 inc nInx xor eax,eax mov rect1.left,eax mov rect1.top,eax mov rect1.right,eax mov rect1.bottom,eax invoke DrawText,mDC,addr buffer1,-1,addr rect1,DT_SINGLELINE or DT_CALCRECT mov eax,rect2.right mov rect2.left,eax mov eax,rect1.right add rect2.right,eax invoke DrawText,mDC,addr buffer1,-1,addr rect2,DT_SINGLELINE mov eax,des.dlgpt.x sub eax,des.mnurect.left mov edx,des.dlgpt.y sub edx,des.mnurect.top .if eax>=rect2.left && eax<=rect2.right && edx>=rect2.top && edx<=rect2.bottom mov eax,nInx mov des.nmnu,eax dec rect2.bottom invoke GetSystemMetrics,SM_SWAPBUTTON .if eax mov eax,VK_RBUTTON .else mov eax,VK_LBUTTON .endif invoke GetAsyncKeyState,eax and eax,8000h push eax .if eax mov eax,BDR_SUNKENOUTER .else mov eax,BDR_RAISEDINNER .endif invoke DrawEdge,mDC,addr rect2,eax,BF_RECT pop edx mov eax,[ebx].DLGHEAD.lpmnu .if eax && edx mov eax,nInx mov fMnu,eax invoke GetWindowRect,hWin,addr rect1 mov eax,rect1.left add eax,rect.left add eax,rect2.left mov pt.x,eax mov eax,rect1.top add eax,rect.bottom dec eax mov pt.y,eax .endif inc rect2.bottom .endif jmp @b .endif mov eax,rect.right sub eax,rect.left mov edx,rect.bottom sub edx,rect.top invoke BitBlt,hDC,rect.left,rect.top,eax,edx,mDC,0,0,SRCCOPY pop eax invoke SelectObject,mDC,eax pop eax invoke SelectObject,mDC,eax invoke DeleteObject,eax invoke DeleteDC,mDC invoke ReleaseDC,hWin,hDC .if fMnu mov eax,[ebx].DLGHEAD.lpmnu add eax,sizeof MNUHEAD invoke CreateSubMenu,eax,fMnu .if eax .if des.hmnu push eax invoke DestroyMenu,des.hmnu mov des.hmnu,0 pop eax .endif mov des.hmnu,eax invoke TrackPopupMenu,des.hmnu,TPM_LEFTALIGN or TPM_LEFTBUTTON,pt.x,pt.y,0,hWin,0 .endif .endif .endif .elseif eax==WM_NCMOUSEMOVE invoke SetWindowPos,hWin,0,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_FRAMECHANGED invoke UpdateWindow,hWin .elseif eax==WM_EXITMENULOOP .if des.hmnu invoke DestroyMenu,des.hmnu .endif xor eax,eax mov des.hmnu,eax mov des.dlgpt.x,eax mov des.dlgpt.y,eax invoke SetWindowPos,hWin,0,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_FRAMECHANGED invoke UpdateWindow,hWin .elseif eax==WM_ERASEBKGND .if fGrid invoke GetClientRect,hWin,addr rect invoke FillRect,wParam,addr rect,hGridBr xor eax,eax ret .endif .endif invoke DefDlgProc,hWin,uMsg,wParam,lParam ret MakeDlgClassProc endp MakeDialog proc uses esi edi ebx,hMem:DWORD,nSelID:DWORD LOCAL nInx:DWORD LOCAL hDlg:HWND LOCAL racol:RACOLOR LOCAL buffer[MaxCap]:BYTE ;Get convertiion mov dlgps,10 mov dlgfn,0 invoke CreateDialogIndirectParam,hInstance,offset dlgdata,hDEd,offset TestProc,0 invoke DestroyWindow,eax mov eax,fntwt mov dfntwt,eax mov eax,fntht mov dfntht,eax mov esi,hMem mov eax,[esi].DLGHEAD.fontsize mov dlgps,ax invoke ConvFontToUnicode,offset dlgfn,addr [esi].DLGHEAD.font invoke CreateDialogIndirectParam,hInstance,offset dlgdata,hDEd,offset TestProc,0 invoke DestroyWindow,eax .if nSelID==-1 push 0 mov ebx,hMultiSel @@: invoke GetParent,ebx invoke GetWindowLong,eax,GWL_ID push eax mov ecx,8 .while ecx push ecx invoke GetWindowLong,ebx,GWL_USERDATA mov ebx,eax pop ecx dec ecx .endw or ebx,ebx jne @b .while hMultiSel invoke DestroyMultiSel,hMultiSel mov hMultiSel,eax .endw .endif invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,128*1024 mov ebx,eax push eax mov [ebx].MyDLGTEMPLATEEX.dlgVer,1 mov [ebx].MyDLGTEMPLATEEX.signature,-1 mov [ebx].MyDLGTEMPLATEEX.helpID,0 mov esi,hMem mov edi,esi add esi,sizeof DLGHEAD mov eax,[esi].DIALOG.style .if byte ptr [edi].DLGHEAD.font or eax,DS_SETFONT .endif or eax,WS_ALWAYS or DS_NOFAILCREATE and eax,-1 xor (WS_POPUP or WS_DISABLED or WS_MINIMIZE or WS_MAXIMIZE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS) mov [ebx].MyDLGTEMPLATEEX.style,eax push eax mov eax,[esi].DIALOG.exstyle and eax,0F7FFFh and eax,-1 xor (WS_EX_LAYERED or WS_EX_TRANSPARENT or WS_EX_MDICHILD) mov [ebx].MyDLGTEMPLATEEX.exStyle,eax push esi mov ecx,-1 .while [esi].DIALOG.hwnd .if [esi].DIALOG.hwnd!=-1 inc ecx .endif add esi,sizeof DIALOG .endw pop esi mov [ebx].MyDLGTEMPLATEEX.cDlgItems,cx mov [ebx].MyDLGTEMPLATEEX.x,0 mov [ebx].MyDLGTEMPLATEEX.y,0 mov eax,[esi].DIALOG.duccx mov [ebx].MyDLGTEMPLATEEX.ccx,ax mov eax,[esi].DIALOG.duccy mov [ebx].MyDLGTEMPLATEEX.ccy,ax mov [ebx].MyDLGTEMPLATEEX.menu,0 add ebx,sizeof MyDLGTEMPLATEEX ;Class invoke SaveWideChar,addr szDlgChildClass,ebx add ebx,eax ;Caption invoke ConvertCaption,addr buffer,addr [esi].DIALOG.caption invoke SaveWideChar,addr buffer,ebx add ebx,eax pop eax test eax,DS_SETFONT .if !ZERO? ;Fontsize mov eax,[edi].DLGHEAD.fontsize mov [ebx],ax add ebx,2 ;Weight mov word ptr [ebx],0 add ebx,2 ;Italics mov byte ptr [ebx],0 add ebx,1 ;Charset mov byte ptr [ebx],0 add ebx,1 ;Facename invoke SaveWideChar,addr [edi].DLGHEAD.font,ebx add ebx,eax .endif add esi,sizeof DIALOG mov edi,esi mov nInx,0 .while [edi].DIALOG.hwnd inc nInx add edi,sizeof DIALOG .endw .if nInx @@: sub edi,sizeof DIALOG add ebx,2 and ebx,0FFFFFFFCh .if [edi].DIALOG.hwnd .if [edi].DIALOG.hwnd!=-1 mov [ebx].MyDLGITEMTEMPLATEEX.helpID,0 mov eax,[edi].DIALOG.style or eax,WS_ALWAYS and eax,-1 xor (WS_POPUP or WS_DISABLED or WS_MINIMIZE or WS_MAXIMIZE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS) .if [edi].DIALOG.ntype==14 or eax,LVS_SHAREIMAGELISTS .elseif [edi].DIALOG.ntype==16 and eax,(-1 xor UDS_AUTOBUDDY) .endif mov [ebx].MyDLGITEMTEMPLATEEX.style,eax mov eax,[edi].DIALOG.exstyle and eax,0F7FFFh and eax,-1 xor (WS_EX_LAYERED or WS_EX_TRANSPARENT or WS_EX_MDICHILD) mov [ebx].MyDLGITEMTEMPLATEEX.exStyle,eax mov eax,[edi].DIALOG.dux mov [ebx].MyDLGITEMTEMPLATEEX.x,ax mov eax,[edi].DIALOG.duy mov [ebx].MyDLGITEMTEMPLATEEX.y,ax mov eax,[edi].DIALOG.duccx mov [ebx].MyDLGITEMTEMPLATEEX.ccx,ax mov eax,[edi].DIALOG.duccy mov [ebx].MyDLGITEMTEMPLATEEX.ccy,ax mov eax,nInx mov [ebx].MyDLGITEMTEMPLATEEX.id,eax add ebx,sizeof MyDLGITEMTEMPLATEEX ;Class mov eax,[edi].DIALOG.ntype mov edx,sizeof TYPES mul edx add eax,offset ctltypes invoke SaveWideChar,[eax].TYPES.lpclass,ebx add ebx,eax ;Caption invoke ConvertCaption,addr buffer,addr [edi].DIALOG.caption invoke SaveWideChar,addr buffer,ebx add ebx,eax mov word ptr [ebx],0 add ebx,2 .endif dec nInx jne @b .endif .endif pop ebx invoke GetWindowLong,hDEd,DEWM_DIALOG .if eax invoke DestroyWindow,eax .endif invoke SetWindowLong,hDEd,DEWM_MEMORY,hMem invoke CreateDialogIndirectParam,hInstance,ebx,hDEd,offset MakeDlgProc,0 mov hDlg,eax mov des.hdlg,eax invoke SetWindowLong,hDEd,DEWM_DIALOG,hDlg invoke GlobalFree,ebx mov esi,hMem invoke SetWindowLong,hDlg,GWL_ID,0 invoke SendMessage,hDlg,WM_NCACTIVATE,1,0 .if nSelID==-1 .while TRUE pop eax .break .if !eax invoke GetDlgItem,hDlg,eax invoke CtlMultiSelect,eax .endw .else .if nSelID invoke GetDlgItem,hDlg,nSelID .else mov eax,hDlg .endif invoke SizeingRect,eax,FALSE .endif mov esi,hMem lea esi,[esi+sizeof DLGHEAD+sizeof DIALOG] xor ebx,ebx .while [esi].DIALOG.hwnd inc ebx .if [esi].DIALOG.hwnd!=-1 invoke GetDlgItem,des.hdlg,ebx .if eax invoke SetWindowPos,eax,HWND_BOTTOM,0,0,0,0,SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE .endif .endif add esi,sizeof DIALOG .endw invoke SetWindowPos,hInvisible,HWND_TOP,0,0,0,0,SWP_NOACTIVATE or SWP_SHOWWINDOW or SWP_NOMOVE or SWP_NOSIZE invoke InvalidateRect,hDEd,NULL,TRUE invoke UpdateWindow,hDEd mov esi,hMem .if ![esi].DLGHEAD.hred invoke CreateWindowEx,200h,addr szRAEditClass,0,WS_CHILD or STYLE_NOSIZEGRIP or STYLE_NOCOLLAPSE,0,0,0,0,hRes,0,hInstance,0 mov [esi].DLGHEAD.hred,eax invoke SendMessage,[esi].DLGHEAD.hred,WM_SETFONT,hredfont,0 invoke SendMessage,[esi].DLGHEAD.hred,REM_GETCOLOR,0,addr racol mov eax,color.back mov racol.bckcol,eax mov racol.cmntback,eax mov racol.strback,eax mov racol.oprback,eax mov racol.numback,eax mov eax,color.text mov racol.txtcol,eax mov racol.strcol,0 invoke SendMessage,[esi].DLGHEAD.hred,REM_SETCOLOR,0,addr racol invoke SendMessage,[esi].DLGHEAD.hred,REM_SETWORDGROUP,0,2 invoke UpdateRAEdit,esi invoke SendMessage,[esi].DLGHEAD.hred,EM_EMPTYUNDOBUFFER,0,0 .else invoke UpdateRAEdit,esi .endif mov eax,hDlg mov des.hdlg,eax ret MakeDialog endp CreateDlg proc uses esi edi,lpProItemMem:DWORD invoke CloseDialog mov esi,lpProItemMem invoke SetWindowLong,hDEd,DEWM_PROJECT,esi mov eax,(PROJECT ptr [esi]).hmem .if !eax ;Create new dlg invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,MaxMem mov esi,eax invoke GlobalLock,esi invoke SetWindowLong,hDEd,DEWM_MEMORY,esi invoke CreateNewCtl,hDEd,0,DlgX,DlgY,150,100 .else ;Create existing dlg mov esi,eax push esi add esi,sizeof DLGHEAD .while [esi].DIALOG.hwnd mov eax,[esi].DIALOG.ntype invoke GetTypePtr,eax mov eax,[eax].TYPES.ID mov [esi].DIALOG.ntypeid,eax add esi,sizeof DIALOG .endw pop esi invoke MakeDialog,esi,0 .endif invoke ShowWindow,hDEd,SW_SHOWNA mov eax,esi ret CreateDlg endp UndoRedo proc uses ebx esi edi,fRedo:DWORD invoke GetWindowLong,hDEd,DEWM_MEMORY .if eax mov ebx,eax .if [ebx].DLGHEAD.hred .if fRedo!=-1 mov edx,EM_UNDO .if fRedo mov edx,EM_REDO .endif invoke SendMessage,[ebx].DLGHEAD.hred,edx,0,0 invoke SendMessage,[ebx].DLGHEAD.hred,EM_SETSEL,0,0 .endif invoke GetWindowLong,hPrj,0 mov esi,eax invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,256*1024 mov edi,eax invoke SaveToMem,[ebx].DLGHEAD.hred,edi .while ebx!=[esi].PROJECT.hmem add esi,sizeof PROJECT .endw mov [esi].PROJECT.hmem,0 push [ebx].DLGHEAD.hred push [ebx].DLGHEAD.ftextmode invoke GetWindowLong,hPrj,0 invoke ParseRCMem,edi,eax .if fParseError .if [esi].PROJECT.hmem invoke GlobalUnlock,[esi].PROJECT.hmem invoke GlobalFree,[esi].PROJECT.hmem .endif mov [esi].PROJECT.hmem,ebx pop eax pop eax .else mov eax,[esi].PROJECT.hmem pop [eax].DLGHEAD.ftextmode pop [eax].DLGHEAD.hred invoke CreateDlg,esi invoke GlobalUnlock,ebx invoke GlobalFree,ebx .endif invoke GlobalFree,edi invoke SetChanged,TRUE mov fClose,0 .endif .endif invoke NotifyParent ret UndoRedo endp
; A215459: Arises in quick gossiping without duplicate transmission. ; 1,2,4,8,12,16,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110 mov $1,$0 lpb $1 mov $1,6 lpe add $0,1 mul $1,2 add $1,$0 trn $1,6 add $1,$0
TalkToTrainerScript:: faceplayer trainerflagaction CHECK_FLAG iftrue AlreadyBeatenTrainerScript loadtemptrainer encountermusic sjump StartBattleWithMapTrainerScript SeenByTrainerScript:: loadtemptrainer encountermusic showemote EMOTE_SHOCK, LAST_TALKED, 30 callasm TrainerWalkToPlayer applymovementlasttalked wMovementBuffer writeobjectxy LAST_TALKED faceobject PLAYER, LAST_TALKED sjump StartBattleWithMapTrainerScript StartBattleWithMapTrainerScript: opentext trainertext TRAINERTEXT_SEEN waitbutton closetext loadtemptrainer startbattle reloadmapafterbattle trainerflagaction SET_FLAG loadmem wRunningTrainerBattleScript, -1 AlreadyBeatenTrainerScript: scripttalkafter
; A199572: Number of round trips of length n on the cycle graph C_2 from any of the two vertices. ; 1,0,4,0,16,0,64,0,256,0,1024,0,4096,0,16384,0,65536,0,262144,0,1048576,0,4194304,0,16777216,0,67108864,0,268435456,0,1073741824,0,4294967296,0,17179869184,0,68719476736,0,274877906944,0 mov $1,-2 pow $1,$0 trn $1,0
; A309490: Total number of adjacent node merge operations to turn a circular list of size n to a node. ; Submitted by Jon Maiga ; 0,1,6,28,145,876,6139,49120,442089,4420900,48629911,583558944,7586266285,106207728004,1593115920075,25489854721216,433327530260689,7799895544692420,148198015349155999,2963960306983120000,62243166446645520021,1369349661826201440484,31495042222002633131155,755881013328063195147744 mov $1,1 mov $2,1 lpb $0 sub $0,1 add $2,1 mul $1,$2 add $1,$3 mov $3,1 lpe mov $0,$1 sub $0,1
org 0 cpu 8086 mov ax,cs mov ds,ax mov si,message mov cx,messageEnd-message int 0x64 mov al,'A' int 0x65 sti mov al,'B' int 0x65 mov ax,0x40 mov ds,ax mov ax,[0x6c] delayLoop: mov bx,[0x6c] sub bx,ax cmp bx,91 jbe delayLoop mov al,'C' int 0x65 int 0x60 mov al,'D' int 0x65 mov ax,[0x6c] delayLoop2: mov bx,[0x6c] sub bx,ax cmp bx,91 jbe delayLoop2 mov al,'E' int 0x65 mov ax,cs mov ds,ax mov si,doneMessage mov cx,doneMessageEnd-doneMessage int 0x64 mov al,'F' int 0x65 int 0x67 message: db "Delaying 5 seconds",10 messageEnd: doneMessage: db "Complete",10 doneMessageEnd:
; This example shows one of possible ways to use multiple STRUCT definitions ; as some kind of C-language-like "union" ; ; The "receive_buffer" is single block of memory large enough to accomodate ; any of the specific "commands" ; ; RECEIVE_BUFFER_HEADER struct defines the initial header shared across all "commands" ; RECEIVE_BUFFER_CMD_READ_REGS, RECEIVE_BUFFER_CMD_CONTINUE, RECEIVE_BUFFER_CMD_PED_TEST ; then define the specific "commands" with their extended fields ; ; finally there is small fake process-like subroutine to show usage of the defined fields ; define the command structures STRUCT RECEIVE_BUFFER_HEADER length DWORD 0 seq_no BYTE 0 command BYTE 0 ENDS STRUCT RECEIVE_BUFFER_CMD_READ_REGS, RECEIVE_BUFFER_HEADER register_number BYTE 0 ENDS STRUCT RECEIVE_BUFFER_CMD_CONTINUE, RECEIVE_BUFFER_HEADER bp1_enable BYTE 0 bp1_address WORD 0 bp2_enable BYTE 0 bp2_address WORD 0 ENDS STRUCT RECEIVE_BUFFER_CMD_PED_TEST, RECEIVE_BUFFER_HEADER pattern BLOCK 256 ENDS ; find the structure with maximum size to define how long the receive_buffer should be RB_MAX_SIZE = RECEIVE_BUFFER_HEADER RB_MAX_SIZE = RB_MAX_SIZE >? RECEIVE_BUFFER_CMD_READ_REGS RB_MAX_SIZE = RB_MAX_SIZE >? RECEIVE_BUFFER_CMD_CONTINUE RB_MAX_SIZE = RB_MAX_SIZE >? RECEIVE_BUFFER_CMD_PED_TEST ; reserve the memory for the receive_buffer (one buffer for all) ORG $8000 receive_buffer RECEIVE_BUFFER_HEADER .data BLOCK RB_MAX_SIZE - RECEIVE_BUFFER_HEADER, 0 ; definie alias labels for "receive_buffer" to access specific-command fields rb_read_regs RECEIVE_BUFFER_CMD_READ_REGS = receive_buffer rb_continue RECEIVE_BUFFER_CMD_CONTINUE = receive_buffer rb_ped_test RECEIVE_BUFFER_CMD_PED_TEST = receive_buffer ; example of usage in code ORG $C000 process_command: ld a,(receive_buffer.command) cp 1 jr nz,.not_read_regs ; CMD_READ_REGS specific code ld a,(rb_read_regs.register_number) rst 0 .not_read_regs: cp 2 jr nz,.not_continue ; CMD_CONTINUE specific code ld hl,(rb_continue.bp1_address) ld de,(rb_continue.bp2_address) ld bc,(rb_continue.bp1_enable) ; C = bp1_enable ld a,(rb_continue.bp2_enable) ld b,a ; B = bp2_enable rst 0 .not_continue: ; must be RECEIVE_BUFFER_CMD_PED_TEST then ld hl,rb_ped_test.pattern ld bc,$5B ; C = ZX Next sprite pattern upload port, B = 0 (256x) otir ; upload pattern to active pattern slot rst 0
TITLE LZW-EXPANDER Copyright (c) SLR Systems 1989 INCLUDE MACROS INCLUDE SLR32 PUBLIC EXP_STRUCT_SIZE,SLRPACK_PARAS,SLR_SKIP_PARAS PUBLIC SLR_STACK_ADR,SLR_START_ADR,SLR_PACK_LEN PUBLIC POS_TABLE,POS_TABLE_LEN,SLRUNPACK,FIX_INT21 EXP_STRUCT STRUC CURN_CHARSET_SIZE DW ? LIMIT EQU CURN_CHARSET_SIZE CURN_RT_SIZE DW ? BITLEN DB CHARSET_SIZE DUP(?) IF $ AND 1 DB ? ENDIF DECLEN DB 256 DUP(?) DECTBL DW 256 DUP(?) RIGHT DW CHARSET_SIZE*2 DUP(?) LEFT DW CHARSET_SIZE*2 DUP(?) POSITION_STUFF DB $ DUP(?) SIZE_BP DW ? EXP_STRUCT ENDS EXP_STRUCT_SIZE EQU (SIZE EXP_STRUCT+15) AND 0FFF0H GETBYTE MACRO MOV AL,[BX] INC BX XOR AH,AH ENDM PACK_SLR SEGMENT PARA PUBLIC 'UNPACK_DATA' ASSUME NOTHING,CS:PACK_SLR SLRUNPACK_START: SLRUNPACK: DB 87H,0C0H JMP SHORT SLRUNPACK1 DW SLR_START_JMP DB 02 ;COMPRESSION TYPE SLR_STACK_ADR DD ? SLR_START_ADR DD ? SLRUNPACK1: ; ;STACK IS WHERE I WANT IT... ; CLD MOV DX,DS ;PSP ADD DX,10H PUSH DX PUSH SS POP ES PUSH CS POP DS ASSUME DS:PACK_SLR ADD SLR_STACK_ADR.SEGM,DX ADD SLR_START_ADR.SEGM,DX XOR SI,SI XOR DI,DI MOV CX,SLR_PACK_LEN/2+1 REP MOVSW PUSH ES MOV AX,OFF SLR_MOVE_REST PUSH AX RETF SLR_MOVE_REST PROC NEAR ; ;MOVE COMPRESSED DATA UP SO WE CAN EXPAND DOWN... ; STD MOV BX,SLRPACK_PARAS ;# OF PARAGRAPHS TO MOVE... ASSUME DS:NOTHING 1$: ; ;MOVE SMALLER OF BX AND 1000H PARAS ; MOV CX,1000H ;ASSUME 64K CMP BX,CX JA 2$ MOV CX,BX 2$: SUB BX,CX MOV AX,DS SUB AX,CX MOV DS,AX MOV AX,ES SUB AX,CX MOV ES,AX ADD CX,CX ADD CX,CX ADD CX,CX ;# OF WORDS TO MOVE MOV DI,CX DEC DI ADD DI,DI ;ADDRESS OF FIRST WORD TO MOVE MOV SI,DI REP MOVSW OR BX,BX JNZ 1$ CLD PUSH ES ; POP DS LEA BX,2[DI] SLR_MOVE_REST ENDP SLR_1 PROC NEAR ; ;INITIALIZATION ; ; PUSH DS PUSH SS POP ES PUSH CS POP DS MOV DI,DATA_BASE MOV BP,DI LEA SI,INIT_1 MOVSW MOVSW MOV DI,POSITION_STUFF+DATA_BASE MOVSW MOVSW POP DS XOR DI,DI ;# OF BYTES NOT PACKED... ADD DX,8080H SLR_SKIP_PARAS EQU $-2 MOV ES,DX MOV DH,[BX] INC BX MOV DL,[BX] INC BX MOV CX,8 ; CALL FIX_PTRS JMP NEW_BLOCK INIT_1 DW CHARSET_SIZE DW 9 DW 1 SHL (POSSIZE-HARD_CODED) DW POSSIZE-HARD_CODED if limited_charset 2$: IF EXTRABITS EQ 8 GETBYTE ELSE MOV AL,EXTRABITS CALL GETBITS ENDIF JMP 29$ endif 0$: STOSB 1$: XOR AH,AH ;TABLE LOOKUP ON BYTE SAYS WHAT MOV AL,DH ;TO DO XCHG AX,SI MOV AL,DECLEN[SI+BP] ADD SI,SI MOV SI,DECTBL[SI+BP] ; ;NOW SKIP AL BITS ; ;AL IS NUMBER OF BITS TO READ ;CL IS BITS IN DX (EXCESS 8) ; CALL SKIP_BITS XCHG AX,SI CMP AX,CHARSET_SIZE JAE DO_DATA_AGAIN DA_RET: OR AH,AH JZ 0$ if limited_charset CMP AL,CHARSET_SIZE-256-1 JZ 2$ 29$: endif CMP AL,SLR_FIX_BUFFERS-256 JAE 4$ 5$: OR AL,AL JZ 6$ XOR AH,AH ;TABLE LOOKUP ON BYTE SAYS WHAT PUSH AX ;GET HI-PART OF POSITION MOV AL,DH ;TO DO XCHG AX,SI MOV AL,DECLEN[SI+POSITION_STUFF+BP] ADD SI,SI MOV SI,[SI+POSITION_STUFF+BP].DECTBL CALL SKIP_BITS CMP SI,1 SHL (POSSIZE-HARD_CODED) JAE 55$ 56$: if hard_coded eq 8 XCHG AX,SI XCHG AL,AH MOV SI,AX GETBYTE else XCHG AX,CX MOV CL,HARD_CODED SHL SI,CL XCHG AX,CX CALL GETBITS endif ADD SI,AX NEG SI ADD SI,DI DEC SI POP AX ADD AX,THRESHOLD XCHG AX,CX PUSH DS PUSH ES POP DS REP MOVSB POP DS XCHG AX,CX JMP 1$ 55$: PUSH BP MOV BP,POSITION_STUFF+DATA_BASE CALL TRY_AGAIN POP BP JMP 56$ DO_DATA_AGAIN: XCHG AX,SI CALL TRY_AGAIN XCHG AX,SI JMP DA_RET 6$: if t2_bits eq 8 GETBYTE else MOV AL,T2_BITS CALL GETBITS endif LEA SI,-1[DI] SUB SI,AX MOVS [DI],ES:BPTR[SI] MOVS [DI],ES:BPTR[SI] JMP 1$ 4$: JZ FIX_PTRS1 CMP AL,SLR_EOF-256 JZ SLR_STARTUP NEW_BLOCK: CALL INITIALIZE_BLOCK JMP 1$ FIX_PTRS1: CALL FIX_PTRS JMP 1$ FIX_PTRS: CMP DI,0C000H JB FIX_DOT SUB DI,4000H MOV AX,ES ADD AX,400H MOV ES,AX FIX_DOT: MOV AL,'.' FIX_DOT1: MOV AH,2 PUSH DX MOV DL,AL FIX_INT21: INT 21H POP DX CLD FIX_GET: OR BX,BX JNS 9$ MOV AX,DS ADD AX,800H MOV DS,AX SUB BH,80H 9$: RET SLR_STARTUP: ; ;SET UP REGS AND SUCH FOR STARTING UP... ; MOV AL,0DH CALL FIX_DOT1 MOV AL,0AH CALL FIX_DOT1 POP DX SUB DX,10H MOV BX,ES ;FOR EXTERNAL UNPACKER MOV DS,DX ;DS & ES ARE PSP MOV ES,DX MOV AX,SLR_STACK_ADR.SEGM CLI MOV SS,AX MOV SP,SLR_STACK_ADR.OFFS STI SLR_START_JMP: NOP JMP SLR_START_ADR SLR_1 ENDP EVEN TRY_AGAIN PROC NEAR ; ; ; ADD SI,SI ADD DX,DX DEC CX JZ 7$ 79$: JC DO_RIGHT MOV SI,LEFT[SI+BP] CMP LIMIT[BP],SI JBE TRY_AGAIN RET 7$: MOV DL,[BX] INC BX MOV CL,8 JMP 79$ EVEN DO_RIGHT: MOV SI,RIGHT[SI+BP] CMP LIMIT[BP],SI JBE TRY_AGAIN 9$: RET TRY_AGAIN ENDP EVEN GETBIT: MOV AL,1 GETBITS PROC NEAR ; ;AL IS NUMBER OF BITS TO READ ;CL IS BITS IN DX (EXCESS 8) ;RETURN BITS IN AX ; CMP AL,8 ;08 JZ GET8BITS_1 ;08 PUSHM SI,AX ;24 SUB AL,16 ;08 NEG AL ;08 XCHG AX,CX ;04 MOV SI,DX ;08 SHR SI,CL ;05+4*(16-bits) XCHG AX,CX ;03 POP AX ;12 PUSH SI ;12 CALL SKIP_BITS ;20 POPM AX,SI ;24 RET ;=== ;176 GETBITS ENDP EVEN GET8BITS PROC NEAR MOV AL,8 GET8BITS_1: PUSH DX CALL SKIP_BITS POP AX MOV AL,AH XOR AH,AH RET GET8BITS ENDP EVEN SKIP_BITS PROC NEAR ; ; ; CMP CL,AL ;08 JNC 2$ ;08 ; ;NOT ENOUGH, USE WHAT YOU CAN... ; SHL DX,CL MOV DL,[BX] INC BX SUB AL,CL MOV CL,AL SHL DX,CL MOV CL,8 SUB CL,AL RET EVEN 1$: MOV DL,[BX] INC BX MOV CL,8 RET 2$: ; ;ENOUGH BITS ALREADY HERE ; XCHG AX,CX ;04 SHL DX,CL ;33 XCHG AX,CX ;03 SUB CL,AL ;02 JZ 1$ ;08 RET ;12 ;== ;78 SKIP_BITS ENDP REBUILD_TREE PROC NEAR ; ; ; PUSHM DS,SI,DX,CX,BX MOV BX,CURN_CHARSET_SIZE[BP] MOV CX,100H ;LEN=1, DEPTH=0 MOV DX,-1 ;C=-1 XOR SI,SI ;CODE=0 CALL PARTIAL_TREE POPM BX,CX,DX,SI,DS RET REBUILD_TREE ENDP EVEN PARTIAL_TREE PROC NEAR ; ;if (len==depth) ; CMP CH,CL JNZ 5$ ; ;SCAN FOR MATCHING LEN ; INC DX MOV AX,CURN_CHARSET_SIZE[BP] SUB AX,DX ;# LEFT TO SCAN JBE 4$ ; IF NONE LEFT TO SCAN XCHG AX,CX MOV DI,DX LEA DI,BITLEN[DI+BP] REPNE SCASB XCHG AX,CX JNZ 4$ ; ; ; LEA DX,-BITLEN-1[DI] SUB DX,BP ; ;if len<=8 ; CMP CH,8 JA 3$ MOV AL,8 SUB AL,CH XCHG AX,CX MOV CH,1 SHL CH,CL MOV DI,SI MOV CL,8 SHR DI,CL PUSHM AX,DI LEA DI,DECLEN[DI+BP] MOV CL,CH XOR CH,CH PUSH CX MOV AL,AH ;LEN REP STOSB POPM CX,DI ADD DI,DI LEA DI,DECTBL[DI+BP] MOV AX,DX ;C REP STOSW POP CX 3$: ; ;return c ; MOV AX,DX RET 4$: ; ;NO MORE THIS BITLEN ; MOV DX,-1 ;C = -1 INC CH ; LEN++ 5$: PUSH BX ;SAVE I=AVAIL INC BX ;AVAIL++ INC CX ;DEPTH++ (CL) CALL PARTIAL_TREE ; POP DI ;I ADD DI,DI ; MOV LEFT[DI+BP],AX ; PUSH SI MOV AX,8000H DEC CX SHR AX,CL INC CX XOR SI,AX PUSHM DI CALL PARTIAL_TREE POPM DI,SI MOV RIGHT[DI+BP],AX DEC CX SHR DI,1 CMP CL,8 JNZ 6$ MOV AX,SI MOV AL,AH XOR AH,AH XCHG AX,SI MOV DECLEN[SI+BP],CL;8 ADD SI,SI MOV DECTBL[SI+BP],DI XCHG AX,SI 6$: XCHG AX,DI ;RETURN I RET PARTIAL_TREE ENDP INITIALIZE_BLOCK PROC NEAR ; ; ; PUSHM ES,DI PUSH SS POP ES CALL GETBIT OR AX,AX JZ 0$ ;JMP IF KEEPING LAST TREE CALL READ_TREE 0$: MOV BP,POSITION_STUFF+DATA_BASE CALL GETBIT OR AX,AX JZ 2$ CALL READ_TREE ;1 MEANS READ A NEW TREE 05$: ; OR AL,1 1$: POPM DI,ES XOR CH,CH MOV BP,DATA_BASE RET 2$: CALL GETBIT OR AX,AX ;USE SAME AS LAST TIME... JZ 05$ PUSHM DS,SI,DX,CX,BX,SS ;ONE MEANS USE DEFAULT POP DS LEA SI,POS_TABLE LEA DI,BITLEN[BP] MOV AL,1 MOV DX,LENGTH POS_TABLE XOR CH,CH 3$: MOV CL,[SI] INC SI REP STOSB INC AX DEC DX JNZ 3$ CALL REBUILD_TREE POPM BX,CX,DX,SI,DS JMP 05$ INITIALIZE_BLOCK ENDP READ_TREE PROC NEAR ; ; ; PUSH CX LEA DI,BITLEN[BP] GETBYTE MOV SI,AX INC SI XOR CH,CH 1$: GETBYTE MOV AH,AL MOV CL,4 SHR AH,CL MOV CL,AH AND AL,0FH INC AX STOSB REP STOSB DEC SI JNZ 1$ ; CMP WPTR BITLEN[BP],101H ; JNZ 2$ ; CMP BITLEN+2[BP],1 ; JZ 5$ ;2$: POP CX ; ;NOW, DO BUILD TREE ; JMP REBUILD_TREE ;5$: ; POP CX ; MOV AX,CURN_RT_SIZE[BP] ; CALL GETBITS ; PUSH CX ; MOV CX,CURN_CHARSET_SIZE[BP] ; LEA DI,DECTBL[BP] ; PUSH CX ; REP STOSW ; LEA DI,DECLEN[BP] ; POP CX ; XOR AL,AL ; REP STOSB ; JMP 2$ READ_TREE ENDP ;DO_READEM PROC NEAR ; ; ; ;1$: ; MOV AL,1 ; CALL GETBITS ; OR AX,AX ; JZ 2$ ; MOV AL,LENFIELD ; CALL GETBITS ; INC AX ;2$: ; STOSB ; DEC SI ; JNZ 1$ ; RET ; ;DO_READEM ENDP CopyRight DB 'Copyright (C) Digital Mars 1990-2004' POS_TABLE DB 1,0,0,1,2,6,15,22,20,19,42 ;0,1,0,2,3,7,18,47,50 POS_TABLE_LEN EQU $-POS_TABLE SLRPACK_PARAS DW ? SLR_PACK_LEN EQU $-SLRUNPACK_START DATA_BASE EQU (SLR_PACK_LEN+15) AND 0FFF0H PACK_SLR ENDS END
#include <insider_kernel.h> #include "addkeys.h" #include "mixcols.h" #include "shiftrows.h" #include "structure.h" #include "subbytes.h" void app_aes_process_5(ST_Queue<bool> &reset_app_aes_process_5, ST_Queue<unsigned int> &app_aes_proc_5_params, ST_Queue<unsigned int> &app_aes_proc_6_params, ST_Queue<APP_Data> &app_aes_proc_5_input_data, ST_Queue<APP_Data> &app_aes_proc_6_input_data) { _Bool valid_param = false; ; unsigned int input_param_num = 0; ; ; Elem s_table[64][256]; ; ; Matrix mix_table; ; ; #pragma HLS array_partition variable = s_table complete dim = 1 #pragma HLS array_partition variable = s_table cyclic factor = 4 dim = 2 Matrix key_table; ; ; ; bool reset = false; unsigned reset_cnt = 0; while (1) { bool dummy; if (reset || (reset = reset_app_aes_process_5.read_nb(dummy))) { valid_param = false; input_param_num = 0; for (int i0 = 0; i0 < 64; i0++) { for (int i1 = 0; i1 < 256; i1++) { s_table[i0][i1] = Elem(); } } mix_table = Matrix(); key_table = Matrix(); unsigned int dummy0; app_aes_proc_5_params.read_nb(dummy0); struct APP_Data dummy1; app_aes_proc_5_input_data.read_nb(dummy1); reset_cnt++; if (reset_cnt == RESET_CNT) { reset_cnt = 0; reset = false; } } else { #pragma HLS pipeline unsigned int param; APP_Data data_in; APP_Data data_out; if ((!valid_param) && app_aes_proc_5_params.read_nb(param)) { // param for subbytes if (input_param_num < 64) { unsigned char idx = ((input_param_num)&3); unsigned char id = ((input_param_num) >> 2); for (int i = 0; i < 64; i++) { #pragma HLS unroll s_table[i][16 * id + 4 * idx + 0] = (Elem)((param >> 24) & 0xff); s_table[i][16 * id + 4 * idx + 1] = (Elem)((param >> 16) & 0xff); s_table[i][16 * id + 4 * idx + 2] = (Elem)((param >> 8) & 0xff); s_table[i][16 * id + 4 * idx + 3] = (Elem)((param >> 0) & 0xff); } // param for mixcols } else if (input_param_num < 68) { unsigned char idx = input_param_num - 64; mix_table(32 * idx + 31, 32 * idx) = param; // param for addkeys } else if (input_param_num < 72) { unsigned char idx = input_param_num - 68; key_table(32 * idx + 31, 32 * idx) = param; if (input_param_num == 72 - 1) valid_param = true; } input_param_num++; app_aes_proc_6_params.write(param); } else if (valid_param && app_aes_proc_5_input_data.read_nb(data_in)) { for (int i = 0; i < 4; i++) { #pragma HLS unroll Matrix data = data_in.data(128 * i + 127, 128 * i); subbytes(data, s_table, i); shiftrows(data); mixcols(data, mix_table); addkeys(data, key_table); data_out.data(128 * i + 127, 128 * i) = data; } data_out.eop = data_in.eop; data_out.len = 64; app_aes_proc_6_input_data.write(data_out); } } } }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r8 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1a1bb, %rsi lea addresses_UC_ht+0x9678, %rdi nop nop nop inc %rax mov $87, %rcx rep movsb nop nop nop add %r12, %r12 lea addresses_WT_ht+0x4ef8, %r15 nop cmp $50038, %r8 mov (%r15), %di nop nop nop nop nop xor $53969, %rsi lea addresses_UC_ht+0x4678, %r15 nop nop sub $55723, %rcx and $0xffffffffffffffc0, %r15 vmovaps (%r15), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %rsi nop nop nop nop and %rsi, %rsi lea addresses_A_ht+0x3678, %rsi lea addresses_UC_ht+0x11078, %rdi nop nop cmp %r10, %r10 mov $121, %rcx rep movsb nop nop and $29304, %r15 lea addresses_WC_ht+0x1b3ac, %rsi lea addresses_WC_ht+0x1c308, %rdi nop nop nop nop nop and $62825, %r12 mov $56, %rcx rep movsq nop nop xor %rcx, %rcx lea addresses_normal_ht+0x5718, %rsi lea addresses_WT_ht+0x16448, %rdi nop xor %rax, %rax mov $52, %rcx rep movsl nop and $31562, %rax lea addresses_WT_ht+0x473c, %rsi lea addresses_A_ht+0x1acf8, %rdi clflush (%rsi) nop nop nop nop sub $4459, %r8 mov $111, %rcx rep movsq nop nop nop nop nop and %rdi, %rdi lea addresses_WC_ht+0xda88, %r12 clflush (%r12) nop cmp %r8, %r8 and $0xffffffffffffffc0, %r12 movntdqa (%r12), %xmm0 vpextrq $1, %xmm0, %rsi nop dec %rsi lea addresses_UC_ht+0x6678, %r10 nop nop nop nop nop cmp %rcx, %rcx mov $0x6162636465666768, %rdi movq %rdi, (%r10) nop nop nop nop nop cmp %r10, %r10 lea addresses_normal_ht+0x11978, %r15 nop cmp %r8, %r8 mov (%r15), %r10 nop nop nop nop nop dec %r15 lea addresses_WC_ht+0x1dbb8, %rsi nop nop nop cmp $51236, %rdi mov $0x6162636465666768, %r12 movq %r12, %xmm1 vmovups %ymm1, (%rsi) nop sub $48854, %r8 lea addresses_WC_ht+0x313c, %r15 clflush (%r15) nop nop nop nop cmp $2254, %rsi movb (%r15), %cl nop nop nop sub %r12, %r12 lea addresses_normal_ht+0xb598, %rax nop nop nop nop nop xor $11072, %r15 movw $0x6162, (%rax) nop nop nop nop nop add %r10, %r10 pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %rdx push %rsi // Faulty Load mov $0x678, %rdx nop nop nop nop xor %r14, %r14 movntdqa (%rdx), %xmm4 vpextrq $1, %xmm4, %r11 lea oracles, %r15 and $0xff, %r11 shlq $12, %r11 mov (%r15,%r11,1), %r11 pop %rsi pop %rdx pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_P'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_P'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'44': 6, '45': 21729, '48': 10, '00': 84} 48 44 44 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 */
db 0 ; species ID placeholder db 100, 134, 110, 61, 95, 100 ; hp atk def spd sat sdf db ROCK, DARK ; type db 45 ; catch rate db 218 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 40 ; step cycles to hatch INCBIN "gfx/pokemon/tyranitar/front.dimensions" db GROWTH_SLOW ; growth rate dn EGG_MONSTER, EGG_MONSTER ; egg groups db 35 ; happiness ; tm/hm learnset tmhm FOCUS_PUNCH, DRAGON_CLAW, WATER_PULSE, ROAR, TOXIC, HIDDEN_POWER, SUNNY_DAY, TAUNT, ICE_BEAM, BLIZZARD, HYPER_BEAM, PROTECT, RAIN_DANCE, FRUSTRATION, IRON_TAIL, THUNDERBOLT, THUNDER, EARTHQUAKE, RETURN, DIG, BRICK_BREAK, DOUBLE_TEAM, SHOCK_WAVE, FLAMETHROWER, SANDSTORM, FIRE_BLAST, ROCK_TOMB, AERIAL_ACE, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, FOCUS_BLAST, FLING, ENDURE, DRAGON_PULSE, SHADOW_CLAW, PAYBACK, GIGA_IMPACT, ROCK_POLISH, STONE_EDGE, AVALANCHE, THUNDER_WAVE, STEALTH_ROCK, CAPTIVATE, DARK_PULSE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, CUT, SURF, STRENGTH, ROCK_SMASH, ROCK_CLIMB, ANCIENTPOWER, AQUA_TAIL, EARTH_POWER, FIRE_PUNCH, FURY_CUTTER, ICE_PUNCH, IRON_HEAD, MUD_SLAP, OUTRAGE, SNORE, SPITE, SUPERPOWER, THUNDERPUNCH, UPROAR ; end
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r15 push %r9 push %rax // Load lea addresses_PSE+0x4ea4, %rax nop nop nop nop xor %r15, %r15 movb (%rax), %r13b nop add $55087, %r12 // Store lea addresses_D+0x1e594, %r10 nop nop cmp %r12, %r12 mov $0x5152535455565758, %r14 movq %r14, %xmm3 vmovups %ymm3, (%r10) sub %r15, %r15 // Store lea addresses_A+0x15124, %r12 nop nop nop nop add $45794, %r9 movb $0x51, (%r12) nop nop and %r13, %r13 // Store lea addresses_normal+0x18904, %r15 nop nop nop nop and %r13, %r13 movb $0x51, (%r15) nop nop nop nop nop dec %r15 // Faulty Load lea addresses_US+0x17124, %r14 cmp %r15, %r15 movups (%r14), %xmm4 vpextrq $1, %xmm4, %r12 lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rax pop %r9 pop %r15 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'00': 3} 00 00 00 */
############################################################################### # 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 p224r1_data: _prime224r1: .long 0x1, 0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF .p2align 4, 0x90 .globl p8_add_224 .type p8_add_224, @function p8_add_224: movl (%esi), %eax addl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax adcl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax adcl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax adcl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax adcl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax adcl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax adcl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe1: .size p8_add_224, .Lfe1-(p8_add_224) .p2align 4, 0x90 .globl p8_sub_224 .type p8_sub_224, @function p8_sub_224: movl (%esi), %eax subl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax sbbl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax sbbl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax sbbl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax sbbl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax sbbl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax sbbl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe2: .size p8_sub_224, .Lfe2-(p8_sub_224) .p2align 4, 0x90 .globl p8_shl_224 .type p8_shl_224, @function p8_shl_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm1 movl (24)(%esi), %eax psrldq $(4), %xmm1 movdqa %xmm0, %xmm2 psllq $(1), %xmm0 psrlq $(63), %xmm2 movdqa %xmm1, %xmm3 psllq $(1), %xmm1 psrlq $(63), %xmm3 palignr $(8), %xmm2, %xmm3 pslldq $(8), %xmm2 por %xmm3, %xmm1 por %xmm2, %xmm0 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) shr $(31), %eax ret .Lfe3: .size p8_shl_224, .Lfe3-(p8_shl_224) .p2align 4, 0x90 .globl p8_shr_224 .type p8_shr_224, @function p8_shr_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm2 movd %eax, %xmm1 palignr $(4), %xmm2, %xmm1 movdqa %xmm0, %xmm2 psrlq $(1), %xmm0 psllq $(63), %xmm2 movdqa %xmm1, %xmm3 psrlq $(1), %xmm1 psllq $(63), %xmm3 movdqa %xmm3, %xmm4 palignr $(8), %xmm2, %xmm3 psrldq $(8), %xmm4 por %xmm3, %xmm0 por %xmm4, %xmm1 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) ret .Lfe4: .size p8_shr_224, .Lfe4-(p8_shr_224) .p2align 4, 0x90 .globl p8_p224r1_add .type p8_p224r1_add, @function p8_p224r1_add: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call p8_add_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_sub_224 lea (%esp), %esi movl (8)(%ebp), %edi sub %eax, %edx cmovne %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe5: .size p8_p224r1_add, .Lfe5-(p8_p224r1_add) .p2align 4, 0x90 .globl p8_p224r1_sub .type p8_p224r1_sub, @function p8_p224r1_sub: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call p8_sub_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe6: .size p8_p224r1_sub, .Lfe6-(p8_p224r1_sub) .p2align 4, 0x90 .globl p8_p224r1_neg .type p8_p224r1_neg, @function p8_p224r1_neg: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi mov $(0), %eax subl (%esi), %eax movl %eax, (%edi) mov $(0), %eax sbbl (4)(%esi), %eax movl %eax, (4)(%edi) mov $(0), %eax sbbl (8)(%esi), %eax movl %eax, (8)(%edi) mov $(0), %eax sbbl (12)(%esi), %eax movl %eax, (12)(%edi) mov $(0), %eax sbbl (16)(%esi), %eax movl %eax, (16)(%edi) mov $(0), %eax sbbl (20)(%esi), %eax movl %eax, (20)(%edi) mov $(0), %eax sbbl (24)(%esi), %eax movl %eax, (24)(%edi) sbb %edx, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe7: .size p8_p224r1_neg, .Lfe7-(p8_p224r1_neg) .p2align 4, 0x90 .globl p8_p224r1_mul_by_2 .type p8_p224r1_mul_by_2, @function p8_p224r1_mul_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call p8_shl_224 mov %eax, %edx mov %edi, %esi movl (8)(%ebp), %edi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe8: .size p8_p224r1_mul_by_2, .Lfe8-(p8_p224r1_mul_by_2) .p2align 4, 0x90 .globl p8_p224r1_mul_by_3 .type p8_p224r1_mul_by_3, @function p8_p224r1_mul_by_3: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(64), %esp and $(-16), %esp movl %eax, (60)(%esp) lea p224r1_data, %eax lea ((_prime224r1-p224r1_data))(%eax), %eax movl %eax, (56)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call p8_shl_224 mov %eax, %edx mov %edi, %esi lea (28)(%esp), %edi mov (56)(%esp), %ebx call p8_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov %edi, %esi movl (12)(%ebp), %ebx call p8_add_224 mov %eax, %edx movl (8)(%ebp), %edi mov (56)(%esp), %ebx call p8_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (60)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe9: .size p8_p224r1_mul_by_3, .Lfe9-(p8_p224r1_mul_by_3) .p2align 4, 0x90 .globl p8_p224r1_div_by_2 .type p8_p224r1_div_by_2, @function p8_p224r1_div_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_add_224 mov $(0), %edx movl (%esi), %ecx and $(1), %ecx cmovne %edi, %esi cmove %edx, %eax movl (8)(%ebp), %edi call p8_shr_224 mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe10: .size p8_p224r1_div_by_2, .Lfe10-(p8_p224r1_div_by_2) .p2align 4, 0x90 .globl p8_p224r1_mul_mont_slm .type p8_p224r1_mul_mont_slm, @function p8_p224r1_mul_mont_slm: push %ebp mov %esp, %ebp push %ebx push %esi push %edi push %ebp mov %esp, %eax sub $(48), %esp and $(-16), %esp movl %eax, (44)(%esp) pxor %mm0, %mm0 movq %mm0, (%esp) movq %mm0, (8)(%esp) movq %mm0, (16)(%esp) movq %mm0, (24)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebp movl %edi, (32)(%esp) movl %esi, (36)(%esp) movl %ebp, (40)(%esp) mov $(7), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 .p2align 4, 0x90 .Lmmul_loopgas_11: movd %edi, %mm7 movl (%ebp), %edx movl (%esi), %eax movd %edx, %mm0 add $(4), %ebp movl %ebp, (40)(%esp) pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 mul %edx addl (%esp), %eax adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (4)(%esp), %ecx movd (20)(%esi), %mm1 adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (8)(%esp), %ebx movd (24)(%esi), %mm2 adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (12)(%esp), %ebp adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (16)(%esp), %edi adc $(0), %edx neg %eax adc $(0), %ecx movl %ecx, (%esp) adc $(0), %ebx movl %ebx, (4)(%esp) mov %eax, %ecx sbb $(0), %eax sub %eax, %ebp movl %ebp, (8)(%esp) mov %ecx, %eax mov $(0), %ebp sbb $(0), %edi movl %edi, (12)(%esp) adc $(0), %ebp movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (20)(%esp), %ecx adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (24)(%esp), %ebx adc $(0), %edx sub %ebp, %ecx movl %ecx, (16)(%esp) sbb $(0), %ebx movl %ebx, (20)(%esp) movd %mm7, %edi sbb $(0), %eax mov $(0), %ebx addl (28)(%esp), %edx adc $(0), %ebx add %eax, %edx movl %edx, (24)(%esp) adc $(0), %ebx movl %ebx, (28)(%esp) sub $(1), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 jz .Lexit_mmul_loopgas_11 movl (40)(%esp), %ebp jmp .Lmmul_loopgas_11 .Lexit_mmul_loopgas_11: emms mov (32)(%esp), %edi lea (%esp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_sub_224 movl (28)(%esp), %edx sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (44)(%esp), %esp pop %ebp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe11: .size p8_p224r1_mul_mont_slm, .Lfe11-(p8_p224r1_mul_mont_slm) .p2align 4, 0x90 .globl p8_p224r1_sqr_mont_slm .type p8_p224r1_sqr_mont_slm, @function p8_p224r1_sqr_mont_slm: push %ebp mov %esp, %ebp push %esi push %edi movl (12)(%ebp), %esi movl (8)(%ebp), %edi push %esi push %esi push %edi call p8_p224r1_mul_mont_slm add $(12), %esp pop %edi pop %esi pop %ebp ret .Lfe12: .size p8_p224r1_sqr_mont_slm, .Lfe12-(p8_p224r1_sqr_mont_slm) .p2align 4, 0x90 .globl p8_p224r1_mred .type p8_p224r1_mred, @function p8_p224r1_mred: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %esi mov $(7), %ecx xor %edx, %edx .p2align 4, 0x90 .Lmred_loopgas_13: movl (%esi), %eax neg %eax mov $(0), %ebx movl %ebx, (%esi) movl (4)(%esi), %ebx adc $(0), %ebx movl %ebx, (4)(%esi) movl (8)(%esi), %ebx adc $(0), %ebx movl %ebx, (8)(%esi) push %eax movl (12)(%esi), %ebx sbb $(0), %eax sub %eax, %ebx movl %ebx, (12)(%esi) pop %eax movl (16)(%esi), %ebx sbb $(0), %ebx movl %ebx, (16)(%esi) movl (20)(%esi), %ebx sbb $(0), %ebx movl %ebx, (20)(%esi) movl (24)(%esi), %ebx sbb $(0), %ebx movl %ebx, (24)(%esi) movl (28)(%esi), %ebx sbb $(0), %eax add %edx, %eax mov $(0), %edx adc $(0), %edx add %eax, %ebx movl %ebx, (28)(%esi) adc $(0), %edx lea (4)(%esi), %esi sub $(1), %ecx jnz .Lmred_loopgas_13 movl (8)(%ebp), %edi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call p8_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) pop %edi pop %esi pop %ebx pop %ebp ret .Lfe13: .size p8_p224r1_mred, .Lfe13-(p8_p224r1_mred) .p2align 4, 0x90 .globl p8_p224r1_select_pp_w5 .type p8_p224r1_select_pp_w5, @function p8_p224r1_select_pp_w5: push %ebp mov %esp, %ebp push %esi push %edi pxor %xmm0, %xmm0 movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %eax movd %eax, %xmm7 pshufd $(0), %xmm7, %xmm7 mov $(1), %edx movd %edx, %xmm6 pshufd $(0), %xmm6, %xmm6 movdqa %xmm0, (%edi) movdqa %xmm0, (16)(%edi) movdqa %xmm0, (32)(%edi) movdqa %xmm0, (48)(%edi) movdqa %xmm0, (64)(%edi) pxor %xmm3, %xmm3 movdqa %xmm6, %xmm5 mov $(16), %ecx .p2align 4, 0x90 .Lselect_loopgas_14: movdqa %xmm5, %xmm4 pcmpeqd %xmm7, %xmm4 movdqu (%esi), %xmm0 pand %xmm4, %xmm0 por (%edi), %xmm0 movdqa %xmm0, (%edi) movdqu (16)(%esi), %xmm1 pand %xmm4, %xmm1 por (16)(%edi), %xmm1 movdqa %xmm1, (16)(%edi) movdqu (32)(%esi), %xmm0 pand %xmm4, %xmm0 por (32)(%edi), %xmm0 movdqa %xmm0, (32)(%edi) movdqu (48)(%esi), %xmm1 pand %xmm4, %xmm1 por (48)(%edi), %xmm1 movdqa %xmm1, (48)(%edi) movdqu (64)(%esi), %xmm0 pand %xmm4, %xmm0 por (64)(%edi), %xmm0 movdqa %xmm0, (64)(%edi) movd (80)(%esi), %xmm1 pand %xmm4, %xmm1 por %xmm1, %xmm3 paddd %xmm6, %xmm5 add $(84), %esi sub $(1), %ecx jnz .Lselect_loopgas_14 movd %xmm3, (80)(%edi) pop %edi pop %esi pop %ebp ret .Lfe14: .size p8_p224r1_select_pp_w5, .Lfe14-(p8_p224r1_select_pp_w5)
; A218296: E.g.f.: Sum_{n>=0} n^n * cosh(n*x) * x^n/n!. ; Submitted by Jamie Morken(w2) ; 1,1,4,30,352,5560,109056,2540720,68401152,2087897472,71236526080,2686375597312,110951893303296,4980913763830784,241491517062512640,12575483733378816000,700015678015053758464,41480146826887546372096,2606901492484549499682816,173197151325111462461505536,12128809378920744149613281280,892921976446301940830305517568,68943339483424419159020067094528,5570756853009470932283493989220352,470132843037662812661906953941811200,41364184693572895004164653252608000000,3787928732042345084281464709848672239616 mov $4,$0 add $0,1 lpb $0 sub $0,1 mov $2,$4 sub $2,$1 pow $2,$4 mov $3,$4 bin $3,$1 add $1,2 mul $3,$2 add $5,$3 lpe mov $0,$5
; A130047: Left half of Pascal's triangle (A034868) modulo 2. ; Submitted by Jon Maiga ; 1,1,1,0,1,1,1,0,0,1,1,0,1,0,1,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0 lpb $0 add $1,$2 sub $0,$1 cmp $2,0 sub $0,$2 lpe add $2,$1 add $1,$2 bin $1,$0 mov $0,$1 mod $0,2
; Display "A" for 26 times. .MODEL SMALL .STACK 100 .DATA .CODE MAIN PROC MOV AX,@DATA MOV DS,AX MOV CX, 26 L1: MOV AH, 02H MOV DL, "A" INT 21H LOOP L1 MOV AX,4C00H INT 21H MAIN ENDP END MAIN
bits 64 db 0x66, 0x0F, 0x38, 0xF8, 0x07 ; MOVDIR64B [rdi], [rax] db 0x0F, 0x38, 0xF9, 0x00 ; MOVDIRI dword ptr [rax], eax db 0xF2, 0x0F, 0x38, 0xF8, 0x00 ; ENQCMD [rax], zmmword ptr [rax] db 0xF3, 0x0F, 0x38, 0xF8, 0x00 ; ENQCMDS [rax], zmmword ptr [rax]
; A086303: Numbers n such that n+15 is prime. ; 2,4,8,14,16,22,26,28,32,38,44,46,52,56,58,64,68,74,82,86,88,92,94,98,112,116,122,124,134,136,142,148,152,158,164,166,176,178,182,184,196,208,212,214,218,224,226,236,242,248,254,256,262,266,268,278,292,296 add $0,5 seq $0,98090 ; Numbers k such that 2k-3 is prime. sub $0,9 mul $0,2
; ; Posted in comp.sys.ibm.pc by Michael A. Shiels 8/16/89 ; From https://groups.google.com/forum/#!searchin/comp.sys.ibm.pc/single-step$20interrupt/comp.sys.ibm.pc/irWPIdzmCHQ/SyqEtq9mqCEJ ; ; Converted from MASM syntax to NASM syntax by Jeff Parsons 4/3/15 ; ;; title CPUID - Determine CPU & NDP Type ;; page 58,122 ;; name CPUID ; ; CPUID uniquely identifies each NEC & Intel CPU & NDP. ; ; Environments tested in: ; ; CPU Speed ; System in MHz CPU NDP ; ------ --------- --- --- ; IBM PC AT 6 Intel 80286 Intel 80287 ; IBM PC AT 9 Intel 80286 Intel 80287 ; IBM PC AT 6 Intel 80286 none ; IBM PC AT 8.5 Intel 80286 none ; IBM PC 4.77 Intel 8088 Intel 8087-3 ; IBM PC 4.77 Intel 8088* Intel 8087-3 ; IBM PC XT 4.77 Intel 8088 none ; IBM PC XT 4.77 Intel 8088 Intel 8087-3 ; IBM PC Portable 4.77 NEC V20 none ; COMPAQ 4.77 Intel 8088 none ; COMPAQ 4.77 NEC V20 none ; AT&T PC 6300 8 Intel 8086 Intel 8087-2 ; AT&T PC 6300 8 NEC V30 Intel 8087-2 ; Tandy 2000 8 Intel 80186 none ; ; * = faulty CPU ; ; Original code by: ; ; Bob Smith May 1985 ; Qualitas, Inc. ; 8314 Thoreau Dr. ; Bethesda, MD 20817 ; ; Arthur Zachai suggested the technique to distinguish within the ; 808x and 8018x families by exploiting the difference in the ; length of their pre-fetch instruction queues. ; ; Published in PC Tech Journal - April 1986 - Vol 4 No 4 ; CPU 8086 struc ARG_STR ARG_BP resw 1 ; caller's BP ARG_OFF resw 1 ; caller's offset ARG_SEG resw 1 ; segment ARG_FLG resw 1 ; flags endstruc ; Record to define bits in the CPU's & NDP's flags' registers CPU_CF equ 0001h CPU_PF equ 0004h CPU_AF equ 0010h CPU_ZF equ 0040h CPU_SF equ 0080h CPU_TF equ 0100h CPU_IF equ 0200h CPU_DF equ 0400h CPU_OF equ 0800h CPU_IOPL equ 3000h CPU_NT equ 4000h NDP_IM equ 0001h NDP_DM equ 0002h NDP_ZM equ 0004h NDP_OM equ 0008h NDP_UM equ 0010h NDP_PM equ 0020h NDP_IEM equ 0080h NDP_PC equ 0300h NDP_IC equ 1000h ; FLG_PIQL Pre-fetch instruction queue length, 0 => 4-byte, 1 => 6-byte ; FLG_08 Intel 808x ; FLG_NEC NEC V20 or V30 ; FLG_18 Intel 8018x ; FLG_28 Intel 8028x ; FLG_87 Intel 8087 ; FLG_287 Intel 80287 ; ; FLG_CERR Faulty CPU ; FLG_NERR Faulty NDP switch setting FLG_CPU equ 0007h ; CPU-related flags FLG_PIQL equ 001b FLG_08 equ 000b FLG_NEC equ 010b FLG_18 equ 100b FLG_28 equ 110b FLG_8088 equ FLG_08 FLG_8086 equ FLG_08 | FLG_PIQL FLG_V20 equ FLG_NEC FLG_v30 equ FLG_NEC | FLG_PIQL FLG_80188 equ FLG_18 FLG_80186 equ FLG_18 | FLG_PIQL FLG_80286 equ FLG_28 | FLG_PIQL FLG_NDP equ 0018h ; NDP-related flags FLG_NP equ 00b << 3 FLG_87 equ 01b << 3 FLG_287 equ 10b << 3 ; Assorted constants BEL equ 07h LF equ 0ah CR equ 0dh EOS equ '$' POPFF macro local L1,L2 jmp short L2 ; skip over IRET L1: iret ; pop the CP & IP pushed below along ; with the flags, our original purpose L2: push cs ; prepare for IRET by pushing CS call L1 ; push IP, jump to IRET endm ; POPFF macro TAB macro TYP push bx ; save for a moment and bx,mask FLG_&TYP ; isolate flags mov cl,FLG_&TYP ; shift amount shr bx,cl ; shift to low-order shl bx,1 ; times two to index table of words mov dx,TYP&MSG_TAB[bx] ; ds:dx => descriptive message pop bx ; restore mov ah,09h ; function code to display string int 21h ; request dos service endm ; TAB macro INT_VEC segment at 0 ; start INT_VEC segment dd ? ; pointer to INT 00h INT01_OFF dw ? ; pointer to INT 01h INT01_SEG dw ? INT_VEC ends ; end INT_VEC segment I11_REC record I11_PRN:2,I11_RSV1:2,I11_COM:3,I11_RSV2:1,I11_DISK:2,I11_VID:2,I11_RSV3:2,I11_NDP:1,I11_IPL:1 .section data OLDINT01_VEC label dword ; save area for original INT 01h handler OLDINT01_OFF dw ? OLDINT01_SEG dw ? NDP_CW label word ; save area for NDP control word db ? NDP_CW_HI db 0 ; high byte of control word NDP_ENV dw 7 dup(?) ; save area for NDP environment DATA ends subttl Message Data Area page MDATA segment byte public 'data' ; start MDATA segment assume ds:PGROUP MSG_START db 'CPUID -- Version 1.0' db CR,LF,CR,LF,EOS MSG_8088 db 'CPU is an Intel 8088.' db CR,LF,EOS MSG_8086 db 'CPU is an Intel 8086.' db CR,LF,EOS MSG_V20 db 'CPU is an NEC V20.' db CR,LF,EOS MSG_V30 db 'CPU is an NEC V30.' db CR,LF,EOS MSG_80188 db 'CPU is an Intel 80188.' db CR,LF,EOS MSG_80186 db 'CPU is an Intel 80186.' db CR,LF,EOS MSG_UNK db 'CPU is a maverick -- 80288??.' db CR,LF,EOS MSG_80286 db 'CPU is an Intel 80286.' db CR,LF,EOS CPUMSG_TAB dw PGROUP:MSG_8088 ; 000 = Intel 8088 dw PGROUP:MSG_8086 ; 001 = Intel 8086 dw PGROUP:MSG_V20 ; 010 = NEC V20 dw PGROUP:MSG_V30 ; 011 = NEC V30 dw PGROUP:MSG_80188 ; 100 = Intel 80188 dw PGROUP:MSG_80186 ; 101 = Intel 80186 dw PGROUP:MSG_UNK ; 110 = ? dw PGROUP:MSG_80286 ; 111 = Intel 80286 NDPMSG_TAB dw PGROUP:MSG_NDPX ; 00 = No NDP dw PGROUP:MSG_8087 ; 01 = Intel 8087 dw PGROUP:MSG_80287 ; 10 = Intel 80287 MSG_NDPX db 'NDP is not present.' db CR,LF,EOS MSG_8087 db 'NDP is an Intel 8087.' db CR,LF,EOS MSG_80287 db 'NDP is an Intel 80287.' db CR,LF,EOS CERRMSG_TAB dw PGROUP:MSG_CPUOK ; 0 = CPU healthy dw PGROUP:MSG_CPUBAD ; 1 = CPU faulty MSG_CPUOK db 'CPU appears to be healthy.' db CR,LF,EOS MSG_CPUBAD db BEL,'*** CPU incorrectly allows interrupts ' db 'after a change to SS ***',CR,LF db 'It should be replaced with a more recent ' db 'version as it could crash the',CR,LF db 'system at seemingly random times.',CR,LF,EOS NERRMSG_TAB dw PGROUP:MSG_NDPSWOK ; 0 = NDP switch set correctly dw PGROUP:MSG_NDPSWERR ; 1 = NDP switch set incorrectly MSG_NDPSWOK db EOS ; no message MSG_NDPSWERR db '*** Although there is an NDP installed ' db 'on this sytem, the corresponding',CR,LF db 'system board switch is not properly set. ' db 'To correct this, flip switch 2 of',CR,LF db 'switch block 1 on the system board.',CR,LF,EOS MDATA ends ; end MDATA segment subttl Main Routine page CODE segment byte public 'prog' ; start CODE segment assume cs:PGROUP,ds:PGROUP,es:PGROUP org 100h ; skip over PSP INITIAL proc near mov dx,offset ds:MSG_START ; starting message mov ah,09h ; function code to display string int 21h ; request DOS service call CPU_ID ; check the CPU's identity TAB CPU ; display CPU results TAB NDP ; display NDP results TAB CERR ; display CPU ERR results TAB NERR ; display NDP ERR results ret ; return to DOS INITIAL endp ; end INITIAL procedure subttl CPU_ID Procedure page CPU_ID proc near ; start CPU_ID procedure assume cs:PGROUP,ds:PGROUP,es:PGROUP ; This procedure determines the type of CPU and NDP (if any) in use. ; ; The possibilities include: ; ; Intel 8086 ; Intel 8088 ; NEC V20 ; NEC V30 ; Intel 80186 ; Intel 80188 ; Intel 80286 ; Intel 8087 ; Intel 80287 ; ; Also checked is whether or not the CPU allows interrupts after ; changing the SS register segment. If the CPU does, it is faulty ; and should be replaced. ; ; Further, if an NDP is installed, non-AT machines should have a ; system board switch set. Such a discrepancy is reported. ; ; On exit, BX contains flag settings (as defined in FLG record) which ; the caller can check. For example, to test for an Intel 80286, use ; ; and bx,mask FLAG_CPU ; cmp bx,FLG_80286 ; je ITSA286 irp XX,<ax,cx,di,ds,es> ; save registers push XX endm ; test for 80286 -- this CPU executes PUSH SP by first storing SP on ; stack, then decrementing it. earlier CPU's decrement, THEN store. mov bx,FLG_28 ; assume it's a 286 push sp ; only 286 pushes pre-push SP pop ax ; get it back cmp ax,sp ; check for same je CHECK_PIQL ; they are, so it's a 286 ; test for 80186/80188 -- 18xx and 286 CPU's mask shift/rotate ; operations mod 32; earlier CPUs use all 8 bits of CL. mov bx,FLG_18 ; assume it's an 8018x mov cl,32+1 ; 18x masks shift counts mod 32 ; note we can't use just 32 in CL mov al,0ffh ; start with all bits set shl al,cl ; shift one position if 18x jnz CHECK_PIQL ; some bits still on, ; so its a 18x, check PIQL ; test for V20 mov bx,FLG_NEC ; assume it's an NEC V-series CPU call CHECK_NEC ; see if it's an NEC chip jcxz CHECK_PIQL ; good guess, check PIQL mov bx,FLG_08 ; it's an 808x subttl Check Length of Pre-Fetch Instruction Queue page ; Check the length of the pre-fetch instruction queue (PIQ). ; ; xxxx6 CPUs have a PIQ length of 6 bytes, ; xxxx8 CPUs have a PIQ length of 4 bytes ; ; Self-modifying code is used to distinguish the two PIQ lengths. CHECK_PIQL: call PIQL_SUB ; handle via subroutine jcxz CHECK_ERR ; if CX is 0, INC was not executed, ; hence PIQ length is 4 or bx,FLG_PIQL ; PIQ length is 6 subttl Check for Allowing Interrupts After POP SS page ; Test for faulty chip (allows interrupts after change to SS register) CHECK_ERR: xor ax,ax ; prepare to address ; interrupt vector segment mov ds,ax ; DS points to segment 0 assume ds:INT_VEC ; tell the assembler cli ; nobody move while we swap mov ax,offset cs:INT01 ; point to our own handler xchg ax,INT01_OFF ; get and swap offset mov OLDINT01_OFF,ax ; save to restore later mov ax,cs ; our handler's segment xchg ax,INT01_SEG ; get and swap segment mov OLDINT01_SEG,ax ; save to restore later ; note we continue with interrupts disabled to avoid ; an external interrupt occuring during this test mov cx,1 ; initialize a register push ss ; save ss to store back into itself pushf ; move flags pop ax ; ... into ax or ax,mask TF ; set trap flag push ax ; place onto stack POPFF ; ... and then into effect ; some CPUs affect the trap flag ; immediately, some ; wait one instruction nop ; allow interrupt to take effect POST_NOP: pop ss ; change the stack segment register ; (to itself) dec cx ; normal cpu's execute this instruction ; before recognizing the single-step ; interrupt hlt ; we never get here INT01: ; Note: IF=TF=0 ; If we're stopped at or before POST_NOP, continue on push bp ; prepare to address the stack mov bp,sp ; hello, Mr. stack cmp [bp].ARG_STR.ARG_OFF,offset cs:POST_NOP ; check offset pop bp ; restore ja INTO1_DONE ; we're done iret ; return to caller INTO1_DONE: ; restore old INT 01h handler les ax,OLDINT01_VEC ; ES:AX ==> old INT 01h handler assume es:nothing ; tell the assembler mov INT01_OFF,ax ; restore offset mov INT01_SEG,es ; ... and segment sti ; allow interrupts again (IF=1) add sp,3*2 ; strip IP, CS, and flags from stack push cs ; setup DS for code below pop ds assume ds:PGROUP ; tell the assembler jcxz CHECK_NDP ; if cx is 0, the dec cx was executed, ; and the cpu is ok or bx,mask FLG_CERR ; it's a faulty chip subttl Check For Numeric Data Processor page ; Test for a Numeric Data Processor -- Intel 8087 or 80287. The ; technique used is passive -- it leaves the NDP in the same state in ; which it is found. CHECK_NDP: cli ; protect FNSTENV fnstenv NDP_ENV ; if NDP present, save ; current environment, ; otherwise, this instruction ; is ignored mov cx,50/7 ; cycle this many times loop $ ; wait for result to be stored sti ; allow interrupts fninit ; initialize processor to known state jmp short $+2 ; wait for initialization fnstcw NDP_CW ; save control word jmp short $+2 ; wait for result to be stored jmp short $+2 cmp NDP_CW_HI,03h ; check for NDP initial control word jne CPUID_EXIT ; no NDP installed int 11h ; get equipment flags into ax test ax,mask I11_NDP ; check NDP-installed bit jnz CHECK_NDP1 ; it's correctly set or bx,mask FLG_NERR ; mark as in error CHECK_NDP1: and NDP_CW,not mask IEM ; enable interrupts ; (IEM=0, 8087 only) fldcw NDP_CW ; reload control word fdisi ; disable interrupts (IEM=1) on 8087, ; ignored by 80287 fstcw NDP_CW ; save control word fldenv NDP_ENV ; restore original NDP environment ; no need to wait ; for environment to be loaded test NDP_CW,mask IEM ; check interrupt enable mask ; (8087 only) jnz CPUID_8087 ; it changed, hence NDP is an 8087 or bx,FLG_287 ; NDP is an 80287 jmp short CPUID_EXIT ; exit with falgs in BX CPUID_8087: or bx,FLG_87 ; NDP is an 8087 CPUID_EXIT: irp XX,<es,ds,di,cx,ax> ; restore registers pop XX endm assume ds:nothing,es:nothing ret ; return to caller CPU_ID endp ; end CPU_ID procedure subttl Check For NEC V20/V30 page CHECK_NEC proc near ; The NEC V20/V30 are very compatible with the Intel 8086/8088. ; The only point of "incompatibility" is that they do not contain ; a bug found in the Intel CPU's. Specifically, the NEC CPU's ; correctly restart an interrupted multi-prefix string instruction ; at the start of the instruction. The Intel CPU's incorrectly ; restart in the middle of the instruction. This routine tests ; for that situation by executing such an instruction for a ; sufficiently long period of time for a timer interrupt to occur. ; If at the end of the instruction, CX is zero, it must be an NEC ; CPU; if not, it's an Intel CPU. ; ; Note that we're counting on the timer interrupt to do its thing ; every 18.2 times per second. ; ; Here's a worst case analysis: An Intel 8088/8086 executes 65535 ; iterations of LODSB ES[SI] in 2+9+13*65535 = 851,966 clock ticks. ; If the Intel 8088/8086 is running at 10 MHz, each clock tick is ; 100 nanoseconds, hence the entire operation takes 85 milliseconds. ; If the timer is running at normal speed, it interrupts the CPU every ; 55ms and so should interrupt the repeated string instruction at least ; once. mov cx,0ffffh ; move a lot of data sti ; ensure timer enabled ; execute multi-prefix instruction. note that the value of ES as ; well as the direction flag setting is irrelevant. push ax ; save registers push si rep lods byte ptr es:[si] pop si ; restore pop ax ; on exit: if cx is zero, it's an NEC CPU, otherwise it's an Intel CPU ret ; return to caller CHECK_NEC endp subttl Pre-Fetch Instruction Queue Subroutine page PIQL_SUB proc near ; This subroutine discerns the length of the CPU's pre-fetch ; instruction queue (PIQ). ; ; The technique used is to first ensure that the PIQ is full, then ; change an instruction which should be in a 6-byte PIQ but not in a ; 4-byte PIQ. Then, if the original instruction is executed, the PIQ ; is 6-bytes long; if the new instruction is executed, PIQ length is 4. ; ; We ensure the PIQ is full be executing an instruction which takes ; long enough so that the Bus Interface Unit (BIU) can fill the PIQ ; while the instruction is executing. ; ; Specifically, for all byt the last STOSB, we're simple marking time ; waiting for the BIU to fill the PIQ. The last STOSB actually changes ; the instruction. By that time, the orignial instruction should be in ; a six-byte PIQ byt not a four-byte PIQ. assume cs:PGROUP,es:PGROUP @REP equ 3 ; repeat the store this many times std ; store backwards mov di,offset es:LAB_INC+@REP-1 ; change the instructions ; at ES:DI ; and preceding mov al,ds:LAB_STI ; change to a sti mov cx,@REP ; give the BIU time ; to pre-fetch instructions cli ; ensure interrupts are disabled, ; otherwise a timer tick ; could change the PIQ filling rep stosb ; change the instruction ; during execution of this instruction ; the BIU is refilling the PIQ. The ; current instruction is no longer ; in the PIQ. ; Note at end, CX is 0. ; The PIQ begins filling here cld ; restore direction flag nop ; PIQ fillers nop nop ; The following instruction is beyond a four-byte-PIQ CPU's reach, ; but within that of a six-byte-PIQ CPU. LAB_INC label byte inc cx ; executed only if PIQ length is 6 LAB_STI label byte rept @REP-1 sti ; restore interrupts endm ret ; return to caller assume ds:nothing,es:nothing PIQL_SUB endp ; end PIQL_SUB procedure CODE ends ; end code segment end INITIAL ; end CPU_ID module
// Computes RAM[1] = 1+2+ ... +n // Usage: put a number (n) in RAM[0] @R0 D=M @n M=D // n = R0 @i M=1 // i = 1 @sum M=0 // sum = 0 (LOOP) @i D=M @n D=D-M @STOP D;JGT // if i > n goto STOP @sum D=M @i D=D+M @sum M=D // sum += i @i M=M+1 // i += 1 @LOOP 0;JMP (STOP) @sum D=M @R1 M=D // RAM[1] = sum (END) @END 0;JMP
.code pal_execute_write_cr3 proc mov cr3, rcx; ret; pal_execute_write_cr3 endp end
;-----------------------------------------------------------------------------; ; Author: Michael Schierl (schierlm[at]gmx[dot]de) ; Version: 1.0 (29 December 2012) ;-----------------------------------------------------------------------------; [BITS 32] ; Input: EBP - Data to decode ; ECX - Data length ; ESI - Key (16 bytes for simplicity) ; EDI - pointer to 0x100 bytes scratch space for S-box ; Direction flag has to be cleared ; Output: None. Data is decoded in place. ; Clobbers: EAX, EBX, ECX, EDX, EBP (stack is not used) ; Initialize S-box xor eax, eax ; Start with 0 init: stosb ; Store next S-Box byte S[i] = i inc al ; increase byte to write (EDI is increased automatically) jnz init ; loop until we wrap around sub edi, 0x100 ; restore EDI ; permute S-box according to key xor ebx, ebx ; Clear EBX (EAX is already cleared) permute: add bl, [edi+eax] ; BL += S[AL] + KEY[AL % 16] mov edx, eax and dl, 0xF add bl, [esi+edx] mov dl, [edi+eax] ; swap S[AL] and S[BL] xchg dl, [edi+ebx] mov [edi+eax], dl inc al ; AL += 1 until we wrap around jnz permute ; decryption loop xor ebx, ebx ; Clear EBX (EAX is already cleared) decrypt: inc al ; AL += 1 add bl, [edi+eax] ; BL += S[AL] mov dl, [edi+eax] ; swap S[AL] and S[BL] xchg dl, [edi+ebx] mov [edi+eax], dl add dl, [edi+ebx] ; DL = S[AL]+S[BL] mov dl, [edi+edx] ; DL = S[DL] xor [ebp], dl ; [EBP] ^= DL inc ebp ; advance data pointer dec ecx ; reduce counter jnz decrypt ; until finished
//cpp #include "tic_tac_toe.h" bool TicTacToe::game_over() { if(check_column_win() || check_row_win() || check_diagonal_win()) { set_winner(); return true; } else if(check_board_full()) { winner = "C"; return true; } return false; } void TicTacToe::mark_board(int position) { pegs[position-1] = player; set_next_player(); } void TicTacToe::set_next_player() { if(player == "X") { player= "O"; } else { player = "X"; } } void TicTacToe::start_game(std::string first_player) { player=first_player; clear_board(); } void TicTacToe::display_board()const { for(std::size_t i=0; i < pegs.size(); i += 3) { std::cout<<pegs[i]<<"|"<<pegs[i+1]<<"|"<<pegs[i+2]<<"\n"; } } bool TicTacToe::check_board_full()const { for(auto peg: pegs) { if(peg==" ") { return false; } } return true; } void TicTacToe::clear_board() { for(std::size_t i=0; i < pegs.size(); ++i) { pegs[i] = " "; } } //p2 bool TicTacToe::check_column_win() { if(pegs[0] == pegs[3] && pegs[3] == pegs[6] && pegs[0] != " ") { return true; } else if(pegs[1] == pegs[4] && pegs[4] == pegs[7] && pegs[1] != " ") { return true; } else if(pegs[2] == pegs[5] && pegs[5] == pegs[8] && pegs[2] != " ") { return true; } return false; } bool TicTacToe::check_row_win() { if(pegs[0] == pegs[1] && pegs[1] == pegs[2] && pegs[0] != " ") { return true; } else if(pegs[3] == pegs[4] && pegs[4] == pegs[5] && pegs[3] != " ") { return true; } else if(pegs[6] == pegs[7] && pegs[7] == pegs[8] && pegs[6] != " ") { return true; } return false; } bool TicTacToe::check_diagonal_win() { if(pegs[0] == pegs[4] && pegs[4] == pegs[8] && pegs[4] != " ") { return true; } else if(pegs[2] == pegs[4] && pegs[4] == pegs[6] && pegs[4] != " ") { return true; } return false; } void TicTacToe::set_winner() { if(player == "X") { winner = "O"; } else { winner = "X"; } }
; A095374: One less than the number of divisors of 2*n + 1. ; 1,1,1,2,1,1,3,1,1,3,1,2,3,1,1,3,3,1,3,1,1,5,1,2,3,1,3,3,1,1,5,3,1,3,1,1,5,3,1,4,1,3,3,1,3,3,3,1,5,1,1,7,1,1,3,1,3,5,3,2,3,3,1,3,1,3,7,1,1,3,3,3,5,1,1,5,3,1,3,3,1,7,1,2,5,1,5,3,1,1,3,3,3,7,1,1,7,1,1,3 add $0,1 mul $0,4 mov $1,$0 add $0,1 seq $0,94820 ; Partial sums of A038548. seq $1,94820 ; Partial sums of A038548. sub $0,$1 sub $0,1
////////////////////////////////////////////////////////////////////////////// // test_util_code.asm // Copyright(c) 2021 Neal Smith. // License: MIT. See LICENSE file in root directory. ////////////////////////////////////////////////////////////////////////////// // This file contains code, macros, and data that are utility for all // test programs in nv_c64_util_test // import all nv_c64_util macros and data. The data // will go in default place #import "../../nv_c64_util/nv_c64_util_macs_and_data.asm" space_str: .text @" \$00" passed_str: .text @" PASSED\$00" failed_str: .text @" FAILED\$00" fail_control_str: nv_screen_lite_red_fg_str() pass_control_str: nv_screen_green_fg_str() normal_control_str: nv_screen_white_fg_str() passed: .byte 0 bad_carry_str: .text@" C\$00" bad_overflow_str: .text@" V\$00" bad_neg_str: .text@" N\$00" bad_zero_str: .text@" Z\$00" overflow_set_str: .text@" V=1\$00" overflow_clear_str: .text@" V=0\$00" hit_anykey_str: .text @"HIT ANY KEY ...\$00" ///////////////////////////////////////////////////////////////////////////// // wait for key then clear screen when its detected .macro wait_and_clear_at_row(init_row, title_str) { .var row = init_row .eval row++ nv_screen_plot_cursor(row++, 0) nv_screen_print_str(hit_anykey_str) jsr WaitAnyKey nv_screen_clear() .eval row=0 nv_screen_plot_cursor(row++, 23) nv_screen_print_str(title_str) } ////////////////////////////////////////////////////////////////////////////// WaitAnyKey: nv_key_wait_any_key() rts ////////////////////////////////////////////////////////////////////////////// .macro pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, expect_neg_set) { php nv_screen_print_str(fail_control_str) plp .if (expect_carry_set) { bcs CarryGood } else { bcc CarryGood } php nv_screen_print_str(bad_carry_str) lda #0 sta passed plp CarryGood: .if (expect_overflow_set) { bvs OverflowGood } else { bvc OverflowGood } php nv_screen_print_str(bad_overflow_str) lda #0 sta passed plp OverflowGood: .if (expect_neg_set) { bmi NegGood } else { bpl NegGood } php nv_screen_print_str(bad_neg_str) lda #0 sta passed plp NegGood: php nv_screen_print_str(normal_control_str) plp } ////////////////////////////////////////////////////////////////////////////// .macro pass_or_fail_carry(expect_carry_set) { php nv_screen_print_str(fail_control_str) plp .if (expect_carry_set) { bcs CarryGood } else { bcc CarryGood } php nv_screen_print_str(bad_carry_str) lda #0 sta passed plp CarryGood: } ////////////////////////////////////////////////////////////////////////////// .macro pass_or_fail_zero(expect_zero_set) { php nv_screen_print_str(fail_control_str) plp .if (expect_zero_set) { beq Good } else { bne Good } php nv_screen_print_str(bad_zero_str) lda #0 sta passed plp Good: } ////////////////////////////////////////////////////////////////////////////// .macro pass_or_fail_overflow(expect_overflow_set) { php .if (expect_overflow_set) { bvs OverflowGood } else { bvc OverflowGood } nv_screen_print_str(fail_control_str) lda #0 sta passed jmp PrintOverflowState OverflowGood: nv_screen_print_str(pass_control_str) PrintOverflowState: plp php bvs OverflowSet OverflowClear: nv_screen_print_str(overflow_clear_str) jmp Done OverflowSet: nv_screen_print_str(overflow_set_str) Done: nv_screen_print_str(normal_control_str) plp } /////////////////////////////////////////////////////////////////////// PrintHexWord: { nv_screen_print_hex_word_mem(word_to_print, true) rts } word_to_print: .word 0 /////////////////////////////////////////////////////////////////////// PrintHexByteAccum: { nv_screen_print_hex_byte_a(true) rts } /////////////////////////////////////////////////////////////////////// PrintPassed: { nv_screen_print_str(space_str) lda passed bne PrintPassed PrintFailed: nv_screen_print_str(fail_control_str) nv_screen_print_str(failed_str) jmp Done PrintPassed: nv_screen_print_str(pass_control_str) nv_screen_print_str(passed_str) Done: nv_screen_print_str(normal_control_str) rts } ///////////////////////////////////////////////////////////////// // /* .macro PrintCarryAndOverflow() { php bcc NoCarry Carry: bvs CarryAndOverflow CarryNoOverflow: nv_screen_print_str(carry_str) jmp Done CarryAndOverflow: nv_screen_print_str(carry_and_overflow_str) jmp Done NoCarry: bvc NoCarryNoOverflow NoCarryButOverflow: nv_screen_print_str(overflow_str) jmp Done NoCarryNoOverflow: Done: plp } */
// Copyright Aleksey Gurtovoy 2001-2004 // // 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) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/libs/mpl/test/joint_view.cpp,v $ // $Date: 2004/10/01 16:32:41 $ // $Revision: 1.5 $ #include <boost/mpl/joint_view.hpp> #include <boost/mpl/range_c.hpp> #include <boost/mpl/list.hpp> #include <boost/mpl/equal.hpp> #include <boost/mpl/size.hpp> #include <boost/mpl/aux_/test.hpp> MPL_TEST_CASE() { typedef joint_view< range_c<int,0,10> , range_c<int,10,15> > numbers; typedef range_c<int,0,15> answer; MPL_ASSERT(( equal<numbers,answer> )); MPL_ASSERT_RELATION( size<numbers>::value, ==, 15 ); } template< typename View > struct test_is_empty { typedef typename begin<View>::type first_; typedef typename end<View>::type last_; MPL_ASSERT_RELATION( size<View>::value, ==, 0 ); MPL_ASSERT(( is_same< first_,last_> )); MPL_ASSERT_INSTANTIATION( View ); MPL_ASSERT_INSTANTIATION( first_ ); MPL_ASSERT_INSTANTIATION( last_ ); }; MPL_TEST_CASE() { test_is_empty< joint_view< list0<>,list0<> > >(); test_is_empty< joint_view< list<>,list0<> > >(); test_is_empty< joint_view< list<>,list<> > >(); test_is_empty< joint_view< list<>, joint_view< list0<>,list0<> > > >(); }
/** \class HLTMuonDimuonL2Filter * * See header file for documentation * * \author J. Alcaraz, P. Garcia * */ #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" #include "DataFormats/HLTReco/interface/TriggerRefsCollections.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "HLTMuonDimuonL3Filter.h" #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h" #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h" #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" #include "TrackingTools/PatternTools/interface/ClosestApproachInRPhi.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/Math/interface/deltaR.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" using namespace edm; using namespace std; using namespace reco; using namespace trigger; // // constructors and destructor // namespace { struct Out { Out(std::vector<double> const& v) : v_(v) {} std::vector<double> const& v_; }; #if defined(EDM_ML_DEBUG) std::ostream& operator<<(std::ostream& iS, Out const& iO) { iS << "["; for (double v : iO.v_) { iS << v << " "; } iS << "]"; return iS; } #endif } // namespace HLTMuonDimuonL3Filter::HLTMuonDimuonL3Filter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig), beamspotTag_(iConfig.getParameter<edm::InputTag>("BeamSpotTag")), beamspotToken_(consumes<reco::BeamSpot>(beamspotTag_)), candTag_(iConfig.getParameter<edm::InputTag>("CandTag")), candToken_(consumes<reco::RecoChargedCandidateCollection>(candTag_)), previousCandTag_(iConfig.getParameter<InputTag>("PreviousCandTag")), previousCandToken_(consumes<trigger::TriggerFilterObjectWithRefs>(previousCandTag_)), l1CandTag_(iConfig.getParameter<InputTag>("L1CandTag")), l1CandToken_(consumes<trigger::TriggerFilterObjectWithRefs>(l1CandTag_)), recoMuTag_(iConfig.getParameter<InputTag>("inputMuonCollection")), recoMuToken_(consumes<reco::MuonCollection>(recoMuTag_)), previousCandIsL2_(iConfig.getParameter<bool>("PreviousCandIsL2")), fast_Accept_(iConfig.getParameter<bool>("FastAccept")), min_N_(iConfig.getParameter<int>("MinN")), max_Eta_(iConfig.getParameter<double>("MaxEta")), min_Nhits_(iConfig.getParameter<int>("MinNhits")), max_Dr_(iConfig.getParameter<double>("MaxDr")), max_Dz_(iConfig.getParameter<double>("MaxDz")), chargeOpt_(iConfig.getParameter<int>("ChargeOpt")), min_PtPair_(iConfig.getParameter<vector<double> >("MinPtPair")), max_PtPair_(iConfig.getParameter<vector<double> >("MaxPtPair")), min_PtMax_(iConfig.getParameter<vector<double> >("MinPtMax")), min_PtMin_(iConfig.getParameter<vector<double> >("MinPtMin")), max_PtMin_(iConfig.getParameter<vector<double> >("MaxPtMin")), min_InvMass_(iConfig.getParameter<vector<double> >("MinInvMass")), max_InvMass_(iConfig.getParameter<vector<double> >("MaxInvMass")), min_Acop_(iConfig.getParameter<double>("MinAcop")), max_Acop_(iConfig.getParameter<double>("MaxAcop")), min_PtBalance_(iConfig.getParameter<double>("MinPtBalance")), max_PtBalance_(iConfig.getParameter<double>("MaxPtBalance")), nsigma_Pt_(iConfig.getParameter<double>("NSigmaPt")), max_DCAMuMu_(iConfig.getParameter<double>("MaxDCAMuMu")), max_YPair_(iConfig.getParameter<double>("MaxRapidityPair")), cutCowboys_(iConfig.getParameter<bool>("CutCowboys")), theL3LinksLabel(iConfig.getParameter<InputTag>("InputLinks")), linkToken_(consumes<reco::MuonTrackLinksCollection>(theL3LinksLabel)), L1MatchingdR_(iConfig.getParameter<double>("L1MatchingdR")), matchPreviousCand_(iConfig.getParameter<bool>("MatchToPreviousCand")), MuMass2_(0.106 * 0.106) { LogDebug("HLTMuonDimuonL3Filter") << " CandTag/MinN/MaxEta/MinNhits/MaxDr/MaxDz/MinPt1/MinPt2/MinInvMass/MaxInvMass/" "MinAcop/MaxAcop/MinPtBalance/MaxPtBalance/NSigmaPt/MaxDzMuMu/MaxRapidityPair : " << candTag_.encode() << " " << fast_Accept_ << " " << min_N_ << " " << max_Eta_ << " " << min_Nhits_ << " " << max_Dr_ << " " << max_Dz_ << " " << chargeOpt_ << " " << Out(min_PtPair_) << " " << Out(min_PtMax_) << " " << Out(min_PtMin_) << " " << Out(min_InvMass_) << " " << Out(max_InvMass_) << " " << min_Acop_ << " " << max_Acop_ << " " << min_PtBalance_ << " " << max_PtBalance_ << " " << nsigma_Pt_ << " " << max_DCAMuMu_ << " " << max_YPair_; } HLTMuonDimuonL3Filter::~HLTMuonDimuonL3Filter() = default; void HLTMuonDimuonL3Filter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; makeHLTFilterDescription(desc); desc.add<edm::InputTag>("BeamSpotTag", edm::InputTag("hltOfflineBeamSpot")); desc.add<edm::InputTag>("CandTag", edm::InputTag("hltL3MuonCandidates")); // desc.add<edm::InputTag>("PreviousCandTag",edm::InputTag("hltDiMuonL2PreFiltered0")); desc.add<edm::InputTag>("PreviousCandTag", edm::InputTag("")); desc.add<edm::InputTag>("L1CandTag", edm::InputTag("")); desc.add<edm::InputTag>("inputMuonCollection", edm::InputTag("")); desc.add<bool>("PreviousCandIsL2", true); desc.add<bool>("FastAccept", false); desc.add<int>("MinN", 1); desc.add<double>("MaxEta", 2.5); desc.add<int>("MinNhits", 0); desc.add<double>("MaxDr", 2.0); desc.add<double>("MaxDz", 9999.0); desc.add<int>("ChargeOpt", 0); vector<double> v1; v1.push_back(0.0); vector<double> v2; v2.push_back(1e125); vector<double> v3; v3.push_back(3.0); vector<double> v4; v4.push_back(3.0); vector<double> v5; v5.push_back(1e125); vector<double> v6; v6.push_back(2.8); vector<double> v7; v7.push_back(3.4); desc.add<vector<double> >("MinPtPair", v1); desc.add<vector<double> >("MaxPtPair", v2); desc.add<vector<double> >("MinPtMax", v3); desc.add<vector<double> >("MinPtMin", v4); desc.add<vector<double> >("MaxPtMin", v5); desc.add<vector<double> >("MinInvMass", v6); desc.add<vector<double> >("MaxInvMass", v7); desc.add<double>("MinAcop", -1.0); desc.add<double>("MaxAcop", 3.15); desc.add<double>("MinPtBalance", -1.0); desc.add<double>("MaxPtBalance", 999999.0); desc.add<double>("NSigmaPt", 0.0); desc.add<double>("MaxDCAMuMu", 99999.9); desc.add<double>("MaxRapidityPair", 999999.0); desc.add<bool>("CutCowboys", false); desc.add<edm::InputTag>("InputLinks", edm::InputTag("")); desc.add<double>("L1MatchingdR", 0.3); desc.add<bool>("MatchToPreviousCand", true); descriptions.add("hltMuonDimuonL3Filter", desc); } // // member functions // // ------------ method called to produce the data ------------ bool HLTMuonDimuonL3Filter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs& filterproduct) const { if (min_InvMass_.size() != min_PtPair_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } if (min_InvMass_.size() != max_PtPair_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } if (min_InvMass_.size() != min_PtMax_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } if (min_InvMass_.size() != min_PtMin_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } if (min_InvMass_.size() != max_PtMin_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } if (min_InvMass_.size() != max_InvMass_.size()) { cout << "ERROR!!! Vector sizes don't match!" << endl; return false; } // All HLT filters must create and fill an HLT filter object, // recording any reconstructed physics objects satisfying (or not) // this HLT filter, and place it in the Event. // Read RecoChargedCandidates from L3MuonCandidateProducer: Handle<RecoChargedCandidateCollection> mucands; if (saveTags()) filterproduct.addCollectionTag(candTag_); //? iEvent.getByToken(candToken_, mucands); // Read L2 triggered objects: Handle<TriggerFilterObjectWithRefs> previousLevelCands; iEvent.getByToken(previousCandToken_, previousLevelCands); vector<RecoChargedCandidateRef> vl2cands; previousLevelCands->getObjects(TriggerMuon, vl2cands); // Read BeamSpot information: Handle<BeamSpot> recoBeamSpotHandle; iEvent.getByToken(beamspotToken_, recoBeamSpotHandle); const BeamSpot& beamSpot = *recoBeamSpotHandle; // sort them by L2Track std::map<reco::TrackRef, std::vector<RecoChargedCandidateRef> > L2toL3s; // map the L3 cands matched to a L1 to their position in the recoMuon collection std::map<unsigned int, RecoChargedCandidateRef> MuonToL3s; // Test to see if we can use L3MuonTrajectorySeeds: if (mucands->empty()) return false; auto const& tk = (*mucands)[0].track(); bool useL3MTS = false; if (tk->seedRef().isNonnull()) { auto a = dynamic_cast<const L3MuonTrajectorySeed*>(tk->seedRef().get()); useL3MTS = a != nullptr; } // If we can use L3MuonTrajectory seeds run the older code: if (useL3MTS) { unsigned int maxI = mucands->size(); for (unsigned int i = 0; i != maxI; i++) { const TrackRef& tk = (*mucands)[i].track(); if (previousCandIsL2_) { edm::Ref<L3MuonTrajectorySeedCollection> l3seedRef = tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >(); TrackRef staTrack = l3seedRef->l2Track(); L2toL3s[staTrack].push_back(RecoChargedCandidateRef(mucands, i)); } else { L2toL3s[tk].push_back(RecoChargedCandidateRef(mucands, i)); } } } // Using normal TrajectorySeeds: else { // Read Links collection: edm::Handle<reco::MuonTrackLinksCollection> links; iEvent.getByToken(linkToken_, links); edm::Handle<trigger::TriggerFilterObjectWithRefs> level1Cands; std::vector<l1t::MuonRef> vl1cands; bool check_l1match = true; // Loop over RecoChargedCandidates: for (unsigned int i(0); i < mucands->size(); ++i) { RecoChargedCandidateRef cand(mucands, i); TrackRef tk = cand->track(); // is inner track if (!matchPreviousCand_) { MuonToL3s[i] = RecoChargedCandidateRef(cand); } else { check_l1match = true; for (auto const& link : *links) { // Using the same method that was used to create the links between L3 and L2 // ToDo: there should be a better way than dR,dPt matching const reco::Track& trackerTrack = *link.trackerTrack(); if (tk->pt() == 0 or trackerTrack.pt() == 0) continue; float dR2 = deltaR2(tk->eta(), tk->phi(), trackerTrack.eta(), trackerTrack.phi()); float dPt = std::abs(tk->pt() - trackerTrack.pt()) / tk->pt(); if (dR2 < 0.02 * 0.02 and dPt < 0.001) { const TrackRef staTrack = link.standAloneTrack(); L2toL3s[staTrack].push_back(RecoChargedCandidateRef(cand)); check_l1match = false; } } //MTL loop if (not l1CandTag_.label().empty() and check_l1match) { iEvent.getByToken(l1CandToken_, level1Cands); level1Cands->getObjects(trigger::TriggerL1Mu, vl1cands); const unsigned int nL1Muons(vl1cands.size()); for (unsigned int il1 = 0; il1 != nL1Muons; ++il1) { if (deltaR(cand->eta(), cand->phi(), vl1cands[il1]->eta(), vl1cands[il1]->phi()) < L1MatchingdR_) { //was muon, non cand MuonToL3s[i] = RecoChargedCandidateRef(cand); } } } } } //RCC loop } //end of using normal TrajectorySeeds // Needed for DCA calculation ESHandle<MagneticField> bFieldHandle; iSetup.get<IdealMagneticFieldRecord>().get(bFieldHandle); // look at all mucands, check cuts and add to filter object int n = 0; // look at all mucands, check cuts and add to filter object auto L2toL3s_it1 = L2toL3s.begin(); auto L2toL3s_end = L2toL3s.end(); bool atLeastOnePair = false; for (; L2toL3s_it1 != L2toL3s_end; ++L2toL3s_it1) { if (!triggeredByLevel2(L2toL3s_it1->first, vl2cands)) continue; //loop over the L3Tk reconstructed for this L2. unsigned int iTk1 = 0; unsigned int maxItk1 = L2toL3s_it1->second.size(); for (; iTk1 != maxItk1; iTk1++) { bool thisL3Index1isDone = false; RecoChargedCandidateRef& cand1 = L2toL3s_it1->second[iTk1]; TrackRef tk1 = cand1->get<TrackRef>(); LogDebug("HLTMuonDimuonL3Filter") << " 1st muon in loop: q*pt= " << tk1->charge() * tk1->pt() << " (" << cand1->charge() * cand1->pt() << ") " << ", eta= " << tk1->eta() << " (" << cand1->eta() << ") " << ", hits= " << tk1->numberOfValidHits(); // Run muon selection on first muon: if (!applyMuonSelection(cand1, beamSpot)) continue; // Pt threshold cut // Don't convert to 90% efficiency threshold LogDebug("HLTMuonDimuonL3Filter") << " ... 1st muon in loop, pt1= " << cand1->pt(); // Loop on 2nd muon cand auto L2toL3s_it2 = L2toL3s_it1; L2toL3s_it2++; for (; L2toL3s_it2 != L2toL3s_end; ++L2toL3s_it2) { if (!triggeredByLevel2(L2toL3s_it2->first, vl2cands)) continue; //loop over the L3Tk reconstructed for this L2. unsigned int iTk2 = 0; unsigned int maxItk2 = L2toL3s_it2->second.size(); for (; iTk2 != maxItk2; iTk2++) { RecoChargedCandidateRef& cand2 = L2toL3s_it2->second[iTk2]; TrackRef tk2 = cand2->get<TrackRef>(); LogDebug("HLTMuonDimuonL3Filter") << " 2nd muon in loop: q*pt= " << tk2->charge() * tk2->pt() << " (" << cand2->charge() * cand2->pt() << ") " << ", eta= " << tk2->eta() << " (" << cand2->eta() << ") " << ", hits= " << tk2->numberOfValidHits() << ", d0= " << tk2->d0(); // Run muon selection on second muon: if (!applyMuonSelection(cand2, beamSpot)) continue; // Pt threshold cut // Don't convert to 90% efficiency threshold LogDebug("HLTMuonDimuonL3Filter") << " ... 2nd muon in loop, pt2= " << cand2->pt(); // Run dimuon selection: if (!applyDiMuonSelection(cand1, cand2, beamSpot, bFieldHandle)) continue; // Add this pair n++; LogDebug("HLTMuonDimuonL3Filter") << " Track1 passing filter: pt= " << cand1->pt() << ", eta: " << cand1->eta(); LogDebug("HLTMuonDimuonL3Filter") << " Track2 passing filter: pt= " << cand2->pt() << ", eta: " << cand2->eta(); bool i1done = false; bool i2done = false; vector<RecoChargedCandidateRef> vref; filterproduct.getObjects(TriggerMuon, vref); for (auto& i : vref) { RecoChargedCandidateRef candref = RecoChargedCandidateRef(i); TrackRef tktmp = candref->get<TrackRef>(); if (tktmp == tk1) i1done = true; else if (tktmp == tk2) i2done = true; //why is this an elif? if (i1done && i2done) break; } if (!i1done) filterproduct.addObject(TriggerMuon, cand1); if (!i2done) filterproduct.addObject(TriggerMuon, cand2); //break anyway since a L3 track pair has been found matching the criteria thisL3Index1isDone = true; atLeastOnePair = true; break; } //loop on the track of the second L2 //break the loop if fast accept. if (atLeastOnePair && fast_Accept_) break; } //loop on the second L2 //break the loop if fast accept. if (atLeastOnePair && fast_Accept_) break; if (thisL3Index1isDone) break; //Loop over L3FromL1 collection see if we get a pair that way auto MuonToL3s_it1 = MuonToL3s.begin(); auto MuonToL3s_end = MuonToL3s.end(); for (; MuonToL3s_it1 != MuonToL3s_end; ++MuonToL3s_it1) { const RecoChargedCandidateRef& cand2 = MuonToL3s_it1->second; if (!applyMuonSelection(cand2, beamSpot)) continue; TrackRef tk2 = cand2->get<TrackRef>(); // Run dimuon selection: if (!applyDiMuonSelection(cand1, cand2, beamSpot, bFieldHandle)) continue; n++; LogDebug("HLTMuonDimuonL3Filter") << " L3FromL2 Track1 passing filter: pt= " << cand1->pt() << ", eta: " << cand1->eta(); LogDebug("HLTMuonDimuonL3Filter") << " L3FromL1 Track2 passing filter: pt= " << cand2->pt() << ", eta: " << cand2->eta(); bool i1done = false; bool i2done = false; vector<RecoChargedCandidateRef> vref; filterproduct.getObjects(TriggerMuon, vref); for (auto& i : vref) { RecoChargedCandidateRef candref = RecoChargedCandidateRef(i); TrackRef tktmp = candref->get<TrackRef>(); if (tktmp == tk1) i1done = true; else if (tktmp == tk2) i2done = true; //why is this an elif? if (i1done && i2done) break; } if (!i1done) filterproduct.addObject(TriggerMuon, cand1); if (!i2done) filterproduct.addObject(TriggerMuon, cand2); //break anyway since a L3 track pair has been found matching the criteria thisL3Index1isDone = true; atLeastOnePair = true; break; } //L3FromL1 loop //break the loop if fast accept. if (atLeastOnePair && fast_Accept_) break; if (thisL3Index1isDone) break; } //loop on tracks for first L2 //break the loop if fast accept. if (atLeastOnePair && fast_Accept_) break; } //loop on the first L2 // now loop on 1st L3 from L1 auto MuonToL3s_it1 = MuonToL3s.begin(); auto MuonToL3s_end = MuonToL3s.end(); for (; MuonToL3s_it1 != MuonToL3s_end; ++MuonToL3s_it1) { bool thisL3Index1isDone = false; const RecoChargedCandidateRef& cand1 = MuonToL3s_it1->second; if (!applyMuonSelection(cand1, beamSpot)) continue; TrackRef tk1 = cand1->get<TrackRef>(); // Loop on 2nd L3 from L1 auto MuonToL3s_it2 = MuonToL3s_it1; for (; MuonToL3s_it2 != MuonToL3s_end; ++MuonToL3s_it2) { const RecoChargedCandidateRef& cand2 = MuonToL3s_it2->second; if (!applyMuonSelection(cand2, beamSpot)) continue; TrackRef tk2 = cand2->get<TrackRef>(); // Run dimuon selection: if (!applyDiMuonSelection(cand1, cand2, beamSpot, bFieldHandle)) continue; n++; LogDebug("HLTMuonDimuonL3Filter") << " L3FromL1 Track1 passing filter: pt= " << cand1->pt() << ", eta: " << cand1->eta(); LogDebug("HLTMuonDimuonL3Filter") << " L3FromL1 Track2 passing filter: pt= " << cand2->pt() << ", eta: " << cand2->eta(); bool i1done = false; bool i2done = false; vector<RecoChargedCandidateRef> vref; filterproduct.getObjects(TriggerMuon, vref); for (auto& i : vref) { RecoChargedCandidateRef candref = RecoChargedCandidateRef(i); TrackRef tktmp = candref->get<TrackRef>(); if (tktmp == tk1) i1done = true; else if (tktmp == tk2) i2done = true; //why is this an elif? if (i1done && i2done) break; } if (!i1done) filterproduct.addObject(TriggerMuon, cand1); if (!i2done) filterproduct.addObject(TriggerMuon, cand2); //break anyway since a L3 track pair has been found matching the criteria thisL3Index1isDone = true; atLeastOnePair = true; break; } //loop on 2nd muon //break the loop if fast accept if (atLeastOnePair && fast_Accept_) break; if (thisL3Index1isDone) break; } //loop on 1st muon // filter decision const bool accept(n >= min_N_); LogDebug("HLTMuonDimuonL3Filter") << " >>>>> Result of HLTMuonDimuonL3Filter is " << accept << ", number of muon pairs passing thresholds= " << n; return accept; } bool HLTMuonDimuonL3Filter::triggeredByLevel2(TrackRef const& staTrack, vector<RecoChargedCandidateRef> const& vcands) { bool ok = false; for (auto const& vcand : vcands) { if (vcand->get<TrackRef>() == staTrack) { ok = true; LogDebug("HLTMuonL3PreFilter") << "The L2 track triggered"; break; } } return ok; } bool HLTMuonDimuonL3Filter::applyMuonSelection(const RecoChargedCandidateRef& cand, const BeamSpot& beamSpot) const { // eta cut if (std::abs(cand->eta()) > max_Eta_) return false; // cut on number of hits TrackRef tk = cand->track(); if (tk->numberOfValidHits() < min_Nhits_) return false; //dr cut if (std::abs((-(cand->vx() - beamSpot.x0()) * cand->py() + (cand->vy() - beamSpot.y0()) * cand->px()) / cand->pt()) > max_Dr_) return false; //dz cut if (std::abs((cand->vz() - beamSpot.z0()) - ((cand->vx() - beamSpot.x0()) * cand->px() + (cand->vy() - beamSpot.y0()) * cand->py()) / cand->pt() * cand->pz() / cand->pt()) > max_Dz_) return false; return true; } bool HLTMuonDimuonL3Filter::applyDiMuonSelection(const RecoChargedCandidateRef& cand1, const RecoChargedCandidateRef& cand2, const BeamSpot& beamSpot, const ESHandle<MagneticField>& bFieldHandle) const { // Opposite Charge if (chargeOpt_ < 0 and (cand1->charge() * cand2->charge() > 0)) return false; else if (chargeOpt_ > 0 and (cand1->charge() * cand2->charge() < 0)) return false; // Acoplanarity double acop = std::abs(cand1->phi() - cand2->phi()); if (acop > M_PI) acop = 2 * M_PI - acop; acop = M_PI - acop; LogDebug("HLTMuonDimuonL3Filter") << " ... 1-2 acop= " << acop; if (acop < min_Acop_) return false; if (acop > max_Acop_) return false; // Pt balance double ptbalance = std::abs(cand1->pt() - cand2->pt()); if (ptbalance < min_PtBalance_) return false; if (ptbalance > max_PtBalance_) return false; // Combined dimuon syste double e1, e2; Particle::LorentzVector p, p1, p2; e1 = sqrt(cand1->momentum().Mag2() + MuMass2_); e2 = sqrt(cand2->momentum().Mag2() + MuMass2_); p1 = Particle::LorentzVector(cand1->px(), cand1->py(), cand1->pz(), e1); p2 = Particle::LorentzVector(cand2->px(), cand2->py(), cand2->pz(), e2); p = p1 + p2; double pt12 = p.pt(); LogDebug("HLTMuonDimuonL3Filter") << " ... 1-2 pt12= " << pt12; double ptLx1 = cand1->pt(); double ptLx2 = cand2->pt(); double invmass = abs(p.mass()); // if (invmass>0) invmass = sqrt(invmass); else invmass = 0; LogDebug("HLTMuonDimuonL3Filter") << " ... 1-2 invmass= " << invmass; bool proceed = false; for (unsigned int iv = 0; iv < min_InvMass_.size(); iv++) { if (invmass < min_InvMass_[iv]) return false; if (invmass > max_InvMass_[iv]) return false; if (ptLx1 > ptLx2) { if (ptLx1 < min_PtMax_[iv]) return false; if (ptLx2 < min_PtMin_[iv]) return false; if (ptLx2 > max_PtMin_[iv]) return false; } else { if (ptLx2 < min_PtMax_[iv]) return false; if (ptLx1 < min_PtMin_[iv]) return false; if (ptLx1 > max_PtMin_[iv]) return false; } if (pt12 < min_PtPair_[iv]) return false; if (pt12 > max_PtPair_[iv]) return false; proceed = true; break; } if (!proceed) return false; // Delta Z between the two muons //double DeltaZMuMu = std::abs(tk2->dz(beamSpot.position())-tk1->dz(beamSpot.position())); //if ( DeltaZMuMu > max_DzMuMu_) return false; // DCA between the two muons TrackRef tk1 = cand1->track(); TrackRef tk2 = cand2->track(); TransientTrack mu1TT(*tk1, &(*bFieldHandle)); TransientTrack mu2TT(*tk2, &(*bFieldHandle)); TrajectoryStateClosestToPoint mu1TS = mu1TT.impactPointTSCP(); TrajectoryStateClosestToPoint mu2TS = mu2TT.impactPointTSCP(); if (mu1TS.isValid() && mu2TS.isValid()) { ClosestApproachInRPhi cApp; cApp.calculate(mu1TS.theState(), mu2TS.theState()); if (!cApp.status() || cApp.distance() > max_DCAMuMu_) return false; } // Max dimuon |rapidity| double rapidity = std::abs(p.Rapidity()); if (rapidity > max_YPair_) return false; // if cutting on cowboys reject muons that bend towards each other if (cutCowboys_ && (cand1->charge() * deltaPhi(cand1->phi(), cand2->phi()) > 0.)) return false; return true; } // declare this class as a framework plugin #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(HLTMuonDimuonL3Filter);
; A111069: Numbers k such that 3*k^2 + 25 is prime. ; Submitted by Jon Maiga ; 2,4,12,14,18,24,26,28,38,46,56,66,74,84,96,98,102,112,124,126,128,144,152,164,168,182,186,212,214,236,238,252,254,262,266,268,278,284,304,306,312,324,332,334,338,352,362,378,388,392,396,404,416,418,438,448,476,494,506,508,514,518,528,532,542,548,558,572,574,586,592,598,604,606,616,618,632,642,644,648,654,672,676,688,698,702,704,714,756,782,784,788,794,802,808,826,828,836,844,852 mov $1,-4 mov $2,332202 mov $5,24 lpb $2 mov $3,$6 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,16 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,18 add $5,$1 add $1,8 mov $6,$5 lpe mov $0,$1 div $0,12 add $0,1
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %rcx push %rdi push %rdx push %rsi // Load lea addresses_WT+0x10311, %rdx clflush (%rdx) nop xor $23543, %rsi movb (%rdx), %r10b nop nop and %rsi, %rsi // Store mov $0xb11, %r10 nop nop nop nop nop dec %r11 mov $0x5152535455565758, %rcx movq %rcx, %xmm5 vmovups %ymm5, (%r10) nop nop nop nop nop and $2285, %rsi // Store lea addresses_D+0xa161, %r13 nop nop nop and %rsi, %rsi movb $0x51, (%r13) // Exception!!! nop nop nop mov (0), %rcx nop sub $40090, %r10 // Faulty Load lea addresses_PSE+0xa751, %rcx clflush (%rcx) nop and %rsi, %rsi movb (%rcx), %dl lea oracles, %r11 and $0xff, %rdx shlq $12, %rdx mov (%r11,%rdx,1), %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
HazeEffect_: ld a, $7 ; store 7 on every stat mod ld hl, wPlayerMonAttackMod call ResetStatMods ld hl, wEnemyMonAttackMod call ResetStatMods ; copy unmodified stats to battle stats ld hl, wPlayerMonUnmodifiedAttack ld de, wBattleMonAttack call ResetStats ld hl, wEnemyMonUnmodifiedAttack ld de, wEnemyMonAttack call ResetStats ; cure non-volatile status, but only for the target ld hl, wEnemyMonStatus ld de, wEnemySelectedMove ldh a, [hWhoseTurn] and a jr z, .cureStatuses ld hl, wBattleMonStatus dec de ; wPlayerSelectedMove .cureStatuses ld a, [hl] ld [hl], $0 and SLP | (1 << FRZ) jr z, .cureVolatileStatuses ; prevent the Pokemon from executing a move if it was asleep or frozen ld a, $ff ld [de], a .cureVolatileStatuses xor a ld [wPlayerDisabledMove], a ld [wEnemyDisabledMove], a ld hl, wPlayerDisabledMoveNumber ld [hli], a ld [hl], a ld hl, wPlayerBattleStatus1 call CureVolatileStatuses ld hl, wEnemyBattleStatus1 call CureVolatileStatuses ld hl, PlayCurrentMoveAnimation call CallBankF ld hl, StatusChangesEliminatedText jp PrintText CureVolatileStatuses: res CONFUSED, [hl] inc hl ; BATTSTATUS2 ld a, [hl] ; clear USING_X_ACCURACY, PROTECTED_BY_MIST, GETTING_PUMPED, and SEEDED statuses and $ff ^((1 << USING_X_ACCURACY) | (1 << PROTECTED_BY_MIST) | (1 << GETTING_PUMPED) | (1 << NEEDS_TO_RECHARGE) | (1 << SEEDED)) ld [hli], a ; BATTSTATUS3 ld a, [hl] and %11110000 | (1 << TRANSFORMED) ; clear Bad Poison, Reflect and Light Screen statuses ld [hl], a ret ResetStatMods: ld b, $8 .loop ld [hli], a dec b jr nz, .loop ret ResetStats: ld b, $8 .loop ld a, [hli] ld [de], a inc de dec b jr nz, .loop ret StatusChangesEliminatedText: text_far _StatusChangesEliminatedText text_end
; A297663: a(n) = 5*n + 2^n. ; 1,7,14,23,36,57,94,163,296,557,1074,2103,4156,8257,16454,32843,65616,131157,262234,524383,1048676,2097257,4194414,8388723,16777336,33554557,67108994,134217863,268435596,536871057,1073741974,2147483803,4294967456,8589934757,17179869354,34359738543,68719476916,137438953657,274877907134,549755814083,1099511627976,2199023255757,4398046511314,8796093022423,17592186044636,35184372089057,70368744177894,140737488355563,281474976710896,562949953421557,1125899906842874,2251799813685503,4503599627370756,9007199254741257,18014398509482254,36028797018964243,72057594037928216,144115188075856157,288230376151712034,576460752303423783,1152921504606847276,2305843009213694257,4611686018427388214,9223372036854776123,18446744073709551936,36893488147419103557,73786976294838206794,147573952589676413263,295147905179352826196,590295810358705652057,1180591620717411303774,2361183241434822607203,4722366482869645214056,9444732965739290427757,18889465931478580855154,37778931862957161709943,75557863725914323419516,151115727451828646838657,302231454903657293676934,604462909807314587353483,1208925819614629174706576,2417851639229258349412757,4835703278458516698825114,9671406556917033397649823,19342813113834066795299236,38685626227668133590598057,77371252455336267181195694,154742504910672534362390963,309485009821345068724781496,618970019642690137449562557,1237940039285380274899124674,2475880078570760549798248903,4951760157141521099596497356,9903520314283042199192994257,19807040628566084398385988054,39614081257132168796771975643,79228162514264337593543950816,158456325028528675187087901157,316912650057057350374175801834,633825300114114700748351603183 mov $1,2 pow $1,$0 mov $2,$0 mul $2,5 add $1,$2 mov $0,$1
; A307539: Heinz numbers of square integer partitions, where the Heinz number of an integer partition (y_1,...,y_k) is prime(y_1)*...*prime(y_k). ; 1,2,9,125,2401,161051,4826809,410338673,16983563041,1801152661463,420707233300201,25408476896404831,6582952005840035281,925103102315013629321,73885357344138503765449,12063348350820368238715343,3876269050118516845397872321,1271991467017507741703714391419,136753052840548005895349735207881,49593099428404263766544428188098203,10596610576391421032662867140133202401,1348279907365869037210940254745047725673,559494740587480879172162808385362976196641,137656310293626928473255626953462008797108987 mov $2,$0 trn $0,1 seq $0,6005 ; The odd prime numbers together with 1. max $0,2 pow $0,$2
MACRO_CLEAR_PLAYER MACRO X,Y mov pre_position_x,x mov pre_position_y,y call Update_Players ENDM ; MACRO_CLEAR_Barrier MACRO X,Y ; mov pre_position_x,x ; mov pre_position_y,y ; call Update_Players ; ENDM PRINT_Messages MACRO MSG PUSH AX push DX mov ah, 9 mov dx, offset MSG int 21h pop DX POP AX ENDM ;;;;Macro to send a 8 bit word using uart SendChar MACRO MyChar LOCAL Send Send: push ax mov dx, 3fdh in al, dx test al, 00100000b jz Send mov dx, 3f8h ;sending value mov al, MyChar out dx, al pop ax ENDM ;;;;Macro to recieve a 8 bit word using uart ReceiveChar MACRO LOCAL Return RETURN: MOV AL, 0 mov dx , 3FDH ; Line Status Register in al , dx test al , 1 JZ RETURN mov dx , 03F8H in al , dx ENDM ;;;;Macro to recieve a 8 bit word using uart ReceiveCharNotAmustToRecieve MACRO LOCAL Return MOV AL, 0 mov dx , 3FDH ; Line Status Register in al , dx test al , 1 JZ RETURN mov dx , 03F8H in al , dx RETURN: ENDM .model HUGE .stack 64h .data WINDOW_WIDTH equ 320 ;the width of the Game window (320 pixels) WINDOW_HEIGHT equ 160 ;the height of the Game window (200*4/5 pixels)---> the chat takes 1/5 of the console WINDOW_BOUNDS equ 6 ; used to check collisions early from the lower,left,right pounds window_bounds_upper equ 15 ;height of the health bar health_bar_width equ 100 ;width of each player's health bar heart_height equ 10 ;height of the heart image in health bar heart_width equ 15 ;height of the heart image in health bar TIME_AUX DB 0 ;variable used when checking if the time has changed background_color EQU 53 ;Background pixel color id graphics_mode EQU 13h ;320*200 pixels , 256colors PRE_POSITION_X DW 0 ;Temp variable used when moving position to check first if it causes collisions PRE_POSITION_Y DW 0 ;Temp variable used when moving position to check first if it causes collisions PRE_POSITION_X2 DW 0 ;Temp variable used when moving position to check first if it causes collisions PRE_POSITION_Y2 DW 0 ;Temp variable used when moving position to check first if it causes collisions First_Player_Name DB 15,?,15 dup('$') first_player_X DW 50 ;The starting X-position of player one first_player_Y DW 50 ;The starting Y-position of player one first_player_health DW 5 ;Number of hearts to the first player first_player_health_X equ 0 ;the starting upper left x coordinate of the first player's first heart first_player_health_Y equ 0 ;the starting upper left y coordinate of the first player's first heart first_player_health_immunity DW 0 ;when the player gets hit by barrier, he gains an immunity to resist the barriers first_player_Freeze DW 0 ;Duration for which the player is frozen First_Is_Collided DB 0 ;Boolean Variable To check if the player is colliding Second_Player_Name DB 15,?,15 dup('$') second_player_X DW 270 ;The starting X-position of player two SECOND_PLAYER_Y DW 50 ;The starting Y-position of player two second_player_health DW 5 ;Number of hearts to the second player second_player_health_X equ 305 ;the starting upper left x coordinate of the second player's first heart second_player_health_Y equ 0 ;the starting upper left y coordinate of the second player's first heart second_player_health_immunity DW 0 ;when the player gets hit by barrier, he gains an immunity to resist the barriers second_player_Freeze DW 0 ;Duration for which the player is frozen PLAYERS_WIDTH equ 20 ;the width of player's image PLAYERS_HEIGHT equ 25 ;the height of player's image PLAYERS_VELOCITY DW 04h Second_Is_Collided DB 0 ;Boolean Variable To check if the player is colliding Initial_Freeze EQU 20 ;The freezing time of player after being attacked Initial_Imunity EQU 20 ;This is the immunity to the player fter being hit ;VARIABLES USED IN THE PROCS OF DRAWING THE BARRIER LEN DW 100d ;used by the draw barrier proc WID DW 100d ;used by the draw barrier proc LENMAX DW 252d ;used by the draw barrier proc WIDMAX DW 152d ;used by the draw barrier proc Initial_Y_Barrier1 EQU 140 Initial_Y_Barrier2 EQU 140 X_BARRIER1 DW 10 ; xpos of barrier1 Y_BARRIER1 DW 140 ; ypos of barrier1 X_BARRIER2 DW 260 ; xpos of barrier2 Y_BARRIER2 DW 104 ; ypos of barrier2 ;Laser Colors RED EQU 39 Yellow EQU 14 Dark_Blue EQU 105 Light_Blue EQU 76 ;Laser Target (The ARC Reactor of the suit) Player_Reactor_Y_Offset EQU 16 Player_Reactor_Y_Size EQU 4 LASER_SIZE EQU 3 ;Laser Launcher (Laser Shooters) Player_Shooter_Y_Offset EQU 19 ;Lasers Coordinates Blue_Laser_Start_X DW ? Blue_Laser_End_X DW ? Red_Laser_Start_X DW ? Red_Laser_End_X DW ? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;#DEFINES FOR THE LENGTH AND SIZE OF THE BARRIER BARRIER_HORIZONTAL_SIZE EQU 60D BARRIER_VERTICAL_SIZE EQU 10D ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;SCREEN SIZE IN PIXELS SCREEN_MAX_X EQU 319D SCREEN_MAX_Y EQU 199D ;next is the first player's pixel colors/Note: they are indexed in reversed order (from the (20,25) to (0,0)) p1 DB 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 16, 39, 39, 39, 16, 0, 0, 0, 0, 16, 39, 39, 39, 16, 0, 0, 0 DB 0, 0, 0, 16, 16, 39, 39, 16, 0, 0, 0, 0, 16, 39, 39, 16, 16, 0, 0, 0, 0, 0, 0, 0, 16, 39, 14, 14, 16, 16, 16, 16, 14, 14, 39, 16, 0, 0, 0, 0 DB 0, 0, 0, 31, 16, 14, 14, 39, 39, 39, 39, 39, 39, 14, 14, 16, 31, 0, 0, 0, 0, 0, 16, 16, 0, 16, 39, 39, 39, 39, 39, 39, 39, 39, 16, 0, 16, 16, 0, 0 DB 0, 16, 39, 39, 16, 16, 39, 39, 39, 16, 16, 39, 39, 39, 16, 16, 39, 39, 16, 0, 0, 16, 39, 39, 14, 16, 39, 39, 16, 25, 25, 16, 39, 39, 16, 14, 39, 39, 16, 0 DB 0, 0, 16, 14, 14, 16, 39, 16, 25, 25, 25, 25, 16, 39, 16, 14, 14, 16, 0, 0, 0, 0, 41, 16, 39, 16, 39, 16, 16, 16, 16, 16, 16, 39, 16, 39, 16, 41, 0, 0 DB 0, 0, 41, 0, 16, 39, 16, 14, 14, 14, 14, 14, 14, 16, 39, 16, 0, 41, 0, 0, 0, 41, 41, 0, 0, 16, 14, 16, 16, 16, 16, 16, 16, 14, 16, 0, 0, 41, 41, 0 DB 0, 41, 0, 0, 16, 39, 14, 14, 14, 14, 14, 14, 14, 14, 39, 16, 0, 0, 41, 0, 0, 41, 0, 16, 39, 39, 14, 14, 14, 14, 14, 14, 14, 14, 39, 39, 16, 0, 41, 0 DB 41, 41, 16, 39, 14, 25, 25, 25, 16, 16, 16, 16, 25, 25, 25, 14, 39, 16, 41, 41, 41, 0, 16, 39, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 39, 16, 0, 41 DB 41, 0, 16, 39, 16, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 39, 16, 0, 41, 41, 0, 0, 16, 39, 14, 14, 14, 39, 39, 39, 39, 14, 14, 14, 39, 16, 0, 0, 41 DB 41, 0, 0, 16, 39, 14, 14, 39, 39, 39, 39, 39, 39, 14, 14, 39, 16, 0, 0, 41, 41, 0, 0, 0, 16, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 16, 0, 0, 0, 41 DB 41, 41, 41, 41, 41, 16, 16, 16, 39, 39, 39, 39, 16, 16, 16, 41, 41, 41, 41, 41, 41, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, 41 DB 41, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 41, 41, 41, 41, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 41, 41, 41 DB 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41 ;next is the first player's heart pixel colors/Note: they are indexed in reversed order' h1 DB 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 39, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 39, 39, 39, 16 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 39, 39, 39, 39, 39, 16, 0, 0, 0, 0, 0, 0, 0, 16, 39, 39, 39, 39, 39, 39, 39, 16, 0, 0, 0, 0, 0, 16, 39, 39 DB 39, 39, 39, 39, 39, 39, 39, 16, 0, 0, 0, 0, 16, 39, 39, 39, 39, 16, 39, 39, 39, 39, 16, 0, 0, 0, 0, 0, 16, 39, 39, 16, 0, 16, 39, 39, 16, 0, 0, 0 DB 0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;next is the Second player's pixel colors/Note: they are indexed in reversed order (from the (20,25) to (0,0)) p2 DB 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 16, 105, 105, 105, 16, 0, 0, 0, 0, 16, 105, 105, 105, 16, 0, 0, 0 DB 0, 0, 0, 16, 16, 105, 105, 16, 0, 0, 0, 0, 16, 105, 105, 16, 16, 0, 0, 0, 0, 0, 0, 0, 16, 105, 76, 76, 16, 16, 16, 16, 76, 76, 105, 16, 0, 0, 0, 0 DB 0, 0, 0, 31, 16, 76, 76, 105, 105, 105, 105, 105, 105, 76, 76, 16, 31, 0, 0, 0, 0, 0, 16, 16, 0, 16, 105, 105, 105, 105, 105, 105, 105, 105, 16, 0, 16, 16, 0, 0 DB 0, 16, 105, 105, 16, 16, 105, 105, 105, 16, 16, 105, 105, 105, 16, 16, 105, 105, 16, 0, 0, 16, 105, 105, 76, 16, 105, 105, 16, 25, 25, 16, 105, 105, 16, 76, 105, 105, 16, 0 DB 0, 0, 16, 76, 76, 16, 105, 16, 25, 25, 25, 25, 16, 105, 16, 76, 76, 16, 0, 0, 0, 0, 105, 16, 105, 16, 105, 16, 16, 16, 16, 16, 16, 105, 16, 105, 16, 105, 0, 0 DB 0, 0, 105, 0, 16, 105, 16, 76, 76, 76, 76, 76, 76, 16, 105, 16, 0, 105, 0, 0, 0, 105, 105, 0, 0, 16, 76, 16, 16, 16, 16, 16, 16, 76, 16, 0, 0, 105, 105, 0 DB 0, 105, 0, 0, 16, 105, 76, 76, 76, 76, 76, 76, 76, 76, 105, 16, 0, 0, 105, 0, 0, 105, 0, 16, 105, 105, 76, 76, 76, 76, 76, 76, 76, 76, 105, 105, 16, 0, 105, 0 DB 105, 105, 16, 105, 76, 25, 25, 25, 16, 16, 16, 16, 25, 25, 25, 76, 105, 16, 105, 105, 105, 0, 16, 105, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 105, 16, 0, 105 DB 105, 0, 16, 105, 16, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 16, 105, 16, 0, 105, 105, 0, 0, 16, 105, 76, 76, 76, 105, 105, 105, 105, 76, 76, 76, 105, 16, 0, 0, 105 DB 105, 0, 0, 16, 105, 76, 76, 105, 105, 105, 105, 105, 105, 76, 76, 105, 16, 0, 0, 105, 105, 0, 0, 0, 16, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 16, 0, 0, 0, 105 DB 105, 105, 105, 105, 105, 16, 16, 16, 105, 105, 105, 105, 16, 16, 16, 105, 105, 105, 105, 105, 105, 76, 76, 76, 76, 76, 76, 76, 16, 16, 16, 16, 76, 76, 76, 76, 76, 76, 76, 105 DB 105, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 105, 105, 105, 105, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 105, 105, 105 DB 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105 ;next is the second player's heart pixel colors/Note: they are indexed in reversed order' h2 DB 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 105, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 105, 105, 105, 16 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 105, 105, 105, 105, 105, 16, 0, 0, 0, 0, 0, 0, 0, 16, 105, 105, 105, 105, 105, 105, 105, 16, 0, 0, 0, 0, 0, 16, 105, 105 DB 105, 105, 105, 105, 105, 105, 105, 16, 0, 0, 0, 0, 16, 105, 105, 105, 105, 16, 105, 105, 105, 105, 16, 0, 0, 0, 0, 0, 16, 105, 105, 16, 0, 16, 105, 105, 16, 0, 0, 0 DB 0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Barrier_array DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 16, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186 DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 DB 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 16, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186 ;MAIN MENU GAME_MASTER DB 00H GAME_SLAVE DB 0 CHAT_MASTER DB 0 CHAT_SLAVE DB 0 LEVEL_CHOSEN DB 0 GAME_INVITATION_SEND_MSG DB 'YOU SENT A GAME INVITATION TO $' GAME_INVITATION_REC_MSG DB ' sent A GAME INVITATION TO YOU $' CHAT_INVITATION_SEND_MEG DB 'YOU SENT A CHAT INVITATION TO $' CHAT_INVITATION_REC_MEG DB ' sent A CHAT INVITATION TO YOU $' play_against_meg DB ' ', 0ah,0dh DB ' ============================================',0ah,0dh DB ' || ||',0ah,0dh DB ' || * YOU PLAY AGAINST ||',0ah,0dh DB ' || ||',0ah,0dh DB ' ============================================',0ah,0dh DB '$',0ah,0dh WAITING_MESSAGE DB 'PLEASE WAIT FOR OTHER PLAYER RESPONSE $' CHAT DB '*To Start Chatting Press F1 $' Sky_GAME DB '*To Start Sky Fall Game Press F2 $' END_GAME_mess DB '*To End the Program Press ESC $' levelone DB '*please press 1 for level 1 $' leveltwo DB '*please press 2 for level 2 $' Name_Message_1 DB '*Enter the first player name,Press Enter to porceed $' Name_Message_2 DB '*Enter the second player name, Press Enter to porceed $' Invalid_Start_msg2 db "* Invalid Player Name ! $" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Game over screen;;;;;;;;;;;;;;;;;;;;;;;;;;; imgW equ 200 imgH equ 26 img DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 112, 112, 112, 112, 112, 112, 112, 112, 184, 184, 16, 16, 16, 16, 184, 183, 112, 112, 112, 112, 112, 184, 16, 184, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112 DB 112, 112, 112, 112, 183, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 183, 184, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 183, 183, 112, 112, 112, 184 DB 184, 184, 112, 112, 112, 112, 112, 112, 112, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 112, 112, 112, 112, 112, 112, 112, 112, 184, 112, 112, 112 DB 184, 184, 112, 112, 112, 112, 112, 112, 16, 16, 184, 112, 112, 112, 112, 112, 184, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 112, 184, 184, 112, 112, 16, 16, 184, 112, 112, 112, 112, 112 DB 183, 16, 16, 16, 16, 16, 16, 16, 16, 184, 184, 112, 112, 112, 112, 184, 16, 16, 184, 112, 112, 112, 184, 112, 184, 184, 112, 112, 112, 112, 112, 112, 184, 184, 16, 16, 16, 16, 16, 16 DB 113, 113, 111, 111, 111, 111, 111, 111, 136, 184, 16, 16, 16, 16, 184, 207, 136, 111, 111, 111, 111, 183, 185, 209, 111, 111, 111, 111, 111, 111, 111, 111, 113, 113, 111, 111, 113, 113, 113, 113 DB 111, 111, 111, 111, 208, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 183, 207, 113, 113, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 208, 136, 113, 113, 111, 111 DB 113, 111, 113, 113, 113, 111, 113, 113, 111, 208, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 208, 111, 111, 111, 111, 113, 111, 111, 111, 111, 111, 111, 111, 111 DB 111, 136, 111, 111, 111, 111, 111, 111, 16, 16, 111, 111, 111, 111, 111, 111, 183, 16, 16, 16, 16, 16, 16, 16, 16, 183, 111, 111, 111, 111, 111, 111, 16, 16, 111, 111, 113, 113, 111, 110 DB 182, 16, 16, 16, 16, 16, 16, 16, 16, 185, 113, 111, 111, 111, 111, 111, 16, 185, 208, 111, 111, 111, 113, 113, 113, 113, 111, 111, 113, 113, 113, 113, 113, 185, 16, 16, 16, 16, 16, 16 DB 113, 113, 4, 4, 4, 4, 4, 4, 4, 184, 184, 16, 16, 16, 184, 111, 4, 4, 4, 4, 4, 4, 184, 208, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 DB 4, 4, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 4, 4, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 4, 4, 4, 4, 4 DB 4, 4, 4, 4, 4, 4, 4, 4, 4, 111, 184, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 111, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 DB 4, 4, 4, 4, 4, 4, 4, 4, 184, 184, 112, 4, 4, 4, 4, 4, 185, 16, 16, 16, 16, 16, 16, 16, 16, 184, 4, 4, 4, 4, 4, 4, 184, 183, 4, 4, 4, 4, 4, 4 DB 185, 16, 16, 16, 16, 16, 16, 16, 16, 208, 4, 4, 4, 4, 4, 111, 184, 183, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 112, 184, 16, 16, 16, 16, 16 DB 113, 113, 4, 4, 4, 4, 4, 4, 4, 112, 183, 18, 16, 16, 184, 111, 4, 4, 40, 4, 4, 4, 184, 208, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 DB 4, 4, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 4, 4, 4, 183, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 184, 113, 4, 4, 4, 4, 4 DB 4, 4, 4, 4, 4, 4, 4, 4, 4, 111, 184, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 111, 111, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 DB 4, 4, 4, 4, 4, 4, 4, 4, 184, 184, 112, 4, 4, 4, 4, 4, 185, 16, 16, 16, 16, 16, 16, 16, 16, 184, 4, 4, 4, 4, 4, 4, 183, 183, 4, 4, 4, 4, 4, 4 DB 112, 16, 16, 16, 16, 16, 16, 16, 16, 208, 4, 4, 4, 4, 4, 111, 183, 183, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 112, 184, 183, 16, 16, 16, 16 DB 16, 16, 112, 4, 40, 40, 4, 40, 4, 4, 4, 4, 183, 184, 184, 113, 4, 40, 40, 40, 4, 112, 16, 16, 16, 16, 16, 16, 183, 183, 16, 185, 184, 184, 16, 16, 16, 184, 112, 4 DB 4, 4, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 185, 113, 4, 4, 4, 4, 4, 4, 4, 111, 184, 16, 16, 16, 16, 16, 16, 16, 185, 4, 4, 40, 40, 4, 4, 184, 16 DB 16, 16, 185, 185, 16, 16, 112, 4, 40, 4, 4, 4, 111, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 183, 183, 183, 185, 16, 16, 16, 16, 183, 183, 183, 16, 16, 16 DB 184, 111, 4, 4, 4, 40, 40, 4, 16, 16, 4, 4, 4, 40, 4, 4, 182, 16, 16, 16, 16, 16, 16, 16, 16, 112, 4, 4, 40, 40, 4, 4, 184, 16, 4, 40, 40, 40, 40, 4 DB 112, 16, 16, 16, 16, 16, 16, 16, 16, 185, 40, 40, 40, 40, 4, 4, 16, 184, 4, 4, 4, 40, 4, 4, 111, 184, 185, 185, 185, 185, 4, 4, 4, 4, 4, 4, 183, 16, 16, 16 DB 16, 16, 112, 4, 40, 4, 4, 4, 40, 40, 39, 4, 183, 184, 184, 113, 40, 40, 40, 40, 4, 112, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 112, 4 DB 4, 40, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 185, 113, 4, 4, 4, 4, 40, 4, 4, 111, 184, 16, 16, 16, 16, 16, 16, 16, 113, 4, 4, 40, 40, 4, 4, 184, 16 DB 16, 16, 16, 16, 16, 16, 112, 4, 40, 40, 4, 4, 136, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 184, 112, 4, 40, 40, 4, 4, 4, 16, 16, 4, 4, 40, 4, 4, 4, 208, 16, 16, 16, 16, 16, 16, 16, 16, 112, 4, 40, 40, 40, 4, 4, 184, 184, 4, 40, 40, 40, 40, 4 DB 112, 16, 16, 16, 16, 16, 16, 16, 16, 185, 40, 40, 40, 40, 4, 4, 16, 16, 4, 4, 4, 40, 4, 4, 112, 184, 16, 16, 16, 184, 4, 4, 4, 4, 4, 4, 208, 16, 16, 16 DB 16, 16, 183, 136, 136, 4, 40, 40, 40, 40, 40, 4, 112, 112, 112, 4, 40, 40, 40, 40, 39, 111, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 112, 4 DB 40, 40, 40, 40, 4, 112, 16, 16, 16, 16, 184, 184, 112, 4, 40, 40, 40, 40, 40, 40, 40, 40, 4, 112, 184, 184, 16, 16, 16, 16, 16, 111, 40, 40, 40, 40, 40, 4, 16, 16 DB 16, 16, 16, 16, 16, 16, 184, 4, 40, 40, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 185, 4, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 4, 208, 16, 184, 184, 184, 112, 183, 184, 184, 185, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40 DB 4, 112, 112, 112, 112, 112, 112, 112, 112, 4, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40, 182, 16, 16, 16, 16, 16, 113, 111, 4, 4, 40, 40, 4, 112, 184, 184 DB 16, 16, 184, 184, 184, 112, 40, 40, 40, 40, 40, 40, 113, 113, 4, 4, 40, 40, 40, 40, 39, 111, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 112, 4 DB 40, 40, 40, 40, 4, 112, 16, 16, 16, 16, 208, 136, 4, 4, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 136, 136, 16, 16, 16, 16, 16, 111, 40, 40, 40, 40, 40, 4, 16, 16 DB 16, 16, 16, 16, 16, 16, 184, 4, 40, 40, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 185, 4, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40, 208, 16, 16, 208, 136, 136, 207, 16, 184, 113, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40 DB 4, 4, 4, 4, 111, 111, 136, 136, 4, 4, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 39, 182, 16, 16, 16, 16, 16, 184, 112, 112, 4, 40, 40, 4, 113, 113, 113 DB 16, 16, 16, 16, 16, 185, 4, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 4 DB 40, 40, 40, 40, 4, 111, 16, 16, 16, 184, 112, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 184, 16, 16, 16, 184, 110, 40, 40, 40, 40, 4, 4, 184, 16 DB 16, 16, 16, 16, 16, 16, 184, 4, 40, 40, 40, 40, 4, 112, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 184, 112, 40, 40, 40, 40, 40, 4, 182, 183, 4, 40, 40, 40, 40, 40, 185, 184, 184, 112, 40, 40, 111, 184, 184, 113, 40, 40, 40, 40, 40, 4, 185, 184, 4, 4, 40, 40, 40, 40 DB 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 184, 183, 4, 40, 40, 40, 40, 40, 208, 184, 184, 184, 16, 16, 16, 16, 184, 111, 40, 40, 40, 40, 40, 4 DB 16, 16, 16, 16, 16, 185, 4, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39, 4, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 185, 4 DB 40, 40, 40, 40, 4, 112, 16, 18, 16, 16, 112, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 185, 16, 18, 16, 184, 110, 40, 40, 40, 40, 40, 4, 184, 16 DB 16, 16, 16, 16, 16, 16, 184, 6, 40, 40, 40, 40, 4, 184, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 184, 112, 40, 40, 40, 40, 40, 4, 183, 183, 4, 40, 40, 40, 40, 40, 113, 184, 184, 111, 40, 40, 111, 184, 184, 113, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40 DB 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 184, 184, 4, 40, 40, 40, 40, 40, 185, 184, 184, 184, 16, 16, 16, 16, 16, 111, 40, 40, 40, 40, 40, 4 DB 6, 6, 6, 6, 6, 6, 42, 42, 6, 113, 186, 209, 207, 206, 113, 6, 42, 42, 42, 41, 12, 114, 16, 16, 16, 16, 16, 16, 16, 114, 140, 6, 6, 6, 6, 6, 6, 6, 42, 42 DB 42, 42, 42, 42, 140, 186, 184, 212, 140, 6, 42, 42, 42, 42, 42, 42, 6, 113, 185, 113, 6, 42, 42, 42, 42, 42, 6, 6, 163, 185, 16, 188, 42, 41, 42, 42, 42, 6, 184, 16 DB 16, 16, 16, 16, 16, 16, 185, 12, 41, 42, 42, 42, 12, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 115, 140, 6, 6, 6, 6, 6, 6 DB 6, 42, 42, 42, 42, 42, 42, 6, 16, 16, 6, 42, 42, 42, 42, 42, 42, 42, 6, 42, 42, 42, 42, 42, 6, 42, 42, 42, 42, 41, 42, 6, 185, 184, 6, 42, 42, 42, 42, 42 DB 114, 185, 111, 183, 208, 208, 185, 185, 184, 114, 12, 42, 42, 42, 42, 6, 16, 16, 12, 42, 42, 42, 42, 42, 6, 6, 6, 186, 16, 16, 16, 16, 16, 137, 42, 42, 42, 42, 42, 6 DB 65, 42, 42, 42, 65, 42, 42, 42, 12, 112, 16, 184, 184, 184, 184, 139, 42, 42, 42, 42, 12, 6, 16, 16, 16, 16, 16, 16, 16, 136, 65, 42, 42, 42, 42, 12, 65, 42, 42, 42 DB 42, 42, 42, 42, 12, 113, 16, 138, 65, 42, 42, 42, 42, 42, 42, 42, 12, 184, 184, 185, 12, 42, 42, 42, 42, 42, 42, 65, 64, 185, 16, 139, 42, 42, 42, 42, 12, 6, 184, 16 DB 16, 16, 16, 16, 16, 16, 185, 64, 42, 42, 42, 42, 12, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 184, 139, 65, 65, 42, 42, 42, 42, 42 DB 42, 42, 42, 42, 42, 42, 42, 12, 16, 16, 12, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 65, 42, 42, 42, 42, 42, 42, 42, 185, 16, 12, 12, 42, 42, 42, 12 DB 114, 184, 184, 184, 16, 16, 16, 184, 184, 114, 12, 42, 42, 42, 42, 12, 16, 16, 12, 42, 42, 42, 42, 42, 42, 65, 65, 114, 16, 16, 16, 16, 16, 138, 42, 42, 42, 42, 12, 6 DB 42, 42, 42, 42, 42, 42, 42, 65, 24, 208, 16, 16, 16, 16, 16, 140, 42, 42, 42, 42, 42, 115, 16, 16, 16, 16, 16, 16, 16, 137, 65, 65, 42, 65, 65, 65, 65, 65, 42, 42 DB 42, 42, 42, 42, 65, 186, 16, 138, 43, 42, 42, 42, 42, 42, 65, 65, 164, 185, 16, 208, 25, 65, 42, 42, 42, 42, 42, 42, 42, 185, 16, 138, 42, 42, 42, 42, 42, 6, 16, 16 DB 16, 16, 16, 16, 16, 16, 186, 42, 42, 42, 43, 43, 140, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 183, 139, 65, 42, 42, 65, 64, 65, 65 DB 65, 42, 42, 42, 42, 42, 42, 42, 16, 16, 6, 43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 16, 16, 6, 42, 42, 42, 42, 42 DB 114, 16, 16, 16, 16, 16, 16, 16, 16, 138, 42, 42, 42, 42, 43, 6, 16, 16, 12, 65, 65, 65, 65, 42, 65, 12, 65, 211, 16, 16, 16, 16, 16, 138, 42, 42, 42, 42, 42, 6 DB 43, 43, 43, 42, 43, 43, 115, 114, 209, 16, 16, 16, 16, 16, 184, 140, 43, 43, 43, 43, 43, 115, 16, 16, 16, 16, 16, 16, 16, 186, 114, 114, 114, 114, 114, 114, 114, 114, 6, 43 DB 43, 43, 43, 42, 65, 187, 16, 139, 43, 43, 42, 43, 43, 42, 114, 187, 187, 16, 16, 184, 187, 114, 114, 43, 43, 43, 43, 43, 65, 185, 16, 139, 43, 42, 43, 43, 43, 6, 16, 16 DB 16, 16, 16, 16, 16, 16, 186, 43, 43, 43, 43, 43, 65, 186, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 185, 114, 114, 114, 113, 113, 114, 114 DB 114, 6, 43, 43, 43, 43, 43, 42, 16, 16, 6, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 16, 16, 42, 43, 43, 43, 43, 43 DB 115, 16, 16, 16, 16, 16, 16, 16, 16, 137, 43, 43, 43, 43, 43, 42, 16, 16, 113, 114, 114, 114, 114, 114, 114, 114, 114, 185, 16, 16, 16, 16, 16, 138, 43, 43, 43, 42, 43, 42 DB 43, 43, 43, 43, 43, 43, 186, 16, 16, 16, 16, 16, 16, 16, 16, 140, 43, 43, 43, 43, 43, 116, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 187, 66 DB 43, 43, 43, 43, 43, 187, 16, 163, 43, 43, 43, 43, 43, 6, 16, 16, 16, 16, 16, 167, 16, 16, 185, 66, 43, 43, 43, 43, 43, 186, 16, 140, 43, 43, 43, 43, 14, 140, 16, 16 DB 16, 16, 16, 16, 16, 16, 187, 66, 43, 43, 43, 43, 66, 186, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 138, 43, 43, 43, 43, 43, 43, 16, 16, 6, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 16, 16, 140, 43, 43, 43, 43, 43 DB 138, 16, 16, 16, 16, 16, 16, 16, 16, 138, 43, 43, 43, 43, 43, 140, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 167, 166, 16, 16, 16, 140, 44, 43, 43, 43, 43, 6 DB 43, 43, 43, 43, 43, 43, 209, 16, 16, 16, 16, 16, 16, 16, 16, 25, 43, 43, 43, 43, 14, 116, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 187, 66 DB 43, 43, 43, 43, 43, 187, 16, 163, 43, 43, 43, 43, 43, 6, 16, 16, 16, 16, 16, 16, 16, 16, 185, 66, 43, 43, 43, 43, 66, 186, 16, 164, 43, 43, 43, 43, 43, 140, 16, 16 DB 16, 16, 16, 16, 16, 16, 187, 66, 43, 43, 43, 43, 66, 186, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 138, 43, 43, 43, 43, 43, 43, 16, 16, 6, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 16, 16, 43, 14, 43, 43, 43, 43 DB 115, 16, 16, 16, 16, 16, 16, 16, 16, 138, 43, 43, 43, 43, 14, 65, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 167, 16, 16, 16, 16, 140, 43, 43, 43, 43, 43, 43 DB 43, 43, 43, 43, 43, 43, 208, 16, 16, 16, 16, 16, 16, 16, 16, 140, 44, 43, 43, 43, 44, 116, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 187, 14 DB 43, 43, 43, 43, 14, 188, 16, 164, 44, 43, 43, 43, 44, 43, 16, 16, 16, 16, 16, 16, 16, 16, 186, 43, 43, 43, 43, 43, 14, 186, 16, 140, 44, 43, 43, 44, 43, 6, 16, 16 DB 16, 16, 16, 16, 16, 16, 187, 14, 43, 43, 43, 43, 43, 187, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 115, 44, 43, 43, 43, 43, 43, 16, 16, 6, 43, 43, 43, 43, 43, 43, 43, 14, 43, 138, 138, 6, 14, 43, 43, 43, 43, 43, 43, 43, 43, 18, 16, 138, 139, 115, 43, 44, 43 DB 43, 116, 116, 188, 16, 16, 187, 116, 116, 43, 44, 43, 43, 139, 139, 137, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 116, 116, 116, 43, 43, 43, 43, 140, 138, 137 DB 43, 43, 43, 43, 44, 44, 186, 16, 16, 16, 16, 16, 16, 16, 16, 26, 44, 43, 44, 43, 14, 116, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 187, 67 DB 44, 44, 43, 44, 14, 188, 16, 164, 44, 43, 43, 43, 44, 43, 16, 16, 16, 16, 16, 16, 16, 16, 186, 14, 44, 44, 44, 43, 14, 186, 16, 164, 44, 44, 43, 43, 14, 6, 16, 16 DB 16, 16, 16, 16, 16, 16, 187, 14, 43, 43, 43, 44, 14, 187, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 139, 44, 44, 44, 44, 44, 43, 16, 16, 43, 44, 43, 43, 43, 43, 43, 44, 14, 6, 16, 16, 115, 14, 44, 43, 44, 44, 44, 43, 44, 43, 16, 16, 16, 16, 16, 43, 44, 44 DB 14, 14, 68, 140, 16, 16, 139, 68, 14, 14, 43, 44, 43, 185, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 14, 14, 14, 43, 44, 6, 16, 16, 16 DB 14, 14, 14, 44, 44, 45, 187, 16, 16, 16, 16, 16, 16, 16, 16, 6, 44, 44, 44, 44, 14, 116, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 187, 14 DB 44, 44, 44, 44, 14, 188, 16, 164, 44, 43, 44, 43, 44, 6, 16, 16, 16, 16, 16, 16, 16, 16, 186, 14, 44, 44, 44, 44, 14, 186, 16, 164, 67, 14, 44, 44, 44, 6, 16, 16 DB 16, 16, 16, 16, 16, 16, 188, 14, 44, 44, 14, 67, 67, 187, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 DB 16, 115, 44, 44, 44, 44, 44, 43, 16, 16, 43, 44, 44, 44, 43, 43, 14, 14, 67, 25, 16, 16, 139, 67, 67, 14, 44, 44, 44, 44, 44, 43, 16, 16, 16, 16, 16, 26, 67, 14 DB 43, 44, 14, 116, 16, 16, 115, 14, 44, 44, 14, 67, 66, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 43, 44, 43, 44, 14, 67, 26, 16, 16, 16 DB 6, 6, 43, 44, 44, 44, 140, 140, 164, 164, 164, 164, 164, 140, 140, 14, 44, 44, 44, 44, 14, 116, 16, 21, 23, 164, 164, 164, 164, 164, 164, 164, 140, 140, 164, 164, 140, 140, 140, 14 DB 44, 44, 44, 44, 14, 188, 16, 164, 44, 44, 44, 44, 14, 45, 16, 16, 16, 16, 16, 16, 16, 16, 186, 67, 44, 44, 44, 44, 14, 187, 16, 138, 43, 6, 43, 44, 44, 43, 140, 163 DB 164, 164, 163, 164, 164, 140, 116, 14, 44, 44, 6, 115, 115, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 139, 164, 140, 164, 164, 164, 164, 164, 164, 164, 140, 140, 140, 140 DB 140, 25, 14, 44, 44, 44, 44, 43, 16, 16, 43, 44, 44, 44, 44, 14, 43, 116, 116, 115, 16, 16, 187, 116, 116, 6, 44, 44, 44, 44, 44, 14, 18, 16, 16, 16, 16, 139, 116, 116 DB 43, 14, 14, 43, 163, 163, 43, 14, 44, 45, 116, 115, 115, 16, 16, 16, 16, 16, 166, 164, 165, 164, 164, 164, 140, 140, 140, 140, 140, 140, 43, 44, 14, 43, 116, 116, 139, 16, 16, 16 DB 16, 16, 187, 67, 44, 44, 44, 44, 14, 44, 14, 14, 14, 14, 14, 14, 44, 44, 44, 44, 14, 116, 16, 26, 14, 14, 14, 14, 14, 14, 44, 44, 44, 44, 14, 14, 44, 44, 44, 44 DB 44, 44, 44, 44, 14, 188, 16, 164, 44, 44, 44, 44, 44, 45, 16, 16, 16, 16, 16, 16, 16, 16, 186, 14, 44, 44, 44, 44, 14, 187, 16, 16, 16, 16, 116, 14, 44, 44, 14, 44 DB 14, 14, 14, 14, 44, 44, 44, 44, 44, 14, 188, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 44, 44, 44, 44, 14, 44, 44, 44, 44, 44, 14, 14 DB 14, 44, 44, 44, 44, 44, 14, 14, 16, 16, 66, 14, 44, 44, 44, 44, 140, 16, 16, 16, 16, 16, 16, 16, 16, 236, 14, 44, 44, 44, 44, 45, 18, 16, 16, 16, 166, 166, 16, 16 DB 6, 14, 44, 44, 14, 14, 44, 44, 14, 43, 16, 16, 16, 16, 16, 16, 16, 186, 14, 14, 44, 14, 44, 14, 14, 14, 14, 44, 44, 44, 44, 44, 14, 140, 16, 16, 16, 16, 16, 16 DB 16, 16, 187, 68, 14, 44, 44, 44, 44, 14, 44, 44, 14, 14, 14, 14, 44, 44, 44, 44, 14, 116, 16, 27, 44, 14, 14, 14, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44 DB 44, 44, 44, 44, 14, 188, 16, 24, 44, 44, 44, 44, 44, 45, 16, 16, 16, 16, 16, 16, 16, 16, 189, 14, 44, 44, 44, 44, 14, 187, 16, 16, 16, 16, 140, 14, 44, 44, 14, 14 DB 14, 44, 14, 14, 44, 44, 44, 44, 44, 14, 188, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 14, 14, 44, 44, 44, 14, 44, 44, 44, 44, 44, 44, 14, 14 DB 14, 44, 44, 44, 44, 44, 14, 14, 16, 16, 66, 14, 44, 44, 44, 14, 140, 16, 16, 16, 16, 16, 16, 16, 16, 138, 14, 44, 44, 44, 44, 44, 18, 16, 16, 16, 166, 166, 16, 16 DB 6, 14, 14, 14, 14, 14, 44, 44, 14, 43, 16, 16, 16, 16, 16, 16, 16, 186, 14, 14, 44, 14, 44, 14, 14, 14, 14, 44, 44, 44, 44, 44, 14, 140, 16, 16, 16, 16, 16, 16 DB 16, 16, 18, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 164, 24, 24, 24, 20, 16, 22, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 DB 24, 24, 164, 164, 24, 189, 16, 21, 24, 164, 24, 24, 24, 165, 16, 16, 16, 16, 16, 16, 16, 16, 16, 23, 24, 24, 24, 24, 24, 18, 16, 16, 16, 16, 20, 24, 164, 140, 164, 164 DB 24, 24, 24, 24, 24, 24, 24, 24, 24, 164, 209, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 140, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 DB 24, 24, 164, 24, 24, 24, 24, 24, 16, 16, 165, 24, 24, 24, 164, 164, 20, 16, 16, 16, 16, 16, 16, 16, 16, 19, 164, 164, 24, 24, 25, 140, 16, 16, 16, 16, 16, 16, 16, 16 DB 141, 164, 24, 24, 24, 24, 24, 24, 24, 140, 16, 16, 16, 16, 16, 16, 16, 16, 23, 24, 24, 24, 164, 164, 24, 24, 24, 24, 24, 24, 24, 24, 25, 142, 16, 16, 16, 16, 16, 16 x_position dw 50 y_position dw 30 first_player_wins db 'First Player Wins $' second_player_wins db 'Second player wins $' GAME_OVER_mess db 'Press ESC Key to Return to main menu $' Goodbye_mess db 'Goodbye *^-^* $' ;;;;;;;CHAT ;;; First_cursor_X DB 6 First_cursor_Y DB 1 ; SECOND CURSOR USED FOR RECEIVING SECOND_CURSOR_X DB 6 SECOND_CURSOR_Y DB 13 start_position_x equ 6 LETTER_SENT DB ? LETTER_RECEIVING DB ? Line_status_register equ 3FDH TRANSMIT_DATA_REGISTER equ 3F8H Line_Control_Register equ 3fbh end_line db 76 IS_ENTER DB 0 IS_BACKSPACE DB 0 ;players Name first_chatter db 'chatter 1 : $' second_chatter db 'chatter 2 : $' chat_end_string db 'To end chat press ESC $' ;;; IN GAME CHAT MODULE in_game_cursor_up db 0 in_game_cursor_down db 0 in_game_received_val db 0 in_game_to_send_val db 0 in_game_iterator db 0 in_game_end_chat db 0 is_quit db 0 level DB 0 ;------------------------------------------------------------ ;;FOR MAKING GAME BEING PLAYED BY TWO PCS LETTER_RECEIVED DB ?;LETTER RECIEVED BY UART is_master DB 01h ;WHEN A PLAYER SENT INVI. TO THE ANOTHER ONE SO HE IS THE MASTER (MASTER VALUE=1) STORED_KEY_OR_UART DB ?;LETTER RECIEVED BY UART OR KEY OF KEYBOARD(OPTIONS OF CONTROLLING THE PLAYERS) ;--------------------------------------------------------------------------- .code MAIN PROC FAR mov ax,@data mov ds ,ax MOV ES, AX CALL Far PTR Take_User_Data Call FAR PTR MAIN_MENU Call FAR PTR CLEAR_SCREEN mov ah,2 mov dx,090fh int 10h PRINT_Messages Goodbye_mess mov ah,0 int 16h RET MAIN ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;taking the character from the user and reacting to it ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;taking the character from the user and reacting to it ;taking the character from the user and reacting to it MOVE_PLAYERS PROC FAR ;Check if any player is freezed--> then reduce its freezing time cmp first_player_freeze,0 je Is_Second_Player_Freeze dec first_player_freeze Is_Second_Player_Freeze: cmp second_player_freeze,0 je Check_Pressed dec second_player_freeze Check_Pressed: ;TO KNOW THAT I AM THE MASTER OR THE SLAVE mov DL,GAME_MASTER CMP DL, 0 jnz I_AM_NOT_MASTER_reverse_label jmp I_AM_NOT_MASTER I_AM_NOT_MASTER_reverse_label: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASTER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;check if any key is being pressed MOV AH,01h INT 16h JnZ CHECK_MOVEMENT_MASTER_KEYBOARD ;ZF = 1, JZ -> Jump If Zero jmp CHECK_MOVEMENT_MASTER_UART CHECK_MOVEMENT_MASTER_KEYBOARD: ;Read which key is being pressed (AL = ASCII character/ AH = SCAN CODE) MOV AH,00h INT 16h SendChar AH ;in game chat cmp ah,27h ;press ';' to start ni game chat jne cont1 ;call far ptr send_in_chat_inv call far ptr start_in_game_chatting jmp End_Moving cont1: cmp AH,39h ;this is space key(ATTACK BUTTON) jne First_moved_1 cmp first_player_freeze,0 JLE Do_not_End_Moving_1 ;if it is still freezed jmp End_Moving Do_not_End_Moving_1: cmp First_Is_Collided,1 ;If he is colliding, he cannot attack JNE Do_not_End_Moving_2 Jmp End_Moving Do_not_End_Moving_2: call FAR PTR First_Player_Attack jmp End_Moving First_moved_1: cmp first_player_freeze,0 JLE Do_not_End_Moving_3 jmp End_Moving ;if it is still freezed Do_not_End_Moving_3: MOV STORED_KEY_OR_UART,AH call FAR PTR CHECK_FIRST_PLAYER_MOVEMENT jmp End_Moving CHECK_MOVEMENT_MASTER_UART: ;;;;;;;;;;;;;;;;;;;;;;;RECIEVEFROM_UART;;;;;;;;;;;;;;;;;;;;;;;;;;; ReceiveCharNotAmustToRecieve MOV LETTER_RECEIVED,AL ;in game chat cmp LETTER_RECEIVED,27h ;press ';' to start ni game chat jne cont2 ;call far ptr send_in_chat_inv call far ptr start_in_game_chatting jmp End_Moving cont2: ;;;;;;;;;;;;;;;;;;;;;;;RECIEVEFROM_UART;;;;;;;;;;;;;;;;;;;;;;;;;;; cmp LETTER_RECEIVED,39h ;this is Enter (ATTACK BUTTON) jne Second_MOVED_1 cmp second_player_freeze,0 JLE Do_not_End_Moving_4 jmp End_Moving ;if it is still freezed Do_not_End_Moving_4: cmp Second_Is_Collided,1 ;If he is colliding, he cannot attack JNE Do_not_End_Moving_5 Jmp End_Moving Do_not_End_Moving_5: call FAR PTR Second_Player_Attack jmp End_Moving Second_MOVED_1: cmp second_player_freeze,0 JLE Do_not_End_Moving_6 jmp End_Moving ;if it is still freezed Do_not_End_Moving_6: MOV STORED_KEY_OR_UART,AL call FAR PTR CHECK_SECOND_PLAYER_MOVEMENT jmp End_Moving ;/////////////////////////////////////////////////////////////////////////////////////////////////////SLAVE///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// I_AM_NOT_MASTER: MOV AH,01h INT 16h JnZ CHECK_MOVEMENT_SLAVE_KEYBOARD ;ZF = 1, JZ -> Jump If Zero JZ CHECK_MOVEMENT_SLAVE_UART CHECK_MOVEMENT_SLAVE_KEYBOARD: ;Read which key is being pressed (AL = ASCII character/ AH = SCAN CODE) MOV AH,00h INT 16h SendChar AH cmp ah,27h ;press ';' to start ni game chat jne cont3 ;call far ptr send_in_chat_inv call far ptr start_in_game_chatting jmp End_Moving cont3: cmp AH,39h ;this is ENTER key (ATTACK BUTTON) jne SECOND_moved_2 cmp SECOND_player_freeze,0 jg End_Moving ;if it is still freezed cmp SECOND_Is_Collided,1 ;If he is colliding, he cannot attack JE End_Moving call FAR PTR SECOND_Player_Attack jmp End_Moving SECOND_moved_2: cmp first_player_freeze,0 jg End_Moving ;if it is still freezed MOV STORED_KEY_OR_UART,AH call FAR PTR CHECK_SECOND_PLAYER_MOVEMENT jmp End_Moving CHECK_MOVEMENT_SLAVE_UART: ;;;;;;;;;;;;;;;;;;;;;;;RECIEVEFROM_UART;;;;;;;;;;;;;;;;;;;;;;;;;;; ReceiveCharNotAmustToRecieve MOV LETTER_RECEIVED,AL cmp LETTER_RECEIVED,27h ;press ';' to start ni game chat jne cont4 ;call far ptr send_in_chat_inv call far ptr start_in_game_chatting jmp End_Moving cont4: ;;;;;;;;;;;;;;;;;;;;;;;RECIEVEFROM_UART;;;;;;;;;;;;;;;;;;;;;;;;;;; cmp LETTER_RECEIVED,39h ;this is SPACE (ATTACK BUTTON) jne FIRST_MOVED_2 cmp FIRST_player_freeze,0 jg End_Moving ;if it is still freezed cmp FIRST_Is_Collided,1 ;If he is colliding, he cannot attack JE End_Moving call FAR PTR FIRST_Player_Attack jmp End_Moving FIRST_MOVED_2: cmp second_player_freeze,0 jg End_Moving ;if it is still freezed MOV STORED_KEY_OR_UART,AL call FAR PTR CHECK_FIRST_PLAYER_MOVEMENT ;call FAR PTR CHECK_SECOND_PLAYER_MOVEMENT jmp End_Moving End_Moving: RET MOVE_PLAYERS ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;this will check for direction of the attack First_Player_Attack PROC mov ax,first_player_X cmp ax,second_player_X jGE Second_IS_IN_THE_LEFT_SIDE call FAR PTR First_Attack_Left_TO_Right RET Second_IS_IN_THE_LEFT_SIDE: Call far PTR First_Attack_Right_TO_Left RET First_Player_Attack ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;this will check for direction of the attack Second_Player_Attack PROC mov ax,Second_player_X cmp ax,First_player_X jGE First_IS_IN_THE_LEFT_SIDE call FAR PTR Second_Attack_Left_TO_Right RET First_IS_IN_THE_LEFT_SIDE: Call far PTR Second_Attack_Right_TO_Left RET Second_Player_Attack ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;clear the console CLEAR_SCREEN PROC FAR MOV AH,00h ;set the configuration to video mode MOV AL,13h ;choose the video mode INT 10h ;execute the configuration MOV AH,0fh ;set the configuration MOV BH,00h ;to the background color MOV BL,00h ;choose black as background color INT 10h ;execute the configuration RET CLEAR_SCREEN ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;draw the image of player one draw_p1 proc FAR ;;;;;;;;;;;;;; mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov di,0 mov al,p1[DI] ;the pixel color mov bh,0 ;the page number mov cx,first_player_X ;the starting x-position (column) add cx,PLAYERS_WIDTH ;as we draw in the reversed order mov dx,first_player_Y ;the starting y-position (row) add dx,PLAYERS_HEIGHT ;as we draw in the reversed order ;here we loop for the image size (player_size) fill_p1: cmp al,0 jz pass_the_pixel int 10h pass_the_pixel: inc di mov al,p1[DI] dec cx cmp cx,first_player_X jnz fill_p1 ;if not zero so we continue to the same row mov cx,first_player_X ;the starting x-position (column) add cx,PLAYERS_WIDTH ;as we draw in the reversed order dec dx ;if not zero so we continue to draw the background cmp dx,first_player_Y jnz fill_p1 ;;;;;;;;;;;;;; ret draw_p1 endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;draw the image of player two draw_p2 proc FAR ;;;;;;;;;;;;;; mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov di,0 mov al,p2[DI] ;the pixel color mov bh,0 ;the page number mov cx,second_player_X ;the starting x-position (column) add cx,PLAYERS_WIDTH ;as we draw in the reversed order mov dx,SECOND_PLAYER_Y ;the starting y-position (row) add dx,PLAYERS_HEIGHT ;as we draw in the reversed order ;here we loop for the image size (player_size) fill_p2: cmp al,0 jz pass_the_pixel_2 int 10h pass_the_pixel_2: inc di mov al,p2[DI] dec cx cmp cx,second_player_X jnz fill_p2 ;if not zero so we continue to the same row mov cx,second_player_X ;the starting x-position (column) add cx,PLAYERS_WIDTH ;as we draw in the reversed order dec dx ;if not zero so we continue to draw the background cmp dx,SECOND_PLAYER_Y jnz fill_p2 ;;;;;;;;;;;;;; ret draw_p2 endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;fill the whole screen with the background color draw_background proc FAR ;;;;;;;;;;;;;; mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov al,background_color ;the pixel color mov bh,0 ;the page number mov cx,0 ;the x-position (column) mov dx,0 ;the y-position (row) ;here we loop for 4/5 of the screen fillblue: int 10h inc cx cmp cx,WINDOW_WIDTH jnz fillblue ;if not zero so we continue to the same row inc dx mov cx,0 cmp dx,WINDOW_HEIGHT ;if not zero so we continue to draw the background jnz fillblue ;;;;;;;;;;;;;; ret draw_background endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;draw a number of hearts that is first_player_health draw_h1 PROC FAR ;check if health is zero, don't draw mov ax,first_player_health cmp ax,0 jnz first_player_alive RET first_player_alive: mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov PRE_POSITION_X,first_player_health_X mov PRE_POSITION_Y,first_player_health_Y mov si,0 CLEAR_H1: mov al,background_color mov bh,0 mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,health_bar_width mov dx,pre_position_y add dx,window_bounds_upper fill_h1_background: int 10h dec cx cmp cx,pre_position_x jnz fill_h1_background mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,health_bar_width dec dx cmp dx,PRE_POSITION_Y jnz fill_h1_background draw_one_Red_heart: ;;;;;;;;;;;;;; mov di,0 mov al,h1[DI] ;the pixel color mov bh,0 ;the page number mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,heart_WIDTH ;as we draw in the reversed order mov dx,PRE_POSITION_Y ;the starting y-position (row) add dx,heart_HEIGHT ;as we draw in the reversed order ;here we loop for the image size (player_size) fill_h1: cmp al,0 jz pass_the_pixel__1 int 10h pass_the_pixel__1: inc di mov al,h1[DI] dec cx cmp cx,PRE_POSITION_X jnz fill_h1 ;if not zero so we continue to the same row mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,heart_WIDTH ;as we draw in the reversed order dec dx ;if not zero so we continue to draw the background cmp dx,PRE_POSITION_Y jnz fill_h1 ;;;;;;;;;;;;;; inc si cmp si,first_player_health jz finish_drawing_h1 mov di,pre_position_x add di,heart_WIDTH mov pre_position_x,di jmp draw_one_Red_heart finish_drawing_h1: ret draw_h1 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;draw a number of hearts that is second_player_health draw_h2 PROC FAR ;check if health is zero, don't draw mov ax,second_player_health cmp AX,0 jnz second_player_alive RET second_player_alive: mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov PRE_POSITION_X,second_player_health_X mov PRE_POSITION_Y,second_player_health_Y mov si,0 CLEAR_H2: mov al,background_color mov bh,0 mov cx,WINDOW_WIDTH ;the ending x-position (column) SUB cx,health_bar_width mov dx,pre_position_y add dx,window_bounds_upper fill_h2_background: int 10h INC cx cmp cx,WINDOW_WIDTH jnz fill_h2_background mov cx,WINDOW_WIDTH ;the starting x-position (column) sub cx,health_bar_width dec dx cmp dx,PRE_POSITION_Y jnz fill_h2_background draw_one_Blue_heart: ;;;;;;;;;;;;;; mov di,0 mov al,h2[DI] ;the pixel color mov bh,0 ;the page number mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,heart_WIDTH ;as we draw in the reversed order mov dx,PRE_POSITION_Y ;the starting y-position (row) add dx,heart_HEIGHT ;as we draw in the reversed order ;here we loop for the image size (player_size) fill_h2: cmp al,0 jz pass_the_pixel__2 int 10h pass_the_pixel__2: inc di mov al,h2[DI] dec cx cmp cx,PRE_POSITION_X jnz fill_h2 ;if not zero so we continue to the same row mov cx,PRE_POSITION_X ;the starting x-position (column) add cx,heart_WIDTH ;as we draw in the reversed order dec dx ;if not zero so we continue to draw the background cmp dx,PRE_POSITION_Y jnz fill_h2 ;;;;;;;;;;;;;; inc si cmp si,second_player_health jz finish_drawing_h2 mov di,pre_position_x sub di,heart_WIDTH mov pre_position_x,di jmp draw_one_Blue_heart finish_drawing_h2: ret draw_h2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FILLRECTANGLE proc FAR MOV DI,0 PUSH LEN FILL: PUSH LEN FILLINNER: MOV AH,0CH MOV AL,Barrier_array[DI] INC DI MOV BH,0H MOV CX,LEN MOV DX,WID INT 10H MOV BX,LENMAX INC LEN CMP BX,LEN JNZ FILLINNER POP LEN INC WID MOV BX,WIDMAX CMP BX,WID JNZ FILL POP WID RET FILLRECTANGLE ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DRAW_BARRIER1 PROC FAR ;As we use pre_position variables as temp, and we always call draw_barrier after we update their values ;We need to condition only one special case is when we draw them for the first time mov ax,pre_position_y cmp ax,0 jz first_time_to_draw1 first_time_to_draw1: mov Ax,X_BARRIER1 mov LEN,Ax add Ax, BARRIER_HORIZONTAL_SIZE mov LENMAX,ax mov ax,Y_BARRIER1 mov WID,ax add ax, BARRIER_VERTICAL_SIZE mov WIDMAX,ax CALL FAR PTR CHECK_BOUNDARY_BARRIER1 RET DRAW_BARRIER1 endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DRAW_BARRIER2 PROC FAR ;As we use pre_position variables as temp, and we always call draw_barrier after we update their values ;We need to condition only one special case is when we draw them for the first time mov ax,pre_position_y cmp ax,0 jz first_draw2 first_draw2: ;; CALL CHECK_OVERLAPPING_BARRIER2 mov Ax,X_BARRIER2 mov LEN,Ax add Ax, BARRIER_HORIZONTAL_SIZE mov LENMAX,ax mov ax,Y_BARRIER2 mov WID,ax add ax, BARRIER_VERTICAL_SIZE mov WIDMAX,ax CALL FAR PTR CHECK_BOUNDARY_BARRIER2 RET DRAW_BARRIER2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;checking that this move is allowed CHECK_FIRST_PLAYER_MOVEMENT PROC FAR ;STORE THE PREVIOUS POSITION OF PLAYER 1, we will use it if the new position causes collision (the same as push it in the stack) MOV BX,first_player_X MOV PRE_POSITION_X,BX mov BX,first_player_Y MOV PRE_POSITION_Y,BX ;if it is 'w' or 'W' move up CMP STORED_KEY_OR_UART, 48H JE MOVE_FIRST_PLAYER_UP ;if it is 's' or 'S' move down CMP STORED_KEY_OR_UART,50H JE MOVE_FIRST_PLAYER_DOWN ;if it is 'D' or 'd' move first player right cmp STORED_KEY_OR_UART,4DH je MOVE_FIRST_PLAYER_right ; if it is 'A' or 'a' move first player left cmp STORED_KEY_OR_UART,4BH je MOVE_FIRST_PLAYER_LEFT JMP Exit_FIRST_PLAYER_MOVEMENT MOVE_FIRST_PLAYER_UP: MOV AX,PLAYERS_VELOCITY SUB first_player_Y,AX MOV AX,window_bounds_upper CMP first_player_Y,AX JL FIX_FIRST_PLAYER_TOP_POSITION ;it will jump if first_player_Y < AX ---> outside the window JMP CHECK_FOR_COLLISION_1 FIX_FIRST_PLAYER_TOP_POSITION: ;Return it to inside the window MOV first_player_Y,AX JMP CHECK_FOR_COLLISION_1 MOVE_FIRST_PLAYER_DOWN: MOV AX,PLAYERS_VELOCITY ADD first_player_Y,AX MOV AX,WINDOW_HEIGHT SUB AX,WINDOW_BOUNDS SUB AX,PLAYERS_HEIGHT CMP first_player_Y,AX JG FIX_FIRST_PLAYER_BOTTOM_POSITION ;it will jump if first_player_Y > AX---> outside the window JMP CHECK_FOR_COLLISION_1 FIX_FIRST_PLAYER_BOTTOM_POSITION: ;Return it to inside the window MOV first_player_Y,AX JMP CHECK_FOR_COLLISION_1 MOVE_FIRST_PLAYER_right: MOV AX,PLAYERS_VELOCITY ADD first_player_X,AX MOV AX,WINDOW_WIDTH SUB AX,PLAYERS_WIDTH SUB AX,WINDOW_BOUNDS cmp first_player_X,AX JG FIX_FIRST_PLAYER_RIGHT_POSITION ;it will jump if first_player_X > AX---> outside the window JMP CHECK_FOR_COLLISION_1 FIX_FIRST_PLAYER_RIGHT_POSITION: ;Return it to inside the window MOV first_player_X,AX JMP CHECK_FOR_COLLISION_1 MOVE_FIRST_PLAYER_LEFT: mov ax,PLAYERS_VELOCITY SUB first_player_X,ax MOV AX,WINDOW_BOUNDS CMP first_player_X,AX JL FIX_FIRST_PLAYER_LEFT_POSITION JMP CHECK_FOR_COLLISION_1 FIX_FIRST_PLAYER_LEFT_POSITION: MOV first_player_X,AX JMP CHECK_FOR_COLLISION_1 CHECK_FOR_COLLISION_1: ; maxx1 > minx2 && minx1 < maxx2 && maxy1 > miny2 && miny1 < maxy2 MOV AX,first_player_X ;IF maxx1 > minx2 ADD AX,PLAYERS_WIDTH CMP AX,second_player_X JNG Exit_FIRST_PLAYER_MOVEMENT ;No collision will happen MOV AX,second_player_X ;IF minx1 < maxx2 ADD AX,PLAYERS_WIDTH CMP first_player_X,AX JNL Exit_FIRST_PLAYER_MOVEMENT ;No collision will happen MOV AX,SECOND_PLAYER_Y ;IF maxy1 > miny2 ADD AX,PLAYERS_HEIGHT CMP AX,first_player_Y JNG Exit_FIRST_PLAYER_MOVEMENT ;No collision will happen MOV AX,first_player_Y ;IF miny1 < maxy2 ADD AX,PLAYERS_HEIGHT CMP SECOND_PLAYER_Y,AX JNL Exit_FIRST_PLAYER_MOVEMENT ;No collision will happen MOV DX,PRE_POSITION_X ; If it reached here then there will be a collision MOV first_player_X,DX ; Return the old values MOV DX,PRE_POSITION_Y MOV first_player_Y,DX RET Exit_FIRST_PLAYER_MOVEMENT: call FAR PTR Update_Players call FAR PTR draw_p1 RET CHECK_FIRST_PLAYER_MOVEMENT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;checking that this move is allowed ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;checking that this move is allowed CHECK_SECOND_PLAYER_MOVEMENT PROC FAR mov DX,second_player_X MOV PRE_POSITION_X,DX mov DX,SECOND_PLAYER_Y MOV PRE_POSITION_Y,DX ;if it is 'o' or 'O' move up ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IN AX, 60H CMP STORED_KEY_OR_UART, 48H ;(UP_ARROW) JE MOVE_SECOND_PLAYER_UP CMP STORED_KEY_OR_UART, 50H ;(DOWN_ARROW) JE MOVE_SECOND_PLAYER_DOWN CMP STORED_KEY_OR_UART, 4BH ;(LEST_ARROW) JE MOVE_SECOND_PLAYER_left CMP STORED_KEY_OR_UART, 4DH;(RIGHT_ARROW) JE MOVE_SECOND_PLAYER_right JMP EXIT_PLAYERS_MOVEMENT MOVE_SECOND_PLAYER_UP: MOV AX,PLAYERS_VELOCITY SUB SECOND_PLAYER_Y,AX MOV AX,window_bounds_upper CMP SECOND_PLAYER_Y,AX JL FIX_second_player_TOP_POSITION JMP CHECK_FOR_COLLISION_2 FIX_second_player_TOP_POSITION: MOV SECOND_PLAYER_Y,AX JMP CHECK_FOR_COLLISION_2 MOVE_SECOND_PLAYER_DOWN: MOV AX,PLAYERS_VELOCITY ADD SECOND_PLAYER_Y,AX MOV AX,WINDOW_HEIGHT SUB AX,WINDOW_BOUNDS SUB AX,PLAYERS_HEIGHT CMP SECOND_PLAYER_Y,AX JG FIX_second_player_down_POSITION JMP CHECK_FOR_COLLISION_2 FIX_second_player_down_POSITION: MOV SECOND_PLAYER_Y,AX JMP CHECK_FOR_COLLISION_2 MOVE_SECOND_PLAYER_left: MOV AX,PLAYERS_VELOCITY SUB second_player_X,AX MOV AX,WINDOW_BOUNDS CMP second_player_X,AX JL FIX_SECOND_PLAYER_left_POSITION JMP CHECK_FOR_COLLISION_2 FIX_SECOND_PLAYER_left_POSITION: MOV second_player_X,AX JMP CHECK_FOR_COLLISION_2 MOVE_SECOND_PLAYER_right: MOV AX,PLAYERS_VELOCITY ADD second_player_X,AX MOV AX,WINDOW_WIDTH SUB AX,WINDOW_BOUNDS sub AX,PLAYERS_WIDTH CMP second_player_X,AX JG FIX_SECOND_PLAYER_RIGHT_POSITION JMP CHECK_FOR_COLLISION_2 FIX_SECOND_PLAYER_RIGHT_POSITION: MOV second_player_X,AX JMP CHECK_FOR_COLLISION_2 CHECK_FOR_COLLISION_2: ; maxx1 > minx2 && minx1 < maxx2 && maxy1 > miny2 && miny1 < maxy2 MOV AX,first_player_X ;IF maxx1 > minx2 ADD AX,PLAYERS_WIDTH CMP AX,second_player_X JNG EXIT_PLAYERS_MOVEMENT ;No collision will happen MOV AX,second_player_X ;IF minx1 < maxx2 ADD AX,PLAYERS_WIDTH CMP first_player_X,AX JNL EXIT_PLAYERS_MOVEMENT ;No collision will happen MOV AX,SECOND_PLAYER_Y ;IF maxy1 > miny2 ADD AX,PLAYERS_HEIGHT CMP AX,first_player_Y JNG EXIT_PLAYERS_MOVEMENT ;No collision will happen MOV AX,first_player_Y ;IF miny1 < maxy2 ADD AX,PLAYERS_HEIGHT CMP SECOND_PLAYER_Y,AX JNL EXIT_PLAYERS_MOVEMENT ;No collision will happen MOV DX,PRE_POSITION_X ; If it reached here then there will be a collision MOV second_player_X,DX ; Return the old values MOV DX,PRE_POSITION_Y MOV SECOND_PLAYER_Y,DX RET EXIT_PLAYERS_MOVEMENT: Call FAR PTR Update_Players Call FAR PTR draw_p2 RET CHECK_SECOND_PLAYER_MOVEMENT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;erase the player original position before moving Update_Players PROC FAR ;;;;;;;;;;;;;; mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov al,background_color ;the pixel color mov bh,0 ;the page number MOV CX,PRE_POSITION_X MOV SI,CX ADD SI,PLAYERS_WIDTH ADD SI,1 MOV Dx,PRE_POSITION_Y MOV DI,DX ADD DI,PLAYERS_HEIGHT ADD DI,1 ;here we loop for 4/5 of the screen fillblue1: int 10h inc cx cmp cx,SI jnz fillblue1 ;if not zero so we continue to the same row inc dx mov cx,PRE_POSITION_X cmp dx,DI ;if not zero so we continue to draw the background jnz fillblue1 ;;;;;;;;;;;;;; RET Update_Players ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; first_player_barriers_coli PROC FAR ;check for collision between player1 and barriers(1,2) ;CHECK_FOR_COLLISION_p1_b1: mov First_Is_Collided,0 ;first_player_x+players_width<x_barrier1 MOV AX,first_player_X ADD AX,PLAYERS_WIDTH CMP AX,X_BARRIER1 JNG CHECK_FOR_COLLISION_p1_b2 ;No collision will happen ;first_player_x>x_barrier1+ BARRIER_HORIZONTAL_SIZE MOV AX,X_BARRIER1 ADD AX, BARRIER_HORIZONTAL_SIZE CMP first_player_X,AX JNL CHECK_FOR_COLLISION_p1_b2 ;No collision will happen ;first_player_Y+players_HEIGHT<Y_barrier1 MOV AX,First_PLAYER_Y ADD AX,PLAYERS_HEIGHT CMP AX,Y_BARRIER1 JNG CHECK_FOR_COLLISION_p1_b2 ;No collision will happen ;first_player_Y>Y_barrier1+ BARRIER_VERTICAL_SIZE MOV AX,Y_BARRIER1 ADD AX, BARRIER_VERTICAL_SIZE CMP first_player_Y,AX JNL CHECK_FOR_COLLISION_p1_b2 ;No collision will happen ;There is collision , set his state to collided and check if he has immunity to collision before decreasing health mov First_Is_Collided,1 ;check if he has immunity to collision cmp first_player_health_immunity , 0 JZ Decrease_first_health_1 JNZ Donot_Decrease_first_health_1 Decrease_first_health_1: DEC first_player_health ;give him immunity to not be affected by any barriers for this player MOV first_player_health_immunity,25 CALL draw_h1 Donot_Decrease_first_health_1: DEC first_player_health_immunity CHECK_FOR_COLLISION_p1_b2: ;first_player_x+players_width<x_barrier2 MOV AX,first_player_X ADD AX,PLAYERS_WIDTH CMP AX,X_BARRIER2 JNG EXIT_PLAYERS_barriers_col ;No collision will happen ;first_player_x>x_barrier2+ BARRIER_HORIZONTAL_SIZE MOV AX,X_BARRIER2 ADD AX, BARRIER_HORIZONTAL_SIZE CMP first_player_X,AX JNL EXIT_PLAYERS_barriers_col ;No collision will happen ;first_player_Y+players_HEIGHT<Y_barrier2 MOV AX,First_PLAYER_Y ADD AX,PLAYERS_HEIGHT CMP AX,Y_BARRIER2 JNG EXIT_PLAYERS_barriers_col ;No collision will happen ;first_player_Y>Y_barrier2+ BARRIER_VERTICAL_SIZE MOV AX,Y_BARRIER2 ADD AX, BARRIER_VERTICAL_SIZE CMP first_player_Y,AX JNL EXIT_PLAYERS_barriers_col ;No collision will happen ;There is collision , set his state to collided and check if he has immunity to collision before decreasing health mov First_Is_Collided,1 ;check if he has immunity to collision cmp first_player_health_immunity , 0 JZ Decrease_first_health_2 JNZ Donot_Decrease_first_health_2 Decrease_first_health_2: DEC first_player_health ;give him immunity to not be affected by any barriers for this player MOV first_player_health_immunity,25 CALL draw_h1 Donot_Decrease_first_health_2: DEC first_player_health_immunity EXIT_PLAYERS_barriers_col: RET first_player_barriers_coli ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; second_player_barriers_coli PROC FAR ;;check for collision between player2 and barriers(1,2) CHECK_FOR_COLLISION_p2_b1: mov Second_Is_Collided,0 ;second_player_x+players_width<x_barrier1 MOV AX,second_player_X ADD AX,PLAYERS_WIDTH CMP AX,X_BARRIER1 JNG CHECK_FOR_COLLISION_p2_b2 ;No collision will happen ;second_player_x>x_barrier1+ BARRIER_HORIZONTAL_SIZE MOV AX,X_BARRIER1 ADD AX, BARRIER_HORIZONTAL_SIZE CMP second_player_X,AX JNL CHECK_FOR_COLLISION_p2_b2 ;No collision will happen ;second_player_Y+players_HEIGHT<Y_barrier1 MOV AX,second_PLAYER_Y ADD AX,PLAYERS_HEIGHT CMP AX,Y_BARRIER1 JNG CHECK_FOR_COLLISION_p2_b2 ;No collision will happen ;second_player_Y>Y_barrier1+ BARRIER_VERTICAL_SIZE MOV AX,Y_BARRIER1 ADD AX, BARRIER_VERTICAL_SIZE CMP second_player_Y,AX JNL CHECK_FOR_COLLISION_p2_b2 ;No collision will happen ;There is collision , set his state to collided and check if he has immunity to collision before decreasing health mov Second_Is_Collided,1 ;check if he has immunity to collision cmp second_player_health_immunity , 0 JZ Decrease_second_health_1 JNZ Donot_Decrease_second_health_1 Decrease_second_health_1: DEC second_player_health ;give him immunity to not be affected by any barriers for this player MOV second_player_health_immunity,25 CALL draw_h2 Donot_Decrease_second_health_1: DEC second_player_health_immunity CHECK_FOR_COLLISION_p2_b2: ;second_player_x+players_width<x_barrier2 MOV AX,second_player_X ADD AX,PLAYERS_WIDTH CMP AX,X_BARRIER2 JNG EXIT2_PLAYERS_barriers_col ;No collision will happen ;second_player_x>x_barrier1+ BARRIER_HORIZONTAL_SIZE MOV AX,X_BARRIER2 ADD AX, BARRIER_HORIZONTAL_SIZE CMP second_player_X,AX JNL EXIT2_PLAYERS_barriers_col ;No collision will happen ;second_player_Y+players_HEIGHT<Y_barrier1 MOV AX,second_PLAYER_Y ADD AX,PLAYERS_HEIGHT CMP AX,Y_BARRIER2 JNG EXIT2_PLAYERS_barriers_col ;No collision will happen ;second_player_Y>Y_barrier1+ BARRIER_VERTICAL_SIZE MOV AX,Y_BARRIER2 ADD AX, BARRIER_VERTICAL_SIZE CMP second_player_Y,AX JNL EXIT2_PLAYERS_barriers_col ;No collision will happen ;There is collision , set his state to collided and check if he has immunity to collision before decreasing health mov Second_Is_Collided,1 ;check if he has immunity to collision cmp second_player_health_immunity , 0 JZ Decrease_second_health_2 JNZ Donot_Decrease_second_health_2 Decrease_second_health_2: DEC second_player_health ;give him immunity to not be affected by any barriers for this player MOV second_player_health_immunity,25 CALL draw_h2 Donot_Decrease_second_health_2: DEC second_player_health_immunity EXIT2_PLAYERS_barriers_col: RET second_player_barriers_coli ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_BOUNDARY_BARRIER1 PROC FAR MOV AX,X_BARRIER1 CMP AX,SCREEN_MAX_X JE DONT_DRAW ;-> IF X==THE LAST ROW OF PIXELS THEN DONT DRAW MOV BX,SCREEN_MAX_X- BARRIER_HORIZONTAL_SIZE CMP BX,AX ;IF(BX>=AX) THEN NOTHING,,,,, ELSE -> THE BARRIER LENGTH WILL BE OUT OF THE SCREEN AND HAVE TO BE SHORTENED JAE GOOD_LENGTH MOV LENMAX,SCREEN_MAX_X GOOD_LENGTH: MOV AX,Y_BARRIER1 CMP AX,SCREEN_MAX_Y JE DONT_DRAW ;; IF Y== LAST COLUMN OF PIXELS THEN DONT DRAW MOV BX,SCREEN_MAX_Y- BARRIER_VERTICAL_SIZE CMP BX,AX ;IF(BX>=AX) THEN NOTHING,,,,, ELSE -> THE BARRIER WIDTH WILL BE OUT OF THE SCREEN AND HAVE TO BE SHORTENED JAE GOOD_WIDTH MOV WIDMAX,SCREEN_MAX_Y GOOD_WIDTH: CALL FILLRECTANGLE DONT_DRAW: RET CHECK_BOUNDARY_BARRIER1 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_BOUNDARY_BARRIER2 PROC FAR MOV AX,X_BARRIER2 CMP AX,SCREEN_MAX_X JE DONT_DRAW2 ;-> IF X==THE LAST ROW OF PIXELS THEN DONT DRAW MOV BX,SCREEN_MAX_X- BARRIER_HORIZONTAL_SIZE ;IF(BX>=AX) THEN NOTHING,,,,, ELSE -> THE BARRIER LENGTH WILL BE OUT OF THE SCREEN AND HAVE TO BE SHORTENED CMP BX,AX JAE GOOD_LENGTH2 MOV LENMAX,SCREEN_MAX_X GOOD_LENGTH2: MOV AX,Y_BARRIER2 CMP AX,SCREEN_MAX_Y JE DONT_DRAW2 ;; IF Y== LAST COLUMN OF PIXELS THEN DONT DRAW MOV BX,SCREEN_MAX_Y- BARRIER_VERTICAL_SIZE CMP BX,AX ;IF(BX>=AX) THEN NOTHING,,,,, ELSE -> THE BARRIER WIDTH WILL BE OUT OF THE SCREEN AND HAVE TO BE SHORTENED JAE GOOD_WIDTH2 MOV WIDMAX,SCREEN_MAX_Y GOOD_WIDTH2: CALL FILLRECTANGLE DONT_DRAW2: RET CHECK_BOUNDARY_BARRIER2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_OVERLAPPING_BARRIER2 PROC FAR MOV AX,X_BARRIER2 CMP AX,X_BARRIER1 JGE CHECK_LESS_X1 ; if x2>= x1 then go check if x2 is less than x1+its length JMP END_CHECK_OVERLAPPING_BARRIER2 CHECK_LESS_X1: MOV AX,X_BARRIER1 ADD AX, BARRIER_HORIZONTAL_SIZE MOV BX,X_BARRIER2 CMP BX,AX JLE X2_OVERLAPS ;this means it overlaps JMP END_CHECK_OVERLAPPING_BARRIER2 X2_OVERLAPS: ;if barrier 2 overlaps with barrier 1,make barrier2 start at the end of barrier1 MOV AX,X_BARRIER1 ADD AX, BARRIER_HORIZONTAL_SIZE MOV X_BARRIER2,AX END_CHECK_OVERLAPPING_BARRIER2: RET CHECK_OVERLAPPING_BARRIER2 ENDP ERASE_RECTANGLE proc FAR ;MOV DI,0 PUSH LEN ERASE: PUSH LEN ERASEINNER: MOV AH,0CH MOV AL,background_color INC DI MOV BH,0H MOV CX,LEN MOV DX,WID INT 10H MOV BX,LENMAX INC LEN CMP BX,LEN JNZ ERASEINNER POP LEN INC WID MOV BX,WIDMAX CMP BX,WID JNZ ERASE POP WID RET ERASE_RECTANGLE ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;MOVING BARRIER 1,2 for level_1 ;MOVING BARRIER 1,2 MOVE_BARRIERS PROC FAR ;; DELETE THE OLD BARRIER1 BEFORE DRAWING IT IN THE NEW POSITION MOV AX,X_BARRIER1 MOV LEN,AX ADD AX,BARRIER_HORIZONTAL_SIZE MOV LENMAX,AX MOV AX,Y_BARRIER1 MOV WID,AX ADD AX,BARRIER_VERTICAL_SIZE MOV WIDMAX,AX CALL ERASE_RECTANGLE ;; DELETE THE OLD BARRIER1 BEFORE DRAWING IT IN THE NEW POSITION MOV AX,X_BARRIER2 MOV LEN,AX ADD AX,BARRIER_HORIZONTAL_SIZE MOV LENMAX,AX MOV AX,Y_BARRIER2 MOV WID,AX ADD AX,BARRIER_VERTICAL_SIZE MOV WIDMAX,AX CALL ERASE_RECTANGLE MOV AX,x_barrier1 MOV PRE_POSITION_X,AX MOV AX,Y_barrier1 MOV PRE_POSITION_Y,AX MOV AX,x_barrier2 MOV PRE_POSITION_X2,AX MOV AX,Y_barrier2 MOV PRE_POSITION_Y2,AX CHECK_BARRIER1_TOP: ;check if barrier1 reach top of page(before reaching health bar) CMP Y_BARRIER1 ,24 JLE BARRIER_1_REACHED_TOP JG BARRIERS_1_DIDNT_REACH_TOP BARRIER_1_REACHED_TOP: ;If reached top of page return it to the bottom Mov Y_BARRIER1,Initial_Y_Barrier1 ;Change the X-position of the Barrier check_x1: CMP X_BARRIER1,260;10<=x_barrier_1<= 260 JGE X1_REACH_MAX JL X1_DONT_REACH_MAX X1_REACH_MAX: SUB X_BARRIER1,200 JMP CHECK_BARRIER2_TOP X1_DONT_REACH_MAX: ADD X_BARRIER1,50 ;;10-->60-->120.....--->260 JMP CHECK_BARRIER2_TOP BARRIERS_1_DIDNT_REACH_TOP: ;moving barriers up SUB Y_Barrier1,1 ;5 steps by which the barriers are moving CHECK_BARRIER2_TOP: ;check if barrier2 reach top of page(before reaching health bar) CMP Y_BARRIER2 ,24 JLE BARRIER_2_REACHED_TOP JG BARRIERS_2_DIDNT_REACH_TOP BARRIER_2_REACHED_TOP: Mov Y_BARRIER2,Initial_Y_Barrier2 ;Randomize the X-position of the Barrier check_x2: CMP X_BARRIER2,10;10<=x_barrier_1<= 260 JLE X2_REACH_MAX JG X2_DONT_REACH_MAX X2_REACH_MAX: ADD X_BARRIER2,200 JMP X_TEMP_LABEL1 X2_DONT_REACH_MAX: SUB X_BARRIER2,50 ;;260-->210-->...-->10 JMP X_TEMP_LABEL1 BARRIERS_2_DIDNT_REACH_TOP: ;moving barriers up SUB Y_Barrier2,2 ;5 steps by which the barriers are moving X_TEMP_LABEL1: CALL first_player_barriers_coli CALL second_player_barriers_coli CALL draw_p1 CALL draw_p2 CALL DRAW_BARRIER1 CALL DRAW_BARRIER2 RET MOVE_BARRIERS ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;MOVING BARRIER 1,2 for level_2 MOVE_BARRIERS_2 PROC FAR ;; DELETE THE OLD BARRIER1 BEFORE DRAWING IT IN THE NEW POSITION MOV AX,X_BARRIER1 MOV LEN,AX ADD AX,BARRIER_HORIZONTAL_SIZE MOV LENMAX,AX MOV AX,Y_BARRIER1 MOV WID,AX ADD AX,BARRIER_VERTICAL_SIZE MOV WIDMAX,AX CALL ERASE_RECTANGLE ;; DELETE THE OLD BARRIER1 BEFORE DRAWING IT IN THE NEW POSITION MOV AX,X_BARRIER2 MOV LEN,AX ADD AX,BARRIER_HORIZONTAL_SIZE MOV LENMAX,AX MOV AX,Y_BARRIER2 MOV WID,AX ADD AX,BARRIER_VERTICAL_SIZE MOV WIDMAX,AX CALL ERASE_RECTANGLE MOV AX,x_barrier1 MOV PRE_POSITION_X,AX MOV AX,Y_barrier1 MOV PRE_POSITION_Y,AX MOV AX,x_barrier2 MOV PRE_POSITION_X2,AX MOV AX,Y_barrier2 MOV PRE_POSITION_Y2,AX CHECK_BARRIER1_TOP_2: ;check if barrier1 reach top of page(before reaching health bar) CMP Y_BARRIER1 ,24 JLE BARRIER_1_REACHED_TOP_2 JG BARRIERS_1_DIDNT_REACH_TOP_2 BARRIER_1_REACHED_TOP_2: ;If reached top of page return it to the bottom Mov Y_BARRIER1,Initial_Y_Barrier1 ;Change the X-position of the Barrier BARRIERS_1_DIDNT_REACH_TOP_2: ;moving barriers up SUB Y_Barrier1,1 ;5 steps by which the barriers are moving check_x1_2: CMP X_BARRIER1,260;10<=x_barrier_1<= 260 JGE X1_REACH_MAX_2 JL X1_DONT_REACH_MAX_2 X1_REACH_MAX_2: SUB X_BARRIER1,200 JMP CHECK_BARRIER2_TOP_2 X1_DONT_REACH_MAX_2: ADD X_BARRIER1,2 ;;10-->60-->120.....--->260 JMP CHECK_BARRIER2_TOP_2 CHECK_BARRIER2_TOP_2: ;check if barrier2 reach top of page(before reaching health bar) CMP Y_BARRIER2 ,24 JLE BARRIER_2_REACHED_TOP_2 JG BARRIERS_2_DIDNT_REACH_TOP_2 BARRIER_2_REACHED_TOP_2: Mov Y_BARRIER2,Initial_Y_Barrier2 ;Randomize the X-position of the Barrier BARRIERS_2_DIDNT_REACH_TOP_2: ;moving barriers up SUB Y_Barrier2,2 ;5 steps by which the barriers are moving check_x2_2: CMP X_BARRIER2,10;10<=x_barrier_1<= 260 JLE X2_REACH_MAX_2 JG X2_DONT_REACH_MAX_2 X2_REACH_MAX_2: ADD X_BARRIER2,200 JMP X_TEMP_LABEL_2 X2_DONT_REACH_MAX_2: SUB X_BARRIER2,1 ;;260-->210-->...-->10 JMP X_TEMP_LABEL_2 X_TEMP_LABEL_2: CALL first_player_barriers_coli CALL second_player_barriers_coli CALL draw_p1 CALL draw_p2 CALL DRAW_BARRIER1 CALL DRAW_BARRIER2 RET MOVE_BARRIERS_2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to draw the Red Laser from Left to Right (Just a colored line from start to end) Draw_RED_LASER_LEFT_TO_RIGHT PROC FAR mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov cx,Red_Laser_Start_X mov dx,first_player_Y add dx,Player_Shooter_Y_Offset Continue_Red_LASER_1: mov al,RED Int 10h INC dx mov al, Yellow INT 10h INC dx mov al, Yellow INT 10h INC dx mov al, Red INT 10h cmp cx,Red_Laser_End_X jz END_Draw_Red_Laser_1 inc cx Sub dx,3 jmp Continue_Red_LASER_1 End_Draw_Red_Laser_1: mov cx,0ffffh wait1: DEC CX CMP CX,0 JNE wait1 mov cx,Red_Laser_Start_X mov dx,first_player_Y add dx,Player_Shooter_Y_Offset Clear_Red_Laser_1: mov al,background_color Int 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h cmp cx,Red_Laser_End_X jz END_Red_Laser_1 inc cx Sub dx,3 jmp Clear_Red_LASER_1 END_Red_Laser_1: RET Draw_RED_LASER_LEFT_TO_RIGHT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to draw the Red Laser from Right to Left (Just a colored line from start to end) Draw_RED_LASER_RIGHT_TO_LEFT PROC mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov cx,Red_Laser_Start_X mov dx,first_player_Y add dx,Player_Shooter_Y_Offset Continue_Red_LASER_2: mov al,RED Int 10h INC dx mov al, Yellow INT 10h INC dx mov al, Yellow INT 10h INC dx mov al, Red INT 10h cmp cx,Red_Laser_End_X jz END_Draw_Red_Laser_2 dec cx Sub dx,3 jmp Continue_Red_LASER_2 END_Draw_Red_Laser_2: mov cx,0ffffh wait2: DEC CX CMP CX,0 JNE wait2 mov cx,Red_Laser_Start_X mov dx,first_player_Y add dx,Player_Shooter_Y_Offset Clear_Red_LASER_2: mov al,background_color Int 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h cmp cx,Red_Laser_End_X jz END_Red_Laser_2 dec cx Sub dx,3 jmp Clear_Red_LASER_2 END_Red_Laser_2: RET Draw_RED_LASER_RIGHT_TO_LEFT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to draw the Blue Laser from Left to Right (Just a colored line from start to end) Draw_BLUE_LASER_LEFT_TO_RIGHT PROC mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov cx,Blue_Laser_Start_X mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset Continue_Blue_LASER_1: mov al,Dark_Blue Int 10h INC dx mov al, Light_Blue INT 10h INC dx mov al, Light_Blue INT 10h INC dx mov al, Dark_Blue INT 10h cmp cx,Blue_Laser_End_X jz END_Draw_Blue_Laser_1 inc cx Sub dx,3 jmp Continue_Blue_LASER_1 END_Draw_Blue_Laser_1: mov cx,0ffffh wait3: DEC CX CMP CX,0 JNE wait3 mov cx,Blue_Laser_Start_X mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset Clear_Blue_LASER_1: mov al,background_color Int 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h cmp cx,Blue_Laser_End_X jz END_Blue_Laser_1 inc cx Sub dx,3 jmp Clear_Blue_LASER_1 END_Blue_Laser_1: RET Draw_BLUE_LASER_LEFT_TO_RIGHT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to draw the Blue Laser from Right to Left (Just a colored line from start to end) Draw_BLUE_LASER_RIGHT_TO_LEFT PROC mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov cx,Blue_Laser_Start_X mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset Continue_Blue_LASER_2: mov al,Dark_Blue Int 10h INC dx mov al, Light_Blue INT 10h INC dx mov al, Light_Blue INT 10h INC dx mov al, Dark_Blue INT 10h cmp cx,Blue_Laser_End_X jz END_Draw_Blue_Laser_2 dec cx Sub dx,3 jmp Continue_Blue_LASER_2 End_Draw_Blue_Laser_2: mov cx,0ffffh wait4: DEC CX CMP CX,0 JNE wait4 mov cx,Blue_Laser_Start_X mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset Clear_Blue_LASER_2: mov al,background_color Int 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h INC dx mov al, background_color INT 10h cmp cx,Blue_Laser_End_X jz END_Blue_Laser_2 dec cx Sub dx,3 jmp Clear_Blue_LASER_2 END_Blue_Laser_2: RET Draw_BLUE_LASER_RIGHT_TO_LEFT ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to make the first Player attack from Left to Right First_Attack_Left_TO_Right PROC FAR ;First we set the coordinates for the drawing mov ax,first_player_X Add ax,PLAYERS_WIDTH mov Red_Laser_Start_X,Ax ;git the first thing that will hit the laser mov bx,WINDOW_WIDTH ;BX will contain the end of the laser for the rest of the function sub bx,2 ;check the barriers, first ask if it is in the same Y Area, then ask for the X area ; *---------------------------- | ; ------------* | Barrier At Right | | ; |At left: | | | | The window wall ; | Beam | | | | ; ------------* | | | ; *----------------------------- | Red_Laser1_Colli_First_Barrier: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier1 JL Red_Laser1_Colli_Second_Barrier ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Y_barrier1 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Red_Laser1_Colli_Second_Barrier ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X cmp ax,X_BARRIER1 ;Check the Barrier Position relative to the Player JGE Red_Laser1_Colli_Second_Barrier ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER1 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? cmp ax,bx JG Red_Laser1_Colli_Second_Barrier ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the second barrier Red_Laser1_Colli_Second_Barrier: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier2 JL Red_Laser1_Colli_Second_Player ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Y_barrier2 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Red_Laser1_Colli_Second_Player ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X cmp ax,X_BARRIER2 ;Check the Barrier Position relative to the Player JGE Red_Laser1_Colli_Second_Player ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER2 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? cmp ax,bx JG Red_Laser1_Colli_Second_Player ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the blue player Red_Laser1_Colli_Second_Player: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Second_player_Y JL Finish_First_Attack_Left_TO_Right ;all the Y of the laser < starting Y of the Second Player--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Second_player_Y add cx,PLAYERS_HEIGHT ;now cx has the last Y of the Player cmp dx,cx JG Finish_First_Attack_Left_TO_Right ;all the Y of the laser > ending Y of the Player--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X cmp ax,second_player_X ;Check the Second Player Position relative to the Player JGE Finish_First_Attack_Left_TO_Right ;The Second Player is Behind the player (if player is collided with the barrier we won't fire ) mov ax,Second_player_X ;when reached here, it means that the Second Player Will block my way. But is it the first thing to block ? cmp ax,bx JG Finish_First_Attack_Left_TO_Right ;if this new AX(second_player_X) > BX ---> Then it's not the first thing to Block my way mov bx,ax mov second_player_Freeze,25 ;make the second player freeze Finish_First_Attack_Left_TO_Right: mov Red_Laser_End_X,bx Call Draw_RED_LASER_LEFT_TO_RIGHT RET First_Attack_Left_TO_Right ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to make the first Player attack from Left to Right First_Attack_Right_TO_Left PROC FAR ;First we set the coordinates for the drawing mov ax,first_player_X mov Red_Laser_Start_X,Ax ;git the first thing that will hit the laser mov bx,2 ;BX will contain the end of the laser for the rest of the function ;check the barriers, first ask if it is in the same Y Area, then ask for the X area ; | ----------------------------* ;The | | Barrier At Left | *------------ ;Window | | | |At Right: | ;Wall | | | | Beam | ; | | | *------------ ; | -----------------------------* Red_Laser2_Colli_First_Barrier: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier1 JL Red_Laser2_Colli_Second_Barrier ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Y_barrier1 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Red_Laser2_Colli_Second_Barrier ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X mov dx,X_Barrier1 Add dx,BARRIER_HORIZONTAL_SIZE ;now dx has the right most X_Position of the Barrier cmp ax,DX ;Check the Barrier Position relative to the Player JLE Red_Laser2_Colli_Second_Barrier ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER1 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? ADD ax,BARRIER_HORIZONTAL_SIZE cmp ax,bx JL Red_Laser2_Colli_Second_Barrier ;if this new AX(X_Barrier) < BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the second barrier Red_Laser2_Colli_Second_Barrier: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier2 JL Red_Laser2_Colli_Second_Player ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Y_barrier2 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Red_Laser2_Colli_Second_Player ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X mov dx,X_BARRIER2 Add dx,BARRIER_HORIZONTAL_SIZE ;now dx has the right most X_Position of the Barrier cmp ax,DX ;Check the Barrier Position relative to the Player JLE Red_Laser2_Colli_Second_Player ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER2 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? ADD ax,BARRIER_HORIZONTAL_SIZE cmp ax,bx JL Red_Laser2_Colli_Second_Player ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the blue player Red_Laser2_Colli_Second_Player: mov dx,First_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the Red Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Second_player_Y JL Finish_First_Attack_Right_TO_Left ;all the Y of the laser < starting Y of the Second Player--> No collision sub dx,LASER_SIZE ;now the dx has the Red Laser Start Y mov cx,Second_player_Y add cx,PLAYERS_HEIGHT ;now cx has the last Y of the Player cmp dx,cx JG Finish_First_Attack_Right_TO_Left ;all the Y of the laser > ending Y of the Player--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Red_Laser_Start_X mov dx,second_player_X ADD dx,PLAYERS_WIDTH cmp ax,DX ;Check the Second Player Position relative to the Player JLE Finish_First_Attack_Right_TO_Left ;The Second Player is Behind the player (if player is collided with the barrier we won't fire ) mov ax,Second_player_X ;when reached here, it means that the Second Player Will block my way. But is it the first thing to block ? add ax,PLAYERS_WIDTH cmp ax,bx JL Finish_First_Attack_Right_TO_Left ;if this new AX(second_player_X) > BX ---> Then it's not the first thing to Block my way mov bx,ax mov second_player_Freeze,25 ;make the second player freeze Finish_First_Attack_Right_TO_Left: mov Red_Laser_End_X,bx Call Draw_RED_LASER_Right_TO_Left RET First_Attack_Right_TO_Left ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to make the Second Player attack from Left to Right Second_Attack_Left_TO_Right PROC FAR ;First we set the coordinates for the drawing mov ax,Second_player_X Add ax,PLAYERS_WIDTH mov Blue_Laser_Start_X,Ax ;git the first thing that will hit the laser mov bx,WINDOW_WIDTH ;BX will contain the end of the laser for the rest of the function sub bx,2 ;check the barriers, first ask if it is in the same Y Area, then ask for the X area ; *---------------------------- | ; ------------* | Barrier At Right | | ; |At left: | | | | The window wall ; | Beam | | | | ; ------------* | | | ; *----------------------------- | Blue_Laser1_Colli_First_Barrier: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier1 JL Blue_Laser1_Colli_Second_Barrier ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,Y_barrier1 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Blue_Laser1_Colli_Second_Barrier ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X cmp ax,X_BARRIER1 ;Check the Barrier Position relative to the Player JGE Blue_Laser1_Colli_Second_Barrier ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER1 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? cmp ax,bx JG Blue_Laser1_Colli_Second_Barrier ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the second barrier Blue_Laser1_Colli_Second_Barrier: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier2 JL Blue_Laser1_Colli_first_Player ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,Y_barrier2 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Blue_Laser1_Colli_first_Player ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X cmp ax,X_BARRIER2 ;Check the Barrier Position relative to the Player JGE Blue_Laser1_Colli_First_Player ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER2 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? cmp ax,bx JG Blue_Laser1_Colli_First_Player ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the BLUE player Blue_Laser1_Colli_First_Player: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,First_player_Y JL Finish_Second_Attack_Left_TO_Right ;all the Y of the laser < starting Y of the Second Player--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,first_player_Y add cx,PLAYERS_HEIGHT ;now cx has the last Y of the Player cmp dx,cx JG Finish_Second_Attack_Left_TO_Right ;all the Y of the laser > ending Y of the Player--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X cmp ax,First_player_X ;Check the Second Player Position relative to the Player JGE Finish_Second_Attack_Left_TO_Right ;The Second Player is Behind the player (if player is collided with the barrier we won't fire ) mov ax,first_player_X ;when reached here, it means that the Second Player Will block my way. But is it the first thing to block ? cmp ax,bx JG Finish_Second_Attack_Left_TO_Right ;if this new AX(second_player_X) > BX ---> Then it's not the first thing to Block my way mov bx,ax mov First_player_Freeze,25 ;make the first player freeze Finish_Second_Attack_Left_TO_Right: mov Blue_Laser_End_X,bx Call Draw_Blue_LASER_LEFT_TO_RIGHT RET Second_Attack_Left_TO_Right ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This function is to make the Second Player attack from Left to Right Second_Attack_Right_TO_Left PROC FAR ;First we set the coordinates for the drawing mov ax,Second_player_X mov Blue_Laser_Start_X,Ax ;git the first thing that will hit the laser mov bx,2 ;BX will contain the end of the laser for the rest of the function ;check the barriers, first ask if it is in the same Y Area, then ask for the X area ; | ----------------------------* ;The | | Barrier At Left | *------------ ;Window | | | |At Right: | ;Wall | | | | Beam | ; | | | *------------ ; | -----------------------------* Blue_Laser2_Colli_First_Barrier: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier1 JL Blue_Laser2_Colli_Second_Barrier ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,Y_barrier1 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Blue_Laser2_Colli_Second_Barrier ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X mov dx,X_Barrier1 Add dx,BARRIER_HORIZONTAL_SIZE ;now dx has the right most X_Position of the Barrier cmp ax,DX ;Check the Barrier Position relative to the Player JLE Blue_Laser2_Colli_Second_Barrier ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER1 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? ADD ax,BARRIER_HORIZONTAL_SIZE cmp ax,bx JL Blue_Laser2_Colli_Second_Barrier ;if this new AX(X_Barrier) < BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the second barrier Blue_Laser2_Colli_Second_Barrier: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,Y_barrier2 JL Blue_Laser2_Colli_First_Player ;all the Y of the laser < starting Y of the Barrier--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,Y_barrier2 add cx,BARRIER_VERTICAL_SIZE ;now cx has the last Y of the Barrier cmp dx,cx JG Blue_Laser2_Colli_First_Player ;all the Y of the laser > ending Y of the Barrier--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X mov dx,X_BARRIER2 Add dx,BARRIER_HORIZONTAL_SIZE ;now dx has the right most X_Position of the Barrier cmp ax,DX ;Check the Barrier Position relative to the Player JLE Blue_Laser2_Colli_First_Player ;The Barrier is Behind the player (if player is collided with the barrier we won't fire ) mov ax,X_BARRIER2 ;when reached here, it means that the Barrier Will block my way. But is it the first thing to block ? ADD ax,BARRIER_HORIZONTAL_SIZE cmp ax,bx JL Blue_Laser2_Colli_First_Player ;if this new AX(X_Barrier) > BX ---> Then it's not the first thing to Block my way mov bx,ax ;check the BLUE player Blue_Laser2_Colli_First_Player: mov dx,Second_player_Y add dx,Player_Shooter_Y_Offset ;now the dx has the BLUE Laser Start Y add dx,LASER_SIZE ;dx --->the laser ending Y cmp dx,First_player_Y JL Finish_Second_Attack_Right_TO_Left ;all the Y of the laser < starting Y of the Second Player--> No collision sub dx,LASER_SIZE ;now the dx has the BLUE Laser Start Y mov cx,First_player_Y add cx,PLAYERS_HEIGHT ;now cx has the last Y of the Player cmp dx,cx JG Finish_Second_Attack_Right_TO_Left ;all the Y of the laser > ending Y of the Player--> No collision ;;;;If it reached here then, there will be a collision in the Y,check for X mov ax, Blue_Laser_Start_X mov dx,First_player_X ADD dx,PLAYERS_WIDTH cmp ax,DX ;Check the Second Player Position relative to the Player JLE Finish_Second_Attack_Right_TO_Left ;The Second Player is Behind the player (if player is collided with the barrier we won't fire ) mov ax,First_player_X ;when reached here, it means that the Second Player Will block my way. But is it the first thing to block ? add ax,PLAYERS_WIDTH cmp ax,bx JL Finish_Second_Attack_Right_TO_Left ;if this new AX(second_player_X) > BX ---> Then it's not the first thing to Block my way mov bx,ax mov first_player_Freeze,25 ;make the first player freeze Finish_Second_Attack_Right_TO_Left: mov Blue_Laser_End_X,bx Call Draw_Blue_LASER_Right_TO_Left RET Second_Attack_Right_TO_Left ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;description Game_over_screen PROC mov ah,0ch ;this means with int 10h ---> you're drawing a pixel mov di,0 mov al,img[DI] ;the pixel color mov bh,0 ;the page number mov cx,x_position ;the starting x-position (column) add cx,imgW ;as we draw in the reversed order mov dx,y_position ;the starting y-position (row) add dx,imgH ;as we draw in the reversed order ;here we loop for the image size (player_size) fill_over: cmp al,16 jz pass_the_pixel_over int 10h pass_the_pixel_over: inc di mov al,img[DI] dec cx cmp cx,x_position jnz fill_over ;if not zero so we continue to the same row mov cx,x_position ;the starting x-position (column) add cx,imgw ;as we draw in the reversed order dec dx ;if not zero so we continue to draw the background cmp dx,y_position jnz fill_over ret Game_over_screen ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;This function is to take Players name Before entering the game Take_User_Data PROC FAR Start: CALL FAR PTR CLEAR_SCREEN ;clear the screen before taking the names mov ah,0 mov al,02 int 10h ;this to choose text mode mov ah,2 mov dx,0a0ah int 10h ;Position the Cursor ;PRINT_Messages Name_Message_1 Add DH,2 INT 10H PRINT_Messages Name_Message_1 ;This MACRO will print a message to ask players to enter their names Add DH,2 INT 10H ;Position the Cursor below it by two rows Take_First_name: ;Start taking the first name untill it reaches the maximum/or the player presses enter mov AH,0AH mov dx,offset First_Player_Name int 21h CMP First_Player_Name[2],65 JGE GREATER_Than_65 JL Wrong_start GREATER_Than_65: CMP First_Player_Name[2],90 JLE Between_65_90_or_97_122 JG Greater_than_90 Greater_than_90: CMP First_Player_Name[2],97 JGE GREATER_Than_97 JL Wrong_start GREATER_Than_97: CMP First_Player_Name[2],122 JLE Between_65_90_or_97_122 JG Wrong_start Wrong_start: mov ah,2 mov dx,1620h int 10h ;Position the Cursor PRINT_Messages Invalid_Start_msg2 ;;;;;delay;;;;;; mov cx, 25h ;HIGH WORD. mov dx, 2420h ;LOW WORD. mov ah, 86h ;WAIT. int 15h Jmp Start Between_65_90_or_97_122: MOV AH,2 ;MOVE CURSOR TO PRINT WAITING MESSAGE MOV DX,140fH int 10h mov ah,9 mov dx,offset WAITING_MESSAGE int 21h mov di,offset First_Player_Name mov si ,offset Second_Player_Name mov cl, First_Player_Name[1] ;actual size ;;;;;;;;;;;;;;;;;;;;;; SEND THE ACUTUAL SIZE OF PLAYER NAME mov dx,3fdh ;wait till we are able to send WAIT_FOR_SEND: in al,dx test al,00100000b jz WAIT_FOR_SEND ;WE CAN SEND NOW mov dx,3f8h mov al,cl out dx,al ;;;;;;;;;;;;; RECEIVE THE ACUTUAL SIZE OF PLAYER NAME CHECK_size_AGAIN: mov dx,3fdh in al,dx test al,1 jz CHECK_size_AGAIN ;if nothing received go to the begining ;if received mov dx,03f8h in al,dx mov ch,al add di,2 add si,2 ;;;;;;;;;;;;;;;;;;;;; SEND AND RECEIVE THE PLAYER NAMES ;;;;; START_NAME_SEND_REC: mov dx,3fdh ;wait till we are able to send in al,dx test al,00100000b jz CHECK_AGAIN_SR cmp cl,0 je reso ;when we are able send mov dx,3f8h mov al,[di] out dx,al inc di dec cl reso: mov dx,3fdh in al,dx test al,1 jz CHECK_AGAIN_SR ;if nothing received go to the begining ;if received mov dx,03f8h in al,dx mov [si],al inc si dec ch CHECK_AGAIN_SR:;check if we finished and if not go to the begining cmp cl,0 jnz START_NAME_SEND_REC cmp ch,0 jnz START_NAME_SEND_REC ;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN MENU ENDED -> GO TO MENUBAR ;;;;;;;;; ;; CLEAR SCREEN ;; mov ah,0 mov al,3 int 10h ;;;;;;;SET CURSOR POSITION AND PRINT PLAY_AGAINST MESSAGE mov ah,2 mov dx,0a0ah int 10h mov ah,9 mov dx,offset play_against_meg int 21h add dl,2 ;;;;;;;SET CURSOR POSITION AND PRINT PLAYER NAME MESSAGE mov ah,2 mov dx,0d23h int 10h mov ah,9 mov dx,offset Second_Player_Name+1 int 21h ;--------- DELAY FOR 5 SECOND ---------------- mov cx, 50h ;HIGH WORD. mov dx, 4840h ;LOW WORD. mov ah, 86h ;WAIT. int 15h Temp_End: RET Take_User_Data ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main_menu PROC FAR FIRST_MENU: mov CHAT_MASTER,0 mov GAME_MASTER,0 MOV CHAT_SLAVE,0 MOV CHAT_SLAVE,0 mov ah,00 mov al,02 int 10h mov ah,2 mov dx,0a13h int 10h PRINT_Messages CHAT ADD DH,2 INT 10h PRINT_Messages Sky_GAME ADD DH,2 INT 10h PRINT_Messages END_GAME_mess ;;;;;;;;;;;; DRAW LINE ;;;;;;;;;;;;; mov ah,02 mov dx, 1600h int 10h MOV AH,09H MOV AL,'-' MOV BH,0 MOV BL,02 MOV CX ,80 INT 10H ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK FOR INVITATIONS ;;;;;;;;;;;;; CHECK_INVITATION: mov dx,3fdh in al,dx test al,1 jz CHECK_INVITAT_again jmp if_receive ; CHECK_INVITAT_again: ; mov ah,1 ; int 16h ; jz CHECK_INVITATION if_receive: mov dx,03f8h in al,dx cmp AL,3BH ;CHECK IF F1 PRESSED CHAT INVENTATION jE FAR PTR GO_CHAT_INVET_REC CMP Al,3CH ;CHECK IF F2 PRESSED GAME INVENTATION JE FAR PTR GO_GAME_INVENT_REC_TEMP CMP AL,01 JE END_MAIN_MENU_REC_TEMP CHECK_INVITAT_again: mov ah,1 int 16h jz CHECK_INVITATION ;;;;;;;;;;;;;;;;;; SEND INVITAION ;;;;;;;;;;;;;;;;;; MOV AH,0 INT 16h CMP AH,3BH ;f1 JE GO_CHAT_INVET_SEND CMP AH,3CH ;f2 JE GO_GAME_INVENT_SEND_TEMP CMP AH,01 JE END_MAIN_MENU_SEND_TEMP JMP CHECK_INVITATION ;;;;;;;;;;;;;;;;;;; IF JUMP TO GO_CHAT_INVET_SEND ;;;;;;;;;;;; GO_CHAT_INVET_SEND: ;;;;; MOVE THE CURSOR TO THE POSITION IN WHICH SENT INVETATION APPEAR CMP CHAT_SLAVE,1 JE RECIEVE_CHAT CALL FAR PTR CHAT_INVET_M_PROC JMP CHECK_INVITATION RECIEVE_CHAT: MOV DX,3fdh loop_until_ready_37: in al,dx test al,00100000b jz loop_until_ready_37 ;when we are able send mov dx,3f8h mov al,3BH out dx,al JMP chatpage ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; IF I RECEIVE A CHAT INVITAION ;;;;;;; GO_GAME_INVENT_SEND_TEMP: JMP GO_GAME_INVENT_SEND GO_GAME_INVENT_REC_TEMP: JMP GO_GAME_INVENT_REC Start_Game_temp: jmp Start_Game END_MAIN_MENU_SEND_TEMP: JMP END_MAIN_MENU_SEND END_MAIN_MENU_REC_TEMP: JMP END_MAIN_MENU_REC GO_CHAT_INVET_REC: cmp CHAT_MASTER,1 jE ACCEPT MOV ah,02 ;;SLAVE mov dx, 1800h int 10h MOV AH,09H MOV AL,' ' MOV BH,0 MOV BL,02 MOV CX ,80 INT 10H MOV AH,02 MOV DX,1800H INT 10H PRINT_Messages Second_Player_Name+1 ADD DL,2 PRINT_Messages CHAT_INVITATION_REC_MEG MOV CHAT_SLAVE,1 MOV GAME_SLAVE,0 jmp CHECK_INVITAT_again ACCEPT: ; mov dx,3fdh ; loop_until_ready_2: ; in al,dx ; test al,00100000b ; jz loop_until_ready_2 ; ;;;;;;;;;;; now we can send ;;;;;;;;;;;;;;;;;; ; mov dx,3f8h ; mov al,3BH ; out dx,al jmp chatpage ;----------------------------------------------------; GO_GAME_INVENT_SEND: ;;;;;;;; CLEAR THE LINE 23 BEFORE PRINTING THE NEXT INVITATION MSG ;;;;;;; ;;; MOVE THE CURSOR TO WRITE cmp GAME_SLAVE,1 ; JE receive_level mov ah,02 mov dx, 1700h int 10h MOV AH,09H MOV AL,' ' MOV BH,0 MOV BL,02 MOV CX ,80 INT 10H MOV AH,02 MOV DX , 1700H INT 10H PRINT_Messages GAME_INVITATION_SEND_MSG add dl,2 PRINT_Messages Second_Player_Name ;;;; CHECK IF REGISTER IS EMPTY ;;; MOV DX,3fdh loop_until_ready_3: in al,dx test al,00100000b jz loop_until_ready_3 ;when we are able send mov dx,3f8h mov al,3CH ;F2 ->GAME out dx,al mov GAME_MASTER,1 MOV CHAT_MASTER,0 JMP CHECK_INVITATION receive_level: MOV DX,3fdh loop_until_ready_33: in al,dx test al,00100000b jz loop_until_ready_33 ;when we are able send mov dx,3f8h mov al,3CH out dx,al call far ptr CLEAR_SCREEN call far ptr draw_background CALL FAR PTR draw_p1 CALL FAR PTR draw_p2 MOV DX,3fdh loop_until_ready_34: in al,dx test al,1 jz loop_until_ready_34 ;when we are able send mov dx,3f8h in al,dx mov level,al jmp LETS_START_GAME ;--------------------------------------------------------; GO_GAME_INVENT_REC: CMP GAME_MASTER,1 JE ACCEPT_GAME mov game_slave,1 MOV CHAT_SLAVE,0 MOV ah,02 mov dx, 1800h int 10h MOV AH,09H MOV AL,' ' MOV BH,0 MOV BL,02 MOV CX ,80 INT 10H MOV AH,02 MOV DX,1800H INT 10H mov ah,9 mov dx,offset Second_Player_Name+1 int 21h mov ah,9 mov dx,offset GAME_INVITATION_REC_MSG int 21h jmp CHECK_INVITAT_again ACCEPT_GAME: ; mov dx,3fdh ; loop_until_ready_25: ; in al,dx ; test al,00100000b ; jz loop_until_ready_25 ; ;;;;;;;;;;; now we can send ;;;;;;;;;;;;;;;;;; ; mov dx,3f8h ; mov al,3CH ; out dx,al JMP Which_level ABCD: mov dx,3fdh loop_until_ready_5: in al,dx test al,00100000b jz loop_until_ready_5 ;;;;;;;;;;; now we can send ;;;;;;;;;;;;;;;;;; mov dx,3f8h mov al,bl out dx,al mov level,bl LETS_START_GAME: CALL FAR PTR Start_Game jmp First_menu ;;----------------------------------------------------------------------- END_MAIN_MENU_SEND: mov dx,3fdh loop_until_ready_66: in al,dx test al,00100000b jz loop_until_ready_66 mov dx,3f8h mov al,01H ;F1 ->CHAT out dx,al JMP END_GAME END_MAIN_MENU_REC: JMP END_GAME chatpage: CALL FAR PTR CHAT_MODULE jmp FIRST_MENU Which_level: mov ah,00 mov al,02 int 10h mov ah,2 mov dx,01113h int 10h PRINT_Messages levelone ADD DH,2 INT 10h PRINT_Messages leveltwo mov ah,0 int 16h cmp al,49 mov bl ,al JE ABCD cmp al,50 mov bl ,al JE ABCD JMP Which_level End_Game : RET Main_menu ENDP chose_which_level proc FAR RET chose_which_level ENDP CHAT_INVET_M_PROC PROC FAR mov ah,02 mov dx, 1700h int 10h MOV AH,09H MOV AL,' ' MOV BH,0 MOV BL,02 MOV CX ,80 INT 10H MOV AH,02 MOV DX,1700H INT 10H PRINT_Messages CHAT_INVITATION_SEND_MEG ADD DL,2 PRINT_Messages Second_Player_Name+1 mov dx,3fdh loop_until_ready: in al,dx test al,00100000b jz loop_until_ready ;;;;;;;;;;; now we can send ;;;;;;;;;;;;;;;;;; mov dx,3f8h mov al,3BH ;F1 ->CHAT out dx,al mov GAME_MASTER,0 MOV CHAT_MASTER,1 ;;;THE PLAYER HOW SENT THE CHAT INVITAION IS THE RET CHAT_INVET_M_PROC ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Start_Game PROC FAR CALL FAR PTR CLEAR_SCREEN ;clear the screen before entering the game call FAR PTR draw_background ;draw the background of the Game window call FAR PTR draw_h1 call FAR PTR draw_h2 CALL FAR PTR draw_p1 CALL FAR PTR draw_p2 call FAR PTR DRAW_BARRIER1 call FAR PTR DRAW_BARRIER2 ;;;;;;;;;;;GAME LOOP FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_TIME: MOV AH,2Ch ;get the system time INT 21h ;CH = hour CL = minute DH = second DL = 1/100 seconds CMP DL,TIME_AUX ;is the current time equal to the previous one(TIME_AUX)? JE CHECK_TIME ;if it is the same, check again ;if it's different, then draw, move, etc. MOV TIME_AUX,DL ;update time cmp level,49 JZ level1 level2: CALL FAR PTR MOVE_BARRIERS_2 level1: CALL FAR PTR MOVE_BARRIERS ;check if health is zero, Game Over mov ax,first_player_health cmp ax,0 jz Game_Over ;check if health is zero, Game Over mov ax,second_player_health cmp ax,0 jz Game_Over CALL FAR PTR MOVE_PLAYERS ;;;;;;;;;;;;;Flushing the keyboard buffer mov ah,0ch mov al,0 int 21h JMP CHECK_TIME ;after everything checks time again ;;;;;;;;;;;GAME ENDING FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;; Game_Over: CALL FAR PTR CLEAR_SCREEN ;clear the screen before entering the game ; call FAR PTR draw_background call far PTR Game_over_screen mov ax,second_player_health cmp ax,0 jz first_wins mov ax,first_player_health cmp ax,0 jz second_wins jmp final first_wins: mov first_player_X,10 mov first_player_y,90 call FAR PTR draw_p1 mov ah,2 mov dl,20 mov dh,90 int 10h PRINT_Messages First_player_wins ; MOV BP, OFFSET first_player_wins+1 ; ES: BP POINTS TO THE TEXT ; MOV AH, 13H ; WRITE THE STRING ; MOV AL, 01H; ATTRIBUTE IN BL, MOVE CURSOR TO THAT POSITION ; XOR BH,BH ; VIDEO PAGE = 0 ; MOV BL, 0eh ;YELLOW ; MOV CX, 17 ; LENGTH OF THE STRING ; MOV DH, 12 ;ROW TO PLACE STRING ; MOV DL, 12 ; COLUMN TO PLACE STRING ; INT 10H jmp final second_wins: mov second_player_X,10 mov second_player_Y,90 call FAR PTR draw_p2 mov ah,2 mov dl,20 mov dh,90 int 10h PRINT_Messages Second_player_wins ; MOV BP, OFFSET second_player_wins ; ES: BP POINTS TO THE TEXT ; MOV AH, 13H ; WRITE THE STRING ; MOV AL, 01H; ATTRIBUTE IN BL, MOVE CURSOR TO THAT POSITION ; XOR BH,BH ; VIDEO PAGE = 0 ; MOV BL, 01h ;BLUE ; MOV CX, 20 ; LENGTH OF THE STRING ; MOV DH, 12 ;ROW TO PLACE STRING ; MOV DL, 12 ; COLUMN TO PLACE STRING ; INT 10H final: mov ah,2 mov dx,1100h int 10h ;Position the Cursor ADD DH,3 PRINT_Messages GAME_OVER_mess mov ah,0 int 16h cmp AH,01 JNE Final ;Now Send it to the reciever mov dx , 3FDH ; Line Status Register Send_ESC_GAME_OVER_AGAIN: In al , dx ;Read Line Status test al , 00100000b JZ Send_ESC_GAME_OVER_AGAIN ;Not empty ;If empty put the VALUE in Transmit data register mov dx , 3F8H ; Transmit data register mov al,01 ;ESC KEY SCAN CODE out dx , al ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Start_RECIEVING_VALUES: ;Wait for the recived ESC from other user ;Check that Data is Ready mov dx , 3FDH ; Line Status Register Recieve_ESC_GAME_OVER_AGAIN: in al , dx test al , 1 JZ Recieve_ESC_GAME_OVER_AGAIN ;Not Ready ;If Ready read the VALUE in Receive data register mov dx , 03F8H in al , dx cmp al,01 ;ESC KEY SCAN CODE JNE Start_RECIEVING_VALUES RESET_ALL_DATA: mov first_player_X,50 ;The starting X-position of player one mov first_player_Y , 50 ;The starting Y-position of player one mov first_player_health , 5 ;Number of hearts to the first player mov first_player_health_immunity , 0 ;when the player gets hit by barrier, he gains an immunity to resist the barriers mov first_player_Freeze , 0 ;Duration for which the player is frozen mov First_Is_Collided , 0 ;Boolean Variable To check if the player is colliding mov second_player_X , 270 ;The starting X-position of player two mov SECOND_PLAYER_Y , 50 ;The starting Y-position of player two mov second_player_health , 5 ;Number of hearts to the second player mov second_player_health_immunity , 0 ;when the player gets hit by barrier, he gains an immunity to resist the barriers mov second_player_Freeze , 0 ;Duration for which the player is frozen mov Second_Is_Collided , 0 ;Boolean Variable To check if the player is colliding mov X_BARRIER1 , 10 ; xpos of barrier1 mov Y_BARRIER1 , 140 ; ypos of barrier1 mov X_BARRIER2 , 260 ; xpos of barrier2 mov Y_BARRIER2 , 104 ; ypos of barrier2 mov GAME_MASTER , 00H mov GAME_SLAVE , 0 mov CHAT_MASTER , 0 mov CHAT_SLAVE , 0 mov LEVEL_CHOSEN , 0 mov First_cursor_X , 6 mov First_cursor_Y , 1 ; SECOND CURSOR USED FOR RECEIVING mov SECOND_CURSOR_X , 6 mov SECOND_CURSOR_Y , 13 mov end_line , 76 mov IS_ENTER , 0 mov IS_BACKSPACE , 0 ;;; IN GAME CHAT MODULE mov in_game_cursor_up , 0 mov in_game_cursor_down , 0 mov in_game_received_val , 0 mov in_game_to_send_val , 0 mov in_game_iterator , 0 mov in_game_end_chat , 0 mov is_quit , 0 mov level , 0 mov is_master , 01h ;WHEN A PLAYER SENT INVI. TO THE ANOTHER ONE SO HE IS THE MASTER (MASTER VALUE=1) RET Start_Game ENDP CHAT_MODULE PROC FAR ;CLEAR screen mov ah,0 mov al,3 int 10h CALL FAR PTR SET_CHATTERS call FAR PTR draw_line ;set first cursor position to top left center MOV AH,2 MOV DL,0 MOV DH ,0 INT 10H ;check if any letter recevied CHECK_RECEIVE: ;check if their is letter received MOV DX,Line_status_register ; LINE STATUS resgister IN AL,DX TEST AL,1 JZ NO_RECIEVE ;receive register MOV DX ,TRANSMIT_DATA_REGISTER IN AL ,DX MOV LETTER_RECEIVING,AL CMP AL,1BH ;scan code of ESC JE END_CHAT CMP AL,8 JZ IT_IS_BACK_REC ;CHECK IF RECIEVED BACKSPACE TO SET THE VARIABLE JMP CHECK_ENTER_REC IT_IS_BACK_REC: MOV IS_BACKSPACE,1 JMP GO_TO_LOWER_SCREEN CHECK_ENTER_REC: CMP AL,13 ;CHECK IF RECIEVED ENTER JZ ITIS_ENTER JMP GO_TO_LOWER_SCREEN ITIS_ENTER: MOV IS_ENTER,1 GO_TO_LOWER_SCREEN: CALL FAR PTR Lower_screen JMP CHECK_RECEIVE ;IF NOTHING TO RECIEVE SEND CHARACTER IF ANY NO_RECIEVE: MOV AL,0 MOV AH,01H INT 16H CMP AL,0 JE CHECK_RECEIVE MOV AH,00H INT 16H MOV LETTER_SENT,AL ;STORE DATA IN LETTER TO BE SENT ;LATER ;--------------------- START SENDING ------------------------- MOV DX , Line_status_register ;LINE STATUS REGISTER IN AL , DX ;READ LINE STATUS TEST AL , 00100000B JZ CHECK_RECEIVE ;NOT EMPTY MOV DX , TRANSMIT_DATA_REGISTER ; TRANSMIT DATA REGISTER MOV AL,LETTER_SENT OUT DX , AL CMP AL,27 ; check if ESC is pressed JE END_CHAT CMP AL,8 JZ IT_IS_BACK1 JMP check_enter_SEND IT_IS_BACK1: MOV IS_BACKSPACE,1 JMP GO_TO_UPPER_SCREEN check_enter_SEND: CMP AL,13 ;CHECK scan code if ENTER KEY JNZ GO_TO_UPPER_SCREEN MOV IS_ENTER,1 GO_TO_UPPER_SCREEN: CALL FAR PTR upper_screen JMP CHECK_RECEIVE END_CHAT: mov ah,0 mov al,3 int 10h RET CHAT_MODULE ENDP SET_CHATTERS PROC FAR mov ah,2 ;SET POSITION mov DX,0H INT 10H MOV AH,09 MOV DX,OFFSET First_Player_Name+2 ;PRINT first_chatter NAME INT 21H mov ah,2 ;SET POSITION mov DX,0c00H INT 10H MOV AH,09 MOV DX,OFFSET Second_Player_Name+2 ;PRINT SECOND_chatter NAME INT 21H mov ah,2 ;SET POSITION mov DX,1800H INT 10H MOV AH,09 MOV DX,OFFSET chat_end_string ;PRINT SECOND_chatter NAME INT 21H RET SET_CHATTERS ENDP ;description draw_line PROC FAR MOV AH,2 mov dx,12 INT 10H mov ax,0b800h ;text mode mov DI,1760 ; each row 80 column each one 2 bits 80*2*12 mov es,ax mov ah,0fh ; black background mov al,'-' ; '-' mov cx,80 rep stosw mov ax,0b800h ;text mode mov DI,3680 ; each row 80 column each one 2 bits 80*2*12 mov es,ax mov ah,0fh ; black background mov al,'_' ; '-' mov cx,80 rep stosw ret draw_line ENDP upper_screen PROC FAR push ax push bx push cx PUSH DX CMP IS_BACKSPACE,1 JNZ NOT_BACK CMP First_cursor_X,start_position_x JG CAN_BACK JMP SET_BACK CAN_BACK: DEC First_cursor_X ; IF IT IS BACKSPACE DEC POSITION X ; AND STORE ' ' IN AL SET_BACK: MOV LETTER_SENT,' ' ;SPACE JMP set_new_position NOT_BACK: CMP IS_ENTER,1 JE NEW_LINE JMP set_new_position NEW_LINE: INC First_cursor_Y ;START NEW LINE MOV First_cursor_X,start_position_x ;SET X TO LINE BEGINNING JMP CHECK_SCROLL ;SCROLL ONE LINE set_new_position: MOV AH,2 MOV DL ,First_cursor_X MOV DH ,First_cursor_Y INT 10H ; PRINT THE CURRENT CHARACTER WITH CERTAIN COLOR MOV AH,9 MOV BH,0 MOV AL ,LETTER_SENT ; STORE SENT LETTER IN AL MOV CX,1H ; PRINT LETTER 1 TIME MOV BL,03H ;LIGHT BLUE COLOR INT 10H CMP IS_BACKSPACE,1 JE END_UPPER_CHAT INC First_cursor_X ;IF FIRST_CURSOR_X REACHES END OF LINE 76 START NEW LINE MOV DL,end_line CMP First_cursor_X ,DL JNZ END_UPPER_CHAT JMP NEW_LINE CHECK_SCROLL: CMP First_cursor_Y,11 JNZ END_UPPER_CHAT JMP SCROLL_UPPER_SCREEN SCROLL_UPPER_SCREEN: CALL FAR PTR SCROLL_UP END_UPPER_CHAT: MOV AH,2 MOV DL ,First_cursor_X ; SET NEW X-POSITION OF CURSOR MOV DH ,First_cursor_Y ; SET NEW Y-POSITION OF CURSOR INT 10H MOV AL,0 MOV IS_BACKSPACE,0 ;RETURN IS_BACKSPACE,IS_ENTER TO ZERO AGAIN MOV IS_ENTER,0 POP DX pop cx pop bx pop ax RET upper_screen ENDP ;description ;description SCROLL_UP PROC FAR PUSH ax PUSH bx PUSH cx PUSH DX MOV AH,6 MOV AL,1 ; SCROLL THE UPPER PART BY 1 LINE MOV BH,0 ; NORMAL VIDEO ATTRIBUTE MOV CH,1 ;GET POSITION MOV CL,03 MOV DH,10 MOV DL,79 INT 10H DEC First_cursor_Y POP dx POP CX POP BX POP AX RET SCROLL_UP ENDP Lower_screen PROC PUSH AX PUSH bx PUSH cx PUSH DX CMP IS_BACKSPACE,1 JNZ NOT_BACK2 CMP SECOND_CURSOR_X,start_position_x JG CAN_BACK2 JMP SET_BACK2 CAN_BACK2: DEC SECOND_CURSOR_X SET_BACK2: MOV AL,' ' ;SPACE JMP set_new_position2 NOT_BACK2: CMP IS_ENTER,1 JE NEW_LINE2 JMP set_new_position2 NEW_LINE2: INC SECOND_CURSOR_Y MOV SECOND_CURSOR_X,start_position_x ;SET CURSOR_X OF LOWER SCREEN JMP CHECK_SCROLL2 set_new_position2: MOV AH,2 MOV DL ,SECOND_CURSOR_X ; SET CURSOR POSITION OF 2ND CURSOR MOV DH ,SECOND_CURSOR_Y INT 10H MOV AH,9 ;PRINT THE RECEIVED LETTER WITH RED COLOR MOV BH,0 MOV CX,1H ; one time MOV BL,0CH ;RED COLOR INT 10H CMP IS_BACKSPACE,1 JE END_LOWER_CHAT INC SECOND_CURSOR_X ; inc X_position of 2nd cursor if it is not backspace mov dl,end_line CMP SECOND_CURSOR_X ,dl ; if X_position of 2nd cursor reach end of line JNE END_LOWER_CHAT JMP NEW_LINE2 ; start new line CHECK_SCROLL2: CMP SECOND_CURSOR_Y,23 JNE END_LOWER_CHAT JMP SCROLL_BOTTOM SCROLL_BOTTOM: CALL FAR PTR SCROLL_DOWN END_LOWER_CHAT: MOV AH,2 MOV DL ,First_cursor_X ;SET NEW CURSOR POSITION X MOV DH ,First_cursor_Y ;SET NEW CURSOR POSITION Y INT 10H ;CLEAR FLAGS MOV IS_ENTER,0 MOV IS_BACKSPACE,0 MOV AL,0 POP dx POP CX POP bx POP ax RET Lower_screen ENDP ;description SCROLL_dOWN PROC FAR PUSH ax PUSH bx PUSH cx PUSH DX MOV AH,6 MOV AL,1 MOV BH,0 MOV CH,13 MOV CL,0 MOV DH,22 MOV DL,79 INT 10H DEC SECOND_CURSOR_Y POP dx POP CX POP BX POP AX RET SCROLL_dOWN ENDP start_in_game_chatting proc FAR start_in_game_chatting_again: ; debughh: ; jmp debughh ; print_first_name_in_game_chat: ; mov SI, OFFSET First_Player_Name ; inc SI ; mov cx,0 ; mov cl,First_Player_Name+1 ; inc SI ; mov dl, 0 ;Column (0->39) ; mov dh, 21 ;Row (0-> 24) and we're only printing in the 1/5 of the screen ; mov bh, 0 ;Display page ; print_first_name_in_game_chat_loop : ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, [SI] ; mov bl, 0Ch ;Color is red ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; INC SI ;the next char ; INC DL ;increase col ; inc in_game_cursor_up ; Loop print_first_name_in_game_chat_loop ;if x=79 and erase all and print name again ;print chars from keyboard ;if enter pressed then erase backward all and prnit name agaibn ;send the character ;print name2 in pos 22; ;print_second_name_in_game_chat: ; mov SI, OFFSET Second_Player_Name ; inc SI ; mov cx,0 ; mov cl,Second_Player_Name+1 ; inc SI ; mov dl, 0 ;Column (0->39) ; mov dh, 22 ;Row (0-> 24) and we're only printing in the 1/5 of the screen ; mov bh, 0 ;Display page ; print_second_name_in_game_chat_loop : ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, [SI] ; mov bl, 0Ch ;Color is red ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; INC SI ;the next char ; INC DL ;increase col ; inc in_game_cursor_down ; Loop print_second_name_in_game_chat_loop WHILE_IN_GAME_CHAT: read_keyboard_ingame: mov ah,1 int 16h jnz Do_not_recevive_vale_from_another_player_label jmp recevive_vale_from_another_player ;; if no key pressed then see incoming chars Do_not_recevive_vale_from_another_player_label: mov ah,0 int 16h mov in_game_to_send_val,al cmp ah,3eh;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if key is f4 then get isquit be 1 jne not_quit mov is_quit, 1 mov in_game_to_send_val,ah ;; put the vakue of the scan code instead of ascii code as f4 has no ascii not_quit: cmp in_game_to_send_val,'=' ; if user press ';' then he wil continue the game jne not_out_out_chat mov in_game_end_chat,1d not_out_out_chat: ;;send value to next player mov dx , 3FDH ; Line Status Register AGAIN_in_game_chat: In al , dx ;Read Line Status test al , 00100000b JZ AGAIN_in_game_chat ;Not empty ;If empty put the VALUE in Transmit data register mov dx , 3F8H ; Transmit data register mov al,in_game_to_send_val out dx , al cmp in_game_cursor_up,39 jne not_end_of_line ;; clear_line_in_game_chat as the cursor has reached its end so we erase from the end of the postion of the player name to position 79 mov di, offset First_Player_Name inc di mov cl,[di] mov cl,0 mov in_game_iterator ,cl ; save in the iterator the size of the player name to begin after it inc in_game_iterator clear_line_in_game_chat_up: mov dl, in_game_iterator ;Column mov dh, 21 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, ' ' mov bl, 0h ;Color is black mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_iterator mov al,in_game_iterator cmp al,79d jle clear_line_in_game_chat_up mov in_game_cursor_up,0 not_end_of_line: mov dl, in_game_cursor_up ;Column mov dh, 21 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, in_game_to_send_val mov bl, 4h ;Color is white mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_cursor_up recevive_vale_from_another_player: mov dx , 3FDH ; Line Status Register in al , dx test al , 1 JZ chk_end ;Not Ready ;If Ready read the VALUE in Receive data register mov dx , 03F8H in al , dx mov in_game_received_val , al cmp al,3eh ;;;;;; if the value recieced equals to f4 then end the game jne not_end_game2 mov is_quit,1d not_end_game2: cmp al,'=' ;if value received is ';' then return back to the game jne not_end_chat2 mov in_game_end_chat,1 not_end_chat2: print_from_another_player: cmp in_game_cursor_down,39 ;; same as before we clear the line if it reached its end jne not_end_of_line2 mov di, offset Second_Player_Name inc di mov cl,[di] mov cl,0 mov in_game_iterator ,cl inc in_game_iterator clear_line_in_game_chat_down: mov dl, in_game_iterator ;Column mov dh, 22 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, ' ' mov bl, 0h ;Color is black mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_iterator mov al,in_game_iterator cmp al,79d jle clear_line_in_game_chat_down mov in_game_cursor_down,0 not_end_of_line2: mov dl, in_game_cursor_down ;Column mov dh, 22 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, in_game_received_val mov bl, 1h ;Color is white mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_cursor_down chk_end: cmp in_game_end_chat,1 je return_from_ingame_chat ; cmp is_quit,1 ; je return_from_ingame_chat jmp WHILE_IN_GAME_CHAT return_from_ingame_chat: mov in_game_end_chat,0 mov in_game_cursor_up,0 mov in_game_cursor_down,0 mov in_game_iterator,0 ;; clearing chat lines before returning from the functoin clear_line_in_game_chat_down2: mov dl, in_game_iterator ;Column mov dh, 22 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, ' ' mov bl, 0h ;Color is black mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_iterator mov al,in_game_iterator cmp al,79d jle clear_line_in_game_chat_down2 mov in_game_iterator,0 clear_line_in_game_chat_up2: mov dl, in_game_iterator ;Column mov dh, 21 ;Row mov bh, 0 ;Display page mov ah, 02h ;SetCursorPosition int 10h mov al, ' ' mov bl, 0h ;Color is black mov bh, 0 ;Display page mov ah, 0Eh ;Teletype int 10h inc in_game_iterator mov al,in_game_iterator cmp al,79d jle clear_line_in_game_chat_up2 mov in_game_iterator,0 mov in_game_end_chat,0 mov in_game_cursor_up,0 mov in_game_cursor_down,0 mov in_game_iterator,0 ret ;if x=79 erase all backward and print name ;if recevived print character ;if enter rceived erase backwards ;if x=79 erase all and print name again mov ah,0 RET start_in_game_chatting ENDP ; start_in_game_chatting2 proc FAR ; start_in_game_chatting_again2: ; ; ; WHILE_IN_GAME_CHAT2: ; read_keyboard_ingame2: ; mov ah,1 ; int 16h ; jnz Do_not_recevive_vale_from_another_player_label2 ; jmp recevive_vale_from_another_player2 ;; if no key pressed then see incoming chars ; Do_not_recevive_vale_from_another_player_label2: ; mov ah,0 ; int 16h ; mov in_game_to_send_val,al ; cmp ah,3eh;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if key is f4 then get isquit be 1 ; jne not_quit2 ; mov is_quit, 1 ; mov in_game_to_send_val,ah ;; put the vakue of the scan code instead of ascii code as f4 has no ascii ; not_quit2: ; cmp in_game_to_send_val,';' ; if user press ';' then he wil continue the game ; jne not_out_out_chat2 ; mov in_game_end_chat,1d ; not_out_out_chat2: ; ;;send value to next player ; mov dx , 3FDH ; Line Status Register ; AGAIN_in_game_chat2: In al , dx ;Read Line Status ; test al , 00100000b ; JZ AGAIN_in_game_chat2 ;Not empty ; ;If empty put the VALUE in Transmit data register ; mov dx , 3F8H ; Transmit data register ; mov al,in_game_to_send_val ; out dx , al ; cmp in_game_cursor_up,79 ; jne not_end_of_line22 ; ;; clear_line_in_game_chat as the cursor has reached its end so we erase from the end of the postion of the player name to position 79 ; mov di, offset First_Player_Name ; inc di ; mov cl,[di] ; mov cl,0 ; mov in_game_iterator ,cl ; save in the iterator the size of the player name to begin after it ; inc in_game_iterator ; clear_line_in_game_chat_up22: ; mov dl, in_game_iterator ;Column ; mov dh, 21 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, ' ' ; mov bl, 0h ;Color is black ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_iterator ; mov al,in_game_iterator ; cmp al,79d ; jle clear_line_in_game_chat_up22 ; not_end_of_line22: ; mov dl, in_game_cursor_up ;Column ; mov dh, 21 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, in_game_to_send_val ; mov bl, 0Fh ;Color is white ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_cursor_up ; recevive_vale_from_another_player2: ; mov dx , 3FDH ; Line Status Register ; in al , dx ; test al , 1 ; JZ chk_end2 ;Not Ready ; ;If Ready read the VALUE in Receive data register ; mov dx , 03F8H ; in al , dx ; mov in_game_received_val , al ; cmp al,3eh ;;;;;; if the value recieced equals to f4 then end the game ; jne not_end_game22 ; mov is_quit,1d ; not_end_game22: ; cmp al,';' ;if value received is ';' then return back to the game ; jne not_end_chat22 ; mov is_quit,1 ; not_end_chat22: ; print_from_another_player2: ; cmp in_game_cursor_down,79 ;; same as before we clear the line if it reached its end ; jne not_end_of_line223 ; mov di, offset Second_Player_Name ; inc di ; mov cl,[di] ; mov cl,0 ; mov in_game_iterator ,cl ; inc in_game_iterator ; clear_line_in_game_chat_down22: ; mov dl, in_game_iterator ;Column ; mov dh, 22 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, ' ' ; mov bl, 0h ;Color is black ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_iterator ; mov al,in_game_iterator ; cmp al,79d ; jle clear_line_in_game_chat_down22 ; not_end_of_line223: ; mov dl, in_game_cursor_down ;Column ; mov dh, 22 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, in_game_received_val ; mov bl, 0Fh ;Color is white ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_cursor_down ; chk_end2: ; cmp in_game_end_chat,1 ; je return_from_ingame_chat2 ; cmp is_quit,1 ; je return_from_ingame_chat2 ; jmp WHILE_IN_GAME_CHAT2 ; return_from_ingame_chat2: ; mov in_game_end_chat,0 ; mov in_game_cursor_up,0 ; mov in_game_cursor_down,0 ; mov in_game_iterator,0 ; ;; clearing chat lines before returning from the functoin ; clear_line_in_game_chat_down223: ; mov dl, in_game_iterator ;Column ; mov dh, 22 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, ' ' ; mov bl, 0h ;Color is black ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_iterator ; mov al,in_game_iterator ; cmp al,79d ; jle clear_line_in_game_chat_down223 ; mov in_game_iterator,0 ; clear_line_in_game_chat_up223: ; mov dl, in_game_iterator ;Column ; mov dh, 21 ;Row ; mov bh, 0 ;Display page ; mov ah, 02h ;SetCursorPosition ; int 10h ; mov al, ' ' ; mov bl, 0h ;Color is black ; mov bh, 0 ;Display page ; mov ah, 0Eh ;Teletype ; int 10h ; inc in_game_iterator ; mov al,in_game_iterator ; cmp al,79d ; jle clear_line_in_game_chat_up223 ; mov in_game_iterator,0 ; mov in_game_end_chat,0 ; mov in_game_cursor_up,0 ; mov in_game_cursor_down,0 ; mov in_game_iterator,0 ; ret ; ;if x=79 erase all backward and print name ; ;if recevived print character ; ;if enter rceived erase backwards ;if x=79 erase all and print name again ; mov ah,0 ; RET ; start_in_game_chatting2 ENDP ;description send_in_chat_inv PROC ;Check that Transmitter Holding Register is Empty mov dx , 3FDH ; Line Status Register send_chat_now: In al , dx ;Read Line Status test al , 00100000b JZ send_chat_now ;Not empty ;If empty put the VALUE in Transmit data register mov dx , 3F8H ; Transmit data register mov al,27h out dx , al ret send_in_chat_inv ENDP END MAIN
############################################################################### # 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 .globl l9_Decrypt_RIJ128_AES_NI .type l9_Decrypt_RIJ128_AES_NI, @function l9_Decrypt_RIJ128_AES_NI: lea (,%rdx,4), %rax lea (,%rax,4), %rax movdqu (%rdi), %xmm0 pxor (%rcx,%rax), %xmm0 cmp $(12), %rdx jl .Lkey_128gas_1 jz .Lkey_192gas_1 .Lkey_256gas_1: aesdec (208)(%rcx), %xmm0 aesdec (192)(%rcx), %xmm0 .Lkey_192gas_1: aesdec (176)(%rcx), %xmm0 aesdec (160)(%rcx), %xmm0 .Lkey_128gas_1: aesdec (144)(%rcx), %xmm0 aesdec (128)(%rcx), %xmm0 aesdec (112)(%rcx), %xmm0 aesdec (96)(%rcx), %xmm0 aesdec (80)(%rcx), %xmm0 aesdec (64)(%rcx), %xmm0 aesdec (48)(%rcx), %xmm0 aesdec (32)(%rcx), %xmm0 aesdec (16)(%rcx), %xmm0 aesdeclast (%rcx), %xmm0 movdqu %xmm0, (%rsi) vzeroupper ret .Lfe1: .size l9_Decrypt_RIJ128_AES_NI, .Lfe1-(l9_Decrypt_RIJ128_AES_NI)
; ; Kaypro II pseudo graphics routines ; ; Stefano Bodrato 2018 ; ; ; $Id: plot_end_83.asm $ ; SECTION code_clib PUBLIC plot_end_83 PUBLIC plot_decode_83 EXTERN __gfx_coords .plot_decode_83 ld (__gfx_coords),hl ld c,a srl a ;and a ld b,a ;y/2 ld a,h ld hl,$3000 ld de,128 jr z,az .yloop add hl,de djnz yloop .az ld e,a add hl,de ld a,(hl) and a ; ' = top ld a,1 jr z,ydone ld a,(hl) cp ',' ; bottom ld a,2 jr z,ydone ld a,(hl) cp '|' ; top+bottom ld a,3 jr z,ydone xor a .ydone rr c ret .plot_end_83 push hl ld hl,chars add l ld l,a jr nc,nocy inc h .nocy ld a,(hl) pop hl ld (hl),a pop bc ret .chars defb ' ',0,',','|'
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_WC_ht+0x11dd7, %r10 nop nop nop sub %r9, %r9 mov (%r10), %r14w nop nop and %rcx, %rcx lea addresses_A_ht+0xced7, %rsi lea addresses_UC_ht+0x1857, %rdi nop nop nop xor %r15, %r15 mov $61, %rcx rep movsw nop nop nop nop xor %r10, %r10 lea addresses_WT_ht+0x3703, %rcx nop nop xor %r9, %r9 mov $0x6162636465666768, %rsi movq %rsi, %xmm6 movups %xmm6, (%rcx) nop nop sub $33975, %r14 lea addresses_UC_ht+0x1b357, %r9 nop nop nop lfence mov (%r9), %r14d nop nop nop add %r14, %r14 lea addresses_D_ht+0x13f33, %rdi nop sub $46909, %r9 movb (%rdi), %r14b inc %rdi lea addresses_normal_ht+0x17ed7, %rsi lea addresses_normal_ht+0x8597, %rdi clflush (%rsi) clflush (%rdi) nop nop nop nop nop cmp $22372, %r12 mov $87, %rcx rep movsq nop nop nop nop inc %rsi pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r8 push %rcx push %rdx push %rsi // Faulty Load lea addresses_UC+0x4ed7, %rsi clflush (%rsi) nop nop nop nop xor $25772, %r8 mov (%rsi), %ecx lea oracles, %r13 and $0xff, %rcx shlq $12, %rcx mov (%r13,%rcx,1), %rcx pop %rsi pop %rdx pop %rcx pop %r8 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}} {'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 */