text stringlengths 1 1.05M |
|---|
/*=============================================================================
Copyright (c) 2011-2019 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_STRING_HPP
#define SPROUT_TYPE_STRING_HPP
#include <sprout/type/string/string.hpp>
#include <sprout/type/string/to_string_constant.hpp>
#include <sprout/type/string/to_string.hpp>
#include <sprout/type/string/alias.hpp>
#endif // #ifndef SPROUT_TYPE_STRING_HPP
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004A10 move.w D1, -(A0)
004A12 dbra D0, $4a10
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
;https://github.com/weltling/ml64_exercise/blob/master/int64_overflow/mul.asm
.code
mult_qWord proc
xor eax,eax
cvtsi2sd xmm0,rcx
cvtsi2sd xmm1,rdx
imul rcx,rdx
mulsd xmm0,xmm1
mov [r8],rcx
movsd real8 ptr [r9],xmm0
jno @NOF
xor eax,1 ; integer overflow -> rax = 1
@NOF: ret
mult_qWord endp
mult proc
; rcx == __int64 a
; rdx == __int64 b
; r8 == __int64 *lret
; r9 == double *dret
push rdx ; imul stores result into rdx
imul rdx,rcx
jo ovfl
ok:
mov [r8],rdx
xor rax,rax
pop rdx
jmp done
ovfl:
pop rdx
cvtsi2sd xmm0,rdx
cvtsi2sd xmm1,rcx
mulsd xmm0,xmm1
movsd qword ptr[r9],xmm0
mov rax,1
done:
ret
mult endp
int64_mul_ovfl proc
; rcx == __int64 a
; rdx == __int64 b
; r8 == __int64 *lret
xor rax,rax
push rdx
imul rdx,rcx
mov qword ptr[r8],rdx
pop rdx
jno done
add rax,1
done:
ret
int64_mul_ovfl endp
end |
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.0.7 #12017 (Linux)
;--------------------------------------------------------
; Processed by Z88DK
;--------------------------------------------------------
EXTERN __divschar
EXTERN __divschar_callee
EXTERN __divsint
EXTERN __divsint_callee
EXTERN __divslong
EXTERN __divslong_callee
EXTERN __divslonglong
EXTERN __divslonglong_callee
EXTERN __divsuchar
EXTERN __divsuchar_callee
EXTERN __divuchar
EXTERN __divuchar_callee
EXTERN __divuint
EXTERN __divuint_callee
EXTERN __divulong
EXTERN __divulong_callee
EXTERN __divulonglong
EXTERN __divulonglong_callee
EXTERN __divuschar
EXTERN __divuschar_callee
EXTERN __modschar
EXTERN __modschar_callee
EXTERN __modsint
EXTERN __modsint_callee
EXTERN __modslong
EXTERN __modslong_callee
EXTERN __modslonglong
EXTERN __modslonglong_callee
EXTERN __modsuchar
EXTERN __modsuchar_callee
EXTERN __moduchar
EXTERN __moduchar_callee
EXTERN __moduint
EXTERN __moduint_callee
EXTERN __modulong
EXTERN __modulong_callee
EXTERN __modulonglong
EXTERN __modulonglong_callee
EXTERN __moduschar
EXTERN __moduschar_callee
EXTERN __mulint
EXTERN __mulint_callee
EXTERN __mullong
EXTERN __mullong_callee
EXTERN __mullonglong
EXTERN __mullonglong_callee
EXTERN __mulschar
EXTERN __mulschar_callee
EXTERN __mulsuchar
EXTERN __mulsuchar_callee
EXTERN __muluchar
EXTERN __muluchar_callee
EXTERN __muluschar
EXTERN __muluschar_callee
EXTERN __rlslonglong
EXTERN __rlslonglong_callee
EXTERN __rlulonglong
EXTERN __rlulonglong_callee
EXTERN __rrslonglong
EXTERN __rrslonglong_callee
EXTERN __rrulonglong
EXTERN __rrulonglong_callee
EXTERN ___sdcc_call_hl
EXTERN ___sdcc_call_iy
EXTERN ___sdcc_enter_ix
EXTERN banked_call
EXTERN _banked_ret
EXTERN ___fs2schar
EXTERN ___fs2schar_callee
EXTERN ___fs2sint
EXTERN ___fs2sint_callee
EXTERN ___fs2slong
EXTERN ___fs2slong_callee
EXTERN ___fs2slonglong
EXTERN ___fs2slonglong_callee
EXTERN ___fs2uchar
EXTERN ___fs2uchar_callee
EXTERN ___fs2uint
EXTERN ___fs2uint_callee
EXTERN ___fs2ulong
EXTERN ___fs2ulong_callee
EXTERN ___fs2ulonglong
EXTERN ___fs2ulonglong_callee
EXTERN ___fsadd
EXTERN ___fsadd_callee
EXTERN ___fsdiv
EXTERN ___fsdiv_callee
EXTERN ___fseq
EXTERN ___fseq_callee
EXTERN ___fsgt
EXTERN ___fsgt_callee
EXTERN ___fslt
EXTERN ___fslt_callee
EXTERN ___fsmul
EXTERN ___fsmul_callee
EXTERN ___fsneq
EXTERN ___fsneq_callee
EXTERN ___fssub
EXTERN ___fssub_callee
EXTERN ___schar2fs
EXTERN ___schar2fs_callee
EXTERN ___sint2fs
EXTERN ___sint2fs_callee
EXTERN ___slong2fs
EXTERN ___slong2fs_callee
EXTERN ___slonglong2fs
EXTERN ___slonglong2fs_callee
EXTERN ___uchar2fs
EXTERN ___uchar2fs_callee
EXTERN ___uint2fs
EXTERN ___uint2fs_callee
EXTERN ___ulong2fs
EXTERN ___ulong2fs_callee
EXTERN ___ulonglong2fs
EXTERN ___ulonglong2fs_callee
EXTERN ____sdcc_2_copy_src_mhl_dst_deix
EXTERN ____sdcc_2_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_deix
EXTERN ____sdcc_4_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_mbc
EXTERN ____sdcc_4_ldi_nosave_bc
EXTERN ____sdcc_4_ldi_save_bc
EXTERN ____sdcc_4_push_hlix
EXTERN ____sdcc_4_push_mhl
EXTERN ____sdcc_lib_setmem_hl
EXTERN ____sdcc_ll_add_de_bc_hl
EXTERN ____sdcc_ll_add_de_bc_hlix
EXTERN ____sdcc_ll_add_de_hlix_bc
EXTERN ____sdcc_ll_add_de_hlix_bcix
EXTERN ____sdcc_ll_add_deix_bc_hl
EXTERN ____sdcc_ll_add_deix_hlix
EXTERN ____sdcc_ll_add_hlix_bc_deix
EXTERN ____sdcc_ll_add_hlix_deix_bc
EXTERN ____sdcc_ll_add_hlix_deix_bcix
EXTERN ____sdcc_ll_asr_hlix_a
EXTERN ____sdcc_ll_asr_mbc_a
EXTERN ____sdcc_ll_copy_src_de_dst_hlix
EXTERN ____sdcc_ll_copy_src_de_dst_hlsp
EXTERN ____sdcc_ll_copy_src_deix_dst_hl
EXTERN ____sdcc_ll_copy_src_deix_dst_hlix
EXTERN ____sdcc_ll_copy_src_deixm_dst_hlsp
EXTERN ____sdcc_ll_copy_src_desp_dst_hlsp
EXTERN ____sdcc_ll_copy_src_hl_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_deixm
EXTERN ____sdcc_ll_lsl_hlix_a
EXTERN ____sdcc_ll_lsl_mbc_a
EXTERN ____sdcc_ll_lsr_hlix_a
EXTERN ____sdcc_ll_lsr_mbc_a
EXTERN ____sdcc_ll_push_hlix
EXTERN ____sdcc_ll_push_mhl
EXTERN ____sdcc_ll_sub_de_bc_hl
EXTERN ____sdcc_ll_sub_de_bc_hlix
EXTERN ____sdcc_ll_sub_de_hlix_bc
EXTERN ____sdcc_ll_sub_de_hlix_bcix
EXTERN ____sdcc_ll_sub_deix_bc_hl
EXTERN ____sdcc_ll_sub_deix_hlix
EXTERN ____sdcc_ll_sub_hlix_bc_deix
EXTERN ____sdcc_ll_sub_hlix_deix_bc
EXTERN ____sdcc_ll_sub_hlix_deix_bcix
EXTERN ____sdcc_load_debc_deix
EXTERN ____sdcc_load_dehl_deix
EXTERN ____sdcc_load_debc_mhl
EXTERN ____sdcc_load_hlde_mhl
EXTERN ____sdcc_store_dehl_bcix
EXTERN ____sdcc_store_debc_hlix
EXTERN ____sdcc_store_debc_mhl
EXTERN ____sdcc_cpu_pop_ei
EXTERN ____sdcc_cpu_pop_ei_jp
EXTERN ____sdcc_cpu_push_di
EXTERN ____sdcc_outi
EXTERN ____sdcc_outi_128
EXTERN ____sdcc_outi_256
EXTERN ____sdcc_ldi
EXTERN ____sdcc_ldi_128
EXTERN ____sdcc_ldi_256
EXTERN ____sdcc_4_copy_srcd_hlix_dst_deix
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_dehl_dst_bcix
EXTERN ____sdcc_4_and_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_cpl_src_mhl_dst_debc
EXTERN ____sdcc_4_xor_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_or_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_xor_src_debc_hlix_dst_debc
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
GLOBAL _m32_acosf
;--------------------------------------------------------
; Externals used
;--------------------------------------------------------
GLOBAL _m32_polyf
GLOBAL _m32_hypotf
GLOBAL _m32_ldexpf
GLOBAL _m32_frexpf
GLOBAL _m32_invsqrtf
GLOBAL _m32_sqrtf
GLOBAL _m32_invf
GLOBAL _m32_sqrf
GLOBAL _m32_div2f
GLOBAL _m32_mul2f
GLOBAL _m32_modff
GLOBAL _m32_fmodf
GLOBAL _m32_roundf
GLOBAL _m32_floorf
GLOBAL _m32_fabsf
GLOBAL _m32_ceilf
GLOBAL _m32_powf
GLOBAL _m32_log10f
GLOBAL _m32_log2f
GLOBAL _m32_logf
GLOBAL _m32_exp10f
GLOBAL _m32_exp2f
GLOBAL _m32_expf
GLOBAL _m32_atanhf
GLOBAL _m32_acoshf
GLOBAL _m32_asinhf
GLOBAL _m32_tanhf
GLOBAL _m32_coshf
GLOBAL _m32_sinhf
GLOBAL _m32_atan2f
GLOBAL _m32_atanf
GLOBAL _m32_asinf
GLOBAL _m32_tanf
GLOBAL _m32_cosf
GLOBAL _m32_sinf
GLOBAL _poly_callee
GLOBAL _poly
GLOBAL _exp10_fastcall
GLOBAL _exp10
GLOBAL _mul10u_fastcall
GLOBAL _mul10u
GLOBAL _mul2_fastcall
GLOBAL _mul2
GLOBAL _div2_fastcall
GLOBAL _div2
GLOBAL _invsqrt_fastcall
GLOBAL _invsqrt
GLOBAL _inv_fastcall
GLOBAL _inv
GLOBAL _sqr_fastcall
GLOBAL _sqr
GLOBAL _isunordered_callee
GLOBAL _isunordered
GLOBAL _islessgreater_callee
GLOBAL _islessgreater
GLOBAL _islessequal_callee
GLOBAL _islessequal
GLOBAL _isless_callee
GLOBAL _isless
GLOBAL _isgreaterequal_callee
GLOBAL _isgreaterequal
GLOBAL _isgreater_callee
GLOBAL _isgreater
GLOBAL _fma_callee
GLOBAL _fma
GLOBAL _fmin_callee
GLOBAL _fmin
GLOBAL _fmax_callee
GLOBAL _fmax
GLOBAL _fdim_callee
GLOBAL _fdim
GLOBAL _nexttoward_callee
GLOBAL _nexttoward
GLOBAL _nextafter_callee
GLOBAL _nextafter
GLOBAL _nan_fastcall
GLOBAL _nan
GLOBAL _copysign_callee
GLOBAL _copysign
GLOBAL _remquo_callee
GLOBAL _remquo
GLOBAL _remainder_callee
GLOBAL _remainder
GLOBAL _fmod_callee
GLOBAL _fmod
GLOBAL _modf_callee
GLOBAL _modf
GLOBAL _trunc_fastcall
GLOBAL _trunc
GLOBAL _lround_fastcall
GLOBAL _lround
GLOBAL _round_fastcall
GLOBAL _round
GLOBAL _lrint_fastcall
GLOBAL _lrint
GLOBAL _rint_fastcall
GLOBAL _rint
GLOBAL _nearbyint_fastcall
GLOBAL _nearbyint
GLOBAL _floor_fastcall
GLOBAL _floor
GLOBAL _ceil_fastcall
GLOBAL _ceil
GLOBAL _tgamma_fastcall
GLOBAL _tgamma
GLOBAL _lgamma_fastcall
GLOBAL _lgamma
GLOBAL _erfc_fastcall
GLOBAL _erfc
GLOBAL _erf_fastcall
GLOBAL _erf
GLOBAL _cbrt_fastcall
GLOBAL _cbrt
GLOBAL _sqrt_fastcall
GLOBAL _sqrt
GLOBAL _pow_callee
GLOBAL _pow
GLOBAL _hypot_callee
GLOBAL _hypot
GLOBAL _fabs_fastcall
GLOBAL _fabs
GLOBAL _logb_fastcall
GLOBAL _logb
GLOBAL _log2_fastcall
GLOBAL _log2
GLOBAL _log1p_fastcall
GLOBAL _log1p
GLOBAL _log10_fastcall
GLOBAL _log10
GLOBAL _log_fastcall
GLOBAL _log
GLOBAL _scalbln_callee
GLOBAL _scalbln
GLOBAL _scalbn_callee
GLOBAL _scalbn
GLOBAL _ldexp_callee
GLOBAL _ldexp
GLOBAL _ilogb_fastcall
GLOBAL _ilogb
GLOBAL _frexp_callee
GLOBAL _frexp
GLOBAL _expm1_fastcall
GLOBAL _expm1
GLOBAL _exp2_fastcall
GLOBAL _exp2
GLOBAL _exp_fastcall
GLOBAL _exp
GLOBAL _tanh_fastcall
GLOBAL _tanh
GLOBAL _sinh_fastcall
GLOBAL _sinh
GLOBAL _cosh_fastcall
GLOBAL _cosh
GLOBAL _atanh_fastcall
GLOBAL _atanh
GLOBAL _asinh_fastcall
GLOBAL _asinh
GLOBAL _acosh_fastcall
GLOBAL _acosh
GLOBAL _tan_fastcall
GLOBAL _tan
GLOBAL _sin_fastcall
GLOBAL _sin
GLOBAL _cos_fastcall
GLOBAL _cos
GLOBAL _atan2_callee
GLOBAL _atan2
GLOBAL _atan_fastcall
GLOBAL _atan
GLOBAL _asin_fastcall
GLOBAL _asin
GLOBAL _acos_fastcall
GLOBAL _acos
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
SECTION bss_compiler
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
IF 0
; .area _INITIALIZED removed by z88dk
ENDIF
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
SECTION code_crt_init
;--------------------------------------------------------
; Home
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; code
;--------------------------------------------------------
SECTION code_compiler
; ---------------------------------
; Function m32_acosf
; ---------------------------------
_m32_acosf:
push ix
ld ix,0
add ix,sp
push af
push af
ex (sp), hl
ld (ix-2),e
ld (ix-1),d
ld l,(ix-4)
ld h,(ix-3)
ld e,(ix-2)
ld d,(ix-1)
call _m32_sqrf
push de
push hl
ld hl,0x3f80
push hl
ld hl,0x0000
push hl
call ___fssub_callee
call _m32_sqrtf
ld c, l
ld l,(ix-2)
ld b,h
ld h,(ix-1)
push hl
ld l,(ix-4)
ld h,(ix-3)
push hl
push de
push bc
call ___fsdiv_callee
call _m32_atanf
ld sp, ix
pop ix
ret
SECTION IGNORE
|
#pragma once
#include "KNoise.hpp"
#define PERLIN_ALLOCATION_SIZE 32
namespace KNoise {
struct Perlin {
Perlin();
~Perlin();
enum CacheType { // Seed cache types, Deafult is recomended
Single, // Saves last PTable
Array, // PTables are stored in array, array needs to be searched to find cached PTable
Index, // Seed is index of cache array removing need for searching array
// Faster with large numbers of cached seeds but uses more memory if used incorectly
Experimental // Experimental cache implementations that will probably be implemented later after fixing bugs
// Currently nothing is tested here if selected behaves as FastArray cache
};
void SetCacheType(int F_CacheType); // Sets cache type
int GetCacheType(); // Returns cache type
size_t GetCacheSize(); // Returns cache size (if any)
void ClearCache(); // Clears cache (dosent do anything in some cache types)
float Get(V3f F_Position, unsigned int F_Seed); // Get noise value for set seed and position
double Get(V3d F_Position, unsigned int F_Seed); // Get double precision noise value for set seed and position
private:
// Main cache class
struct SeedCache {
// Cache needs to generate PTable and return it in GetPTable
struct PTable { // Permutation Table ( array with random numbers )
unsigned int Seed = 0; // Generated PTable seed
std::vector<unsigned int> Permutation; // Permutation
bool Created = false; // Was PTable generated?
PTable(unsigned int F_Seed); // Generate new PTable
PTable(); // Allocate memory for PTable
};
// Set type to CacheType enum in constructor
CacheType Type;
// These functions are implemented by cache implementation
virtual ~SeedCache() = 0; // Virtual destructor leave it empty if you dont use it
virtual PTable* GetPTable(unsigned int F_Seed) = 0; // This function returns PTable for given seed
virtual size_t GetCacheSize() = 0; // Returns cache size (if any)
virtual void Clear() = 0; // This function clears cache (if there is any cache)
// TODO
//std::vector<std::thread> Requests;
//void RequestPTable(unsigned int F_Seed, PTable* Return);
};
// Cache implementations:
struct SingleCache : public SeedCache {
SingleCache();
PTable* GetPTable(unsigned int F_Seed) override;
size_t GetCacheSize() override;
void Clear() override;
private:
PTable Last;
};
struct ArrayCache : public SeedCache {
ArrayCache();
PTable* GetPTable(unsigned int F_Seed) override;
size_t GetCacheSize() override;
void Clear() override;
private:
std::vector<PTable> Cache;
};
struct IndexCache : public SeedCache {
IndexCache();
PTable* GetPTable(unsigned int F_Seed) override;
size_t GetCacheSize() override;
void Clear() override;
private:
unsigned int FirstSeed = (unsigned int)-1;
std::vector<PTable> Cache;
};
struct ExperimentalCache : public SeedCache {
ExperimentalCache();
PTable* GetPTable(unsigned int F_Seed) override;
size_t GetCacheSize() override;
void Clear() override;
private:
unsigned int FirstSeed = (unsigned int)-1;
std::vector<PTable> Cache;
};
// Cache implementation
SeedCache* Seed = NULL;
std::mutex SeedLock;
// These functions are used by Get() function to generate noise
float Fade(float t);
float Lerp(float t, float a, float b);
float Grad(int hash, float x, float y, float z);
// Double precision versions
double FadeD(double t);
double LerpD(double t, double a, double b);
double GradD(int hash, double x, double y, double z);
};
} |
; unsigned char esx_f_open_p3(unsigned char *filename,unsigned char mode,struct esx_p3_hdr *h)
SECTION code_esxdos
PUBLIC _esx_f_open_p3_callee
PUBLIC l0_esx_f_open_p3_callee
EXTERN asm_esx_f_open_p3
_esx_f_open_p3_callee:
pop bc
pop hl
dec sp
pop af
pop de
push bc
l0_esx_f_open_p3_callee:
push ix
call asm_esx_f_open_p3
pop ix
ret
|
; A249118: Position of 32n^6 in the ordered union of {h^6, h >=1} and {32*k^6, k >=1}.
; 2,5,8,11,13,16,19,22,25,27,30,33,36,38,41,44,47,50,52,55,58,61,63,66,69,72,75,77,80,83,86,89,91,94,97,100,102,105,108,111,114,116,119,122,125,127,130,133,136,139,141,144,147,150,152,155,158,161,164
mov $3,$0
add $0,1
mov $1,5
mul $1,$0
mul $0,8
pow $1,2
div $1,$0
div $1,4
add $1,2
mov $2,$3
mul $2,2
add $1,$2
|
db 0 ; species ID placeholder
db 80, 105, 65, 70, 100, 70
; hp atk def spd sat sdf
db GRASS, POISON ; type
db 45 ; catch rate
db 191 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/victreebel/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm CURSE, TOXIC, HIDDEN_POWER, SUNNY_DAY, SWEET_SCENT, SNORE, HYPER_BEAM, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, REST, ATTRACT, CUT, FLASH
; end
|
; A230462: Numbers congruent to {1, 11, 13, 17, 19, or 29} mod 30.
; 1,11,13,17,19,29,31,41,43,47,49,59,61,71,73,77,79,89,91,101,103,107,109,119,121,131,133,137,139,149,151,161,163,167,169,179,181,191,193,197,199,209,211,221,223,227,229,239,241,251,253,257,259,269,271,281,283,287,289,299,301,311,313,317,319,329,331,341,343,347,349,359,361,371,373,377,379,389,391,401,403,407,409,419,421,431,433,437,439,449,451,461,463,467,469,479,481,491,493,497,499,509,511,521,523,527,529,539,541,551,553,557,559,569,571,581,583,587,589,599,601,611,613,617,619,629,631,641,643,647,649,659,661,671,673,677,679,689,691,701,703,707,709,719,721,731,733,737,739,749,751,761,763,767,769,779,781,791,793,797,799,809,811,821,823,827,829,839,841,851,853,857,859,869,871,881,883,887,889,899,901,911,913,917,919,929,931,941,943,947,949,959,961,971,973,977,979,989,991,1001,1003,1007,1009,1019,1021,1031,1033,1037,1039,1049,1051,1061,1063,1067,1069,1079,1081,1091,1093,1097,1099,1109,1111,1121,1123,1127,1129,1139,1141,1151,1153,1157,1159,1169,1171,1181,1183,1187,1189,1199,1201,1211,1213,1217,1219,1229,1231,1241,1243,1247
mov $1,$0
add $1,2
mov $2,3
mov $3,2
mov $5,$0
lpb $2,1
mov $4,$1
lpb $4,1
add $1,$3
trn $4,$3
lpe
sub $2,1
trn $2,1
add $3,4
lpe
lpb $5,1
add $1,1
sub $5,1
lpe
sub $1,9
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.text@150
lbegin:
ld c, 41
ld b, 03
lbegin_waitm3:
ldff a, (c)
and a, b
cmp a, b
jrnz lbegin_waitm3
ld a, 20
ldff(c), a
ld a, 02
ldff(ff), a
ei
nop
halt
.text@1000
lstatint:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldff a, (c)
and a, b
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
; A146083: Expansion of 1/(1 - x*(1 - 11*x)).
; 1,1,-10,-21,89,320,-659,-4179,3070,49039,15269,-524160,-692119,5073641,12686950,-43123101,-182679551,291674560,2301149621,-907270539,-26219916370,-16239940441,272179139629,450818484480,-2543152051439,-7502155380719,20472517185110,102996226373019,-122201462663191,-1255159952766400,89056136528701,13895815616959101,12916198115143390,-139937773671406721,-282015952937984011,1257299557447489920,4359475039765314041,-9470820092157075079,-57425045529575529530,46753975484152296339,678429476309483121169,164135745983807861440,-7298588493420506471419,-9104081699242392947259,71180391728383178238350,171325290420049500658199,-611659018592165459963651,-2496237213212709967203840,4232011991301110092396321,31690621336640919731638561,-14861510567671291284720970,-363458345270721408332745141,-199981729026337204200814471,3798060068951598287459382080,5997859088241307533668341261,-35780801670226273628384861619,-101757251640880656498736615490,291831566731608353413496862319,1411161334781295574899599632709,-1798985899266396312648865852800,-17321760581860647636544461812599,2467084310069711802593062568201,193006450710536835804582142506790,165868523299770005976058454256579,-1957202434516135187874345113318111,-3781756190813605253610988110140480,17747470588863881813006808136358741,59346788687813539602727677347904021,-135875387789689160340347212152042130,-788690063355638095970351662978986361,705939202330942667773467670693477069
mul $0,2
mov $1,1
lpb $0
sub $0,2
sub $1,$2
add $2,$1
mul $2,11
lpe
mov $0,$1
|
; A272459: The total number of different isosceles trapezoids, excluding squares, that can be drawn on an n X n square grid where the corners of each individual trapezoid lie on a lattice point.
; 0,1,7,18,40,71,119,180,264,365,495,646,832,1043,1295,1576,1904,2265,2679,3130,3640,4191,4807,5468,6200,6981,7839,8750,9744,10795,11935,13136,14432,15793,17255,18786,20424,22135,23959,25860,27880,29981,32207,34518,36960,39491,42159,44920,47824,50825,53975,57226,60632,64143,67815,71596,75544,79605,83839,88190,92720,97371,102207,107168,112320,117601,123079,128690,134504,140455,146615,152916,159432,166093,172975,180006,187264,194675,202319,210120,218160,226361,234807,243418,252280,261311,270599,280060,289784,299685,309855,320206,330832,341643,352735,364016,375584,387345,399399,411650
mov $2,$0
mov $3,$0
lpb $3
lpb $2
trn $3,1
add $0,$3
add $4,$0
add $0,$3
sub $2,1
trn $3,1
sub $4,$3
lpe
mov $1,$4
lpe
mov $0,$1
|
; A142755: Primes congruent to 28 mod 59.
; Submitted by Jon Maiga
; 677,1031,1621,2447,2683,2801,3037,3391,3863,4099,4217,5279,5869,5987,6577,7639,7757,7993,8111,8819,9173,10589,11887,12241,12713,13421,14011,15073,15427,16253,16607,16843,17551,17669,18731,19793,20029,20147,21563,21799,22153,22271,22861,23333,23687,24631,24749,25339,25457,25693,27109,27581,27817,28289,28643,28879,29587,30059,30649,31121,31357,32183,32537,33599,34543,34897,35251,36313,37021,37139,37493,37847,38083,38201,38791,39499,39971,41269,41387,42331,44101,44809,44927,45281,45989,46933,47051
mov $2,$0
add $2,6
pow $2,2
lpb $2
mov $3,$4
add $3,27
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,59
lpe
mov $0,$4
add $0,28
|
;
; ZX 81 specific routines
; by Stefano Bodrato, 04/08/2009
;
; Copy a variable from basic to float
;
; float zx_getfloat(char *variable);
;
;
; $Id: zx_getfloat.asm,v 1.4 2016-06-26 20:32:08 dom Exp $
;
SECTION code_clib
PUBLIC zx_getfloat
PUBLIC _zx_getfloat
EXTERN zx_locatenum
EXTERN fa
IF FORlambda
INCLUDE "lambdafp.def"
ELSE
INCLUDE "81fp.def"
ENDIF
; hl = char *variable
zx_getfloat:
_zx_getfloat:
call zx_locatenum
jr c,error
; Move from variable to SP calculator
ld a,(hl)
inc hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
ld b,(hl)
call ZXFP_STK_STORE
rst ZXFP_BEGIN_CALC
defb ZXFP_END_CALC ; Now HL points to the float on the FP stack
ld (ZXFP_STK_PTR),hl ; update the FP stack pointer (equalise)
ld de,fa+5
ld b,5
.bloop2
ld a,(hl)
ld (de),a
inc hl
dec de
djnz bloop2
ret
error: ; force zero
ld hl,fa+5
ld (hl),0
ld d,h
ld e,l
dec de
ld bc,5
lddr
ret
|
Route5_Script:
jp EnableAutoTextBoxDrawing
Route5_TextPointers:
dw Route5Text1
Route5Text1:
text_far _Route5Text1
text_end
|
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
for (int k = a; k <= b; k++)
{
int part1 = k / 100;
int part2 = k % 100;
if (part1 * part1 == part2)
{
cout << k << " ";
}
}
cout << endl;
return 0;
} |
; A135497: a(n) = n^5 - n^2.
; 0,0,28,234,1008,3100,7740,16758,32704,58968,99900,160930,248688,371124,537628,759150,1048320,1419568,1889244,2475738,3199600,4083660,5153148,6435814,7962048,9765000,11880700,14348178,17209584,20510308,24299100,28628190,33553408,39134304,45434268,52520650,60464880,69342588,79233724,90222678,102398400,115854520,130689468,147006594,164914288,184526100,205960860,229342798,254801664,282472848,312497500,345022650,380201328,418192684,459162108,503281350,550728640,601688808,656353404,714920818,777596400,844592580,916128988,992432574,1073737728,1160286400,1252328220,1350120618,1453928944,1564026588,1680695100,1804224310,1934912448,2073066264,2219001148,2373041250,2535519600,2706778228,2887168284,3077050158,3276793600,3486777840,3707391708,3939033754,4182112368,4437045900,4704262780,4984201638,5277311424,5584051528,5904891900,6240313170,6590806768,6956875044,7339031388,7737800350,8153717760,8587330848,9039198364,9509890698
mov $1,$0
pow $0,5
pow $1,2
sub $0,$1
|
;
; Startup for CP/M
;
; Stefano Bodrato - Apr. 2000
; Apr. 2001: Added MS-DOS protection
;
; Dominic Morris - Jan. 2001: Added argc/argv support
; - Jan. 2001: Added in malloc routines
; - Jan. 2001: File support added
;
; $Id: cpm_crt0.asm,v 1.43 2016/10/31 16:16:33 stefano Exp $
;
; There are a couple of #pragma commands which affect
; this file:
;
; #pragma output nostreams - No stdio disc files
; #pragma output nofileio - No fileio at all, use in conjunction to "-lndos"
; #pragma output noprotectmsdos - strip the MS-DOS protection header
; #pragma output noredir - do not insert the file redirection option while parsing the
; command line arguments (useless if "nostreams" is set)
; #pragma output nogfxglobals - No global variables for graphics (required for GFX on the TIKI-100 and Spectrum +3)
;
; These can cut down the size of the resultant executable
MODULE cpm_crt0
;-------------------------------------------------
; Include zcc_opt.def to find out some information
;-------------------------------------------------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;-----------------------
; Some scope definitions
;-----------------------
EXTERN _main ;main() is always external to crt0
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
IF (startup=2)
org 32768
ELSE
org $100
ENDIF
;----------------------
; Execution starts here
;----------------------
start:
IF !DEFINED_noprotectmsdos
defb $eb,$04 ;DOS protection... JMPS LABE
ex de,hl
jp begin-start+$100
defb $b4,$09 ;DOS protection... MOV AH,9
defb $ba
defw dosmessage ;DOS protection... MOV DX,OFFSET dosmessage
defb $cd,$21 ;DOS protection... INT 21h.
defb $cd,$20 ;DOS protection... INT 20h.
dosmessage:
defm "This program is for a CP/M system."
defb 13,10,'$'
begin:
ENDIF
IF (startup=2)
;EXTERN ASMTAIL
ld hl,$100
ld de,32768
ld bc,$4000 ; max. code size = 16K
ldir
IF !DEFINED_noprotectmsdos
jp 32768+14
ELSE
jp 32768+14-start+begin
ENDIF
ENDIF
call crt0_init_bss ;Initialise any data setup by sdcc
ld (start1+1),sp ;Save entry stack
ld a,($80) ;byte count of length of args
inc a ;we can use this since args are space separated
neg
ld l,a
ld h,-1 ;negative number
IF (startup=3)
ld de,-64-18-18 ;Add on space for atexit() stack and +3 MEM banking
ELSE
ld de,-64 ;Add on space for atexit() stack
ENDIF
add hl,de
add hl,sp
ld sp,hl
ld (exitsp),sp
; Memory banking for Spectrum +3
IF (startup=3)
PUBLIC p3_poke
PUBLIC p3_peek
push hl
ld de,64
add hl,de
ld (p3_poke+1),hl
push hl
ld de,18
add hl,de
ld (p3_peek+1),hl
pop hl
ld d,h
ld e,l
ld hl,pokebyte_code
ld bc,18+18
ldir
pop hl
ENDIF
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
; the compiled program and the stack pointer
IF DEFINED_USING_amalloc
INCLUDE "amalloc.def"
ENDIF
ld hl,$80
ld a,(hl)
ld b,0
and a
jr z,argv_done
ld c,a
add hl,bc ;now points to the end of the command line
INCLUDE "crt0_command_line.asm"
IF DEFINED_Z88DK_USES_SDCC
push hl ;argv
push bc ;argc
ELSE
push bc ;argc
push hl ;argv
ENDIF
call _main ;Call user code
pop bc ;kill argv
pop bc ;kill argc
ld a,(defltdsk) ;Restore default disc
ld e,a
ld c,14
call 5
cleanup:
push hl ;Save return value
IF !DEFINED_nostreams
EXTERN closeall ;Close any opened files
call closeall
ENDIF
pop bc ;Get exit() value into bc
start1: ld sp,0 ;Pick up entry sp
jp 0
;ret
l_dcal: jp (hl) ;Used for call by function ptr
; Memory banking for Spectrum +3
IF (startup=3)
p3_poke:
jp 0
p3_peek:
jp 0
pokebyte_code:
di
; ..$15 00010101 -> banks 4,5,6,3
; ..$11 00010001 -> banks 0,1,2,3 (TPA)
ex af,af
ld a,$15
;ld a,$0D
;ld a,$05
ld bc,$1ffd
out(c),a
ex af,af
ld (hl),a
ld a,$11 ; avoid using ($FF01) to be compatible with CP/M 2.2
;ld a,$09
;ld a,$01
;ld a,($FF01) ; saved value
out(c),a
ei
ret
; adjust code size
nop
peekbyte_code:
di
; ..$15 00010101 -> banks 4,5,6,3
; ..$11 00010001 -> banks 0,1,2,3 (TPA)
ld a,$15
;ld a,$0D
;ld a,$05
ld bc,$1ffd
out(c),a
ld a,(hl)
ex af,af
ld a,$11 ; avoid using ($FF01) to be compatible with CP/M 2.2
;ld a,$09
;ld a,$01
;ld a,($FF01) ; saved value
out(c),a
ex af,af
ei
ret
; adjust code size
nop
ENDIF
defm "Small C+ CP/M"
INCLUDE "crt0_runtime_selection.asm"
INCLUDE "crt0_section.asm"
SECTION code_crt_init
ld c,25
call 5
ld (defltdsk),a
SECTION bss_crt
;-----------------------
; Some startup variables
;-----------------------
PUBLIC defltdsk
defltdsk: defb 0 ;Default disc
IF !DEFINED_nofileio
PUBLIC __fcb
__fcb: defs 420,0 ;file control block (10 files) (MAXFILE)
ENDIF
;-----------------------------------------------------
; Unneccessary file signature + target specific stuff
;-----------------------------------------------------
PUBLIC _vdcDispMem
_vdcDispMem: ; Label used by "c128cpm.lib" only
end: defb 0 ; null file name
IF !DEFINED_nogfxglobals
PUBLIC RG0SAV
PUBLIC pixelbyte
RG0SAV: defb 1*8 ; VDP graphics driver (Einstein)
; Also used to remember the border color for the ZX Spectrum +3
; in CP/M mode (Blue is default)
pixelbyte: defb 0 ; temp byte storage for VDP driver
ENDIF
SECTION rodata_clib
IF !DEFINED_noredir
IF !DEFINED_nostreams
redir_fopen_flag: defb 'w',0
redir_fopen_flagr: defb 'r',0
ENDIF
ENDIF
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x7ded, %rsi
nop
nop
nop
nop
nop
add %r13, %r13
movw $0x6162, (%rsi)
cmp %r13, %r13
lea addresses_WC_ht+0x15ae9, %rsi
lea addresses_WC_ht+0x19109, %rdi
cmp %r11, %r11
mov $44, %rcx
rep movsl
nop
sub %rsi, %rsi
lea addresses_WT_ht+0xae9, %rsi
nop
cmp $58512, %rbx
movl $0x61626364, (%rsi)
nop
nop
nop
add $20142, %r15
lea addresses_A_ht+0xb839, %r15
nop
nop
nop
add $32506, %rbx
movb $0x61, (%r15)
nop
nop
add $44481, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r14
push %r8
push %r9
push %rdx
// Store
lea addresses_WT+0xa99d, %r8
nop
nop
add %rdx, %rdx
movw $0x5152, (%r8)
nop
nop
nop
nop
sub %r10, %r10
// Store
lea addresses_RW+0x7169, %rdx
nop
cmp %r9, %r9
mov $0x5152535455565758, %r8
movq %r8, (%rdx)
and $38762, %r10
// Load
mov $0xa1b, %r9
nop
and $25504, %r14
mov (%r9), %edx
nop
sub $18363, %r14
// Store
lea addresses_US+0x1b2e9, %r9
nop
nop
nop
nop
nop
sub $36837, %r10
movw $0x5152, (%r9)
nop
nop
nop
nop
nop
dec %r10
// Load
lea addresses_US+0x89f7, %rdx
nop
nop
nop
xor %r10, %r10
movb (%rdx), %r8b
nop
nop
nop
nop
sub %r14, %r14
// Store
lea addresses_WT+0xd259, %rdx
and %r11, %r11
movw $0x5152, (%rdx)
xor $50785, %r10
// Faulty Load
lea addresses_US+0x52e9, %rdx
nop
dec %r10
vmovups (%rdx), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r8
lea oracles, %r10
and $0xff, %r8
shlq $12, %r8
mov (%r10,%r8,1), %r8
pop %rdx
pop %r9
pop %r8
pop %r14
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}}
{'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
*/
|
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/worklet/ScatterPermutation.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <ctime>
#include <random>
namespace
{
class Worklet : public vtkm::worklet::WorkletVisitPointsWithCells
{
public:
using ControlSignature = void(CellSetIn cellset,
FieldOutPoint outPointId,
FieldOutPoint outVisit);
using ExecutionSignature = void(InputIndex, VisitIndex, _2, _3);
using InputDomain = _1;
using ScatterType = vtkm::worklet::ScatterPermutation<>;
VTKM_CONT
static ScatterType MakeScatter(const vtkm::cont::ArrayHandle<vtkm::Id>& permutation)
{
return ScatterType(permutation);
}
VTKM_EXEC void operator()(vtkm::Id pointId,
vtkm::IdComponent visit,
vtkm::Id& outPointId,
vtkm::IdComponent& outVisit) const
{
outPointId = pointId;
outVisit = visit;
}
};
template <typename CellSetType>
void RunTest(const CellSetType& cellset, const vtkm::cont::ArrayHandle<vtkm::Id>& permutation)
{
vtkm::cont::ArrayHandle<vtkm::Id> outPointId;
vtkm::cont::ArrayHandle<vtkm::IdComponent> outVisit;
vtkm::worklet::DispatcherMapTopology<Worklet> dispatcher(Worklet::MakeScatter(permutation));
dispatcher.Invoke(cellset, outPointId, outVisit);
for (vtkm::Id i = 0; i < permutation.GetNumberOfValues(); ++i)
{
VTKM_TEST_ASSERT(outPointId.ReadPortal().Get(i) == permutation.ReadPortal().Get(i),
"output point ids do not match the permutation");
VTKM_TEST_ASSERT(outVisit.ReadPortal().Get(i) == 0, "incorrect visit index");
}
}
void TestScatterPermutation()
{
vtkm::cont::DataSet dataset = vtkm::cont::testing::MakeTestDataSet().Make2DUniformDataSet0();
auto cellset = dataset.GetCellSet();
vtkm::Id numberOfPoints = cellset.GetNumberOfPoints();
vtkm::UInt32 seed = static_cast<vtkm::UInt32>(std::time(nullptr));
std::default_random_engine generator;
generator.seed(seed);
std::uniform_int_distribution<vtkm::Id> countDistribution(1, 2 * numberOfPoints);
std::uniform_int_distribution<vtkm::Id> ptidDistribution(0, numberOfPoints - 1);
const int iterations = 5;
std::cout << "Testing with random permutations " << iterations << " times\n";
std::cout << "Seed: " << seed << std::endl;
for (int i = 1; i <= iterations; ++i)
{
std::cout << "iteration: " << i << "\n";
vtkm::Id count = countDistribution(generator);
vtkm::cont::ArrayHandle<vtkm::Id> permutation;
permutation.Allocate(count);
auto portal = permutation.WritePortal();
std::cout << "using permutation:";
for (vtkm::Id j = 0; j < count; ++j)
{
auto val = ptidDistribution(generator);
std::cout << " " << val;
portal.Set(j, val);
}
std::cout << "\n";
RunTest(cellset, permutation);
}
}
} // anonymous namespace
int UnitTestScatterPermutation(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestScatterPermutation, argc, argv);
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Optimized pq of N source vectors using SSE3
;;; int pq_check_sse(int vects, int len, void **array)
;;; Generates P+Q parity vector from N (vects-2) sources in array of pointers
;;; (**array). Last two pointers are the P and Q destinations respectively.
;;; Vectors must be aligned to 16 bytes. Length must be 16 byte aligned.
%include "reg_sizes.asm"
%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 tmp3 arg4
%define return rax
%define func(x) x:
%define FUNC_SAVE
%define FUNC_RESTORE
%endif
%ifidn __OUTPUT_FORMAT__, win64
%define arg0 rcx
%define arg1 rdx
%define arg2 r8
%define arg3 r9
%define tmp r11
%define tmp3 r10
%define return rax
%define stack_size 7*16 + 8 ; must be an odd multiple of 8
%define func(x) proc_frame x
%macro FUNC_SAVE 0
alloc_stack stack_size
save_xmm128 xmm6, 0*16
save_xmm128 xmm7, 1*16
save_xmm128 xmm8, 2*16
save_xmm128 xmm9, 3*16
save_xmm128 xmm10, 4*16
save_xmm128 xmm11, 5*16
save_xmm128 xmm15, 6*16
end_prolog
%endmacro
%macro FUNC_RESTORE 0
movdqa xmm6, [rsp + 0*16]
movdqa xmm7, [rsp + 1*16]
movdqa xmm8, [rsp + 2*16]
movdqa xmm9, [rsp + 3*16]
movdqa xmm10, [rsp + 4*16]
movdqa xmm11, [rsp + 5*16]
movdqa xmm15, [rsp + 9*16]
add rsp, stack_size
%endmacro
%endif
%define vec arg0
%define len arg1
%define ptr arg3
%define pos return
%define xp1 xmm0
%define xq1 xmm1
%define xtmp1 xmm2
%define xs1 xmm3
%define xp2 xmm4
%define xq2 xmm5
%define xtmp2 xmm6
%define xs2 xmm7
%define xp3 xmm8
%define xq3 xmm9
%define xtmp3 xmm10
%define xs3 xmm11
%define xpoly xmm15
;;; Use Non-temporal load/stor
%ifdef NO_NT_LDST
%define XLDR movdqa
%define XSTR movdqa
%else
%define XLDR movdqa
%define XSTR movntdq
%endif
default rel
[bits 64]
section .text
align 16
mk_global pq_check_sse, function
func(pq_check_sse)
FUNC_SAVE
sub vec, 3 ;Keep as offset to last source
jng return_fail ;Must have at least 2 sources
cmp len, 0
je return_pass
test len, (16-1) ;Check alignment of length
jnz return_fail
mov pos, 0
movdqa xpoly, [poly]
cmp len, 48
jl loop16
len_aligned_32bytes:
sub len, 48 ;Do end of vec first and run backward
loop48:
mov ptr, [arg2+8+vec*8] ;Get address of P parity vector
mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
XLDR xp1, [ptr+pos] ;Initialize xp1 with P1 src
XLDR xp2, [ptr+pos+16] ;Initialize xp2 with P2 src + 16B ahead
XLDR xp3, [ptr+pos+32] ;Initialize xp3 with P2 src + 32B ahead
pxor xq1, xq1 ;q1 = 0
pxor xq2, xq2 ;q2 = 0
pxor xq3, xq3 ;q3 = 0
mov ptr, [arg2+vec*8] ;Fetch last source pointer
mov tmp, vec ;Set tmp to point back to last vector
XLDR xs1, [ptr+pos] ;Preload last vector (source)
XLDR xs2, [ptr+pos+16] ;Preload last vector (source)
XLDR xs3, [ptr+pos+32] ;Preload last vector (source)
next_vect:
sub tmp, 1 ;Inner loop for each source vector
mov ptr, [arg2+tmp*8] ; get pointer to next vect
pxor xp1, xs1 ; p1 ^= s1
pxor xp2, xs2 ; p2 ^= s2
pxor xp3, xs3 ; p3 ^= s2
pxor xq1, xs1 ; q1 ^= s1
pxor xq2, xs2 ; q2 ^= s2
pxor xq3, xs3 ; q3 ^= s3
pxor xtmp1, xtmp1 ; xtmp1 = 0 - for compare to 0
pxor xtmp2, xtmp2 ; xtmp2 = 0
pxor xtmp3, xtmp3 ; xtmp3 = 0
pcmpgtb xtmp1, xq1 ; xtmp1 = mask 0xff or 0x00 if bit7 set
pcmpgtb xtmp2, xq2 ; xtmp2 = mask 0xff or 0x00 if bit7 set
pcmpgtb xtmp3, xq3 ; xtmp3 = mask 0xff or 0x00 if bit7 set
pand xtmp1, xpoly ; xtmp1 = poly or 0x00
pand xtmp2, xpoly ; xtmp2 = poly or 0x00
pand xtmp3, xpoly ; xtmp3 = poly or 0x00
XLDR xs1, [ptr+pos] ; Get next vector (source data1)
XLDR xs2, [ptr+pos+16] ; Get next vector (source data2)
XLDR xs3, [ptr+pos+32] ; Get next vector (source data3)
paddb xq1, xq1 ; q1 = q1<<1
paddb xq2, xq2 ; q2 = q2<<1
paddb xq3, xq3 ; q3 = q3<<1
pxor xq1, xtmp1 ; q1 = q1<<1 ^ poly_masked
pxor xq2, xtmp2 ; q2 = q2<<1 ^ poly_masked
pxor xq3, xtmp3 ; q3 = q3<<1 ^ poly_masked
jg next_vect ; Loop for each vect except 0
pxor xp1, xs1 ;p1 ^= s1[0] - last source is already loaded
pxor xq1, xs1 ;q1 ^= 1 * s1[0]
pxor xp2, xs2 ;p2 ^= s2[0]
pxor xq2, xs2 ;q2 ^= 1 * s2[0]
pxor xp3, xs3 ;p3 ^= s3[0]
pxor xq3, xs3 ;q3 ^= 1 * s3[0]
mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
XLDR xtmp1, [tmp+pos] ;re-init xq1 with Q1 src
XLDR xtmp2, [tmp+pos+16] ;re-init xq2 with Q2 src + 16B ahead
XLDR xtmp3, [tmp+pos+32] ;re-init xq3 with Q2 src + 32B ahead
pxor xq1, xtmp1 ;xq1 = q1 calculated ^ q1 saved
pxor xq2, xtmp2
pxor xq3, xtmp3
por xp1, xq1 ;Confirm that all P&Q parity are 0
por xp1, xp2
por xp1, xq2
por xp1, xp3
por xp1, xq3
ptest xp1, xp1
jnz return_fail
add pos, 48
cmp pos, len
jle loop48
;; ------------------------------
;; Do last 16 or 32 Bytes remaining
add len, 48
cmp pos, len
je return_pass
loop16:
mov ptr, [arg2+8+vec*8] ;Get address of P parity vector
mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
XLDR xp1, [ptr+pos] ;Initialize xp1 with P1 src
pxor xq1, xq1 ;q = 0
mov ptr, [arg2+vec*8] ;Fetch last source pointer
mov tmp, vec ;Set tmp to point back to last vector
XLDR xs1, [ptr+pos] ;Preload last vector (source)
next_vect16:
sub tmp, 1 ;Inner loop for each source vector
mov ptr, [arg2+tmp*8] ; get pointer to next vect
pxor xq1, xs1 ; q ^= s
pxor xtmp1, xtmp1 ; xtmp = 0
pcmpgtb xtmp1, xq1 ; xtmp = mask 0xff or 0x00 if bit7 set
pand xtmp1, xpoly ; xtmp = poly or 0x00
pxor xp1, xs1 ; p ^= s
paddb xq1, xq1 ; q = q<<1
pxor xq1, xtmp1 ; q = q<<1 ^ poly_masked
XLDR xs1, [ptr+pos] ; Get next vector (source data)
jg next_vect16 ; Loop for each vect except 0
pxor xp1, xs1 ;p ^= s[0] - last source is already loaded
pxor xq1, xs1 ;q ^= 1 * s[0]
mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
XLDR xtmp1, [tmp+pos] ;re-init tmp with Q1 src
pxor xq1, xtmp1 ;xq1 = q1 calculated ^ q1 saved
por xp1, xq1 ;Confirm that all P&Q parity are = 0
ptest xp1, xp1
jnz return_fail
add pos, 16
cmp pos, len
jl loop16
return_pass:
mov return, 0
FUNC_RESTORE
ret
return_fail:
mov return, 1
FUNC_RESTORE
ret
endproc_frame
section .data
align 16
poly:
dq 0x1d1d1d1d1d1d1d1d, 0x1d1d1d1d1d1d1d1d
;;; func core, ver, snum
slversion pq_check_sse, 00, 06, 0033
|
/*
* 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/cwp/v20180228/model/DescribeSaveOrUpdateWarningsRequest.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::Cwp::V20180228::Model;
using namespace std;
DescribeSaveOrUpdateWarningsRequest::DescribeSaveOrUpdateWarningsRequest() :
m_warningObjectsHasBeenSet(false)
{
}
string DescribeSaveOrUpdateWarningsRequest::ToJsonString() const
{
rapidjson::Document d;
d.SetObject();
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();
if (m_warningObjectsHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "WarningObjects";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator);
int i=0;
for (auto itr = m_warningObjects.begin(); itr != m_warningObjects.end(); ++itr, ++i)
{
d[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
(*itr).ToJsonObject(d[key.c_str()][i], allocator);
}
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
d.Accept(writer);
return buffer.GetString();
}
vector<WarningObject> DescribeSaveOrUpdateWarningsRequest::GetWarningObjects() const
{
return m_warningObjects;
}
void DescribeSaveOrUpdateWarningsRequest::SetWarningObjects(const vector<WarningObject>& _warningObjects)
{
m_warningObjects = _warningObjects;
m_warningObjectsHasBeenSet = true;
}
bool DescribeSaveOrUpdateWarningsRequest::WarningObjectsHasBeenSet() const
{
return m_warningObjectsHasBeenSet;
}
|
; A024082: 7^n-n^7.
; 1,6,-79,-1844,-13983,-61318,-162287,0,3667649,35570638,272475249,1957839572,13805455393,96826261890,678117659345,4747390650568,33232662134145,232630103648534,1628412985690417,11398894291501404,79792265017612001,558545862282195466,3909821046088630161,27368747336676090896,191581231375979942977,1341068619657861385182,9387480337639722495473,65712362363523819786340,459986536544726468048289,3219905755813162476961298,22539340290692236217863249,157775382034845779102428632,1104427674243920611945560833
mov $1,7
pow $1,$0
pow $0,7
add $0,1
sub $1,$0
add $1,1
mov $0,$1
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__delete_struct_static_52a.cpp
Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete.nonpointer.label.xml
Template File: sources-sink-52a.tmpl.cpp
*/
/*
* @description
* CWE: 590 Free Memory Not on Heap
* BadSource: static Data buffer is declared static on the stack
* GoodSource: Allocate memory on the heap
* Sink:
* BadSink : Print then free data
* Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_static_52
{
#ifndef OMITBAD
/* bad function declaration */
void badSink_b(twoIntsStruct * data);
void bad()
{
twoIntsStruct * data;
data = NULL; /* Initialize data */
{
/* FLAW: data is allocated on the stack and deallocated in the BadSink */
static twoIntsStruct dataBuffer;
dataBuffer.intOne = 1;
dataBuffer.intTwo = 1;
data = &dataBuffer;
}
badSink_b(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
void goodG2BSink_b(twoIntsStruct * data);
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
twoIntsStruct * data;
data = NULL; /* Initialize data */
{
/* FIX: data is allocated on the heap and deallocated in the BadSink */
twoIntsStruct * dataBuffer = new twoIntsStruct;
dataBuffer->intOne = 2;
dataBuffer->intTwo = 2;
data = dataBuffer;
}
goodG2BSink_b(data);
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_static_52; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2015, 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:
;
; LRotU64.nasm
;
; Abstract:
;
; 64-bit left rotation for Ia32
;
;------------------------------------------------------------------------------
SECTION .text
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathLRotU64 (
; IN UINT64 Operand,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
global ASM_PFX(InternalMathLRotU64)
ASM_PFX(InternalMathLRotU64):
push ebx
mov cl, [esp + 16]
mov edx, [esp + 12]
mov eax, [esp + 8]
shld ebx, edx, cl
shld edx, eax, cl
ror ebx, cl
shld eax, ebx, cl
test cl, 32 ; Count >= 32?
jz .0
mov ecx, eax
mov eax, edx
mov edx, ecx
.0:
pop ebx
ret
|
_forktest: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "fork test OK\n");
}
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
forktest();
11: e8 3a 00 00 00 call 50 <forktest>
exit();
16: e8 87 03 00 00 call 3a2 <exit>
1b: 66 90 xchg %ax,%ax
1d: 66 90 xchg %ax,%ax
1f: 90 nop
00000020 <printf>:
{
20: 55 push %ebp
21: 89 e5 mov %esp,%ebp
23: 53 push %ebx
24: 83 ec 10 sub $0x10,%esp
27: 8b 5d 0c mov 0xc(%ebp),%ebx
write(fd, s, strlen(s));
2a: 53 push %ebx
2b: e8 a0 01 00 00 call 1d0 <strlen>
30: 83 c4 0c add $0xc,%esp
33: 50 push %eax
34: 53 push %ebx
35: ff 75 08 pushl 0x8(%ebp)
38: e8 85 03 00 00 call 3c2 <write>
}
3d: 83 c4 10 add $0x10,%esp
40: 8b 5d fc mov -0x4(%ebp),%ebx
43: c9 leave
44: c3 ret
45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000050 <forktest>:
{
50: 55 push %ebp
51: 89 e5 mov %esp,%ebp
53: 53 push %ebx
for(n=0; n<N; n++){
54: 31 db xor %ebx,%ebx
{
56: 83 ec 10 sub $0x10,%esp
write(fd, s, strlen(s));
59: 68 4c 04 00 00 push $0x44c
5e: e8 6d 01 00 00 call 1d0 <strlen>
63: 83 c4 0c add $0xc,%esp
66: 50 push %eax
67: 68 4c 04 00 00 push $0x44c
6c: 6a 01 push $0x1
6e: e8 4f 03 00 00 call 3c2 <write>
73: 83 c4 10 add $0x10,%esp
76: eb 19 jmp 91 <forktest+0x41>
78: 90 nop
79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(pid == 0)
80: 0f 84 7c 00 00 00 je 102 <forktest+0xb2>
for(n=0; n<N; n++){
86: 83 c3 01 add $0x1,%ebx
89: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
8f: 74 4f je e0 <forktest+0x90>
pid = fork();
91: e8 04 03 00 00 call 39a <fork>
if(pid < 0)
96: 85 c0 test %eax,%eax
98: 79 e6 jns 80 <forktest+0x30>
for(; n > 0; n--){
9a: 85 db test %ebx,%ebx
9c: 74 10 je ae <forktest+0x5e>
9e: 66 90 xchg %ax,%ax
if(wait() < 0){
a0: e8 05 03 00 00 call 3aa <wait>
a5: 85 c0 test %eax,%eax
a7: 78 5e js 107 <forktest+0xb7>
for(; n > 0; n--){
a9: 83 eb 01 sub $0x1,%ebx
ac: 75 f2 jne a0 <forktest+0x50>
if(wait() != -1){
ae: e8 f7 02 00 00 call 3aa <wait>
b3: 83 f8 ff cmp $0xffffffff,%eax
b6: 75 71 jne 129 <forktest+0xd9>
write(fd, s, strlen(s));
b8: 83 ec 0c sub $0xc,%esp
bb: 68 7e 04 00 00 push $0x47e
c0: e8 0b 01 00 00 call 1d0 <strlen>
c5: 83 c4 0c add $0xc,%esp
c8: 50 push %eax
c9: 68 7e 04 00 00 push $0x47e
ce: 6a 01 push $0x1
d0: e8 ed 02 00 00 call 3c2 <write>
}
d5: 8b 5d fc mov -0x4(%ebp),%ebx
d8: c9 leave
d9: c3 ret
da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
write(fd, s, strlen(s));
e0: 83 ec 0c sub $0xc,%esp
e3: 68 8c 04 00 00 push $0x48c
e8: e8 e3 00 00 00 call 1d0 <strlen>
ed: 83 c4 0c add $0xc,%esp
f0: 50 push %eax
f1: 68 8c 04 00 00 push $0x48c
f6: 6a 01 push $0x1
f8: e8 c5 02 00 00 call 3c2 <write>
exit();
fd: e8 a0 02 00 00 call 3a2 <exit>
exit();
102: e8 9b 02 00 00 call 3a2 <exit>
write(fd, s, strlen(s));
107: 83 ec 0c sub $0xc,%esp
10a: 68 57 04 00 00 push $0x457
10f: e8 bc 00 00 00 call 1d0 <strlen>
114: 83 c4 0c add $0xc,%esp
117: 50 push %eax
118: 68 57 04 00 00 push $0x457
11d: 6a 01 push $0x1
11f: e8 9e 02 00 00 call 3c2 <write>
exit();
124: e8 79 02 00 00 call 3a2 <exit>
write(fd, s, strlen(s));
129: 83 ec 0c sub $0xc,%esp
12c: 68 6b 04 00 00 push $0x46b
131: e8 9a 00 00 00 call 1d0 <strlen>
136: 83 c4 0c add $0xc,%esp
139: 50 push %eax
13a: 68 6b 04 00 00 push $0x46b
13f: 6a 01 push $0x1
141: e8 7c 02 00 00 call 3c2 <write>
exit();
146: e8 57 02 00 00 call 3a2 <exit>
14b: 66 90 xchg %ax,%ax
14d: 66 90 xchg %ax,%ax
14f: 90 nop
00000150 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 53 push %ebx
154: 8b 45 08 mov 0x8(%ebp),%eax
157: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
15a: 89 c2 mov %eax,%edx
15c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
160: 83 c1 01 add $0x1,%ecx
163: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
167: 83 c2 01 add $0x1,%edx
16a: 84 db test %bl,%bl
16c: 88 5a ff mov %bl,-0x1(%edx)
16f: 75 ef jne 160 <strcpy+0x10>
;
return os;
}
171: 5b pop %ebx
172: 5d pop %ebp
173: c3 ret
174: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
17a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000180 <strcmp>:
int
strcmp(const char *p, const char *q)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 53 push %ebx
184: 8b 55 08 mov 0x8(%ebp),%edx
187: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
18a: 0f b6 02 movzbl (%edx),%eax
18d: 0f b6 19 movzbl (%ecx),%ebx
190: 84 c0 test %al,%al
192: 75 1c jne 1b0 <strcmp+0x30>
194: eb 2a jmp 1c0 <strcmp+0x40>
196: 8d 76 00 lea 0x0(%esi),%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1a0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
1a3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1a6: 83 c1 01 add $0x1,%ecx
1a9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
1ac: 84 c0 test %al,%al
1ae: 74 10 je 1c0 <strcmp+0x40>
1b0: 38 d8 cmp %bl,%al
1b2: 74 ec je 1a0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
1b4: 29 d8 sub %ebx,%eax
}
1b6: 5b pop %ebx
1b7: 5d pop %ebp
1b8: c3 ret
1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1c0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1c2: 29 d8 sub %ebx,%eax
}
1c4: 5b pop %ebx
1c5: 5d pop %ebp
1c6: c3 ret
1c7: 89 f6 mov %esi,%esi
1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001d0 <strlen>:
uint
strlen(const char *s)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1d6: 80 39 00 cmpb $0x0,(%ecx)
1d9: 74 15 je 1f0 <strlen+0x20>
1db: 31 d2 xor %edx,%edx
1dd: 8d 76 00 lea 0x0(%esi),%esi
1e0: 83 c2 01 add $0x1,%edx
1e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1e7: 89 d0 mov %edx,%eax
1e9: 75 f5 jne 1e0 <strlen+0x10>
;
return n;
}
1eb: 5d pop %ebp
1ec: c3 ret
1ed: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
1f0: 31 c0 xor %eax,%eax
}
1f2: 5d pop %ebp
1f3: c3 ret
1f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000200 <memset>:
void*
memset(void *dst, int c, uint n)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 57 push %edi
204: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
207: 8b 4d 10 mov 0x10(%ebp),%ecx
20a: 8b 45 0c mov 0xc(%ebp),%eax
20d: 89 d7 mov %edx,%edi
20f: fc cld
210: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
212: 89 d0 mov %edx,%eax
214: 5f pop %edi
215: 5d pop %ebp
216: c3 ret
217: 89 f6 mov %esi,%esi
219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000220 <strchr>:
char*
strchr(const char *s, char c)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 53 push %ebx
224: 8b 45 08 mov 0x8(%ebp),%eax
227: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
22a: 0f b6 10 movzbl (%eax),%edx
22d: 84 d2 test %dl,%dl
22f: 74 1d je 24e <strchr+0x2e>
if(*s == c)
231: 38 d3 cmp %dl,%bl
233: 89 d9 mov %ebx,%ecx
235: 75 0d jne 244 <strchr+0x24>
237: eb 17 jmp 250 <strchr+0x30>
239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
240: 38 ca cmp %cl,%dl
242: 74 0c je 250 <strchr+0x30>
for(; *s; s++)
244: 83 c0 01 add $0x1,%eax
247: 0f b6 10 movzbl (%eax),%edx
24a: 84 d2 test %dl,%dl
24c: 75 f2 jne 240 <strchr+0x20>
return (char*)s;
return 0;
24e: 31 c0 xor %eax,%eax
}
250: 5b pop %ebx
251: 5d pop %ebp
252: c3 ret
253: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <gets>:
char*
gets(char *buf, int max)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 57 push %edi
264: 56 push %esi
265: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
266: 31 f6 xor %esi,%esi
268: 89 f3 mov %esi,%ebx
{
26a: 83 ec 1c sub $0x1c,%esp
26d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
270: eb 2f jmp 2a1 <gets+0x41>
272: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
278: 8d 45 e7 lea -0x19(%ebp),%eax
27b: 83 ec 04 sub $0x4,%esp
27e: 6a 01 push $0x1
280: 50 push %eax
281: 6a 00 push $0x0
283: e8 32 01 00 00 call 3ba <read>
if(cc < 1)
288: 83 c4 10 add $0x10,%esp
28b: 85 c0 test %eax,%eax
28d: 7e 1c jle 2ab <gets+0x4b>
break;
buf[i++] = c;
28f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
293: 83 c7 01 add $0x1,%edi
296: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
299: 3c 0a cmp $0xa,%al
29b: 74 23 je 2c0 <gets+0x60>
29d: 3c 0d cmp $0xd,%al
29f: 74 1f je 2c0 <gets+0x60>
for(i=0; i+1 < max; ){
2a1: 83 c3 01 add $0x1,%ebx
2a4: 3b 5d 0c cmp 0xc(%ebp),%ebx
2a7: 89 fe mov %edi,%esi
2a9: 7c cd jl 278 <gets+0x18>
2ab: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
2ad: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2b0: c6 03 00 movb $0x0,(%ebx)
}
2b3: 8d 65 f4 lea -0xc(%ebp),%esp
2b6: 5b pop %ebx
2b7: 5e pop %esi
2b8: 5f pop %edi
2b9: 5d pop %ebp
2ba: c3 ret
2bb: 90 nop
2bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2c0: 8b 75 08 mov 0x8(%ebp),%esi
2c3: 8b 45 08 mov 0x8(%ebp),%eax
2c6: 01 de add %ebx,%esi
2c8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2ca: c6 03 00 movb $0x0,(%ebx)
}
2cd: 8d 65 f4 lea -0xc(%ebp),%esp
2d0: 5b pop %ebx
2d1: 5e pop %esi
2d2: 5f pop %edi
2d3: 5d pop %ebp
2d4: c3 ret
2d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002e0 <stat>:
int
stat(const char *n, struct stat *st)
{
2e0: 55 push %ebp
2e1: 89 e5 mov %esp,%ebp
2e3: 56 push %esi
2e4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
2e5: 83 ec 08 sub $0x8,%esp
2e8: 6a 00 push $0x0
2ea: ff 75 08 pushl 0x8(%ebp)
2ed: e8 f0 00 00 00 call 3e2 <open>
if(fd < 0)
2f2: 83 c4 10 add $0x10,%esp
2f5: 85 c0 test %eax,%eax
2f7: 78 27 js 320 <stat+0x40>
return -1;
r = fstat(fd, st);
2f9: 83 ec 08 sub $0x8,%esp
2fc: ff 75 0c pushl 0xc(%ebp)
2ff: 89 c3 mov %eax,%ebx
301: 50 push %eax
302: e8 f3 00 00 00 call 3fa <fstat>
close(fd);
307: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
30a: 89 c6 mov %eax,%esi
close(fd);
30c: e8 b9 00 00 00 call 3ca <close>
return r;
311: 83 c4 10 add $0x10,%esp
}
314: 8d 65 f8 lea -0x8(%ebp),%esp
317: 89 f0 mov %esi,%eax
319: 5b pop %ebx
31a: 5e pop %esi
31b: 5d pop %ebp
31c: c3 ret
31d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
320: be ff ff ff ff mov $0xffffffff,%esi
325: eb ed jmp 314 <stat+0x34>
327: 89 f6 mov %esi,%esi
329: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000330 <atoi>:
int
atoi(const char *s)
{
330: 55 push %ebp
331: 89 e5 mov %esp,%ebp
333: 53 push %ebx
334: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
337: 0f be 11 movsbl (%ecx),%edx
33a: 8d 42 d0 lea -0x30(%edx),%eax
33d: 3c 09 cmp $0x9,%al
n = 0;
33f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
344: 77 1f ja 365 <atoi+0x35>
346: 8d 76 00 lea 0x0(%esi),%esi
349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
350: 8d 04 80 lea (%eax,%eax,4),%eax
353: 83 c1 01 add $0x1,%ecx
356: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
35a: 0f be 11 movsbl (%ecx),%edx
35d: 8d 5a d0 lea -0x30(%edx),%ebx
360: 80 fb 09 cmp $0x9,%bl
363: 76 eb jbe 350 <atoi+0x20>
return n;
}
365: 5b pop %ebx
366: 5d pop %ebp
367: c3 ret
368: 90 nop
369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000370 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
370: 55 push %ebp
371: 89 e5 mov %esp,%ebp
373: 56 push %esi
374: 53 push %ebx
375: 8b 5d 10 mov 0x10(%ebp),%ebx
378: 8b 45 08 mov 0x8(%ebp),%eax
37b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
37e: 85 db test %ebx,%ebx
380: 7e 14 jle 396 <memmove+0x26>
382: 31 d2 xor %edx,%edx
384: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
388: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
38c: 88 0c 10 mov %cl,(%eax,%edx,1)
38f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
392: 39 d3 cmp %edx,%ebx
394: 75 f2 jne 388 <memmove+0x18>
return vdst;
}
396: 5b pop %ebx
397: 5e pop %esi
398: 5d pop %ebp
399: c3 ret
0000039a <fork>:
39a: b8 01 00 00 00 mov $0x1,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <exit>:
3a2: b8 02 00 00 00 mov $0x2,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <wait>:
3aa: b8 03 00 00 00 mov $0x3,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <pipe>:
3b2: b8 04 00 00 00 mov $0x4,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <read>:
3ba: b8 05 00 00 00 mov $0x5,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <write>:
3c2: b8 10 00 00 00 mov $0x10,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <close>:
3ca: b8 15 00 00 00 mov $0x15,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <kill>:
3d2: b8 06 00 00 00 mov $0x6,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <exec>:
3da: b8 07 00 00 00 mov $0x7,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <open>:
3e2: b8 0f 00 00 00 mov $0xf,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <mknod>:
3ea: b8 11 00 00 00 mov $0x11,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <unlink>:
3f2: b8 12 00 00 00 mov $0x12,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <fstat>:
3fa: b8 08 00 00 00 mov $0x8,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <link>:
402: b8 13 00 00 00 mov $0x13,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <mkdir>:
40a: b8 14 00 00 00 mov $0x14,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <chdir>:
412: b8 09 00 00 00 mov $0x9,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <dup>:
41a: b8 0a 00 00 00 mov $0xa,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <getpid>:
422: b8 0b 00 00 00 mov $0xb,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <sbrk>:
42a: b8 0c 00 00 00 mov $0xc,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <sleep>:
432: b8 0d 00 00 00 mov $0xd,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <uptime>:
43a: b8 0e 00 00 00 mov $0xe,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <getreadcount>:
442: b8 16 00 00 00 mov $0x16,%eax
447: cd 40 int $0x40
449: c3 ret
|
.byte 0x02,0x00,0x09,0x00
.word 0x08095838
.byte 0x09,0x00,0x0F,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x01,0x00,0x00
.byte 0x00,0x1E,0x00,0x03
.byte 0x09,0x00,0x00,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x20,0x52,0x0A,0x00
.byte 0x44,0x46,0x00,0x00
.byte 0x09,0x00,0x01,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x64,0x98,0x0A,0x00
.byte 0xB0,0x04,0x00,0x00
.byte 0x09,0x00,0x02,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x14,0x9D,0x0A,0x00
.byte 0xF0,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x0E,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x09,0x00,0x08,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x1E,0x00,0x00,0x00
.byte 0x14,0x00,0x00,0x00
.byte 0x09,0x00,0x03,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x09,0x00,0x09,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x11,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x08,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0D,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x41,0x00,0x00,0x00
.byte 0x01,0x00,0x01,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x42,0x00,0x00,0x00
.byte 0xF0,0x00,0x00,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x46,0x00,0x00,0x00
.byte 0x14,0x00,0x00,0x00
.byte 0x0C,0x00,0x02,0x00
.byte 0x48,0x00,0x00,0x00
.byte 0x3F,0x00,0x00,0x00
.byte 0x0C,0x00,0x01,0x00
.byte 0x48,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x4A,0x00,0x00,0x00
.byte 0x3F,0x00,0x00,0x00
.byte 0x0C,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x40,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0D,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x41,0x00,0x00,0x00
loadCharsAndSfx s_naporon1lose1
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0D,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x43,0x00,0x00,0x00
loadCharsAndSfx s_naporon1lose2
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x06,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x44,0x00,0x00,0x00
loadCharsAndSfx s_naporon1lose3
.byte 0x02,0x00,0x09,0x00
.word 0x08095F3C
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0F,0x00,0x02,0x00
.byte 0x07,0xFF,0xFF,0x7F
.byte 0x02,0x00,0x09,0x00
.word MinigameUnlock
.byte 0x00,0x00,0x01,0x00 |
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2020, STEREOLABS.
//
// All rights reserved.
//
// 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 "zed_wrapper_nodelet.hpp"
#include <csignal>
#include <chrono>
#ifndef NDEBUG
#include <ros/console.h>
#endif
#include "zed_interfaces/ObjectStamped.h"
#include "zed_interfaces/Objects.h"
#include "visualization_msgs/Marker.h"
#include "visualization_msgs/MarkerArray.h"
//#define DEBUG_SENS_TS 1
namespace zed_nodelets {
#ifndef DEG2RAD
#define DEG2RAD 0.017453293
#define RAD2DEG 57.295777937
#endif
#define MAG_FREQ 50.
#define BARO_FREQ 25.
ZEDWrapperNodelet::ZEDWrapperNodelet() : Nodelet() {}
ZEDWrapperNodelet::~ZEDWrapperNodelet() {
if (mDevicePollThread.joinable()) {
mDevicePollThread.join();
}
/*if (mPcThread.joinable()) {
mPcThread.join();
}*/
}
void ZEDWrapperNodelet::onInit() {
// Node handlers
mNh = getMTNodeHandle();
mNhNs = getMTPrivateNodeHandle();
mStopNode = false;
mPcDataReady = false;
mRgbDepthDataRetrieved = true;
#ifndef NDEBUG
if (ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME,
ros::console::levels::Debug)) {
ros::console::notifyLoggerLevelsChanged();
}
#endif
NODELET_INFO( "********** Starting nodelet '%s' **********",getName().c_str() );
std::string ver = sl_tools::getSDKVersion(mVerMajor, mVerMinor, mVerSubMinor);
NODELET_INFO_STREAM("SDK version : " << ver);
if( mVerMajor < 3 ) {
NODELET_ERROR( "This version of the ZED ROS Wrapper is designed to be used with ZED SDK v3.x");
ros::shutdown();
raise(SIGINT);
raise(SIGABRT);
exit(-1);
}
readParameters();
initTransforms();
// Set the video topic names
std::string rgbTopicRoot = "rgb";
std::string rightTopicRoot = "right";
std::string leftTopicRoot = "left";
std::string stereoTopicRoot = "stereo";
std::string img_topic = "/image_rect_color";
std::string img_raw_topic = "/image_raw_color";
std::string img_gray_topic = "/image_rect_gray";
std::string img_raw_gray_topic_ = "/image_raw_gray";
std::string raw_suffix = "_raw";
string left_topic = leftTopicRoot + img_topic;
string left_raw_topic = leftTopicRoot + raw_suffix + img_raw_topic;
string right_topic = rightTopicRoot + img_topic;
string right_raw_topic = rightTopicRoot + raw_suffix + img_raw_topic;
string rgb_topic = rgbTopicRoot + img_topic;
string rgb_raw_topic = rgbTopicRoot + raw_suffix + img_raw_topic;
string stereo_topic = stereoTopicRoot + img_topic;
string stereo_raw_topic = stereoTopicRoot + raw_suffix + img_raw_topic;
string left_gray_topic = leftTopicRoot + img_gray_topic;
string left_raw_gray_topic = leftTopicRoot + raw_suffix + img_raw_gray_topic_;
string right_gray_topic = rightTopicRoot + img_gray_topic;
string right_raw_gray_topic = rightTopicRoot + raw_suffix + img_raw_gray_topic_;
string rgb_gray_topic = rgbTopicRoot + img_gray_topic;
string rgb_raw_gray_topic = rgbTopicRoot + raw_suffix + img_raw_gray_topic_;
// Set the disparity topic name
std::string disparityTopic = "disparity/disparity_image";
// Set the depth topic names
string depth_topic_root = "depth";
if (mOpenniDepthMode) {
NODELET_INFO_STREAM("Openni depth mode activated -> Units: mm, Encoding: MONO16");
}
depth_topic_root += "/depth_registered";
string pointcloud_topic = "point_cloud/cloud_registered";
string pointcloud_fused_topic = "mapping/fused_cloud";
string object_det_topic_root = "obj_det";
string object_det_topic = object_det_topic_root + "/objects";
string object_det_rviz_topic = object_det_topic_root + "/object_markers";
std::string confImgRoot = "confidence";
string conf_map_topic_name = "confidence_map";
string conf_map_topic = confImgRoot + "/" + conf_map_topic_name;
// Set the positional tracking topic names
std::string poseTopic = "pose";
string pose_cov_topic;
pose_cov_topic = poseTopic + "_with_covariance";
std::string odometryTopic = "odom";
string odom_path_topic = "path_odom";
string map_path_topic = "path_map";
// Create camera info
mRgbCamInfoMsg.reset(new sensor_msgs::CameraInfo());
mLeftCamInfoMsg.reset(new sensor_msgs::CameraInfo());
mRightCamInfoMsg.reset(new sensor_msgs::CameraInfo());
mRgbCamInfoRawMsg.reset(new sensor_msgs::CameraInfo());
mLeftCamInfoRawMsg.reset(new sensor_msgs::CameraInfo());
mRightCamInfoRawMsg.reset(new sensor_msgs::CameraInfo());
mDepthCamInfoMsg.reset(new sensor_msgs::CameraInfo());
// Initialization transformation listener
mTfBuffer.reset(new tf2_ros::Buffer);
mTfListener.reset(new tf2_ros::TransformListener(*mTfBuffer));
// Try to initialize the ZED
if (!mSvoFilepath.empty() || !mRemoteStreamAddr.empty()) {
if (!mSvoFilepath.empty()) {
mZedParams.input.setFromSVOFile(mSvoFilepath.c_str());
mZedParams.svo_real_time_mode = true;
} else if (!mRemoteStreamAddr.empty()) {
std::vector<std::string> configStream = sl_tools::split_string(mRemoteStreamAddr, ':');
sl::String ip = sl::String(configStream.at(0).c_str());
if (configStream.size() == 2) {
mZedParams.input.setFromStream(ip, atoi(configStream.at(1).c_str()));
} else {
mZedParams.input.setFromStream(ip);
}
}
mSvoMode = true;
} else {
mZedParams.camera_fps = mCamFrameRate;
mZedParams.camera_resolution = static_cast<sl::RESOLUTION>(mCamResol);
if (mZedSerialNumber == 0) {
mZedParams.input.setFromCameraID(mZedId);
} else {
bool waiting_for_camera = true;
while (waiting_for_camera) {
// Ctrl+C check
if (!mNhNs.ok()) {
mStopNode = true; // Stops other threads
std::lock_guard<std::mutex> lock(mCloseZedMutex);
NODELET_DEBUG("Closing ZED");
mZed.close();
NODELET_DEBUG("ZED pool thread finished");
return;
}
sl::DeviceProperties prop = sl_tools::getZEDFromSN(mZedSerialNumber);
if (prop.id < -1 ||
prop.camera_state == sl::CAMERA_STATE::NOT_AVAILABLE) {
std::string msg = "ZED SN" + to_string(mZedSerialNumber) +
" not detected ! Please connect this ZED";
NODELET_INFO_STREAM(msg.c_str());
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
} else {
waiting_for_camera = false;
mZedParams.input.setFromCameraID(prop.id);
}
}
}
}
mZedParams.coordinate_system = sl::COORDINATE_SYSTEM::RIGHT_HANDED_Z_UP_X_FWD;
NODELET_INFO_STREAM(" * Camera coordinate system\t-> " << sl::toString(mZedParams.coordinate_system));
mZedParams.coordinate_units = sl::UNIT::METER;
mZedParams.depth_mode = static_cast<sl::DEPTH_MODE>(mDepthMode);
mZedParams.sdk_verbose = mVerbose;
mZedParams.sdk_gpu_id = mGpuId;
mZedParams.depth_stabilization = mDepthStabilization;
mZedParams.camera_image_flip = mCameraFlip;
mZedParams.depth_minimum_distance = static_cast<float>(mCamMinDepth);
mZedParams.depth_maximum_distance = static_cast<float>(mCamMaxDepth);
mZedParams.camera_disable_self_calib = !mCameraSelfCalib;
mZedParams.enable_image_enhancement = true; // Always active
mDiagUpdater.add("ZED Diagnostic", this, &ZEDWrapperNodelet::callback_updateDiagnostic);
mDiagUpdater.setHardwareID("ZED camera");
mConnStatus = sl::ERROR_CODE::CAMERA_NOT_DETECTED;
NODELET_INFO_STREAM(" *** Opening " << sl::toString( mZedUserCamModel) << "...");
while (mConnStatus != sl::ERROR_CODE::SUCCESS) {
mConnStatus = mZed.open(mZedParams);
NODELET_INFO_STREAM("ZED connection -> " << sl::toString(mConnStatus));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
if (!mNhNs.ok()) {
mStopNode = true; // Stops other threads
std::lock_guard<std::mutex> lock(mCloseZedMutex);
NODELET_DEBUG("Closing ZED");
mZed.close();
NODELET_DEBUG("ZED pool thread finished");
return;
}
mDiagUpdater.update();
}
NODELET_INFO_STREAM(" ... " << sl::toString( mZedRealCamModel) << " ready");
//CUdevice devid;
cuCtxGetDevice(&mGpuId);
NODELET_INFO_STREAM("ZED SDK running on GPU #" << mGpuId);
// Disable AEC_AGC and Auto Whitebalance to trigger it if use set to automatic
mZed.setCameraSettings(sl::VIDEO_SETTINGS::AEC_AGC, 0);
mZed.setCameraSettings(sl::VIDEO_SETTINGS::WHITEBALANCE_AUTO, 0);
mZedRealCamModel = mZed.getCameraInformation().camera_model;
if (mZedRealCamModel == sl::MODEL::ZED) {
if (mZedUserCamModel != mZedRealCamModel) {
NODELET_WARN("Camera model does not match user parameter. Please modify "
"the value of the parameter 'camera_model' to 'zed'");
}
} else if (mZedRealCamModel == sl::MODEL::ZED_M) {
if (mZedUserCamModel != mZedRealCamModel) {
NODELET_WARN("Camera model does not match user parameter. Please modify "
"the value of the parameter 'camera_model' to 'zedm'");
}
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
mSlCamImuTransf = mZed.getCameraInformation().camera_imu_transform;
#else
mSlCamImuTransf = mZed.getCameraInformation().sensors_configuration.camera_imu_transform;
#endif
NODELET_INFO( "Camera-IMU Transform: \n %s", mSlCamImuTransf.getInfos().c_str() );
} else if (mZedRealCamModel == sl::MODEL::ZED2) {
if (mZedUserCamModel != mZedRealCamModel) {
NODELET_WARN("Camera model does not match user parameter. Please modify "
"the value of the parameter 'camera_model' to 'zed2'");
}
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
mSlCamImuTransf = mZed.getCameraInformation().camera_imu_transform;
#else
mSlCamImuTransf = mZed.getCameraInformation().sensors_configuration.camera_imu_transform;
#endif
NODELET_INFO( "Camera-IMU Transform: \n %s", mSlCamImuTransf.getInfos().c_str() );
}
NODELET_INFO_STREAM(" * CAMERA MODEL\t -> " << sl::toString(mZedRealCamModel).c_str());
mZedSerialNumber = mZed.getCameraInformation().serial_number;
NODELET_INFO_STREAM(" * Serial Number -> " << mZedSerialNumber);
if (!mSvoMode) {
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
mCamFwVersion = mZed.getCameraInformation().camera_firmware_version;
#else
mCamFwVersion = mZed.getCameraInformation().camera_configuration.firmware_version;
#endif
NODELET_INFO_STREAM(" * Camera FW Version -> " << mCamFwVersion);
if(mZedRealCamModel!=sl::MODEL::ZED) {
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
mSensFwVersion = mZed.getCameraInformation().sensors_firmware_version;
#else
mSensFwVersion = mZed.getCameraInformation().sensors_configuration.firmware_version;
#endif
NODELET_INFO_STREAM(" * Sensors FW Version -> " << mSensFwVersion);
}
} else {
NODELET_INFO_STREAM(" * Input type\t -> " << sl::toString(mZed.getCameraInformation().input_type).c_str());
}
// Set the IMU topic names using real camera model
string imu_topic;
string imu_topic_raw;
string imu_temp_topic;
string imu_mag_topic;
//string imu_mag_topic_raw;
string pressure_topic;
string temp_topic_root = "temperature";
string temp_topic_left = temp_topic_root + "/left";
string temp_topic_right = temp_topic_root + "/right";
if (mZedRealCamModel != sl::MODEL::ZED) {
std::string imuTopicRoot = "imu";
string imu_topic_name = "data";
string imu_topic_raw_name = "data_raw";
string imu_topic_mag_name = "mag";
//string imu_topic_mag_raw_name = "mag_raw";
string pressure_topic_name = "atm_press";
imu_topic = imuTopicRoot + "/" + imu_topic_name;
imu_topic_raw = imuTopicRoot + "/" + imu_topic_raw_name;
imu_temp_topic = temp_topic_root + "/" + imuTopicRoot;
imu_mag_topic = imuTopicRoot + "/" + imu_topic_mag_name;
//imu_mag_topic_raw = imuTopicRoot + "/" + imu_topic_mag_raw_name;
pressure_topic = /*imuTopicRoot + "/" +*/ pressure_topic_name;
}
mDiagUpdater.setHardwareIDf("%s - s/n: %d [GPU #%d]", sl::toString(mZedRealCamModel).c_str(), mZedSerialNumber, mGpuId);
// ----> Dynamic Reconfigure parameters
mDynRecServer = boost::make_shared<dynamic_reconfigure::Server<zed_nodelets::ZedConfig>>(mDynServerMutex);
dynamic_reconfigure::Server<zed_nodelets::ZedConfig>::CallbackType f;
f = boost::bind(&ZEDWrapperNodelet::callback_dynamicReconf, this, _1, _2);
mDynRecServer->setCallback(f);
// Update parameters
zed_nodelets::ZedConfig config;
mDynRecServer->getConfigDefault(config);
mDynServerMutex.lock();
mDynRecServer->updateConfig(config);
mDynServerMutex.unlock();
updateDynamicReconfigure();
// <---- Dynamic Reconfigure parameters
// Create all the publishers
// Image publishers
image_transport::ImageTransport it_zed(mNhNs);
//mPubRgb = it_zed.advertiseCamera(rgb_topic, 1); // rgb
//NODELET_INFO_STREAM("Advertised on topic " << mPubRgb.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRgb.getInfoTopic());
//mPubRawRgb = it_zed.advertiseCamera(rgb_raw_topic, 1); // rgb raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRgb.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRgb.getInfoTopic());
mPubLeft = it_zed.advertiseCamera(left_topic, 1); // left
NODELET_INFO_STREAM("Advertised on topic " << mPubLeft.getTopic());
NODELET_INFO_STREAM("Advertised on topic " << mPubLeft.getInfoTopic());
//mPubRawLeft = it_zed.advertiseCamera(left_raw_topic, 1); // left raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawLeft.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawLeft.getInfoTopic());
mPubRight = it_zed.advertiseCamera(right_topic, 1); // right
NODELET_INFO_STREAM("Advertised on topic " << mPubRight.getTopic());
NODELET_INFO_STREAM("Advertised on topic " << mPubRight.getInfoTopic());
//mPubRawRight = it_zed.advertiseCamera(right_raw_topic, 1); // right raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRight.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRight.getInfoTopic());
//mPubRgbGray = it_zed.advertiseCamera(rgb_gray_topic, 1); // rgb
//NODELET_INFO_STREAM("Advertised on topic " << mPubRgbGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRgbGray.getInfoTopic());
//mPubRawRgbGray = it_zed.advertiseCamera(rgb_raw_gray_topic, 1); // rgb raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRgbGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRgbGray.getInfoTopic());
//mPubLeftGray = it_zed.advertiseCamera(left_gray_topic, 1); // left
//NODELET_INFO_STREAM("Advertised on topic " << mPubLeftGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubLeftGray.getInfoTopic());
//mPubRawLeftGray = it_zed.advertiseCamera(left_raw_gray_topic, 1); // left raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawLeftGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawLeftGray.getInfoTopic());
//mPubRightGray = it_zed.advertiseCamera(right_gray_topic, 1); // right
//NODELET_INFO_STREAM("Advertised on topic " << mPubRightGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRightGray.getInfoTopic());
//mPubRawRightGray = it_zed.advertiseCamera(right_raw_gray_topic, 1); // right raw
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRightGray.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawRightGray.getInfoTopic());
//mPubDepth = it_zed.advertiseCamera(depth_topic_root, 1); // depth
//NODELET_INFO_STREAM("Advertised on topic " << mPubDepth.getTopic());
//NODELET_INFO_STREAM("Advertised on topic " << mPubDepth.getInfoTopic());
//mPubStereo = it_zed.advertise(stereo_topic, 1);
//NODELET_INFO_STREAM("Advertised on topic " << mPubStereo.getTopic());
//mPubRawStereo = it_zed.advertise(stereo_raw_topic, 1);
//NODELET_INFO_STREAM("Advertised on topic " << mPubRawStereo.getTopic());
// Confidence Map publisher
//mPubConfMap = mNhNs.advertise<sensor_msgs::Image>(conf_map_topic, 1); // confidence map
//NODELET_INFO_STREAM("Advertised on topic " << mPubConfMap.getTopic());
// Disparity publisher
//mPubDisparity = mNhNs.advertise<stereo_msgs::DisparityImage>(disparityTopic, static_cast<int>(mVideoDepthFreq));
//NODELET_INFO_STREAM("Advertised on topic " << mPubDisparity.getTopic());
// PointCloud publishers
//mPubCloud = mNhNs.advertise<sensor_msgs::PointCloud2>(pointcloud_topic, 1);
//NODELET_INFO_STREAM("Advertised on topic " << mPubCloud.getTopic());
if (mMappingEnabled) {
mPubFusedCloud = mNhNs.advertise<sensor_msgs::PointCloud2>(pointcloud_fused_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubFusedCloud.getTopic() << " @ " << mFusedPcPubFreq << " Hz");
}
// Object detection publishers
if (mObjDetEnabled) {
mPubObjDet = mNhNs.advertise<zed_interfaces::Objects>(object_det_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubObjDet.getTopic());
mPubObjDetViz = mNhNs.advertise<visualization_msgs::MarkerArray>(object_det_rviz_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubObjDetViz.getTopic());
}
// Odometry and Pose publisher
mPubPose = mNhNs.advertise<geometry_msgs::PoseStamped>(poseTopic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubPose.getTopic());
mPubPoseCov = mNhNs.advertise<geometry_msgs::PoseWithCovarianceStamped>(pose_cov_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubPoseCov.getTopic());
mPubOdom = mNhNs.advertise<nav_msgs::Odometry>(odometryTopic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubOdom.getTopic());
// Camera Path
if (mPathPubRate > 0) {
mPubOdomPath = mNhNs.advertise<nav_msgs::Path>(odom_path_topic, 1, true);
NODELET_INFO_STREAM("Advertised on topic " << mPubOdomPath.getTopic());
mPubMapPath = mNhNs.advertise<nav_msgs::Path>(map_path_topic, 1, true);
NODELET_INFO_STREAM("Advertised on topic " << mPubMapPath.getTopic());
mPathTimer = mNhNs.createTimer(ros::Duration(1.0 / mPathPubRate),
&ZEDWrapperNodelet::callback_pubPath, this);
if (mPathMaxCount != -1) {
NODELET_DEBUG_STREAM("Path vectors reserved " << mPathMaxCount << " poses.");
mOdomPath.reserve(mPathMaxCount);
mMapPath.reserve(mPathMaxCount);
NODELET_DEBUG_STREAM("Path vector sizes: " << mOdomPath.size() << " " << mMapPath.size());
}
} else {
NODELET_INFO_STREAM("Path topics not published -> mPathPubRate: " << mPathPubRate);
}
// Sensor publishers
if (mZedRealCamModel != sl::MODEL::ZED) {
// IMU Publishers
mPubImu = mNhNs.advertise<sensor_msgs::Imu>(imu_topic, 1/*static_cast<int>(mSensPubRate)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubImu.getTopic() );
mPubImuRaw = mNhNs.advertise<sensor_msgs::Imu>(imu_topic_raw, 1/*static_cast<int>(mSensPubRate)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubImuRaw.getTopic() );
mPubImuMag = mNhNs.advertise<sensor_msgs::MagneticField>(imu_mag_topic, 1/*MAG_FREQ*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubImuMag.getTopic() );
if( mZedRealCamModel == sl::MODEL::ZED2 ) {
// IMU temperature sensor
mPubImuTemp = mNhNs.advertise<sensor_msgs::Temperature>(imu_temp_topic, 1/*static_cast<int>(mSensPubRate)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubImuTemp.getTopic() );
// Atmospheric pressure
mPubPressure = mNhNs.advertise<sensor_msgs::FluidPressure>(pressure_topic, 1/*static_cast<int>(BARO_FREQ)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubPressure.getTopic() );
// CMOS sensor temperatures
mPubTempL = mNhNs.advertise<sensor_msgs::Temperature>(temp_topic_left, 1/*static_cast<int>(BARO_FREQ)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubTempL.getTopic() );
mPubTempR = mNhNs.advertise<sensor_msgs::Temperature>(temp_topic_right, 1/*static_cast<int>(BARO_FREQ)*/);
NODELET_INFO_STREAM("Advertised on topic " << mPubTempR.getTopic() );
}
// Publish camera imu transform in a latched topic
if (mZedRealCamModel != sl::MODEL::ZED) {
string cam_imu_tr_topic = "left_cam_imu_transform";
mPubCamImuTransf = mNhNs.advertise<geometry_msgs::Transform>( cam_imu_tr_topic, 1, true );
sl::Orientation sl_rot = mSlCamImuTransf.getOrientation();
sl::Translation sl_tr = mSlCamImuTransf.getTranslation();
mCameraImuTransfMgs = boost::make_shared<geometry_msgs::Transform>();
mCameraImuTransfMgs->rotation.x = sl_rot.ox;
mCameraImuTransfMgs->rotation.y = sl_rot.oy;
mCameraImuTransfMgs->rotation.z = sl_rot.oz;
mCameraImuTransfMgs->rotation.w = sl_rot.ow;
mCameraImuTransfMgs->translation.x = sl_tr.x;
mCameraImuTransfMgs->translation.y = sl_tr.y;
mCameraImuTransfMgs->translation.z = sl_tr.z;
NODELET_DEBUG( "Camera-IMU Rotation: \n %s", sl_rot.getRotationMatrix().getInfos().c_str() );
NODELET_DEBUG( "Camera-IMU Translation: \n %g %g %g", sl_tr.x, sl_tr.y, sl_tr.z );
mPubCamImuTransf.publish( mCameraImuTransfMgs );
NODELET_INFO_STREAM("Advertised on topic " << mPubCamImuTransf.getTopic() << " [LATCHED]");
}
if(!mSvoMode&&!mSensTimestampSync) {
mFrameTimestamp = ros::Time::now();
mImuTimer = mNhNs.createTimer(ros::Duration(1.0 / (mSensPubRate*1.5) ),
&ZEDWrapperNodelet::callback_pubSensorsData, this);
mSensPeriodMean_usec.reset(new sl_tools::CSmartMean(mSensPubRate / 2));
} else {
mSensPeriodMean_usec.reset(new sl_tools::CSmartMean(mCamFrameRate / 2));
}
}
// Services
mSrvSetInitPose = mNhNs.advertiseService("set_pose", &ZEDWrapperNodelet::on_set_pose, this);
mSrvResetOdometry = mNhNs.advertiseService("reset_odometry", &ZEDWrapperNodelet::on_reset_odometry, this);
mSrvResetTracking = mNhNs.advertiseService("reset_tracking", &ZEDWrapperNodelet::on_reset_tracking, this);
mSrvSvoStartRecording = mNhNs.advertiseService("start_svo_recording", &ZEDWrapperNodelet::on_start_svo_recording, this);
mSrvSvoStopRecording = mNhNs.advertiseService("stop_svo_recording", &ZEDWrapperNodelet::on_stop_svo_recording, this);
mSrvSetLedStatus = mNhNs.advertiseService("set_led_status", &ZEDWrapperNodelet::on_set_led_status, this);
mSrvToggleLed = mNhNs.advertiseService("toggle_led", &ZEDWrapperNodelet::on_toggle_led, this);
mSrvSvoStartStream = mNhNs.advertiseService("start_remote_stream", &ZEDWrapperNodelet::on_start_remote_stream, this);
mSrvSvoStopStream = mNhNs.advertiseService("stop_remote_stream", &ZEDWrapperNodelet::on_stop_remote_stream, this);
mSrvStartMapping = mNhNs.advertiseService("start_3d_mapping", &ZEDWrapperNodelet::on_start_3d_mapping, this);
mSrvStopMapping = mNhNs.advertiseService("stop_3d_mapping", &ZEDWrapperNodelet::on_stop_3d_mapping, this);
mSrvStartObjDet = mNhNs.advertiseService("start_object_detection", &ZEDWrapperNodelet::on_start_object_detection, this);
mSrvStopObjDet = mNhNs.advertiseService("stop_object_detection", &ZEDWrapperNodelet::on_stop_object_detection, this);
// Start Pointcloud thread
//mPcThread = std::thread(&ZEDWrapperNodelet::pointcloud_thread_func, this);
// Start pool thread
mDevicePollThread = std::thread(&ZEDWrapperNodelet::device_poll_thread_func, this);
// Start data publishing timer
mVideoDepthTimer = mNhNs.createTimer(ros::Duration(1.0 / mVideoDepthFreq), &ZEDWrapperNodelet::callback_pubVideoDepth,
this);
}
void ZEDWrapperNodelet::readParameters() {
NODELET_INFO_STREAM("*** PARAMETERS ***");
// ----> General
// Get parameters from param files
mNhNs.getParam("general/camera_name", mCameraName);
NODELET_INFO_STREAM(" * Camera Name\t\t\t-> " << mCameraName.c_str());
int resol;
mNhNs.getParam("general/resolution", resol);
mCamResol = static_cast<sl::RESOLUTION>(resol);
NODELET_INFO_STREAM(" * Camera Resolution\t\t-> " << sl::toString(mCamResol).c_str());
mNhNs.getParam("general/grab_frame_rate", mCamFrameRate);
checkResolFps();
NODELET_INFO_STREAM(" * Camera Grab Framerate\t-> " << mCamFrameRate);
mNhNs.getParam("general/gpu_id", mGpuId);
NODELET_INFO_STREAM(" * Gpu ID\t\t\t-> " << mGpuId);
mNhNs.getParam("general/zed_id", mZedId);
NODELET_INFO_STREAM(" * Camera ID\t\t\t-> " << mGpuId);
mNhNs.getParam("general/verbose", mVerbose);
NODELET_INFO_STREAM(" * Verbose\t\t\t-> " << (mVerbose ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("general/camera_flip", mCameraFlip, false);
NODELET_INFO_STREAM(" * Camera Flip\t\t\t-> " << (mCameraFlip ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("general/self_calib", mCameraSelfCalib, true);
NODELET_INFO_STREAM(" * Self calibration\t\t-> " << (mCameraSelfCalib ? "ENABLED" : "DISABLED"));
int tmp_sn = 0;
mNhNs.getParam("general/serial_number", tmp_sn);
if (tmp_sn > 0) {
mZedSerialNumber = static_cast<int>(tmp_sn);
NODELET_INFO_STREAM(" * Serial number\t\t-> " << mZedSerialNumber);
}
string camera_model;
mNhNs.getParam("general/camera_model", camera_model);
if (camera_model == "zed") {
mZedUserCamModel = sl::MODEL::ZED;
NODELET_INFO_STREAM(" * Camera Model by param\t-> " << camera_model);
} else if (camera_model == "zedm") {
mZedUserCamModel = sl::MODEL::ZED_M;
NODELET_INFO_STREAM(" * Camera Model by param\t-> " << camera_model);
} else if (camera_model == "zed2") {
mZedUserCamModel = sl::MODEL::ZED2;
NODELET_INFO_STREAM(" * Camera Model by param\t-> " << camera_model);
} else {
NODELET_ERROR_STREAM("Camera model not valid: " << camera_model);
}
// <---- General
// ----> Video
mNhNs.getParam("video/img_downsample_factor", mCamImageResizeFactor);
NODELET_INFO_STREAM(" * Image resample factor\t-> " << mCamImageResizeFactor);
mNhNs.getParam("video/extrinsic_in_camera_frame", mUseOldExtrinsic);
NODELET_INFO_STREAM(" * Extrinsic param. frame\t-> " << (mUseOldExtrinsic?"X RIGHT - Y DOWN - Z FWD":"X FWD - Y LEFT - Z UP"));
// <---- Video
// -----> Depth
int depth_mode;
mNhNs.getParam("depth/quality", depth_mode);
mDepthMode = static_cast<sl::DEPTH_MODE>(depth_mode);
NODELET_INFO_STREAM(" * Depth quality\t\t-> " << sl::toString(mDepthMode).c_str());
int sensing_mode;
mNhNs.getParam("depth/sensing_mode", sensing_mode );
mCamSensingMode = static_cast<sl::SENSING_MODE>(sensing_mode);
NODELET_INFO_STREAM(" * Depth Sensing mode\t\t-> " << sl::toString(mCamSensingMode).c_str());
mNhNs.getParam("depth/openni_depth_mode", mOpenniDepthMode);
NODELET_INFO_STREAM(" * OpenNI mode\t\t\t-> " << (mOpenniDepthMode ? "ENABLED" : "DISABLED"));
mNhNs.getParam("depth/depth_stabilization", mDepthStabilization);
NODELET_INFO_STREAM(" * Depth Stabilization\t\t-> " << (mDepthStabilization ? "ENABLED" : "DISABLED"));
mNhNs.getParam("depth/min_depth", mCamMinDepth);
NODELET_INFO_STREAM(" * Minimum depth\t\t-> " << mCamMinDepth << " m");
mNhNs.getParam("depth/max_depth", mCamMaxDepth);
NODELET_INFO_STREAM(" * Maximum depth\t\t-> " << mCamMaxDepth << " m");
mNhNs.getParam("depth/depth_downsample_factor", mCamDepthResizeFactor);
NODELET_INFO_STREAM(" * Depth resample factor\t-> " << mCamDepthResizeFactor);
// <----- Depth
// ----> Tracking
mNhNs.getParam("pos_tracking/path_pub_rate", mPathPubRate);
NODELET_INFO_STREAM(" * Path rate\t\t\t-> " << mPathPubRate << " Hz");
mNhNs.getParam("pos_tracking/path_max_count", mPathMaxCount);
NODELET_INFO_STREAM(" * Path history size\t\t-> " << (mPathMaxCount == -1) ? std::string("INFINITE") : std::to_string(
mPathMaxCount));
if (mPathMaxCount < 2 && mPathMaxCount != -1) {
mPathMaxCount = 2;
}
mNhNs.getParam("pos_tracking/initial_base_pose", mInitialBasePose);
mNhNs.getParam("pos_tracking/area_memory_db_path", mAreaMemDbPath);
NODELET_INFO_STREAM(" * Odometry DB path\t\t-> " << mAreaMemDbPath.c_str());
mNhNs.param<bool>("pos_tracking/area_memory", mAreaMemory, false);
NODELET_INFO_STREAM(" * Spatial Memory\t\t-> " << (mAreaMemory ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("pos_tracking/imu_fusion", mImuFusion, true);
NODELET_INFO_STREAM(" * IMU Fusion\t\t\t-> " << (mImuFusion ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("pos_tracking/floor_alignment", mFloorAlignment, false);
NODELET_INFO_STREAM(" * Floor alignment\t\t-> " << (mFloorAlignment ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("pos_tracking/init_odom_with_first_valid_pose", mInitOdomWithPose, true);
NODELET_INFO_STREAM(" * Init Odometry with first valid pose data -> " << (mInitOdomWithPose ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("pos_tracking/two_d_mode", mTwoDMode, false);
NODELET_INFO_STREAM(" * Two D mode\t\t\t-> " << (mTwoDMode ? "ENABLED" : "DISABLED"));
mNhNs.param<double>("pos_tracking/fixed_z_value", mFixedZValue, 0.0);
if (mTwoDMode) {
NODELET_INFO_STREAM(" * Fixed Z value\t\t-> " << mFixedZValue);
}
// <---- Tracking
// ----> Mapping
mNhNs.param<bool>("mapping/mapping_enabled", mMappingEnabled, false);
if (mMappingEnabled) {
NODELET_INFO_STREAM(" * Mapping\t\t\t-> ENABLED");
mNhNs.getParam("mapping/resolution", mMappingRes);
NODELET_INFO_STREAM(" * Mapping resolution\t\t-> " << mMappingRes << " m" );
mNhNs.getParam("mapping/max_mapping_range", mMaxMappingRange);
NODELET_INFO_STREAM(" * Mapping max range\t\t-> " << mMaxMappingRange << " m" << ((mMaxMappingRange < 0.0)?" [AUTO]":""));
mNhNs.getParam("mapping/fused_pointcloud_freq", mFusedPcPubFreq);
NODELET_INFO_STREAM(" * Fused point cloud freq:\t-> " << mFusedPcPubFreq << " Hz");
} else {
NODELET_INFO_STREAM(" * Mapping\t\t\t-> DISABLED");
}
// <---- Mapping
// ----> Object Detection
mNhNs.param<bool>("object_detection/od_enabled", mObjDetEnabled, false);
if (mObjDetEnabled) {
NODELET_INFO_STREAM(" * Object Detection\t\t-> ENABLED");
mNhNs.getParam("object_detection/confidence_threshold", mObjDetConfidence);
NODELET_INFO_STREAM(" * Object confidence\t\t-> " << mObjDetConfidence);
mNhNs.getParam("object_detection/object_tracking_enabled", mObjDetTracking);
NODELET_INFO_STREAM(" * Object tracking\t\t-> " << (mObjDetTracking?"ENABLED":"DISABLED"));
mNhNs.getParam("object_detection/people_detection", mObjDetPeople);
NODELET_INFO_STREAM(" * People detection\t\t-> " << (mObjDetPeople?"ENABLED":"DISABLED"));
mNhNs.getParam("object_detection/vehicle_detection", mObjDetVehicles);
NODELET_INFO_STREAM(" * Vehicles detection\t\t-> " << (mObjDetVehicles?"ENABLED":"DISABLED"));
} else {
NODELET_INFO_STREAM(" * Object Detection\t\t-> DISABLED");
}
// <---- Object Detection
// ----> Sensors
mNhNs.getParam("sensors/sensors_timestamp_sync", mSensTimestampSync);
NODELET_INFO_STREAM(" * Sensors timestamp sync\t-> " << (mSensTimestampSync ? "ENABLED" : "DISABLED"));
// <---- Sensors
// ----> SVO
mNhNs.param<std::string>("svo_file", mSvoFilepath, std::string());
NODELET_INFO_STREAM(" * SVO input file: \t\t-> " << mSvoFilepath.c_str());
int svo_compr = 0;
mNhNs.getParam("general/svo_compression", svo_compr);
if (svo_compr >= static_cast<int>(sl::SVO_COMPRESSION_MODE::LAST)) {
NODELET_WARN_STREAM("The parameter `general/svo_compression` has an invalid value. Please check it in the configuration file `common.yaml`");
svo_compr = 0;
}
mSvoComprMode = static_cast<sl::SVO_COMPRESSION_MODE>(svo_compr);
NODELET_INFO_STREAM(" * SVO REC compression\t\t-> " << sl::toString(mSvoComprMode));
// <---- SVO
// Remote Stream
mNhNs.param<std::string>("stream", mRemoteStreamAddr, std::string());
// ----> Coordinate frames
mNhNs.param<std::string>("pos_tracking/map_frame", mMapFrameId, "map");
mNhNs.param<std::string>("pos_tracking/odometry_frame", mOdometryFrameId, "odom");
mNhNs.param<std::string>("general/base_frame", mBaseFrameId, "base_link");
mCameraFrameId = mCameraName + "_camera_center";
mImuFrameId = mCameraName + "_imu_link";
mLeftCamFrameId = mCameraName + "_left_camera_frame";
mLeftCamOptFrameId = mCameraName + "_left_camera_optical_frame";
mRightCamFrameId = mCameraName + "_right_camera_frame";
mRightCamOptFrameId = mCameraName + "_right_camera_optical_frame";
mBaroFrameId = mCameraName + "_baro_link";
mMagFrameId = mCameraName + "_mag_link";
mTempLeftFrameId = mCameraName + "_temp_left_link";
mTempRightFrameId = mCameraName + "_temp_right_link";
mDepthFrameId = mLeftCamFrameId;
mDepthOptFrameId = mLeftCamOptFrameId;
// Note: Depth image frame id must match color image frame id
mCloudFrameId = mDepthOptFrameId;
mRgbFrameId = mDepthFrameId;
mRgbOptFrameId = mCloudFrameId;
mDisparityFrameId = mDepthFrameId;
mDisparityOptFrameId = mDepthOptFrameId;
mConfidenceFrameId = mDepthFrameId;
mConfidenceOptFrameId = mDepthOptFrameId;
// Print TF frames
NODELET_INFO_STREAM(" * map_frame\t\t\t-> " << mMapFrameId);
NODELET_INFO_STREAM(" * odometry_frame\t\t-> " << mOdometryFrameId);
NODELET_INFO_STREAM(" * base_frame\t\t\t-> " << mBaseFrameId);
NODELET_INFO_STREAM(" * camera_frame\t\t\t-> " << mCameraFrameId);
NODELET_INFO_STREAM(" * imu_link\t\t\t-> " << mImuFrameId);
NODELET_INFO_STREAM(" * left_camera_frame\t\t-> " << mLeftCamFrameId);
NODELET_INFO_STREAM(" * left_camera_optical_frame\t-> " << mLeftCamOptFrameId);
NODELET_INFO_STREAM(" * right_camera_frame\t\t-> " << mRightCamFrameId);
NODELET_INFO_STREAM(" * right_camera_optical_frame\t-> " << mRightCamOptFrameId);
NODELET_INFO_STREAM(" * depth_frame\t\t\t-> " << mDepthFrameId);
NODELET_INFO_STREAM(" * depth_optical_frame\t\t-> " << mDepthOptFrameId);
NODELET_INFO_STREAM(" * disparity_frame\t\t-> " << mDisparityFrameId);
NODELET_INFO_STREAM(" * disparity_optical_frame\t-> " << mDisparityOptFrameId);
NODELET_INFO_STREAM(" * confidence_frame\t\t-> " << mConfidenceFrameId);
NODELET_INFO_STREAM(" * confidence_optical_frame\t-> " << mConfidenceOptFrameId);
// <---- Coordinate frames
// ----> TF broadcasting
mNhNs.param<bool>("pos_tracking/publish_tf", mPublishTf, true);
NODELET_INFO_STREAM(" * Broadcast odometry TF\t-> " << (mPublishTf ? "ENABLED" : "DISABLED"));
mNhNs.param<bool>("pos_tracking/publish_map_tf", mPublishMapTf, true);
NODELET_INFO_STREAM(" * Broadcast map pose TF\t-> " << (mPublishTf ? (mPublishMapTf ? "ENABLED" : "DISABLED") :
"DISABLED"));
mNhNs.param<bool>("sensors/publish_imu_tf", mPublishImuTf, true);
NODELET_INFO_STREAM(" * Broadcast IMU pose TF\t-> " << ( mPublishImuTf ? "ENABLED" : "DISABLED" ) );
// <---- TF broadcasting
// ----> Dynamic
mNhNs.getParam("depth_confidence", mCamDepthConfidence);
NODELET_INFO_STREAM(" * [DYN] Depth confidence\t-> " << mCamDepthConfidence);
mNhNs.getParam("depth_texture_conf", mCamDepthTextureConf);
NODELET_INFO_STREAM(" * [DYN] Depth texture conf.\t-> " << mCamDepthTextureConf);
mNhNs.getParam("pub_frame_rate", mVideoDepthFreq);
NODELET_INFO_STREAM(" * [DYN] pub_frame_rate\t\t-> " << mVideoDepthFreq << " Hz");
mNhNs.getParam("point_cloud_freq", mPointCloudFreq);
NODELET_INFO_STREAM(" * [DYN] point_cloud_freq\t-> " << mPointCloudFreq << " Hz");
mNhNs.getParam("brightness", mCamBrightness);
NODELET_INFO_STREAM(" * [DYN] brightness\t\t-> " << mCamBrightness);
mNhNs.getParam("contrast", mCamContrast);
NODELET_INFO_STREAM(" * [DYN] contrast\t\t-> " << mCamContrast);
mNhNs.getParam("hue", mCamHue);
NODELET_INFO_STREAM(" * [DYN] hue\t\t\t-> " << mCamHue);
mNhNs.getParam("saturation", mCamSaturation);
NODELET_INFO_STREAM(" * [DYN] saturation\t\t-> " << mCamSaturation);
mNhNs.getParam("sharpness", mCamSharpness);
NODELET_INFO_STREAM(" * [DYN] sharpness\t\t-> " << mCamSharpness);
#if (ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION>=1)
mNhNs.getParam("gamma", mCamGamma);
NODELET_INFO_STREAM(" * [DYN] gamma\t\t\t-> " << mCamGamma);
#endif
mNhNs.getParam("auto_exposure_gain", mCamAutoExposure);
NODELET_INFO_STREAM(" * [DYN] auto_exposure_gain\t-> " << (mCamAutoExposure ? "ENABLED" : "DISABLED"));
mNhNs.getParam("gain", mCamGain);
mNhNs.getParam("exposure", mCamExposure);
if(!mCamAutoExposure) {
NODELET_INFO_STREAM(" * [DYN] gain\t\t-> " << mCamGain);
NODELET_INFO_STREAM(" * [DYN] exposure\t\t-> " << mCamExposure);
}
mNhNs.getParam("auto_whitebalance", mCamAutoWB);
NODELET_INFO_STREAM(" * [DYN] auto_whitebalance\t-> " << (mCamAutoWB ? "ENABLED" : "DISABLED"));
mNhNs.getParam("whitebalance_temperature", mCamWB);
if(!mCamAutoWB) {
NODELET_INFO_STREAM(" * [DYN] whitebalance_temperature\t\t-> " << mCamWB);
}
if (mCamAutoExposure) {
mTriggerAutoExposure = true;
}
if (mCamAutoWB) {
mTriggerAutoWB = true;
}
// <---- Dynamic
}
void ZEDWrapperNodelet::checkResolFps() {
switch (mCamResol) {
case sl::RESOLUTION::HD2K:
if (mCamFrameRate != 15) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD2K. Set to 15 FPS.");
mCamFrameRate = 15;
}
break;
case sl::RESOLUTION::HD1080:
if (mCamFrameRate == 15 || mCamFrameRate == 30) {
break;
}
if (mCamFrameRate > 15 && mCamFrameRate < 30) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD1080. Set to 15 FPS.");
mCamFrameRate = 15;
} else if (mCamFrameRate > 30) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD1080. Set to 30 FPS.");
mCamFrameRate = 30;
} else {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD1080. Set to 15 FPS.");
mCamFrameRate = 15;
}
break;
case sl::RESOLUTION::HD720:
if (mCamFrameRate == 15 || mCamFrameRate == 30 || mCamFrameRate == 60) {
break;
}
if (mCamFrameRate > 15 && mCamFrameRate < 30) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD720. Set to 15 FPS.");
mCamFrameRate = 15;
} else if (mCamFrameRate > 30 && mCamFrameRate < 60) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD720. Set to 30 FPS.");
mCamFrameRate = 30;
} else if (mCamFrameRate > 60) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD720. Set to 60 FPS.");
mCamFrameRate = 60;
} else {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution HD720. Set to 15 FPS.");
mCamFrameRate = 15;
}
break;
case sl::RESOLUTION::VGA:
if (mCamFrameRate == 15 || mCamFrameRate == 30 || mCamFrameRate == 60 ||
mCamFrameRate == 100) {
break;
}
if (mCamFrameRate > 15 && mCamFrameRate < 30) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution VGA. Set to 15 FPS.");
mCamFrameRate = 15;
} else if (mCamFrameRate > 30 && mCamFrameRate < 60) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution VGA. Set to 30 FPS.");
mCamFrameRate = 30;
} else if (mCamFrameRate > 60 && mCamFrameRate < 100) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution VGA. Set to 60 FPS.");
mCamFrameRate = 60;
} else if (mCamFrameRate > 100) {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution VGA. Set to 100 FPS.");
mCamFrameRate = 100;
} else {
NODELET_WARN_STREAM("Wrong FrameRate ("
<< mCamFrameRate
<< ") for the resolution VGA. Set to 15 FPS.");
mCamFrameRate = 15;
}
break;
default:
NODELET_WARN_STREAM("Invalid resolution. Set to HD720 @ 30 FPS");
mCamResol = sl::RESOLUTION::HD720;
mCamFrameRate = 30;
}
}
void ZEDWrapperNodelet::initTransforms() {
// According to REP 105 -> http://www.ros.org/reps/rep-0105.html
// base_link <- odom <- map
// ^ |
// | |
// -------------------
// ----> Dynamic transforms
mOdom2BaseTransf.setIdentity(); // broadcasted if `publish_tf` is true
mMap2OdomTransf.setIdentity(); // broadcasted if `publish_map_tf` is true
mMap2BaseTransf.setIdentity(); // used internally, but not broadcasted
mMap2CameraTransf.setIdentity(); // used internally, but not broadcasted
// <---- Dynamic transforms
}
bool ZEDWrapperNodelet::getCamera2BaseTransform() {
NODELET_DEBUG("Getting static TF from '%s' to '%s'", mCameraFrameId.c_str(), mBaseFrameId.c_str());
mCamera2BaseTransfValid = false;
static bool first_error = true;
// ----> Static transforms
// Sensor to Base link
try {
// Save the transformation
geometry_msgs::TransformStamped c2b =
mTfBuffer->lookupTransform(mCameraFrameId, mBaseFrameId, ros::Time(0), ros::Duration(0.1));
// Get the TF2 transformation
tf2::fromMsg(c2b.transform, mCamera2BaseTransf);
double roll, pitch, yaw;
tf2::Matrix3x3(mCamera2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_INFO("Static transform Camera Center to Base [%s -> %s]",
mCameraFrameId.c_str(), mBaseFrameId.c_str());
NODELET_INFO(" * Translation: {%.3f,%.3f,%.3f}",
mCamera2BaseTransf.getOrigin().x(), mCamera2BaseTransf.getOrigin().y(), mCamera2BaseTransf.getOrigin().z());
NODELET_INFO(" * Rotation: {%.3f,%.3f,%.3f}",
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
} catch (tf2::TransformException& ex) {
if(!first_error) {
NODELET_DEBUG_THROTTLE(1.0, "Transform error: %s", ex.what());
NODELET_WARN_THROTTLE(1.0, "The tf from '%s' to '%s' is not available.",
mCameraFrameId.c_str(), mBaseFrameId.c_str());
NODELET_WARN_THROTTLE(1.0, "Note: one of the possible cause of the problem is the absense of an instance "
"of the `robot_state_publisher` node publishing the correct static TF transformations "
"or a modified URDF not correctly reproducing the ZED "
"TF chain '%s' -> '%s' -> '%s'",
mBaseFrameId.c_str(), mCameraFrameId.c_str(),mDepthFrameId.c_str());
first_error=false;
}
mCamera2BaseTransf.setIdentity();
return false;
}
// <---- Static transforms
mCamera2BaseTransfValid = true;
return true;
}
bool ZEDWrapperNodelet::getSens2CameraTransform() {
NODELET_DEBUG("Getting static TF from '%s' to '%s'", mDepthFrameId.c_str(), mCameraFrameId.c_str());
mSensor2CameraTransfValid = false;
static bool first_error = true;
// ----> Static transforms
// Sensor to Camera Center
try {
// Save the transformation
geometry_msgs::TransformStamped s2c =
mTfBuffer->lookupTransform(mDepthFrameId, mCameraFrameId, ros::Time(0), ros::Duration(0.1));
// Get the TF2 transformation
tf2::fromMsg(s2c.transform, mSensor2CameraTransf);
double roll, pitch, yaw;
tf2::Matrix3x3(mSensor2CameraTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_INFO("Static transform Sensor to Camera Center [%s -> %s]",
mDepthFrameId.c_str(), mCameraFrameId.c_str());
NODELET_INFO(" * Translation: {%.3f,%.3f,%.3f}",
mSensor2CameraTransf.getOrigin().x(), mSensor2CameraTransf.getOrigin().y(), mSensor2CameraTransf.getOrigin().z());
NODELET_INFO(" * Rotation: {%.3f,%.3f,%.3f}",
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
} catch (tf2::TransformException& ex) {
if(!first_error) {
NODELET_DEBUG_THROTTLE(1.0, "Transform error: %s", ex.what());
NODELET_WARN_THROTTLE(1.0, "The tf from '%s' to '%s' is not available.",
mDepthFrameId.c_str(), mCameraFrameId.c_str());
NODELET_WARN_THROTTLE(1.0, "Note: one of the possible cause of the problem is the absense of an instance "
"of the `robot_state_publisher` node publishing the correct static TF transformations "
"or a modified URDF not correctly reproducing the ZED "
"TF chain '%s' -> '%s' -> '%s'",
mBaseFrameId.c_str(), mCameraFrameId.c_str(),mDepthFrameId.c_str());
first_error = false;
}
mSensor2CameraTransf.setIdentity();
return false;
}
// <---- Static transforms
mSensor2CameraTransfValid = true;
return true;
}
bool ZEDWrapperNodelet::getSens2BaseTransform() {
NODELET_DEBUG("Getting static TF from '%s' to '%s'", mDepthFrameId.c_str(), mBaseFrameId.c_str());
mSensor2BaseTransfValid = false;
static bool first_error = true;
// ----> Static transforms
// Sensor to Base link
try {
// Save the transformation
geometry_msgs::TransformStamped s2b =
mTfBuffer->lookupTransform(mDepthFrameId, mBaseFrameId, ros::Time(0), ros::Duration(0.1));
// Get the TF2 transformation
tf2::fromMsg(s2b.transform, mSensor2BaseTransf);
double roll, pitch, yaw;
tf2::Matrix3x3(mSensor2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_INFO("Static transform Sensor to Base [%s -> %s]",
mDepthFrameId.c_str(), mBaseFrameId.c_str());
NODELET_INFO(" * Translation: {%.3f,%.3f,%.3f}",
mSensor2BaseTransf.getOrigin().x(), mSensor2BaseTransf.getOrigin().y(), mSensor2BaseTransf.getOrigin().z());
NODELET_INFO(" * Rotation: {%.3f,%.3f,%.3f}",
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
} catch (tf2::TransformException& ex) {
if(!first_error) {
NODELET_DEBUG_THROTTLE(1.0, "Transform error: %s", ex.what());
NODELET_WARN_THROTTLE(1.0, "The tf from '%s' to '%s' is not available.",
mDepthFrameId.c_str(), mBaseFrameId.c_str());
NODELET_WARN_THROTTLE(1.0, "Note: one of the possible cause of the problem is the absense of an instance "
"of the `robot_state_publisher` node publishing the correct static TF transformations "
"or a modified URDF not correctly reproducing the ZED "
"TF chain '%s' -> '%s' -> '%s'",
mBaseFrameId.c_str(), mCameraFrameId.c_str(),mDepthFrameId.c_str());
first_error = false;
}
mSensor2BaseTransf.setIdentity();
return false;
}
// <---- Static transforms
mSensor2BaseTransfValid = true;
return true;
}
bool ZEDWrapperNodelet::set_pose(float xt, float yt, float zt, float rr,
float pr, float yr) {
initTransforms();
if (!mSensor2BaseTransfValid) {
getSens2BaseTransform();
}
if (!mSensor2CameraTransfValid) {
getSens2CameraTransform();
}
if (!mCamera2BaseTransfValid) {
getCamera2BaseTransform();
}
// Apply Base to sensor transform
tf2::Transform initPose;
tf2::Vector3 origin(xt, yt, zt);
initPose.setOrigin(origin);
tf2::Quaternion quat;
quat.setRPY(rr, pr, yr);
initPose.setRotation(quat);
initPose = initPose * mSensor2BaseTransf.inverse();
// SL pose
sl::float3 t_vec;
t_vec[0] = initPose.getOrigin().x();
t_vec[1] = initPose.getOrigin().y();
t_vec[2] = initPose.getOrigin().z();
sl::float4 q_vec;
q_vec[0] = initPose.getRotation().x();
q_vec[1] = initPose.getRotation().y();
q_vec[2] = initPose.getRotation().z();
q_vec[3] = initPose.getRotation().w();
sl::Translation trasl(t_vec);
sl::Orientation orient(q_vec);
mInitialPoseSl.setTranslation(trasl);
mInitialPoseSl.setOrientation(orient);
return (mSensor2BaseTransfValid & mSensor2CameraTransfValid & mCamera2BaseTransfValid);
}
bool ZEDWrapperNodelet::on_set_pose(
zed_interfaces::set_pose::Request& req,
zed_interfaces::set_pose::Response& res) {
mInitialBasePose.resize(6);
mInitialBasePose[0] = req.x;
mInitialBasePose[1] = req.y;
mInitialBasePose[2] = req.z;
mInitialBasePose[3] = req.R;
mInitialBasePose[4] = req.P;
mInitialBasePose[5] = req.Y;
if (!set_pose(mInitialBasePose[0], mInitialBasePose[1], mInitialBasePose[2],
mInitialBasePose[3], mInitialBasePose[4], mInitialBasePose[5])) {
res.done = false;
return false;
}
std::lock_guard<std::mutex> lock(mPosTrkMutex);
// Disable tracking
mTrackingActivated = false;
mZed.disablePositionalTracking();
// Restart tracking
start_pos_tracking();
res.done = true;
return true;
}
bool ZEDWrapperNodelet::on_reset_tracking(
zed_interfaces::reset_tracking::Request& req,
zed_interfaces::reset_tracking::Response& res) {
if (!mTrackingActivated) {
res.reset_done = false;
return false;
}
if (!set_pose(mInitialBasePose[0], mInitialBasePose[1], mInitialBasePose[2],
mInitialBasePose[3], mInitialBasePose[4], mInitialBasePose[5])) {
res.reset_done = false;
return false;
}
std::lock_guard<std::mutex> lock(mPosTrkMutex);
// Disable tracking
mTrackingActivated = false;
mZed.disablePositionalTracking();
// Restart tracking
start_pos_tracking();
res.reset_done = true;
return true;
}
bool ZEDWrapperNodelet::on_reset_odometry(
zed_interfaces::reset_odometry::Request& req,
zed_interfaces::reset_odometry::Response& res) {
mResetOdom = true;
res.reset_done = true;
return true;
}
bool ZEDWrapperNodelet::start_3d_mapping() {
if (!mMappingEnabled) {
return false;
}
NODELET_INFO_STREAM("*** Starting Spatial Mapping ***");
sl::SpatialMappingParameters params;
params.map_type = sl::SpatialMappingParameters::SPATIAL_MAP_TYPE::FUSED_POINT_CLOUD;
params.use_chunk_only = true;
sl::SpatialMappingParameters spMapPar;
float lRes = spMapPar.allowed_resolution.first;
float hRes = spMapPar.allowed_resolution.second;
if(mMappingRes < lRes) {
NODELET_WARN_STREAM( "'mapping/resolution' value (" << mMappingRes << " m) is lower than the allowed resolution values. Fixed automatically" );
mMappingRes = lRes;
}
if(mMappingRes > hRes) {
NODELET_WARN_STREAM( "'mapping/resolution' value (" << mMappingRes << " m) is higher than the allowed resolution values. Fixed automatically" );
mMappingRes = hRes;
}
params.resolution_meter = mMappingRes;
float lRng = spMapPar.allowed_range.first;
float hRng = spMapPar.allowed_range.second;
if(mMaxMappingRange < 0) {
mMaxMappingRange = sl::SpatialMappingParameters::getRecommendedRange( mMappingRes, mZed );
NODELET_INFO_STREAM("Mapping: max range set to " << mMaxMappingRange << " m for a resolution of " << mMappingRes << " m" );
} else if(mMaxMappingRange < lRng) {
NODELET_WARN_STREAM( "'mapping/max_mapping_range_m' value (" << mMaxMappingRange << " m) is lower than the allowed resolution values. Fixed automatically" );
mMaxMappingRange = lRng;
} else if(mMaxMappingRange > hRng) {
NODELET_WARN_STREAM( "'mapping/max_mapping_range_m' value (" << mMaxMappingRange << " m) is higher than the allowed resolution values. Fixed automatically" );
mMaxMappingRange = hRng;
}
params.range_meter = mMaxMappingRange;
sl::ERROR_CODE err = mZed.enableSpatialMapping(params);
if (err == sl::ERROR_CODE::SUCCESS) {
if(mPubFusedCloud.getTopic().empty()) {
string pointcloud_fused_topic = "mapping/fused_cloud";
mPubFusedCloud = mNhNs.advertise<sensor_msgs::PointCloud2>(pointcloud_fused_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubFusedCloud.getTopic() << " @ " << mFusedPcPubFreq << " Hz");
}
mMappingRunning = true;
mFusedPcTimer = mNhNs.createTimer(ros::Duration(1.0 / mFusedPcPubFreq), &ZEDWrapperNodelet::callback_pubFusedPointCloud,
this);
NODELET_INFO_STREAM(" * Resolution: " << params.resolution_meter << " m");
NODELET_INFO_STREAM(" * Max Mapping Range: " << params.range_meter << " m");
NODELET_INFO_STREAM(" * Map point cloud publishing rate: " << mFusedPcPubFreq << " Hz");
return true;
} else {
mMappingRunning = false;
mFusedPcTimer.stop();
NODELET_WARN("Mapping not activated: %s", sl::toString(err).c_str());
return false;
}
}
void ZEDWrapperNodelet::stop_3d_mapping() {
mFusedPcTimer.stop();
mMappingRunning = false;
mMappingEnabled = false;
mZed.disableSpatialMapping();
NODELET_INFO("*** Spatial Mapping stopped ***");
}
bool ZEDWrapperNodelet::start_obj_detect() {
if(mZedRealCamModel!=sl::MODEL::ZED2) {
NODELET_ERROR_STREAM( "Object detection not started. OD is available only using a ZED2 camera model");
return false;
}
if(!mObjDetEnabled) {
return false;
}
if( !mCamera2BaseTransfValid || !mSensor2CameraTransfValid || !mSensor2BaseTransfValid) {
NODELET_DEBUG( "Tracking transforms not yet ready, OD starting postponed");
return false;
}
NODELET_INFO_STREAM("*** Starting Object Detection ***");
sl::ObjectDetectionParameters od_p;
od_p.enable_mask_output = false;
od_p.enable_tracking = mObjDetTracking;
//od_p.image_sync = true;
od_p.image_sync = false; // Asynchronous object detection
sl::ERROR_CODE objDetError = mZed.enableObjectDetection(od_p);
if (objDetError != sl::ERROR_CODE::SUCCESS) {
NODELET_ERROR_STREAM("Object detection error: " << sl::toString(objDetError));
mObjDetRunning = false;
return false;
}
if(mPubObjDet.getTopic().empty()) {
string object_det_topic_root = "obj_det";
string object_det_topic = object_det_topic_root + "/objects";
string object_det_rviz_topic = object_det_topic_root + "/object_markers";
mPubObjDet = mNhNs.advertise<zed_interfaces::Objects>(object_det_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubObjDet.getTopic());
mPubObjDetViz = mNhNs.advertise<visualization_msgs::MarkerArray>(object_det_rviz_topic, 1);
NODELET_INFO_STREAM("Advertised on topic " << mPubObjDetViz.getTopic());
}
mObjDetFilter.clear();
if(mObjDetPeople) {
mObjDetFilter.push_back(sl::OBJECT_CLASS::PERSON);
}
if(mObjDetVehicles) {
mObjDetFilter.push_back(sl::OBJECT_CLASS::VEHICLE);
}
mObjDetRunning = true;
return false;
}
void ZEDWrapperNodelet::stop_obj_detect() {
if (mObjDetRunning) {
NODELET_INFO_STREAM("*** Stopping Object Detection ***");
mObjDetRunning = false;
mObjDetEnabled = false;
mZed.disableObjectDetection();
}
}
void ZEDWrapperNodelet::start_pos_tracking() {
NODELET_INFO_STREAM("*** Starting Positional Tracking ***");
NODELET_INFO(" * Waiting for valid static transformations...");
bool transformOk = false;
double elapsed = 0.0;
auto start = std::chrono::high_resolution_clock::now();
do {
transformOk = set_pose(mInitialBasePose[0], mInitialBasePose[1], mInitialBasePose[2],
mInitialBasePose[3], mInitialBasePose[4], mInitialBasePose[5]);
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() -
start).count();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (elapsed > 10000) {
NODELET_WARN(" !!! Failed to get static transforms. Is the 'ROBOT STATE PUBLISHER' node correctly working? ");
break;
}
} while (transformOk == false);
if (transformOk) {
NODELET_DEBUG("Time required to get valid static transforms: %g sec", elapsed / 1000.);
}
NODELET_INFO("Initial ZED left camera pose (ZED pos. tracking): ");
NODELET_INFO(" * T: [%g,%g,%g]",
mInitialPoseSl.getTranslation().x, mInitialPoseSl.getTranslation().y, mInitialPoseSl.getTranslation().z);
NODELET_INFO(" * Q: [%g,%g,%g,%g]",
mInitialPoseSl.getOrientation().ox, mInitialPoseSl.getOrientation().oy,
mInitialPoseSl.getOrientation().oz, mInitialPoseSl.getOrientation().ow);
if (mAreaMemDbPath != "" && !sl_tools::file_exist(mAreaMemDbPath)) {
mAreaMemDbPath = "";
NODELET_WARN("area_memory_db_path path doesn't exist or is unreachable.");
}
// Tracking parameters
sl::PositionalTrackingParameters trackParams;
trackParams.area_file_path = mAreaMemDbPath.c_str();
mPoseSmoothing = false; // Always false. Pose Smoothing is to be enabled only for VR/AR applications
trackParams.enable_pose_smoothing = mPoseSmoothing;
trackParams.enable_area_memory = mAreaMemory;
trackParams.enable_imu_fusion = mImuFusion;
trackParams.initial_world_transform = mInitialPoseSl;
trackParams.set_floor_as_origin = mFloorAlignment;
sl::ERROR_CODE err = mZed.enablePositionalTracking(trackParams);
if (err == sl::ERROR_CODE::SUCCESS) {
mTrackingActivated = true;
} else {
mTrackingActivated = false;
NODELET_WARN("Tracking not activated: %s", sl::toString(err).c_str());
}
}
void ZEDWrapperNodelet::publishOdom(tf2::Transform odom2baseTransf, sl::Pose& slPose, ros::Time t) {
nav_msgs::OdometryPtr odomMsg = boost::make_shared<nav_msgs::Odometry>();
odomMsg->header.stamp = t;
odomMsg->header.frame_id = mOdometryFrameId; // frame
odomMsg->child_frame_id = mBaseFrameId; // camera_frame
// conversion from Tranform to message
geometry_msgs::Transform base2odom = tf2::toMsg(odom2baseTransf);
// Add all value in odometry message
odomMsg->pose.pose.position.x = base2odom.translation.x;
odomMsg->pose.pose.position.y = base2odom.translation.y;
odomMsg->pose.pose.position.z = base2odom.translation.z;
odomMsg->pose.pose.orientation.x = base2odom.rotation.x;
odomMsg->pose.pose.orientation.y = base2odom.rotation.y;
odomMsg->pose.pose.orientation.z = base2odom.rotation.z;
odomMsg->pose.pose.orientation.w = base2odom.rotation.w;
// Odometry pose covariance
for (size_t i = 0; i < odomMsg->pose.covariance.size(); i++) {
odomMsg->pose.covariance[i] = static_cast<double>(slPose.pose_covariance[i]);
if (mTwoDMode) {
if (i == 14 || i == 21 || i == 28) {
odomMsg->pose.covariance[i] = 1e-9; // Very low covariance if 2D mode
} else if ((i >= 2 && i <= 4) ||
(i >= 8 && i <= 10) ||
(i >= 12 && i <= 13) ||
(i >= 15 && i <= 16) ||
(i >= 18 && i <= 20) ||
(i == 22) ||
(i >= 24 && i <= 27)) {
odomMsg->pose.covariance[i] = 0.0;
}
}
}
// Publish odometry message
mPubOdom.publish(odomMsg);
}
void ZEDWrapperNodelet::publishPose(ros::Time t) {
tf2::Transform base_pose;
base_pose.setIdentity();
if (mPublishMapTf) {
base_pose = mMap2BaseTransf;
} else if (mPublishTf) {
base_pose = mOdom2BaseTransf;
}
std_msgs::Header header;
header.stamp = t;
header.frame_id = mMapFrameId;
geometry_msgs::Pose pose;
// conversion from Tranform to message
geometry_msgs::Transform base2frame = tf2::toMsg(base_pose);
// Add all value in Pose message
pose.position.x = base2frame.translation.x;
pose.position.y = base2frame.translation.y;
pose.position.z = base2frame.translation.z;
pose.orientation.x = base2frame.rotation.x;
pose.orientation.y = base2frame.rotation.y;
pose.orientation.z = base2frame.rotation.z;
pose.orientation.w = base2frame.rotation.w;
if (mPubPose.getNumSubscribers() > 0) {
geometry_msgs::PoseStamped poseNoCov;
poseNoCov.header = header;
poseNoCov.pose = pose;
// Publish pose stamped message
mPubPose.publish(poseNoCov);
}
if (mPubPoseCov.getNumSubscribers() > 0) {
geometry_msgs::PoseWithCovarianceStampedPtr poseCovMsg = boost::make_shared<geometry_msgs::PoseWithCovarianceStamped>();
poseCovMsg->header = header;
poseCovMsg->pose.pose = pose;
// Odometry pose covariance if available
for (size_t i = 0; i < poseCovMsg->pose.covariance.size(); i++) {
poseCovMsg->pose.covariance[i] = static_cast<double>(mLastZedPose.pose_covariance[i]);
if (mTwoDMode) {
if (i == 14 || i == 21 || i == 28) {
poseCovMsg->pose.covariance[i] = 1e-9; // Very low covariance if 2D mode
} else if ((i >= 2 && i <= 4) ||
(i >= 8 && i <= 10) ||
(i >= 12 && i <= 13) ||
(i >= 15 && i <= 16) ||
(i >= 18 && i <= 20) ||
(i == 22) ||
(i >= 24 && i <= 27)) {
poseCovMsg->pose.covariance[i] = 0.0;
}
}
}
// Publish pose with covariance stamped message
mPubPoseCov.publish(poseCovMsg);
}
}
void ZEDWrapperNodelet::publishStaticImuFrame() {
// Publish IMU TF as static TF
if( !mPublishImuTf ) {
return;
}
if(mStaticImuFramePublished) {
return;
}
mStaticImuTransformStamped.header.stamp = ros::Time::now();
mStaticImuTransformStamped.header.frame_id = mLeftCamFrameId;
mStaticImuTransformStamped.child_frame_id = mImuFrameId;
sl::Translation sl_tr = mSlCamImuTransf.getTranslation();
mStaticImuTransformStamped.transform.translation.x = sl_tr.x;
mStaticImuTransformStamped.transform.translation.y = sl_tr.y;
mStaticImuTransformStamped.transform.translation.z = sl_tr.z;
sl::Orientation sl_or = mSlCamImuTransf.getOrientation();
mStaticImuTransformStamped.transform.rotation.x = sl_or.ox;
mStaticImuTransformStamped.transform.rotation.y = sl_or.oy;
mStaticImuTransformStamped.transform.rotation.z = sl_or.oz;
mStaticImuTransformStamped.transform.rotation.w = sl_or.ow;
// Publish transformation
mStaticTransformImuBroadcaster.sendTransform(mStaticImuTransformStamped);
NODELET_INFO_STREAM("Published static transform '" << mImuFrameId << "' -> '" << mLeftCamFrameId << "'" );
mStaticImuFramePublished = true;
}
void ZEDWrapperNodelet::publishOdomFrame(tf2::Transform odomTransf, ros::Time t) {
if (!mSensor2BaseTransfValid) {
getSens2BaseTransform();
}
if (!mSensor2CameraTransfValid) {
getSens2CameraTransform();
}
if (!mCamera2BaseTransfValid) {
getCamera2BaseTransform();
}
geometry_msgs::TransformStamped transformStamped;
transformStamped.header.stamp = t;
transformStamped.header.frame_id = mOdometryFrameId;
transformStamped.child_frame_id = mBaseFrameId;
// conversion from Tranform to message
transformStamped.transform = tf2::toMsg(odomTransf);
// Publish transformation
mTransformOdomBroadcaster.sendTransform(transformStamped);
//NODELET_INFO_STREAM( "Published ODOM TF with TS: " << t );
}
void ZEDWrapperNodelet::publishPoseFrame(tf2::Transform baseTransform, ros::Time t) {
if (!mSensor2BaseTransfValid) {
getSens2BaseTransform();
}
if (!mSensor2CameraTransfValid) {
getSens2CameraTransform();
}
if (!mCamera2BaseTransfValid) {
getCamera2BaseTransform();
}
geometry_msgs::TransformStamped transformStamped;
transformStamped.header.stamp = t;
transformStamped.header.frame_id = mMapFrameId;
transformStamped.child_frame_id = mOdometryFrameId;
// conversion from Tranform to message
transformStamped.transform = tf2::toMsg(baseTransform);
// Publish transformation
mTransformPoseBroadcaster.sendTransform(transformStamped);
//NODELET_INFO_STREAM( "Published POSE TF with TS: " << t );
}
void ZEDWrapperNodelet::publishImage(sensor_msgs::ImagePtr imgMsgPtr, sl::Mat img,
image_transport::CameraPublisher& pubImg, sensor_msgs::CameraInfoPtr camInfoMsg,
string imgFrameId, ros::Time t) {
camInfoMsg->header.stamp = t;
sl_tools::imageToROSmsg( imgMsgPtr, img, imgFrameId, t);
pubImg.publish(imgMsgPtr, camInfoMsg);
}
/*void ZEDWrapperNodelet::publishDepth(sensor_msgs::ImagePtr imgMsgPtr, sl::Mat depth, ros::Time t) {
mDepthCamInfoMsg->header.stamp = t;
//NODELET_DEBUG_STREAM("mOpenniDepthMode: " << mOpenniDepthMode);
if (!mOpenniDepthMode) {
sl_tools::imageToROSmsg(imgMsgPtr, depth, mDepthOptFrameId, t);
mPubDepth.publish(imgMsgPtr, mDepthCamInfoMsg);
return;
}
// OPENNI CONVERSION (meter -> millimeters - float32 -> uint16)
if(!imgMsgPtr) {
imgMsgPtr = boost::make_shared<sensor_msgs::Image>();
}
imgMsgPtr->header.stamp = t;
imgMsgPtr->header.frame_id = mDepthOptFrameId;
imgMsgPtr->height = depth.getHeight();
imgMsgPtr->width = depth.getWidth();
int num = 1; // for endianness detection
imgMsgPtr->is_bigendian = !(*(char*)&num == 1);
imgMsgPtr->step = imgMsgPtr->width * sizeof(uint16_t);
imgMsgPtr->encoding = sensor_msgs::image_encodings::MONO16;
size_t size = imgMsgPtr->step * imgMsgPtr->height;
imgMsgPtr->data.resize(size);
uint16_t* data = (uint16_t*)(&imgMsgPtr->data[0]);
int dataSize = imgMsgPtr->width * imgMsgPtr->height;
sl::float1* depthDataPtr = depth.getPtr<sl::float1>();
for (int i = 0; i < dataSize; i++) {
*(data++) = static_cast<uint16_t>(std::round(*(depthDataPtr++) * 1000)); // in mm, rounded
}
mPubDepth.publish(imgMsgPtr, mDepthCamInfoMsg);
}*/
/*void ZEDWrapperNodelet::publishDisparity(sl::Mat disparity, ros::Time t) {
sl::CameraInformation zedParam = mZed.getCameraInformation(mMatResolDepth);
sensor_msgs::ImagePtr disparityImgMsg = boost::make_shared<sensor_msgs::Image>();
stereo_msgs::DisparityImagePtr disparityMsg = boost::make_shared<stereo_msgs::DisparityImage>();
sl_tools::imageToROSmsg(disparityImgMsg, disparity, mDisparityFrameId, t);
disparityMsg->image = *disparityImgMsg;
disparityMsg->header = disparityMsg->image.header;
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
disparityMsg->f = zedParam.calibration_parameters.left_cam.fx;
disparityMsg->T = zedParam.calibration_parameters.T.x;
#else
disparityMsg->f = zedParam.camera_configuration.calibration_parameters.left_cam.fx;
disparityMsg->T = zedParam.camera_configuration.calibration_parameters.getCameraBaseline();
#endif
if (disparityMsg->T > 0) {
disparityMsg->T *= -1.0f;
}
disparityMsg->min_disparity = disparityMsg->f * disparityMsg->T / mZed.getInitParameters().depth_minimum_distance;
disparityMsg->max_disparity = disparityMsg->f * disparityMsg->T / mZed.getInitParameters().depth_maximum_distance;
mPubDisparity.publish(disparityMsg);
}*/
/*void ZEDWrapperNodelet::pointcloud_thread_func() {
std::unique_lock<std::mutex> lock(mPcMutex);
while (!mStopNode) {
while (!mPcDataReady) { // loop to avoid spurious wakeups
if (mPcDataReadyCondVar.wait_for(lock, std::chrono::milliseconds(500)) == std::cv_status::timeout) {
// Check thread stopping
if (mStopNode) {
return;
} else {
continue;
}
}
}
// ----> Check publishing frequency
double pc_period_msec = 1000.0 / mPointCloudFreq;
static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double elapsed_msec = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_time).count();
if (elapsed_msec < pc_period_msec) {
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<long int>(pc_period_msec - elapsed_msec)));
}
// <---- Check publishing frequency
last_time = std::chrono::steady_clock::now();
publishPointCloud();
mPcDataReady = false;
}
NODELET_DEBUG("Pointcloud thread finished");
}*/
/*void ZEDWrapperNodelet::publishPointCloud() {
sensor_msgs::PointCloud2Ptr pointcloudMsg = boost::make_shared<sensor_msgs::PointCloud2>();
// Publish freq calculation
static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double elapsed_usec = std::chrono::duration_cast<std::chrono::microseconds>(now - last_time).count();
last_time = now;
mPcPeriodMean_usec->addValue(elapsed_usec);
// Initialize Point Cloud message
// https://github.com/ros/common_msgs/blob/jade-devel/sensor_msgs/include/sensor_msgs/point_cloud2_iterator.h
int ptsCount = mMatResolDepth.width * mMatResolDepth.height;
pointcloudMsg->header.stamp = mPointCloudTime;
if (pointcloudMsg->width != mMatResolDepth.width || pointcloudMsg->height != mMatResolDepth.height) {
pointcloudMsg->header.frame_id = mPointCloudFrameId; // Set the header values of the ROS message
pointcloudMsg->is_bigendian = false;
pointcloudMsg->is_dense = false;
pointcloudMsg->width = mMatResolDepth.width;
pointcloudMsg->height = mMatResolDepth.height;
sensor_msgs::PointCloud2Modifier modifier(*pointcloudMsg);
modifier.setPointCloud2Fields(4,
"x", 1, sensor_msgs::PointField::FLOAT32,
"y", 1, sensor_msgs::PointField::FLOAT32,
"z", 1, sensor_msgs::PointField::FLOAT32,
"rgb", 1, sensor_msgs::PointField::FLOAT32);
}
// Data copy
sl::Vector4<float>* cpu_cloud = mCloud.getPtr<sl::float4>();
float* ptCloudPtr = (float*)(&pointcloudMsg->data[0]);
// We can do a direct memcpy since data organization is the same
memcpy(ptCloudPtr, (float*)cpu_cloud, 4 * ptsCount * sizeof(float));
// Pointcloud publishing
mPubCloud.publish(pointcloudMsg);
}*/
void ZEDWrapperNodelet::callback_pubFusedPointCloud(const ros::TimerEvent& e) {
sensor_msgs::PointCloud2Ptr pointcloudFusedMsg = boost::make_shared<sensor_msgs::PointCloud2>();
uint32_t fusedCloudSubnumber = mPubFusedCloud.getNumSubscribers();
if (fusedCloudSubnumber == 0) {
return;
}
std::lock_guard<std::mutex> lock(mCloseZedMutex);
if (!mZed.isOpened()) {
return;
}
//pointcloudFusedMsg->header.stamp = t;
mZed.requestSpatialMapAsync();
while (mZed.getSpatialMapRequestStatusAsync() == sl::ERROR_CODE::FAILURE) {
//Mesh is still generating
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
sl::ERROR_CODE res = mZed.retrieveSpatialMapAsync(mFusedPC);
if (res != sl::ERROR_CODE::SUCCESS) {
NODELET_WARN_STREAM("Fused point cloud not extracted: " << sl::toString(res).c_str());
return;
}
size_t ptsCount = mFusedPC.getNumberOfPoints();
bool resized = false;
if (pointcloudFusedMsg->width != ptsCount || pointcloudFusedMsg->height != 1) {
// Initialize Point Cloud message
// https://github.com/ros/common_msgs/blob/jade-devel/sensor_msgs/include/sensor_msgs/point_cloud2_iterator.h
pointcloudFusedMsg->header.frame_id = mMapFrameId; // Set the header values of the ROS message
pointcloudFusedMsg->is_bigendian = false;
pointcloudFusedMsg->is_dense = false;
pointcloudFusedMsg->width = ptsCount;
pointcloudFusedMsg->height = 1;
sensor_msgs::PointCloud2Modifier modifier(*pointcloudFusedMsg);
modifier.setPointCloud2Fields(4,
"x", 1, sensor_msgs::PointField::FLOAT32,
"y", 1, sensor_msgs::PointField::FLOAT32,
"z", 1, sensor_msgs::PointField::FLOAT32,
"rgb", 1, sensor_msgs::PointField::FLOAT32);
resized = true;
}
std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now();
//NODELET_INFO_STREAM("Chunks: " << mFusedPC.chunks.size());
int index = 0;
float* ptCloudPtr = (float*)(&pointcloudFusedMsg->data[0]);
int updated = 0;
for (int c = 0; c < mFusedPC.chunks.size(); c++) {
if (mFusedPC.chunks[c].has_been_updated || resized) {
updated++;
size_t chunkSize = mFusedPC.chunks[c].vertices.size();
if (chunkSize > 0) {
float* cloud_pts = (float*)(mFusedPC.chunks[c].vertices.data());
memcpy(ptCloudPtr, cloud_pts, 4 * chunkSize * sizeof(float));
ptCloudPtr += 4 * chunkSize;
pointcloudFusedMsg->header.stamp = sl_tools::slTime2Ros(mFusedPC.chunks[c].timestamp);
}
} else {
index += mFusedPC.chunks[c].vertices.size();
}
}
std::chrono::steady_clock::time_point end_time = std::chrono::steady_clock::now();
//NODELET_INFO_STREAM("Updated: " << updated);
//double elapsed_usec = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time).count();
// NODELET_INFO_STREAM("Data copy: " << elapsed_usec << " usec [" << ptsCount << "] - " << (static_cast<double>
// (ptsCount) / elapsed_usec) << " pts/usec");
// Pointcloud publishing
mPubFusedCloud.publish(pointcloudFusedMsg);
}
void ZEDWrapperNodelet::publishCamInfo(sensor_msgs::CameraInfoPtr camInfoMsg,
ros::Publisher pubCamInfo, ros::Time t) {
static int seq = 0;
camInfoMsg->header.stamp = t;
camInfoMsg->header.seq = seq;
pubCamInfo.publish(camInfoMsg);
seq++;
}
void ZEDWrapperNodelet::fillCamInfo(sl::Camera& zed, sensor_msgs::CameraInfoPtr leftCamInfoMsg,
sensor_msgs::CameraInfoPtr rightCamInfoMsg, string leftFrameId,
string rightFrameId, bool rawParam /*= false*/) {
sl::CalibrationParameters zedParam;
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
if (rawParam) {
zedParam = zed.getCameraInformation(mMatResolVideo).calibration_parameters_raw; // ok
} else {
zedParam = zed.getCameraInformation(mMatResolVideo).calibration_parameters; // ok
}
#else
if (rawParam) {
zedParam = zed.getCameraInformation(mMatResolVideo).camera_configuration.calibration_parameters_raw;
} else {
zedParam = zed.getCameraInformation(mMatResolVideo).camera_configuration.calibration_parameters;
}
#endif
float baseline = zedParam.getCameraBaseline();
leftCamInfoMsg->distortion_model =
sensor_msgs::distortion_models::PLUMB_BOB;
rightCamInfoMsg->distortion_model =
sensor_msgs::distortion_models::PLUMB_BOB;
leftCamInfoMsg->D.resize(5);
rightCamInfoMsg->D.resize(5);
leftCamInfoMsg->D[0] = zedParam.left_cam.disto[0]; // k1
leftCamInfoMsg->D[1] = zedParam.left_cam.disto[1]; // k2
leftCamInfoMsg->D[2] = zedParam.left_cam.disto[4]; // k3
leftCamInfoMsg->D[3] = zedParam.left_cam.disto[2]; // p1
leftCamInfoMsg->D[4] = zedParam.left_cam.disto[3]; // p2
rightCamInfoMsg->D[0] = zedParam.right_cam.disto[0]; // k1
rightCamInfoMsg->D[1] = zedParam.right_cam.disto[1]; // k2
rightCamInfoMsg->D[2] = zedParam.right_cam.disto[4]; // k3
rightCamInfoMsg->D[3] = zedParam.right_cam.disto[2]; // p1
rightCamInfoMsg->D[4] = zedParam.right_cam.disto[3]; // p2
leftCamInfoMsg->K.fill(0.0);
rightCamInfoMsg->K.fill(0.0);
leftCamInfoMsg->K[0] = static_cast<double>(zedParam.left_cam.fx);
leftCamInfoMsg->K[2] = static_cast<double>(zedParam.left_cam.cx);
leftCamInfoMsg->K[4] = static_cast<double>(zedParam.left_cam.fy);
leftCamInfoMsg->K[5] = static_cast<double>(zedParam.left_cam.cy);
leftCamInfoMsg->K[8] = 1.0;
rightCamInfoMsg->K[0] = static_cast<double>(zedParam.right_cam.fx);
rightCamInfoMsg->K[2] = static_cast<double>(zedParam.right_cam.cx);
rightCamInfoMsg->K[4] = static_cast<double>(zedParam.right_cam.fy);
rightCamInfoMsg->K[5] = static_cast<double>(zedParam.right_cam.cy);
rightCamInfoMsg->K[8] = 1.0;
leftCamInfoMsg->R.fill(0.0);
rightCamInfoMsg->R.fill(0.0);
for (size_t i = 0; i < 3; i++) {
// identity
rightCamInfoMsg->R[i + i * 3] = 1;
leftCamInfoMsg->R[i + i * 3] = 1;
}
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
if (rawParam) {
std::vector<float> R_ = sl_tools::convertRodrigues(zedParam.R);
float* p = R_.data();
for (int i = 0; i < 9; i++) {
rightCamInfoMsg->R[i] = p[i];
}
}
#else
if (rawParam) {
if(mUseOldExtrinsic) { // Camera frame (Z forward, Y down, X right)
std::vector<float> R_ = sl_tools::convertRodrigues(zedParam.R);
float* p = R_.data();
for (int i = 0; i < 9; i++) {
rightCamInfoMsg->R[i] = p[i];
}
} else { // ROS frame (X forward, Z up, Y left)
for (int i = 0; i < 9; i++) {
rightCamInfoMsg->R[i] = zedParam.stereo_transform.getRotationMatrix().r[i];
}
}
}
#endif
leftCamInfoMsg->P.fill(0.0);
rightCamInfoMsg->P.fill(0.0);
leftCamInfoMsg->P[0] = static_cast<double>(zedParam.left_cam.fx);
leftCamInfoMsg->P[2] = static_cast<double>(zedParam.left_cam.cx);
leftCamInfoMsg->P[5] = static_cast<double>(zedParam.left_cam.fy);
leftCamInfoMsg->P[6] = static_cast<double>(zedParam.left_cam.cy);
leftCamInfoMsg->P[10] = 1.0;
// http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html
rightCamInfoMsg->P[3] = static_cast<double>(-1 * zedParam.left_cam.fx * baseline);
rightCamInfoMsg->P[0] = static_cast<double>(zedParam.right_cam.fx);
rightCamInfoMsg->P[2] = static_cast<double>(zedParam.right_cam.cx);
rightCamInfoMsg->P[5] = static_cast<double>(zedParam.right_cam.fy);
rightCamInfoMsg->P[6] = static_cast<double>(zedParam.right_cam.cy);
rightCamInfoMsg->P[10] = 1.0;
leftCamInfoMsg->width = rightCamInfoMsg->width = static_cast<uint32_t>(mMatResolVideo.width);
leftCamInfoMsg->height = rightCamInfoMsg->height = static_cast<uint32_t>(mMatResolVideo.height);
leftCamInfoMsg->header.frame_id = leftFrameId;
rightCamInfoMsg->header.frame_id = rightFrameId;
}
void ZEDWrapperNodelet::fillCamDepthInfo(sl::Camera& zed, sensor_msgs::CameraInfoPtr depth_info_msg,
string frame_id ) {
sl::CalibrationParameters zedParam;
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
zedParam = zed.getCameraInformation(mMatResolDepth).calibration_parameters;
#else
zedParam = zed.getCameraInformation(mMatResolDepth).camera_configuration.calibration_parameters;
#endif
float baseline = zedParam.getCameraBaseline();
depth_info_msg->distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;
depth_info_msg->D.resize(5);
depth_info_msg->D[0] = zedParam.left_cam.disto[0]; // k1
depth_info_msg->D[1] = zedParam.left_cam.disto[1]; // k2
depth_info_msg->D[2] = zedParam.left_cam.disto[4]; // k3
depth_info_msg->D[3] = zedParam.left_cam.disto[2]; // p1
depth_info_msg->D[4] = zedParam.left_cam.disto[3]; // p2
depth_info_msg->K.fill(0.0);
depth_info_msg->K[0] = static_cast<double>(zedParam.left_cam.fx);
depth_info_msg->K[2] = static_cast<double>(zedParam.left_cam.cx);
depth_info_msg->K[4] = static_cast<double>(zedParam.left_cam.fy);
depth_info_msg->K[5] = static_cast<double>(zedParam.left_cam.cy);
depth_info_msg->K[8] = 1.0;
depth_info_msg->R.fill(0.0);
for (size_t i = 0; i < 3; i++) {
// identity
depth_info_msg->R[i + i * 3] = 1;
}
depth_info_msg->P.fill(0.0);
depth_info_msg->P[0] = static_cast<double>(zedParam.left_cam.fx);
depth_info_msg->P[2] = static_cast<double>(zedParam.left_cam.cx);
depth_info_msg->P[5] = static_cast<double>(zedParam.left_cam.fy);
depth_info_msg->P[6] = static_cast<double>(zedParam.left_cam.cy);
depth_info_msg->P[10] = 1.0;
// http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html
depth_info_msg->width = static_cast<uint32_t>(mMatResolDepth.width);
depth_info_msg->height = static_cast<uint32_t>(mMatResolDepth.height);
depth_info_msg->header.frame_id = frame_id;
}
void ZEDWrapperNodelet::updateDynamicReconfigure() {
//NODELET_DEBUG_STREAM( "updateDynamicReconfigure MUTEX LOCK");
mDynParMutex.lock();
zed_nodelets::ZedConfig config;
config.auto_exposure_gain = mCamAutoExposure;
config.auto_whitebalance = mCamAutoWB;
config.brightness = mCamBrightness;
config.depth_confidence = mCamDepthConfidence;
config.depth_texture_conf = mCamDepthTextureConf;
config.contrast = mCamContrast;
config.exposure = mCamExposure;
config.gain = mCamGain;
config.hue = mCamHue;
config.saturation = mCamSaturation;
config.sharpness = mCamSharpness;
config.gamma = mCamGamma;
config.whitebalance_temperature = mCamWB/100;
config.point_cloud_freq = mPointCloudFreq;
config.pub_frame_rate = mVideoDepthFreq;
mDynParMutex.unlock();
mDynServerMutex.lock();
mDynRecServer->updateConfig(config);
mDynServerMutex.unlock();
mUpdateDynParams = false;
//NODELET_DEBUG_STREAM( "updateDynamicReconfigure MUTEX UNLOCK");
}
void ZEDWrapperNodelet::callback_dynamicReconf(zed_nodelets::ZedConfig& config, uint32_t level) {
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX LOCK");
mDynParMutex.lock();
DynParams param = static_cast<DynParams>(level);
switch (param) {
case DATAPUB_FREQ:
if(config.pub_frame_rate>mCamFrameRate) {
mVideoDepthFreq = mCamFrameRate;
NODELET_WARN_STREAM( "'pub_frame_rate' cannot be major than camera grabbing framerate. Set to " << mVideoDepthFreq );
mUpdateDynParams = true;
} else {
mVideoDepthFreq = config.pub_frame_rate;
NODELET_INFO("Reconfigure Video and Depth pub. frequency: %g", mVideoDepthFreq);
}
mVideoDepthTimer.setPeriod( ros::Duration(1.0 / mVideoDepthFreq) );
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case CONFIDENCE:
mCamDepthConfidence = config.depth_confidence;
NODELET_INFO("Reconfigure confidence threshold: %d", mCamDepthConfidence);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case TEXTURE_CONF:
mCamDepthTextureConf = config.depth_texture_conf;
NODELET_INFO("Reconfigure texture confidence threshold: %d", mCamDepthTextureConf);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case POINTCLOUD_FREQ:
if(config.point_cloud_freq>mCamFrameRate) {
mPointCloudFreq = mCamFrameRate;
NODELET_WARN_STREAM( "'point_cloud_freq' cannot be major than camera grabbing framerate. Set to " << mPointCloudFreq );
mUpdateDynParams = true;
} else {
mPointCloudFreq = config.point_cloud_freq;
NODELET_INFO("Reconfigure point cloud pub. frequency: %g", mPointCloudFreq);
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case BRIGHTNESS:
mCamBrightness = config.brightness;
NODELET_INFO("Reconfigure image brightness: %d", mCamBrightness);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case CONTRAST:
mCamContrast = config.contrast;
NODELET_INFO("Reconfigure image contrast: %d", mCamContrast);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case HUE:
mCamHue = config.hue;
NODELET_INFO("Reconfigure image hue: %d", mCamHue);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case SATURATION:
mCamSaturation = config.saturation;
NODELET_INFO("Reconfigure image saturation: %d", mCamSaturation);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case SHARPNESS:
mCamSharpness = config.sharpness;
NODELET_INFO("Reconfigure image sharpness: %d", mCamSharpness);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case GAMMA:
#if (ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION>=1)
mCamGamma = config.gamma;
NODELET_INFO("Reconfigure image gamma: %d", mCamGamma);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
#else
NODELET_DEBUG_STREAM( "Gamma Control is not available for SDK older that v3.1");
mDynParMutex.unlock();
#endif
break;
case AUTO_EXP_GAIN:
mCamAutoExposure = config.auto_exposure_gain;
NODELET_INFO_STREAM("Reconfigure auto exposure/gain: " << mCamAutoExposure?"ENABLED":"DISABLED");
if( !mCamAutoExposure ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::AEC_AGC, 0 );
mTriggerAutoExposure = false;
} else {
mTriggerAutoExposure = true;
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case GAIN:
mCamGain = config.gain;
if(mCamAutoExposure) {
NODELET_WARN("Reconfigure gain has no effect if 'auto_exposure_gain' is enabled");
} else {
NODELET_INFO("Reconfigure gain: %d", mCamGain);
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case EXPOSURE:
mCamExposure = config.exposure;
if(mCamAutoExposure) {
NODELET_WARN("Reconfigure exposure has no effect if 'auto_exposure_gain' is enabled");
} else {
NODELET_INFO("Reconfigure exposure: %d", mCamExposure);
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case AUTO_WB:
mCamAutoWB = config.auto_whitebalance;
NODELET_INFO_STREAM("Reconfigure auto white balance: " << mCamAutoWB?"ENABLED":"DISABLED");
if( !mCamAutoWB ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::WHITEBALANCE_AUTO, 0 );
mTriggerAutoWB = false;
} else {
mTriggerAutoWB = true;
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
case WB_TEMP:
mCamWB = config.whitebalance_temperature*100;
if(mCamAutoWB) {
NODELET_WARN("Reconfigure white balance temperature has no effect if 'auto_whitebalance' is enabled");
} else {
NODELET_INFO("Reconfigure white balance temperature: %d", mCamWB);
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
break;
default:
NODELET_DEBUG_STREAM( "dynamicReconfCallback Unknown param: " << level);
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "dynamicReconfCallback MUTEX UNLOCK");
}
}
void ZEDWrapperNodelet::callback_pubVideoDepth(const ros::TimerEvent& e) {
static sl::Timestamp lastZedTs = 0; // Used to calculate stable publish frequency
//uint32_t rgbSubnumber = mPubRgb.getNumSubscribers();
//uint32_t rgbRawSubnumber = mPubRawRgb.getNumSubscribers();
uint32_t leftSubnumber = mPubLeft.getNumSubscribers();
//uint32_t leftRawSubnumber = mPubRawLeft.getNumSubscribers();
uint32_t rightSubnumber = mPubRight.getNumSubscribers();
//uint32_t rightRawSubnumber = mPubRawRight.getNumSubscribers();
//uint32_t rgbGraySubnumber = mPubRgbGray.getNumSubscribers();
//uint32_t rgbGrayRawSubnumber = mPubRawRgbGray.getNumSubscribers();
//uint32_t leftGraySubnumber = mPubLeftGray.getNumSubscribers();
//uint32_t leftGrayRawSubnumber = mPubRawLeftGray.getNumSubscribers();
//uint32_t rightGraySubnumber = mPubRightGray.getNumSubscribers();
//uint32_t rightGrayRawSubnumber = mPubRawRightGray.getNumSubscribers();
//uint32_t depthSubnumber = mPubDepth.getNumSubscribers();
//uint32_t disparitySubnumber = mPubDisparity.getNumSubscribers();
//uint32_t confMapSubnumber = mPubConfMap.getNumSubscribers();
//uint32_t stereoSubNumber = mPubStereo.getNumSubscribers();
//uint32_t stereoRawSubNumber = mPubRawStereo.getNumSubscribers();
uint32_t tot_sub = leftSubnumber+rightSubnumber;
bool retrieved = false;
sl::Mat mat_left,mat_left_raw;
sl::Mat mat_right,mat_right_raw;
sl::Mat mat_left_gray,mat_left_raw_gray;
sl::Mat mat_right_gray,mat_right_raw_gray;
sl::Mat mat_depth,mat_disp,mat_conf;
sl::Timestamp ts_rgb=0; // used to check RGB/Depth sync
sl::Timestamp ts_depth=0; // used to check RGB/Depth sync
sl::Timestamp grab_ts=0;
mCamDataMutex.lock();
// ----> Retrieve all required image data
if(leftSubnumber>0) {
mZed.retrieveImage(mat_left, sl::VIEW::LEFT, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
ts_rgb=mat_left.timestamp;
grab_ts=mat_left.timestamp;
}
/*if(rgbRawSubnumber+leftRawSubnumber+stereoRawSubNumber>0) {
mZed.retrieveImage(mat_left_raw, sl::VIEW::LEFT_UNRECTIFIED, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_left_raw.timestamp;
}*/
if(rightSubnumber>0) {
mZed.retrieveImage(mat_right, sl::VIEW::RIGHT, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_right.timestamp;
}
/*if(rightRawSubnumber+stereoRawSubNumber>0) {
mZed.retrieveImage(mat_right_raw, sl::VIEW::RIGHT_UNRECTIFIED, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_right_raw.timestamp;
}*/
/*if(rgbGraySubnumber+leftGraySubnumber>0) {
mZed.retrieveImage(mat_left_gray, sl::VIEW::LEFT_GRAY, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_left_gray.timestamp;
}*/
/*if(rgbGrayRawSubnumber+leftGrayRawSubnumber>0) {
mZed.retrieveImage(mat_left_raw_gray, sl::VIEW::LEFT_UNRECTIFIED_GRAY, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_left_raw_gray.timestamp;
}*/
/*if(rightGraySubnumber>0) {
mZed.retrieveImage(mat_right_gray, sl::VIEW::RIGHT_GRAY, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_right_gray.timestamp;
}*/
/*if(rightGrayRawSubnumber>0) {
mZed.retrieveImage(mat_right_raw_gray, sl::VIEW::RIGHT_UNRECTIFIED_GRAY, sl::MEM::CPU, mMatResolVideo);
retrieved = true;
grab_ts=mat_right_raw_gray.timestamp;
}*/
/*if(depthSubnumber>0) {
mZed.retrieveMeasure(mat_depth, sl::MEASURE::DEPTH, sl::MEM::CPU, mMatResolDepth);
retrieved = true;
grab_ts=mat_depth.timestamp;
ts_depth = mat_depth.timestamp;
if( ts_rgb.data_ns!=0 && (ts_depth.data_ns!=ts_rgb.data_ns) ) {
NODELET_WARN_STREAM( "!!!!! DEPTH/RGB ASYNC !!!!! - Delta: " << 1e-9*static_cast<double>(ts_depth-ts_rgb) << " sec");
}
}*/
/*if(disparitySubnumber>0) {
mZed.retrieveMeasure(mat_disp, sl::MEASURE::DISPARITY, sl::MEM::CPU, mMatResolDepth);
retrieved = true;
grab_ts=mat_disp.timestamp;
}*/
/*if(confMapSubnumber>0) {
mZed.retrieveMeasure(mat_conf, sl::MEASURE::CONFIDENCE, sl::MEM::CPU, mMatResolDepth);
retrieved = true;
grab_ts=mat_conf.timestamp;
}*/
// <---- Retrieve all required image data
// ----> Data ROS timestamp
ros::Time stamp = sl_tools::slTime2Ros(grab_ts);
if(mSvoMode) {
stamp = ros::Time::now();
}
// <---- Data ROS timestamp
// ----> Publish sensor data if sync is required by user or SVO
if( mZedRealCamModel!=sl::MODEL::ZED )
{
if(mSensTimestampSync) {
//NODELET_INFO_STREAM("tot_sub: " << tot_sub << " - retrieved: " << retrieved << " - grab_ts.data_ns!=lastZedTs.data_ns: " << (grab_ts.data_ns!=lastZedTs.data_ns));
if(tot_sub>0 && retrieved && (grab_ts.data_ns!=lastZedTs.data_ns)) {
//NODELET_INFO("CALLBACK");
publishSensData(stamp);
}
} else if(mSvoMode) {
publishSensData(stamp);
}
}
// <---- Publish sensor data if sync is required by user or SVO
mCamDataMutex.unlock();
// ----> Notify grab thread that all data are synchronized and a new grab can be done
//mRgbDepthDataRetrievedCondVar.notify_one();
//mRgbDepthDataRetrieved = true;
// <---- Notify grab thread that all data are synchronized and a new grab can be done
if(!retrieved) {
mPublishingData = false;
lastZedTs = 0;
return;
}
mPublishingData = true;
// ----> Check if a grab has been done before publishing the same images
if( grab_ts.data_ns==lastZedTs.data_ns ) {
// Data not updated by a grab calling in the grab thread
return;
}
if(lastZedTs.data_ns!=0) {
double period_sec = static_cast<double>(grab_ts.data_ns - lastZedTs.data_ns)/1e9;
//NODELET_DEBUG_STREAM( "PUBLISHING PERIOD: " << period_sec << " sec @" << 1./period_sec << " Hz") ;
mVideoDepthPeriodMean_sec->addValue(period_sec);
//NODELET_DEBUG_STREAM( "MEAN PUBLISHING PERIOD: " << mVideoDepthPeriodMean_sec->getMean() << " sec @" << 1./mVideoDepthPeriodMean_sec->getMean() << " Hz") ;
}
lastZedTs = grab_ts;
// <---- Check if a grab has been done before publishing the same images
// Publish the left = rgb image if someone has subscribed to
if (leftSubnumber > 0) {
sensor_msgs::ImagePtr leftImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(leftImgMsg, mat_left, mPubLeft, mLeftCamInfoMsg, mLeftCamOptFrameId, stamp);
}
/*if (rgbSubnumber > 0) {
sensor_msgs::ImagePtr rgbImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rgbImgMsg, mat_left, mPubRgb, mRgbCamInfoMsg, mDepthOptFrameId, stamp);
}*/
// Publish the left = rgb GRAY image if someone has subscribed to
/*if (leftGraySubnumber > 0) {
sensor_msgs::ImagePtr leftGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(leftGrayImgMsg, mat_left_gray, mPubLeftGray, mLeftCamInfoMsg, mLeftCamOptFrameId, stamp);
}*/
/*if (rgbGraySubnumber > 0) {
sensor_msgs::ImagePtr rgbGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rgbGrayImgMsg, mat_left_gray, mPubRgbGray, mRgbCamInfoMsg, mDepthOptFrameId, stamp);
}*/
// Publish the left_raw = rgb_raw image if someone has subscribed to
/*if (leftRawSubnumber > 0) {
sensor_msgs::ImagePtr rawLeftImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawLeftImgMsg, mat_left_raw, mPubRawLeft, mLeftCamInfoRawMsg, mLeftCamOptFrameId, stamp);
}*/
/*if (rgbRawSubnumber > 0) {
sensor_msgs::ImagePtr rawRgbImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawRgbImgMsg, mat_left_raw, mPubRawRgb, mRgbCamInfoRawMsg, mDepthOptFrameId, stamp);
}*/
// Publish the left_raw == rgb_raw GRAY image if someone has subscribed to
/*if (leftGrayRawSubnumber > 0) {
sensor_msgs::ImagePtr rawLeftGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawLeftGrayImgMsg, mat_left_raw_gray, mPubRawLeftGray, mLeftCamInfoRawMsg, mLeftCamOptFrameId, stamp);
}*/
/*if (rgbGrayRawSubnumber > 0) {
sensor_msgs::ImagePtr rawRgbGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawRgbGrayImgMsg, mat_left_raw_gray, mPubRawRgbGray, mRgbCamInfoRawMsg, mDepthOptFrameId, stamp);
}*/
// Publish the right image if someone has subscribed to
if (rightSubnumber > 0) {
sensor_msgs::ImagePtr rightImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rightImgMsg, mat_right, mPubRight, mRightCamInfoMsg, mRightCamOptFrameId, stamp);
}
// Publish the right image GRAY if someone has subscribed to
/*if (rightGraySubnumber > 0) {
sensor_msgs::ImagePtr rightGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rightGrayImgMsg, mat_right_gray, mPubRightGray, mRightCamInfoMsg, mRightCamOptFrameId, stamp);
}*/
// Publish the right raw image if someone has subscribed to
/*if (rightRawSubnumber > 0) {
sensor_msgs::ImagePtr rawRightImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawRightImgMsg, mat_right_raw, mPubRawRight, mRightCamInfoRawMsg, mRightCamOptFrameId, stamp);
}*/
// Publish the right raw image GRAY if someone has subscribed to
/*if (rightGrayRawSubnumber > 0) {
sensor_msgs::ImagePtr rawRightGrayImgMsg = boost::make_shared<sensor_msgs::Image>();
publishImage(rawRightGrayImgMsg, mat_right_raw_gray, mPubRawRightGray, mRightCamInfoRawMsg, mRightCamOptFrameId, stamp);
}*/
// Stereo couple side-by-side
/*if (stereoSubNumber > 0) {
sensor_msgs::ImagePtr stereoImgMsg = boost::make_shared<sensor_msgs::Image>();
sl_tools::imagesToROSmsg(stereoImgMsg, mat_left, mat_right, mCameraFrameId, stamp);
mPubStereo.publish(stereoImgMsg);
}*/
// Stereo RAW couple side-by-side
/*if (stereoRawSubNumber > 0) {
sensor_msgs::ImagePtr rawStereoImgMsg = boost::make_shared<sensor_msgs::Image>();
sl_tools::imagesToROSmsg(rawStereoImgMsg, mat_left_raw, mat_right_raw, mCameraFrameId, stamp);
mPubRawStereo.publish(rawStereoImgMsg);
}*/
// Publish the depth image if someone has subscribed to
/*if (depthSubnumber > 0) {
sensor_msgs::ImagePtr depthImgMsg = boost::make_shared<sensor_msgs::Image>();
publishDepth(depthImgMsg, mat_depth, stamp);
}*/
// Publish the disparity image if someone has subscribed to
/*if (disparitySubnumber > 0) {
publishDisparity(mat_disp, stamp);
}*/
// Publish the confidence map if someone has subscribed to
/*if (confMapSubnumber > 0) {
sensor_msgs::ImagePtr confMapMsg = boost::make_shared<sensor_msgs::Image>();
sl_tools::imageToROSmsg(confMapMsg, mat_conf, mConfidenceOptFrameId, stamp);
mPubConfMap.publish(confMapMsg);
}*/
}
void ZEDWrapperNodelet::callback_pubPath(const ros::TimerEvent& e) {
uint32_t mapPathSub = mPubMapPath.getNumSubscribers();
uint32_t odomPathSub = mPubOdomPath.getNumSubscribers();
geometry_msgs::PoseStamped odomPose;
geometry_msgs::PoseStamped mapPose;
odomPose.header.stamp = mFrameTimestamp;
odomPose.header.frame_id = mMapFrameId; // frame
// conversion from Tranform to message
geometry_msgs::Transform base2odom = tf2::toMsg(mOdom2BaseTransf);
// Add all value in Pose message
odomPose.pose.position.x = base2odom.translation.x;
odomPose.pose.position.y = base2odom.translation.y;
odomPose.pose.position.z = base2odom.translation.z;
odomPose.pose.orientation.x = base2odom.rotation.x;
odomPose.pose.orientation.y = base2odom.rotation.y;
odomPose.pose.orientation.z = base2odom.rotation.z;
odomPose.pose.orientation.w = base2odom.rotation.w;
mapPose.header.stamp = mFrameTimestamp;
mapPose.header.frame_id = mMapFrameId; // frame
// conversion from Tranform to message
geometry_msgs::Transform base2map = tf2::toMsg(mMap2BaseTransf);
// Add all value in Pose message
mapPose.pose.position.x = base2map.translation.x;
mapPose.pose.position.y = base2map.translation.y;
mapPose.pose.position.z = base2map.translation.z;
mapPose.pose.orientation.x = base2map.rotation.x;
mapPose.pose.orientation.y = base2map.rotation.y;
mapPose.pose.orientation.z = base2map.rotation.z;
mapPose.pose.orientation.w = base2map.rotation.w;
// Circular vector
if (mPathMaxCount != -1) {
if (mOdomPath.size() == mPathMaxCount) {
NODELET_DEBUG("Path vectors full: rotating ");
std::rotate(mOdomPath.begin(), mOdomPath.begin() + 1, mOdomPath.end());
std::rotate(mMapPath.begin(), mMapPath.begin() + 1, mMapPath.end());
mMapPath[mPathMaxCount - 1] = mapPose;
mOdomPath[mPathMaxCount - 1] = odomPose;
} else {
//NODELET_DEBUG_STREAM("Path vectors adding last available poses");
mMapPath.push_back(mapPose);
mOdomPath.push_back(odomPose);
}
} else {
//NODELET_DEBUG_STREAM("No limit path vectors, adding last available poses");
mMapPath.push_back(mapPose);
mOdomPath.push_back(odomPose);
}
if (mapPathSub > 0) {
nav_msgs::PathPtr mapPath = boost::make_shared<nav_msgs::Path>();
mapPath->header.frame_id = mMapFrameId;
mapPath->header.stamp = mFrameTimestamp;
mapPath->poses = mMapPath;
mPubMapPath.publish(mapPath);
}
if (odomPathSub > 0) {
nav_msgs::PathPtr odomPath = boost::make_shared<nav_msgs::Path>();
odomPath->header.frame_id = mMapFrameId;
odomPath->header.stamp = mFrameTimestamp;
odomPath->poses = mOdomPath;
mPubOdomPath.publish(odomPath);
}
}
void ZEDWrapperNodelet::callback_pubSensorsData(const ros::TimerEvent& e) {
//NODELET_INFO("callback_pubSensorsData");
std::lock_guard<std::mutex> lock(mCloseZedMutex);
if (!mZed.isOpened()) {
return;
}
publishSensData();
}
void ZEDWrapperNodelet::publishSensData(ros::Time t) {
//NODELET_INFO("publishSensData");
uint32_t imu_SubNumber = mPubImu.getNumSubscribers();
uint32_t imu_RawSubNumber = mPubImuRaw.getNumSubscribers();
uint32_t imu_TempSubNumber = 0;
uint32_t imu_MagSubNumber = 0;
uint32_t pressSubNumber = 0;
uint32_t tempLeftSubNumber = 0;
uint32_t tempRightSubNumber = 0;
if( mZedRealCamModel == sl::MODEL::ZED2 ) {
imu_TempSubNumber = mPubImuTemp.getNumSubscribers();
imu_MagSubNumber = mPubImuMag.getNumSubscribers();
pressSubNumber = mPubPressure.getNumSubscribers();
tempLeftSubNumber = mPubTempL.getNumSubscribers();
tempRightSubNumber = mPubTempR.getNumSubscribers();
}
uint32_t tot_sub = imu_SubNumber+imu_RawSubNumber+imu_TempSubNumber+imu_MagSubNumber+pressSubNumber+
tempLeftSubNumber+tempRightSubNumber;
if(tot_sub>0) {
mSensPublishing=true;
} else {
mSensPublishing=false;
}
bool sensors_data_published = false;
ros::Time ts_imu;
ros::Time ts_baro;
ros::Time ts_mag;
static ros::Time lastTs_imu = ros::Time();
static ros::Time lastTs_baro = ros::Time();
static ros::Time lastT_mag = ros::Time();
sl::SensorsData sens_data;
if(mSvoMode || mSensTimestampSync) {
if( mZed.getSensorsData(sens_data, sl::TIME_REFERENCE::IMAGE) != sl::ERROR_CODE::SUCCESS ) {
NODELET_DEBUG("Not retrieved sensors data in IMAGE REFERENCE TIME");
return;
}
} else {
if( mZed.getSensorsData(sens_data, sl::TIME_REFERENCE::CURRENT) != sl::ERROR_CODE::SUCCESS ) {
NODELET_DEBUG("Not retrieved sensors data in CURRENT REFERENCE TIME");
return;
}
}
if(t!=ros::Time(0)) {
ts_imu = t;
ts_baro = t;
ts_mag = t;
} else {
ts_imu = sl_tools::slTime2Ros(sens_data.imu.timestamp);
ts_baro = sl_tools::slTime2Ros(sens_data.barometer.timestamp);
ts_mag = sl_tools::slTime2Ros(sens_data.magnetometer.timestamp);
}
// ----> Publish odometry tf only if enabled
if (mPublishTf && mTrackingReady) {
NODELET_DEBUG("Publishing TF");
publishOdomFrame(mOdom2BaseTransf, ts_imu); // publish the base Frame in odometry frame
if (mPublishMapTf) {
publishPoseFrame(mMap2OdomTransf, ts_imu); // publish the odometry Frame in map frame
}
if(mPublishImuTf && !mStaticImuFramePublished )
{
publishStaticImuFrame();
}
}
// <---- Publish odometry tf only if enabled
bool new_imu_data = ts_imu!=lastTs_imu;
bool new_baro_data = ts_baro!=lastTs_baro;
bool new_mag_data = ts_mag!=lastT_mag;
if( !new_imu_data && !new_baro_data && !new_mag_data) {
NODELET_DEBUG("No updated sensors data");
return;
}
if( mZedRealCamModel == sl::MODEL::ZED2 ) {
// Update temperatures for Diagnostic
sens_data.temperature.get( sl::SensorsData::TemperatureData::SENSOR_LOCATION::ONBOARD_LEFT, mTempLeft);
sens_data.temperature.get( sl::SensorsData::TemperatureData::SENSOR_LOCATION::ONBOARD_RIGHT, mTempRight);
}
if (imu_TempSubNumber>0) {
sensor_msgs::TemperaturePtr imuTempMsg = boost::make_shared<sensor_msgs::Temperature>();
imuTempMsg->header.stamp = ts_imu;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==imuTempMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing IMU data with old timestamp " << old_ts );
}
old_ts = imuTempMsg->header.stamp;
#endif
imuTempMsg->header.frame_id = mImuFrameId;
float imu_temp;
sens_data.temperature.get( sl::SensorsData::TemperatureData::SENSOR_LOCATION::IMU, imu_temp);
imuTempMsg->temperature = static_cast<double>(imu_temp);
imuTempMsg->variance = 0.0;
sensors_data_published = true;
mPubImuTemp.publish(imuTempMsg);
} else {
NODELET_DEBUG("No new IMU temp.");
}
if( sens_data.barometer.is_available && new_baro_data ) {
lastTs_baro = ts_baro;
if( pressSubNumber>0 ) {
sensor_msgs::FluidPressurePtr pressMsg = boost::make_shared<sensor_msgs::FluidPressure>();
pressMsg->header.stamp = ts_baro;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==pressMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing BARO data with old timestamp " << old_ts );
}
old_ts = pressMsg->header.stamp;
#endif
pressMsg->header.frame_id = mBaroFrameId;
pressMsg->fluid_pressure = sens_data.barometer.pressure * 1e-2; // Pascal
pressMsg->variance = 1.0585e-2;
sensors_data_published = true;
mPubPressure.publish(pressMsg);
}
if( tempLeftSubNumber>0 ) {
sensor_msgs::TemperaturePtr tempLeftMsg = boost::make_shared<sensor_msgs::Temperature>();
tempLeftMsg->header.stamp = ts_baro;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==tempLeftMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing BARO data with old timestamp " << old_ts );
}
old_ts = tempLeftMsg->header.stamp;
#endif
tempLeftMsg->header.frame_id = mTempLeftFrameId;
tempLeftMsg->temperature = static_cast<double>(mTempLeft);
tempLeftMsg->variance = 0.0;
sensors_data_published = true;
mPubTempL.publish(tempLeftMsg);
}
if( tempRightSubNumber>0 ) {
sensor_msgs::TemperaturePtr tempRightMsg = boost::make_shared<sensor_msgs::Temperature>();
tempRightMsg->header.stamp = ts_baro;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==tempRightMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing BARO data with old timestamp " << old_ts );
}
old_ts = tempRightMsg->header.stamp;
#endif
tempRightMsg->header.frame_id = mTempRightFrameId;
tempRightMsg->temperature = static_cast<double>(mTempRight);
tempRightMsg->variance = 0.0;
sensors_data_published = true;
mPubTempR.publish(tempRightMsg);
}
} else {
NODELET_DEBUG("No new BAROM. DATA");
}
if( imu_MagSubNumber>0) {
if( sens_data.magnetometer.is_available && new_mag_data ) {
lastT_mag = ts_mag;
sensor_msgs::MagneticFieldPtr magMsg = boost::make_shared<sensor_msgs::MagneticField>();
magMsg->header.stamp = ts_mag;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==magMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing MAG data with old timestamp " << old_ts );
}
old_ts = magMsg->header.stamp;
#endif
magMsg->header.frame_id = mMagFrameId;
magMsg->magnetic_field.x = sens_data.magnetometer.magnetic_field_calibrated.x*1e-6; // Tesla
magMsg->magnetic_field.y = sens_data.magnetometer.magnetic_field_calibrated.y*1e-6; // Tesla
magMsg->magnetic_field.z = sens_data.magnetometer.magnetic_field_calibrated.z*1e-6; // Tesla
magMsg->magnetic_field_covariance[0] = 0.039e-6;
magMsg->magnetic_field_covariance[1] = 0.0f;
magMsg->magnetic_field_covariance[2] = 0.0f;
magMsg->magnetic_field_covariance[3] = 0.0f;
magMsg->magnetic_field_covariance[4] = 0.037e-6;
magMsg->magnetic_field_covariance[5] = 0.0f;
magMsg->magnetic_field_covariance[6] = 0.0f;
magMsg->magnetic_field_covariance[7] = 0.0f;
magMsg->magnetic_field_covariance[8] = 0.047e-6;
sensors_data_published = true;
mPubImuMag.publish(magMsg);
}
} else {
NODELET_DEBUG("No new MAG. DATA");
}
if( imu_SubNumber > 0 && new_imu_data) {
lastTs_imu = ts_imu;
sensor_msgs::ImuPtr imuMsg = boost::make_shared<sensor_msgs::Imu>();
imuMsg->header.stamp = ts_imu;
#ifdef DEBUG_SENS_TS
static ros::Time old_ts;
if(old_ts==imuMsg->header.stamp) {
NODELET_WARN_STREAM("Publishing IMU data with old timestamp " << old_ts );
} else {
NODELET_INFO_STREAM("Publishing IMU data with new timestamp. Freq: " << 1./(ts_imu.toSec()-old_ts.toSec()) );
old_ts = imuMsg->header.stamp;
}
#endif
imuMsg->header.frame_id = mImuFrameId;
imuMsg->orientation.x = sens_data.imu.pose.getOrientation()[0];
imuMsg->orientation.y = sens_data.imu.pose.getOrientation()[1];
imuMsg->orientation.z = sens_data.imu.pose.getOrientation()[2];
imuMsg->orientation.w = sens_data.imu.pose.getOrientation()[3];
imuMsg->angular_velocity.x = sens_data.imu.angular_velocity[0] * DEG2RAD;
imuMsg->angular_velocity.y = sens_data.imu.angular_velocity[1] * DEG2RAD;
imuMsg->angular_velocity.z = sens_data.imu.angular_velocity[2] * DEG2RAD;
imuMsg->linear_acceleration.x = sens_data.imu.linear_acceleration[0];
imuMsg->linear_acceleration.y = sens_data.imu.linear_acceleration[1];
imuMsg->linear_acceleration.z = sens_data.imu.linear_acceleration[2];
for (int i = 0; i < 3; ++i) {
int r = 0;
if (i == 0) {
r = 0;
} else if (i == 1) {
r = 1;
} else {
r = 2;
}
imuMsg->orientation_covariance[i * 3 + 0] =
sens_data.imu.pose_covariance.r[r * 3 + 0] * DEG2RAD * DEG2RAD;
imuMsg->orientation_covariance[i * 3 + 1] =
sens_data.imu.pose_covariance.r[r * 3 + 1] * DEG2RAD * DEG2RAD;
imuMsg->orientation_covariance[i * 3 + 2] =
sens_data.imu.pose_covariance.r[r * 3 + 2] * DEG2RAD * DEG2RAD;
imuMsg->linear_acceleration_covariance[i * 3 + 0] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 0];
imuMsg->linear_acceleration_covariance[i * 3 + 1] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 1];
imuMsg->linear_acceleration_covariance[i * 3 + 2] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 2];
imuMsg->angular_velocity_covariance[i * 3 + 0] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 0] * DEG2RAD * DEG2RAD;
imuMsg->angular_velocity_covariance[i * 3 + 1] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 1] * DEG2RAD * DEG2RAD;
imuMsg->angular_velocity_covariance[i * 3 + 2] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 2] * DEG2RAD * DEG2RAD;
}
sensors_data_published = true;
mPubImu.publish(imuMsg);
} else {
NODELET_DEBUG("No new IMU DATA");
}
if (imu_RawSubNumber > 0 && new_imu_data) {
sensor_msgs::ImuPtr imuRawMsg = boost::make_shared<sensor_msgs::Imu>();
imuRawMsg->header.stamp = ts_imu;
imuRawMsg->header.frame_id = mImuFrameId;
imuRawMsg->angular_velocity.x = sens_data.imu.angular_velocity[0] * DEG2RAD;
imuRawMsg->angular_velocity.y = sens_data.imu.angular_velocity[1] * DEG2RAD;
imuRawMsg->angular_velocity.z = sens_data.imu.angular_velocity[2] * DEG2RAD;
imuRawMsg->linear_acceleration.x = sens_data.imu.linear_acceleration[0];
imuRawMsg->linear_acceleration.y = sens_data.imu.linear_acceleration[1];
imuRawMsg->linear_acceleration.z = sens_data.imu.linear_acceleration[2];
for (int i = 0; i < 3; ++i) {
int r = 0;
if (i == 0) {
r = 0;
} else if (i == 1) {
r = 1;
} else {
r = 2;
}
imuRawMsg->linear_acceleration_covariance[i * 3 + 0] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 0];
imuRawMsg->linear_acceleration_covariance[i * 3 + 1] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 1];
imuRawMsg->linear_acceleration_covariance[i * 3 + 2] =
sens_data.imu.linear_acceleration_covariance.r[r * 3 + 2];
imuRawMsg->angular_velocity_covariance[i * 3 + 0] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 0] * DEG2RAD * DEG2RAD;
imuRawMsg->angular_velocity_covariance[i * 3 + 1] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 1] * DEG2RAD * DEG2RAD;
imuRawMsg->angular_velocity_covariance[i * 3 + 2] =
sens_data.imu.angular_velocity_covariance.r[r * 3 + 2] * DEG2RAD * DEG2RAD;
}
// Orientation data is not available in "data_raw" -> See ROS REP145
// http://www.ros.org/reps/rep-0145.html#topics
imuRawMsg->orientation_covariance[0] =
-1;
sensors_data_published = true;
mPubImuRaw.publish(imuRawMsg);
}
// ----> Update Diagnostic
if( sensors_data_published ) {
// Publish freq calculation
static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double elapsed_usec = std::chrono::duration_cast<std::chrono::microseconds>(now - last_time).count();
last_time = now;
mSensPeriodMean_usec->addValue(elapsed_usec);
}
// <---- Update Diagnostic
}
void ZEDWrapperNodelet::device_poll_thread_func() {
ros::Rate loop_rate(mCamFrameRate);
mRecording = false;
mElabPeriodMean_sec.reset(new sl_tools::CSmartMean(mCamFrameRate));
mGrabPeriodMean_usec.reset(new sl_tools::CSmartMean(mCamFrameRate));
mVideoDepthPeriodMean_sec.reset(new sl_tools::CSmartMean(mCamFrameRate));
mPcPeriodMean_usec.reset(new sl_tools::CSmartMean(mCamFrameRate));
mObjDetPeriodMean_msec.reset(new sl_tools::CSmartMean(mCamFrameRate));
// Timestamp initialization
if (mSvoMode) {
mFrameTimestamp = ros::Time::now();
} else {
mFrameTimestamp = sl_tools::slTime2Ros(mZed.getTimestamp(sl::TIME_REFERENCE::CURRENT));
}
mPrevFrameTimestamp = mFrameTimestamp;
mTrackingActivated = false;
mMappingRunning = false;
mRecording = false;
// Get the parameters of the ZED images
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<1
mCamWidth = mZed.getCameraInformation().camera_resolution.width;
mCamHeight = mZed.getCameraInformation().camera_resolution.height;
#else
mCamWidth = mZed.getCameraInformation().camera_configuration.resolution.width;
mCamHeight = mZed.getCameraInformation().camera_configuration.resolution.height;
#endif
NODELET_DEBUG_STREAM("Camera Frame size : " << mCamWidth << "x" << mCamHeight);
int v_w = static_cast<int>(mCamWidth * mCamImageResizeFactor);
int v_h = static_cast<int>(mCamHeight * mCamImageResizeFactor);
mMatResolVideo = sl::Resolution(v_w,v_h);
NODELET_DEBUG_STREAM("Image Mat size : " << mMatResolVideo.width << "x" << mMatResolVideo.height);
int d_w = static_cast<int>(mCamWidth * mCamDepthResizeFactor);
int d_h = static_cast<int>(mCamHeight * mCamDepthResizeFactor);
mMatResolDepth = sl::Resolution(d_w,d_h);
NODELET_DEBUG_STREAM("Depth Mat size : " << mMatResolDepth.width << "x" << mMatResolDepth.height);
// Create and fill the camera information messages
fillCamInfo(mZed, mLeftCamInfoMsg, mRightCamInfoMsg, mLeftCamOptFrameId, mRightCamOptFrameId);
fillCamInfo(mZed, mLeftCamInfoRawMsg, mRightCamInfoRawMsg, mLeftCamOptFrameId, mRightCamOptFrameId, true);
fillCamDepthInfo(mZed,mDepthCamInfoMsg,mLeftCamOptFrameId);
// the reference camera is the Left one (next to the ZED logo)
mRgbCamInfoMsg = mLeftCamInfoMsg;
mRgbCamInfoRawMsg = mLeftCamInfoRawMsg;
sl::RuntimeParameters runParams;
runParams.sensing_mode = static_cast<sl::SENSING_MODE>(mCamSensingMode);
// Main loop
while (mNhNs.ok()) {
// Check for subscribers
//uint32_t rgbSubnumber = mPubRgb.getNumSubscribers();
//int32_t rgbRawSubnumber = mPubRawRgb.getNumSubscribers();
uint32_t leftSubnumber = mPubLeft.getNumSubscribers();
//uint32_t leftRawSubnumber = mPubRawLeft.getNumSubscribers();
uint32_t rightSubnumber = mPubRight.getNumSubscribers();
//uint32_t rightRawSubnumber = mPubRawRight.getNumSubscribers();
//uint32_t rgbGraySubnumber = mPubRgbGray.getNumSubscribers();
//uint32_t rgbGrayRawSubnumber = mPubRawRgbGray.getNumSubscribers();
//uint32_t leftGraySubnumber = mPubLeftGray.getNumSubscribers();
//uint32_t leftGrayRawSubnumber = mPubRawLeftGray.getNumSubscribers();
//uint32_t rightGraySubnumber = mPubRightGray.getNumSubscribers();
//uint32_t rightGrayRawSubnumber = mPubRawRightGray.getNumSubscribers();
//uint32_t depthSubnumber = mPubDepth.getNumSubscribers();
//uint32_t disparitySubnumber = mPubDisparity.getNumSubscribers();
//uint32_t cloudSubnumber = mPubCloud.getNumSubscribers();
//uint32_t fusedCloudSubnumber = mPubFusedCloud.getNumSubscribers();
uint32_t poseSubnumber = mPubPose.getNumSubscribers();
uint32_t poseCovSubnumber = mPubPoseCov.getNumSubscribers();
uint32_t odomSubnumber = mPubOdom.getNumSubscribers();
//uint32_t confMapSubnumber = mPubConfMap.getNumSubscribers();
uint32_t pathSubNumber = mPubMapPath.getNumSubscribers() + mPubOdomPath.getNumSubscribers();
//uint32_t stereoSubNumber = mPubStereo.getNumSubscribers();
//uint32_t stereoRawSubNumber = mPubRawStereo.getNumSubscribers();
uint32_t objDetSubnumber = 0;
uint32_t objDetVizSubnumber = 0;
bool objDetActive = false;
if (mObjDetEnabled) {
objDetSubnumber = mPubObjDet.getNumSubscribers();
objDetVizSubnumber = mPubObjDetViz.getNumSubscribers();
if (objDetSubnumber > 0 || objDetVizSubnumber > 0) {
objDetActive = true;
}
}
mGrabActive = mRecording || mStreaming || mMappingEnabled || mObjDetEnabled || mTrackingActivated ||
((leftSubnumber + rightSubnumber + poseSubnumber + poseCovSubnumber + odomSubnumber + pathSubNumber) > 0);
// Run the loop only if there is some subscribers or SVO is active
if (mGrabActive) {
std::lock_guard<std::mutex> lock(mPosTrkMutex);
// Note: ones tracking is started it is never stopped anymore to not lose tracking information
bool computeTracking = (mMappingEnabled || mObjDetEnabled || (mComputeDepth & mDepthStabilization) || poseSubnumber > 0 ||
poseCovSubnumber > 0 || odomSubnumber > 0 || pathSubNumber > 0);
// Start the tracking?
if ((computeTracking) && !mTrackingActivated && (mDepthMode != sl::DEPTH_MODE::NONE)) {
start_pos_tracking();
}
// Start the mapping?
mMappingMutex.lock();
if (mMappingEnabled && !mMappingRunning) {
start_3d_mapping();
}
mMappingMutex.unlock();
// Start the object detection?
mObjDetMutex.lock();
if (mObjDetEnabled && !mObjDetRunning) {
start_obj_detect();
}
mObjDetMutex.unlock();
// Detect if one of the subscriber need to have the depth information
mComputeDepth = mDepthMode != sl::DEPTH_MODE::NONE &&
((poseSubnumber + poseCovSubnumber + odomSubnumber) > 0);
if (mComputeDepth) {
runParams.confidence_threshold = mCamDepthConfidence;
#if ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION<2
runParams.textureness_confidence_threshold = mCamDepthTextureConf;
#else
runParams.texture_confidence_threshold = mCamDepthTextureConf;
#endif
runParams.enable_depth = true; // Ask to compute the depth
} else {
runParams.enable_depth = false; // Ask to not compute the depth
}
// ----> Wait for RGB/Depth synchronization before grabbing
// std::unique_lock<std::mutex> datalock(mCamDataMutex);
// while (!mRgbDepthDataRetrieved) { // loop to avoid spurious wakeups
// if (mRgbDepthDataRetrievedCondVar.wait_for(datalock, std::chrono::milliseconds(500)) == std::cv_status::timeout) {
// // Check thread stopping
// if (mStopNode) {
// return;
// } else {
// continue;
// }
// }
// }
// <---- Wait for RGB/Depth synchronization before grabbing
mCamDataMutex.lock();
mRgbDepthDataRetrieved = false;
mGrabStatus = mZed.grab(runParams);
mCamDataMutex.unlock();
std::chrono::steady_clock::time_point start_elab = std::chrono::steady_clock::now();
// cout << toString(grab_status) << endl;
if (mGrabStatus != sl::ERROR_CODE::SUCCESS) {
// Detect if a error occurred (for example:
// the zed have been disconnected) and
// re-initialize the ZED
NODELET_INFO_STREAM_ONCE(toString(mGrabStatus));
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if ((ros::Time::now() - mPrevFrameTimestamp).toSec() > 5 && !mSvoMode) {
mCloseZedMutex.lock();
mZed.close();
mCloseZedMutex.unlock();
mConnStatus = sl::ERROR_CODE::CAMERA_NOT_DETECTED;
while (mConnStatus != sl::ERROR_CODE::SUCCESS) {
if (!mNhNs.ok()) {
mStopNode = true;
std::lock_guard<std::mutex> lock(mCloseZedMutex);
NODELET_DEBUG("Closing ZED");
if(mRecording) {
mRecording=false;
mZed.disableRecording();
}
mZed.close();
NODELET_DEBUG("ZED pool thread finished");
return;
}
int id = sl_tools::checkCameraReady(mZedSerialNumber);
if (id >= 0) {
mZedParams.input.setFromCameraID(id);
mConnStatus = mZed.open(mZedParams); // Try to initialize the ZED
NODELET_INFO_STREAM(toString(mConnStatus));
} else {
NODELET_INFO_STREAM("Waiting for the ZED (S/N " << mZedSerialNumber << ") to be re-connected");
}
mDiagUpdater.force_update();
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}
mTrackingActivated = false;
computeTracking = mDepthStabilization || poseSubnumber > 0 || poseCovSubnumber > 0 ||
odomSubnumber > 0;
if (computeTracking) { // Start the tracking
start_pos_tracking();
}
}
mDiagUpdater.update();
continue;
}
mFrameCount++;
// SVO recording
mRecMutex.lock();
if (mRecording) {
mRecStatus = mZed.getRecordingStatus();
if (!mRecStatus.status) {
NODELET_ERROR_THROTTLE(1.0, "Error saving frame to SVO");
}
mDiagUpdater.force_update();
}
mRecMutex.unlock();
// Timestamp
mPrevFrameTimestamp = mFrameTimestamp;
// Publish freq calculation
static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double elapsed_usec = std::chrono::duration_cast<std::chrono::microseconds>(now - last_time).count();
last_time = now;
mGrabPeriodMean_usec->addValue(elapsed_usec);
// NODELET_INFO_STREAM("Grab time: " << elapsed_usec / 1000 << " msec");
// Timestamp
if (mSvoMode) {
mFrameTimestamp = ros::Time::now();
} else {
mFrameTimestamp = sl_tools::slTime2Ros(mZed.getTimestamp(sl::TIME_REFERENCE::IMAGE));
}
ros::Time stamp = mFrameTimestamp; // Timestamp
// ----> Camera Settings
if( !mSvoMode && mFrameCount%5 == 0 ) {
//NODELET_DEBUG_STREAM( "[" << mFrameCount << "] device_poll_thread_func MUTEX LOCK");
mDynParMutex.lock();
int brightness = mZed.getCameraSettings(sl::VIDEO_SETTINGS::BRIGHTNESS);
if( brightness != mCamBrightness ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::BRIGHTNESS, mCamBrightness);
NODELET_DEBUG_STREAM( "mCamBrightness changed: " << mCamBrightness << " <- " << brightness);
mUpdateDynParams = true;
}
int contrast = mZed.getCameraSettings(sl::VIDEO_SETTINGS::CONTRAST);
if( contrast != mCamContrast ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::CONTRAST, mCamContrast);
NODELET_DEBUG_STREAM( "mCamContrast changed: " << mCamContrast << " <- " << contrast);
mUpdateDynParams = true;
}
int hue = mZed.getCameraSettings(sl::VIDEO_SETTINGS::HUE);
if( hue != mCamHue ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::HUE, mCamHue);
NODELET_DEBUG_STREAM( "mCamHue changed: " << mCamHue << " <- " << hue);
mUpdateDynParams = true;
}
int saturation = mZed.getCameraSettings(sl::VIDEO_SETTINGS::SATURATION);
if( saturation != mCamSaturation ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::SATURATION, mCamSaturation);
NODELET_DEBUG_STREAM( "mCamSaturation changed: " << mCamSaturation << " <- " << saturation);
mUpdateDynParams = true;
}
int sharpness = mZed.getCameraSettings(sl::VIDEO_SETTINGS::SHARPNESS);
if( sharpness != mCamSharpness ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::SHARPNESS, mCamSharpness);
NODELET_DEBUG_STREAM( "mCamSharpness changed: " << mCamSharpness << " <- " << sharpness);
mUpdateDynParams = true;
}
#if (ZED_SDK_MAJOR_VERSION==3 && ZED_SDK_MINOR_VERSION>=1)
int gamma = mZed.getCameraSettings(sl::VIDEO_SETTINGS::GAMMA);
if( gamma != mCamGamma ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::GAMMA, mCamGamma);
NODELET_DEBUG_STREAM( "mCamGamma changed: " << mCamGamma << " <- " << gamma);
mUpdateDynParams = true;
}
#endif
if (mCamAutoExposure) {
if( mTriggerAutoExposure ) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::AEC_AGC, 1);
mTriggerAutoExposure = false;
}
} else {
int exposure = mZed.getCameraSettings(sl::VIDEO_SETTINGS::EXPOSURE);
if (exposure != mCamExposure) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::EXPOSURE, mCamExposure);
NODELET_DEBUG_STREAM( "mCamExposure changed: " << mCamExposure << " <- " << exposure);
mUpdateDynParams = true;
}
int gain = mZed.getCameraSettings(sl::VIDEO_SETTINGS::GAIN);
if (gain != mCamGain) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::GAIN, mCamGain);
NODELET_DEBUG_STREAM( "mCamGain changed: " << mCamGain << " <- " << gain);
mUpdateDynParams = true;
}
}
if (mCamAutoWB ) {
if(mTriggerAutoWB) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::WHITEBALANCE_AUTO, 1);
mTriggerAutoWB = false;
}
} else {
int wb = mZed.getCameraSettings(sl::VIDEO_SETTINGS::WHITEBALANCE_TEMPERATURE);
if (wb != mCamWB) {
mZed.setCameraSettings(sl::VIDEO_SETTINGS::WHITEBALANCE_TEMPERATURE, mCamWB);
NODELET_DEBUG_STREAM( "mCamWB changed: " << mCamWB << " <- " << wb);
mUpdateDynParams = true;
}
}
mDynParMutex.unlock();
//NODELET_DEBUG_STREAM( "device_poll_thread_func MUTEX UNLOCK");
}
if(mUpdateDynParams) {
NODELET_DEBUG( "Update Dynamic Parameters");
updateDynamicReconfigure();
}
// <---- Camera Settings
// Publish the point cloud if someone has subscribed to
/*if (cloudSubnumber > 0) {
// Run the point cloud conversion asynchronously to avoid slowing down
// all the program
// Retrieve raw pointCloud data if latest Pointcloud is ready
std::unique_lock<std::mutex> lock(mPcMutex, std::defer_lock);
if (lock.try_lock()) {
mZed.retrieveMeasure(mCloud, sl::MEASURE::XYZBGRA, sl::MEM::CPU, mMatResolDepth);
mPointCloudFrameId = mDepthFrameId;
mPointCloudTime = stamp;
// Signal Pointcloud thread that a new pointcloud is ready
mPcDataReadyCondVar.notify_one();
mPcDataReady = true;
mPcPublishing = true;
}
} else {
mPcPublishing = false;
}*/
mPcPublishing = false;
mObjDetMutex.lock();
if (mObjDetRunning) {
//std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
detectObjects(objDetSubnumber > 0, objDetVizSubnumber > 0, stamp);
//std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
//double elapsed_msec = std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count();
//mObjDetPeriodMean_msec->addValue(elapsed_msec);
}
mObjDetMutex.unlock();
// Publish the odometry if someone has subscribed to
if (computeTracking) {
if (!mSensor2BaseTransfValid) {
getSens2BaseTransform();
}
if (!mSensor2CameraTransfValid) {
getSens2CameraTransform();
}
if (!mCamera2BaseTransfValid) {
getCamera2BaseTransform();
}
if (!mInitOdomWithPose) {
sl::Pose deltaOdom;
mPosTrackingStatus = mZed.getPosition(deltaOdom, sl::REFERENCE_FRAME::CAMERA);
sl::Translation translation = deltaOdom.getTranslation();
sl::Orientation quat = deltaOdom.getOrientation();
#if 0
NODELET_DEBUG("delta ODOM [%s] - %.2f,%.2f,%.2f %.2f,%.2f,%.2f,%.2f",
sl::toString(mTrackingStatus).c_str(),
translation(0), translation(1), translation(2),
quat(0), quat(1), quat(2), quat(3));
NODELET_DEBUG_STREAM("ODOM -> Tracking Status: " << sl::toString(mTrackingStatus));
#endif
if (mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::OK || mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::SEARCHING ||
mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::FPS_TOO_LOW) {
// Transform ZED delta odom pose in TF2 Transformation
geometry_msgs::Transform deltaTransf;
deltaTransf.translation.x = translation(0);
deltaTransf.translation.y = translation(1);
deltaTransf.translation.z = translation(2);
deltaTransf.rotation.x = quat(0);
deltaTransf.rotation.y = quat(1);
deltaTransf.rotation.z = quat(2);
deltaTransf.rotation.w = quat(3);
tf2::Transform deltaOdomTf;
tf2::fromMsg(deltaTransf, deltaOdomTf);
// delta odom from sensor to base frame
tf2::Transform deltaOdomTf_base =
mSensor2BaseTransf.inverse() * deltaOdomTf * mSensor2BaseTransf;
// Propagate Odom transform in time
mOdom2BaseTransf = mOdom2BaseTransf * deltaOdomTf_base;
if (mTwoDMode) {
tf2::Vector3 tr_2d = mOdom2BaseTransf.getOrigin();
tr_2d.setZ(mFixedZValue);
mOdom2BaseTransf.setOrigin(tr_2d);
double roll, pitch, yaw;
tf2::Matrix3x3(mOdom2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
tf2::Quaternion quat_2d;
quat_2d.setRPY(0.0, 0.0, yaw);
mOdom2BaseTransf.setRotation(quat_2d);
}
#if 0 //#ifndef NDEBUG // Enable for TF checking
double roll, pitch, yaw;
tf2::Matrix3x3(mOdom2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_DEBUG("+++ Odometry [%s -> %s] - {%.3f,%.3f,%.3f} {%.3f,%.3f,%.3f}",
mOdometryFrameId.c_str(), mBaseFrameId.c_str(),
mOdom2BaseTransf.getOrigin().x(), mOdom2BaseTransf.getOrigin().y(), mOdom2BaseTransf.getOrigin().z(),
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
#endif
// Publish odometry message
if (odomSubnumber > 0) {
publishOdom(mOdom2BaseTransf, deltaOdom, stamp);
}
mTrackingReady = true;
}
} else if (mFloorAlignment) {
NODELET_WARN_THROTTLE(5.0, "Odometry will be published as soon as the floor as been detected for the first time");
}
}
// Publish the zed camera pose if someone has subscribed to
if (computeTracking) {
static sl::POSITIONAL_TRACKING_STATE oldStatus;
mPosTrackingStatus = mZed.getPosition(mLastZedPose, sl::REFERENCE_FRAME::WORLD);
sl::Translation translation = mLastZedPose.getTranslation();
sl::Orientation quat = mLastZedPose.getOrientation();
#if 0 //#ifndef NDEBUG // Enable for TF checking
double roll, pitch, yaw;
tf2::Matrix3x3(tf2::Quaternion(quat.ox, quat.oy, quat.oz, quat.ow)).getRPY(roll, pitch, yaw);
NODELET_DEBUG("Sensor POSE [%s -> %s] - {%.2f,%.2f,%.2f} {%.2f,%.2f,%.2f}",
mLeftCamFrameId.c_str(), mMapFrameId.c_str(),
translation.x, translation.y, translation.z,
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
NODELET_DEBUG_STREAM("MAP -> Tracking Status: " << sl::toString(mTrackingStatus));
#endif
if (mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::OK ||
mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::SEARCHING /*|| status == sl::POSITIONAL_TRACKING_STATE::FPS_TOO_LOW*/) {
// Transform ZED pose in TF2 Transformation
geometry_msgs::Transform map2sensTransf;
map2sensTransf.translation.x = translation(0);
map2sensTransf.translation.y = translation(1);
map2sensTransf.translation.z = translation(2);
map2sensTransf.rotation.x = quat(0);
map2sensTransf.rotation.y = quat(1);
map2sensTransf.rotation.z = quat(2);
map2sensTransf.rotation.w = quat(3);
tf2::Transform map_to_sens_transf;
tf2::fromMsg(map2sensTransf, map_to_sens_transf);
mMap2BaseTransf = map_to_sens_transf * mSensor2BaseTransf; // Base position in map frame
if (mTwoDMode) {
tf2::Vector3 tr_2d = mMap2BaseTransf.getOrigin();
tr_2d.setZ(mFixedZValue);
mMap2BaseTransf.setOrigin(tr_2d);
double roll, pitch, yaw;
tf2::Matrix3x3(mMap2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
tf2::Quaternion quat_2d;
quat_2d.setRPY(0.0, 0.0, yaw);
mMap2BaseTransf.setRotation(quat_2d);
}
#if 0 //#ifndef NDEBUG // Enable for TF checking
double roll, pitch, yaw;
tf2::Matrix3x3(mMap2BaseTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_DEBUG("*** Base POSE [%s -> %s] - {%.3f,%.3f,%.3f} {%.3f,%.3f,%.3f}",
mMapFrameId.c_str(), mBaseFrameId.c_str(),
mMap2BaseTransf.getOrigin().x(), mMap2BaseTransf.getOrigin().y(), mMap2BaseTransf.getOrigin().z(),
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
#endif
bool initOdom = false;
if (!(mFloorAlignment)) {
initOdom = mInitOdomWithPose;
} else {
initOdom = (mPosTrackingStatus == sl::POSITIONAL_TRACKING_STATE::OK) & mInitOdomWithPose;
}
if (initOdom || mResetOdom) {
NODELET_INFO("Odometry aligned to last tracking pose");
// Propagate Odom transform in time
mOdom2BaseTransf = mMap2BaseTransf;
mMap2BaseTransf.setIdentity();
if (odomSubnumber > 0) {
// Publish odometry message
publishOdom(mOdom2BaseTransf, mLastZedPose, mFrameTimestamp);
}
mInitOdomWithPose = false;
mResetOdom = false;
} else {
// Transformation from map to odometry frame
//mMap2OdomTransf = mOdom2BaseTransf.inverse() * mMap2BaseTransf;
mMap2OdomTransf = mMap2BaseTransf * mOdom2BaseTransf.inverse();
#if 0 //#ifndef NDEBUG // Enable for TF checking
double roll, pitch, yaw;
tf2::Matrix3x3(mMap2OdomTransf.getRotation()).getRPY(roll, pitch, yaw);
NODELET_DEBUG("+++ Diff [%s -> %s] - {%.3f,%.3f,%.3f} {%.3f,%.3f,%.3f}",
mMapFrameId.c_str(), mOdometryFrameId.c_str(),
mMap2OdomTransf.getOrigin().x(), mMap2OdomTransf.getOrigin().y(), mMap2OdomTransf.getOrigin().z(),
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
#endif
}
// Publish Pose message
if ((poseSubnumber + poseCovSubnumber) > 0) {
publishPose(stamp);
}
mTrackingReady = true;
}
oldStatus = mPosTrackingStatus;
}
if(mZedRealCamModel == sl::MODEL::ZED) {
// Publish pose tf only if enabled
if(mPublishTf) {
// Note, the frame is published, but its values will only change if
// someone has subscribed to odom
publishOdomFrame(mOdom2BaseTransf, stamp); // publish the base Frame in odometry frame
if(mPublishMapTf) {
// Note, the frame is published, but its values will only change if
// someone has subscribed to map
publishPoseFrame(mMap2OdomTransf, stamp); // publish the odometry Frame in map frame
}
}
}
#if 0 //#ifndef NDEBUG // Enable for TF checking
// Double check: map_to_pose must be equal to mMap2BaseTransf
tf2::Transform map_to_base;
try {
// Save the transformation from base to frame
geometry_msgs::TransformStamped b2m =
mTfBuffer->lookupTransform(mMapFrameId, mBaseFrameId, ros::Time(0));
// Get the TF2 transformation
tf2::fromMsg(b2m.transform, map_to_base);
} catch (tf2::TransformException& ex) {
NODELET_DEBUG_THROTTLE(1.0, "Transform error: %s", ex.what());
NODELET_WARN_THROTTLE(1.0, "The tf from '%s' to '%s' is not available.",
mMapFrameId.c_str(), mBaseFrameId.c_str());
}
double roll, pitch, yaw;
tf2::Matrix3x3(map_to_base.getRotation()).getRPY(roll, pitch, yaw);
NODELET_DEBUG("*** Check [%s -> %s] - {%.3f,%.3f,%.3f} {%.3f,%.3f,%.3f}",
mMapFrameId.c_str(), mBaseFrameId.c_str(),
map_to_base.getOrigin().x(), map_to_base.getOrigin().y(), map_to_base.getOrigin().z(),
roll * RAD2DEG, pitch * RAD2DEG, yaw * RAD2DEG);
NODELET_DEBUG("*******************************");
#endif
std::chrono::steady_clock::time_point end_elab = std::chrono::steady_clock::now();
double elab_usec = std::chrono::duration_cast<std::chrono::microseconds>(end_elab - start_elab).count();
double mean_elab_sec = mElabPeriodMean_sec->addValue(elab_usec / 1000000.);
static int count_warn = 0;
if (!loop_rate.sleep()) {
if (mean_elab_sec > (1. / mCamFrameRate)) {
if (++count_warn > 10) {
NODELET_DEBUG_THROTTLE(
1.0,
"Working thread is not synchronized with the Camera frame rate");
NODELET_DEBUG_STREAM_THROTTLE(
1.0, "Expected cycle time: " << loop_rate.expectedCycleTime()
<< " - Real cycle time: "
<< mean_elab_sec);
NODELET_WARN_STREAM_THROTTLE(10.0, "Elaboration takes longer (" << mean_elab_sec << " sec) than requested "
"by the FPS rate (" << loop_rate.expectedCycleTime() << " sec). Please consider to "
"lower the 'frame_rate' setting or to reduce the power requirements reducing the resolutions.");
}
loop_rate.reset();
} else {
count_warn = 0;
}
}
} else {
NODELET_DEBUG_THROTTLE(5.0, "No topics subscribed by users");
if(mZedRealCamModel == sl::MODEL::ZED || !mPublishImuTf) {
// Publish odometry tf only if enabled
if (mPublishTf) {
ros::Time t;
if (mSvoMode) {
t = ros::Time::now();
} else {
t = sl_tools::slTime2Ros(mZed.getTimestamp(sl::TIME_REFERENCE::CURRENT));
}
publishOdomFrame(mOdom2BaseTransf, mFrameTimestamp); // publish the base Frame in odometry frame
if (mPublishMapTf) {
publishPoseFrame(mMap2OdomTransf, mFrameTimestamp); // publish the odometry Frame in map frame
}
if(mPublishImuTf && !mStaticImuFramePublished )
{
publishStaticImuFrame();
}
}
}
std::this_thread::sleep_for(
std::chrono::milliseconds(10)); // No subscribers, we just wait
loop_rate.reset();
}
mDiagUpdater.update();
} // while loop
mStopNode = true; // Stops other threads
std::lock_guard<std::mutex> lock(mCloseZedMutex);
NODELET_DEBUG("Closing ZED");
if(mRecording) {
mRecording=false;
mZed.disableRecording();
}
mZed.close();
NODELET_DEBUG("ZED pool thread finished");
}
void ZEDWrapperNodelet::callback_updateDiagnostic(diagnostic_updater::DiagnosticStatusWrapper& stat) {
if (mConnStatus != sl::ERROR_CODE::SUCCESS) {
stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, sl::toString(mConnStatus).c_str());
return;
}
if (mGrabActive) {
if (mGrabStatus == sl::ERROR_CODE::SUCCESS /*|| mGrabStatus == sl::ERROR_CODE::NOT_A_NEW_FRAME*/) {
stat.summary(diagnostic_msgs::DiagnosticStatus::OK, "Camera grabbing");
double freq = 1000000. / mGrabPeriodMean_usec->getMean();
double freq_perc = 100.*freq / mCamFrameRate;
stat.addf("Capture", "Mean Frequency: %.1f Hz (%.1f%%)", freq, freq_perc);
stat.addf("General Processing", "Mean Time: %.3f sec (Max. %.3f sec)", mElabPeriodMean_sec->getMean(), 1. / mCamFrameRate);
if(mPublishingData) {
freq = 1. / mVideoDepthPeriodMean_sec->getMean();
freq_perc = 100.*freq / mVideoDepthFreq;
stat.addf("Video/Depth Publish", "Mean Frequency: %.1f Hz (%.1f%%)", freq, freq_perc);
}
if( mSvoMode ) {
int frame = mZed.getSVOPosition();
int totFrames = mZed.getSVONumberOfFrames();
double svo_perc = 100.*(static_cast<double>(frame)/totFrames);
stat.addf("Playing SVO", "Frame: %d/%d (%.1f%%)", frame,totFrames, svo_perc);
}
if (mComputeDepth) {
stat.add("Depth status", "ACTIVE");
if (mPcPublishing) {
double freq = 1000000. / mPcPeriodMean_usec->getMean();
double freq_perc = 100.*freq / mPointCloudFreq;
stat.addf("Point Cloud", "Mean Frequency: %.1f Hz (%.1f%%)", freq, freq_perc);
} else {
stat.add("Point Cloud", "Topic not subscribed");
}
if (mFloorAlignment) {
if (mInitOdomWithPose) {
stat.add("Floor Detection", "NOT INITIALIZED");
} else {
stat.add("Floor Detection", "INITIALIZED");
}
}
if (mTrackingActivated) {
stat.addf("Tracking status", "%s", sl::toString(mPosTrackingStatus).c_str());
} else {
stat.add("Pos. Tracking status", "INACTIVE");
}
if (mObjDetRunning) {
double freq = 1000./mObjDetPeriodMean_msec->getMean();
double freq_perc = 100.*freq / mCamFrameRate;
stat.addf("Object detection", "Mean Frequency: %.3f Hz (%.1f%%)", freq, freq_perc );
} else {
stat.add("Object Detection", "INACTIVE");
}
} else {
stat.add("Depth status", "INACTIVE");
}
} else {
stat.summaryf(diagnostic_msgs::DiagnosticStatus::ERROR, "Camera error: %s", sl::toString(mGrabStatus).c_str());
}
} else {
stat.summary(diagnostic_msgs::DiagnosticStatus::OK, "Waiting for data subscriber");
stat.add("Capture", "INACTIVE");
}
if (mSensPublishing) {
double freq = 1000000. / mSensPeriodMean_usec->getMean();
double freq_perc = 100.*freq / mSensPubRate;
stat.addf("IMU", "Mean Frequency: %.1f Hz (%.1f%%)", freq, freq_perc);
} else {
stat.add("IMU", "Topics not subscribed");
}
if( mZedRealCamModel == sl::MODEL::ZED2 ) {
stat.addf("Left CMOS Temp.", "%.1f °C", mTempLeft);
stat.addf("Right CMOS Temp.", "%.1f °C", mTempRight);
if( mTempLeft>70.f || mTempRight>70.f ) {
stat.summary(diagnostic_msgs::DiagnosticStatus::WARN, "Camera temperature");
}
} else {
stat.add("Left CMOS Temp.", "N/A");
stat.add("Right CMOS Temp.", "N/A");
}
if (mRecording) {
if (!mRecStatus.status) {
if (mGrabActive) {
stat.add("SVO Recording", "ERROR");
stat.summary(diagnostic_msgs::DiagnosticStatus::WARN,
"Error adding frames to SVO file while recording. Check free disk space");
} else {
stat.add("SVO Recording", "WAITING");
}
} else {
stat.add("SVO Recording", "ACTIVE");
stat.addf("SVO compression time", "%g msec", mRecStatus.average_compression_time);
stat.addf("SVO compression ratio", "%.1f%%", mRecStatus.average_compression_ratio);
}
} else {
stat.add("SVO Recording", "NOT ACTIVE");
}
}
bool ZEDWrapperNodelet::on_start_svo_recording(zed_interfaces::start_svo_recording::Request& req,
zed_interfaces::start_svo_recording::Response& res) {
std::lock_guard<std::mutex> lock(mRecMutex);
if (mRecording) {
res.result = false;
res.info = "Recording was just active";
return false;
}
// Check filename
if (req.svo_filename.empty()) {
req.svo_filename = "zed.svo";
}
sl::ERROR_CODE err;
sl::RecordingParameters recParams;
recParams.compression_mode = mSvoComprMode;
recParams.video_filename = req.svo_filename.c_str();
err = mZed.enableRecording(recParams);
if (err == sl::ERROR_CODE::SVO_UNSUPPORTED_COMPRESSION) {
recParams.compression_mode = mSvoComprMode == sl::SVO_COMPRESSION_MODE::H265 ? sl::SVO_COMPRESSION_MODE::H264 :
sl::SVO_COMPRESSION_MODE::H265;
NODELET_WARN_STREAM("The chosen " << sl::toString(mSvoComprMode).c_str() << "mode is not available. Trying " <<
sl::toString(recParams.compression_mode).c_str());
err = mZed.enableRecording(recParams);
if (err == sl::ERROR_CODE::SVO_UNSUPPORTED_COMPRESSION) {
NODELET_WARN_STREAM(sl::toString(recParams.compression_mode).c_str() << "not available. Trying " << sl::toString(
sl::SVO_COMPRESSION_MODE::H264).c_str());
recParams.compression_mode = sl::SVO_COMPRESSION_MODE::H264;
err = mZed.enableRecording(recParams);
if (err == sl::ERROR_CODE::SVO_UNSUPPORTED_COMPRESSION) {
recParams.compression_mode = sl::SVO_COMPRESSION_MODE::LOSSLESS;
err = mZed.enableRecording(recParams);
}
}
}
if (err != sl::ERROR_CODE::SUCCESS) {
res.result = false;
res.info = sl::toString(err).c_str();
mRecording = false;
return false;
}
mSvoComprMode = recParams.compression_mode;
mRecording = true;
res.info = "Recording started (";
res.info += sl::toString(mSvoComprMode).c_str();
res.info += ")";
res.result = true;
NODELET_INFO_STREAM("SVO recording STARTED: " << req.svo_filename << " (" << sl::toString(mSvoComprMode).c_str() << ")");
return true;
}
bool ZEDWrapperNodelet::on_stop_svo_recording(zed_interfaces::stop_svo_recording::Request& req,
zed_interfaces::stop_svo_recording::Response& res) {
std::lock_guard<std::mutex> lock(mRecMutex);
if (!mRecording) {
res.done = false;
res.info = "Recording was not active";
return false;
}
mZed.disableRecording();
mRecording = false;
res.info = "Recording stopped";
res.done = true;
NODELET_INFO_STREAM("SVO recording STOPPED");
return true;
}
bool ZEDWrapperNodelet::on_start_remote_stream(zed_interfaces::start_remote_stream::Request& req,
zed_interfaces::start_remote_stream::Response& res) {
if (mStreaming) {
res.result = false;
res.info = "SVO remote streaming was just active";
return false;
}
sl::StreamingParameters params;
params.codec = static_cast<sl::STREAMING_CODEC>(req.codec);
params.port = req.port;
params.bitrate = req.bitrate;
params.gop_size = req.gop_size;
params.adaptative_bitrate = req.adaptative_bitrate;
if (params.gop_size < -1 || params.gop_size > 256) {
mStreaming = false;
res.result = false;
res.info = "`gop_size` wrong (";
res.info += params.gop_size;
res.info += "). Remote streaming not started";
NODELET_ERROR_STREAM(res.info);
return false;
}
if (params.port % 2 != 0) {
mStreaming = false;
res.result = false;
res.info = "`port` must be an even number. Remote streaming not started";
NODELET_ERROR_STREAM(res.info);
return false;
}
sl::ERROR_CODE err = mZed.enableStreaming(params);
if (err != sl::ERROR_CODE::SUCCESS) {
mStreaming = false;
res.result = false;
res.info = sl::toString(err).c_str();
NODELET_ERROR_STREAM("Remote streaming not started (" << res.info << ")");
return false;
}
mStreaming = true;
NODELET_INFO_STREAM("Remote streaming STARTED");
res.result = true;
res.info = "Remote streaming STARTED";
return true;
}
bool ZEDWrapperNodelet::on_stop_remote_stream(zed_interfaces::stop_remote_stream::Request& req,
zed_interfaces::stop_remote_stream::Response& res) {
if (mStreaming) {
mZed.disableStreaming();
}
mStreaming = false;
NODELET_INFO_STREAM("SVO remote streaming STOPPED");
res.done = true;
return true;
}
bool ZEDWrapperNodelet::on_set_led_status(zed_interfaces::set_led_status::Request& req,
zed_interfaces::set_led_status::Response& res) {
if (mCamFwVersion < 1523) {
NODELET_WARN_STREAM("To set the status of the blue LED the camera must be updated to FW 1523 or newer");
return false;
}
mZed.setCameraSettings(sl::VIDEO_SETTINGS::LED_STATUS, req.led_enabled ? 1 : 0);
return true;
}
bool ZEDWrapperNodelet::on_toggle_led(zed_interfaces::toggle_led::Request& req,
zed_interfaces::toggle_led::Response& res) {
if (mCamFwVersion < 1523) {
NODELET_WARN_STREAM("To set the status of the blue LED the camera must be updated to FW 1523 or newer");
return false;
}
int status = mZed.getCameraSettings(sl::VIDEO_SETTINGS::LED_STATUS);
int new_status = status == 0 ? 1 : 0;
mZed.setCameraSettings(sl::VIDEO_SETTINGS::LED_STATUS, new_status);
return (new_status == 1);
}
bool ZEDWrapperNodelet::on_start_3d_mapping(zed_interfaces::start_3d_mapping::Request& req,
zed_interfaces::start_3d_mapping::Response& res) {
if( mMappingEnabled && mMappingRunning) {
NODELET_WARN_STREAM("Spatial mapping was just running");
res.done = false;
return res.done;
}
mMappingRunning = false;
mMappingRes = req.resolution;
mMaxMappingRange = req.max_mapping_range;
mFusedPcPubFreq = req.fused_pointcloud_freq;
NODELET_DEBUG_STREAM(" * Received mapping resolution\t\t-> " << mMappingRes << " m");
NODELET_DEBUG_STREAM(" * Received mapping max range\t-> " << mMaxMappingRange << " m" );
NODELET_DEBUG_STREAM(" * Received fused point cloud freq:\t-> " << mFusedPcPubFreq << " Hz");
mMappingEnabled = true;
res.done = true;
return res.done;
}
bool ZEDWrapperNodelet::on_stop_3d_mapping(zed_interfaces::stop_3d_mapping::Request& req,
zed_interfaces::stop_3d_mapping::Response& res) {
if( mMappingEnabled ) {
mPubFusedCloud.shutdown();
mMappingMutex.lock();
stop_3d_mapping();
mMappingMutex.unlock();
res.done = true;
} else {
res.done = false;
}
return res.done;
}
bool ZEDWrapperNodelet::on_start_object_detection(zed_interfaces::start_object_detection::Request& req,
zed_interfaces::start_object_detection::Response& res) {
if(mZedRealCamModel!=sl::MODEL::ZED2) {
mObjDetEnabled = false;
mObjDetRunning = false;
NODELET_ERROR_STREAM( "Object detection not started. OD is available only using a ZED2 camera model");
return false;
}
if( mObjDetEnabled && mObjDetRunning) {
NODELET_WARN_STREAM("Object Detection was just running");
res.done = false;
return res.done;
}
mObjDetRunning = false;
mObjDetConfidence = req.confidence;
mObjDetTracking = req.tracking;
mObjDetPeople = req.people;
mObjDetVehicles = req.vehicles;
NODELET_DEBUG_STREAM(" * Object min. confidence\t-> " << mObjDetConfidence);
NODELET_DEBUG_STREAM(" * Object tracking\t\t-> " << (mObjDetTracking?"ENABLED":"DISABLED"));
NODELET_DEBUG_STREAM(" * People detection\t\t-> " << (mObjDetPeople?"ENABLED":"DISABLED"));
NODELET_DEBUG_STREAM(" * Vehicles detection\t\t-> " << (mObjDetVehicles?"ENABLED":"DISABLED"));
mObjDetEnabled = true;
res.done = true;
return res.done;
}
/*! \brief Service callback to stop_object_detection service
*/
bool ZEDWrapperNodelet::on_stop_object_detection(zed_interfaces::stop_object_detection::Request& req,
zed_interfaces::stop_object_detection::Response& res) {
if( mObjDetEnabled ) {
mObjDetMutex.lock();
stop_obj_detect();
mObjDetMutex.unlock();
res.done = true;
} else {
res.done = false;
}
return res.done;
}
void ZEDWrapperNodelet::detectObjects(bool publishObj, bool publishViz, ros::Time t) {
static std::chrono::steady_clock::time_point old_time = std::chrono::steady_clock::now();
sl::ObjectDetectionRuntimeParameters objectTracker_parameters_rt;
objectTracker_parameters_rt.detection_confidence_threshold = mObjDetConfidence;
objectTracker_parameters_rt.object_class_filter = mObjDetFilter;
sl::Objects objects;
sl::ERROR_CODE objDetRes = mZed.retrieveObjects(objects, objectTracker_parameters_rt);
if (objDetRes != sl::ERROR_CODE::SUCCESS) {
NODELET_WARN_STREAM("Object Detection error: " << sl::toString(objDetRes));
return;
}
if(!objects.is_new)
{
return;
}
// ----> Diagnostic information update
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double elapsed_msec = std::chrono::duration_cast<std::chrono::milliseconds>(now - old_time).count();
mObjDetPeriodMean_msec->addValue(elapsed_msec);
old_time = now;
// <---- Diagnostic information update
// NODELET_DEBUG_STREAM("Detected " << objects.object_list.size() << " objects");
size_t objCount = objects.object_list.size();
zed_interfaces::Objects objMsg;
objMsg.objects.resize(objCount);
std_msgs::Header header;
header.stamp = t;
header.frame_id = mLeftCamFrameId;
visualization_msgs::MarkerArray objMarkersMsg;
//objMarkersMsg.markers.resize(objCount * 3);
for (size_t i = 0; i < objCount; i++) {
sl::ObjectData data = objects.object_list[i];
if (publishObj) {
objMsg.objects[i].header = header;
objMsg.objects[i].label = sl::toString(data.label).c_str();
objMsg.objects[i].label_id = data.id;
objMsg.objects[i].confidence = data.confidence;
objMsg.objects[i].tracking_state = static_cast<int8_t>(data.tracking_state);
objMsg.objects[i].position.x = data.position.x;
objMsg.objects[i].position.y = data.position.y;
objMsg.objects[i].position.z = data.position.z;
objMsg.objects[i].linear_vel.x = data.velocity.x;
objMsg.objects[i].linear_vel.y = data.velocity.y;
objMsg.objects[i].linear_vel.z = data.velocity.z;
for (int c = 0; c < data.bounding_box_2d.size(); c++) {
objMsg.objects[i].bbox_2d[c].x = data.bounding_box_2d[c].x;
objMsg.objects[i].bbox_2d[c].y = data.bounding_box_2d[c].y;
objMsg.objects[i].bbox_2d[c].z = 0.0f;
}
for (int c = 0; c < data.bounding_box.size(); c++) {
objMsg.objects[i].bbox_3d[c].x = data.bounding_box[c].x;
objMsg.objects[i].bbox_3d[c].y = data.bounding_box[c].y;
objMsg.objects[i].bbox_3d[c].z = data.bounding_box[c].z;
}
}
if (publishViz) {
if( data.bounding_box.size()!=8 ) {
continue; // No 3D information available
}
visualization_msgs::Marker bbx_marker;
bbx_marker.header = header;
bbx_marker.ns = "bbox";
bbx_marker.id = data.id;
bbx_marker.type = visualization_msgs::Marker::CUBE;
bbx_marker.action = visualization_msgs::Marker::ADD;
bbx_marker.pose.position.x = data.position.x;
bbx_marker.pose.position.y = data.position.y;
bbx_marker.pose.position.z = data.position.z;
bbx_marker.pose.orientation.x = 0.0;
bbx_marker.pose.orientation.y = 0.0;
bbx_marker.pose.orientation.z = 0.0;
bbx_marker.pose.orientation.w = 1.0;
bbx_marker.scale.x = fabs(data.bounding_box[0].x - data.bounding_box[1].x);
bbx_marker.scale.y = fabs(data.bounding_box[0].y - data.bounding_box[3].y);
bbx_marker.scale.z = fabs(data.bounding_box[0].z - data.bounding_box[4].z);
sl::float3 color = generateColorClass(data.id);
bbx_marker.color.b = color.b;
bbx_marker.color.g = color.g;
bbx_marker.color.r = color.r;
bbx_marker.color.a = 0.4;
bbx_marker.lifetime = ros::Duration(0.3);
bbx_marker.frame_locked = true;
objMarkersMsg.markers.push_back(bbx_marker);
visualization_msgs::Marker label;
label.header = header;
label.lifetime = ros::Duration(0.3);
label.action = visualization_msgs::Marker::ADD;
label.id = data.id;
label.ns = "label";
label.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
label.scale.z = 0.1;
label.color.r = 255-color.r;
label.color.g = 255-color.g;
label.color.b = 255-color.b;
label.color.a = 0.75f;
label.pose.position.x = data.position.x;
label.pose.position.y = data.position.y;
label.pose.position.z = data.position.z+1.1*bbx_marker.scale.z/2;
label.text = std::to_string(data.id) + ". " + std::string(sl::toString(data.label).c_str());
objMarkersMsg.markers.push_back(label);
}
}
if (publishObj) {
mPubObjDet.publish(objMsg);
}
if (mPubObjDetViz) {
mPubObjDetViz.publish(objMarkersMsg);
}
}
} // namespace
|
;http://blog.csdn.net/wwyyxx26/article/details/23562689
.model flat
.data
end |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x14f21, %r14
nop
nop
add $54792, %r10
movb $0x61, (%r14)
cmp $14653, %rsi
lea addresses_WT_ht+0x134db, %rsi
lea addresses_D_ht+0x7ef9, %rdi
nop
nop
xor $25189, %r14
mov $25, %rcx
rep movsl
nop
nop
nop
nop
sub %r9, %r9
lea addresses_WC_ht+0xd615, %r9
nop
nop
xor $31740, %r11
movl $0x61626364, (%r9)
sub $49986, %rdi
lea addresses_A_ht+0x15619, %r10
nop
inc %r14
mov (%r10), %rcx
nop
nop
nop
nop
add $63182, %rdi
lea addresses_D_ht+0x12a19, %rsi
lea addresses_WT_ht+0x11c09, %rdi
nop
nop
and %r10, %r10
mov $4, %rcx
rep movsb
nop
nop
nop
and $19908, %rcx
lea addresses_A_ht+0x18ce9, %r10
nop
nop
nop
nop
xor %r11, %r11
mov $0x6162636465666768, %rsi
movq %rsi, %xmm0
movups %xmm0, (%r10)
nop
nop
add %r9, %r9
lea addresses_UC_ht+0xd119, %r9
clflush (%r9)
nop
sub $31542, %r11
mov $0x6162636465666768, %rdi
movq %rdi, %xmm6
vmovups %ymm6, (%r9)
nop
nop
nop
xor $49761, %r10
lea addresses_normal_ht+0xfbb9, %rsi
lea addresses_WC_ht+0x1b119, %rdi
nop
nop
nop
nop
nop
sub $56699, %rdx
mov $39, %rcx
rep movsq
nop
xor %rdx, %rdx
lea addresses_A_ht+0x54b1, %rdi
clflush (%rdi)
nop
nop
dec %rdx
movw $0x6162, (%rdi)
nop
sub $8371, %r14
lea addresses_A_ht+0x1ee19, %rsi
dec %rcx
mov (%rsi), %r14
nop
and %r11, %r11
lea addresses_D_ht+0x136f9, %rsi
lea addresses_WT_ht+0x17a19, %rdi
nop
nop
inc %r9
mov $9, %rcx
rep movsw
nop
nop
nop
nop
nop
sub $9721, %r9
lea addresses_WT_ht+0x10d99, %rsi
lea addresses_normal_ht+0x1c509, %rdi
sub $36253, %r14
mov $68, %rcx
rep movsq
nop
nop
nop
xor $59597, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r15
push %r8
push %r9
push %rax
push %rcx
push %rsi
// Store
lea addresses_WT+0x1c449, %rsi
inc %r14
mov $0x5152535455565758, %r15
movq %r15, %xmm0
vmovups %ymm0, (%rsi)
cmp %r9, %r9
// Store
mov $0x339, %rax
nop
nop
nop
inc %r8
movl $0x51525354, (%rax)
sub %r8, %r8
// Store
lea addresses_US+0x12a19, %r15
xor %r8, %r8
movb $0x51, (%r15)
nop
and $4670, %r9
// Load
lea addresses_A+0x13e09, %rax
clflush (%rax)
nop
nop
nop
and %r14, %r14
mov (%rax), %r15w
nop
nop
nop
cmp %rcx, %rcx
// Load
lea addresses_RW+0xde19, %rsi
nop
nop
sub $12393, %rax
vmovups (%rsi), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r14
nop
nop
nop
nop
cmp %r8, %r8
// Store
lea addresses_A+0xd219, %r15
nop
nop
nop
nop
nop
dec %r8
mov $0x5152535455565758, %r14
movq %r14, %xmm3
movups %xmm3, (%r15)
nop
nop
nop
inc %r9
// Store
mov $0x785, %r15
nop
nop
nop
nop
nop
xor %r8, %r8
movb $0x51, (%r15)
nop
xor %r14, %r14
// Store
lea addresses_D+0x8aa5, %rcx
nop
nop
nop
nop
cmp $55153, %r14
mov $0x5152535455565758, %r9
movq %r9, %xmm7
movups %xmm7, (%rcx)
nop
nop
nop
sub $8658, %r15
// Faulty Load
lea addresses_UC+0x8219, %r15
nop
nop
nop
nop
add %rax, %rax
movups (%r15), %xmm3
vpextrq $1, %xmm3, %r9
lea oracles, %rax
and $0xff, %r9
shlq $12, %r9
mov (%rax,%r9,1), %r9
pop %rsi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WT', 'AVXalign': False, 'size': 32}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_P', 'AVXalign': False, 'size': 4}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_US', 'AVXalign': False, 'size': 1}}
{'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_A', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_RW', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_A', 'AVXalign': False, 'size': 16}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_P', 'AVXalign': False, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_D', 'AVXalign': False, 'size': 16}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}}
{'src': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_A_ht', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 2, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32}}
{'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}}
{'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}}
{'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}}
{'00': 382}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A314056: Coordination sequence Gal.4.135.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,5,11,15,21,27,31,37,42,47,53,57,63,69,73,79,84,89,95,99,105,111,115,121,126,131,137,141,147,153,157,163,168,173,179,183,189,195,199,205,210,215,221,225,231,237,241,247,252,257
mov $4,2
mov $6,$0
lpb $4
sub $4,1
add $0,$4
sub $0,1
mov $7,2
mov $9,$0
lpb $7
mov $0,$9
sub $7,1
add $0,$7
mov $2,$0
pow $2,3
mul $2,7
add $2,4
div $2,8
mov $5,$2
mov $8,$7
lpb $8
sub $8,1
mov $10,$5
lpe
lpe
lpb $9
mov $9,0
sub $10,$5
lpe
mov $3,$4
mov $5,$10
lpb $3
mov $1,$5
sub $3,1
lpe
lpe
lpb $6
sub $1,$5
mov $6,0
lpe
|
/*
* myworkcell_core.cpp
*
* Created on: Sep 12, 2019
* Author: Jorge Nicho
*/
#include <rclcpp/rclcpp.hpp>
#include <myworkcell_msgs/srv/localize_part.hpp>
#include <myworkcell_msgs/srv/plan_cartesian_path.hpp>
#include <myworkcell_msgs/srv/move_to_pose.hpp>
#include <myworkcell_msgs/srv/execute_trajectory.hpp>
#include <console_bridge/console.h>
static const std::string NODE_NAME = "myworkcell_node";
static const int WAIT_SERVICE_PERIOD = 10;
class ScanNPlan: public rclcpp::Node
{
public:
ScanNPlan(const rclcpp::NodeOptions & options):
rclcpp::Node(NODE_NAME, options)
{
//***FILL CODE HERE IN CONSTRUCTOR FOR SERVICES
}
~ScanNPlan()
{
}
bool start(const std::string& base_frame)
{
//***FILL CODE HERE TO CALL THE ROS SERVICES OVER THE BRIDGE
}
//***FILL CODE HERE TO DECLARE SERVICES
};
int main(int argc, char** argv)
{
//***FILL CODE HERE TO START ROS2, INSTANTIATE THE ScanNPlan CLASS, AND CALL THE start() METHOD
}
|
Name: game_over_usa.asm
Type: file
Size: 75996
Last-Modified: '1993-07-20T07:13:25Z'
SHA-1: 488D330AFC2CFF9D0DD6B0C952301E881FAC32E3
Description: null
|
; ASM data file from a ZX-Paintbrush picture with 256 x 256 pixels (= 32 x 32 characters)
; and an attribute area of 1024 bytes
; block based output of pixel data - each block contains 8 x 8 pixels
; blocks at pixel positionn (y=0):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x07, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF
defb 0x4F
defb 0xE0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x16, 0x6F, 0xDF, 0xFF, 0xDF
defb 0x48
defb 0x00, 0x00, 0x0F, 0xF7, 0xDE, 0x7D, 0xFE, 0xFD
defb 0x48
defb 0x00, 0x15, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
defb 0x48
defb 0xFC, 0xF6, 0xBF, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF
defb 0x48
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x0A, 0x11, 0x02, 0x28, 0x45, 0x0E, 0x75, 0x80
defb 0x43
defb 0x01, 0x4E, 0x14, 0x29, 0xC0, 0xA8, 0x01, 0x10
defb 0x03
defb 0x80, 0x72, 0x28, 0x94, 0x03, 0x15, 0x80, 0x08
defb 0x43
defb 0x50, 0x88, 0x40, 0x14, 0xA2, 0x70, 0xAE, 0x01
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x5A, 0x85, 0x00, 0x18, 0x20, 0x00, 0x00, 0x00
defb 0x43
defb 0xD0, 0x0D, 0x00, 0x00, 0x07, 0x0A, 0x40, 0x00
defb 0x03
defb 0x3A, 0x50, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00
defb 0x43
defb 0x7A, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x03
; blocks at pixel positionn (y=8):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x06
defb 0x4F
defb 0xFF, 0xFE, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xA0
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x4F
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x41
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x0A, 0x11, 0x02, 0x28, 0x45, 0x0E, 0x75, 0x80
defb 0x43
defb 0x01, 0x4E, 0x14, 0x29, 0xC0, 0xA8, 0x01, 0x10
defb 0x03
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x80, 0x72, 0x28, 0x94, 0x03, 0x15, 0x80, 0x08
defb 0x43
defb 0x50, 0x88, 0x40, 0x14, 0xA2, 0x70, 0xAE, 0x01
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=16):
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x03
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x02
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x05, 0x02, 0x51, 0x2A, 0x04, 0x0E, 0x04, 0x0A
defb 0x02
defb 0x5A, 0x85, 0x00, 0x18, 0x20, 0x00, 0xB0, 0x0B
defb 0x43
defb 0xD0, 0x0D, 0x00, 0x00, 0x07, 0x0A, 0xA1, 0x5E
defb 0x03
defb 0x00, 0xAA, 0x01, 0x02, 0x14, 0xA9, 0x52, 0x24
defb 0x03
defb 0x0C, 0x56, 0x8F, 0x5B, 0xA9, 0x2E, 0x94, 0x40
defb 0x47
defb 0x30, 0x6A, 0xF1, 0xDA, 0x95, 0x74, 0x29, 0x02
defb 0x47
defb 0x00, 0x55, 0x80, 0x40, 0x28, 0x95, 0x4A, 0x24
defb 0x03
defb 0x00, 0x2C, 0x7E, 0x5A, 0x2C, 0x5A, 0x34, 0x5A
defb 0x47
defb 0x00, 0xA8, 0x54, 0xA2, 0x74, 0xAA, 0x50, 0xAA
defb 0x06
defb 0x3C, 0x5A, 0x74, 0x2A, 0x5C, 0x3E, 0x54, 0x3A
defb 0x47
defb 0x54, 0x8A, 0x54, 0xA2, 0x54, 0xAA, 0x10, 0xAA
defb 0x06
defb 0x3C, 0x5A, 0x74, 0x2A, 0x5C, 0x3E, 0x54, 0x3A
defb 0x47
defb 0x54, 0x8A, 0x54, 0xA2, 0x54, 0xAA, 0x10, 0xAA
defb 0x06
defb 0x10, 0x10, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x08, 0x08, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x40, 0x60, 0xD0, 0xA8, 0xC5, 0x80, 0x80, 0x44
defb 0x43
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x43
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=24):
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x03
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x3C, 0x5A, 0x74, 0x2A, 0x5C, 0x3E, 0x54, 0x3A
defb 0x47
defb 0x54, 0x8A, 0x54, 0xA2, 0x54, 0xAA, 0x10, 0xAA
defb 0x06
defb 0x3C, 0x5A, 0x74, 0x2A, 0x5C, 0x3E, 0x54, 0x3A
defb 0x47
defb 0x54, 0x8A, 0x54, 0xA2, 0x54, 0xAA, 0x10, 0xAA
defb 0x06
defb 0x2C, 0x5A, 0x34, 0x5A, 0x2C, 0x5A, 0x7E, 0x2C
defb 0x47
defb 0x54, 0xAA, 0x50, 0xAA, 0x74, 0xA2, 0x54, 0xA8
defb 0x06
defb 0x00, 0x03, 0x0C, 0x11, 0x27, 0x2C, 0x58, 0x59
defb 0x45
defb 0x00, 0xC0, 0x30, 0x88, 0xE4, 0x34, 0x1A, 0x9A
defb 0x05
defb 0x60, 0x00, 0x60, 0x00, 0x30, 0x00, 0x30, 0x00
defb 0x45
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x03, 0x0C, 0x11, 0x27, 0x2C, 0x58, 0x59
defb 0x45
defb 0x00, 0xC0, 0x30, 0x88, 0xE4, 0x34, 0x1A, 0x9A
defb 0x05
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x06, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x0C, 0x00
defb 0x45
defb 0xA0, 0x40, 0x8A, 0x54, 0x20, 0x70, 0x20, 0x50
defb 0x43
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x43
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x02
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x02
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x03
; blocks at pixel positionn (y=32):
defb 0x00, 0x21, 0x54, 0x39, 0x1C, 0x4A, 0x25, 0x43
defb 0x43
defb 0x00, 0x14, 0xB6, 0x12, 0xB4, 0x22, 0x14, 0x86
defb 0x42
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x44, 0x20, 0x54, 0x22, 0x10, 0x28, 0x11, 0x28
defb 0x03
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x05, 0x02, 0x51, 0x2A, 0x04, 0x0E, 0x04, 0x0A
defb 0x02
defb 0x04, 0x04, 0x44, 0x44, 0x2C, 0x2C, 0x34, 0x14
defb 0x47
defb 0x04, 0x04, 0x84, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C
defb 0x45
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x40, 0x75, 0x3B, 0x1B, 0x43, 0x25, 0x89, 0x19
defb 0x47
defb 0x01, 0x57, 0xAE, 0x4C, 0xE1, 0x52, 0x48, 0x48
defb 0x07
defb 0x5F, 0x3E, 0x15, 0x1F, 0x2F, 0x5F, 0x7F, 0xBF
defb 0x46
defb 0x46, 0x8C, 0x18, 0x88, 0x04, 0xCA, 0xA6, 0xC3
defb 0x06
defb 0x00, 0x5D, 0xB9, 0x75, 0x35, 0x19, 0x2D, 0x00
defb 0x45
defb 0x00, 0xBA, 0x9D, 0xAE, 0xAC, 0x98, 0xB4, 0x00
defb 0x05
defb 0x7F, 0x3C, 0x18, 0x00, 0x80, 0xC0, 0xE3, 0xFF
defb 0x7E
defb 0x7F, 0x3C, 0x18, 0x00, 0x80, 0xC0, 0xE3, 0xFF
defb 0x3E
defb 0x00, 0x06, 0x18, 0x22, 0x55, 0x40, 0x2A, 0x00
defb 0x47
defb 0x00, 0xA0, 0x18, 0xA4, 0x52, 0x00, 0xAA, 0x00
defb 0x07
defb 0x00, 0x00, 0x06, 0x3E, 0x74, 0x60, 0x36, 0x5C
defb 0x47
defb 0x00, 0x00, 0xF0, 0xF8, 0x08, 0x04, 0x04, 0x08
defb 0x06
defb 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x20, 0x20, 0x10
defb 0x06
defb 0x00, 0x00, 0x60, 0x7C, 0x2E, 0x06, 0x6C, 0x3A
defb 0x47
defb 0x7F, 0x3C, 0x18, 0x00, 0x80, 0xC0, 0xE3, 0xFF
defb 0xCD
defb 0xFF, 0xFE, 0x3C, 0x18, 0x00, 0x01, 0x83, 0xE7
defb 0xCD
defb 0x00, 0x34, 0x4A, 0x50, 0x42, 0x28, 0x14, 0x00
defb 0x43
defb 0x34, 0x4A, 0x50, 0x42, 0x28, 0x14, 0x00, 0x00
defb 0x02
; blocks at pixel positionn (y=40):
defb 0x69, 0x64, 0x28, 0x45, 0x29, 0x44, 0x2D, 0x00
defb 0x42
defb 0x54, 0xE2, 0x72, 0xA8, 0x14, 0x8E, 0x36, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x41
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x02
defb 0x00, 0x10, 0x20, 0x04, 0x02, 0xA0, 0x54, 0x01
defb 0x02
defb 0x00, 0x10, 0x20, 0x02, 0x20, 0x14, 0xAA, 0x75
defb 0x02
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x02
defb 0x19, 0x19, 0x2D, 0x6D, 0x6E, 0x76, 0xF7, 0xF7
defb 0x47
defb 0x9C, 0x9C, 0x98, 0x98, 0xB8, 0xB8, 0x38, 0x38
defb 0x45
defb 0x00, 0x7A, 0x60, 0x55, 0x00, 0x22, 0x11, 0x22
defb 0x46
defb 0x00, 0xAA, 0x56, 0xAE, 0x00, 0x24, 0x00, 0x24
defb 0x06
defb 0x1D, 0x4E, 0x06, 0x27, 0x02, 0x8A, 0x41, 0xA9
defb 0x07
defb 0x54, 0x29, 0x90, 0xE4, 0xA1, 0xA2, 0x45, 0xCA
defb 0x06
defb 0xBF, 0xFF, 0xBF, 0x7F, 0x5F, 0x2E, 0x1B, 0x06
defb 0x06
defb 0xA5, 0xC2, 0xA5, 0xC2, 0x46, 0x8C, 0x18, 0xA0
defb 0x02
defb 0x1C, 0x0C, 0x04, 0x16, 0x0A, 0x08, 0x07, 0x05
defb 0x42
defb 0x38, 0x30, 0x20, 0x68, 0x50, 0x10, 0xE0, 0xA0
defb 0x02
defb 0x7E, 0x5E, 0x52, 0x42, 0x50, 0x42, 0x10, 0x42
defb 0x46
defb 0x7E, 0x5E, 0x52, 0x42, 0x50, 0x42, 0x10, 0x42
defb 0x06
defb 0x69, 0x64, 0x28, 0x45, 0x29, 0x44, 0x2D, 0x00
defb 0x42
defb 0x69, 0x64, 0x28, 0x45, 0x29, 0x44, 0x2D, 0x00
defb 0x42
defb 0x3C, 0x54, 0x25, 0x17, 0x06, 0x1B, 0x02, 0x18
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x3C, 0x2A, 0xA4, 0xE8, 0x60, 0xD8, 0x40, 0x18
defb 0x07
defb 0x7F, 0x3C, 0x18, 0x00, 0x80, 0xC0, 0xE3, 0xFF
defb 0xCD
defb 0xFF, 0xFE, 0x3C, 0x18, 0x00, 0x01, 0x83, 0xE7
defb 0xCD
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=48):
defb 0x3C, 0x7E, 0x6A, 0x34, 0x1C, 0x20, 0x1C, 0x00
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x0F, 0x3F, 0x67, 0xB5, 0xD1, 0x40, 0x00
defb 0x01
defb 0x82, 0xC5, 0xF9, 0x9A, 0x28, 0x24, 0x04, 0x00
defb 0x01
defb 0xFF, 0x42, 0x5A, 0x3C, 0x18, 0x10, 0x28, 0x24
defb 0x01
defb 0xC0, 0x58, 0x3E, 0x01, 0xFE, 0x00, 0x14, 0x12
defb 0x01
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0xAB, 0xFF, 0x0A, 0xDD, 0x2A, 0xD5, 0x02, 0xD5
defb 0x03
defb 0xEB, 0xD4, 0xEF, 0x7D, 0x80, 0x55, 0xA0, 0x55
defb 0x42
defb 0xAB, 0xFF, 0x0A, 0xDD, 0x2A, 0xD5, 0x02, 0xD5
defb 0x03
defb 0xEB, 0xD4, 0xEF, 0x7D, 0x80, 0x55, 0xA0, 0x55
defb 0x42
defb 0xAB, 0xFF, 0x0A, 0xDD, 0x2A, 0xD5, 0x02, 0xD5
defb 0x03
defb 0xEB, 0xD4, 0xEF, 0x7D, 0x80, 0x55, 0xA0, 0x55
defb 0x42
defb 0x00, 0x7A, 0x60, 0x55, 0x00, 0x22, 0x11, 0x22
defb 0x47
defb 0x00, 0xAA, 0x56, 0xAE, 0x00, 0x24, 0x00, 0x24
defb 0x01
defb 0x10, 0x22, 0x11, 0x22, 0x01, 0x22, 0x01, 0x22
defb 0x05
defb 0x00, 0x24, 0xF8, 0x04, 0xF8, 0x24, 0x00, 0x24
defb 0x01
defb 0x10, 0x22, 0x11, 0x22, 0x01, 0x22, 0x01, 0x22
defb 0x05
defb 0x00, 0x24, 0xF8, 0x04, 0xF8, 0x24, 0x00, 0x24
defb 0x01
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x03
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x03
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x03
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x02
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x03
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x03
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x02
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x43
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x02
; blocks at pixel positionn (y=56):
defb 0x00, 0x24, 0x00, 0x24, 0x20, 0x34, 0x3C, 0x18
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x41
defb 0xAB, 0xFF, 0x0A, 0xDD, 0x2A, 0xD5, 0x02, 0xD5
defb 0x03
defb 0xEB, 0xD4, 0xEF, 0x7D, 0x80, 0x55, 0xA0, 0x55
defb 0x42
defb 0x38, 0x30, 0x20, 0x68, 0x50, 0x10, 0xE0, 0xA0
defb 0x42
defb 0x38, 0x30, 0x20, 0x68, 0x50, 0x10, 0xE0, 0xA0
defb 0x01
defb 0x1C, 0x0C, 0x04, 0x16, 0x0A, 0x08, 0x07, 0x05
defb 0x01
defb 0x1C, 0x0C, 0x04, 0x16, 0x0A, 0x08, 0x07, 0x05
defb 0x42
defb 0x7A, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x01
defb 0x7A, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x01
defb 0x10, 0x22, 0x11, 0x22, 0x01, 0x22, 0x01, 0x22
defb 0x05
defb 0x00, 0x24, 0xF8, 0x04, 0xF8, 0x24, 0x00, 0x24
defb 0x01
defb 0x10, 0x22, 0x11, 0x22, 0x01, 0x22, 0x01, 0x22
defb 0x05
defb 0x00, 0x24, 0xF8, 0x04, 0xF8, 0x24, 0x00, 0x24
defb 0x01
defb 0x10, 0x32, 0x10, 0x22, 0x30, 0x3A, 0x14, 0x08
defb 0x05
defb 0x00, 0x24, 0x00, 0x24, 0x20, 0x34, 0x3C, 0x18
defb 0x01
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x03
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x02
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x03
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x02
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x02
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x02
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x03
defb 0x00, 0x10, 0x20, 0x04, 0x02, 0xA0, 0x54, 0x01
defb 0x02
defb 0x00, 0x10, 0x20, 0x02, 0x20, 0x14, 0xAA, 0x75
defb 0x02
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x02
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x03
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x02
; blocks at pixel positionn (y=64):
defb 0x44, 0x20, 0x54, 0x22, 0x10, 0x28, 0x11, 0x28
defb 0x03
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x02
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x03
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x43
defb 0x44, 0x2D, 0x44, 0x29, 0x44, 0x48, 0x25, 0x41
defb 0x43
defb 0xA2, 0x14, 0xB2, 0x10, 0xB4, 0x22, 0x14, 0x82
defb 0x42
defb 0x44, 0x2D, 0x44, 0x29, 0x44, 0x48, 0x25, 0x41
defb 0x43
defb 0x68, 0x60, 0x20, 0x41, 0x01, 0x04, 0x0D, 0x08
defb 0x42
defb 0x00, 0xBA, 0x9D, 0xAE, 0xAC, 0x98, 0xB4, 0x00
defb 0x05
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x5D, 0xB9, 0x75, 0x35, 0x19, 0x2D, 0x00
defb 0x05
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x43
defb 0x00, 0xAA, 0x75, 0x6A, 0x98, 0x0D, 0x19, 0x0D
defb 0x03
defb 0x00, 0x00, 0x7D, 0xA9, 0x51, 0x08, 0x99, 0x08
defb 0x02
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x02
defb 0x47, 0x20, 0x5E, 0x3E, 0x14, 0x20, 0x17, 0x20
defb 0x03
defb 0x08, 0x80, 0x04, 0x40, 0x04, 0x80, 0x08, 0x01
defb 0x02
defb 0x80, 0x40, 0x17, 0x82, 0x00, 0x8F, 0x15, 0x20
defb 0x02
defb 0x01, 0x02, 0xFD, 0xAA, 0x04, 0xFE, 0x44, 0x0A
defb 0x02
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x43
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x02
defb 0x47, 0x20, 0x5E, 0x3E, 0x14, 0x20, 0x17, 0x20
defb 0x03
defb 0x01, 0x02, 0xFD, 0xAA, 0x04, 0xFE, 0x44, 0x0A
defb 0x02
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x47
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x46
; blocks at pixel positionn (y=72):
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x02
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x02
defb 0xA0, 0x40, 0x8A, 0x54, 0x20, 0x70, 0x20, 0x50
defb 0x43
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x69, 0x64, 0x28, 0x45, 0x29, 0x44, 0x2D, 0x48
defb 0x43
defb 0x14, 0xA2, 0x30, 0xA2, 0x14, 0x82, 0x34, 0xB2
defb 0x02
defb 0x68, 0x60, 0x20, 0x41, 0x01, 0x04, 0x0D, 0x08
defb 0x43
defb 0x14, 0xA2, 0x30, 0xA2, 0x14, 0x82, 0x34, 0xB2
defb 0x02
defb 0x38, 0x30, 0x20, 0x68, 0x50, 0x10, 0xE0, 0xA0
defb 0x42
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x1C, 0x0C, 0x04, 0x16, 0x0A, 0x08, 0x07, 0x05
defb 0x42
defb 0x0A, 0x11, 0x02, 0x28, 0x45, 0x0E, 0x75, 0x80
defb 0x4B
defb 0x01, 0x4E, 0x14, 0x29, 0xC0, 0xA8, 0x01, 0x10
defb 0x03
defb 0x80, 0x72, 0x28, 0x94, 0x03, 0x15, 0x80, 0x08
defb 0x43
defb 0x50, 0x88, 0x40, 0x14, 0xA2, 0x70, 0xAE, 0x01
defb 0x0A
defb 0x34, 0x20, 0x1F, 0x20, 0x18, 0x2F, 0x42, 0x78
defb 0x03
defb 0x29, 0x4D, 0x04, 0x08, 0x04, 0xC4, 0xA2, 0x10
defb 0x02
defb 0x9C, 0x0C, 0x86, 0x03, 0x80, 0x40, 0x1F, 0x05
defb 0x02
defb 0x7E, 0x01, 0xAB, 0xFF, 0x01, 0x01, 0xFD, 0x52
defb 0x02
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x02
defb 0x11, 0xE0, 0x82, 0x04, 0x1A, 0xE0, 0x54, 0x01
defb 0x02
defb 0x00, 0x43, 0x40, 0x44, 0x60, 0x44, 0xAE, 0x75
defb 0x02
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x02
defb 0x34, 0x20, 0x1F, 0x20, 0x18, 0x2F, 0x42, 0x78
defb 0x03
defb 0x7E, 0x01, 0xAB, 0xFF, 0x01, 0x01, 0xFD, 0x52
defb 0x02
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x02
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x02
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x06
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x04
; blocks at pixel positionn (y=80):
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x47
defb 0x00, 0xAA, 0x75, 0x6A, 0x98, 0x0D, 0x19, 0x0D
defb 0x47
defb 0x00, 0x00, 0x7D, 0xA9, 0x51, 0x08, 0x99, 0x08
defb 0x46
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x46
defb 0x47, 0x20, 0x5E, 0x3E, 0x14, 0x20, 0x17, 0x20
defb 0x46
defb 0x08, 0x80, 0x04, 0x40, 0x04, 0x80, 0x08, 0x01
defb 0x46
defb 0x80, 0x40, 0x17, 0x82, 0x00, 0x8F, 0x15, 0x20
defb 0x06
defb 0x01, 0x02, 0xFD, 0xAA, 0x04, 0xFE, 0x44, 0x0A
defb 0x06
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x47
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x46
defb 0x47, 0x20, 0x5E, 0x3E, 0x14, 0x20, 0x17, 0x20
defb 0x46
defb 0x01, 0x02, 0xFD, 0xAA, 0x04, 0xFE, 0x44, 0x0A
defb 0x06
defb 0x00, 0x35, 0x7E, 0x5C, 0x28, 0x40, 0x61, 0x3E
defb 0x47
defb 0x00, 0xAA, 0x75, 0x6A, 0x98, 0x0D, 0x19, 0x0D
defb 0x47
defb 0x00, 0x00, 0x7D, 0xA9, 0x51, 0x08, 0x99, 0x08
defb 0x46
defb 0x00, 0xAA, 0x75, 0x6A, 0x98, 0x0D, 0x19, 0x0D
defb 0x46
defb 0x00, 0x00, 0x7D, 0xA9, 0x51, 0x08, 0x99, 0x08
defb 0x46
defb 0x00, 0x46, 0x12, 0x38, 0x72, 0x64, 0x02, 0xA4
defb 0x46
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x47
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x47
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x46
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x46
defb 0x44, 0x20, 0x54, 0x22, 0x10, 0x28, 0x11, 0x28
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x05, 0x02, 0x51, 0x2A, 0x04, 0x0E, 0x04, 0x0A
defb 0x06
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x47
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x46
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x47
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x06
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x47
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x46
; blocks at pixel positionn (y=88):
defb 0x34, 0x20, 0x1F, 0x20, 0x18, 0x2F, 0x42, 0x78
defb 0x47
defb 0x29, 0x4D, 0x04, 0x08, 0x04, 0xC4, 0xA2, 0x10
defb 0x46
defb 0x9C, 0x0C, 0x86, 0x03, 0x80, 0x40, 0x1F, 0x05
defb 0x46
defb 0x7E, 0x01, 0xAB, 0xFF, 0x01, 0x01, 0xFD, 0x52
defb 0x06
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x06
defb 0x11, 0xE0, 0x82, 0x04, 0x1A, 0xE0, 0x54, 0x01
defb 0x06
defb 0x00, 0x43, 0x40, 0x44, 0x60, 0x44, 0xAE, 0x75
defb 0x06
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x04
defb 0x34, 0x20, 0x1F, 0x20, 0x18, 0x2F, 0x42, 0x78
defb 0x47
defb 0x7E, 0x01, 0xAB, 0xFF, 0x01, 0x01, 0xFD, 0x52
defb 0x06
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x06
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x04
defb 0x30, 0x20, 0x3F, 0x15, 0x28, 0x30, 0x23, 0x14
defb 0x06
defb 0x11, 0xE0, 0x82, 0x04, 0x1A, 0xE0, 0x54, 0x01
defb 0x06
defb 0x00, 0x43, 0x40, 0x44, 0x60, 0x44, 0xAE, 0x75
defb 0x06
defb 0x11, 0xE0, 0x82, 0x04, 0x1A, 0xE0, 0x54, 0x01
defb 0x06
defb 0x00, 0x43, 0x40, 0x44, 0x60, 0x44, 0xAE, 0x75
defb 0x06
defb 0xE2, 0x58, 0x0E, 0x04, 0x62, 0xF0, 0x42, 0x96
defb 0x04
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x06
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x46
defb 0x00, 0x10, 0x20, 0x04, 0x02, 0xA0, 0x54, 0x01
defb 0x06
defb 0x00, 0x10, 0x20, 0x02, 0x20, 0x14, 0xAA, 0x75
defb 0x06
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x04
defb 0x30, 0x08, 0x02, 0x30, 0x38, 0x24, 0x41, 0x60
defb 0x46
defb 0x02, 0x06, 0x2A, 0x96, 0x3A, 0x0C, 0x00, 0x6F
defb 0x06
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x46
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x06
defb 0x38, 0x10, 0x28, 0x14, 0x28, 0x30, 0x21, 0x14
defb 0x46
defb 0x02, 0x00, 0x2A, 0x44, 0x02, 0x00, 0x42, 0x96
defb 0x06
; blocks at pixel positionn (y=96):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x46
defb 0x00, 0x02, 0x05, 0x0B, 0x16, 0x1A, 0x24, 0x28
defb 0x47
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x47
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x46
defb 0x00, 0x00, 0x50, 0x28, 0x44, 0xA0, 0x4A, 0x00
defb 0x46
defb 0x44, 0x20, 0x54, 0x22, 0x10, 0x28, 0x11, 0x28
defb 0x46
defb 0xFF, 0x42, 0x5A, 0x3C, 0x18, 0x10, 0x28, 0x24
defb 0x07
defb 0xC0, 0x58, 0x3E, 0x01, 0xFE, 0x00, 0x14, 0x12
defb 0x06
defb 0x05, 0x02, 0x51, 0x2A, 0x04, 0x0E, 0x04, 0x0A
defb 0x06
defb 0x00, 0xAA, 0x01, 0x02, 0x14, 0xA9, 0x52, 0x24
defb 0x03
defb 0x0C, 0x56, 0x8F, 0x5B, 0xA9, 0x2E, 0x94, 0x40
defb 0x4F
defb 0x30, 0x6A, 0xF1, 0xDA, 0x95, 0x74, 0x29, 0x02
defb 0x4F
defb 0x00, 0x55, 0x80, 0x40, 0x28, 0x95, 0x4A, 0x24
defb 0x03
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0xBA, 0x9D, 0xAE, 0xAC, 0x98, 0xB4, 0x00
defb 0x0D
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x5D, 0xB9, 0x75, 0x35, 0x19, 0x2D, 0x00
defb 0x0D
defb 0x00, 0x0F, 0x3F, 0x67, 0xB5, 0xD1, 0x40, 0x00
defb 0x45
defb 0x82, 0xC5, 0xF9, 0x9A, 0x28, 0x24, 0x04, 0x00
defb 0x45
defb 0xFF, 0x42, 0x5A, 0x3C, 0x18, 0x10, 0x28, 0x24
defb 0x45
defb 0xC0, 0x58, 0x3E, 0x01, 0xFE, 0x00, 0x14, 0x12
defb 0x45
defb 0x00, 0x0F, 0x3F, 0x67, 0xB5, 0xD1, 0x40, 0x00
defb 0x47
defb 0x82, 0xC5, 0xF9, 0x9A, 0x28, 0x24, 0x04, 0x00
defb 0x47
; blocks at pixel positionn (y=104):
defb 0x00, 0x00, 0x7D, 0xAA, 0x57, 0x22, 0x40, 0x08
defb 0x47
defb 0x00, 0x46, 0x12, 0x00, 0x22, 0x44, 0x22, 0x04
defb 0x46
defb 0x00, 0x75, 0x62, 0x50, 0x20, 0x50, 0x68, 0x30
defb 0x47
defb 0x00, 0xAA, 0x75, 0x2A, 0x14, 0x89, 0x40, 0x00
defb 0x46
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x47
defb 0x00, 0x0F, 0x3F, 0x67, 0xB5, 0xD1, 0x40, 0x00
defb 0x47
defb 0x82, 0xC5, 0xF9, 0x9A, 0x28, 0x24, 0x04, 0x00
defb 0x07
defb 0x02, 0x06, 0x0B, 0x15, 0xA3, 0x01, 0x01, 0x22
defb 0x06
defb 0x10, 0x28, 0x00, 0x2A, 0x14, 0x02, 0x01, 0x00
defb 0x06
defb 0x00, 0x10, 0x20, 0x04, 0x02, 0xA0, 0x54, 0x01
defb 0x06
defb 0x00, 0x10, 0x20, 0x02, 0x20, 0x14, 0xAA, 0x75
defb 0x06
defb 0x24, 0x8A, 0x04, 0x40, 0x14, 0x28, 0xC0, 0x00
defb 0x04
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x38, 0x30, 0x20, 0x68, 0x50, 0x10, 0xE0, 0xA0
defb 0x4A
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x1C, 0x0C, 0x04, 0x16, 0x0A, 0x08, 0x07, 0x05
defb 0x4A
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x45
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x45
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x45
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x45
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=112):
defb 0xFF, 0x42, 0x5A, 0x3C, 0x18, 0x10, 0x28, 0x24
defb 0x47
defb 0xC0, 0x58, 0x3E, 0x01, 0xFE, 0x00, 0x14, 0x12
defb 0x47
defb 0x18, 0x34, 0x7C, 0xFA, 0xFC, 0x0A, 0x30, 0x1C
defb 0x46
defb 0x78, 0x05, 0x9D, 0x73, 0x0F, 0x7E, 0x01, 0xAA
defb 0x43
defb 0x00, 0x15, 0x3F, 0x67, 0x43, 0x41, 0x63, 0xBF
defb 0x47
defb 0x00, 0xD4, 0x7A, 0xFD, 0x7E, 0x7D, 0x3E, 0x85
defb 0x07
defb 0x3E, 0x41, 0x4B, 0xC7, 0xDE, 0xC0, 0x3E, 0x03
defb 0x43
defb 0x54, 0x2A, 0x12, 0x2B, 0x51, 0x04, 0x74, 0x96
defb 0x42
defb 0x19, 0x39, 0x72, 0x40, 0x1E, 0x6B, 0xAB, 0xFE
defb 0x4F
defb 0x6B, 0xDD, 0xEA, 0x35, 0x2E, 0x35, 0x2A, 0x7F
defb 0x48
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x15, 0x40, 0x80, 0x0A, 0x90, 0x00, 0x00, 0x90
defb 0x47
defb 0x54, 0x02, 0x01, 0x50, 0x09, 0x00, 0x09, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x15, 0x40, 0x80, 0x0A, 0x90, 0x00, 0x00, 0x90
defb 0x47
defb 0x00, 0x80, 0x00, 0x90, 0x00, 0x00, 0x90, 0x00
defb 0x47
defb 0x00, 0x09, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00
defb 0x47
defb 0x54, 0x02, 0x01, 0x50, 0x09, 0x00, 0x09, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA5
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x36, 0xE9
defb 0x42
defb 0x02, 0x0F, 0x36, 0xE9, 0xC6, 0x98, 0x60, 0x80
defb 0x02
defb 0x66, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x02, 0x08, 0x20, 0x10, 0x20, 0x00, 0x80
defb 0x47
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=120):
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x22, 0x75, 0x3E, 0x3D, 0x1A, 0x15, 0x0A
defb 0x05
defb 0x01, 0x08, 0x09, 0x08, 0x11, 0x10, 0x21, 0xCA
defb 0x05
defb 0x1F, 0x7F, 0x00, 0x55, 0x02, 0x55, 0x7F, 0x00
defb 0x47
defb 0x56, 0xFD, 0x1A, 0x41, 0x80, 0x01, 0x2A, 0x00
defb 0x07
defb 0x7C, 0xFF, 0xFF, 0x5D, 0x2A, 0x01, 0x2A, 0x54
defb 0x06
defb 0xE6, 0x2F, 0xC9, 0x5C, 0x1C, 0x3E, 0x56, 0xAB
defb 0x02
defb 0x00, 0x00, 0x22, 0x33, 0x22, 0x55, 0x66, 0x77
defb 0x4E
defb 0xFF, 0x55, 0x2A, 0x37, 0x2A, 0x35, 0x2E, 0x55
defb 0x48
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x80, 0x00, 0x90, 0x00, 0x00, 0x90, 0x00
defb 0x47
defb 0x00, 0x09, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x80, 0x00, 0x90, 0x00, 0x00, 0x90, 0x00
defb 0x47
defb 0x15, 0x40, 0x80, 0x0A, 0x90, 0x00, 0x00, 0x90
defb 0x47
defb 0x54, 0x02, 0x01, 0x50, 0x09, 0x00, 0x09, 0x00
defb 0x47
defb 0x00, 0x09, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00
defb 0x47
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x36, 0xE9
defb 0x42
defb 0x02, 0x0F, 0x36, 0xE9, 0xC6, 0x98, 0x60, 0x80
defb 0x02
defb 0x66, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x02, 0x08, 0x04, 0x08, 0x10, 0x08, 0xA0
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=128):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x07, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF
defb 0x6E
defb 0xE0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE
defb 0x6E
defb 0x00, 0x00, 0x00, 0x16, 0x6F, 0xDF, 0xFF, 0xDF
defb 0x69
defb 0x00, 0x00, 0x0F, 0xF7, 0xDE, 0x7D, 0xFE, 0xFD
defb 0x69
defb 0x00, 0x15, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
defb 0x69
defb 0xFC, 0xF6, 0xBF, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF
defb 0x69
defb 0x0A, 0x11, 0x02, 0x28, 0x45, 0x0E, 0x75, 0x80
defb 0x6F
defb 0x01, 0x4E, 0x14, 0x29, 0xC0, 0xA8, 0x01, 0x10
defb 0x6F
defb 0x80, 0x72, 0x28, 0x94, 0x03, 0x15, 0x80, 0x08
defb 0x6F
defb 0x50, 0x88, 0x40, 0x14, 0xA2, 0x70, 0xAE, 0x01
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x15, 0x40, 0x80, 0x0A, 0x90, 0x00, 0x00, 0x90
defb 0x4F
defb 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x54, 0x02, 0x01, 0x50, 0x09, 0x00, 0x09, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x4F
defb 0x00, 0x0F, 0x3F, 0x67, 0xB5, 0xD1, 0x40, 0x00
defb 0x4F
defb 0x82, 0xC5, 0xF9, 0x9A, 0x28, 0x24, 0x04, 0x00
defb 0x4F
defb 0xFF, 0x42, 0x5A, 0x3C, 0x18, 0x10, 0x28, 0x24
defb 0x4F
defb 0xC0, 0x58, 0x3E, 0x01, 0xFE, 0x00, 0x14, 0x12
defb 0x4F
defb 0x0A, 0x11, 0x02, 0x28, 0x45, 0x0E, 0x75, 0x80
defb 0x4B
defb 0x01, 0x4E, 0x14, 0x29, 0xC0, 0xA8, 0x01, 0x10
defb 0x03
defb 0x80, 0x72, 0x28, 0x94, 0x03, 0x15, 0x80, 0x08
defb 0x43
defb 0x50, 0x88, 0x40, 0x14, 0xA2, 0x70, 0xAE, 0x01
defb 0x0A
defb 0x00, 0x12, 0x12, 0x12, 0x32, 0x33, 0x33, 0x33
defb 0x47
defb 0x00, 0x24, 0x24, 0x24, 0x0C, 0x0C, 0x4C, 0x5C
defb 0x45
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
; blocks at pixel positionn (y=136):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x06
defb 0x6E
defb 0xFF, 0xFE, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xA0
defb 0x6E
defb 0x30, 0x24, 0x12, 0x20, 0x10, 0x24, 0x40, 0x60
defb 0x4D
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4D
defb 0x04, 0x01, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00
defb 0x4D
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x4D
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x80, 0x00, 0x90, 0x00, 0x00, 0x90, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x09, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x88, 0xDD, 0x88, 0x00, 0x00, 0x00
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x77, 0x77, 0x67, 0x67, 0xE7, 0xE7, 0xE7, 0xE7
defb 0x47
defb 0x5C, 0x48, 0x68, 0x6A, 0x62, 0x36, 0x36, 0x36
defb 0x45
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x4F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
; blocks at pixel positionn (y=144):
defb 0x00, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00
defb 0x47
defb 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00
defb 0x47
defb 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x0E, 0x3C, 0x11, 0x03, 0x07, 0x4B, 0xE5
defb 0x6F
defb 0x1C, 0x3A, 0x7D, 0xBE, 0xDD, 0xFF, 0xEF, 0xD7
defb 0x6F
defb 0x00, 0x00, 0x70, 0xE8, 0xF5, 0xFF, 0xF7, 0x5D
defb 0x6F
defb 0x00, 0x00, 0x00, 0x06, 0xCF, 0xE0, 0xA0, 0x54
defb 0x6F
defb 0x00, 0x40, 0x10, 0x04, 0x08, 0x04, 0x00, 0x01
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x54, 0x02, 0x01, 0x50, 0x09, 0x00, 0x09, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x47
defb 0x15, 0x40, 0x80, 0x0A, 0x90, 0x00, 0x00, 0x90
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x24, 0x00, 0x24, 0x20, 0x34, 0x3C, 0x18
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x02, 0x08, 0x20, 0x10, 0x20, 0x00, 0x80
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x4F
; blocks at pixel positionn (y=152):
defb 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x6F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x40, 0x10, 0x20, 0x10, 0x08, 0x10, 0x05
defb 0x47
defb 0x00, 0x09, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x47
defb 0x00, 0x80, 0x00, 0x90, 0x00, 0x00, 0x90, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x47
defb 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x36, 0xE9
defb 0x42
defb 0x02, 0x0F, 0x36, 0xE9, 0xC6, 0x98, 0x60, 0x80
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x3C, 0x7E, 0x56, 0x2C, 0x38, 0x04, 0x38, 0x00
defb 0x07
defb 0x00, 0x02, 0x08, 0x04, 0x08, 0x10, 0x08, 0xA0
defb 0x47
defb 0x3C, 0x7E, 0x56, 0x2C, 0x38, 0x04, 0x38, 0x00
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x3C, 0x7E, 0x56, 0x2C, 0x38, 0x04, 0x38, 0x00
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x4F
defb 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80
defb 0x4F
; blocks at pixel positionn (y=160):
defb 0x07, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF
defb 0x46
defb 0xE0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE
defb 0x06
defb 0x3C, 0x7E, 0x56, 0x2C, 0x38, 0x04, 0x38, 0x00
defb 0x07
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x04, 0x04, 0x44, 0x44, 0x2C, 0x2C, 0x34, 0x14
defb 0x42
defb 0x04, 0x04, 0x84, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C
defb 0x42
defb 0x00, 0x12, 0x12, 0x12, 0x32, 0x33, 0x33, 0x33
defb 0x42
defb 0x00, 0x24, 0x24, 0x24, 0x0C, 0x0C, 0x4C, 0x5C
defb 0x42
defb 0x04, 0x04, 0x44, 0x44, 0x2C, 0x2C, 0x34, 0x14
defb 0x4F
defb 0x04, 0x04, 0x84, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C
defb 0x4D
defb 0x00, 0x12, 0x12, 0x12, 0x32, 0x33, 0x33, 0x33
defb 0x4F
defb 0x00, 0x24, 0x24, 0x24, 0x0C, 0x0C, 0x4C, 0x5C
defb 0x4D
defb 0x00, 0x02, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x88, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=168):
defb 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x06
defb 0x06
defb 0xFF, 0xFE, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xA0
defb 0x04
defb 0x00, 0x24, 0x00, 0x24, 0x20, 0x34, 0x3C, 0x18
defb 0x02
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x19, 0x19, 0x2D, 0x6D, 0x6E, 0x76, 0xF7, 0xF7
defb 0x47
defb 0x9C, 0x9C, 0x98, 0x98, 0xB8, 0xB8, 0x38, 0x38
defb 0x45
defb 0x77, 0x77, 0x67, 0x67, 0xE7, 0xE7, 0xE7, 0xE7
defb 0x47
defb 0x5C, 0x48, 0x68, 0x6A, 0x62, 0x36, 0x36, 0x36
defb 0x45
defb 0x19, 0x19, 0x2D, 0x6D, 0x6E, 0x76, 0xF7, 0xF7
defb 0x4F
defb 0x9C, 0x9C, 0x98, 0x98, 0xB8, 0xB8, 0x38, 0x38
defb 0x4D
defb 0x77, 0x77, 0x67, 0x67, 0xE7, 0xE7, 0xE7, 0xE7
defb 0x4F
defb 0x5C, 0x48, 0x68, 0x6A, 0x62, 0x36, 0x36, 0x36
defb 0x4D
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
defb 0x47
defb 0x40, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x44, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=176):
defb 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x0F, 0x00, 0x07
defb 0x47
defb 0x00, 0x50, 0x00, 0xA8, 0x00, 0x60, 0x00, 0x50
defb 0x05
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=184):
defb 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x0F, 0x00, 0x07
defb 0x47
defb 0x00, 0x50, 0x00, 0xA8, 0x00, 0x50, 0x00, 0x60
defb 0x05
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=192):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=200):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x5F
; blocks at pixel positionn (y=208):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x1C, 0x22, 0x14, 0x10, 0x14, 0x10, 0x14
defb 0x47
defb 0x00, 0x00, 0x6C, 0xBE, 0xFA, 0x74, 0x28, 0x10
defb 0x42
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
; blocks at pixel positionn (y=216):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x7E, 0x42, 0x43, 0x42, 0x42, 0x7E, 0x00
defb 0x44
defb 0x00, 0x00, 0x00, 0xFE, 0xAA, 0x1C, 0x14, 0x00
defb 0x04
defb 0x00, 0x7E, 0x42, 0x67, 0x24, 0x18, 0x18, 0x00
defb 0x45
defb 0x00, 0x00, 0x00, 0xFE, 0xAA, 0x1C, 0x14, 0x00
defb 0x05
defb 0x00, 0x3C, 0x66, 0x43, 0x42, 0x66, 0x3C, 0x00
defb 0x46
defb 0x00, 0x00, 0x00, 0xFE, 0xAA, 0x1C, 0x14, 0x00
defb 0x06
defb 0x00, 0x03, 0x2B, 0x75, 0xF9, 0xBD, 0x5F, 0x35
defb 0x46
defb 0x00, 0xA0, 0xD4, 0xE6, 0xF7, 0xFD, 0xAA, 0x54
defb 0x06
defb 0x00, 0x38, 0x76, 0xBF, 0xFA, 0xFF, 0x56, 0x28
defb 0x42
defb 0x00, 0x00, 0x00, 0x06, 0xFC, 0x06, 0x00, 0x00
defb 0x07
defb 0x14, 0x2A, 0x2A, 0x5D, 0x58, 0x55, 0x22, 0x14
defb 0x45
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x0F, 0x3E, 0x7C, 0xFE, 0x7D, 0xAA, 0x54
defb 0x46
defb 0x00, 0x80, 0x00, 0xD0, 0x6C, 0x34, 0x50, 0x60
defb 0x06
; blocks at pixel positionn (y=224):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x1C, 0x6E, 0xF6, 0xF0, 0xF4, 0x6C, 0x18, 0x00
defb 0x47
defb 0x00, 0x0C, 0x36, 0x7A, 0x78, 0x36, 0x04, 0x00
defb 0x47
defb 0x00, 0x0C, 0x36, 0x7A, 0x78, 0x36, 0x04, 0x00
defb 0x46
defb 0x00, 0x0C, 0x14, 0x38, 0x14, 0x0E, 0x04, 0x00
defb 0x46
defb 0x00, 0x0C, 0x14, 0x38, 0x14, 0x0E, 0x04, 0x00
defb 0x42
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x42
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
; blocks at pixel positionn (y=232):
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x47
defb 0x00, 0x0C, 0x36, 0x7A, 0x78, 0x36, 0x04, 0x00
defb 0x47
defb 0x1C, 0x6E, 0xF6, 0xF0, 0xF4, 0x6C, 0x18, 0x00
defb 0x47
defb 0x00, 0x0C, 0x14, 0x38, 0x14, 0x0E, 0x04, 0x00
defb 0x46
defb 0x00, 0x0C, 0x36, 0x7A, 0x78, 0x36, 0x04, 0x00
defb 0x46
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x42
defb 0x00, 0x0C, 0x14, 0x38, 0x14, 0x0E, 0x04, 0x00
defb 0x42
defb 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
defb 0x41
defb 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00
defb 0x41
; blocks at pixel positionn (y=240):
defb 0x31, 0x68, 0x40, 0x01, 0x03, 0x03, 0x01, 0x00
defb 0x46
defb 0x01, 0x88, 0xC0, 0xC0, 0x80, 0x10, 0x18, 0x30
defb 0x46
defb 0x21, 0x83, 0x03, 0x01, 0x00, 0x00, 0x08, 0x0C
defb 0x42
defb 0x80, 0xC0, 0x10, 0x31, 0x98, 0x18, 0x10, 0x00
defb 0x42
defb 0x01, 0x02, 0x00, 0x9C, 0x3E, 0x1C, 0x04, 0x01
defb 0x46
defb 0xC0, 0x64, 0xA6, 0x0C, 0x08, 0x90, 0xC1, 0x80
defb 0x46
defb 0x05, 0x30, 0x60, 0x30, 0x09, 0x03, 0x83, 0x01
defb 0x42
defb 0x26, 0x13, 0x41, 0x80, 0xC0, 0xE0, 0xC0, 0xD0
defb 0x42
defb 0xAA, 0x0F, 0x3F, 0xFE, 0x3F, 0x00, 0x01, 0x0A
defb 0x4D
defb 0xAA, 0xF8, 0xC0, 0x00, 0x80, 0xE8, 0x80, 0x00
defb 0x0D
defb 0x55, 0x0F, 0x03, 0x0F, 0x3F, 0x07, 0x00, 0x00
defb 0x4D
defb 0x55, 0xE0, 0xFA, 0xE0, 0x00, 0xE0, 0x14, 0xA0
defb 0x0D
defb 0xAA, 0x1F, 0x07, 0x01, 0x50, 0x03, 0x0F, 0x01
defb 0x4D
defb 0xAA, 0xF0, 0xC0, 0xF0, 0xFA, 0xE0, 0x00, 0xD4
defb 0x0D
defb 0x55, 0x1F, 0x7E, 0x1F, 0x03, 0x07, 0x2E, 0x03
defb 0x4D
defb 0x55, 0xF0, 0x00, 0x80, 0xEA, 0x80, 0x00, 0x50
defb 0x0D
defb 0x31, 0x68, 0x40, 0x01, 0x03, 0x03, 0x01, 0x00
defb 0x4E
defb 0x01, 0x88, 0xC0, 0xC0, 0x80, 0x10, 0x18, 0x30
defb 0x4E
defb 0x21, 0x83, 0x03, 0x01, 0x00, 0x00, 0x08, 0x0C
defb 0x4A
defb 0x80, 0xC0, 0x10, 0x31, 0x98, 0x18, 0x10, 0x00
defb 0x4A
defb 0x01, 0x02, 0x00, 0x9C, 0x3E, 0x1C, 0x04, 0x01
defb 0x4E
defb 0xC0, 0x64, 0xA6, 0x0C, 0x08, 0x90, 0xC1, 0x80
defb 0x4E
defb 0x05, 0x30, 0x60, 0x30, 0x09, 0x03, 0x83, 0x01
defb 0x4A
defb 0x26, 0x13, 0x41, 0x80, 0xC0, 0xE0, 0xC0, 0xD0
defb 0x4A
defb 0x31, 0x68, 0x40, 0x01, 0x03, 0x03, 0x01, 0x00
defb 0x46
defb 0x01, 0x88, 0xC0, 0xC0, 0x80, 0x10, 0x18, 0x30
defb 0x46
defb 0x21, 0x83, 0x03, 0x01, 0x00, 0x00, 0x08, 0x0C
defb 0x42
defb 0x80, 0xC0, 0x10, 0x31, 0x98, 0x18, 0x10, 0x00
defb 0x42
defb 0x01, 0x02, 0x00, 0x9C, 0x3E, 0x1C, 0x04, 0x01
defb 0x46
defb 0xC0, 0x64, 0xA6, 0x0C, 0x08, 0x90, 0xC1, 0x80
defb 0x46
defb 0x05, 0x30, 0x60, 0x30, 0x09, 0x03, 0x83, 0x01
defb 0x42
defb 0x26, 0x13, 0x41, 0x80, 0xC0, 0xE0, 0xC0, 0xD0
defb 0x42
; blocks at pixel positionn (y=248):
defb 0xAA, 0x0F, 0x3F, 0xFE, 0x3F, 0x00, 0x01, 0x0A
defb 0x56
defb 0xAA, 0xF8, 0xC0, 0x00, 0x80, 0xE8, 0x80, 0x00
defb 0x16
defb 0x55, 0x0F, 0x03, 0x0F, 0x3F, 0x07, 0x00, 0x00
defb 0x56
defb 0x55, 0xE0, 0xFA, 0xE0, 0x00, 0xE0, 0x14, 0xA0
defb 0x16
defb 0xAA, 0x1F, 0x07, 0x01, 0x50, 0x03, 0x0F, 0x01
defb 0x56
defb 0xAA, 0xF0, 0xC0, 0xF0, 0xFA, 0xE0, 0x00, 0xD4
defb 0x16
defb 0x55, 0x1F, 0x7E, 0x1F, 0x03, 0x07, 0x2E, 0x03
defb 0x56
defb 0x55, 0xF0, 0x00, 0x80, 0xEA, 0x80, 0x00, 0x50
defb 0x16
defb 0xAA, 0xF8, 0xC0, 0x00, 0x80, 0xE8, 0x80, 0x00
defb 0x69
defb 0x55, 0x0F, 0x03, 0x0F, 0x3F, 0x07, 0x00, 0x00
defb 0x29
defb 0x55, 0xE0, 0xFA, 0xE0, 0x00, 0xE0, 0x14, 0xA0
defb 0x69
defb 0xAA, 0x1F, 0x07, 0x01, 0x50, 0x03, 0x0F, 0x01
defb 0x29
defb 0xAA, 0xF0, 0xC0, 0xF0, 0xFA, 0xE0, 0x00, 0xD4
defb 0x69
defb 0x55, 0x1F, 0x7E, 0x1F, 0x03, 0x07, 0x2E, 0x03
defb 0x29
defb 0x55, 0xF0, 0x00, 0x80, 0xEA, 0x80, 0x00, 0x50
defb 0x69
defb 0xAA, 0x0F, 0x3F, 0xFE, 0x3F, 0x00, 0x01, 0x0A
defb 0x29
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x0F
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x0D
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x0F
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x0D
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x0F
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x0D
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x0F
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x0D
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x07
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x05
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x07
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x05
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x07
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x05
defb 0x81, 0x45, 0x59, 0x23, 0x23, 0x1A, 0x05, 0x00
defb 0x07
defb 0x02, 0x44, 0x34, 0x88, 0x88, 0xB0, 0x40, 0x00
defb 0x05
|
; A046980: Numerators of Taylor series for exp(x)*cos(x).
; 1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1
lpb $0,1
sub $0,8
lpe
mov $1,1
mov $2,$0
mul $2,$0
lpb $2,1
sub $1,1
div $2,6
add $2,1
lpe
|
;**************************************************
;** Part 5. SCREEN AND PRINTER HANDLING ROUTINES **
;**************************************************
XDEF L09F4
XDEF L0BDB
XDEF L0C0A
XDEF L0D4D
XDEF L0D6B
XDEF L0D6E
XDEF L0DAF
XDEF L0DD9
XDEF L0E44
XDEF L0EAC
XDEF L0ECD
XDEF L0EDF
XDEF L0F2C
XDEF L0F81
XDEF L1097
XDEF L10A8
XDEF L111D
XDEF L11A7
XREF L0095
XREF L03B5
XREF L15D4
XREF L1601
XREF L1615
XREF L1652
XREF L1655
XREF L1695
XREF L1795
XREF L1855
XREF L187D
XREF L18E1
XREF L190F
XREF L191C
XREF L196E
XREF L19E5
XREF L19E8
XREF L1E9F
XREF L1F05
XREF L1F54
XREF L2211
; --------------------------
; THE 'PRINT OUTPUT' ROUTINE
; --------------------------
; This is the routine most often used by the RST 10 restart although the
; subroutine is on two occasions called directly when it is known that
; output will definitely be to the lower screen.
;; PRINT-OUT
L09F4: CALL L0B03 ; routine PO-FETCH fetches print position
; to HL register pair.
CP $20 ; is character a space or higher ?
JP NC,L0AD9 ; jump forward to PO-ABLE if so.
CP $06 ; is character in range 00-05 ?
JR C,L0A69 ; to PO-QUEST to print '?' if so.
CP $18 ; is character in range 24d - 31d ?
JR NC,L0A69 ; to PO-QUEST to also print '?' if so.
LD HL,L0A11 - 6 ; address 0A0B - the base address of control
; character table - where zero would be.
LD E,A ; control character 06 - 23d
LD D,$00 ; is transferred to DE.
ADD HL,DE ; index into table.
LD E,(HL) ; fetch the offset to routine.
ADD HL,DE ; add to make HL the address.
PUSH HL ; push the address.
JP L0B03 ; Jump forward to PO-FETCH,
; as the screen/printer position has been
; disturbed, and then indirectly to the PO-STORE
; routine on stack.
; -----------------------------
; THE 'CONTROL CHARACTER' TABLE
; -----------------------------
; For control characters in the range 6 - 23d the following table
; is indexed to provide an offset to the handling routine that
; follows the table.
;; ctlchrtab
L0A11: DEFB L0A5F - ASMPC ; 06d offset $4E to Address: PO-COMMA
DEFB L0A69 - ASMPC ; 07d offset $57 to Address: PO-QUEST
DEFB L0A23 - ASMPC ; 08d offset $10 to Address: PO-BACK-1
DEFB L0A3D - ASMPC ; 09d offset $29 to Address: PO-RIGHT
DEFB L0A69 - ASMPC ; 10d offset $54 to Address: PO-QUEST
DEFB L0A69 - ASMPC ; 11d offset $53 to Address: PO-QUEST
DEFB L0A69 - ASMPC ; 12d offset $52 to Address: PO-QUEST
DEFB L0A4F - ASMPC ; 13d offset $37 to Address: PO-ENTER
DEFB L0A69 - ASMPC ; 14d offset $50 to Address: PO-QUEST
DEFB L0A69 - ASMPC ; 15d offset $4F to Address: PO-QUEST
DEFB L0A7A - ASMPC ; 16d offset $5F to Address: PO-1-OPER
DEFB L0A7A - ASMPC ; 17d offset $5E to Address: PO-1-OPER
DEFB L0A7A - ASMPC ; 18d offset $5D to Address: PO-1-OPER
DEFB L0A7A - ASMPC ; 19d offset $5C to Address: PO-1-OPER
DEFB L0A7A - ASMPC ; 20d offset $5B to Address: PO-1-OPER
DEFB L0A7A - ASMPC ; 21d offset $5A to Address: PO-1-OPER
DEFB L0A75 - ASMPC ; 22d offset $54 to Address: PO-2-OPER
DEFB L0A75 - ASMPC ; 23d offset $53 to Address: PO-2-OPER
; -------------------------
; THE 'CURSOR LEFT' ROUTINE
; -------------------------
; Backspace and up a line if that action is from the left of screen.
; For ZX printer backspace up to first column but not beyond.
;; PO-BACK-1
L0A23: INC C ; move left one column.
LD A,$22 ; value $21 is leftmost column.
CP C ; have we passed ?
JR NZ,L0A3A ; to PO-BACK-3 if not and store new position.
BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
JR NZ,L0A38 ; to PO-BACK-2 if so, as we are unable to
; backspace from the leftmost position.
INC B ; move up one screen line
LD C,$02 ; the rightmost column position.
LD A,$18 ; Note. This should be $19
; credit. Dr. Frank O'Hara, 1982
CP B ; has position moved past top of screen ?
JR NZ,L0A3A ; to PO-BACK-3 if not and store new position.
DEC B ; else back to $18.
;; PO-BACK-2
L0A38: LD C,$21 ; the leftmost column position.
;; PO-BACK-3
L0A3A: JP L0DD9 ; to CL-SET and PO-STORE to save new
; position in system variables.
; --------------------------
; THE 'CURSOR RIGHT' ROUTINE
; --------------------------
; This moves the print position to the right leaving a trail in the
; current background colour.
; "However the programmer has failed to store the new print position
; so CHR$ 9 will only work if the next print position is at a newly
; defined place.
; e.g. PRINT PAPER 2; CHR$ 9; AT 4,0;
; does work but is not very helpful"
; - Dr. Ian Logan, Understanding Your Spectrum, 1982.
;; PO-RIGHT
L0A3D: LD A,($5C91) ; fetch P_FLAG value
PUSH AF ; and save it on stack.
LD (IY+$57),$01 ; temporarily set P_FLAG 'OVER 1'.
LD A,$20 ; prepare a space.
CALL L0B65 ; routine PO-CHAR to print it.
; Note. could be PO-ABLE which would update
; the column position.
POP AF ; restore the permanent flag.
LD ($5C91),A ; and restore system variable P_FLAG
RET ; return without updating column position
; -----------------------
; Perform carriage return
; -----------------------
; A carriage return is 'printed' to screen or printer buffer.
;; PO-ENTER
L0A4F: BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
JP NZ,L0ECD ; to COPY-BUFF if so, to flush buffer and reset
; the print position.
LD C,$21 ; the leftmost column position.
CALL L0C55 ; routine PO-SCR handles any scrolling required.
DEC B ; to next screen line.
JP L0DD9 ; jump forward to CL-SET to store new position.
; -----------
; Print comma
; -----------
; The comma control character. The 32 column screen has two 16 character
; tabstops. The routine is only reached via the control character table.
;; PO-COMMA
L0A5F: CALL L0B03 ; routine PO-FETCH - seems unnecessary.
LD A,C ; the column position. $21-$01
DEC A ; move right. $20-$00
DEC A ; and again $1F-$00 or $FF if trailing
AND $10 ; will be $00 or $10.
JR L0AC3 ; forward to PO-FILL
; -------------------
; Print question mark
; -------------------
; This routine prints a question mark which is commonly
; used to print an unassigned control character in range 0-31d.
; there are a surprising number yet to be assigned.
;; PO-QUEST
L0A69: LD A,$3F ; prepare the character '?'.
JR L0AD9 ; forward to PO-ABLE.
; --------------------------------
; Control characters with operands
; --------------------------------
; Certain control characters are followed by 1 or 2 operands.
; The entry points from control character table are PO-2-OPER and PO-1-OPER.
; The routines alter the output address of the current channel so that
; subsequent RST $10 instructions take the appropriate action
; before finally resetting the output address back to PRINT-OUT.
;; PO-TV-2
L0A6D: LD DE,L0A87 ; address: PO-CONT will be next output routine
LD ($5C0F),A ; store first operand in TVDATA-hi
JR L0A80 ; forward to PO-CHANGE >>
; ---
; -> This initial entry point deals with two operands - AT or TAB.
;; PO-2-OPER
L0A75: LD DE,L0A6D ; address: PO-TV-2 will be next output routine
JR L0A7D ; forward to PO-TV-1
; ---
; -> This initial entry point deals with one operand INK to OVER.
;; PO-1-OPER
L0A7A: LD DE,L0A87 ; address: PO-CONT will be next output routine
;; PO-TV-1
L0A7D: LD ($5C0E),A ; store control code in TVDATA-lo
;; PO-CHANGE
L0A80: LD HL,($5C51) ; use CURCHL to find current output channel.
LD (HL),E ; make it
INC HL ; the supplied
LD (HL),D ; address from DE.
RET ; return.
; ---
;; PO-CONT
L0A87: LD DE,L09F4 ; Address: PRINT-OUT
CALL L0A80 ; routine PO-CHANGE to restore normal channel.
LD HL,($5C0E) ; TVDATA gives control code and possible
; subsequent character
LD D,A ; save current character
LD A,L ; the stored control code
CP $16 ; was it INK to OVER (1 operand) ?
JP C,L2211 ; to CO-TEMP-5
JR NZ,L0AC2 ; to PO-TAB if not 22d i.e. 23d TAB.
; else must have been 22d AT.
LD B,H ; line to H (0-23d)
LD C,D ; column to C (0-31d)
LD A,$1F ; the value 31d
SUB C ; reverse the column number.
JR C,L0AAC ; to PO-AT-ERR if C was greater than 31d.
ADD A,$02 ; transform to system range $02-$21
LD C,A ; and place in column register.
BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
JR NZ,L0ABF ; to PO-AT-SET as line can be ignored.
LD A,$16 ; 22 decimal
SUB B ; subtract line number to reverse
; 0 - 22 becomes 22 - 0.
;; PO-AT-ERR
L0AAC: JP C,L1E9F ; to REPORT-B if higher than 22 decimal
; Integer out of range.
INC A ; adjust for system range $01-$17
LD B,A ; place in line register
INC B ; adjust to system range $02-$18
BIT 0,(IY+$02) ; TV_FLAG - Lower screen in use ?
JP NZ,L0C55 ; exit to PO-SCR to test for scrolling
CP (IY+$31) ; Compare against DF_SZ
JP C,L0C86 ; to REPORT-5 if too low
; Out of screen.
;; PO-AT-SET
L0ABF: JP L0DD9 ; print position is valid so exit via CL-SET
; ---
; Continue here when dealing with TAB.
; Note. In BASIC, TAB is followed by a 16-bit number and was initially
; designed to work with any output device.
;; PO-TAB
L0AC2: LD A,H ; transfer parameter to A
; Losing current character -
; High byte of TAB parameter.
;; PO-FILL
L0AC3: CALL L0B03 ; routine PO-FETCH, HL-addr, BC=line/column.
; column 1 (right), $21 (left)
ADD A,C ; add operand to current column
DEC A ; range 0 - 31+
AND $1F ; make range 0 - 31d
RET Z ; return if result zero
LD D,A ; Counter to D
SET 0,(IY+$01) ; update FLAGS - signal suppress leading space.
;; PO-SPACE
L0AD0: LD A,$20 ; space character.
CALL L0C3B ; routine PO-SAVE prints the character
; using alternate set (normal output routine)
DEC D ; decrement counter.
JR NZ,L0AD0 ; to PO-SPACE until done
RET ; return
; ----------------------
; Printable character(s)
; ----------------------
; This routine prints printable characters and continues into
; the position store routine
;; PO-ABLE
L0AD9: CALL L0B24 ; routine PO-ANY
; and continue into position store routine.
; ----------------------------
; THE 'POSITION STORE' ROUTINE
; ----------------------------
; This routine updates the system variables associated with the main screen,
; the lower screen/input buffer or the ZX printer.
;; PO-STORE
L0ADC: BIT 1,(IY+$01) ; Test FLAGS - is printer in use ?
JR NZ,L0AFC ; Forward, if so, to PO-ST-PR
BIT 0,(IY+$02) ; Test TV_FLAG - is lower screen in use ?
JR NZ,L0AF0 ; Forward, if so, to PO-ST-E
; This section deals with the upper screen.
LD ($5C88),BC ; Update S_POSN - line/column upper screen
LD ($5C84),HL ; Update DF_CC - upper display file address
RET ; Return.
; ---
; This section deals with the lower screen.
;; PO-ST-E
L0AF0: LD ($5C8A),BC ; Update SPOSNL line/column lower screen
LD ($5C82),BC ; Update ECHO_E line/column input buffer
LD ($5C86),HL ; Update DFCCL lower screen memory address
RET ; Return.
; ---
; This section deals with the ZX Printer.
;; PO-ST-PR
L0AFC: LD (IY+$45),C ; Update P_POSN column position printer
LD ($5C80),HL ; Update PR_CC - full printer buffer memory
; address
RET ; Return.
; Note. that any values stored in location 23681 will be overwritten with
; the value 91 decimal.
; Credit April 1983, Dilwyn Jones. "Delving Deeper into your ZX Spectrum".
; ----------------------------
; THE 'POSITION FETCH' ROUTINE
; ----------------------------
; This routine fetches the line/column and display file address of the upper
; and lower screen or, if the printer is in use, the column position and
; absolute memory address.
; Note. that PR-CC-hi (23681) is used by this routine and if, in accordance
; with the manual (that says this is unused), the location has been used for
; other purposes, then subsequent output to the printer buffer could corrupt
; a 256-byte section of memory.
;; PO-FETCH
L0B03: BIT 1,(IY+$01) ; Test FLAGS - is printer in use ?
JR NZ,L0B1D ; Forward, if so, to PO-F-PR
; assume upper screen in use and thus optimize for path that requires speed.
LD BC,($5C88) ; Fetch line/column from S_POSN
LD HL,($5C84) ; Fetch DF_CC display file address
BIT 0,(IY+$02) ; Test TV_FLAG - lower screen in use ?
RET Z ; Return if upper screen in use.
; Overwrite registers with values for lower screen.
LD BC,($5C8A) ; Fetch line/column from SPOSNL
LD HL,($5C86) ; Fetch display file address from DFCCL
RET ; Return.
; ---
; This section deals with the ZX Printer.
;; PO-F-PR
L0B1D: LD C,(IY+$45) ; Fetch column from P_POSN.
LD HL,($5C80) ; Fetch printer buffer address from PR_CC.
RET ; Return.
; ---------------------------------
; THE 'PRINT ANY CHARACTER' ROUTINE
; ---------------------------------
; This routine is used to print any character in range 32d - 255d
; It is only called from PO-ABLE which continues into PO-STORE
;; PO-ANY
L0B24: CP $80 ; ASCII ?
JR C,L0B65 ; to PO-CHAR is so.
CP $90 ; test if a block graphic character.
JR NC,L0B52 ; to PO-T&UDG to print tokens and UDGs
; The 16 2*2 mosaic characters 128-143 decimal are formed from
; bits 0-3 of the character.
LD B,A ; save character
CALL L0B38 ; routine PO-GR-1 to construct top half
; then bottom half.
CALL L0B03 ; routine PO-FETCH fetches print position.
LD DE,$5C92 ; MEM-0 is location of 8 bytes of character
JR L0B7F ; to PR-ALL to print to screen or printer
; ---
;; PO-GR-1
L0B38: LD HL,$5C92 ; address MEM-0 - a temporary buffer in
; systems variables which is normally used
; by the calculator.
CALL L0B3E ; routine PO-GR-2 to construct top half
; and continue into routine to construct
; bottom half.
;; PO-GR-2
L0B3E: RR B ; rotate bit 0/2 to carry
SBC A,A ; result $00 or $FF
AND $0F ; mask off right hand side
LD C,A ; store part in C
RR B ; rotate bit 1/3 of original chr to carry
SBC A,A ; result $00 or $FF
AND $F0 ; mask off left hand side
OR C ; combine with stored pattern
LD C,$04 ; four bytes for top/bottom half
;; PO-GR-3
L0B4C: LD (HL),A ; store bit patterns in temporary buffer
INC HL ; next address
DEC C ; jump back to
JR NZ,L0B4C ; to PO-GR-3 until byte is stored 4 times
RET ; return
; ---
; Tokens and User defined graphics are now separated.
;; PO-T&UDG
L0B52: SUB $A5 ; the 'RND' character
JR NC,L0B5F ; to PO-T to print tokens
ADD A,$15 ; add 21d to restore to 0 - 20
PUSH BC ; save current print position
LD BC,($5C7B) ; fetch UDG to address bit patterns
JR L0B6A ; to PO-CHAR-2 - common code to lay down
; a bit patterned character
; ---
;; PO-T
L0B5F: CALL L0C10 ; routine PO-TOKENS prints tokens
JP L0B03 ; exit via a JUMP to PO-FETCH as this routine
; must continue into PO-STORE.
; A JR instruction could be used.
; This point is used to print ASCII characters 32d - 127d.
;; PO-CHAR
L0B65: PUSH BC ; save print position
LD BC,($5C36) ; address CHARS
; This common code is used to transfer the character bytes to memory.
;; PO-CHAR-2
L0B6A: EX DE,HL ; transfer destination address to DE
LD HL,$5C3B ; point to FLAGS
RES 0,(HL) ; allow for leading space
CP $20 ; is it a space ?
JR NZ,L0B76 ; to PO-CHAR-3 if not
SET 0,(HL) ; signal no leading space to FLAGS
;; PO-CHAR-3
L0B76: LD H,$00 ; set high byte to 0
LD L,A ; character to A
; 0-21 UDG or 32-127 ASCII.
ADD HL,HL ; multiply
ADD HL,HL ; by
ADD HL,HL ; eight
ADD HL,BC ; HL now points to first byte of character
POP BC ; the source address CHARS or UDG
EX DE,HL ; character address to DE
; ----------------------------------
; THE 'PRINT ALL CHARACTERS' ROUTINE
; ----------------------------------
; This entry point entered from above to print ASCII and UDGs but also from
; earlier to print mosaic characters.
; HL=destination
; DE=character source
; BC=line/column
;; PR-ALL
L0B7F: LD A,C ; column to A
DEC A ; move right
LD A,$21 ; pre-load with leftmost position
JR NZ,L0B93 ; but if not zero to PR-ALL-1
DEC B ; down one line
LD C,A ; load C with $21
BIT 1,(IY+$01) ; test FLAGS - Is printer in use
JR Z,L0B93 ; to PR-ALL-1 if not
PUSH DE ; save source address
CALL L0ECD ; routine COPY-BUFF outputs line to printer
POP DE ; restore character source address
LD A,C ; the new column number ($21) to C
;; PR-ALL-1
L0B93: CP C ; this test is really for screen - new line ?
PUSH DE ; save source
CALL Z,L0C55 ; routine PO-SCR considers scrolling
POP DE ; restore source
PUSH BC ; save line/column
PUSH HL ; and destination
LD A,($5C91) ; fetch P_FLAG to accumulator
LD B,$FF ; prepare OVER mask in B.
RRA ; bit 0 set if OVER 1
JR C,L0BA4 ; to PR-ALL-2
INC B ; set OVER mask to 0
;; PR-ALL-2
L0BA4: RRA ; skip bit 1 of P_FLAG
RRA ; bit 2 is INVERSE
SBC A,A ; will be FF for INVERSE 1 else zero
LD C,A ; transfer INVERSE mask to C
LD A,$08 ; prepare to count 8 bytes
AND A ; clear carry to signal screen
BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
JR Z,L0BB6 ; to PR-ALL-3 if screen
SET 1,(IY+$30) ; update FLAGS2 - signal printer buffer has
; been used.
SCF ; set carry flag to signal printer.
;; PR-ALL-3
L0BB6: EX DE,HL ; now HL=source, DE=destination
;; PR-ALL-4
L0BB7: EX AF,AF' ; save printer/screen flag
LD A,(DE) ; fetch existing destination byte
AND B ; consider OVER
XOR (HL) ; now XOR with source
XOR C ; now with INVERSE MASK
LD (DE),A ; update screen/printer
EX AF,AF' ; restore flag
JR C,L0BD3 ; to PR-ALL-6 - printer address update
INC D ; gives next pixel line down screen
;; PR-ALL-5
L0BC1: INC HL ; address next character byte
DEC A ; the byte count is decremented
JR NZ,L0BB7 ; back to PR-ALL-4 for all 8 bytes
EX DE,HL ; destination to HL
DEC H ; bring back to last updated screen position
BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
CALL Z,L0BDB ; if not, call routine PO-ATTR to update
; corresponding colour attribute.
POP HL ; restore original screen/printer position
POP BC ; and line column
DEC C ; move column to right
INC HL ; increase screen/printer position
RET ; return and continue into PO-STORE
; within PO-ABLE
; ---
; This branch is used to update the printer position by 32 places
; Note. The high byte of the address D remains constant (which it should).
;; PR-ALL-6
L0BD3: EX AF,AF' ; save the flag
LD A,$20 ; load A with 32 decimal
ADD A,E ; add this to E
LD E,A ; and store result in E
EX AF,AF' ; fetch the flag
JR L0BC1 ; back to PR-ALL-5
; -----------------------------------
; THE 'GET ATTRIBUTE ADDRESS' ROUTINE
; -----------------------------------
; This routine is entered with the HL register holding the last screen
; address to be updated by PRINT or PLOT.
; The Spectrum screen arrangement leads to the L register holding the correct
; value for the attribute file and it is only necessary to manipulate H to
; form the correct colour attribute address.
;; PO-ATTR
L0BDB: LD A,H ; fetch high byte $40 - $57
RRCA ; shift
RRCA ; bits 3 and 4
RRCA ; to right.
AND $03 ; range is now 0 - 2
OR $58 ; form correct high byte for third of screen
LD H,A ; HL is now correct
LD DE,($5C8F) ; make D hold ATTR_T, E hold MASK-T
LD A,(HL) ; fetch existing attribute
XOR E ; apply masks
AND D ;
XOR E ;
BIT 6,(IY+$57) ; test P_FLAG - is this PAPER 9 ??
JR Z,L0BFA ; skip to PO-ATTR-1 if not.
AND $C7 ; set paper
BIT 2,A ; to contrast with ink
JR NZ,L0BFA ; skip to PO-ATTR-1
XOR $38 ;
;; PO-ATTR-1
L0BFA: BIT 4,(IY+$57) ; test P_FLAG - Is this INK 9 ??
JR Z,L0C08 ; skip to PO-ATTR-2 if not
AND $F8 ; make ink
BIT 5,A ; contrast with paper.
JR NZ,L0C08 ; to PO-ATTR-2
XOR $07 ;
;; PO-ATTR-2
L0C08: LD (HL),A ; save the new attribute.
RET ; return.
; ---------------------------------
; THE 'MESSAGE PRINTING' SUBROUTINE
; ---------------------------------
; This entry point is used to print tape, boot-up, scroll? and error messages.
; On entry the DE register points to an initial step-over byte or the
; inverted end-marker of the previous entry in the table.
; Register A contains the message number, often zero to print first message.
; (HL has nothing important usually P_FLAG)
;; PO-MSG
L0C0A: PUSH HL ; put hi-byte zero on stack to suppress
LD H,$00 ; trailing spaces
EX (SP),HL ; ld h,0; push hl would have done ?.
JR L0C14 ; forward to PO-TABLE.
; ---
; This entry point prints the BASIC keywords, '<>' etc. from alt set
;; PO-TOKENS
L0C10: LD DE,L0095 ; address: TKN-TABLE
PUSH AF ; save the token number to control
; trailing spaces - see later *
; ->
;; PO-TABLE
L0C14: CALL L0C41 ; routine PO-SEARCH will set carry for
; all messages and function words.
JR C,L0C22 ; forward to PO-EACH if not a command, '<>' etc.
LD A,$20 ; prepare leading space
BIT 0,(IY+$01) ; test FLAGS - leading space if not set
CALL Z,L0C3B ; routine PO-SAVE to print a space without
; disturbing registers.
;; PO-EACH
L0C22: LD A,(DE) ; Fetch character from the table.
AND $7F ; Cancel any inverted bit.
CALL L0C3B ; Routine PO-SAVE to print using the alternate
; set of registers.
LD A,(DE) ; Re-fetch character from table.
INC DE ; Address next character in the table.
ADD A,A ; Was character inverted ?
; (this also doubles character)
JR NC,L0C22 ; back to PO-EACH if not.
POP DE ; * re-fetch trailing space byte to D
CP $48 ; was the last character '$' ?
JR Z,L0C35 ; forward to PO-TR-SP to consider trailing
; space if so.
CP $82 ; was it < 'A' i.e. '#','>','=' from tokens
; or ' ','.' (from tape) or '?' from scroll
RET C ; Return if so as no trailing space required.
;; PO-TR-SP
L0C35: LD A,D ; The trailing space flag (zero if an error msg)
CP $03 ; Test against RND, INKEY$ and PI which have no
; parameters and therefore no trailing space.
RET C ; Return if no trailing space.
LD A,$20 ; Prepare the space character and continue to
; print and make an indirect return.
; -----------------------------------
; THE 'RECURSIVE PRINTING' SUBROUTINE
; -----------------------------------
; This routine which is part of PRINT-OUT allows RST $10 to be used
; recursively to print tokens and the spaces associated with them.
; It is called on three occasions when the value of DE must be preserved.
;; PO-SAVE
L0C3B: PUSH DE ; Save DE value.
EXX ; Switch in main set
RST 10H ; PRINT-A prints using this alternate set.
EXX ; Switch back to this alternate set.
POP DE ; Restore the initial DE value.
RET ; Return.
; ------------
; Table search
; ------------
; This subroutine searches a message or the token table for the
; message number held in A. DE holds the address of the table.
;; PO-SEARCH
L0C41: PUSH AF ; save the message/token number
EX DE,HL ; transfer DE to HL
INC A ; adjust for initial step-over byte
;; PO-STEP
L0C44: BIT 7,(HL) ; is character inverted ?
INC HL ; address next
JR Z,L0C44 ; back to PO-STEP if not inverted.
DEC A ; decrease counter
JR NZ,L0C44 ; back to PO-STEP if not zero
EX DE,HL ; transfer address to DE
POP AF ; restore message/token number
CP $20 ; return with carry set
RET C ; for all messages and function tokens
LD A,(DE) ; test first character of token
SUB $41 ; and return with carry set
RET ; if it is less that 'A'
; i.e. '<>', '<=', '>='
; ---------------
; Test for scroll
; ---------------
; This test routine is called when printing carriage return, when considering
; PRINT AT and from the general PRINT ALL characters routine to test if
; scrolling is required, prompting the user if necessary.
; This is therefore using the alternate set.
; The B register holds the current line.
;; PO-SCR
L0C55: BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
RET NZ ; return immediately if so.
LD DE,L0DD9 ; set DE to address: CL-SET
PUSH DE ; and push for return address.
LD A,B ; transfer the line to A.
BIT 0,(IY+$02) ; test TV_FLAG - lower screen in use ?
JP NZ,L0D02 ; jump forward to PO-SCR-4 if so.
CP (IY+$31) ; greater than DF_SZ display file size ?
JR C,L0C86 ; forward to REPORT-5 if less.
; 'Out of screen'
RET NZ ; return (via CL-SET) if greater
BIT 4,(IY+$02) ; test TV_FLAG - Automatic listing ?
JR Z,L0C88 ; forward to PO-SCR-2 if not.
LD E,(IY+$2D) ; fetch BREG - the count of scroll lines to E.
DEC E ; decrease and jump
JR Z,L0CD2 ; to PO-SCR-3 if zero and scrolling required.
LD A,$00 ; explicit - select channel zero.
CALL L1601 ; routine CHAN-OPEN opens it.
LD SP,($5C3F) ; set stack pointer to LIST_SP
RES 4,(IY+$02) ; reset TV_FLAG - signal auto listing finished.
RET ; return ignoring pushed value, CL-SET
; to MAIN or EDITOR without updating
; print position >>
; ---
;; REPORT-5
L0C86: RST 08H ; ERROR-1
DEFB $04 ; Error Report: Out of screen
; continue here if not an automatic listing.
;; PO-SCR-2
L0C88: DEC (IY+$52) ; decrease SCR_CT
JR NZ,L0CD2 ; forward to PO-SCR-3 to scroll display if
; result not zero.
; now produce prompt.
LD A,$18 ; reset
SUB B ; the
LD ($5C8C),A ; SCR_CT scroll count
LD HL,($5C8F) ; L=ATTR_T, H=MASK_T
PUSH HL ; save on stack
LD A,($5C91) ; P_FLAG
PUSH AF ; save on stack to prevent lower screen
; attributes (BORDCR etc.) being applied.
LD A,$FD ; select system channel 'K'
CALL L1601 ; routine CHAN-OPEN opens it
XOR A ; clear to address message directly
LD DE,L0CF8 ; make DE address: scrl-mssg
CALL L0C0A ; routine PO-MSG prints to lower screen
SET 5,(IY+$02) ; set TV_FLAG - signal lower screen requires
; clearing
LD HL,$5C3B ; make HL address FLAGS
SET 3,(HL) ; signal 'L' mode.
RES 5,(HL) ; signal 'no new key'.
EXX ; switch to main set.
; as calling chr input from alternative set.
CALL L15D4 ; routine WAIT-KEY waits for new key
; Note. this is the right routine but the
; stream in use is unsatisfactory. From the
; choices available, it is however the best.
EXX ; switch back to alternate set.
CP $20 ; space is considered as BREAK
JR Z,L0D00 ; forward to REPORT-D if so
; 'BREAK - CONT repeats'
CP $E2 ; is character 'STOP' ?
JR Z,L0D00 ; forward to REPORT-D if so
OR $20 ; convert to lower-case
CP $6E ; is character 'n' ?
JR Z,L0D00 ; forward to REPORT-D if so else scroll.
LD A,$FE ; select system channel 'S'
CALL L1601 ; routine CHAN-OPEN
POP AF ; restore original P_FLAG
LD ($5C91),A ; and save in P_FLAG.
POP HL ; restore original ATTR_T, MASK_T
LD ($5C8F),HL ; and reset ATTR_T, MASK-T as 'scroll?' has
; been printed.
;; PO-SCR-3
L0CD2: CALL L0DFE ; routine CL-SC-ALL to scroll whole display
LD B,(IY+$31) ; fetch DF_SZ to B
INC B ; increase to address last line of display
LD C,$21 ; set C to $21 (was $21 from above routine)
PUSH BC ; save the line and column in BC.
CALL L0E9B ; routine CL-ADDR finds display address.
LD A,H ; now find the corresponding attribute byte
RRCA ; (this code sequence is used twice
RRCA ; elsewhere and is a candidate for
RRCA ; a subroutine.)
AND $03 ;
OR $58 ;
LD H,A ;
LD DE,$5AE0 ; start of last 'line' of attribute area
LD A,(DE) ; get attribute for last line
LD C,(HL) ; transfer to base line of upper part
LD B,$20 ; there are thirty two bytes
EX DE,HL ; swap the pointers.
;; PO-SCR-3A
L0CF0: LD (DE),A ; transfer
LD (HL),C ; attributes.
INC DE ; address next.
INC HL ; address next.
DJNZ L0CF0 ; loop back to PO-SCR-3A for all adjacent
; attribute lines.
POP BC ; restore the line/column.
RET ; return via CL-SET (was pushed on stack).
; ---
; The message 'scroll?' appears here with last byte inverted.
;; scrl-mssg
L0CF8: DEFB $80 ; initial step-over byte.
DEFM "scroll"
DEFB '?'+$80
;; REPORT-D
L0D00: RST 08H ; ERROR-1
DEFB $0C ; Error Report: BREAK - CONT repeats
; continue here if using lower display - A holds line number.
;; PO-SCR-4
L0D02: CP $02 ; is line number less than 2 ?
JR C,L0C86 ; to REPORT-5 if so
; 'Out of Screen'.
ADD A,(IY+$31) ; add DF_SZ
SUB $19 ;
RET NC ; return if scrolling unnecessary
NEG ; Negate to give number of scrolls required.
PUSH BC ; save line/column
LD B,A ; count to B
LD HL,($5C8F) ; fetch current ATTR_T, MASK_T to HL.
PUSH HL ; and save
LD HL,($5C91) ; fetch P_FLAG
PUSH HL ; and save.
; to prevent corruption by input AT
CALL L0D4D ; routine TEMPS sets to BORDCR etc
LD A,B ; transfer scroll number to A.
;; PO-SCR-4A
L0D1C: PUSH AF ; save scroll number.
LD HL,$5C6B ; address DF_SZ
LD B,(HL) ; fetch old value
LD A,B ; transfer to A
INC A ; and increment
LD (HL),A ; then put back.
LD HL,$5C89 ; address S_POSN_hi - line
CP (HL) ; compare
JR C,L0D2D ; forward to PO-SCR-4B if scrolling required
INC (HL) ; else increment S_POSN_hi
LD B,$18 ; set count to whole display ??
; Note. should be $17 and the top line will be
; scrolled into the ROM which is harmless on
; the standard set up.
; credit P.Giblin 1984.
;; PO-SCR-4B
L0D2D: CALL L0E00 ; routine CL-SCROLL scrolls B lines
POP AF ; restore scroll counter.
DEC A ; decrease
JR NZ,L0D1C ; back to PO-SCR-4A until done
POP HL ; restore original P_FLAG.
LD (IY+$57),L ; and overwrite system variable P_FLAG.
POP HL ; restore original ATTR_T/MASK_T.
LD ($5C8F),HL ; and update system variables.
LD BC,($5C88) ; fetch S_POSN to BC.
RES 0,(IY+$02) ; signal to TV_FLAG - main screen in use.
CALL L0DD9 ; call routine CL-SET for upper display.
SET 0,(IY+$02) ; signal to TV_FLAG - lower screen in use.
POP BC ; restore line/column
RET ; return via CL-SET for lower display.
; ----------------------
; Temporary colour items
; ----------------------
; This subroutine is called 11 times to copy the permanent colour items
; to the temporary ones.
;; TEMPS
L0D4D: XOR A ; clear the accumulator
LD HL,($5C8D) ; fetch L=ATTR_P and H=MASK_P
BIT 0,(IY+$02) ; test TV_FLAG - is lower screen in use ?
JR Z,L0D5B ; skip to TEMPS-1 if not
LD H,A ; set H, MASK P, to 00000000.
LD L,(IY+$0E) ; fetch BORDCR to L which is used for lower
; screen.
;; TEMPS-1
L0D5B: LD ($5C8F),HL ; transfer values to ATTR_T and MASK_T
; for the print flag the permanent values are odd bits, temporary even bits.
LD HL,$5C91 ; address P_FLAG.
JR NZ,L0D65 ; skip to TEMPS-2 if lower screen using A=0.
LD A,(HL) ; else pick up flag bits.
RRCA ; rotate permanent bits to temporary bits.
;; TEMPS-2
L0D65: XOR (HL) ;
AND $55 ; BIN 01010101
XOR (HL) ; permanent now as original
LD (HL),A ; apply permanent bits to temporary bits.
RET ; and return.
; -----------------
; THE 'CLS' COMMAND
; -----------------
; This command clears the display.
; The routine is also called during initialization and by the CLEAR command.
; If it's difficult to write it should be difficult to read.
;; CLS
L0D6B: CALL L0DAF ; Routine CL-ALL clears the entire display and
; sets the attributes to the permanent ones
; from ATTR-P.
; Having cleared all 24 lines of the display area, continue into the
; subroutine that clears the lower display area. Note that at the moment
; the attributes for the lower lines are the same as upper ones and have
; to be changed to match the BORDER colour.
; --------------------------
; THE 'CLS-LOWER' SUBROUTINE
; --------------------------
; This routine is called from INPUT, and from the MAIN execution loop.
; This is very much a housekeeping routine which clears between 2 and 23
; lines of the display, setting attributes and correcting situations where
; errors have occurred while the normal input and output routines have been
; temporarily diverted to deal with, say colour control codes.
;; CLS-LOWER
L0D6E: LD HL,$5C3C ; address System Variable TV_FLAG.
RES 5,(HL) ; TV_FLAG - signal do not clear lower screen.
SET 0,(HL) ; TV_FLAG - signal lower screen in use.
CALL L0D4D ; routine TEMPS applies permanent attributes,
; in this case BORDCR to ATTR_T.
; Note. this seems unnecessary and is repeated
; within CL-LINE.
LD B,(IY+$31) ; fetch lower screen display file size DF_SZ
CALL L0E44 ; routine CL-LINE clears lines to bottom of the
; display and sets attributes from BORDCR while
; preserving the B register.
LD HL,$5AC0 ; set initial attribute address to the leftmost
; cell of second line up.
LD A,($5C8D) ; fetch permanent attribute from ATTR_P.
DEC B ; decrement lower screen display file size.
JR L0D8E ; forward to enter the backfill loop at CLS-3
; where B is decremented again.
; ---
; The backfill loop is entered at midpoint and ensures, if more than 2
; lines have been cleared, that any other lines take the permanent screen
; attributes.
;; CLS-1
L0D87: LD C,$20 ; set counter to 32 character cells per line
;; CLS-2
L0D89: DEC HL ; decrease attribute address.
LD (HL),A ; and place attributes in next line up.
DEC C ; decrease the 32 counter.
JR NZ,L0D89 ; loop back to CLS-2 until all 32 cells done.
;; CLS-3
L0D8E: DJNZ L0D87 ; decrease B counter and back to CLS-1
; if not zero.
LD (IY+$31),$02 ; now set DF_SZ lower screen to 2
; This entry point is also called from CL-ALL below to
; reset the system channel input and output addresses to normal.
;; CL-CHAN
L0D94: LD A,$FD ; select system channel 'K'
CALL L1601 ; routine CHAN-OPEN opens it.
LD HL,($5C51) ; fetch CURCHL to HL to address current channel
LD DE,L09F4 ; set address to PRINT-OUT for first pass.
AND A ; clear carry for first pass.
;; CL-CHAN-A
L0DA0: LD (HL),E ; Insert the output address on the first pass
INC HL ; or the input address on the second pass.
LD (HL),D ;
INC HL ;
LD DE,L10A8 ; fetch address KEY-INPUT for second pass
CCF ; complement carry flag - will set on pass 1.
JR C,L0DA0 ; back to CL-CHAN-A if first pass else done.
LD BC,$1721 ; line 23 for lower screen
JR L0DD9 ; exit via CL-SET to set column
; for lower display
; ---------------------------
; Clearing whole display area
; ---------------------------
; This subroutine called from CLS, AUTO-LIST and MAIN-3
; clears 24 lines of the display and resets the relevant system variables.
; This routine also recovers from an error situation where, for instance, an
; invalid colour or position control code has left the output routine addressing
; PO-TV-2 or PO-CONT.
;; CL-ALL
L0DAF: LD HL,$0000 ; Initialize plot coordinates.
LD ($5C7D),HL ; Set system variable COORDS to 0,0.
RES 0,(IY+$30) ; update FLAGS2 - signal main screen is clear.
CALL L0D94 ; routine CL-CHAN makes channel 'K' 'normal'.
LD A,$FE ; select system channel 'S'
CALL L1601 ; routine CHAN-OPEN opens it.
CALL L0D4D ; routine TEMPS applies permanent attributes,
; in this case ATTR_P, to ATTR_T.
; Note. this seems unnecessary.
LD B,$18 ; There are 24 lines.
CALL L0E44 ; routine CL-LINE clears 24 text lines and sets
; attributes from ATTR-P.
; This routine preserves B and sets C to $21.
LD HL,($5C51) ; fetch CURCHL make HL address output routine.
LD DE,L09F4 ; address: PRINT-OUT
LD (HL),E ; is made
INC HL ; the normal
LD (HL),D ; output address.
LD (IY+$52),$01 ; set SCR_CT - scroll count - to default.
; Note. BC already contains $1821.
LD BC,$1821 ; reset column and line to 0,0
; and continue into CL-SET, below, exiting
; via PO-STORE (for the upper screen).
; --------------------
; THE 'CL-SET' ROUTINE
; --------------------
; This important subroutine is used to calculate the character output
; address for screens or printer based on the line/column for screens
; or the column for printer.
;; CL-SET
L0DD9: LD HL,$5B00 ; the base address of printer buffer
BIT 1,(IY+$01) ; test FLAGS - is printer in use ?
JR NZ,L0DF4 ; forward to CL-SET-2 if so.
LD A,B ; transfer line to A.
BIT 0,(IY+$02) ; test TV_FLAG - lower screen in use ?
JR Z,L0DEE ; skip to CL-SET-1 if handling upper part
ADD A,(IY+$31) ; add DF_SZ for lower screen
SUB $18 ; and adjust.
;; CL-SET-1
L0DEE: PUSH BC ; save the line/column.
LD B,A ; transfer line to B
; (adjusted if lower screen)
CALL L0E9B ; routine CL-ADDR calculates address at left
; of screen.
POP BC ; restore the line/column.
;; CL-SET-2
L0DF4: LD A,$21 ; the column $01-$21 is reversed
SUB C ; to range $00 - $20
LD E,A ; now transfer to DE
LD D,$00 ; prepare for addition
ADD HL,DE ; and add to base address
JP L0ADC ; exit via PO-STORE to update the relevant
; system variables.
; ----------------
; Handle scrolling
; ----------------
; The routine CL-SC-ALL is called once from PO to scroll all the display
; and from the routine CL-SCROLL, once, to scroll part of the display.
;; CL-SC-ALL
L0DFE: LD B,$17 ; scroll 23 lines, after 'scroll?'.
;; CL-SCROLL
L0E00: CALL L0E9B ; routine CL-ADDR gets screen address in HL.
LD C,$08 ; there are 8 pixel lines to scroll.
;; CL-SCR-1
L0E05: PUSH BC ; save counters.
PUSH HL ; and initial address.
LD A,B ; get line count.
AND $07 ; will set zero if all third to be scrolled.
LD A,B ; re-fetch the line count.
JR NZ,L0E19 ; forward to CL-SCR-3 if partial scroll.
; HL points to top line of third and must be copied to bottom of previous 3rd.
; ( so HL = $4800 or $5000 ) ( but also sometimes $4000 )
;; CL-SCR-2
L0E0D: EX DE,HL ; copy HL to DE.
LD HL,$F8E0 ; subtract $08 from H and add $E0 to L -
ADD HL,DE ; to make destination bottom line of previous
; third.
EX DE,HL ; restore the source and destination.
LD BC,$0020 ; thirty-two bytes are to be copied.
DEC A ; decrement the line count.
LDIR ; copy a pixel line to previous third.
;; CL-SCR-3
L0E19: EX DE,HL ; save source in DE.
LD HL,$FFE0 ; load the value -32.
ADD HL,DE ; add to form destination in HL.
EX DE,HL ; switch source and destination
LD B,A ; save the count in B.
AND $07 ; mask to find count applicable to current
RRCA ; third and
RRCA ; multiply by
RRCA ; thirty two (same as 5 RLCAs)
LD C,A ; transfer byte count to C ($E0 at most)
LD A,B ; store line count to A
LD B,$00 ; make B zero
LDIR ; copy bytes (BC=0, H incremented, L=0)
LD B,$07 ; set B to 7, C is zero.
ADD HL,BC ; add 7 to H to address next third.
AND $F8 ; has last third been done ?
JR NZ,L0E0D ; back to CL-SCR-2 if not.
POP HL ; restore topmost address.
INC H ; next pixel line down.
POP BC ; restore counts.
DEC C ; reduce pixel line count.
JR NZ,L0E05 ; back to CL-SCR-1 if all eight not done.
CALL L0E88 ; routine CL-ATTR gets address in attributes
; from current 'ninth line', count in BC.
LD HL,$FFE0 ; set HL to the 16-bit value -32.
ADD HL,DE ; and add to form destination address.
EX DE,HL ; swap source and destination addresses.
LDIR ; copy bytes scrolling the linear attributes.
LD B,$01 ; continue to clear the bottom line.
; ------------------------------
; THE 'CLEAR TEXT LINES' ROUTINE
; ------------------------------
; This subroutine, called from CL-ALL, CLS-LOWER and AUTO-LIST and above,
; clears text lines at bottom of display.
; The B register holds on entry the number of lines to be cleared 1-24.
;; CL-LINE
L0E44: PUSH BC ; save line count
CALL L0E9B ; routine CL-ADDR gets top address
LD C,$08 ; there are eight screen lines to a text line.
;; CL-LINE-1
L0E4A: PUSH BC ; save pixel line count
PUSH HL ; and save the address
LD A,B ; transfer the line to A (1-24).
;; CL-LINE-2
L0E4D: AND $07 ; mask 0-7 to consider thirds at a time
RRCA ; multiply
RRCA ; by 32 (same as five RLCA instructions)
RRCA ; now 32 - 256(0)
LD C,A ; store result in C
LD A,B ; save line in A (1-24)
LD B,$00 ; set high byte to 0, prepare for ldir.
DEC C ; decrement count 31-255.
LD D,H ; copy HL
LD E,L ; to DE.
LD (HL),$00 ; blank the first byte.
INC DE ; make DE point to next byte.
LDIR ; ldir will clear lines.
LD DE,$0701 ; now address next third adjusting
ADD HL,DE ; register E to address left hand side
DEC A ; decrease the line count.
AND $F8 ; will be 16, 8 or 0 (AND $18 will do).
LD B,A ; transfer count to B.
JR NZ,L0E4D ; back to CL-LINE-2 if 16 or 8 to do
; the next third.
POP HL ; restore start address.
INC H ; address next line down.
POP BC ; fetch counts.
DEC C ; decrement pixel line count
JR NZ,L0E4A ; back to CL-LINE-1 till all done.
CALL L0E88 ; routine CL-ATTR gets attribute address
; in DE and B * 32 in BC.
LD H,D ; transfer the address
LD L,E ; to HL.
INC DE ; make DE point to next location.
LD A,($5C8D) ; fetch ATTR_P - permanent attributes
BIT 0,(IY+$02) ; test TV_FLAG - lower screen in use ?
JR Z,L0E80 ; skip to CL-LINE-3 if not.
LD A,($5C48) ; else lower screen uses BORDCR as attribute.
;; CL-LINE-3
L0E80: LD (HL),A ; put attribute in first byte.
DEC BC ; decrement the counter.
LDIR ; copy bytes to set all attributes.
POP BC ; restore the line $01-$24.
LD C,$21 ; make column $21. (No use is made of this)
RET ; return to the calling routine.
; ------------------
; Attribute handling
; ------------------
; This subroutine is called from CL-LINE or CL-SCROLL with the HL register
; pointing to the 'ninth' line and H needs to be decremented before or after
; the division. Had it been done first then either present code or that used
; at the start of PO-ATTR could have been used.
; The Spectrum screen arrangement leads to the L register already holding
; the correct value for the attribute file and it is only necessary
; to manipulate H to form the correct colour attribute address.
;; CL-ATTR
L0E88: LD A,H ; fetch H to A - $48, $50, or $58.
RRCA ; divide by
RRCA ; eight.
RRCA ; $09, $0A or $0B.
DEC A ; $08, $09 or $0A.
OR $50 ; $58, $59 or $5A.
LD H,A ; save high byte of attributes.
EX DE,HL ; transfer attribute address to DE
LD H,C ; set H to zero - from last LDIR.
LD L,B ; load L with the line from B.
ADD HL,HL ; multiply
ADD HL,HL ; by
ADD HL,HL ; thirty two
ADD HL,HL ; to give count of attribute
ADD HL,HL ; cells to the end of display.
LD B,H ; transfer the result
LD C,L ; to register BC.
RET ; return.
; -------------------------------
; Handle display with line number
; -------------------------------
; This subroutine is called from four places to calculate the address
; of the start of a screen character line which is supplied in B.
;; CL-ADDR
L0E9B: LD A,$18 ; reverse the line number
SUB B ; to range $00 - $17.
LD D,A ; save line in D for later.
RRCA ; multiply
RRCA ; by
RRCA ; thirty-two.
AND $E0 ; mask off low bits to make
LD L,A ; L a multiple of 32.
LD A,D ; bring back the line to A.
AND $18 ; now $00, $08 or $10.
OR $40 ; add the base address of screen.
LD H,A ; HL now has the correct address.
RET ; return.
; -------------------
; Handle COPY command
; -------------------
; This command copies the top 176 lines to the ZX Printer
; It is popular to call this from machine code at point
; L0EAF with B holding 192 (and interrupts disabled) for a full-screen
; copy. This particularly applies to 16K Spectrums as time-critical
; machine code routines cannot be written in the first 16K of RAM as
; it is shared with the ULA which has precedence over the Z80 chip.
;; COPY
L0EAC: DI ; disable interrupts as this is time-critical.
LD B,$B0 ; top 176 lines.
L0EAF: LD HL,$4000 ; address start of the display file.
; now enter a loop to handle each pixel line.
;; COPY-1
L0EB2: PUSH HL ; save the screen address.
PUSH BC ; and the line counter.
CALL L0EF4 ; routine COPY-LINE outputs one line.
POP BC ; restore the line counter.
POP HL ; and display address.
INC H ; next line down screen within 'thirds'.
LD A,H ; high byte to A.
AND $07 ; result will be zero if we have left third.
JR NZ,L0EC9 ; forward to COPY-2 if not to continue loop.
LD A,L ; consider low byte first.
ADD A,$20 ; increase by 32 - sets carry if back to zero.
LD L,A ; will be next group of 8.
CCF ; complement - carry set if more lines in
; the previous third.
SBC A,A ; will be FF, if more, else 00.
AND $F8 ; will be F8 (-8) or 00.
ADD A,H ; that is subtract 8, if more to do in third.
LD H,A ; and reset address.
;; COPY-2
L0EC9: DJNZ L0EB2 ; back to COPY-1 for all lines.
JR L0EDA ; forward to COPY-END to switch off the printer
; motor and enable interrupts.
; Note. Nothing else is required.
; ------------------------------
; Pass printer buffer to printer
; ------------------------------
; This routine is used to copy 8 text lines from the printer buffer
; to the ZX Printer. These text lines are mapped linearly so HL does
; not need to be adjusted at the end of each line.
;; COPY-BUFF
L0ECD: DI ; disable interrupts
LD HL,$5B00 ; the base address of the Printer Buffer.
LD B,$08 ; set count to 8 lines of 32 bytes.
;; COPY-3
L0ED3: PUSH BC ; save counter.
CALL L0EF4 ; routine COPY-LINE outputs 32 bytes
POP BC ; restore counter.
DJNZ L0ED3 ; loop back to COPY-3 for all 8 lines.
; then stop motor and clear buffer.
; Note. the COPY command rejoins here, essentially to execute the next
; three instructions.
;; COPY-END
L0EDA: LD A,$04 ; output value 4 to port
OUT ($FB),A ; to stop the slowed printer motor.
EI ; enable interrupts.
; --------------------
; Clear Printer Buffer
; --------------------
; This routine clears an arbitrary 256 bytes of memory.
; Note. The routine seems designed to clear a buffer that follows the
; system variables.
; The routine should check a flag or HL address and simply return if COPY
; is in use.
; As a consequence of this omission the buffer will needlessly
; be cleared when COPY is used and the screen/printer position may be set to
; the start of the buffer and the line number to 0 (B)
; giving an 'Out of Screen' error.
; There seems to have been an unsuccessful attempt to circumvent the use
; of PR_CC_hi.
;; CLEAR-PRB
L0EDF: LD HL,$5B00 ; the location of the buffer.
LD (IY+$46),L ; update PR_CC_lo - set to zero - superfluous.
XOR A ; clear the accumulator.
LD B,A ; set count to 256 bytes.
;; PRB-BYTES
L0EE7: LD (HL),A ; set addressed location to zero.
INC HL ; address next byte - Note. not INC L.
DJNZ L0EE7 ; back to PRB-BYTES. repeat for 256 bytes.
RES 1,(IY+$30) ; set FLAGS2 - signal printer buffer is clear.
LD C,$21 ; set the column position .
JP L0DD9 ; exit via CL-SET and then PO-STORE.
; -----------------
; Copy line routine
; -----------------
; This routine is called from COPY and COPY-BUFF to output a line of
; 32 bytes to the ZX Printer.
; Output to port $FB -
; bit 7 set - activate stylus.
; bit 7 low - deactivate stylus.
; bit 2 set - stops printer.
; bit 2 reset - starts printer
; bit 1 set - slows printer.
; bit 1 reset - normal speed.
;; COPY-LINE
L0EF4: LD A,B ; fetch the counter 1-8 or 1-176
CP $03 ; is it 01 or 02 ?.
SBC A,A ; result is $FF if so else $00.
AND $02 ; result is 02 now else 00.
; bit 1 set slows the printer.
OUT ($FB),A ; slow the printer for the
; last two lines.
LD D,A ; save the mask to control the printer later.
;; COPY-L-1
L0EFD: CALL L1F54 ; call BREAK-KEY to read keyboard immediately.
JR C,L0F0C ; forward to COPY-L-2 if 'break' not pressed.
LD A,$04 ; else stop the
OUT ($FB),A ; printer motor.
EI ; enable interrupts.
CALL L0EDF ; call routine CLEAR-PRB.
; Note. should not be cleared if COPY in use.
;; REPORT-Dc
L0F0A: RST 08H ; ERROR-1
DEFB $0C ; Error Report: BREAK - CONT repeats
;; COPY-L-2
L0F0C: IN A,($FB) ; test now to see if
ADD A,A ; a printer is attached.
RET M ; return if not - but continue with parent
; command.
JR NC,L0EFD ; back to COPY-L-1 if stylus of printer not
; in position.
LD C,$20 ; set count to 32 bytes.
;; COPY-L-3
L0F14: LD E,(HL) ; fetch a byte from line.
INC HL ; address next location. Note. not INC L.
LD B,$08 ; count the bits.
;; COPY-L-4
L0F18: RL D ; prepare mask to receive bit.
RL E ; rotate leftmost print bit to carry
RR D ; and back to bit 7 of D restoring bit 1
;; COPY-L-5
L0F1E: IN A,($FB) ; read the port.
RRA ; bit 0 to carry.
JR NC,L0F1E ; back to COPY-L-5 if stylus not in position.
LD A,D ; transfer command bits to A.
OUT ($FB),A ; and output to port.
DJNZ L0F18 ; loop back to COPY-L-4 for all 8 bits.
DEC C ; decrease the byte count.
JR NZ,L0F14 ; back to COPY-L-3 until 256 bits done.
RET ; return to calling routine COPY/COPY-BUFF.
; ----------------------------------
; Editor routine for BASIC and INPUT
; ----------------------------------
; The editor is called to prepare or edit a BASIC line.
; It is also called from INPUT to input a numeric or string expression.
; The behaviour and options are quite different in the various modes
; and distinguished by bit 5 of FLAGX.
;
; This is a compact and highly versatile routine.
;; EDITOR
L0F2C: LD HL,($5C3D) ; fetch ERR_SP
PUSH HL ; save on stack
;; ED-AGAIN
L0F30: LD HL,L107F ; address: ED-ERROR
PUSH HL ; save address on stack and
LD ($5C3D),SP ; make ERR_SP point to it.
; Note. While in editing/input mode should an error occur then RST 08 will
; update X_PTR to the location reached by CH_ADD and jump to ED-ERROR
; where the error will be cancelled and the loop begin again from ED-AGAIN
; above. The position of the error will be apparent when the lower screen is
; reprinted. If no error then the re-iteration is to ED-LOOP below when
; input is arriving from the keyboard.
;; ED-LOOP
L0F38: CALL L15D4 ; routine WAIT-KEY gets key possibly
; changing the mode.
PUSH AF ; save key.
LD D,$00 ; and give a short click based
LD E,(IY-$01) ; on PIP value for duration.
LD HL,$00C8 ; and pitch.
CALL L03B5 ; routine BEEPER gives click - effective
; with rubber keyboard.
POP AF ; get saved key value.
LD HL,L0F38 ; address: ED-LOOP is loaded to HL.
PUSH HL ; and pushed onto stack.
; At this point there is a looping return address on the stack, an error
; handler and an input stream set up to supply characters.
; The character that has been received can now be processed.
CP $18 ; range 24 to 255 ?
JR NC,L0F81 ; forward to ADD-CHAR if so.
CP $07 ; lower than 7 ?
JR C,L0F81 ; forward to ADD-CHAR also.
; Note. This is a 'bug' and chr$ 6, the comma
; control character, should have had an
; entry in the ED-KEYS table.
; Steven Vickers, 1984, Pitman.
CP $10 ; less than 16 ?
JR C,L0F92 ; forward to ED-KEYS if editing control
; range 7 to 15 dealt with by a table
LD BC,$0002 ; prepare for ink/paper etc.
LD D,A ; save character in D
CP $16 ; is it ink/paper/bright etc. ?
JR C,L0F6C ; forward to ED-CONTR if so
; leaves 22d AT and 23d TAB
; which can't be entered via KEY-INPUT.
; so this code is never normally executed
; when the keyboard is used for input.
INC BC ; if it was AT/TAB - 3 locations required
BIT 7,(IY+$37) ; test FLAGX - Is this INPUT LINE ?
JP Z,L101E ; jump to ED-IGNORE if not, else
CALL L15D4 ; routine WAIT-KEY - input address is KEY-NEXT
; but is reset to KEY-INPUT
LD E,A ; save first in E
;; ED-CONTR
L0F6C: CALL L15D4 ; routine WAIT-KEY for control.
; input address will be key-next.
PUSH DE ; saved code/parameters
LD HL,($5C5B) ; fetch address of keyboard cursor from K_CUR
RES 0,(IY+$07) ; set MODE to 'L'
CALL L1655 ; routine MAKE-ROOM makes 2/3 spaces at cursor
POP BC ; restore code/parameters
INC HL ; address first location
LD (HL),B ; place code (ink etc.)
INC HL ; address next
LD (HL),C ; place possible parameter. If only one
; then DE points to this location also.
JR L0F8B ; forward to ADD-CH-1
; ------------------------
; Add code to current line
; ------------------------
; this is the branch used to add normal non-control characters
; with ED-LOOP as the stacked return address.
; it is also the OUTPUT service routine for system channel 'R'.
;; ADD-CHAR
L0F81: RES 0,(IY+$07) ; set MODE to 'L'
X0F85: LD HL,($5C5B) ; fetch address of keyboard cursor from K_CUR
CALL L1652 ; routine ONE-SPACE creates one space.
; either a continuation of above or from ED-CONTR with ED-LOOP on stack.
;; ADD-CH-1
L0F8B: LD (DE),A ; load current character to last new location.
INC DE ; address next
LD ($5C5B),DE ; and update K_CUR system variable.
RET ; return - either a simple return
; from ADD-CHAR or to ED-LOOP on stack.
; ---
; a branch of the editing loop to deal with control characters
; using a look-up table.
;; ED-KEYS
L0F92: LD E,A ; character to E.
LD D,$00 ; prepare to add.
LD HL,L0FA0 - 7 ; base address of editing keys table. $0F99
ADD HL,DE ; add E
LD E,(HL) ; fetch offset to E
ADD HL,DE ; add offset for address of handling routine.
PUSH HL ; push the address on machine stack.
LD HL,($5C5B) ; load address of cursor from K_CUR.
RET ; Make an indirect jump forward to routine.
; ------------------
; Editing keys table
; ------------------
; For each code in the range $07 to $0F this table contains a
; single offset byte to the routine that services that code.
; Note. for what was intended there should also have been an
; entry for chr$ 6 with offset to ed-symbol.
;; ed-keys-t
L0FA0: DEFB L0FA9 - ASMPC ; 07d offset $09 to Address: ED-EDIT
DEFB L1007 - ASMPC ; 08d offset $66 to Address: ED-LEFT
DEFB L100C - ASMPC ; 09d offset $6A to Address: ED-RIGHT
DEFB L0FF3 - ASMPC ; 10d offset $50 to Address: ED-DOWN
DEFB L1059 - ASMPC ; 11d offset $B5 to Address: ED-UP
DEFB L1015 - ASMPC ; 12d offset $70 to Address: ED-DELETE
DEFB L1024 - ASMPC ; 13d offset $7E to Address: ED-ENTER
DEFB L1076 - ASMPC ; 14d offset $CF to Address: ED-SYMBOL
DEFB L107C - ASMPC ; 15d offset $D4 to Address: ED-GRAPH
; ---------------
; Handle EDIT key
; ---------------
; The user has pressed SHIFT 1 to bring edit line down to bottom of screen.
; Alternatively the user wishes to clear the input buffer and start again.
; Alternatively ...
;; ED-EDIT
L0FA9: LD HL,($5C49) ; fetch E_PPC the last line number entered.
; Note. may not exist and may follow program.
BIT 5,(IY+$37) ; test FLAGX - input mode ?
JP NZ,L1097 ; jump forward to CLEAR-SP if not in editor.
CALL L196E ; routine LINE-ADDR to find address of line
; or following line if it doesn't exist.
CALL L1695 ; routine LINE-NO will get line number from
; address or previous line if at end-marker.
LD A,D ; if there is no program then DE will
OR E ; contain zero so test for this.
JP Z,L1097 ; jump to CLEAR-SP if so.
; Note. at this point we have a validated line number, not just an
; approximation and it would be best to update E_PPC with the true
; cursor line value which would enable the line cursor to be suppressed
; in all situations - see shortly.
PUSH HL ; save address of line.
INC HL ; address low byte of length.
LD C,(HL) ; transfer to C
INC HL ; next to high byte
LD B,(HL) ; transfer to B.
LD HL,$000A ; an overhead of ten bytes
ADD HL,BC ; is added to length.
LD B,H ; transfer adjusted value
LD C,L ; to BC register.
CALL L1F05 ; routine TEST-ROOM checks free memory.
CALL L1097 ; routine CLEAR-SP clears editing area.
LD HL,($5C51) ; address CURCHL
EX (SP),HL ; swap with line address on stack
PUSH HL ; save line address underneath
LD A,$FF ; select system channel 'R'
CALL L1601 ; routine CHAN-OPEN opens it
POP HL ; drop line address
DEC HL ; make it point to first byte of line num.
DEC (IY+$0F) ; decrease E_PPC_lo to suppress line cursor.
; Note. ineffective when E_PPC is one
; greater than last line of program perhaps
; as a result of a delete.
; credit. Paul Harrison 1982.
CALL L1855 ; routine OUT-LINE outputs the BASIC line
; to the editing area.
INC (IY+$0F) ; restore E_PPC_lo to the previous value.
LD HL,($5C59) ; address E_LINE in editing area.
INC HL ; advance
INC HL ; past space
INC HL ; and digit characters
INC HL ; of line number.
LD ($5C5B),HL ; update K_CUR to address start of BASIC.
POP HL ; restore the address of CURCHL.
CALL L1615 ; routine CHAN-FLAG sets flags for it.
RET ; RETURN to ED-LOOP.
; -------------------
; Cursor down editing
; -------------------
; The BASIC lines are displayed at the top of the screen and the user
; wishes to move the cursor down one line in edit mode.
; With INPUT LINE, this key must be used instead of entering STOP.
;; ED-DOWN
L0FF3: BIT 5,(IY+$37) ; test FLAGX - Input Mode ?
JR NZ,L1001 ; skip to ED-STOP if so
LD HL,$5C49 ; address E_PPC - 'current line'
CALL L190F ; routine LN-FETCH fetches number of next
; line or same if at end of program.
JR L106E ; forward to ED-LIST to produce an
; automatic listing.
; ---
;; ED-STOP
L1001: LD (IY+$00),$10 ; set ERR_NR to 'STOP in INPUT' code
JR L1024 ; forward to ED-ENTER to produce error.
; -------------------
; Cursor left editing
; -------------------
; This acts on the cursor in the lower section of the screen in both
; editing and input mode.
;; ED-LEFT
L1007: CALL L1031 ; routine ED-EDGE moves left if possible
JR L1011 ; forward to ED-CUR to update K-CUR
; and return to ED-LOOP.
; --------------------
; Cursor right editing
; --------------------
; This acts on the cursor in the lower screen in both editing and input
; mode and moves it to the right.
;; ED-RIGHT
L100C: LD A,(HL) ; fetch addressed character.
CP $0D ; is it carriage return ?
RET Z ; return if so to ED-LOOP
INC HL ; address next character
;; ED-CUR
L1011: LD ($5C5B),HL ; update K_CUR system variable
RET ; return to ED-LOOP
; --------------
; DELETE editing
; --------------
; This acts on the lower screen and deletes the character to left of
; cursor. If control characters are present these are deleted first
; leaving the naked parameter (0-7) which appears as a '?' except in the
; case of chr$ 6 which is the comma control character. It is not mandatory
; to delete these second characters.
;; ED-DELETE
L1015: CALL L1031 ; routine ED-EDGE moves cursor to left.
LD BC,$0001 ; of character to be deleted.
JP L19E8 ; to RECLAIM-2 reclaim the character.
; ------------------------------------------
; Ignore next 2 codes from key-input routine
; ------------------------------------------
; Since AT and TAB cannot be entered this point is never reached
; from the keyboard. If inputting from a tape device or network then
; the control and two following characters are ignored and processing
; continues as if a carriage return had been received.
; Here, perhaps, another Spectrum has said print #15; AT 0,0; "This is yellow"
; and this one is interpreting input #15; a$.
;; ED-IGNORE
L101E: CALL L15D4 ; routine WAIT-KEY to ignore keystroke.
CALL L15D4 ; routine WAIT-KEY to ignore next key.
; -------------
; Enter/newline
; -------------
; The enter key has been pressed to have BASIC line or input accepted.
;; ED-ENTER
L1024: POP HL ; discard address ED-LOOP
POP HL ; drop address ED-ERROR
;; ED-END
L1026: POP HL ; the previous value of ERR_SP
LD ($5C3D),HL ; is restored to ERR_SP system variable
BIT 7,(IY+$00) ; is ERR_NR $FF (= 'OK') ?
RET NZ ; return if so
LD SP,HL ; else put error routine on stack
RET ; and make an indirect jump to it.
; -----------------------------
; Move cursor left when editing
; -----------------------------
; This routine moves the cursor left. The complication is that it must
; not position the cursor between control codes and their parameters.
; It is further complicated in that it deals with TAB and AT characters
; which are never present from the keyboard.
; The method is to advance from the beginning of the line each time,
; jumping one, two, or three characters as necessary saving the original
; position at each jump in DE. Once it arrives at the cursor then the next
; legitimate leftmost position is in DE.
;; ED-EDGE
L1031: SCF ; carry flag must be set to call the nested
CALL L1195 ; subroutine SET-DE.
; if input then DE=WORKSP
; if editing then DE=E_LINE
SBC HL,DE ; subtract address from start of line
ADD HL,DE ; and add back.
INC HL ; adjust for carry.
POP BC ; drop return address
RET C ; return to ED-LOOP if already at left
; of line.
PUSH BC ; resave return address - ED-LOOP.
LD B,H ; transfer HL - cursor address
LD C,L ; to BC register pair.
; at this point DE addresses start of line.
;; ED-EDGE-1
L103E: LD H,D ; transfer DE - leftmost pointer
LD L,E ; to HL
INC HL ; address next leftmost character to
; advance position each time.
LD A,(DE) ; pick up previous in A
AND $F0 ; lose the low bits
CP $10 ; is it INK to TAB $10-$1F ?
; that is, is it followed by a parameter ?
JR NZ,L1051 ; to ED-EDGE-2 if not
; HL has been incremented once
INC HL ; address next as at least one parameter.
; in fact since 'tab' and 'at' cannot be entered the next section seems
; superfluous.
; The test will always fail and the jump to ED-EDGE-2 will be taken.
LD A,(DE) ; reload leftmost character
SUB $17 ; decimal 23 ('tab')
ADC A,$00 ; will be 0 for 'tab' and 'at'.
JR NZ,L1051 ; forward to ED-EDGE-2 if not
; HL has been incremented twice
INC HL ; increment a third time for 'at'/'tab'
;; ED-EDGE-2
L1051: AND A ; prepare for true subtraction
SBC HL,BC ; subtract cursor address from pointer
ADD HL,BC ; and add back
; Note when HL matches the cursor position BC,
; there is no carry and the previous
; position is in DE.
EX DE,HL ; transfer result to DE if looping again.
; transfer DE to HL to be used as K-CUR
; if exiting loop.
JR C,L103E ; back to ED-EDGE-1 if cursor not matched.
RET ; return.
; -----------------
; Cursor up editing
; -----------------
; The main screen displays part of the BASIC program and the user wishes
; to move up one line scrolling if necessary.
; This has no alternative use in input mode.
;; ED-UP
L1059: BIT 5,(IY+$37) ; test FLAGX - input mode ?
RET NZ ; return if not in editor - to ED-LOOP.
LD HL,($5C49) ; get current line from E_PPC
CALL L196E ; routine LINE-ADDR gets address
EX DE,HL ; and previous in DE
CALL L1695 ; routine LINE-NO gets prev line number
LD HL,$5C4A ; set HL to E_PPC_hi as next routine stores
; top first.
CALL L191C ; routine LN-STORE loads DE value to HL
; high byte first - E_PPC_lo takes E
; this branch is also taken from ed-down.
;; ED-LIST
L106E: CALL L1795 ; routine AUTO-LIST lists to upper screen
; including adjusted current line.
LD A,$00 ; select lower screen again
JP L1601 ; exit via CHAN-OPEN to ED-LOOP
; --------------------------------
; Use of symbol and graphics codes
; --------------------------------
; These will not be encountered with the keyboard but would be handled
; otherwise as follows.
; As noted earlier, Vickers says there should have been an entry in
; the KEYS table for chr$ 6 which also pointed here.
; If, for simplicity, two Spectrums were both using #15 as a bi-directional
; channel connected to each other:-
; then when the other Spectrum has said PRINT #15; x, y
; input #15; i ; j would treat the comma control as a newline and the
; control would skip to input j.
; You can get round the missing chr$ 6 handler by sending multiple print
; items separated by a newline '.
; chr$14 would have the same functionality.
; This is chr$ 14.
;; ED-SYMBOL
L1076: BIT 7,(IY+$37) ; test FLAGX - is this INPUT LINE ?
JR Z,L1024 ; back to ED-ENTER if not to treat as if
; enter had been pressed.
; else continue and add code to buffer.
; Next is chr$ 15
; Note that ADD-CHAR precedes the table so we can't offset to it directly.
;; ED-GRAPH
L107C: JP L0F81 ; jump back to ADD-CHAR
; --------------------
; Editor error routine
; --------------------
; If an error occurs while editing, or inputting, then ERR_SP
; points to the stack location holding address ED_ERROR.
;; ED-ERROR
L107F: BIT 4,(IY+$30) ; test FLAGS2 - is K channel in use ?
JR Z,L1026 ; back to ED-END if not.
; but as long as we're editing lines or inputting from the keyboard, then
; we've run out of memory so give a short rasp.
LD (IY+$00),$FF ; reset ERR_NR to 'OK'.
LD D,$00 ; prepare for beeper.
LD E,(IY-$02) ; use RASP value.
LD HL,$1A90 ; set the pitch - or tone period.
CALL L03B5 ; routine BEEPER emits a warning rasp.
JP L0F30 ; to ED-AGAIN to re-stack address of
; this routine and make ERR_SP point to it.
; ---------------------
; Clear edit/work space
; ---------------------
; The editing area or workspace is cleared depending on context.
; This is called from ED-EDIT to clear workspace if edit key is
; used during input, to clear editing area if no program exists
; and to clear editing area prior to copying the edit line to it.
; It is also used by the error routine to clear the respective
; area depending on FLAGX.
;; CLEAR-SP
L1097: PUSH HL ; preserve HL
CALL L1190 ; routine SET-HL
; if in edit HL = WORKSP-1, DE = E_LINE
; if in input HL = STKBOT, DE = WORKSP
DEC HL ; adjust
CALL L19E5 ; routine RECLAIM-1 reclaims space
LD ($5C5B),HL ; set K_CUR to start of empty area
LD (IY+$07),$00 ; set MODE to 'KLC'
POP HL ; restore HL.
RET ; return.
; ----------------------------
; THE 'KEYBOARD INPUT' ROUTINE
; ----------------------------
; This is the service routine for the input stream of the keyboard channel 'K'.
;; KEY-INPUT
L10A8: BIT 3,(IY+$02) ; test TV_FLAG - has a key been pressed in
; editor ?
CALL NZ,L111D ; routine ED-COPY, if so, to reprint the lower
; screen at every keystroke/mode change.
AND A ; clear carry flag - required exit condition.
BIT 5,(IY+$01) ; test FLAGS - has a new key been pressed ?
RET Z ; return if not. >>
LD A,($5C08) ; system variable LASTK will hold last key -
; from the interrupt routine.
RES 5,(IY+$01) ; update FLAGS - reset the new key flag.
PUSH AF ; save the input character.
BIT 5,(IY+$02) ; test TV_FLAG - clear lower screen ?
CALL NZ,L0D6E ; routine CLS-LOWER if so.
POP AF ; restore the character code.
CP $20 ; if space or higher then
JR NC,L111B ; forward to KEY-DONE2 and return with carry
; set to signal key-found.
CP $10 ; with 16d INK and higher skip
JR NC,L10FA ; forward to KEY-CONTR.
CP $06 ; for 6 - 15d
JR NC,L10DB ; skip forward to KEY-M-CL to handle Modes
; and CapsLock.
; that only leaves 0-5, the flash bright inverse switches.
LD B,A ; save character in B
AND $01 ; isolate the embedded parameter (0/1).
LD C,A ; and store in C
LD A,B ; re-fetch copy (0-5)
RRA ; halve it 0, 1 or 2.
ADD A,$12 ; add 18d gives 'flash', 'bright'
; and 'inverse'.
JR L1105 ; forward to KEY-DATA with the
; parameter (0/1) in C.
; ---
; Now separate capslock 06 from modes 7-15.
;; KEY-M-CL
L10DB: JR NZ,L10E6 ; forward to KEY-MODE if not 06 (capslock)
LD HL,$5C6A ; point to FLAGS2
LD A,$08 ; value 00001000
XOR (HL) ; toggle BIT 3 of FLAGS2 the capslock bit
LD (HL),A ; and store result in FLAGS2 again.
JR L10F4 ; forward to KEY-FLAG to signal no-key.
; ---
;; KEY-MODE
L10E6: CP $0E ; compare with chr 14d
RET C ; return with carry set "key found" for
; codes 7 - 13d leaving 14d and 15d
; which are converted to mode codes.
SUB $0D ; subtract 13d leaving 1 and 2
; 1 is 'E' mode, 2 is 'G' mode.
LD HL,$5C41 ; address the MODE system variable.
CP (HL) ; compare with existing value before
LD (HL),A ; inserting the new value.
JR NZ,L10F4 ; forward to KEY-FLAG if it has changed.
LD (HL),$00 ; else make MODE zero - KLC mode
; Note. while in Extended/Graphics mode,
; the Extended Mode/Graphics key is pressed
; again to get out.
;; KEY-FLAG
L10F4: SET 3,(IY+$02) ; update TV_FLAG - show key state has changed
CP A ; clear carry and reset zero flags -
; no actual key returned.
RET ; make the return.
; ---
; now deal with colour controls - 16-23 ink, 24-31 paper
;; KEY-CONTR
L10FA: LD B,A ; make a copy of character.
AND $07 ; mask to leave bits 0-7
LD C,A ; and store in C.
LD A,$10 ; initialize to 16d - INK.
BIT 3,B ; was it paper ?
JR NZ,L1105 ; forward to KEY-DATA with INK 16d and
; colour in C.
INC A ; else change from INK to PAPER (17d) if so.
;; KEY-DATA
L1105: LD (IY-$2D),C ; put the colour (0-7)/state(0/1) in KDATA
LD DE,L110D ; address: KEY-NEXT will be next input stream
JR L1113 ; forward to KEY-CHAN to change it ...
; ---
; ... so that INPUT_AD directs control to here at next call to WAIT-KEY
;; KEY-NEXT
L110D: LD A,($5C0D) ; pick up the parameter stored in KDATA.
LD DE,L10A8 ; address: KEY-INPUT will be next input stream
; continue to restore default channel and
; make a return with the control code.
;; KEY-CHAN
L1113: LD HL,($5C4F) ; address start of CHANNELS area using CHANS
; system variable.
; Note. One might have expected CURCHL to
; have been used.
INC HL ; step over the
INC HL ; output address
LD (HL),E ; and update the input
INC HL ; routine address for
LD (HL),D ; the next call to WAIT-KEY.
;; KEY-DONE2
L111B: SCF ; set carry flag to show a key has been found
RET ; and return.
; --------------------
; Lower screen copying
; --------------------
; This subroutine is called whenever the line in the editing area or
; input workspace is required to be printed to the lower screen.
; It is by calling this routine after any change that the cursor, for
; instance, appears to move to the left.
; Remember the edit line will contain characters and tokens
; e.g. "1000 LET a=1" is 8 characters.
;; ED-COPY
L111D: CALL L0D4D ; routine TEMPS sets temporary attributes.
RES 3,(IY+$02) ; update TV_FLAG - signal no change in mode
RES 5,(IY+$02) ; update TV_FLAG - signal don't clear lower
; screen.
LD HL,($5C8A) ; fetch SPOSNL
PUSH HL ; and save on stack.
LD HL,($5C3D) ; fetch ERR_SP
PUSH HL ; and save also
LD HL,L1167 ; address: ED-FULL
PUSH HL ; is pushed as the error routine
LD ($5C3D),SP ; and ERR_SP made to point to it.
LD HL,($5C82) ; fetch ECHO_E
PUSH HL ; and push also
SCF ; set carry flag to control SET-DE
CALL L1195 ; call routine SET-DE
; if in input DE = WORKSP
; if in edit DE = E_LINE
EX DE,HL ; start address to HL
CALL L187D ; routine OUT-LINE2 outputs entire line up to
; carriage return including initial
; characterized line number when present.
EX DE,HL ; transfer new address to DE
CALL L18E1 ; routine OUT-CURS considers a
; terminating cursor.
LD HL,($5C8A) ; fetch updated SPOSNL
EX (SP),HL ; exchange with ECHO_E on stack
EX DE,HL ; transfer ECHO_E to DE
CALL L0D4D ; routine TEMPS to re-set attributes
; if altered.
; the lower screen was not cleared, at the outset, so if deleting then old
; text from a previous print may follow this line and requires blanking.
;; ED-BLANK
L1150: LD A,($5C8B) ; fetch SPOSNL_hi is current line
SUB D ; compare with old
JR C,L117C ; forward to ED-C-DONE if no blanking
JR NZ,L115E ; forward to ED-SPACES if line has changed
LD A,E ; old column to A
SUB (IY+$50) ; subtract new in SPOSNL_lo
JR NC,L117C ; forward to ED-C-DONE if no backfilling.
;; ED-SPACES
L115E: LD A,$20 ; prepare a space.
PUSH DE ; save old line/column.
CALL L09F4 ; routine PRINT-OUT prints a space over
; any text from previous print.
; Note. Since the blanking only occurs when
; using $09F4 to print to the lower screen,
; there is no need to vector via a RST 10
; and we can use this alternate set.
POP DE ; restore the old line column.
JR L1150 ; back to ED-BLANK until all old text blanked.
; -------------------------------
; THE 'EDITOR-FULL' ERROR ROUTINE
; -------------------------------
; This is the error routine addressed by ERR_SP. This is not for the out of
; memory situation as we're just printing. The pitch and duration are exactly
; the same as used by ED-ERROR from which this has been augmented. The
; situation is that the lower screen is full and a rasp is given to suggest
; that this is perhaps not the best idea you've had that day.
;; ED-FULL
L1167: LD D,$00 ; prepare to moan.
LD E,(IY-$02) ; fetch RASP value.
LD HL,$1A90 ; set pitch or tone period.
CALL L03B5 ; routine BEEPER.
LD (IY+$00),$FF ; clear ERR_NR.
LD DE,($5C8A) ; fetch SPOSNL.
JR L117E ; forward to ED-C-END
; -------
; the exit point from line printing continues here.
;; ED-C-DONE
L117C: POP DE ; fetch new line/column.
POP HL ; fetch the error address.
; the error path rejoins here.
;; ED-C-END
L117E: POP HL ; restore the old value of ERR_SP.
LD ($5C3D),HL ; update the system variable ERR_SP
POP BC ; old value of SPOSN_L
PUSH DE ; save new value
CALL L0DD9 ; routine CL-SET and PO-STORE
; update ECHO_E and SPOSN_L from BC
POP HL ; restore new value
LD ($5C82),HL ; and overwrite ECHO_E
LD (IY+$26),$00 ; make error pointer X_PTR_hi out of bounds
RET ; return
; -----------------------------------------------
; Point to first and last locations of work space
; -----------------------------------------------
; These two nested routines ensure that the appropriate pointers are
; selected for the editing area or workspace. The routines that call
; these routines are designed to work on either area.
; this routine is called once
;; SET-HL
L1190: LD HL,($5C61) ; fetch WORKSP to HL.
DEC HL ; point to last location of editing area.
AND A ; clear carry to limit exit points to first
; or last.
; this routine is called with carry set and exits at a conditional return.
;; SET-DE
L1195: LD DE,($5C59) ; fetch E_LINE to DE
BIT 5,(IY+$37) ; test FLAGX - Input Mode ?
RET Z ; return now if in editing mode
LD DE,($5C61) ; fetch WORKSP to DE
RET C ; return if carry set ( entry = set-de)
LD HL,($5C63) ; fetch STKBOT to HL as well
RET ; and return (entry = set-hl (in input))
; -----------------------------------
; THE 'REMOVE FLOATING POINT' ROUTINE
; -----------------------------------
; When a BASIC LINE or the INPUT BUFFER is parsed any numbers will have
; an invisible chr 14d inserted after them and the 5-byte integer or
; floating point form inserted after that. Similar invisible value holders
; are also created after the numeric and string variables in a DEF FN list.
; This routine removes these 'compiled' numbers from the edit line or
; input workspace.
;; REMOVE-FP
L11A7: LD A,(HL) ; fetch character
CP $0E ; is it the CHR$ 14 number marker ?
LD BC,$0006 ; prepare to strip six bytes
CALL Z,L19E8 ; routine RECLAIM-2 reclaims bytes if CHR$ 14.
LD A,(HL) ; reload next (or same) character
INC HL ; and advance address
CP $0D ; end of line or input buffer ?
JR NZ,L11A7 ; back to REMOVE-FP until entire line done.
RET ; return.
|
//==============================================================================
// Copyright 2003 - 2013 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2013 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#include <nt2/trigonometric/include/functions/asin.hpp>
#include <boost/simd/sdk/simd/native.hpp>
#include <nt2/sdk/bench/benchmark.hpp>
#include <nt2/sdk/bench/timing.hpp>
#include <boost/dispatch/meta/as_integer.hpp>
#include <nt2/include/constants/mone.hpp>
#include <nt2/include/constants/one.hpp>
using nt2::tag::asin_;
#define RS(T,V1,V2) (T, (V1) ,(V2))
namespace n1 {
typedef float T;
typedef boost::simd::meta::vector_of<T, BOOST_SIMD_BYTES/sizeof(T)>::type vT;
NT2_TIMING(asin_,(RS(vT,nt2::Mone<T>(),nt2::One<T>())))
}
namespace n2 {
typedef double T;
typedef boost::simd::meta::vector_of<T, BOOST_SIMD_BYTES/sizeof(T)>::type vT;
NT2_TIMING(asin_,(RS(vT,nt2::Mone<T>(),nt2::One<T>())))
}
#undef RS
|
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/hhbbc/parse.h"
#include <thread>
#include <unordered_map>
#include <map>
#include <boost/variant.hpp>
#include <algorithm>
#include <iterator>
#include <memory>
#include <set>
#include <unordered_set>
#include <utility>
#include <vector>
#include <folly/gen/Base.h>
#include <folly/gen/String.h>
#include <folly/Memory.h>
#include <folly/ScopeGuard.h>
#include <folly/sorted_vector_types.h>
#include "hphp/runtime/base/repo-auth-type-codec.h"
#include "hphp/runtime/base/repo-auth-type.h"
#include "hphp/runtime/ext/std/ext_std_misc.h"
#include "hphp/runtime/vm/func-emitter.h"
#include "hphp/runtime/vm/hhbc-codec.h"
#include "hphp/runtime/vm/preclass-emitter.h"
#include "hphp/runtime/vm/type-alias-emitter.h"
#include "hphp/runtime/vm/unit-emitter.h"
#include "hphp/hhbbc/cfg.h"
#include "hphp/hhbbc/eval-cell.h"
#include "hphp/hhbbc/func-util.h"
#include "hphp/hhbbc/optimize.h"
#include "hphp/hhbbc/representation.h"
#include "hphp/hhbbc/unit-util.h"
#include "hphp/hhbbc/wide-func.h"
namespace HPHP::HHBBC {
TRACE_SET_MOD(hhbbc_parse);
namespace {
//////////////////////////////////////////////////////////////////////
const StaticString s_Closure("Closure");
const StaticString s_toString("__toString");
const StaticString s_Stringish("Stringish");
const StaticString s_StringishObject("StringishObject");
const StaticString s_XHPChild("XHPChild");
const StaticString s_attr_Deprecated("__Deprecated");
const StaticString s___NoContextSensitiveAnalysis(
"__NoContextSensitiveAnalysis");
//////////////////////////////////////////////////////////////////////
struct ParseUnitState {
std::atomic<uint32_t>& nextFuncId;
/*
* This is computed once for each unit and stashed here. We support
* having either a SourceLocTable or a LineTable. If we're
* optimizing a repo that was already created by hphpc, it won't
* have the full SourceLocTable information in it, so we're limited
* to line numbers.
*/
boost::variant< SourceLocTable
, LineTable
> srcLocInfo;
/*
* Map from Closure index to the function(s) containing their
* associated CreateCl opcode(s).
*/
hphp_fast_map<
int32_t,
hphp_fast_set<php::Func*>
> createClMap;
struct SrcLocHash {
size_t operator()(const php::SrcLoc& sl) const {
auto const h1 = ((size_t)sl.start.col << 32) | sl.start.line;
auto const h2 = ((size_t)sl.past.col << 32) | sl.past.line;
return hash_int64_pair(h1, h2);
}
};
hphp_fast_map<php::SrcLoc, int32_t, SrcLocHash> srcLocs;
/*
* Set of functions that should be processed in the constant
* propagation pass.
*
* Must include every function with a DefCns for correctness; cinit,
* pinit and sinit functions are added to improve overall
* performance.
*/
hphp_fast_set<php::Func*> constPassFuncs;
};
//////////////////////////////////////////////////////////////////////
std::set<Offset> findBasicBlocks(const FuncEmitter& fe) {
std::set<Offset> blockStarts;
auto markBlock = [&] (Offset off) { blockStarts.insert(off); };
// Each entry point for a DV funclet is the start of a basic
// block.
for (auto& param : fe.params) {
if (param.hasDefaultValue()) markBlock(param.funcletOff);
}
// The main entry point is also a basic block start.
markBlock(0);
bool traceBc = false;
/*
* For each instruction, add it to the set if it must be the start
* of a block. It is the start of a block if it is:
*
* - A jump target
*
* - Immediatelly following a control flow instruction, other than
* a call.
*/
auto offset = 0;
for (;;) {
auto const bc = fe.bc();
auto const pc = bc + offset;
auto const nextOff = offset + instrLen(pc);
auto const atLast = nextOff == fe.bcPos();
auto const op = peek_op(pc);
auto const breaksBB =
instrIsNonCallControlFlow(op) ||
instrFlags(op) & TF ||
(isFCall(op) && !instrJumpOffsets(pc).empty());
if (options.TraceBytecodes.count(op)) traceBc = true;
if (breaksBB && !atLast) {
markBlock(nextOff);
}
auto const targets = instrJumpTargets(bc, offset);
for (auto const& target : targets) markBlock(target);
offset = nextOff;
if (atLast) break;
}
/*
* Find blocks associated with exception handlers.
*
* - The start of each EH protected region begins a block.
*
* - The instruction immediately after the end of any
* EH protected region begins a block.
*
* - Each catch entry point begins a block.
*
* - The instruction immediately after the end of any
* catch region begins a block.
*/
for (auto& eh : fe.ehtab) {
markBlock(eh.m_base);
markBlock(eh.m_past);
markBlock(eh.m_handler);
if (eh.m_end != kInvalidOffset) {
markBlock(eh.m_end);
}
}
// Now, each interval in blockStarts delinates a basic block.
blockStarts.insert(fe.bcPos());
if (traceBc) {
FTRACE(0, "TraceBytecode (parse): {}::{} in {}\n",
fe.pce() ? fe.pce()->name()->data() : "",
fe.name, fe.ue().m_filepath);
}
return blockStarts;
}
struct ExnTreeInfo {
/*
* Map from EHEnt to the ExnNode that will represent exception
* behavior in that region.
*/
hphp_fast_map<const EHEnt*,ExnNodeId> ehMap;
};
template<class FindBlock>
ExnTreeInfo build_exn_tree(const FuncEmitter& fe,
php::Func& func,
FindBlock findBlock) {
ExnTreeInfo ret;
func.exnNodes.reserve(fe.ehtab.size());
for (auto& eh : fe.ehtab) {
auto const catchBlk = findBlock(eh.m_handler, true);
auto node = php::ExnNode{};
node.idx = func.exnNodes.size();
node.parent = NoExnNodeId;
node.depth = 1; // 0 depth means no ExnNode
node.region = php::CatchRegion { catchBlk, eh.m_iterId };
ret.ehMap[&eh] = node.idx;
if (eh.m_parentIndex != -1) {
auto it = ret.ehMap.find(&fe.ehtab[eh.m_parentIndex]);
assertx(it != end(ret.ehMap));
assertx(it->second < node.idx);
node.parent = it->second;
auto& parent = func.exnNodes[node.parent];
node.depth = parent.depth + 1;
parent.children.emplace_back(node.idx);
}
func.exnNodes.emplace_back(std::move(node));
}
return ret;
}
template<class T> T decode(PC& pc) {
auto const ret = *reinterpret_cast<const T*>(pc);
pc += sizeof ret;
return ret;
}
template<class T> void decode(PC& pc, T& val) {
val = decode<T>(pc);
}
MKey make_mkey(const php::Func& /*func*/, MemberKey mk) {
switch (mk.mcode) {
case MEL: case MPL:
return MKey{mk.mcode, mk.local, mk.rop};
case MEC: case MPC:
return MKey{mk.mcode, mk.iva, mk.rop};
case MET: case MPT: case MQT:
return MKey{mk.mcode, mk.litstr, mk.rop};
case MEI:
return MKey{mk.mcode, mk.int64, mk.rop};
case MW:
return MKey{};
}
not_reached();
}
template<class FindBlock>
void populate_block(ParseUnitState& puState,
const FuncEmitter& fe,
php::Func& func,
php::Block& blk,
PC pc,
PC const past,
bool& sawCreateCl,
FindBlock findBlock) {
auto const& ue = fe.ue();
auto decode_stringvec = [&] {
auto const vecLen = decode_iva(pc);
CompactVector<LSString> keys;
keys.reserve(vecLen);
for (auto i = size_t{0}; i < vecLen; ++i) {
keys.push_back(ue.lookupLitstr(decode<int32_t>(pc)));
}
return keys;
};
auto decode_switch = [&] (PC opPC) {
SwitchTab ret;
auto const vecLen = decode_iva(pc);
for (int32_t i = 0; i < vecLen; ++i) {
ret.push_back(findBlock(
opPC + decode<Offset>(pc) - fe.bc()
));
}
return ret;
};
auto decode_sswitch = [&] (PC opPC) {
SSwitchTab ret;
auto const vecLen = decode_iva(pc);
for (int32_t i = 0; i < vecLen - 1; ++i) {
auto const id = decode<Id>(pc);
auto const offset = decode<Offset>(pc);
ret.emplace_back(ue.lookupLitstr(id),
findBlock(opPC + offset - fe.bc()));
}
// Final case is the default, and must have a litstr id of -1.
DEBUG_ONLY auto const defId = decode<Id>(pc);
auto const defOff = decode<Offset>(pc);
assertx(defId == -1);
ret.emplace_back(nullptr, findBlock(opPC + defOff - fe.bc()));
return ret;
};
auto createcl = [&] (const Bytecode& b) {
sawCreateCl = true;
puState.createClMap[b.CreateCl.arg2].insert(&func);
};
#define IMM_BLA(n) auto targets = decode_switch(opPC);
#define IMM_SLA(n) auto targets = decode_sswitch(opPC);
#define IMM_IVA(n) auto arg##n = decode_iva(pc);
#define IMM_I64A(n) auto arg##n = decode<int64_t>(pc);
#define IMM_LA(n) auto loc##n = [&] { \
LocalId id = decode_iva(pc); \
always_assert(id < func.locals.size()); \
return id; \
}();
#define IMM_NLA(n) auto nloc##n = [&] { \
NamedLocal loc = decode_named_local(pc); \
always_assert(loc.id < func.locals.size());\
return loc; \
}();
#define IMM_ILA(n) auto loc##n = [&] { \
LocalId id = decode_iva(pc); \
always_assert(id < func.locals.size()); \
return id; \
}();
#define IMM_IA(n) auto iter##n = [&] { \
IterId id = decode_iva(pc); \
always_assert(id < func.numIters); \
return id; \
}();
#define IMM_DA(n) auto dbl##n = decode<double>(pc);
#define IMM_SA(n) auto str##n = ue.lookupLitstr(decode<Id>(pc));
#define IMM_RATA(n) auto rat = decodeRAT(ue, pc);
#define IMM_AA(n) auto arr##n = ue.lookupArray(decode<Id>(pc));
#define IMM_BA(n) assertx(next == past); \
auto target##n = findBlock( \
opPC + decode<Offset>(pc) - fe.bc());
#define IMM_OA_IMPL(n) subop##n; decode(pc, subop##n);
#define IMM_OA(type) type IMM_OA_IMPL
#define IMM_VSA(n) auto keys = decode_stringvec();
#define IMM_KA(n) auto mkey = make_mkey(func, decode_member_key(pc, &ue));
#define IMM_LAR(n) auto locrange = [&] { \
auto const range = decodeLocalRange(pc); \
always_assert(range.first + range.count \
<= func.locals.size()); \
return LocalRange { range.first, range.count }; \
}();
#define IMM_ITA(n) auto ita = decodeIterArgs(pc);
#define IMM_FCA(n) auto fca = [&] { \
auto const fca = decodeFCallArgs(op, pc, &ue); \
auto const numBytes = (fca.numArgs + 7) / 8; \
auto inoutArgs = fca.enforceInOut() \
? std::make_unique<uint8_t[]>(numBytes) \
: nullptr; \
if (inoutArgs) { \
memcpy(inoutArgs.get(), fca.inoutArgs, numBytes); \
} \
auto readonlyArgs = fca.enforceReadonly() \
? std::make_unique<uint8_t[]>(numBytes) \
: nullptr; \
if (readonlyArgs) { \
memcpy(readonlyArgs.get(), fca.readonlyArgs, numBytes); \
} \
auto const aeOffset = fca.asyncEagerOffset; \
auto const aeTarget = aeOffset != kInvalidOffset \
? findBlock(opPC + aeOffset - fe.bc()) \
: NoBlockId; \
assertx(aeTarget == NoBlockId || next == past); \
return FCallArgs(fca.flags, fca.numArgs, \
fca.numRets, std::move(inoutArgs), \
std::move(readonlyArgs), \
aeTarget, fca.context); \
}();
#define IMM_NA
#define IMM_ONE(x) IMM_##x(1)
#define IMM_TWO(x, y) IMM_##x(1) IMM_##y(2)
#define IMM_THREE(x, y, z) IMM_TWO(x, y) IMM_##z(3)
#define IMM_FOUR(x, y, z, n) IMM_THREE(x, y, z) IMM_##n(4)
#define IMM_FIVE(x, y, z, n, m) IMM_FOUR(x, y, z, n) IMM_##m(5)
#define IMM_SIX(x, y, z, n, m, o) IMM_FIVE(x, y, z, n, m) IMM_##o(6)
#define IMM_ARG(which, n) IMM_NAME_##which(n)
#define IMM_ARG_NA
#define IMM_ARG_ONE(x) IMM_ARG(x, 1)
#define IMM_ARG_TWO(x, y) IMM_ARG(x, 1), IMM_ARG(y, 2)
#define IMM_ARG_THREE(x, y, z) IMM_ARG(x, 1), IMM_ARG(y, 2), \
IMM_ARG(z, 3)
#define IMM_ARG_FOUR(x, y, z, l) IMM_ARG(x, 1), IMM_ARG(y, 2), \
IMM_ARG(z, 3), IMM_ARG(l, 4)
#define IMM_ARG_FIVE(x, y, z, l, m) IMM_ARG(x, 1), IMM_ARG(y, 2), \
IMM_ARG(z, 3), IMM_ARG(l, 4), \
IMM_ARG(m, 5)
#define IMM_ARG_SIX(x, y, z, l, m, n) IMM_ARG(x, 1), IMM_ARG(y, 2), \
IMM_ARG(z, 3), IMM_ARG(l, 4), \
IMM_ARG(m, 5), IMM_ARG(n, 6)
#define O(opcode, imms, inputs, outputs, flags) \
case Op::opcode: \
{ \
auto b = [&] () -> Bytecode { \
IMM_##imms /*these two macros advance the pc as required*/ \
if (isTypeAssert(op)) return bc::Nop {}; \
return bc::opcode { IMM_ARG_##imms }; \
}(); \
b.srcLoc = srcLocIx; \
if (Op::opcode == Op::CreateCl) createcl(b); \
blk.hhbcs.push_back(std::move(b)); \
assertx(pc == next); \
} \
break;
assertx(pc != past);
do {
auto const opPC = pc;
auto const next = pc + instrLen(opPC);
assertx(next <= past);
auto const srcLoc = match<php::SrcLoc>(
puState.srcLocInfo,
[&] (const SourceLocTable& tab) {
SourceLoc sloc;
if (SourceLocation::getLoc(tab, opPC - fe.bc(), sloc)) {
return php::SrcLoc {
{ static_cast<uint32_t>(sloc.line0),
static_cast<uint32_t>(sloc.char0) },
{ static_cast<uint32_t>(sloc.line1),
static_cast<uint32_t>(sloc.char1) }
};
}
return php::SrcLoc{};
},
[&] (const LineTable& tab) {
auto const line = SourceLocation::getLineNumber(tab, opPC - fe.bc());
if (line != -1) {
return php::SrcLoc {
{ static_cast<uint32_t>(line), 0 },
{ static_cast<uint32_t>(line), 0 },
};
};
return php::SrcLoc{};
}
);
auto const srcLocIx = puState.srcLocs.emplace(
srcLoc, puState.srcLocs.size()).first->second;
auto op = decode_op(pc);
switch (op) { OPCODES }
if (next == past) {
if (instrAllowsFallThru(op)) {
blk.fallthrough = findBlock(next - fe.bc());
}
}
pc = next;
} while (pc != past);
#undef O
#undef IMM_BLA
#undef IMM_SLA
#undef IMM_IVA
#undef IMM_I64A
#undef IMM_LA
#undef IMM_NLA
#undef IMM_ILA
#undef IMM_IA
#undef IMM_DA
#undef IMM_SA
#undef IMM_RATA
#undef IMM_AA
#undef IMM_BA
#undef IMM_OA_IMPL
#undef IMM_OA
#undef IMM_VSA
#undef IMM_LAR
#undef IMM_ITA
#undef IMM_FCA
#undef IMM_NA
#undef IMM_ONE
#undef IMM_TWO
#undef IMM_THREE
#undef IMM_FOUR
#undef IMM_FIVE
#undef IMM_ARG
#undef IMM_ARG_NA
#undef IMM_ARG_ONE
#undef IMM_ARG_TWO
#undef IMM_ARG_THREE
#undef IMM_ARG_FOUR
#undef IMM_ARG_FIVE
#undef IMM_ARG_SIX
/*
* If a block ends with an unconditional jump, change it to a
* fallthrough edge.
*
* If the jmp is the only instruction, convert it to a Nop, to avoid
* creating an empty block (we have an invariant that no blocks are
* empty).
*/
auto make_fallthrough = [&] {
blk.fallthrough = blk.hhbcs.back().Jmp.target1;
if (blk.hhbcs.size() == 1) {
blk.hhbcs.back() = bc_with_loc(blk.hhbcs.back().srcLoc, bc::Nop{});
} else {
blk.hhbcs.pop_back();
}
};
switch (blk.hhbcs.back().op) {
case Op::Jmp: make_fallthrough(); break;
case Op::JmpNS: make_fallthrough(); blk.fallthroughNS = true; break;
default: break;
}
}
template<class FindBlk>
void link_entry_points(php::Func& func,
const FuncEmitter& fe,
FindBlk findBlock) {
func.dvEntries.resize(fe.params.size(), NoBlockId);
for (size_t i = 0, sz = fe.params.size(); i < sz; ++i) {
if (fe.params[i].hasDefaultValue()) {
auto const dv = findBlock(fe.params[i].funcletOff);
func.params[i].dvEntryPoint = dv;
func.dvEntries[i] = dv;
}
}
func.mainEntry = findBlock(0);
}
void build_cfg(ParseUnitState& puState,
php::Func& func,
const FuncEmitter& fe) {
auto const blockStarts = findBasicBlocks(fe);
FTRACE(3, " blocks are at: {}\n",
[&]() -> std::string {
using namespace folly::gen;
return from(blockStarts)
| eachTo<std::string>()
| unsplit<std::string>(" ");
}()
);
std::map<Offset,std::pair<BlockId, copy_ptr<php::Block>>> blockMap;
auto const bc = fe.bc();
auto findBlock = [&] (Offset off, bool catchEntry = false) {
auto& ent = blockMap[off];
if (!ent.second) {
auto blk = php::Block{};
ent.first = blockMap.size() - 1;
blk.exnNodeId = NoExnNodeId;
blk.catchEntry = catchEntry;
ent.second.emplace(std::move(blk));
} else if (catchEntry) {
ent.second.mutate()->catchEntry = true;
}
return ent.first;
};
auto exnTreeInfo = build_exn_tree(fe, func, findBlock);
hphp_fast_map<BlockId, std::pair<int, int>> predSuccCounts;
bool sawCreateCl = false;
for (auto it = begin(blockStarts);
std::next(it) != end(blockStarts);
++it) {
auto const bid = findBlock(*it);
auto const block = blockMap[*it].second.mutate();
auto const bcStart = bc + *it;
auto const bcStop = bc + *std::next(it);
if (auto const eh = Func::findEH(fe.ehtab, *it)) {
auto it = exnTreeInfo.ehMap.find(eh);
assertx(it != end(exnTreeInfo.ehMap));
block->exnNodeId = it->second;
block->throwExit = func.exnNodes[it->second].region.catchEntry;
}
populate_block(puState, fe, func, *block, bcStart, bcStop,
sawCreateCl, findBlock);
forEachNonThrowSuccessor(*block, [&] (BlockId blkId) {
predSuccCounts[blkId].first++;
predSuccCounts[bid].second++;
});
}
func.hasCreateCl = sawCreateCl;
link_entry_points(func, fe, findBlock);
auto mf = php::WideFunc::mut(&func);
mf.blocks().resize(blockMap.size());
for (auto& kv : blockMap) {
auto const blk = kv.second.second.mutate();
auto const id = kv.second.first;
blk->multiSucc = predSuccCounts[id].second > 1;
blk->multiPred = predSuccCounts[id].first > 1;
blk->hhbcs.shrink_to_fit();
mf.blocks()[id] = std::move(kv.second.second);
}
}
void add_frame_variables(php::Func& func, const FuncEmitter& fe) {
for (auto& param : fe.params) {
func.params.push_back(
php::Param {
param.defaultValue,
NoBlockId,
param.typeConstraint,
param.userType,
param.upperBounds,
param.userAttributes,
param.phpCode,
param.builtinType,
param.isInOut(),
param.isReadonly(),
param.isVariadic()
}
);
}
func.locals.reserve(fe.numLocals());
for (LocalId id = 0; id < fe.numLocals(); ++id) {
func.locals.push_back({
.name = nullptr,
.id = id,
.killed = false,
.nameId = id,
.unusedName = false
});
}
for (auto& kv : fe.localNameMap()) {
func.locals[kv.second].name = kv.first;
}
func.numIters = fe.numIterators();
}
const StaticString
s_construct("__construct"),
s_DynamicallyCallable("__DynamicallyCallable");
std::unique_ptr<php::Func> parse_func(ParseUnitState& puState,
php::Unit* unit,
php::Class* cls,
const FuncEmitter& fe) {
if (fe.hasSourceLocInfo()) {
puState.srcLocInfo = fe.createSourceLocTable();
} else {
puState.srcLocInfo = fe.lineTable();
}
FTRACE(2, " func: {}\n",
fe.name->data() && *fe.name->data() ? fe.name->data() : "pseudomain");
auto ret = std::make_unique<php::Func>();
ret->idx = puState.nextFuncId.fetch_add(1, std::memory_order_relaxed);
ret->name = fe.name;
ret->srcInfo = php::SrcInfo { fe.getLocation(),
fe.docComment };
ret->unit = unit;
ret->cls = cls;
ret->attrs = static_cast<Attr>((fe.attrs & ~AttrNoOverride) |
AttrUnique | AttrPersistent);
// We do not support AttrInterceptable in hhbbc so make sure it is not set
always_assert((ret->attrs & AttrInterceptable) == 0);
ret->userAttributes = fe.userAttributes;
ret->returnUserType = fe.retUserType;
ret->retTypeConstraint = fe.retTypeConstraint;
ret->hasParamsWithMultiUBs = fe.hasParamsWithMultiUBs;
ret->hasReturnWithMultiUBs = fe.hasReturnWithMultiUBs;
ret->returnUBs = fe.retUpperBounds;
ret->originalFilename = fe.originalFilename;
ret->originalClass = ret->cls;
ret->isClosureBody = fe.isClosureBody;
ret->isAsync = fe.isAsync;
ret->isGenerator = fe.isGenerator;
ret->isPairGenerator = fe.isPairGenerator;
ret->isMemoizeWrapper = fe.isMemoizeWrapper;
ret->isMemoizeWrapperLSB = fe.isMemoizeWrapperLSB;
ret->numClosures = fe.numClosures();
ret->isMemoizeImpl = Func::isMemoizeImplName(fe.name);
ret->isReified = fe.userAttributes.find(s___Reified.get()) !=
fe.userAttributes.end();
ret->isReadonlyReturn = fe.attrs & AttrReadonlyReturn;
ret->isReadonlyThis = fe.attrs & AttrReadonlyThis;
ret->noContextSensitiveAnalysis = fe.userAttributes.find(
s___NoContextSensitiveAnalysis.get()) != fe.userAttributes.end();
ret->hasInOutArgs = [&] {
for (auto& a : fe.params) if (a.isInOut()) return true;
return false;
}();
// Assume true, will be updated in build_cfg().
ret->hasCreateCl = true;
auto const coeffectsInfo = getCoeffectsInfoFromList(
fe.staticCoeffects, cls && fe.name == s_construct.get());
ret->requiredCoeffects = coeffectsInfo.first.toRequired();
ret->coeffectEscapes = coeffectsInfo.second;
for (auto& name : fe.staticCoeffects) ret->staticCoeffects.push_back(name);
for (auto& rule : fe.coeffectRules) ret->coeffectRules.push_back(rule);
ret->sampleDynamicCalls = [&] {
if (!(fe.attrs & AttrDynamicallyCallable)) return false;
auto const it = fe.userAttributes.find(s_DynamicallyCallable.get());
if (it == fe.userAttributes.end()) return false;
assertx(isArrayLikeType(type(it->second)));
auto const rate = val(it->second).parr->get(int64_t(0));
if (!isIntType(type(rate)) || val(rate).num < 0) return false;
ret->attrs = Attr(ret->attrs & ~AttrDynamicallyCallable);
return true;
}();
add_frame_variables(*ret, fe);
if (!RuntimeOption::ConstantFunctions.empty()) {
auto const name = [&] {
if (!cls) return fe.name->toCppString();
return folly::sformat("{}::{}", cls->name, ret->name);
}();
auto const it = RuntimeOption::ConstantFunctions.find(name);
if (it != RuntimeOption::ConstantFunctions.end()) {
ret->locals.resize(fe.params.size());
ret->numIters = 0;
ret->attrs |= AttrIsFoldable;
auto const mainEntry = BlockId{0};
auto blk = php::Block{};
blk.exnNodeId = NoExnNodeId;
blk.hhbcs = {gen_constant(it->second), bc::RetC {}};
auto mf = php::WideFunc::mut(ret.get());
mf.blocks().emplace_back(std::move(blk));
ret->dvEntries.resize(fe.params.size(), NoBlockId);
ret->mainEntry = mainEntry;
for (size_t i = 0, sz = fe.params.size(); i < sz; ++i) {
if (fe.params[i].hasDefaultValue()) {
ret->params[i].dvEntryPoint = mainEntry;
ret->dvEntries[i] = mainEntry;
}
}
return ret;
}
}
/*
* Builtin functions get some extra information. The returnType flag is only
* non-std::nullopt for these, but note that something may be a builtin and
* still have a std::nullopt return type.
*/
if (fe.isNative) {
auto const f = [&] () -> HPHP::Func* {
if (ret->cls) {
auto const cls = Class::lookup(ret->cls->name);
return cls ? cls->lookupMethod(ret->name) : nullptr;
} else {
return Func::lookupBuiltin(ret->name);
}
}();
ret->nativeInfo = std::make_unique<php::NativeInfo>();
ret->nativeInfo->returnType = fe.hniReturnType;
if (f && ret->params.size()) {
for (auto i = 0; i < ret->params.size(); i++) {
auto& pi = ret->params[i];
if (pi.isVariadic || !f->params()[i].hasDefaultValue()) continue;
if (pi.defaultValue.m_type == KindOfUninit &&
pi.phpCode != nullptr) {
auto res = eval_cell_value([&] {
auto val = f_constant(StrNR(pi.phpCode));
val.setEvalScalar();
return *val.asTypedValue();
});
if (!res) {
FTRACE(4, "Argument {} to {}: Failed to evaluate {}\n",
i, f->fullName(), pi.phpCode);
continue;
}
pi.defaultValue = *res;
}
}
}
if (!f || !f->nativeFuncPtr() ||
(f->userAttributes().count(
LowStringPtr(s_attr_Deprecated.get())))) {
ret->attrs |= AttrNoFCallBuiltin;
}
}
build_cfg(puState, *ret, fe);
return ret;
}
void parse_methods(ParseUnitState& puState,
php::Class* ret,
php::Unit* unit,
const PreClassEmitter& pce) {
std::unique_ptr<php::Func> cinit;
for (auto& me : pce.methods()) {
auto f = parse_func(puState, unit, ret, *me);
if (f->name == s_86cinit.get()) {
puState.constPassFuncs.insert(f.get());
cinit = std::move(f);
} else {
if (f->name == s_86pinit.get() ||
f->name == s_86sinit.get() ||
f->name == s_86linit.get()) {
puState.constPassFuncs.insert(f.get());
}
ret->methods.push_back(std::move(f));
}
}
if (cinit) ret->methods.push_back(std::move(cinit));
}
void add_stringish(php::Class* cls) {
// The runtime adds StringishObject to any class providing a __toString() function,
// so we mirror that here to make sure analysis of interfaces is correct.
// All StringishObjects are also XHPChild, so handle it here as well.
if (cls->attrs & AttrInterface && cls->name->isame(s_StringishObject.get())) {
return;
}
bool hasXHP = false;
for (auto& iface : cls->interfaceNames) {
if (iface->isame(s_StringishObject.get())) return;
if (iface->isame(s_XHPChild.get())) { hasXHP = true; }
}
const auto has_toString = std::any_of(
begin(cls->methods),
end(cls->methods),
[](const auto& func) { return func->name->isame(s_toString.get()); });
if (has_toString) {
FTRACE(2, "Adding Stringish, StringishObject and XHPChild to {}\n", cls->name->data());
cls->interfaceNames.push_back(s_StringishObject.get());
if (!hasXHP && !cls->name->isame(s_XHPChild.get())) {
cls->interfaceNames.push_back(s_XHPChild.get());
}
}
}
const StaticString s_DynamicallyConstructible("__DynamicallyConstructible");
std::unique_ptr<php::Class> parse_class(ParseUnitState& puState,
php::Unit* unit,
const PreClassEmitter& pce) {
FTRACE(2, " class: {}\n", pce.name()->data());
auto ret = std::make_unique<php::Class>();
ret->name = pce.name();
ret->srcInfo = php::SrcInfo { pce.getLocation(),
pce.docComment() };
ret->unit = unit;
ret->closureContextCls = nullptr;
ret->parentName = pce.parentName()->empty() ? nullptr
: pce.parentName();
ret->attrs = static_cast<Attr>((pce.attrs() & ~AttrNoOverride) |
AttrUnique | AttrPersistent);
ret->userAttributes = pce.userAttributes();
ret->id = pce.id();
ret->hasReifiedGenerics = ret->userAttributes.find(s___Reified.get()) !=
ret->userAttributes.end();
ret->hasConstProp = false;
ret->sampleDynamicConstruct = [&] {
if (!(ret->attrs & AttrDynamicallyConstructible)) return false;
auto const it = ret->userAttributes.find(s_DynamicallyConstructible.get());
if (it == ret->userAttributes.end()) return false;
assertx(isArrayLikeType(type(it->second)));
auto const rate = val(it->second).parr->get(int64_t(0));
if (!isIntType(type(rate)) || val(rate).num < 0) return false;
ret->attrs = Attr(ret->attrs & ~AttrDynamicallyConstructible);
return true;
}();
for (auto& iface : pce.interfaces()) {
ret->interfaceNames.push_back(iface);
}
for (auto& enumInclude : pce.enumIncludes()) {
ret->includedEnumNames.push_back(enumInclude);
}
copy(ret->usedTraitNames, pce.usedTraits());
copy(ret->traitPrecRules, pce.traitPrecRules());
copy(ret->traitAliasRules, pce.traitAliasRules());
copy(ret->requirements, pce.requirements());
parse_methods(puState, ret.get(), unit, pce);
add_stringish(ret.get());
auto& propMap = pce.propMap();
for (size_t idx = 0; idx < propMap.size(); ++idx) {
auto& prop = propMap[idx];
ret->properties.push_back(
php::Prop {
prop.name(),
prop.attrs(),
prop.userAttributes(),
prop.docComment(),
prop.userType(),
prop.typeConstraint(),
prop.upperBounds(),
prop.val()
}
);
if ((prop.attrs() & (AttrStatic | AttrIsConst)) == AttrIsConst) {
ret->hasConstProp = true;
}
}
auto& constMap = pce.constMap();
for (size_t idx = 0; idx < constMap.size(); ++idx) {
auto& cconst = constMap[idx];
ret->constants.push_back(
php::Const {
cconst.name(),
ret.get(),
cconst.valOption(),
cconst.coeffects(),
nullptr,
cconst.kind(),
php::Const::Invariance::None,
cconst.isAbstract(),
cconst.isFromTrait()
}
);
}
if (ret->attrs & AttrBuiltin) {
if (auto nativeConsts = Native::getClassConstants(ret->name)) {
for (auto const& cnsMap : *nativeConsts) {
TypedValueAux tvaux;
tvCopy(cnsMap.second, tvaux);
tvaux.constModifiers() = {};
ret->constants.push_back(
php::Const {
cnsMap.first,
ret.get(),
tvaux,
{},
nullptr,
ConstModifiers::Kind::Value,
php::Const::Invariance::None,
false,
false
}
);
}
}
}
ret->enumBaseTy = pce.enumBaseTy();
return ret;
}
//////////////////////////////////////////////////////////////////////
void assign_closure_context(const ParseUnitState&, php::Class*);
php::Class*
find_closure_context(const ParseUnitState& puState,
php::Func* createClFunc) {
if (auto const cls = createClFunc->cls) {
if (cls->parentName &&
cls->parentName->isame(s_Closure.get())) {
// We have a closure created by a closure's invoke method, which
// means it should inherit the outer closure's context, so we
// have to know that first.
assign_closure_context(puState, cls);
return cls->closureContextCls;
}
return cls;
}
return nullptr;
}
void assign_closure_context(const ParseUnitState& puState,
php::Class* clo) {
if (clo->closureContextCls) return;
auto clIt = puState.createClMap.find(clo->id);
if (clIt == end(puState.createClMap)) {
// Unused closure class. Technically not prohibited by the spec.
return;
}
/*
* Any route to the closure context must yield the same class, or
* things downstream won't understand. We try every route and
* assert they are all the same here.
*
* See bytecode.specification for CreateCl for the relevant
* invariants.
*/
always_assert(!clIt->second.empty());
auto it = begin(clIt->second);
auto const representative = find_closure_context(puState, *it);
if (debug) {
for (++it; it != end(clIt->second); ++it) {
assertx(find_closure_context(puState, *it) == representative);
}
}
clo->closureContextCls = representative;
}
void find_additional_metadata(const ParseUnitState& puState,
php::Unit* unit) {
for (auto& c : unit->classes) {
if (!c->parentName || !c->parentName->isame(s_Closure.get())) {
continue;
}
assign_closure_context(puState, c.get());
}
}
//////////////////////////////////////////////////////////////////////
}
std::unique_ptr<php::Constant> parse_constant(const Constant& c, php::Unit* unit) {
return std::unique_ptr<php::Constant>(new php::Constant{
unit,
c.name,
c.val,
c.attrs | AttrUnique | AttrPersistent
});
}
std::unique_ptr<php::TypeAlias> parse_type_alias(php::Unit* unit,
const TypeAliasEmitter& te) {
FTRACE(2, " type alias: {}\n", te.name()->data());
return std::unique_ptr<php::TypeAlias>(new php::TypeAlias {
unit,
php::SrcInfo { te.getLocation() },
te.name(),
te.value(),
te.attrs() | AttrUnique | AttrPersistent,
te.type(),
te.nullable(),
te.userAttributes(),
te.typeStructure(),
Array{}
});
}
void parse_unit(php::Program& prog, const UnitEmitter* uep) {
Trace::Bump bumper{Trace::hhbbc_parse, kSystemLibBump, uep->isASystemLib()};
FTRACE(2, "parse_unit {}\n", uep->m_filepath->data());
if (RuntimeOption::EvalAbortBuildOnVerifyError && !uep->check(false)) {
fprintf(
stderr,
"The unoptimized unit for %s did not pass verification, "
"bailing because Eval.AbortBuildOnVerifyError is set\n",
uep->m_filepath->data()
);
_Exit(1);
}
auto const& ue = *uep;
auto ret = std::make_unique<php::Unit>();
ret->filename = ue.m_filepath;
ret->metaData = ue.m_metaData;
ret->fileAttributes = ue.m_fileAttributes;
if (ue.m_fatalUnit) {
php::FatalInfo fi{ue.m_fatalLoc, ue.m_fatalOp, ue.m_fatalMsg};
ret->fatalInfo = std::make_unique<php::FatalInfo>(fi);
}
ParseUnitState puState{ prog.nextFuncId };
for (size_t i = 0; i < ue.numPreClasses(); ++i) {
auto cls = parse_class(puState, ret.get(), *ue.pce(i));
ret->classes.push_back(std::move(cls));
}
for (auto& fe : ue.fevec()) {
auto func = parse_func(puState, ret.get(), nullptr, *fe);
assertx(!fe->pce());
ret->funcs.push_back(std::move(func));
}
ret->srcLocs.resize(puState.srcLocs.size());
for (auto& srcInfo : puState.srcLocs) {
ret->srcLocs[srcInfo.second] = srcInfo.first;
}
for (auto& te : ue.typeAliases()) {
ret->typeAliases.push_back(
parse_type_alias(ret.get(), *te)
);
}
for (auto& c : ue.constants()) {
ret->constants.push_back(
parse_constant(c, ret.get())
);
}
find_additional_metadata(puState, ret.get());
assertx(check(*ret));
std::lock_guard<std::mutex> _{prog.lock};
for (auto const item : puState.constPassFuncs) {
prog.constInits.push_back(item);
}
auto unitSn = prog.units.size();
ret->sn = unitSn;
ret->sha1 = SHA1 { unitSn };
prog.units.push_back(std::move(ret));
}
//////////////////////////////////////////////////////////////////////
}
|
Route5Gate_h:
db GATE ; tileset
db ROUTE_5_GATE_HEIGHT, ROUTE_5_GATE_WIDTH ; dimensions (y, x)
dw Route5Gate_Blocks ; blocks
dw Route5Gate_TextPointers ; texts
dw Route5Gate_Script ; scripts
db 0 ; connections
dw Route5Gate_Object ; objects
|
// license:BSD-3-Clause
// copyright-holders:Quench
/***************************************************************************
ToaPlan game hardware from 1987
--------------------------------
Driver by: Quench
Supported games:
Toaplan Board Number: TP-009
Taito Game Number: B25
Wardner (World)
Pyros (USA)
Wardner no Mori (Japan)
Notes:
Basically the same video and machine hardware as Flying Shark,
except for the Main CPU which is a Z80 here.
See twincobr.cpp machine and video drivers to complete the
hardware setup.
To enter the "test mode", press START1 when the grid is displayed.
Press 0 (actually P1 button 3) on startup to skip some video RAM tests
(code at 0x6d25 in 'wardner', 0x6d2f in 'wardnerj' or 0x6d2c in 'pyros').
**************************** Memory & I/O Maps *****************************
Z80:(0) Main CPU
0000-6fff Main ROM
7000-7fff Main RAM
8000-ffff Level and scenery ROMS. This is banked with the following
8000-8fff Sprite RAM
a000-adff Palette RAM
ae00-afff Spare unused, but tested Palette RAM
c000-c7ff Sound RAM - shared with C000-C7FF in Z80(1) RAM
in:
50 DSW A
52 DSW B
54 Player 1 controls
56 Player 2 controls
58 VBlank (bit 7) and coin-in/start inputs
60 LSB data from char display layer
61 MSB data from char display layer
62 LSB data from BG display layer
63 MSB data from BG display layer
64 LSB data from FG display layer
65 MSB data from FG display layer
out:
00 6845 CRTC offset register
02 6845 CRTC register data
10 char scroll LSB < Y >
11 char scroll MSB < Y >
12 char scroll LSB X
13 char scroll MSB X
14 char LSB RAM offset 20h * 40h (0-07ff) and (4000-47ff) ???
15 char MSB RAM offset
20 BG scroll LSB < Y >
21 BG scroll MSB < Y >
22 BG scroll LSB X
23 BG scroll MSB X
24 BG LSB RAM offset 40h * 40h (0-0fff)
25 BG MSB RAM offset
30 FG scroll LSB < Y >
31 FG scroll MSB < Y >
32 FG scroll LSB X
33 FG scroll MSB X
34 FG LSB RAM offset 40h * 40h (0-0fff)
35 FG MSB RAM offset
40 spare scroll LSB < Y > (Not used)
41 spare scroll MSB < Y > (Not used)
5a-5c Control registers
bits 7-4 always 0
bits 3-1 select the control signal to drive.
bit 0 is the value passed to the control signal.
5a data
00-01 INT line to TMS320C10 DSP (Active low trigger)
0c-0d lockout for coin A input (Active low lockout)
0e-0f lockout for coin B input (Active low lockout)
5c data
00-01 ???
02-03 ???
04-05 Active low INTerrupt to Z80(0) for screen refresh
06-07 Flip Screen (Active high flips)
08-09 Background RAM display bank switch
0a-0b Foreground ROM display bank switch (not used here)
0c-0d ??? (what the hell does this do ?)
60 LSB data to char display layer
61 MSB data to char display layer
62 LSB data to BG display layer
63 MSB data to BG display layer
64 LSB data to FG display layer
65 MSB data to FG display layer
70 ROM bank selector for Z80(0) address 8000-ffff
data
00 switch ROM from 8000-ffff out, and put sprite/palette/sound RAM back.
02 switch lower half of B25-18.ROM ROM to 8000-ffff
03 switch upper half of B25-18.ROM ROM to 8000-ffff
04 switch lower half of B25-19.ROM ROM to 8000-ffff
05 switch upper half of B25-19.ROM ROM to 8000-ffff
07 switch B25-30.ROM ROM to 8000-ffff
Z80:(1) Sound CPU
0000-7fff Main ROM
8000-807f RAM ???
c000-cfff Sound RAM, $C000-C7FF shared with $C000-C7FF in Z80(0) ram
TMS320C10 DSP: Harvard type architecture. RAM and ROM on separate data buses.
0000-05ff ROM 16-bit opcodes (word access only).
0000-0090 Internal RAM (words).
in:
01 data read from addressed Z80:(0) address space (Main RAM/Sprite RAM)
out:
00 address of Z80:(0) to read/write to
01 data to write to addressed Z80:(0) address space (Main RAM/Sprite RAM)
03 bit 15 goes to BIO line of TMS320C10. BIO is a polled input line.
***************************************************************************/
#include "emu.h"
#include "includes/twincobr.h"
#include "includes/toaplipt.h"
#include "cpu/tms32010/tms32010.h"
#include "cpu/z80/z80.h"
#include "machine/74259.h"
#include "sound/ymopl.h"
#include "speaker.h"
namespace {
class wardner_state : public twincobr_state
{
public:
wardner_state(const machine_config &mconfig, device_type type, const char *tag)
: twincobr_state(mconfig, type, tag)
, m_rom_ram_view(*this, "rom_ram_view")
, m_rombank(*this, "rombank")
{
}
void wardner(machine_config &config);
void init_wardner();
protected:
virtual void driver_start() override;
virtual void machine_reset() override;
private:
memory_view m_rom_ram_view;
required_memory_bank m_rombank;
void wardner_bank_w(uint8_t data);
void dsp_io_map(address_map &map);
void dsp_program_map(address_map &map);
void main_bank_map(address_map &map);
void main_io_map(address_map &map);
void main_program_map(address_map &map);
void sound_io_map(address_map &map);
void sound_program_map(address_map &map);
};
/***************************** Z80 Main Memory Map **************************/
void wardner_state::wardner_bank_w(uint8_t data)
{
m_rom_ram_view.select(data == 0x00 ? 0 : 1);
m_rombank->set_entry(data & 7);
}
void wardner_state::main_program_map(address_map &map)
{
map(0x0000, 0x6fff).rom();
map(0x7000, 0x7fff).ram();
map(0x8000, 0x8fff).w(FUNC(wardner_state::wardner_sprite_w)); // .share("spriteram8")
map(0xa000, 0xafff).w(m_palette, FUNC(palette_device::write8)); // .share("palette")
map(0xc000, 0xc7ff).writeonly().share(m_sharedram);
map(0x8000, 0xffff).view(m_rom_ram_view);
m_rom_ram_view[0](0x8000, 0x8fff).r(FUNC(wardner_state::wardner_sprite_r)).share("spriteram8");
m_rom_ram_view[0](0xa000, 0xafff).readonly().share("palette");
m_rom_ram_view[0](0xc000, 0xc7ff).readonly().share(m_sharedram);
m_rom_ram_view[1](0x8000, 0xffff).bankr(m_rombank);
}
void wardner_state::main_io_map(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x00).w("crtc", FUNC(mc6845_device::address_w));
map(0x02, 0x02).w("crtc", FUNC(mc6845_device::register_w));
map(0x10, 0x13).w(FUNC(wardner_state::wardner_txscroll_w)); // scroll text layer
map(0x14, 0x15).w(FUNC(wardner_state::wardner_txlayer_w)); // offset in text video RAM
map(0x20, 0x23).w(FUNC(wardner_state::wardner_bgscroll_w)); // scroll bg layer
map(0x24, 0x25).w(FUNC(wardner_state::wardner_bglayer_w)); // offset in bg video RAM
map(0x30, 0x33).w(FUNC(wardner_state::wardner_fgscroll_w)); // scroll fg layer
map(0x34, 0x35).w(FUNC(wardner_state::wardner_fglayer_w)); // offset in fg video RAM
map(0x40, 0x43).w(FUNC(wardner_state::wardner_exscroll_w)); // scroll extra layer (not used)
map(0x50, 0x50).portr("DSWA");
map(0x52, 0x52).portr("DSWB");
map(0x54, 0x54).portr("P1");
map(0x56, 0x56).portr("P2");
map(0x58, 0x58).portr("SYSTEM");
map(0x5a, 0x5a).w(m_coinlatch, FUNC(ls259_device::write_nibble_d0));
map(0x5c, 0x5c).w(m_mainlatch, FUNC(ls259_device::write_nibble_d0));
map(0x60, 0x65).rw(FUNC(wardner_state::wardner_videoram_r), FUNC(wardner_state::wardner_videoram_w));
map(0x70, 0x70).w(FUNC(wardner_state::wardner_bank_w));
}
/***************************** Z80 Sound Memory Map *************************/
void wardner_state::sound_program_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0x807f).ram();
map(0xc000, 0xc7ff).ram().share(m_sharedram);
map(0xc800, 0xcfff).ram();
}
void wardner_state::sound_io_map(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x01).rw("ymsnd", FUNC(ym3812_device::read), FUNC(ym3812_device::write));
}
/***************************** TMS32010 Memory Map **************************/
void wardner_state::dsp_program_map(address_map &map)
{
map(0x000, 0x5ff).rom();
}
// $000 - 08F TMS32010 Internal Data RAM in Data Address Space
void wardner_state::dsp_io_map(address_map &map)
{
map(0x00, 0x00).w(FUNC(wardner_state::wardner_dsp_addrsel_w));
map(0x01, 0x01).rw(FUNC(wardner_state::wardner_dsp_r), FUNC(wardner_state::wardner_dsp_w));
map(0x03, 0x03).w(FUNC(wardner_state::twincobr_dsp_bio_w));
}
/*****************************************************************************
Input Port definitions
*****************************************************************************/
// verified from Z80 code
static INPUT_PORTS_START( wardner_generic )
PORT_START("P1")
TOAPLAN_JOY_UDLR_2_BUTTONS( 1 ) // buttons 3 & 4 named "SHOTC" and "SHOTD" in "test mode"
PORT_START("P2")
TOAPLAN_JOY_UDLR_2_BUTTONS( 2 ) // buttons 3 & 4 named "SHOTC" and "SHOTD" in "test mode"
PORT_START("SYSTEM")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
TOAPLAN_TEST_SWITCH( 0x04, IP_ACTIVE_HIGH ) // "TEST" in "test mode"
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen") // "V-BLANKING" in "test mode"
PORT_START("DSWA")
TOAPLAN_MACHINE_COCKTAIL_LOC(SW1)
TOAPLAN_COINAGE_WORLD_LOC(SW1)
PORT_START("DSWB")
TOAPLAN_DIFFICULTY_LOC(SW2)
PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW2:!3,!4") // table at 0x13ce ('wardner') or 0x13de ('wardnerj')
PORT_DIPSETTING( 0x00, "30k 80k 50k+" )
PORT_DIPSETTING( 0x04, "50k 100k 50k+" )
PORT_DIPSETTING( 0x08, "30k Only" )
PORT_DIPSETTING( 0x0c, "50k Only" )
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:!5,!6")
PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x10, "4" )
PORT_DIPSETTING( 0x20, "5" )
PORT_DIPUNUSED_DIPLOC( 0x40, IP_ACTIVE_HIGH, "SW2:!7" )
PORT_DIPUNUSED_DIPLOC( 0x80, IP_ACTIVE_HIGH, "SW2:!8" )
INPUT_PORTS_END
static INPUT_PORTS_START( wardnerjb )
PORT_INCLUDE( wardner_generic )
PORT_MODIFY("DSWB")
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:!5,!6")
PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPSETTING( 0x20, "3" )
PORT_DIPSETTING( 0x10, "4" )
INPUT_PORTS_END
// verified from Z80 code
static INPUT_PORTS_START( wardner )
PORT_INCLUDE( wardner_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Skip Video RAM Tests") PORT_CODE(KEYCODE_0)
// actually player 1 button 3 - not used in gameplay
// code at 0x6d25 ('wardner'), 0x6d2f ('wardnerj') or 0x6d2c ('pyros')
INPUT_PORTS_END
// verified from Z80 code
static INPUT_PORTS_START( wardnerj )
PORT_INCLUDE( wardner )
PORT_MODIFY("DSWA")
TOAPLAN_COINAGE_JAPAN_LOC(SW1)
INPUT_PORTS_END
// verified from Z80 code
static INPUT_PORTS_START( pyros )
PORT_INCLUDE( wardnerj )
PORT_MODIFY("DSWB")
PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW2:!3,!4") // table at 0x13ce
PORT_DIPSETTING( 0x00, "30k 80k 50k+" )
PORT_DIPSETTING( 0x04, "50k 100k 50k+" )
PORT_DIPSETTING( 0x08, "50k Only" )
PORT_DIPSETTING( 0x0c, "100k Only" )
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW2:!7") // additional code at 0x6037
PORT_DIPSETTING( 0x40, DEF_STR( No ) )
PORT_DIPSETTING( 0x00, DEF_STR( Yes ) )
INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8, // 8*8 characters
RGN_FRAC(1,3), // 2048 characters
3, // 3 bits per pixel
{ RGN_FRAC(0,3), RGN_FRAC(1,3), RGN_FRAC(2,3) }, // the bitplanes are separated
{ STEP8(0,1) },
{ STEP8(0,8) },
8*8 // every char takes 8 consecutive bytes
};
static const gfx_layout tilelayout =
{
8,8, // 8*8 tiles
RGN_FRAC(1,4), // 4096 tiles
4, // 4 bits per pixel
{ RGN_FRAC(0,4), RGN_FRAC(1,4), RGN_FRAC(2,4), RGN_FRAC(3,4) }, // the bitplanes are separated
{ STEP8(0,1) },
{ STEP8(0,8) },
8*8 // every tile takes 8 consecutive bytes
};
static GFXDECODE_START( gfx_wardner )
GFXDECODE_ENTRY( "chars", 0x00000, charlayout, 1536, 32 ) // colors 1536-1791
GFXDECODE_ENTRY( "fg_tiles", 0x00000, tilelayout, 1280, 16 ) // colors 1280-1535
GFXDECODE_ENTRY( "bg_tiles", 0x00000, tilelayout, 1024, 16 ) // colors 1024-1079
GFXDECODE_END
void wardner_state::driver_start()
{
// Save-State stuff in src/machine/twincobr.cpp
driver_savestate();
m_rombank->configure_entries(0, 8, memregion("maincpu")->base(), 0x8000);
}
void wardner_state::machine_reset()
{
twincobr_state::machine_reset();
}
void wardner_state::wardner(machine_config &config)
{
// basic machine hardware
Z80(config, m_maincpu, XTAL(24'000'000) / 4); // 6MHz
m_maincpu->set_addrmap(AS_PROGRAM, &wardner_state::main_program_map);
m_maincpu->set_addrmap(AS_IO, &wardner_state::main_io_map);
z80_device &audiocpu(Z80(config, "audiocpu", XTAL(14'000'000) / 4)); // 3.5MHz
audiocpu.set_addrmap(AS_PROGRAM, &wardner_state::sound_program_map);
audiocpu.set_addrmap(AS_IO, &wardner_state::sound_io_map);
TMS32010(config, m_dsp, XTAL(14'000'000)); // 14MHz Crystal CLKin
m_dsp->set_addrmap(AS_PROGRAM, &wardner_state::dsp_program_map);
// Data Map is internal to the CPU
m_dsp->set_addrmap(AS_IO, &wardner_state::dsp_io_map);
m_dsp->bio().set(FUNC(wardner_state::twincobr_bio_r));
config.set_maximum_quantum(attotime::from_hz(6000)); // 100 CPU slices per frame
LS259(config, m_mainlatch);
m_mainlatch->q_out_cb<2>().set(FUNC(wardner_state::int_enable_w));
m_mainlatch->q_out_cb<3>().set(FUNC(wardner_state::flipscreen_w));
m_mainlatch->q_out_cb<4>().set(FUNC(wardner_state::bg_ram_bank_w));
m_mainlatch->q_out_cb<5>().set(FUNC(wardner_state::fg_rom_bank_w));
m_mainlatch->q_out_cb<6>().set(FUNC(wardner_state::display_on_w));
LS259(config, m_coinlatch);
m_coinlatch->q_out_cb<0>().set(FUNC(wardner_state::dsp_int_w));
m_coinlatch->q_out_cb<4>().set(FUNC(wardner_state::coin_counter_1_w));
m_coinlatch->q_out_cb<5>().set(FUNC(wardner_state::coin_counter_2_w));
m_coinlatch->q_out_cb<6>().set(FUNC(wardner_state::coin_lockout_1_w));
m_coinlatch->q_out_cb<7>().set(FUNC(wardner_state::coin_lockout_2_w));
// video hardware
hd6845s_device &crtc(HD6845S(config, "crtc", XTAL(14'000'000)/4)); // 3.5MHz measured on CLKin
crtc.set_screen(m_screen);
crtc.set_show_border_area(false);
crtc.set_char_width(2);
TOAPLAN_SCU(config, m_spritegen, 0);
m_spritegen->set_screen(m_screen);
m_spritegen->set_palette(m_palette);
m_spritegen->set_xoffsets(32, 14);
m_spritegen->set_pri_callback(FUNC(wardner_state::pri_cb));
BUFFERED_SPRITERAM8(config, m_spriteram8);
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
m_screen->set_raw(14_MHz_XTAL/2, 446, 0, 320, 286, 0, 240);
m_screen->set_screen_update(FUNC(wardner_state::screen_update));
m_screen->screen_vblank().set(m_spriteram8, FUNC(buffered_spriteram8_device::vblank_copy_rising));
m_screen->screen_vblank().append(FUNC(wardner_state::wardner_vblank_irq));
GFXDECODE(config, m_gfxdecode, m_palette, gfx_wardner);
PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 4096);
// sound hardware
SPEAKER(config, "mono").front_center();
ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(14'000'000) / 4));
ymsnd.irq_handler().set_inputline("audiocpu", 0);
ymsnd.add_route(ALL_OUTPUTS, "mono", 1.0);
}
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( wardner )
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF ) // Banked Main Z80 code
ROM_LOAD( "b25-31.6m", 0x00000, 0x08000, CRC(c5dd56fd) SHA1(f0a09557150e9c1c6b9d8e125f5408fc269c9d17) ) // Main Z80 code
ROM_LOAD( "b25-18.7m", 0x10000, 0x10000, CRC(9aab8ee2) SHA1(16fa44b75f4a3a5b1ff713690a299ecec2b5a4bf) ) // OBJ ROMs
ROM_LOAD( "b25-19.8m", 0x20000, 0x10000, CRC(95b68813) SHA1(06ea1b1d6e2e6326ceb9324fc471d082fda6112e) )
ROM_LOAD( "b25-32.10m", 0x38000, 0x08000, CRC(347f411b) SHA1(1fb2883d74d10350cb1c62fb58d5783652861b37) )
ROM_REGION( 0x10000, "audiocpu", 0 ) // Sound Z80 code
ROM_LOAD( "b25-16.4k", 0x00000, 0x08000, CRC(e5202ff8) SHA1(15ae8c0bb16a20bee14e8d80d81c249404ab1463) )
ROM_REGION( 0x2000, "dsp", 0 ) // Co-Processor TMS320C10
ROM_LOAD( "d70012u_gxc-02_mcu_71001", 0x0000, 0x0c00, BAD_DUMP CRC(eee0ff59) SHA1(dad4570815ec444e34cc73f7cd90f9ca8f7b3eb8) ) // it should use undumped MCU 71900, but they are interchangeable
ROM_REGION( 0x0c000, "chars", 0 )
ROM_LOAD( "b25-28.10f", 0x00000, 0x04000, CRC(1392b60d) SHA1(86b9eab87f8d5f68fda500420f4ed61331089fc2) )
ROM_LOAD( "b25-27.8f", 0x04000, 0x04000, CRC(0ed848da) SHA1(e4b38e21c101a28a8961a9fe30c9cb10919cc148) )
ROM_LOAD( "b25-26.7f", 0x08000, 0x04000, CRC(79792c86) SHA1(648b97f1ec30d46e40e60eb13159b4f6f86e9243) )
ROM_REGION( 0x20000, "fg_tiles", 0 )
ROM_LOAD( "b25-12.18f", 0x00000, 0x08000, CRC(15d08848) SHA1(e2e62d95a3f240664b5e0ac0f163a0d5cefa5312) )
ROM_LOAD( "b25-15.23f", 0x08000, 0x08000, CRC(cdd2d408) SHA1(7e4d77f8725fa30d4d65e811d10e0b2c00b23cfe) )
ROM_LOAD( "b25-14.21f", 0x10000, 0x08000, CRC(5a2aef4f) SHA1(60f4ab2582a924defb5241ab367826ae1f4b3f5e) )
ROM_LOAD( "b25-13.19f", 0x18000, 0x08000, CRC(be21db2b) SHA1(7fc1809618f2432c9ec6eb33ce57a5faffd44974) )
ROM_REGION( 0x20000, "bg_tiles", 0 )
ROM_LOAD( "b25-08.12f", 0x00000, 0x08000, CRC(883ccaa3) SHA1(90d686094eac6e80caf8e2cf90c00bb41a0d26e2) )
ROM_LOAD( "b25-11.16f", 0x08000, 0x08000, CRC(d6ebd510) SHA1(d65e0db7756ebe6828bf637a6c915bb06082636c) )
ROM_LOAD( "b25-10.15f", 0x10000, 0x08000, CRC(b9a61e81) SHA1(541e579664d583fbbf81111046115018fdaff073) )
ROM_LOAD( "b25-09.14f", 0x18000, 0x08000, CRC(585411b7) SHA1(67c0f4b7ab303341d5481c4024dc4199acb7c279) )
ROM_REGION( 0x40000, "scu", 0 ) // sprites
ROM_LOAD( "b25-01.14c", 0x00000, 0x10000, CRC(42ec01fb) SHA1(646192a2e89f795ed016860cdcdc0b5ef645fca2) )
ROM_LOAD( "b25-02.16c", 0x10000, 0x10000, CRC(6c0130b7) SHA1(8b6ad72848d03c3d4ee3acd35abbb3a0e678122c) )
ROM_LOAD( "b25-03.17c", 0x20000, 0x10000, CRC(b923db99) SHA1(2f4be81afdf200586bc44b1e94553d84d16d0b62) )
ROM_LOAD( "b25-04.19c", 0x30000, 0x10000, CRC(8059573c) SHA1(75bd19e504433438b85ed00e50e85fb98eebf4de) )
ROM_REGION( 0x260, "proms", 0 ) // nibble bproms, lo/hi order to be determined
ROM_LOAD( "82s129.b19", 0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) ) // sprite priority control ??
ROM_LOAD( "82s129.b18", 0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) ) // sprite priority control ??
ROM_LOAD( "82s123.b21", 0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) ) // sprite control ??
ROM_LOAD( "82s123.c6", 0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) ) // sprite attribute (flip/position) ??
ROM_LOAD( "82s123.f1", 0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) // tile to sprite priority ??
ROM_END
// the ROM contents of the bootleg are the same of the original, the difference is the TMS320C10 code which is in external PROMs instead of internal
ROM_START( wardnerb )
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF ) // Banked Main Z80 code
ROM_LOAD( "b25-31.6m", 0x00000, 0x08000, CRC(c5dd56fd) SHA1(f0a09557150e9c1c6b9d8e125f5408fc269c9d17) ) // Main Z80 code
ROM_LOAD( "b25-18.7m", 0x10000, 0x10000, CRC(9aab8ee2) SHA1(16fa44b75f4a3a5b1ff713690a299ecec2b5a4bf) ) // OBJ ROMs
ROM_LOAD( "b25-19.8m", 0x20000, 0x10000, CRC(95b68813) SHA1(06ea1b1d6e2e6326ceb9324fc471d082fda6112e) )
ROM_LOAD( "b25-32.10m", 0x38000, 0x08000, CRC(347f411b) SHA1(1fb2883d74d10350cb1c62fb58d5783652861b37) )
ROM_REGION( 0x10000, "audiocpu", 0 ) // Sound Z80 code
ROM_LOAD( "b25-16.4k", 0x00000, 0x08000, CRC(e5202ff8) SHA1(15ae8c0bb16a20bee14e8d80d81c249404ab1463) )
ROM_REGION( 0x2000, "dsp", 0 ) // Co-Processor TMS320C10
ROMX_LOAD( "82s137.1d", 0x0000, 0x0400, CRC(cc5b3f53) SHA1(33589665ac995cc4645b56bbcd6d1c1cd5368f88), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) ) // MSB
ROMX_LOAD( "82s137.1e", 0x0000, 0x0400, CRC(47351d55) SHA1(826add3ea3987f2c9ba2d3fc69a4ad2d9b033c89), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s137.3d", 0x0001, 0x0400, CRC(70b537b9) SHA1(5211ec4605894727747dda66b70c9427652b16b4), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) ) // LSB
ROMX_LOAD( "82s137.3e", 0x0001, 0x0400, CRC(6edb2de8) SHA1(48459037c3b865f0c0d63a416fa71ba1119f7a09), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s131.3b", 0x0800, 0x0200, CRC(9dfffaff) SHA1(2f4a1c1afba6a362dc5774a82656883b08fa16f2), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
ROMX_LOAD( "82s131.3a", 0x0800, 0x0200, CRC(712bad47) SHA1(b9f7be13cbd90a17fe7d13fb7987a0b9b759ccad), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s131.2a", 0x0801, 0x0200, CRC(ac843ca6) SHA1(8fd278748ec89d8ebe2d4f3bf8b6731f357ddfb3), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
ROMX_LOAD( "82s131.1a", 0x0801, 0x0200, CRC(50452ff8) SHA1(76964fa9ee89a51cc71904e08cfc83bf81bb89aa), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROM_REGION( 0x0c000, "chars", 0 )
ROM_LOAD( "b25-28.10f", 0x00000, 0x04000, CRC(1392b60d) SHA1(86b9eab87f8d5f68fda500420f4ed61331089fc2) )
ROM_LOAD( "b25-27.8f", 0x04000, 0x04000, CRC(0ed848da) SHA1(e4b38e21c101a28a8961a9fe30c9cb10919cc148) )
ROM_LOAD( "b25-26.7f", 0x08000, 0x04000, CRC(79792c86) SHA1(648b97f1ec30d46e40e60eb13159b4f6f86e9243) )
ROM_REGION( 0x20000, "fg_tiles", 0 )
ROM_LOAD( "b25-12.18f", 0x00000, 0x08000, CRC(15d08848) SHA1(e2e62d95a3f240664b5e0ac0f163a0d5cefa5312) )
ROM_LOAD( "b25-15.23f", 0x08000, 0x08000, CRC(cdd2d408) SHA1(7e4d77f8725fa30d4d65e811d10e0b2c00b23cfe) )
ROM_LOAD( "b25-14.21f", 0x10000, 0x08000, CRC(5a2aef4f) SHA1(60f4ab2582a924defb5241ab367826ae1f4b3f5e) )
ROM_LOAD( "b25-13.19f", 0x18000, 0x08000, CRC(be21db2b) SHA1(7fc1809618f2432c9ec6eb33ce57a5faffd44974) )
ROM_REGION( 0x20000, "bg_tiles", 0 )
ROM_LOAD( "b25-08.12f", 0x00000, 0x08000, CRC(883ccaa3) SHA1(90d686094eac6e80caf8e2cf90c00bb41a0d26e2) )
ROM_LOAD( "b25-11.16f", 0x08000, 0x08000, CRC(d6ebd510) SHA1(d65e0db7756ebe6828bf637a6c915bb06082636c) )
ROM_LOAD( "b25-10.15f", 0x10000, 0x08000, CRC(b9a61e81) SHA1(541e579664d583fbbf81111046115018fdaff073) )
ROM_LOAD( "b25-09.14f", 0x18000, 0x08000, CRC(585411b7) SHA1(67c0f4b7ab303341d5481c4024dc4199acb7c279) )
ROM_REGION( 0x40000, "scu", 0 ) // sprites
ROM_LOAD( "b25-01.14c", 0x00000, 0x10000, CRC(42ec01fb) SHA1(646192a2e89f795ed016860cdcdc0b5ef645fca2) )
ROM_LOAD( "b25-02.16c", 0x10000, 0x10000, CRC(6c0130b7) SHA1(8b6ad72848d03c3d4ee3acd35abbb3a0e678122c) )
ROM_LOAD( "b25-03.17c", 0x20000, 0x10000, CRC(b923db99) SHA1(2f4be81afdf200586bc44b1e94553d84d16d0b62) )
ROM_LOAD( "b25-04.19c", 0x30000, 0x10000, CRC(8059573c) SHA1(75bd19e504433438b85ed00e50e85fb98eebf4de) )
ROM_REGION( 0x260, "proms", 0 ) // nibble bproms, lo/hi order to be determined
ROM_LOAD( "82s129.b19", 0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) ) // sprite priority control ??
ROM_LOAD( "82s129.b18", 0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) ) // sprite priority control ??
ROM_LOAD( "82s123.b21", 0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) ) // sprite control ??
ROM_LOAD( "82s123.c6", 0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) ) // sprite attribute (flip/position) ??
ROM_LOAD( "82s123.f1", 0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) // tile to sprite priority ??
ROM_END
ROM_START( pyros )
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF ) // Banked Z80 code
ROM_LOAD( "b25-29.6m", 0x00000, 0x08000, CRC(b568294d) SHA1(5d04dd006f5180fa0c9340e2efa6613625d712a8) ) // Main Z80 code
ROM_LOAD( "b25-18.7m", 0x10000, 0x10000, CRC(9aab8ee2) SHA1(16fa44b75f4a3a5b1ff713690a299ecec2b5a4bf) ) // OBJ ROMs
ROM_LOAD( "b25-19.8m", 0x20000, 0x10000, CRC(95b68813) SHA1(06ea1b1d6e2e6326ceb9324fc471d082fda6112e) )
ROM_LOAD( "b25-30.10m", 0x38000, 0x08000, CRC(5056c799) SHA1(9750fa8bf5d1181a4fecbcbf822f8f027bebd5a8) )
ROM_REGION( 0x10000, "audiocpu", 0 ) // Sound Z80 code
ROM_LOAD( "b25-16.4k", 0x00000, 0x08000, CRC(e5202ff8) SHA1(15ae8c0bb16a20bee14e8d80d81c249404ab1463) )
ROM_REGION( 0x2000, "dsp", 0 ) // Co-Processor TMS320C10
ROM_LOAD( "d70012u_gxc-02_mcu_71001", 0x0000, 0x0c00, BAD_DUMP CRC(eee0ff59) SHA1(dad4570815ec444e34cc73f7cd90f9ca8f7b3eb8) ) // it should use undumped MCU 71900, but they are interchangeable
ROM_REGION( 0x0c000, "chars", 0 )
ROM_LOAD( "b25-35.10f", 0x00000, 0x04000, CRC(fec6f0c0) SHA1(f91d698fa0712659c2e6b382a8166b1cacc50a3f) )
ROM_LOAD( "b25-34.8f", 0x04000, 0x04000, CRC(02505dad) SHA1(28993c68a17929d6b819ca81cdf60985531fc80b) )
ROM_LOAD( "b25-33.7f", 0x08000, 0x04000, CRC(9a55fcb9) SHA1(e04d68cc0b80b79b5f4c19c14b2e87f226f45ac8) )
ROM_REGION( 0x20000, "fg_tiles", 0 )
ROM_LOAD( "b25-12.18f", 0x00000, 0x08000, CRC(15d08848) SHA1(e2e62d95a3f240664b5e0ac0f163a0d5cefa5312) )
ROM_LOAD( "b25-15.23f", 0x08000, 0x08000, CRC(cdd2d408) SHA1(7e4d77f8725fa30d4d65e811d10e0b2c00b23cfe) )
ROM_LOAD( "b25-14.21f", 0x10000, 0x08000, CRC(5a2aef4f) SHA1(60f4ab2582a924defb5241ab367826ae1f4b3f5e) )
ROM_LOAD( "b25-13.19f", 0x18000, 0x08000, CRC(be21db2b) SHA1(7fc1809618f2432c9ec6eb33ce57a5faffd44974) )
ROM_REGION( 0x20000, "bg_tiles", 0 )
ROM_LOAD( "b25-08.12f", 0x00000, 0x08000, CRC(883ccaa3) SHA1(90d686094eac6e80caf8e2cf90c00bb41a0d26e2) )
ROM_LOAD( "b25-11.16f", 0x08000, 0x08000, CRC(d6ebd510) SHA1(d65e0db7756ebe6828bf637a6c915bb06082636c) )
ROM_LOAD( "b25-10.15f", 0x10000, 0x08000, CRC(b9a61e81) SHA1(541e579664d583fbbf81111046115018fdaff073) )
ROM_LOAD( "b25-09.14f", 0x18000, 0x08000, CRC(585411b7) SHA1(67c0f4b7ab303341d5481c4024dc4199acb7c279) )
ROM_REGION( 0x40000, "scu", 0 ) // sprites
ROM_LOAD( "b25-01.14c", 0x00000, 0x10000, CRC(42ec01fb) SHA1(646192a2e89f795ed016860cdcdc0b5ef645fca2) )
ROM_LOAD( "b25-02.16c", 0x10000, 0x10000, CRC(6c0130b7) SHA1(8b6ad72848d03c3d4ee3acd35abbb3a0e678122c) )
ROM_LOAD( "b25-03.17c", 0x20000, 0x10000, CRC(b923db99) SHA1(2f4be81afdf200586bc44b1e94553d84d16d0b62) )
ROM_LOAD( "b25-04.19c", 0x30000, 0x10000, CRC(8059573c) SHA1(75bd19e504433438b85ed00e50e85fb98eebf4de) )
ROM_REGION( 0x260, "proms", 0 ) // nibble bproms, lo/hi order to be determined
ROM_LOAD( "82s129.b19", 0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) ) // sprite priority control ??
ROM_LOAD( "82s129.b18", 0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) ) // sprite priority control ??
ROM_LOAD( "82s123.b21", 0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) ) // sprite control ??
ROM_LOAD( "82s123.c6", 0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) ) // sprite attribute (flip/position) ??
ROM_LOAD( "82s123.f1", 0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) // tile to sprite priority ??
ROM_END
ROM_START( wardnerj )
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF ) // Banked Z80 code
ROM_LOAD( "b25-17.6m", 0x00000, 0x08000, CRC(4164dca9) SHA1(1f02c0991d7c14230043e34cb4b8e089b467b234) ) // Main Z80 code
ROM_LOAD( "b25-18.7m", 0x10000, 0x10000, CRC(9aab8ee2) SHA1(16fa44b75f4a3a5b1ff713690a299ecec2b5a4bf) ) // OBJ ROMs
ROM_LOAD( "b25-19.8m", 0x20000, 0x10000, CRC(95b68813) SHA1(06ea1b1d6e2e6326ceb9324fc471d082fda6112e) )
ROM_LOAD( "b25-20.10m", 0x38000, 0x08000, CRC(1113ad38) SHA1(88f89054954b1d2776ceaedc7a3605190808d7e5) )
ROM_REGION( 0x10000, "audiocpu", 0 ) // Sound Z80 code
ROM_LOAD( "b25-16.4k", 0x00000, 0x08000, CRC(e5202ff8) SHA1(15ae8c0bb16a20bee14e8d80d81c249404ab1463) )
ROM_REGION( 0x2000, "dsp", 0 ) // Co-Processor TMS320C10
ROM_LOAD( "d70012u_gxc-02_mcu_71001", 0x0000, 0x0c00, BAD_DUMP CRC(eee0ff59) SHA1(dad4570815ec444e34cc73f7cd90f9ca8f7b3eb8) ) // it should use undumped MCU 71900, but they are interchangeable
ROM_REGION( 0x0c000, "chars", 0 )
ROM_LOAD( "b25-07.10f", 0x00000, 0x04000, CRC(50e329e0) SHA1(5d5fb7043457d952b28101acb909ed65bf13a2dc) )
ROM_LOAD( "b25-06.8f", 0x04000, 0x04000, CRC(3bfeb6ae) SHA1(3a251f49901ccb17b5fedf81980d54e4f6f49d4d) )
ROM_LOAD( "b25-05.7f", 0x08000, 0x04000, CRC(be36a53e) SHA1(320fc5b88ed1fce1aa8d8e76e1046206c138b35c) )
ROM_REGION( 0x20000, "fg_tiles", 0 )
ROM_LOAD( "b25-12.18f", 0x00000, 0x08000, CRC(15d08848) SHA1(e2e62d95a3f240664b5e0ac0f163a0d5cefa5312) )
ROM_LOAD( "b25-15.23f", 0x08000, 0x08000, CRC(cdd2d408) SHA1(7e4d77f8725fa30d4d65e811d10e0b2c00b23cfe) )
ROM_LOAD( "b25-14.21f", 0x10000, 0x08000, CRC(5a2aef4f) SHA1(60f4ab2582a924defb5241ab367826ae1f4b3f5e) )
ROM_LOAD( "b25-13.19f", 0x18000, 0x08000, CRC(be21db2b) SHA1(7fc1809618f2432c9ec6eb33ce57a5faffd44974) )
ROM_REGION( 0x20000, "bg_tiles", 0 )
ROM_LOAD( "b25-08.12f", 0x00000, 0x08000, CRC(883ccaa3) SHA1(90d686094eac6e80caf8e2cf90c00bb41a0d26e2) )
ROM_LOAD( "b25-11.16f", 0x08000, 0x08000, CRC(d6ebd510) SHA1(d65e0db7756ebe6828bf637a6c915bb06082636c) )
ROM_LOAD( "b25-10.15f", 0x10000, 0x08000, CRC(b9a61e81) SHA1(541e579664d583fbbf81111046115018fdaff073) )
ROM_LOAD( "b25-09.14f", 0x18000, 0x08000, CRC(585411b7) SHA1(67c0f4b7ab303341d5481c4024dc4199acb7c279) )
ROM_REGION( 0x40000, "scu", 0 ) // sprites
ROM_LOAD( "b25-01.14c", 0x00000, 0x10000, CRC(42ec01fb) SHA1(646192a2e89f795ed016860cdcdc0b5ef645fca2) )
ROM_LOAD( "b25-02.16c", 0x10000, 0x10000, CRC(6c0130b7) SHA1(8b6ad72848d03c3d4ee3acd35abbb3a0e678122c) )
ROM_LOAD( "b25-03.17c", 0x20000, 0x10000, CRC(b923db99) SHA1(2f4be81afdf200586bc44b1e94553d84d16d0b62) )
ROM_LOAD( "b25-04.19c", 0x30000, 0x10000, CRC(8059573c) SHA1(75bd19e504433438b85ed00e50e85fb98eebf4de) )
ROM_REGION( 0x260, "proms", 0 ) // nibble bproms, lo/hi order to be determined
ROM_LOAD( "82s129.b19", 0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) ) // sprite priority control ??
ROM_LOAD( "82s129.b18", 0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) ) // sprite priority control ??
ROM_LOAD( "82s123.b21", 0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) ) // sprite control ??
ROM_LOAD( "82s123.c6", 0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) ) // sprite attribute (flip/position) ??
ROM_LOAD( "82s123.f1", 0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) // tile to sprite priority ??
ROM_END
// This bootleg has World main CPU ROMs mixed with Japanese char ROMs. The only unique ROM is 17.bin, where they changed the lives table, disabled the video RAM check and did some other minor changes
ROM_START( wardnerjb )
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF )
ROM_LOAD( "17.bin", 0x00000, 0x08000, CRC(c06804ec) SHA1(848acfc77af42f62d8d4584bfea83e7089593e71) ) // Main Z80 code
ROM_LOAD( "18.bin", 0x10000, 0x10000, CRC(9aab8ee2) SHA1(16fa44b75f4a3a5b1ff713690a299ecec2b5a4bf) ) // OBJ ROMs
ROM_LOAD( "19.bin", 0x20000, 0x10000, CRC(95b68813) SHA1(06ea1b1d6e2e6326ceb9324fc471d082fda6112e) )
ROM_LOAD( "20.bin", 0x38000, 0x08000, CRC(45185301) SHA1(f0b30a1337801230d49dc267cfe715559e0d1b41) ) // 1ST AND 2ND HALF IDENTICAL
ROM_CONTINUE( 0x38000, 0x08000 )
ROM_REGION( 0x10000, "audiocpu", 0 )
ROM_LOAD( "16.bin", 0x00000, 0x08000, CRC(e5202ff8) SHA1(15ae8c0bb16a20bee14e8d80d81c249404ab1463) )
ROM_REGION( 0x2000, "dsp", 0 ) // Co-Processor TMS320C10, not dumped for this set
ROMX_LOAD( "82s137.1d", 0x0000, 0x0400, BAD_DUMP CRC(cc5b3f53) SHA1(33589665ac995cc4645b56bbcd6d1c1cd5368f88), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) ) // MSB
ROMX_LOAD( "82s137.1e", 0x0000, 0x0400, BAD_DUMP CRC(47351d55) SHA1(826add3ea3987f2c9ba2d3fc69a4ad2d9b033c89), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s137.3d", 0x0001, 0x0400, BAD_DUMP CRC(70b537b9) SHA1(5211ec4605894727747dda66b70c9427652b16b4), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) ) // LSB
ROMX_LOAD( "82s137.3e", 0x0001, 0x0400, BAD_DUMP CRC(6edb2de8) SHA1(48459037c3b865f0c0d63a416fa71ba1119f7a09), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s131.3b", 0x0800, 0x0200, BAD_DUMP CRC(9dfffaff) SHA1(2f4a1c1afba6a362dc5774a82656883b08fa16f2), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
ROMX_LOAD( "82s131.3a", 0x0800, 0x0200, BAD_DUMP CRC(712bad47) SHA1(b9f7be13cbd90a17fe7d13fb7987a0b9b759ccad), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROMX_LOAD( "82s131.2a", 0x0801, 0x0200, BAD_DUMP CRC(ac843ca6) SHA1(8fd278748ec89d8ebe2d4f3bf8b6731f357ddfb3), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
ROMX_LOAD( "82s131.1a", 0x0801, 0x0200, BAD_DUMP CRC(50452ff8) SHA1(76964fa9ee89a51cc71904e08cfc83bf81bb89aa), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
ROM_REGION( 0x0c000, "chars", 0 )
ROM_LOAD( "7.bin", 0x00000, 0x04000, CRC(22abf48e) SHA1(5e8d895f50af0e5fc8499ee0f8c6e8a9ffd1fad8) ) // 0xxxxxxxxxxxxxx = 0xFF
ROM_CONTINUE( 0x00000, 0x04000 )
ROM_LOAD( "6.bin", 0x04000, 0x04000, CRC(49b66bc0) SHA1(5ec4b95cc557b29d26314ce12fe4d6b7e35389ed) ) // 0xxxxxxxxxxxxxx = 0xFF
ROM_CONTINUE( 0x04000, 0x04000 )
ROM_LOAD( "5.bin", 0x08000, 0x04000, CRC(cc7e7850) SHA1(14fcd5f13be46a348c749aef121524709604e9e2) ) // 0xxxxxxxxxxxxxx = 0xFF
ROM_CONTINUE( 0x08000, 0x04000 )
ROM_REGION( 0x20000, "fg_tiles", 0 )
ROM_LOAD( "12.bin", 0x00000, 0x08000, CRC(15d08848) SHA1(e2e62d95a3f240664b5e0ac0f163a0d5cefa5312) )
ROM_LOAD( "15.bin", 0x08000, 0x08000, CRC(cdd2d408) SHA1(7e4d77f8725fa30d4d65e811d10e0b2c00b23cfe) )
ROM_LOAD( "14.bin", 0x10000, 0x08000, CRC(5a2aef4f) SHA1(60f4ab2582a924defb5241ab367826ae1f4b3f5e) )
ROM_LOAD( "13.bin", 0x18000, 0x08000, CRC(be21db2b) SHA1(7fc1809618f2432c9ec6eb33ce57a5faffd44974) )
ROM_REGION( 0x20000, "bg_tiles", 0 )
ROM_LOAD( "8.bin", 0x00000, 0x08000, CRC(883ccaa3) SHA1(90d686094eac6e80caf8e2cf90c00bb41a0d26e2) )
ROM_LOAD( "11.bin", 0x08000, 0x08000, CRC(d6ebd510) SHA1(d65e0db7756ebe6828bf637a6c915bb06082636c) )
ROM_LOAD( "10.bin", 0x10000, 0x08000, CRC(b9a61e81) SHA1(541e579664d583fbbf81111046115018fdaff073) )
ROM_LOAD( "9.bin", 0x18000, 0x08000, CRC(585411b7) SHA1(67c0f4b7ab303341d5481c4024dc4199acb7c279) )
ROM_REGION( 0x40000, "scu", 0 ) // sprites
ROM_LOAD( "1.bin", 0x00000, 0x10000, CRC(42ec01fb) SHA1(646192a2e89f795ed016860cdcdc0b5ef645fca2) )
ROM_LOAD( "2.bin", 0x10000, 0x10000, CRC(6c0130b7) SHA1(8b6ad72848d03c3d4ee3acd35abbb3a0e678122c) )
ROM_LOAD( "3.bin", 0x20000, 0x10000, CRC(b923db99) SHA1(2f4be81afdf200586bc44b1e94553d84d16d0b62) )
ROM_LOAD( "4.bin", 0x30000, 0x10000, CRC(8059573c) SHA1(75bd19e504433438b85ed00e50e85fb98eebf4de) )
ROM_REGION( 0x260, "proms", 0 ) // nibble bproms, lo/hi order to be determined, not dumped for this set
ROM_LOAD( "82s129.b19", 0x000, 0x100, BAD_DUMP CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) ) // Sprite priority control ??
ROM_LOAD( "82s129.b18", 0x100, 0x100, BAD_DUMP CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) ) // Sprite priority control ??
ROM_LOAD( "82s123.b21", 0x200, 0x020, BAD_DUMP CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) ) // Sprite control ??
ROM_LOAD( "82s123.c6", 0x220, 0x020, BAD_DUMP CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) ) // Sprite attribute (flip/position) ??
ROM_LOAD( "82s123.f1", 0x240, 0x020, BAD_DUMP CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) // Tile to sprite priority ??
ROM_END
} // Anonymous namespace
GAME( 1987, wardner, 0, wardner, wardner, wardner_state, empty_init, ROT0, "Toaplan / Taito Corporation Japan", "Wardner (World)", MACHINE_SUPPORTS_SAVE )
GAME( 1987, wardnerb, wardner, wardner, wardner, wardner_state, empty_init, ROT0, "bootleg", "Wardner (World, bootleg)", MACHINE_SUPPORTS_SAVE )
GAME( 1987, pyros, wardner, wardner, pyros, wardner_state, empty_init, ROT0, "Toaplan / Taito America Corporation", "Pyros (US)", MACHINE_SUPPORTS_SAVE )
GAME( 1987, wardnerj, wardner, wardner, wardnerj, wardner_state, empty_init, ROT0, "Toaplan / Taito Corporation", "Wardner no Mori (Japan)", MACHINE_SUPPORTS_SAVE )
GAME( 1987, wardnerjb, wardner, wardner, wardnerjb, wardner_state, empty_init, ROT0, "bootleg", "Wardner no Mori (Japan, bootleg)", MACHINE_SUPPORTS_SAVE )
|
; A295556: a(n) = 0 for n <= 1; thereafter a(n) = a(floor(n/2)) + a(ceiling(n/2)) + floor(n/2) if n not congruent to 0 mod 4, a(n) = a(n/2-1) + a(n/2+1) + n/2 if n == 0 (mod 4).
; 0,0,1,2,4,5,7,9,11,13,15,17,20,22,25,27,30,32,35,37,40,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,112,115,119,122,126,129,133,136,140,143,147,150,154,157,161,164,168
mov $10,$0
mov $12,$0
lpb $12,1
clr $0,10
mov $0,$10
sub $12,1
sub $0,$12
add $3,$0
add $0,$3
sub $0,1
mov $1,$0
mul $0,2
add $1,$3
lpb $0,1
lpb $0,1
sub $0,$1
mod $0,2
add $9,$1
lpe
mov $1,5
lpe
lpb $9,1
add $1,11
div $9,4
lpe
sub $1,16
div $1,11
add $11,$1
lpe
mov $1,$11
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Spool/UI
FILE: uiPrintControl.asm
ROUTINES:
Name Description
---- -----------
Section #1 - Object creation & destruction
MSG PrintControlUpdateSpecBuild MSG_SPEC_BUILD_BRANCH handler
MSG PrintControlVisUnbuild MSG_SPEC_UNBUILD handler
INT PrintControlCleanUp Removes any created UI
Section #2: Changing PrintControl instance data
MSG PrintControlSetAttrs MSG_PRINT_CONTROL handler
MSG PrintControlGetAttrs MSG_PRINT_CONTROL handler
MSG PrintControlSetTotalPageRange MSG_PRINT_CONTROL handler
MSG PrintControlGetTotalPageRange MSG_PRINT_CONTROL handler
MSG PrintControlSetSelectedPageRange MSG_PRINT_CONTROL handler
MSG PrintControlGetSelectedPageRange MSG_PRINT_CONTROL handler
MSG PrintControlSetDocSize MSG_PRINT_CONTROL handler
MSG PrintControlGetDocSize MSG_PRINT_CONTROL handler
MSG PrintControlSetExtendedDocSize MSG_PRINT_CONTROL handler
MSG PrintControlGetExtendedDocSize MSG_PRINT_CONTROL handler
MSG PrintControlSetDocMargins MSG_PRINT_CONTROL handler
MSG PrintControlGetDocMargins MSG_PRINT_CONTROL handler
MSG PrintControlSetAppPrintUI MSG_PRINT_CONTROL handler
MSG PrintControlGetAppPrintUI MSG_PRINT_CONTROL handler
MSG PrintControlSetOutput MSG_PRINT_CONTROL handler
MSG PrintControlGetOutput MSG_PRINT_CONTROL handler
MSG PrintControlSetDefaultPrinter MSG_PRINT_CONTROL handler
MSG PrintControlGetDefaultPrinter MSG_PRINT_CONTROL handler
MSG PrintControlGetPrinterMode MSG_PRINT_CONTROL handler
MSG PrintControlGetPaperSize MSG_PRINT_CONTROL handler
MSG PrintControlGetPrinterMargins MSG_PRINT_CONTROL handler
MSG PrintControlCalcDocumentDimensions MSG_PRINT_CONTROL handler
MSG PrintControlVerifyDocMargins MSG_PRINT_CONTROL handler
MSG PrintControlVerifyDocSize MSG_PRINT_CONTROL handler
MSG PrintControlVerifyError MSG_PRINT_CONTROL handler
Section #3: Handlers & routines for printing
MSG PrintControlInitiatePrint PRINT_CONTROL handler
INT InitializeDialogBox Initializes the print dialog box
MSG PrintControlPrint MSG_PRINT_CONTROL handler
MSG PrintControlSpoolingUpdate MSG_PRINT_CONTROL handler
MSG PrintControlSetDocName MSG_PRINT_CONTROL handler
MSG PrintControlPrintingCompleted MSG_PRINT_CONTROL handler
MSG PrintControlPrintingCancelled MSG_PRINT_CONTROL handler
MSG PrintControlVerifyPrint MSG_PRINT_CONTROL handler
INT StartPrintJob Sends print job to the spooler
INT PrintGetDocumentInfo Fill in JobParameters
INT PrintGetApplicationName Obtain the application name
INT PrinterGetPortInfo Obtain printer port information
INT PrinterGetBaudRate - baud rate
INT PrinterGetParity - parity
INT PrinterGetWordLength - word length
INT PrinterGetStopBits - stop bits
INT PrinterGetHandshake - handshake modes
INT PrinterGetControlBits - control bits
INT PrintRequestUIOptions Obtain any printer UI options
INT PrintCreateSpoolFile Create the spool file
INT PrintRequestDocName Have document name request sent
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
Don 2/90 Much added functionality
Don 1/92 Documentation, new methods, general clean-up
DESCRIPTION:
$Id: uiPrintControl.asm,v 1.2 98/02/17 03:56:00 gene Exp $
------------------------------------------------------------------------------@
PrintControlCommon segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlControlGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get information about the PrintControl object
CALLED BY: GLOBAL (MSG_GEN_CONTROL_GET_INFO)
PASS: *DS:SI = PrintControlControlClass object
DS:DI = PrintControlControlClassInstance
CX:DX = GenControlBuildInfo
RETURN: Nothing
DESTROYED: CX, DI, SI, DS, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/27/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetInfo method dynamic PrintControlClass,
MSG_GEN_CONTROL_GET_INFO
.enter
;
; Note whether we're in address-control mode.
;
call PCIsAddrControl
mov es, cx
mov di, dx ; buffer to fill => ES:DI
segmov ds, cs
mov si, offset PC_dupInfo
mov cx, size GenControlBuildInfo
rep movsb
jnc done ; => not for address control
;
; Turn off child shme if in address control.
;
mov di, dx
mov es:[di].GCBI_childCount, length PC_addrCtrlChildList
mov es:[di].GCBI_childList.offset,
offset PC_addrCtrlChildList
mov es:[di].GCBI_childList.segment,
vseg PC_addrCtrlChildList
mov es:[di].GCBI_dupBlock, handle PrintDialogBox
mov es:[di].GCBI_featuresCount, 0
ornf es:[di].GCBI_flags,
mask GCBF_NOT_REQUIRED_TO_BE_ON_SELF_LOAD_OPTIONS_LIST
done:
.leave
ret
PrintControlGetInfo endm
PC_dupInfo GenControlBuildInfo <
mask GCBF_DO_NOT_DESTROY_CHILDREN_WHEN_CLOSED,
; GCBI_flags
PC_initFileKey, ; GCBI_initFileKey
PC_gcnList, ; GCBI_gcnList
length PC_gcnList, ; GCBI_gcnCount
0, ; GCBI_notificationList
0, ; GCBI_notificationCount
PCName, ; GCBI_controllerName
handle PrintControlUI, ; GCBI_dupBlock
PC_childList, ; GCBI_childList
length PC_childList, ; GCBI_childCount
PC_featuresList, ; GCBI_featuresList
length PC_featuresList, ; GCBI_featuresCount
PRINTC_DEFAULT_FEATURES, ; GCBI_features
handle PrintControlToolboxUI, ; GCBI_toolBlock
PC_toolList, ; GCBI_toolList
length PC_toolList, ; GCBI_toolCount
PC_toolFeaturesList, ; GCBI_toolFeaturesList
length PC_toolFeaturesList, ; GCBI_toolFeaturesCount
PRINTC_DEFAULT_TOOLBOX_FEATURES,; GCBI_toolFeatures
0, ; GCBI_helpContext
0> ; GCBI_reserved
PC_initFileKey char "printControl", 0
PC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_MODAL_WIN_CHANGE>
PC_addrCtrlChildList GenControlChildInfo \
<offset PrintDialogBox, 0, mask GCCF_ALWAYS_ADD>
PC_childList GenControlChildInfo \
<offset PrintTrigger, mask PRINTCF_PRINT_TRIGGER,
mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset FaxTrigger, mask PRINTCF_FAX_TRIGGER,
mask GCCF_IS_DIRECTLY_A_FEATURE>
PC_featuresList GenControlFeaturesInfo \
<offset FaxTrigger, FaxTriggerName, 0>,
<offset PrintTrigger, PrintTriggerName, 0>
PC_toolList GenControlChildInfo \
<offset PrintToolTrigger, mask PRINTCTF_PRINT_TRIGGER,
mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset FaxToolTrigger, mask PRINTCTF_FAX_TRIGGER,
mask GCCF_IS_DIRECTLY_A_FEATURE>
PC_toolFeaturesList GenControlFeaturesInfo \
<offset FaxToolTrigger, FaxTriggerToolName, 0>,
<offset PrintToolTrigger, PrintTriggerToolName, 0>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PCGenControlGetNormalFeatures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Hack to make sure we stay user-initiatable even in address-
control mode (where we support no features)
CALLED BY: MSG_GEN_CONTROL_GET_NORMAL_FEATURES
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
RETURN: ax = current normal feature set
cx = required normal features
dx = prohibited normal features
bp = normal features supported by controller
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/27/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCGenControlGetNormalFeatures method dynamic PrintControlClass,
MSG_GEN_CONTROL_GET_NORMAL_FEATURES
call PCIsAddrControl
jc hackFeatures
mov ax, MSG_GEN_CONTROL_GET_NORMAL_FEATURES
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
hackFeatures:
clr dx, ax
dec ax
mov cx, ax
mov bp, ax
ret
PCGenControlGetNormalFeatures endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGenerateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Generate either the normal or toolbox UI
CALLED BY: GLOBAL (MSG_GEN_CONTROL_GENERATE_UI)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/14/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGenerateUI method dynamic PrintControlClass,
MSG_GEN_CONTROL_GENERATE_UI,
MSG_GEN_CONTROL_GENERATE_TOOLBOX_UI
.enter
; First call our superclass
;
push ax
mov di, offset PrintControlClass
call ObjCallSuperNoLock
; Add ourselves to the global GCN list
;
mov ax, GCNSLT_INSTALLED_PRINTERS
mov bx, MANUFACTURER_ID_GEOWORKS
mov cx, ds:[LMBH_handle]
mov dx, si
call GCNListAdd
pop ax
; When operating in address-control mode, automatically
; initialize our UI.
push ax
mov ax, TEMP_PRINT_CONTROL_ADDRESS_CONTROL
call ObjVarFindData
pop ax
jnc done
mov cl, ds:[bx].TPACD_driverType
cmp ax, MSG_GEN_CONTROL_GENERATE_UI
jne done ; => didn't generate "summons"
call addExpandWidth ; make us expand to fit
mov di, ds:[si]
add di, ds:[di].Gen_offset
mov bx, ds:[di].GI_comp.CP_firstChild.handle
mov di, ds:[di].GI_comp.CP_firstChild.chunk
xchg si, di ; ^lbx:si <- SpoolSummons
; *ds:di <- PrintControl
; make sure the interaction fills the width of the send
; control's dialog
call ObjSwapLock
call addExpandWidth
call ObjSwapUnlock
push cx
call InitializeDialogBox
pop cx
mov ax, MSG_SPOOL_SUMMONS_SET_DRIVER_TYPE
mov di, mask MF_FIXUP_DS
call ObjMessage
done:
.leave
ret
addExpandWidth:
push bx, cx
mov ax, HINT_EXPAND_WIDTH_TO_FIT_PARENT
clr cx
call ObjVarAddData
pop bx, cx
retn
PrintControlGenerateUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PCPrintCannotPrint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Take note that the SpoolSummons thinks it cannot print
CALLED BY: MSG_PRINT_CANNOT_PRINT
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
cx = PrintControlError to put up
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/16/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCPrintCannotPrint method dynamic PrintControlClass, MSG_PRINT_CANNOT_PRINT
.enter
push cx
call PCIsAddrControl
jnc dismissBox
;
; Address control: tell the address control that its address is invalid
;
mov ax, MSG_MAILBOX_ADDRESS_CONTROL_SET_VALID_STATE
clr cx
call PCCallAddressControl
putUpError:
;
; Tell the user why s/he's hosed.
;
pop cx
mov ax, MSG_META_DUMMY ; no response, thanks
call FarUISpoolErrorBox
.leave
ret
dismissBox:
;
; When not an address control, the inability to print keeps the
; box from coming up.
;
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call FarPCCallSummons
jmp putUpError
PCPrintCannotPrint endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PCGenControlTweakDuplicatedUi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If PrintControl is operating in address-control mode, adjust
the duplicated SpoolSummons object to conform to our
needs.
CALLED BY: MSG_GEN_CONTROL_TWEAK_DUPLICATED_UI
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
cx = handle of duplicated UI block
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/27/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCGenControlTweakDuplicatedUi method dynamic PrintControlClass,
MSG_GEN_CONTROL_TWEAK_DUPLICATED_UI
.enter
mov bx, cx ; save child block handle
mov di, offset PrintControlClass
call ObjCallSuperNoLock
call PCIsAddrControl
jnc done
;
; Now adjust the "dialog box" to be a control group, instead.
;
push si
call ObjSwapLock
mov si, offset PrintDialogBox
mov ax, MSG_GEN_INTERACTION_SET_TYPE
mov cl, GIT_ORGANIZATIONAL
call ObjCallInstanceNoLock
mov ax, MSG_GEN_INTERACTION_SET_VISIBILITY
mov cl, GIV_SUB_GROUP
call ObjCallInstanceNoLock
mov ax, MSG_GEN_INTERACTION_SET_ATTRS
mov cx, (mask GIA_MODAL or \
mask GIA_NOT_USER_INITIATABLE) shl 8
call ObjCallInstanceNoLock
;
; Nuke the moniker -- we don't want it any more, thanks; it looks weird
;
clr cx
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_MANUAL
call ObjCallInstanceNoLock
;
; Set not-usable those parts of the dialog that are inappropriate for
; this use:
; - the Print/Fax/Print to File triggers
;
push si
mov ax, MSG_GEN_SET_NOT_USABLE
mov dl, VUM_NOW
mov si, offset PrintTriggerGroup
call ObjCallInstanceNoLock
pop si
call ObjSwapUnlock
;
; Make sure any application-ui is added.
;
pop di ; *ds:di <- PC
; ^lbx:si = summons
call PCAddAppUI
done:
.leave
ret
PCGenControlTweakDuplicatedUi endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PCGenControlDestroyUi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If in address-control mode, remove any app-ui from the
duplicated summons.
CALLED BY: MSG_GEN_CONTROL_DESTROY_UI
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCGenControlDestroyUi method dynamic PrintControlClass,
MSG_GEN_CONTROL_DESTROY_UI
call PCIsAddrControl
jnc done
mov ax, ATTR_PRINT_CONTROL_APP_UI
call ObjVarFindData
jnc done
push si
mov si, ds:[bx].chunk
mov bx, ds:[bx].handle
mov ax, MSG_GEN_REMOVE
mov dl, VUM_NOW
mov bp, mask CCF_MARK_DIRTY
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
pop si
done:
mov di, offset PrintControlClass
mov ax, MSG_GEN_CONTROL_DESTROY_UI
GOTO ObjCallSuperNoLock
PCGenControlDestroyUi endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintNotify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Watch for GAGCNLT_MODAL_WIN_CHANGE, & re-check wether
print completion message should be sent out.
PASS: *ds:si - instance data
ds:di - ptr to start of master instance data
es - segment of class
ax - MSG_META_NOTIFY
cx:dx - GCN notification type
RETURN: nothing
ALLOWED TO DESTROY:
bx, si, di, ds, es
PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
doug 12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintNotify method PrintControlClass, MSG_META_NOTIFY
cmp cx, MANUFACTURER_ID_GEOWORKS
jne toSuper
cmp dx, GWNT_MODAL_WIN_CHANGE
je modalWinChange
toSuper:
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
modalWinChange:
FALL_THRU CheckUpOnPrintCompletionMessage
PrintNotify endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckUpOnPrintCompletionMessage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check to see if printing is now complete
CALLED BY: UTILITY
PASS: *DS:SI = PrintControlClass object
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 1/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckUpOnPrintCompletionMessage proc far
uses ax, bx, cx, dx, bp, di
.enter
; Are we in the middle of printing? If so, continue until done
;
call PCAccessTemp ; access the local data
tst ds:[di].TPCI_jobParHandle ; JobParameters handle ??
jnz done ; yes, so do nothing
tst ds:[di].TPCI_holdUpCompletionCount
jnz done ; Wait for anyone else...
; Are we in the middle of a DETACH? If so, then now is
; the time to destroy our children and clean up.
;
mov ax, DETACH_DATA
call ObjVarFindData
jnc enabled?
call PCDestroySummons
call ObjEnableDetach
; Are we enabled (i.e. is it even possible for the user to interact
; with the print dialog?)
enabled?:
mov ax, MSG_GEN_GET_ENABLED
call ObjCallInstanceNoLock
jnc dispatch ; no, dispatch to show done.
; Is the dialog box still up? If so, continue until done
;
mov ax, MSG_GEN_APPLICATION_GET_MODAL_WIN
call GenCallApplication
tst cx ; if there's a modal window
jnz done ; up, not done.
; Send the print completion event, if one exists
dispatch:
call DispatchPrintCompletionEvent ; Dispach it, if there
done:
.leave
ret
CheckUpOnPrintCompletionMessage endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DispatchPrintCompletionEvent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Dispatch an event
CALLED BY: UTILITY
PASS: *DS:SI = PrintControlClass object
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 1/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DispatchPrintCompletionEvent proc far
uses es
.enter
mov ax, TEMP_PRINT_COMPLETION_EVENT ; If no completion message,
call ObjVarFindData ; nothing to do.
jnc done
mov cx, ds:[bx].TPCED_event ; get stored message
mov dx, ds:[bx].TPCED_messageFlags
mov ax, MSG_META_DISPATCH_EVENT ; dispatch completion msg
mov di, segment PrintControlClass
mov es, di
mov di, offset PrintControlClass
call ObjCallSuperNoLock
mov ax, TEMP_PRINT_COMPLETION_EVENT ; delete stored message
call ObjVarDeleteData
done:
.leave
ret
DispatchPrintCompletionEvent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlScanFeatureHints
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Scan the feature hints to find required & prohibited features
CALLED BY: GLOBAL (MSG_GEN_CONTROL_SCAN_FEATURE_HINTS)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
CX = GenControlUIType
DX:BP = GenControlScanInfo
RETURN: Nothing
DESTROYED: AX, DI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/15/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlScanFeatureHints method dynamic PrintControlClass,
MSG_GEN_CONTROL_SCAN_FEATURE_HINTS
.enter
; First we call our superclass to fill structure
;
mov di, offset PrintControlClass
call ObjCallSuperNoLock
; If fax drivers are available, we're set. Else, we
; need to prohibit the fax feature or tool
;
call PCAccessTemp
test ds:[di].TPCI_status, mask PSF_FAX_AVAILABLE
jnz done ; if available, we're done
mov ax, mask PRINTCF_FAX_TRIGGER
cmp cx, GCUIT_NORMAL
je prohibit
mov ax, mask PRINTCTF_FAX_TRIGGER
prohibit:
mov es, dx ; GenControlScanInfo => ES:BP
or es:[bp].GCSI_appProhibited, ax
done:
.leave
ret
PrintControlScanFeatureHints endm
PrintControlCommon ends
;---
PrintControlCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PCMetaInitialize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize those parts of our instance data that are non-zero
CALLED BY: MSG_META_INITIALIZE
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS: ?
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/26/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCMetaInitialize method dynamic PrintControlClass, MSG_META_INITIALIZE
mov ds:[di].PCI_attrs, PrintControlAttrs <>
mov ds:[di].PCI_startPage, 1
mov ds:[di].PCI_endPage, 1
mov ds:[di].PCI_endUserPage, 0x7fff
mov ds:[di].PCI_defPrinter, -1
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
PCMetaInitialize endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlDetach
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Remove any additional application-defined UI
CALLED BY: GLOBAL (MSG_META_DETACH)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
ES = Segment of PrintControlClass
CX, DX, BP = detach data
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/ 3/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlDetach method dynamic PrintControlClass,
MSG_META_DETACH,
MSG_SPEC_UNBUILD
; Destroy the Print dialog box, unless we are in
; the middle of printing. If that's the case, then
; we increment the detach count and do nothing (if
; we are DETACHing).
;
push ax, cx, dx, bp ; save message and data
call PCDestroySummons ; free the spool summons object
jnc removeFromGCN
pop ax, cx, dx, bp
cmp ax, MSG_SPEC_UNBUILD
je continue
call ObjInitDetach
continue:
push ax, cx, dx, bp
; Remove ourselves from the global GCN list
removeFromGCN:
mov ax, GCNSLT_INSTALLED_PRINTERS
mov bx, MANUFACTURER_ID_GEOWORKS
mov cx, ds:[LMBH_handle]
mov dx, si
call GCNListRemove
; Call our superclass to finish things up
;
pop ax, cx, dx, bp ; restore message
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
PrintControlDetach endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGenGupInteractionCommand
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Respond to InteractionCommand's
CALLED BY: GLOBAL (MSG_GEN_GUP_INTERACTION_COMMAND)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
CX = InteractionCommand
RETURN: Nothing
DESTROYED: see message documentation
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/ 3/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGenGupInteractionCommand method dynamic PrintControlClass,
MSG_GEN_GUP_INTERACTION_COMMAND
; If we are dimissing, ensure we destroy Print & Options UI
;
CheckHack <IC_NULL eq 0>
CheckHack <IC_DISMISS eq 1>
cmp cx, IC_DISMISS ; jump if not IC_NULL nor
ja callSuperClass ; ...IC_DISMISS
push ax, cx, dx, bp
call PCIsAddrControl
jc tellPrinterChangeBox
call PCCallSummons ; send DISMISS to Print DB
popCallSuper:
pop ax, cx, dx, bp
callSuperClass:
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
tellPrinterChangeBox:
;
; In the address-control case, the summons isn't a dialog, but the
; PrinterChangeBox is, so we tell it, rather than telling the
; dialog and relying on it to tell the change box.
;
push si
call PCGetSummons
jnc tellPrinterChangeBoxDone
mov si, offset PrinterChangeBox
push ax
call PCObjMessageSend
pop ax
mov si, offset PrintFileDialogBox
call PCObjMessageSend
tellPrinterChangeBoxDone:
pop si
jmp popCallSuper
PrintControlGenGupInteractionCommand endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlPrinterInstalledRemoved
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Be notified that a printer has been installed or removed
CALLED BY: GLOBAL (MSG_PRINTER_INSTALLED_REMOVED)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
RETURN: Nothing
DESTROYED: AX, CX, DX, BP, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/15/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlPrinterInstalledRemoved method dynamic PrintControlClass,
MSG_PRINTER_INSTALLED_REMOVED
.enter
; don't need to rebuild UI if addr control, as features don't
; change...
call PCIsAddrControl
jc done
; All we're interested in knowing is whether or not
; any fax drivers have been installed or removed.
;
call PCAccessTemp
call PCCheckForFax ; check for status change
jz done ; if no change, jump
; We need to re-evaluate the features available for
; this PrintControl object. Send message via queue, else
; we'll get deadlock in trying to access the GCN block.
;
mov bx, ds:[LMBH_handle] ; PrintControl OD => ^lBX:SI
mov ax, MSG_GEN_CONTROL_REBUILD_NORMAL_UI
mov di, mask MF_FORCE_QUEUE
call ObjMessage
mov ax, MSG_GEN_CONTROL_REBUILD_TOOLBOX_UI
mov di, mask MF_FORCE_QUEUE
call ObjMessage
; Tell the SpoolSummons object about the change
done:
mov ax, MSG_PRINTER_INSTALLED_REMOVED
call PCCallSummons ; call the SpoolSummons object
.leave
ret
PrintControlPrinterInstalledRemoved endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Section #2: Changing PrintControl instance data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetAttrs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the current application print attributes
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_ATTRS)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
CX = PrintControlAttrs
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetAttrs method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_ATTRS
.enter
; Store the new attributes
;
EC < test cx, not PrintControlAttrs ; check for illegal bits >
EC < ERROR_NZ PC_SET_ATTRS_INVALID_ATTRIBUTES >
mov ds:[di].PCI_attrs, cx ; store the attributes
mov ax, MSG_SPOOL_SUMMONS_SET_PRINT_ATTRS
call PCCallSummons
.leave
ret
PrintControlSetAttrs endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetAttrs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the current application-defined print attributes
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_ATTRS)
PASS: DS:DI = PrintControlInstance
RETURN: CX = PrintControlAttrs
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetAttrs method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_ATTRS
.enter
mov cx, ds:[di].PCI_attrs
.leave
ret
PrintControlGetAttrs endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetTotalPageRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the the first & last page numbers in a document
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_TOTAL_PAGE_RANGE)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
CX = First page
DX = Last page
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetTotalPageRange method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_TOTAL_PAGE_RANGE
.enter
; Store the new values - reset the print group if necessary
;
EC < cmp dx, cx ; last must be > than first >
EC < ERROR_B PC_SET_TOTAL_PAGE_LAST_LESS_THAN_FIRST >
cmp cx, ds:[di].PCI_startPage
jne callSpoolSummons
cmp dx, ds:[di].PCI_endPage
callSpoolSummons:
pushf ; save the current flags
mov ds:[di].PCI_startPage, cx
mov ds:[di].PCI_endPage, dx
mov ax, MSG_SPOOL_SUMMONS_SET_PAGE_RANGE
call PCCallSummons
; Also reset the user page range (if range is different)
;
popf ; restore flags
je done ; if no change, do nothing
mov cx, ds:[di].PCI_startUserPage
mov dx, ds:[di].PCI_endUserPage
mov ax, MSG_SPOOL_SUMMONS_SET_USER_PAGE_RANGE
call PCCallSummons
done:
.leave
ret
PrintControlSetTotalPageRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetTotalPageRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the current total page range
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_TOTAL_PAGE_RANGE)
PASS: DS:DI = PrintControlInstance
RETURN: CX = First page (>= 1)
DX = Last page (>= First page)
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetTotalPageRange method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_TOTAL_PAGE_RANGE
.enter
mov cx, ds:[di].PCI_startPage
mov dx, ds:[di].PCI_endPage
.leave
ret
PrintControlGetTotalPageRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetSelectedPageRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the selected range of pages to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_SELECTED_PAGE_RANGE)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
CX = Starting page
DX = Ending page
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetSelectedPageRange method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_SELECTED_PAGE_RANGE
.enter
EC < cmp dx, cx ; last must be > first >
EC < ERROR_B PC_SET_SELECTED_PAGE_LAST_LESS_THAN_FIRST >
mov ds:[di].PCI_startUserPage, cx
mov ds:[di].PCI_endUserPage, dx
mov ax, MSG_SPOOL_SUMMONS_SET_USER_PAGE_RANGE
call PCCallSummons
.leave
ret
PrintControlSetSelectedPageRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetSelectedPageRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the user-selected range of pages to print
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_SELECTED_PAGE_RANGE)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
RETURN: CX = Starting page
DX = Ending page
DESTROYED: BX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetSelectedPageRange method PrintControlClass,
MSG_PRINT_CONTROL_GET_SELECTED_PAGE_RANGE
uses ax, bp
.enter
mov cx, ds:[di].PCI_startUserPage ; assume no address control
mov dx, ds:[di].PCI_endUserPage
if not LIMITED_FAX_SUPPORT
;
; If there's an address control, we must ask it what the pages are;
; that's how the user is expected to select them in this world.
;
mov ax, MSG_MSAC_GET_PAGE_RANGE
call PCCallAddressControl
jc done
endif
mov ax, MSG_SPOOL_SUMMONS_GET_USER_PAGE_RANGE
call PCCallSummons
done:
.leave
ret
PrintControlGetSelectedPageRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetMailboxObjectType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If we're associated with an address control, ask it for
the object type and transaction handle for the current print
job
CALLED BY: MSG_PRINT_GET_MAILBOX_OBJECT_TYPE
PASS: *ds:si = PrintControl object
ds:di = PrintControlInstance
RETURN: carry set if print request not from a MailboxSendControl
ax, bp = destroyed
carry clear if MailboxObjectType returned:
ax = MailboxObjectType
bp = transaction handle
DESTROYED: nothing
SIDE EFFECTS: none
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/ 2/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PCPrintControlGetMailboxObjectType method dynamic PrintControlClass,
MSG_PRINT_GET_MAILBOX_OBJECT_TYPE
uses dx
.enter
mov ax, MSG_MSAC_GET_OBJECT_TYPE
call PCCallAddressControl
cmc
.leave
ret
PCPrintControlGetMailboxObjectType endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDocSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the document size to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DOC_SIZE)
PASS: DS:DI = PrintControlInstance
CX = Document width
DX = Document height
RETURN: Nothing
DESTROYED: BX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDocSize method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DOC_SIZE
.enter
clr bx ; clear high word of size
movdw ds:[di].PCI_docSizeInfo.PSR_width, bxcx
movdw ds:[di].PCI_docSizeInfo.PSR_height, bxdx
.leave
ret
PrintControlSetDocSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetDocSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the size of the document to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_DOC_SIZE
PASS: DS:DI = PrintControlInstance
RETURN: CX = Document width
DX = Document height
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetDocSize method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_DOC_SIZE
.enter
EC < tst ds:[di].PCI_docSizeInfo.PSR_width.high >
EC < ERROR_NZ PC_GET_DOC_SIZE_DIMENSION_IS_32_BIT_VALUE >
EC < tst ds:[di].PCI_docSizeInfo.PSR_height.high <
EC < ERROR_NZ PC_GET_DOC_SIZE_DIMENSION_IS_32_BIT_VALUE >
mov cx, ds:[di].PCI_docSizeInfo.PSR_width.low
mov dx, ds:[di].PCI_docSizeInfo.PSR_height.low
.leave
ret
PrintControlGetDocSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetExtendedDocSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the document size to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_EXTENDED_DOC_SIZE)
PASS: DS:DI = PrintControlInstance
DX:BP = PCDocSizeParams
RETURN: Nothing
DESTROYED: BX, SI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetExtendedDocSize method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_EXTENDED_DOC_SIZE
.enter
mov es, dx ; PCDocSizeParams => ES:BP
movdw bxsi, es:[bp].PCDSP_width
movdw ds:[di].PCI_docSizeInfo.PSR_width, bxsi
movdw bxsi, es:[bp].PCDSP_height
movdw ds:[di].PCI_docSizeInfo.PSR_height, bxsi
.leave
ret
PrintControlSetExtendedDocSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetExtendedDocSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the size of the document to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_EXTENDED_DOC_SIZE
PASS: DS:DI = PrintControlInstance
DX:BP = PCDocSizeParams (empty)
RETURN: DX:BP = PCDocSizeParams (filled)
DESTROYED: BX, SI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetExtendedDocSize method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_EXTENDED_DOC_SIZE
.enter
mov es, dx ; PCDocSizeParams => ES:BP
movdw bxsi, ds:[di].PCI_docSizeInfo.PSR_width
movdw es:[bp].PCDSP_width, bxsi ; store the width
movdw bxsi, ds:[di].PCI_docSizeInfo.PSR_height
movdw es:[bp].PCDSP_height, bxsi ; store the height
.leave
ret
PrintControlGetExtendedDocSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDocMargins
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the document margins, so PrintControl can determine
if the printer can fully display the passed document
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DOC_MARGINS)
PASS: DS:DI = PrintControlInstance
DX:BP = PCMarginParams
RETURN: Nothing
DESTROYED: BX, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/26/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDocMargins method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DOC_MARGINS
.enter
; Store this data away
;
mov es, dx
mov bx, es:[bp].PCMP_left
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_left, bx
mov bx, es:[bp].PCMP_top
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_top, bx
mov bx, es:[bp].PCMP_right
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_right, bx
mov bx, es:[bp].PCMP_bottom
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_bottom, bx
.leave
ret
PrintControlSetDocMargins endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetDocMargins
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gets the document margins set by the application.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_DOC_MARGINS)
PASS: DS:DI = PrintControlInstance
DX:BP = PCMarginParams (empty)
RETURN: DX:BP = PCMarginParams (filled)
DESTROYED: BX, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/26/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetDocMargins method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_DOC_MARGINS
.enter
; Copy the data in the structure
;
mov es, dx ; PCMarginParams => ES:BP
mov bx, ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_left
mov es:[bp].PCMP_left, bx
mov bx, ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_top
mov es:[bp].PCMP_top, bx
mov bx, ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_right
mov es:[bp].PCMP_right, bx
mov bx, ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_bottom
mov es:[bp].PCMP_bottom, bx
.leave
ret
PrintControlGetDocMargins endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDocSizeInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the document size to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DOC_SIZE_INFO)
PASS: DS:DI = PrintControlInstance
DX:BP = PageSizeReport
RETURN: Nothing
DESTROYED: BX, DI, SI, DS, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDocSizeInfo method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DOC_SIZE_INFO
uses cx
.enter
segmov es, ds
add di, offset PCI_docSizeInfo ; destination => ES:DI
mov ds, dx
mov si, bp ; source => DS:SI
mov cx, size PageSizeReport
rep movsb
.leave
ret
PrintControlSetDocSizeInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetDocSizeInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the size of the document to be printed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_DOC_SIZE_INFO
PASS: DS:DI = PrintControlInstance
DX:BP = PageSizeReport buffer
RETURN: DX:BP = PageSizeReport filled
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetDocSizeInfo method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_DOC_SIZE_INFO
.enter
mov si, di
add si, offset PCI_docSizeInfo ; source => DS:SI
mov es, dx
mov di, bp ; destination => ES:DI
mov cx, size PageSizeReport
rep movsb
.leave
ret
PrintControlGetDocSizeInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetOutput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the output of the PC - destination of the print method
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_OUTPUT)
PASS: DS:*SI = PrintControl instance data
DS:DI = PrintControl specific instance data
CX:DX = New Output Descriptor
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetOutput method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_OUTPUT
.enter
; Store the passed information
;
mov ds:[di].PCI_output.handle, cx ; store the block handle
mov ds:[di].PCI_output.chunk, dx ; store the chunk handle
.leave
ret
PrintControlSetOutput endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetOutput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Return the current OD of the PrintControl object
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_OUTPUT)
PASS: DS:DI = PrintControl specific instance data
RETURN: CX:DX = Output Descriptor
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetOutput method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_OUTPUT
.enter
mov cx, ds:[di].PCI_output.handle ; block handle => CX
mov dx, ds:[di].PCI_output.chunk ; chunk handle => DX
.leave
ret
PrintControlGetOutput endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDocNameOutput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the output of the PrintControl to receive
MSG_PRINT_GET_DOC_NAME.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DOC_NAME_OUTPUT)
PASS: DS:*SI = PrintControl instance data
DS:DI = PrintControl specific instance data
CX:DX = New Output Descriptor
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDocNameOutput method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DOC_NAME_OUTPUT
.enter
; Store the passed information
;
mov ds:[di].PCI_docNameOutput.handle, cx ; store the block handle
mov ds:[di].PCI_docNameOutput.chunk, dx ; store the chunk handle
.leave
ret
PrintControlSetDocNameOutput endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetDocNameOutput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Return the current OD of the PrintControl object
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_DOC_NAME_OUTPUT)
PASS: DS:DI = PrintControl specific instance data
RETURN: CX:DX = Output Descriptor
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetDocNameOutput method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_DOC_NAME_OUTPUT
.enter
mov cx, ds:[di].PCI_docNameOutput.handle ; block handle => CX
mov dx, ds:[di].PCI_docNameOutput.chunk ; chunk handle => DX
.leave
ret
PrintControlGetDocNameOutput endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDefaultPrinter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the application-default printer
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DEFAULT_PRINTER)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
CX = Printer number
RETURN: Nothing
DESTROYED: AX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/19/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDefaultPrinter method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DEFAULT_PRINTER
.enter
; Store the passed information
;
mov ds:[di].PCI_defPrinter, cx ; store the default printer
mov ax, MSG_SPOOL_SUMMONS_SET_DEFAULT_PRINTER
call PCCallSummons
.leave
ret
PrintControlSetDefaultPrinter endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetDefaultPrinter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gets the application-default printer
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DEFAULT_PRINTER)
PASS: DS:DI = PrintControlInstance
RETURN: CX = Printer number
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/19/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetDefaultPrinter method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_DEFAULT_PRINTER
.enter
; Store the passed information
;
mov cx, ds:[di].PCI_defPrinter ; get the default printer
.leave
ret
PrintControlGetDefaultPrinter endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetPrinterMode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the current printer mode (if box is up)
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_PRINT_MOE)
PASS: DS:*SI = PrintControl object
RETURN: CL = PrinterMode or 0 if none is yet selected
DESTROYED: BX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 6/29/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetPrinterMode method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_PRINT_MODE
.enter
; Verify that we're in the middle of printing
;
EC < call PCAccessTemp ; access local data >
EC < tst ds:[di].TPCI_fileHandle ; open print file ?? >
EC < ERROR_Z CANNOT_CALL_THIS_FUNCTION_WHILE_NOT_PRINTING >
; Now request summons to provide selected mode
;
clr cl ; assume the DB is not up
mov ax, MSG_SPOOL_SUMMONS_GET_PRINT_MODE
call PCCallSummons ; send the method on...
.leave
ret
PrintControlGetPrinterMode endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetPaperSizeInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the paper size for the currently selected printer
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_PAPER_SIZE_INFO)
PASS: DS:*SI = PrintControl instance data
DX:BP = PageSizeReport buffer
RETURN: DX:BP = PageSizeReport filled
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This is really only useful when an application is in the
middle of printing.
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 9/25/90 Initial version
Don 4/16/91 Works with any printer now
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetPaperSizeInfo method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_PAPER_SIZE_INFO
uses ax
.enter
; Determine if we want the current printer or not
;
mov ax, MSG_SPOOL_SUMMONS_GET_PAPER_SIZE_INFO
call PCCallSummons ; return various pieces of info
.leave
ret
PrintControlGetPaperSizeInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetPaperSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the paper size for the currently selected printer
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_PAPER_SIZE)
PASS: DS:*SI = PrintControl instance data
RETURN: AX:CX = Paper width
BP:DX = Paper height
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This is really only useful when an application is in the
middle of printing.
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 9/25/90 Initial version
Don 4/16/91 Works with any printer now
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetPaperSize method dynamic PrintControlClass,
MSG_PRINT_CONTROL_GET_PAPER_SIZE
.enter
; Determine if we want the current printer or not
;
sub sp, (size PageSizeReport)
mov dx, ss
mov bp, sp
mov ax, MSG_SPOOL_SUMMONS_GET_PAPER_SIZE_INFO
call PCCallSummons ; return various pieces of info
mov bx, bp ; PageSizeReport => SS:BX
movdw axcx, ss:[bx].PSR_width
movdw bpdx, ss:[bx].PSR_height
add sp, (size PageSizeReport)
.leave
ret
PrintControlGetPaperSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlGetPrinterMargins
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the margins used by the current printer
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_GET_PRINTER_MARGINS)
PASS: DS:*SI = PrintControl instance data
DX = TRUE - set document margins to follow printer margins
= FALSE - don't do this
RETURN: AX = Left margin
CX = Top margin
DX = Right margin
BP = Bottom margin
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/22/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlGetPrinterMargins method PrintControlClass,
MSG_PRINT_CONTROL_GET_PRINTER_MARGINS
.enter
; Grab the margins from the SpoolSummons
;
EC < cmp dx, TRUE ; verify the boolean >
EC < je doneEC ; if valid, jump >
EC < cmp dx, FALSE ; verify the boolean >
EC < ERROR_NE PC_GET_PRINT_MARGINS_BOOLEAN_NOT_PASSED >
EC <doneEC: >
mov di, dx
mov ax, MSG_SPOOL_SUMMONS_GET_PRINTER_MARGINS
call PCForceCallSummons ; returns ax, cx, dx, bp
tst di ; copy margin values ??
jz done ; if FALSE, we're done
mov di, ds:[si] ; dereference the instance data
add di, ds:[di].PrintControl_offset
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_left, ax
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_top, cx
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_right, dx
mov ds:[di].PCI_docSizeInfo.PSR_margins.PCMP_bottom, bp
done:
.leave
ret
PrintControlGetPrinterMargins endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlCalcDocDimmensions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the printable page size and the margins for the
specified printer, and sets the application's document
margins and size
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_CALC_DOC_DIMENSIONS)
PASS: DS:*SI = PrintControlClass object
DS:DI = PrintControlClassInstance
DX:BP = PageSizeReport buffer
RETURN: DX:BP = PageSizeReport filled, except that the margins
are already subtracted from the dimensions of
the page & the orientation is taken into account.
DESTROYED: BX, DI, SI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/8/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LABEL_MARGINS equ 72 / 8 ; 1/8"
PrintControlCalcDocDimensions method dynamic PrintControlClass,
MSG_PRINT_CONTROL_CALC_DOC_DIMENSIONS
uses ax, cx
.enter
; Grab the current paper size & margins
;
mov ax, MSG_PRINT_CONTROL_GET_PAPER_SIZE_INFO
call ObjCallInstanceNoLock
; See if the user wants a rotated document
;
mov di, ds:[si]
add di, ds:[di].PrintControl_offset
mov es, dx ; PageSizeReport => ES:BP
test ds:[di].PCI_attrs, mask PCA_FORCE_ROTATION
jz doneRotationCheck
xchgdw es:[bp].PSR_width, es:[bp].PSR_height, ax
mov ax, es:[bp].PSR_margins.PCMP_left
xchg es:[bp].PSR_margins.PCMP_top, ax
mov es:[bp].PSR_margins.PCMP_left, ax
mov ax, es:[bp].PSR_margins.PCMP_right
xchg es:[bp].PSR_margins.PCMP_bottom, ax
mov es:[bp].PSR_margins.PCMP_right, ax
doneRotationCheck:
if _LABELS
; If the paper type is PT_LABEL, then the margins are assumed to
; be 1/8" (as the margins are placed inside of each label, rather
; than on the paper holding the labels). For NIKE, we need to make
; the left & right margins 1/4", to account for labels that may
; extend out to the edge of the paper, and hence be limited by
; the printable area.
;
test es:[bp].PSR_layout, PT_LABEL
jz doneLabels
mov ax, LABEL_MARGINS
mov es:[bp].PSR_margins.PCMP_left, ax
mov es:[bp].PSR_margins.PCMP_right, ax
mov es:[bp].PSR_margins.PCMP_top, ax
mov es:[bp].PSR_margins.PCMP_bottom, ax
doneLabels:
endif
; Set the document size info
;
mov ax, MSG_PRINT_CONTROL_SET_DOC_SIZE_INFO
call ObjCallInstanceNoLock
; Now return the desired values
;
clr cx
mov ax, es:[bp].PSR_margins.PCMP_left
add ax, es:[bp].PSR_margins.PCMP_right
subdw es:[bp].PSR_width, cxax
mov ax, es:[bp].PSR_margins.PCMP_top
add ax, es:[bp].PSR_margins.PCMP_bottom
subdw es:[bp].PSR_height, cxax
.leave
ret
PrintControlCalcDocDimensions endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlCheckIfDocWillFit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if the document will fit on the page
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_CHECK_IF_DOC_WILL_FIT)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
CX = TRUE to generate warning message, FALSE otherwise
RETURN: AX = TRUE if the document will fit, FALSE otherwise
DESTROYED: CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/13/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlCheckIfDocWillFit method dynamic PrintControlClass,
MSG_PRINT_CONTROL_CHECK_IF_DOC_WILL_FIT
.enter
; Get the current document size & page size
;
EC < jcxz errorDone >
EC < cmp cx, TRUE >
EC < ERROR_NE PC_MUST_PASS_TRUE_OR_FALSE >
EC <errorDone: >
sub sp, 2 * (size PageSizeReport)
mov dx, ss
mov bp, sp
push cx
mov ax, MSG_PRINT_CONTROL_GET_DOC_SIZE_INFO
call ObjCallInstanceNoLock
add bp, size PageSizeReport
mov ax, MSG_PRINT_CONTROL_GET_PAPER_SIZE_INFO
call ObjCallInstanceNoLock
pop cx
; Now perform the comparison work
;
push ds, si
mov ds, dx
mov si, bp
sub si, size PageSizeReport
mov di, bp
call WillDocumentFit ; TRUE/FALSE/1 => AX
cmp ax, 1
jne continue
mov ax, TRUE
continue:
pop ds, si
add sp, 2 * (size PageSizeReport)
jcxz done ; if no message, we're done
tst ax
jnz done ; if we fit, display no message
; Else display a message to the user
;
mov ax, MSG_SPOOL_SUMMONS_REMOTE_ERROR
mov cx, PCERR_DOC_WONT_FIT
mov bp, MSG_META_DUMMY ; no method back
call PCCallSummons ; call the SpoolSummons object
clr ax ; return FALSE
done:
.leave
ret
PrintControlCheckIfDocWillFit endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintGetFirstPageOffset
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Return the height of the current cover page.
CALLED BY: MSG_PRINT_GET_FIRST_PAGE_OFFSET
PASS: *ds:si = PrintControlClass object
ds:di = PrintControlClass instance data
ds:bx = PrintControlClass object (same as *ds:si)
es = segment of PrintControlClass
ax = message #
RETURN: dx = height of the last
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimw 4/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintGetFirstPageOffset method dynamic PrintControlClass,
MSG_PRINT_GET_FIRST_PAGE_OFFSET
uses ax, cx, bp
.enter
mov ax, MSG_MSAC_GET_EXTRA_TOP_SPACE
call PCCallAddressControl
jc exit ;carry set if success.
clr dx
exit:
.leave
ret
PrintGetFirstPageOffset endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Section #3: Handlers & routines for printing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlInitiatePrint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initiate a "new" dialog box
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_INITIATE_PRINT)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
Don 2/90 Updated to move to spooler
Don 11/93 Changed to use more general message
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlInitiatePrint method PrintControlClass,
MSG_PRINT_CONTROL_INITIATE_PRINT
; Display all printer drivers
;
mov cl, PDT_PRINTER
FALL_THRU PrintControlInitiateOutputUI
PrintControlInitiatePrint endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlInitiateOutputUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initiate the display of one of the "output" dialog boxes
(currently either Printing or Faxing)
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_INITIATE_OUTPUT_UI)
PASS: *DS:SI = PrintControlClass object
DS:DI = PrintControlClassInstance
CL = PrinterDriverType
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 11/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlInitiateOutputUI method PrintControlClass,
MSG_PRINT_CONTROL_INITIATE_OUTPUT_UI
; First, see if we are already printing by checking
; if there is a JobParameters handle in our temporary
; instance data.
;
call PCAccessTemp
tst ds:[di].TPCI_jobParHandle
jz continue
error:
mov ax, SST_NO_INPUT
call UserStandardSound
done:
ret
; Are we enabled (i.e. is it even possible for the user
; to interact with the print dialog?)
continue:
push cx
mov ax, MSG_GEN_GET_ENABLED
call ObjCallInstanceNoLock
pop cx
jnc error
; Build the dialog box, if this is the first time it
; has been displayd
;
call PCIsAddrControl
jc done
mov bx, ds:[di].TPCI_currentSummons.handle
tst bx
jnz displayBox ; if non-zero, box exists
push cx
call PCBuildSummons ; else build the dialog...
call InitializeDialogBox ; and initialize the sucker
pop cx
; Set the type of print dialog to be displayed, and
; bring it up
displayBox:
mov si, ds:[di].TPCI_currentSummons.chunk
mov ax, MSG_SPOOL_SUMMONS_SET_DRIVER_TYPE
call PCObjMessageSend
mov ax, MSG_GEN_INTERACTION_INITIATE
call PCObjMessageSend
mov ax, MSG_GEN_BRING_TO_TOP
call PCObjMessageSend
ret
PrintControlInitiateOutputUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeDialogBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize the spool print control
CALLED BY: PrintControlInitiatePrint
PASS: BX:SI = SpoolSummonsClass object
DS:*DI = PrintControl instance data
CL = PrinterDriverType
RETURN: DS:DI = TempPrintCtrlInstance
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 4/12/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeDialogBox proc far
class PrintControlClass
uses si
.enter
; Access the important data
;
push di ; PrintControl chunk handle
mov di, ds:[di] ; dereference the handle
add di, ds:[di].PrintControl_offset
push ds:[di].PCI_startUserPage
push ds:[di].PCI_endUserPage ; save start & end user pages
push ds:[di].PCI_startPage
push ds:[di].PCI_endPage ; save start & end page range
push ds:[di].PCI_defPrinter ; save the default printer #
mov cx, ds:[di].PCI_attrs ; attributes => CX
; Now send this information to the SpoolDialogBox
;
mov ax, MSG_SPOOL_SUMMONS_SET_PRINT_ATTRS
call PCObjMessageSend ; send over the attributes
pop cx ; restore the default printer
mov ax, MSG_SPOOL_SUMMONS_SET_DEFAULT_PRINTER
call PCObjMessageSend
pop cx, dx ; start & end page => CX, DX
mov ax, MSG_SPOOL_SUMMONS_SET_PAGE_RANGE
call PCObjMessageSend
pop cx, dx ; start & end user pages
mov ax, MSG_SPOOL_SUMMONS_SET_USER_PAGE_RANGE
call PCObjMessageSend
mov ax, MSG_SPOOL_SUMMONS_INITIALIZE_UI_LEVEL
call PCObjMessageSend ; initialize the UI level
; Clean up
;
pop si
call PCAccessTemp ; TempPrintCtrlInstance => DS:DI
.leave
ret
InitializeDialogBox endp
PCObjMessageSend proc near
mov di, mask MF_FIXUP_DS
GOTO PCObjMessage
PCObjMessageSend endp
PCObjMessageCall proc near
mov di, mask MF_FIXUP_DS or mask MF_CALL
FALL_THRU PCObjMessage
PCObjMessageCall endp
PCObjMessage proc near
call ObjMessage
ret
PCObjMessage endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlPrint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Actually print a document
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_PRINT)
PASS: DS:*SI = PrintControl instance data
ES = Segment of the PrintControlClass
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP, SI, DI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
Don 3/90 Incorporates the print spooler
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlPrint method dynamic PrintControlClass,
MSG_PRINT_CONTROL_PRINT
; Are we already printing ? If so, exit
;
call PCAccessTemp ; access the local data
tst ds:[di].TPCI_jobParHandle ; are we already spooling ??
jnz done ; ...if so, exit now
; Allocate memory for a JobParameters structure
;
mov ax, size JobParameters ; bytes to allocate
mov cx, ((mask HF_SHARABLE or mask HF_SWAPABLE) or \
((mask HAF_LOCK or mask HAF_NO_ERR) shl 8))
call MemAlloc ; allocate the block
mov es, ax
clr bp ; ES:BP is the JobParamters
mov ds:[di].TPCI_jobParHandle, bx ; store the JobPar block handle
and ds:[di].TPCI_status, not (mask PSF_ABORT or \
mask PSF_RECEIVED_COMPLETED or \
mask PSF_RECEIVED_NAME or \
mask PSF_VERIFIED)
SBCS < mov {byte} es:[bp].JP_fname, 0 ; Create NULL name for spoolfile>
DBCS < mov {wchar} es:[bp].JP_fname, 0 ; Create NULL name for spoolfile>
mov es:[bp].JP_size, (size JobParameters)
; Now handle all the verification chores
;
call PrintRequestUIOptions
jc abortPrint
call MemUnlock ; unlock the JobParameters
call PrintRequestAppVerify
jc done
mov cx, TRUE ; keep on printing!
mov di, ds:[si] ; dereference chunk handle
add di, ds:[di].PrintControl_offset
GOTO PrintControlVerifyCompleted
; We have some sort of problem. Abort, abort
;
abortPrint label near
call MemFree ; free the job parameters
mov ax, MSG_MSAC_PRINTING_CANCELED
call PCCallAddressControl
call PCAccessTemp
call PrintMarkAppNotBusy ; mark app not busy (if needed)
clr ds:[di].TPCI_jobParHandle ; not in middle of job now
done:
call CheckUpOnPrintCompletionMessage ; See if we should send out
ret ; completion message
PrintControlPrint endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlVerifyCompleted
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Received when the application decides to allow the printing
to occur, or to reject it altogether.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_VERIFY_COMPLETED)
PASS: DS:*SI = PrintControlClass object
DS:DI = PrintControlClassInstance
CX = TRUE - continue print job
= FALSE - abandon print job
RETURN: Nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlVerifyCompleted method PrintControlClass,
MSG_PRINT_CONTROL_VERIFY_COMPLETED
; See if we continue to print or not. If so, bring down the
; print dialog box.
;
mov dx, ds:[di].PCI_attrs ; get PrintControlAttrs
call PCAccessTemp ; local data => DS:DI
mov bx, ds:[di].TPCI_jobParHandle ; JobParameters handle => BX
cmp cx, FALSE ; abort printing ??
je abortPrint ; yes, so jump
; We need to bring down the print dialog box, and possibly mark
; the application as busy.
;
push bx, si
call PrintMarkAppBusy ; mark application busy
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
mov bx, ds:[di].TPCI_currentSummons.handle
mov si, ds:[di].TPCI_currentSummons.chunk
call PCObjMessageCall
pop bx, si
; Now fill in most of the structure (BX, BP, SI preserved by all)
;
call MemLock ; else re-lock JobParameters
mov es, ax
clr bp ; ES:BP is the JobParamters
call PrintRequestDocName
call PrintGetApplicationName
call PrintGetPrinterInfo
jc abortPrint ; if get info error, abort
call PrintCreateSpoolFile ; returns AX & DI
jc abortPrint ; if file creation error, abort
; Create graphics string
;
call PrintCreateProgressDB ; create progress box, if needed
call MemUnlock ; unlock the JobParameters
mov bp, di ; gstring => BP
call PCAccessTemp ; access the local data
mov ds:[di].TPCI_fileHandle, ax ; save the spool file handle
mov ds:[di].TPCI_gstringHandle, bp ; save the gstring handle
; Send the print method to the OD
;
mov ax, MSG_PRINT_START_PRINTING
mov bx, offset PCI_output
call PCSendToOutputOD
ret
PrintControlVerifyCompleted endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlReportProgress
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Display information about the status of a print job as the
application spools the data.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_REPORT_PROGRESS)
PASS: DS:*SI = PrintControl object
DS:DI = PrintControlInstance
CX = PCProgressType
PCPT_PAGE
DX = Page number
PCPT_PERCENT
DX = Percentage compeleted
PCPT_TEXT
DX:BP = Text message to display
RETURN: AX = TRUE (continue printing)
= FALSE (abort printing)
DESTROYED: BX, CX, DX, DI, SI, BP, DS, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/8/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
progressUpdate nptr.near ProgressUpdatePage,
ProgressUpdatePercent,
ProgressUpdateText
PrintControlReportProgress method dynamic PrintControlClass,
MSG_PRINT_CONTROL_REPORT_PROGRESS
.enter
; Let's parse of what we need to do
;
EC < cmp cx, PCProgressType ; check for valid type >
EC < ERROR_AE PC_ILLEGAL_PC_PROGRESS_TYPE >
EC < test cx, 0x1 ; must be even >
EC < ERROR_NZ PC_ILLEGAL_PC_PROGRESS_TYPE >
call PCAccessTemp ;TempPrintCtrlInstance => DS:DI
mov ax, FALSE ; assume we've aborted
test ds:[di].TPCI_status, mask PSF_ABORT
jnz done ; if assumption correct, jump
mov bx, cx
mov ax, cs:[progressUpdate][bx] ; function address => AX
mov bx, ds:[di].TPCI_progressBox.handle
tst bx ; is a progress box even up??
jz keepPrinting ; nope, so just keep printing
call ax ; call the update function
keepPrinting:
mov ax, TRUE ; and continue printing
done:
.leave
ret
PrintControlReportProgress endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlSetDocName
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Copy the name of the document into the JobParameters field,
for later use by the spooler.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_SET_DOC_NAME)
PASS: DS:*SI = PrintControlClass instance data
CX:DX = Buffer containing the document name
RETURN: Nothing
DESTROYED: AX, BX, DI, SI, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/8/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlSetDocName method dynamic PrintControlClass,
MSG_PRINT_CONTROL_SET_DOC_NAME
uses cx, dx, bp
.enter
; Access the JobParameters structure
;
call PCAccessTemp ; access my local variables
mov bx, ds:[di].TPCI_jobParHandle ; job handle => BX
tst bx ; valid handle ??
jz done ; no, so do nothing
push ds, si, di ; save pointer to LPCD
push ds:[di].TPCI_progressBox.handle ; save object block handle
call MemLock ; lock the structure
mov es, ax
mov di, offset JP_documentName ; buffer => ES:DI
; Now copy the string
;
mov ds, cx
mov si, dx ; string => DS:SI
mov cx, FILE_LONGNAME_LENGTH+1 ; maximum string size
SBCS < rep movsb ; copy the bytes >
DBCS < rep movsw ; copy the bytes >
call MemUnlock ; unlock the JobParameters
; Also copy the string into the progess box, if necessary
;
pop cx ; progress object block handle
jcxz doneProgress
mov si, offset ProgressUI:ProgressDocument
push ds, dx ; save the document name
mov bx, handle Strings
call MemLock
mov ds, ax
assume ds:Strings
mov dx, ds:[progressAppDivider] ; string => DS:DX
call PCAppendText ; append the text
call MemUnlock
assume ds:dgroup
pop ds, dx ; document name => DS:DX
call PCAppendText
doneProgress:
pop ds, si, di ; TempPrintCtrlInstance =>DS:DI
or ds:[di].TPCI_status, mask PSF_RECEIVED_NAME
call StartPrintJob ; start printing ?
done:
.leave
ret
PrintControlSetDocName endp
PCAppendText proc near
uses bx, cx
.enter
mov bx, cx ; GenText object => BX:SI
mov bp, dx
mov dx, ds ; string => DX:BP
clr cx ; string is NULL terminated
mov ax, MSG_VIS_TEXT_APPEND ; append the text to the end
mov di, mask MF_CALL
call ObjMessage
.leave
ret
PCAppendText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlPrintingCompleted
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handle notification that printing is completed
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_PRINTING_COMPLETED)
PASS: ES = Segment of PrintControlClass
DS:*SI = PrintControlClass instance data
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 1/90 Initial version
Don 3/90 Modified to use true spooler
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlPrintingCompleted method PrintControlClass,
MSG_PRINT_CONTROL_PRINTING_COMPLETED
.enter
; Clean up the progress dialog box & the busy cursor
;
push si ; save PC object chunk
call PCAccessTemp ; TempPrintCtrlInstance => DS:DI
; Hold up completion event
; for IACP until the very
; end.
inc ds:[di].TPCI_holdUpCompletionCount
call PrintDestroyProgressDB ; destroy progress dialog box
call PrintMarkAppNotBusy ; mark app not busy
; Destroy the gstring
;
push di ; save temp instance data
clr si
xchg si, ds:[di].TPCI_gstringHandle ; gstring handle => SI
mov di, si
call GrEndGString ; end the gstring
mov dl, GSKT_LEAVE_DATA ; leave data alone
clr di ; no associated GState
call GrDestroyGString ; and destroy the handle
pop si ; restore temp instance data
cmp ax, GSET_DISK_FULL ; check to see if disk filled
je diskFullError ; handle error.
; Close the file
;
clr bx
xchg bx, ds:[si].TPCI_fileHandle ; file handle => BX
mov al, FILE_NO_ERRORS ; close that file now
call FileClose
; Get the remaining pieces of information
;
mov ax, mask PSF_VERIFIED ; assume verification OK
mov bx, ds:[si].TPCI_jobParHandle ; job handle => BX
test ds:[si].TPCI_status, mask PSF_ABORT
pop si ; PrintControl => DS:*SI
jnz release ; if aborted, release job
call MemLock ; lock the block
mov es, ax
clr bp ; ES:BP => JobParameters
push bx ; save the block handle
call PrintGetDocumentInfo ; PrintStatusFlags => AL
pop bx ; job handle => BX
call MemUnlock ; unlock the JobParameters
; Now go to release the print job
release:
call PCAccessTemp ; locals => DS:DI
or al, mask PSF_RECEIVED_COMPLETED
or ds:[di].TPCI_status, al
call StartPrintJob ; start the job now ?
done:
call PCAccessTemp ; locals => DS:DI
dec ds:[di].TPCI_holdUpCompletionCount
call CheckUpOnPrintCompletionMessage ; See if we should send out
.leave
ret
; disk filled up when gstring was being created. Abort the print job,
; which means deleting the spool file, and biffing the spool job block.
; Also, put up a box for the user to tell him/her what is going on...
;
diskFullError:
pop si ; PC object => *DS:SI
push ds, si ; save object
call PrintControlPrintingCancelled
pop ds, si ; restore object
; Display error message for the user
;
mov bp, MSG_META_DUMMY ; method to return (none)
mov cx, PCERR_DISK_FULL ; error type
mov ax, MSG_SPOOL_SUMMONS_REMOTE_ERROR
call PCCallSummons ; call over to the summons
jmp done
PrintControlPrintingCompleted endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlPrintingCancelled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Cancel a print job request in progress
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_PRINTING_CANCELLED)
PASS: DS:*SI = PrintControl instance data
RETURN: Nothing
DESTROYED: AX, BX, DX, DI, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/21/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlPrintingCancelled method PrintControlClass,
MSG_PRINT_CONTROL_PRINTING_CANCELLED
; Destroy the gstring
;
push ds:[LMBH_handle], si
call PCAccessTemp ; access the local variables
call PrintDestroyProgressDB ; destroy progress dialog box
call PrintMarkAppNotBusy ; mark app not busy
clr si
xchg si, ds:[di].TPCI_gstringHandle ; gstring handle => SI
tst si
jz closeFile
push di ; save temp instance data
clr di ; no associated GState
mov dl, GSKT_LEAVE_DATA ; leave data alone
call GrDestroyGString ; and destroy the handle
pop di ; restore temp instance data
; Close the file
closeFile:
clr bx
xchg bx, ds:[di].TPCI_fileHandle ; file handle => BX
tst bx
jz deleteFile
clr al
call FileClose ; close the file
; Delete the spool file
deleteFile:
clr bx
xchg bx, ds:[di].TPCI_jobParHandle ; job handle => BX
tst bx ; job still here ??
jz done ; nope, so leave
call MemLock ; lock the JobParameters
mov ds, ax
mov dx, offset JP_fname ; DS:DX => filename
call FilePushDir ; save the current directory
mov ax, SP_SPOOL ; change to the spool directory
call FileSetStandardPath ; as one of the standard paths
call FileDelete ; delete this spool file
call FilePopDir ; return to original directory
call MemFree ; free the JobParameters block
; Clean up
done:
pop bx, si
call MemDerefDS ; PrintControl object => *DS:SI
; Tell any associated MailboxSpoolAddressControl
push bp ; necessary?
mov ax, MSG_MSAC_PRINTING_CANCELED
call PCCallAddressControl
pop bp
call CheckUpOnPrintCompletionMessage ; See if we should send out
ret ; completion message
PrintControlPrintingCancelled endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlVerifyPrint
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: The document size/margin verification has occurred, and the
user has decided to go ahead
CALLED BY: UI (MSG_PRINT_CONTROL_VERIFY_*)
PASS: DS:DI = PrintControl specific instance data
CX:DX = OD of GenTrigger in verify dialog box
AX = Method passed
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 4/1/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlVerifyPrint method PrintControlClass,
MSG_PRINT_CONTROL_VERIFY_PRINT,
MSG_PRINT_CONTROL_VERIFY_SCALE,
MSG_PRINT_CONTROL_VERIFY_CANCEL
; Free the verify dialog box, as we're done with it
;
push ax, si
mov bx, cx
mov si, offset SizeVerifyDialogBox ; OD of verify box => BX:SI
call PCSetNotUsable ; first set it not usable...
mov ax, MSG_META_BLOCK_FREE
call PCObjMessageSend ; ...then free the block
; Set the proper bit (ignore scaling for now)
;
pop ax, si
call PCAccessTemp
or ds:[di].TPCI_status, mask PSF_VERIFIED
cmp ax, MSG_PRINT_CONTROL_VERIFY_CANCEL
jne doPrinting
or ds:[di].TPCI_status, mask PSF_ABORT
; Else try to print the job now (set/clear scaling flag)
doPrinting:
mov bx, ds:[di].TPCI_jobParHandle
tst bx
jz done
cmp ax, MSG_PRINT_CONTROL_VERIFY_PRINT
je startJob
call MemLock
mov es, ax
or es:[JP_spoolOpts], mask SO_SCALE
call MemUnlock
startJob:
call StartPrintJob ; now print (maybe)
done:
.leave
ret
PrintControlVerifyPrint endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SizeVerifyDialogUpdateWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: clean up if the verify dialog is up on detach
CALLED BY: MSG_META_UPDATE_WINDOW
PASS: *ds:si = SizeVerifyDialogClass object
ds:di = SizeVerifyDialogClass instance data
ds:bx = SizeVerifyDialogClass object (same as *ds:si)
es = segment of SizeVerifyDialogClass
ax = message #
cx = UpdateWindowFlags
dl = VisUpdateMode
RETURN:
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 9/16/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SizeVerifyDialogUpdateWindow method dynamic SizeVerifyDialogClass,
MSG_META_UPDATE_WINDOW
test cx, mask UWF_DETACHING
jz callSuper
push ax, cx, dx
mov ax, MSG_PRINT_CONTROL_VERIFY_CANCEL
mov cx, ds:[LMBH_handle]
mov dx, offset AlertCancelPrintingTrigger
call GenCallParent
pop ax, cx, dx
callSuper:
mov di, offset SizeVerifyDialogClass
GOTO ObjCallSuperNoLock
SizeVerifyDialogUpdateWindow endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartPrintJob
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send the print job off to the spooler
CALLED BY: PrintControlPrintingCompleted
PrintControlSetDocName
PASS: *DS:SI = PrintControl object
DS:DI = TempPrintCtrlInstance
RETURN: Nothing
DESTROYED: AX, BX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/9/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StartPrintJob proc near
class PrintControlClass
uses bp
.enter
; Are we truly ready to print ?
;
mov al, ds:[di].TPCI_status
and al, READY_TO_RELEASE_JOB ; check only those bits
xor al, READY_TO_RELEASE_JOB ; ensure all are set
jnz exit ; if all not set, fail
; Send the job to the spooler
;
clr bx
xchg bx, ds:[di].TPCI_jobParHandle ; job handle => BX
test ds:[di].TPCI_status, mask PSF_ABORT
jnz free
; Call associated MailboxSpoolAddressControl, if there is one.
;
mov cx, bx
push bp
mov ax, MSG_MSAC_PRINTING_COMPLETE
call PCCallAddressControl
pop bp
jc done ; => is one, so all done here
push si ; save PC chunk handle
call MemLock ; lock the block
mov_tr dx, ax
clr si ; JobParameters => DX:SI
call SpoolAddJob ; returns CX => Job handle
pop si ; PrintControl => *DS:SI
push bx ; save JobParameters handle
mov ax, MSG_PRINT_NOTIFY_PRINT_JOB_CREATED
mov bx, offset PCI_output
mov bp, cx ; JobID => BP
call PCSendToOutputOD ; send the message
call PCAccessTemp ; access the local variables
pop bx ; restore JobParameters handle
free:
call MemFree ; free the job block
; Now see if we need to deal with an aborted print job
;
test ds:[di].TPCI_status, mask PSF_ABORT
jz done ; no linked jobs, so we're done
mov ax, MSG_PRINT_CONTROL_PRINTING_CANCELLED
mov bx, ds:[LMBH_handle] ; PC OD => BX:SI
mov di, mask MF_FORCE_QUEUE
call ObjMessage
done:
call CheckUpOnPrintCompletionMessage ; See if we should send out
exit: ; completion message
.leave
ret
StartPrintJob endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintControlAbortPrintJob
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called to abort the current print job. All the data structures
will be freed when either MSG_PC_PRINTING_COMPLETED or
MSG_PC_PRINTING_CANCELLED is called.
CALLED BY: GLOBAL (MSG_PRINT_CONTROL_ABORT_PRINT_JOB)
PASS: DS:*SI = PrintControlClass object
DS:DI = PrintControlClassInstance
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/22/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintControlAbortPrintJob method dynamic PrintControlClass,
MSG_PRINT_CONTROL_ABORT_PRINT_JOB
.enter
; Set the "abort" flag
;
call PCAccessTemp ; TempPrintCtrlInstance => DS:DI
or ds:[di].TPCI_status, mask PSF_ABORT
.leave
ret
PrintControlAbortPrintJob endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintGetDocumentInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Obtain all the document information
CALLED BY: PrintControlPrint
PASS: ES:BP = JobParamters structure
DS:*SI = PrintControl instance data
RETURN: AX = PrintStatusFlags
mask PSF_VERIFIED (or 0)
ES:BP = JobParameters structure
JP_numPages
JP_printMode
JP_paperSize
JP_paperPath
JP_docWidth
JP_docHeight
JP_spoolType
JP_customWidth (if necessary)
JP_customHeight (if necessary)
DESTROYED: AH, BX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/29/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintGetDocumentInfo proc near
class PrintControlClass
uses bp, si, es
.enter
; Get the document size information
;
mov ax, MSG_PRINT_CONTROL_GET_DOC_SIZE_INFO
mov bx, bp ; JobParameters => ES:BX
mov dx, es
add bp, offset JP_docSizeInfo ; PageSizeReport => DX:BP
call ObjCallInstanceNoLock
; Grab the values from the SpoolSummons
;
mov ax, MSG_SPOOL_SUMMONS_GET_USER_PAGE_RANGE
mov di, ds:[si]
add di, ds:[di].PrintControl_offset
test ds:[di].PCI_attrs, mask PCA_PAGE_CONTROLS
jnz callSummons
mov ax, MSG_SPOOL_SUMMONS_GET_PAGE_RANGE
callSummons:
call PCCallSummons
EC < ERROR_NC PRINT_GET_DOCUMENT_INFO_NO_SPOOL_SUMMONS >
sub dx, cx ; last page - first page
inc dx ; account for same page
mov es:[bx].JP_numPages, dx ; store the value
; Get all the print mode stuff
;
mov ax, MSG_SPOOL_SUMMONS_GET_PRINT_INFO
call PCCallSummons
EC < ERROR_NC PRINT_GET_DOCUMENT_INFO_NO_SPOOL_SUMMONS >
mov es:[bx].JP_printMode, cl
mov es:[bx].JP_spoolOpts, ch
mov es:[bx].JP_retries, dl
mov es:[bx].JP_numCopies, dh
mov es:[bx].JP_timeout, bp
; Get the paper size information
;
mov ax, MSG_SPOOL_SUMMONS_GET_PAPER_SIZE_INFO
mov dx, es
mov bp, bx
add bp, offset JP_paperSizeInfo ; PageSizeReport buffer => DX:BP
call PCCallSummons
EC < ERROR_NC PRINT_GET_DOCUMENT_INFO_NO_SPOOL_SUMMONS >
mov bp, bx ; ES:BP => JobParameters
if _HACK_20_FAX
mov ax, MSG_SPOOL_SUMMONS_GET_DRIVER_TYPE
call PCCallSummons ; PrinterDriverType => CL
;
; Here is a hack for faxing under on 20X. Release20X fax printer
; driver returns margins of 0, so in
; SpoolSummonsGetPrinterMargins we set the left and right
; margins to 1/4 inch if they are 0. However, here we need to
; have the margins at 0.
;
; On the same line of hacks, we're going to set the top margin
; to be 1/4 inch.
; 5/6/95 - ptrinh
;
cmp cl, PDT_FACSIMILE ; es:bx => JobParameters
jne notFax
clr es:[bx].JP_paperSizeInfo.PSR_margins.PCMP_left
clr es:[bx].JP_paperSizeInfo.PSR_margins.PCMP_right
mov es:[bx].JP_paperSizeInfo.PSR_margins.PCMP_top, 72/4
notFax:
endif
; Verify the margin and document sizes
;
mov ax, MSG_PRINT_CONTROL_CHECK_IF_DOC_WILL_FIT
mov cx, FALSE
call ObjCallInstanceNoLock
tst ax ; check returned value
mov ax, mask PSF_VERIFIED
LONG jnz done ; document fits, so we're done
; Otherwise we don't fit. What sort of output are we creating?
;
mov ax, MSG_SPOOL_SUMMONS_GET_DRIVER_TYPE
call PCCallSummons ; PrinterDriverType => CL
mov al, cl
; Display the error box, and let the user decide what to do
;
mov cx, handle SizeVerifyDialogBox ; resource handle => CX
mov dx, offset SizeVerifyDialogBox ; chunk handle => DX
mov bp, -1 ; OD not stored anywhere
call PCDuplicateBlock ; new resource handle => BX
; Display the proper text string
;
mov dx, handle SpoolDocWontFitFax
mov bp, offset SpoolDocWontFitFax ; text => ^lDX:BP
cmp al, PDT_FACSIMILE
je setText
mov dx, handle SpoolDocWontFitPrint
mov bp, offset SpoolDocWontFitPrint ; text => ^lDX:BP
setText:
push ax
mov ax, MSG_VIS_TEXT_REPLACE_ALL_OPTR
mov si, offset AlertMessage ; TextObject OD => BX:SI
clr cx ; text is NULL terminated
call PCObjMessageCall
pop ax
; Remove one of the Cancel trigger
;
mov si, offset AlertCancelPrintingTrigger
cmp al, PDT_FACSIMILE
je removeTrigger
mov si, offset AlertCancelFaxingTrigger
removeTrigger:
mov ax, MSG_GEN_SET_NOT_USABLE
mov dl, VUM_NOW
call PCObjMessageCall
; If necessary, change a string to allow the dialog to fit on
; the screen.
;
segmov es, dgroup, ax
test es:[uiOptions], mask SUIO_SIMPLE
jz displayToUser ; not simple, so do nothing
mov ax, MSG_GEN_USE_VIS_MONIKER
mov cx, offset ShortActualSizeMoniker
mov dl, VUM_DELAYED_VIA_UI_QUEUE
mov si, offset AlertPrintTrigger
call PCObjMessageSend
; Now display it to the user
displayToUser:
mov ax, SST_ERROR
call UserStandardSound
mov si, offset SizeVerifyDialogBox ; Dialog box OD => BX:SI
mov ax, MSG_GEN_INTERACTION_INITIATE
call PCObjMessageCall
;
; if detaching, fit dialog didn't come up, pretend we've cancelled
;
mov ax, MSG_GEN_APPLICATION_GET_STATE
call UserCallApplication ; ax = ApplicationStates
test ax, mask AS_DETACHING
mov ax, 0 ; don't set verify flag
jz done
call PCSetNotUsable ; set verify box not usable
mov ax, MSG_META_BLOCK_FREE
call PCObjMessageSend ; free the block
mov ax, mask PSF_VERIFIED or mask PSF_ABORT
done:
.leave
ret
PrintGetDocumentInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintGetApplicationName
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fills the structure eith the application's permanent name
CALLED BY: PrintControlPrint
PASS: ES:BP = JobParamters structure
DS:*SI = PrintControl instance data
RETURN: ES:BP = JobParamters
JP_parent filled in
DESTROYED: AX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintGetApplicationName proc near
class PrintControlClass
uses bx, bp, si
.enter
; Just call to copy the string. Use the JP_parent field as a
; temporary buffer
;
.assert (size GeodeToken) le (size JP_parent)
add bp, offset JP_parent
mov di, bp ; JP_parent field => ES:DI
mov bx, ds:[LMBH_handle] ; handle of block => BX
call MemOwner ; process owning block => BX
mov ax, GGIT_TOKEN_ID
call GeodeGetInfo
mov ax, {word} es:[di+0].GT_chars
mov bx, {word} es:[di+2].GT_chars
mov si, {word} es:[di].GT_manufID
; Now get the proper moniker
;
push bp ; save offset to JP_parent
mov dh, DC_TEXT ; DisplayType
mov bp, (VMS_TEXT shl offset VMSF_STYLE)
mov cx, ds:[LMBH_handle] ; block in which to load moniker
clr di ; allocate a chunk
push cx ; handle
push bp ; pass VisMonikerSearchFlags
push di ; pass unused buffer size
call TokenLoadMoniker ; load a moniker; chunk => DI
pop bx ; handle
call MemDerefDS
pop bp ; restore offset to JP_parent
SBCS < mov {byte} es:[bp], 0 ; assume none (preserve CF)>
DBCS < mov {wchar} es:[bp], 0 ; assume none (preserve CF)>
jc done ; if no moniker, fail
; Now copy the text into our structure
;
mov ax, di ; LMem handle => AX
mov si, ds:[di] ; dereference the handle
mov di, bp ; destination => ES:DI
test ds:[si].VM_type, mask VMT_GSTRING
jnz fail ; a GString? No text moniker
add si, offset VM_data + offset VMT_text
mov cx, FILE_LONGNAME_LENGTH + 1 ; maximum string length
LocalCopyNString ; copy the chars
fail:
call LMemFree ; free the chunk
done:
.leave
ret
PrintGetApplicationName endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintGetPrinterInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Obtain all the printer-related information
CALLED BY: PrintControlPrint
PASS: ES:BP = JobParamters structure
DS:*SI = PrintControl instance data
RETURN: ES:BP = JobParameters structure filled in
JP_printerName
JP_deviceName
JP_portInfo
carry set if error
DESTROYED: AX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/29/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
deviceString byte 'device', 0
portString byte 'port', 0
PrintGetPrinterInfo proc near
class PrintControlClass
uses bx, bp
.enter
; Let's grab some strings
;
push ds, si
push si
call PCGetSummons
pop si
push bx
call PCOpenPrintStrings ; sets up DS, DI, CX, DX
call SSGetPrinterCategory ; returns the string in DS:SI
mov di, bp ; JobParamters => ES:DI
; Get the driver name first
;
push di ; save start of JobParameters
push si ; save start of category
add di, offset JP_printerName ; ES:DI = buffer to fill
inc cx ; copy one additional character
LocalCopyNString ; copy the chars
pop si ; restore start of category
pop di ; rest. start of JobParameters
ConvPrinterNameToIniCat
; Now get the device name
;
push di ; save start of JobParameters
mov cx, cs
mov dx, offset PrintControlCode:deviceString
add di, offset JP_deviceName ; ES:DI = buffer to fill
mov bp, (MAX_DEVICE_NAME_SIZE*(size wchar)) or INITFILE_INTACT_CHARS
call InitFileReadString ; copy the string
pop di ; restore JobParameters
jc abort
; Last, but not least, get the port the printer is connected to
;
mov cx, cs
mov dx, offset PrintControlCode:portString
SBCS < mov bp, INITFILE_UPCASE_CHARS ; allocate a buffer >
DBCS < clr bp ; allocate a buffer >
call InitFileReadString ; put the string in a buffer
; Grab the actual information, and clean up
;
abort:
pop dx ; PrintUI resource handle
jc exit
call PrinterGetPortInfo ; get all the port info
clc ; no error
exit:
ConvPrinterNameDone
pop ds, si ; restore these registers
call PCClosePrintStrings ; unlock the buffer
.leave
ret
PrintGetPrinterInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetPortInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get all the port information
CALLED BY: PrintGetPrinterInfo
PASS: ES:DI = JobParamters structure
DS:SI = Printer category string
BX = Block handle of port name
DX = PrintUI resource handle
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/30/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PortInfo struct
SBCS < PI_name char 2 dup(?) >
DBCS < PI_name wchar 2 dup(?) >
PI_portType PrinterPortType
PortInfo ends
; First 2 characters are enough to distinguish the port type. Fourth
; character is used (for serial and parallel), to get port #
portTable PortInfo \
<"LP", PPT_PARALLEL>,
<"CO", PPT_SERIAL>,
<"CU", PPT_CUSTOM>,
<"UN", PPT_NOTHING>
baudRateString char 'baudRate', 0
handShakeString char 'handshake', 0
parityString char 'parity', 0
wordLenString char 'wordLength', 0
stopBitsString char 'stopBits', 0
stopRemoteString char 'stopRemote', 0
stopLocalString char 'stopLocal', 0
PrinterGetPortInfo proc near
.enter
; Determine if we are printing to a file
;
push ds, si
xchg bx, dx ; PrintUI resource handle => BX
mov si, offset PrintUI:PrintDialogBox
mov ax, MSG_SPOOL_SUMMONS_PRINTING_TO_FILE
mov di, mask MF_CALL ; method preserves DX, BP
call ObjMessage ; AX = 0 (no) or 1 (yes)
; Setup some string stuff
;
xchg bx, dx ; handle of port name => BX
mov_tr cx, ax ; to file or no" value => CX
call MemLock ; lock handle in BX
mov ds, ax
clr si ; port name now in DS:SI
; Get the printer port type and number
;
push cx
DBCS < push bx >
mov bp, offset portTable
mov cx, length portTable
mov ax, ds:[si] ; fetch first 2 characters of
; port name
DBCS < mov bx, ds:[si][2] >
startLoop:
cmp ax, {word}cs:[bp].PI_name
if DBCS_PCGEOS
jne notFound
cmp bx, {word}cs:[bp].PI_name+2
endif
je found
if DBCS_PCGEOS
notFound:
endif
add bp, size PortInfo
loop startLoop
EC < pop cx ; if not printing to >
EC < tst cx ; ..a file, we're hosed >
EC < ERROR_Z PRINTER_PORT_TYPE_NOT_KNOWN >
EC < push cx >
found:
DBCS < pop bx >
mov bp, cs:[bp].PI_portType ; PrinterPortType
; attempt to convert the port string to a port number, assuming the
; port is parallel or serial, which look like LPTn and COMn,
; respectively.
SBCS < clr ah >
SBCS < mov al, ds:[si+3] ; port number character => AL>
DBCS < mov ax, ds:[si+6] ; port number character => AX>
sub ax, '1' ; account for the ASCII offset
; '1' => 0, '2' => 1, etc...
shl ax, 1 ; make it a ParallelPortNum
pop cx ; print to file flag
call MemFree ; free the string block
pop ds, si ; restore the printer category
tst cx ; printing to file
jnz filePort ; yes, so do it!
mov es:[di].JP_portInfo.PPI_type, bp
; Set up extra parameters based on port type.
;
cmp bp, PPT_SERIAL
je serialPort ; yes, so jump
cmp bp, PPT_PARALLEL ; check for parallel
je parallelPort
cmp bp, PPT_CUSTOM
jne done
; For custom port, fetch the port data. Necessary for the
; printer control panel to find the right list.
call PrinterGetCustomPortData
done:
.leave
ret
; Handle the parallel case
;
parallelPort:
mov es:[di].JP_portInfo.PPI_params.PP_parallel.PPP_portNum, ax
jmp done
; Handle the file case - grab path out of file selector
;
filePort:
mov es:[di].JP_portInfo.PPI_type, PPT_FILE
mov bx, dx ; PrintUI resource handle => BX
mov si, offset PrintFileFileSelector
mov dx, es
lea bp, es:[di].JP_portInfo.PPI_params.PP_file.FPP_path
mov cx, size FPP_path
mov ax, MSG_GEN_FILE_SELECTOR_GET_DESTINATION_PATH
mov di, mask MF_CALL
call ObjMessage
mov es:[di].JP_portInfo.PPI_params.PP_file.FPP_diskHandle, cx
; Grab the actual file name
;
mov dx, es
lea bp, es:[di].JP_portInfo.PPI_params.PP_file.FPP_fileName
mov cx, size FPP_fileName
mov si, offset PrintFileNameText
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
mov di, mask MF_CALL
call ObjMessage
jmp done
; Handle the serial case (auugggghhhh) - assign defaults first
;
serialPort:
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_portNum, ax
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format,
SerialFormat <0, 0, SP_NONE, 0, SL_8BITS>
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_mode, SM_RAW
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_baud, SB_300
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_flow,
mask SFC_SOFTWARE
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_stopRem,
mask SMC_RTS
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_stopLoc,
mask SMS_CTS
; Now get any changes from the default values
;
call PrinterGetBaudRate
call PrinterGetParity
call PrinterGetWordLength
call PrinterGetStopBits
call PrinterGetHandshake
call PrinterGetControlBits
jmp done
PrinterGetPortInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetCustomPortData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fetch the custom data for the printer port
CALLED BY: (INTERNAL) PrinterGetPortInfo
PASS: es:di = JobParameters
ds:si = printer category
RETURN: nothing
DESTROYED: ax, bx, cx, dx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 5/31/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
customDataStr char 'customPortData', 0
PrinterGetCustomPortData proc near
uses bp, di
.enter
;
; Zero out the buffer for consistency's sake, in case there aren't
; the max number of bytes in the ini file.
;
lea di, ss:[JP_portInfo].PPI_params.PP_custom.CPP_info
mov cx, size CPP_info/2
clr ax
push di
rep stosw
if size CPP_info and 1
.leave
stosb
endif
pop di
;
; Now fetch the data from the ini file, if it's there.
;
mov cx, cs
mov dx, offset customDataStr
mov bp, size CPP_info
call InitFileReadData
.leave
ret
PrinterGetCustomPortData endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetBaudRate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the baud rate for this printer
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer categroy name
RETURN: Nothing
DESTROYED: AX, BX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/17/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetBaudRate proc near
.enter
mov cx, cs
mov dx, offset PrintControlCode:baudRateString
call InitFileReadInteger ; baud rate => AX
jc done ; no data - use default
mov bx, ax ; baud rate => BX
mov dx, 1
mov ax, 49664 ; DX:AX = 152,000(serial magic)
div bx ; quotient => AX
cmp ax, 57 ; was it a 2000 baud port ??
jne setBaud
inc ax ; else adjust baud value
setBaud:
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_baud, ax
done:
.leave
ret
PrinterGetBaudRate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetParity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the printer's parity settings
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer category name
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/17/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetParity proc near
.enter
; Now check the bit format
;
mov cx, cs
mov dx, offset PrintControlCode:parityString
mov bp, INITFILE_DOWNCASE_CHARS ; allocate a buffer
call InitFileReadString ; string buffer handle => BX
jc done ; no value - use default
call MemLock ; lock the string buffer
push es ; save the JobParamters block
mov es, ax
SBCS < mov bp, 1 ; ES:BP points to 2nd char>
DBCS < mov bp, 2 ; ES:BP points to 2nd char>
mov al, SP_NONE shl (offset SF_PARITY)
SBCS < cmp {byte} es:[bp], 'o' ; check for o in "none" >
DBCS < cmp {wchar} es:[bp], 'o' >
je setParity
mov al, SP_ODD shl (offset SF_PARITY)
SBCS < cmp {byte} es:[bp], 'd' ; check for d in "odd" >
DBCS < cmp {wchar} es:[bp], 'd' >
je setParity
mov al, SP_EVEN shl (offset SF_PARITY)
SBCS < cmp {byte} es:[bp], 'v' ; check for v in "even" >
DBCS < cmp {wchar} es:[bp], 'v' >
je setParity
mov al, SP_ONE shl (offset SF_PARITY)
SBCS < cmp {byte} es:[bp], 'n' ; check for n in "one" >
DBCS < cmp {wchar} es:[bp], 'n' >
je setParity
mov al, SP_ZERO shl (offset SF_PARITY)
setParity:
pop es
call MemFree ; free the buffer in BX
and es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format,
not mask SF_PARITY ; clear the old parity
or es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format, al
done:
.leave
ret
PrinterGetParity endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetWordLength
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the printer's word length
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer category name
RETURN: Nothing
DESTROYED: AX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/17/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetWordLength proc near
.enter
; Get the word length
;
mov cx, cs
mov dx, offset PrintControlCode:wordLenString
call InitFileReadInteger ; integer value => AX
jc done ; if none, use default
sub al, 5 ; 5=>0, 6=>1, etc...
cmp al, SL_7BITS ; raw or cooked ??
jne storeLength ; if not seven bits, RAW
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_mode, SM_COOKED
storeLength:
and es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format,
not mask SF_LENGTH ; clear the old word length
mov cl, offset SF_LENGTH
shl al, cl ; put value into correct pos.
or es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format, al
done:
.leave
ret
PrinterGetWordLength endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetStopBits
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the printer's stop bits info...
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer category name
DESTROYED: AX, BX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/17/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetStopBits proc near
uses ds
.enter
; Finally, get the stop bits
;
mov cx, cs
mov dx, offset PrintControlCode:stopBitsString
mov bp, INITFILE_INTACT_CHARS ; allocate a buffer
call InitFileReadString ; string buffer handle => BX
jc done ; if no key, use default
call MemLock ; lock the block
mov ds, ax ; DS:0 points to string
cmp cx, 1 ; only one character ??
jne setExtra ; no, must be 1.5
SBCS < cmp {byte} ds:[0], '1' ; is character a 1 ?? >
DBCS < cmp {wchar} ds:[0], '1' ; is character a 1 ?? >
je doneStopBits ; yes, so use default
setExtra:
or es:[di].JP_portInfo.PPI_params.PP_serial.SPP_format,
mask SF_EXTRA_STOP ; else set the stop bit
doneStopBits:
call MemFree ; free the buffer in BX
done:
.leave
ret
PrinterGetStopBits endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetHandshake
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stores the handshake type for this printer
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer category name
RETURN: Nothing
DESTROYED: AX, BX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/17/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetHandshake proc near
.enter
; Now check out the handshake type
;
mov cx, cs
mov dx, offset PrintControlCode:handShakeString
mov bp, INITFILE_DOWNCASE_CHARS ; allocate a buffer
call InitFileReadString ; string buffer handle => BX
jc done ; if none use default
call MemLock ; lock the string buffer
push es, di ; save the JobParamters block
mov es, ax
clr di ; ES:DI points to the string
clr dh ; assume neither handshake mode
mov dl, mask SFC_HARDWARE ; assume hardware
SBCS < cmp {byte} es:[di], 'h' ; check for h in "hardware">
DBCS < cmp {wchar} es:[di], 'h' ; check for h in "hardware">
je oneMode
mov dl, mask SFC_SOFTWARE ; assume software
SBCS < cmp {byte} es:[di], 's' ; check for s in "software">
DBCS < cmp {wchar} es:[di], 's' ; check for s in "software">
je oneMode
clr dl ; else none
oneMode:
mov dh, dl ; we now have 1 handshake mode
SBCS < mov al, VC_LF ; search for next string>
DBCS < mov ax, C_LINEFEED ; search for next string>
SBCS < repne scasb ; string count still in CX>
DBCS < repne scasw ; string count still in CX>
jnz setHandshake ; if EOS encountered, done
mov dh, mask SFC_HARDWARE or mask SFC_SOFTWARE
setHandshake:
pop es, di ; JobParameters => ES:DI
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_flow, dh
call MemFree ; free the buffer in BX
done:
.leave
ret
PrinterGetHandshake endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrinterGetControlBits
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the hardware handshake control bits
CALLED BY: PrinterGetPortInfo
PASS: ES:DI = JobParameters
DS:SI = Printer category name
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 8/21/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrinterGetControlBits proc near
.enter
test es:[di].JP_portInfo.PPI_params.PP_serial.SPP_flow,
mask SFC_HARDWARE ; hardware control ??
jz done ; no, so do nothing
mov cx, cs
mov dx, offset PrintControlCode:stopRemoteString
mov bp, INITFILE_DOWNCASE_CHARS ; downcase all the characters
call InitFileReadString ; get the string
jc getLocal ; if failure, try local options
push es, di
call MemLock ; string segment => AX
mov es, ax
clr di ; string => ES:DI
mov dl, mask SMC_DTR ; assume DTR
SBCS < cmp {byte} es:[di], 'd' >
DBCS < cmp {wchar} es:[di], 'd' >
je getNextRemote
mov dl, mask SMC_RTS
getNextRemote:
SBCS < mov al, VC_LF >
DBCS < mov ax, C_LINEFEED >
SBCS < repne scasb ; scan for string sepearation>
DBCS < repne scasw ; scan for string sepearation>
jnz setRemote
mov dl, mask SMC_RTS or mask SMC_DTR
setRemote:
pop es, di ; JobParameters => ES:DI
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_stopRem, dl
; Get the stop local options
;
getLocal:
mov cx, cs
mov dx, offset PrintControlCode:stopLocalString
mov bp, INITFILE_DOWNCASE_CHARS ; downcase all the characters
call InitFileReadString ; buffer => BX, chars => CX
jc done ; if failure, we're done
push es, di ; store the JobParameters
call MemLock ; string segment => AX
mov es, ax
clr di ; string => ES:DI
clr dh
localLoop:
mov dl, mask SMS_CTS
SBCS < cmp {byte} es:[di]+1, 't' ; check for 't' in CTS >
DBCS < cmp {wchar} es:[di]+2, 't' ; check for 't' in CTS >
je intermediateGetLocal
mov dl, mask SMS_DCD
SBCS < cmp {byte} es:[di]+1, 'c' ; check for 'c' in DCD >
DBCS < cmp {wchar} es:[di]+2, 'c' ; check for 'c' in DCD >
je intermediateGetLocal
mov dl, mask SMS_DSR ; else must be 's' in DSR
intermediateGetLocal:
or dh, dl ; store bit in DH
SBCS < mov al, VC_LF >
DBCS < mov ax, C_LINEFEED >
SBCS < repne scasb ; scan for string separation >
DBCS < repne scasw ; scan for string separation >
jz localLoop ; loop until end of string
; Store the local options
;
pop es, di ; JobParameters => ES:DI
mov es:[di].JP_portInfo.PPI_params.PP_serial.SPP_stopLoc, dh
call MemFree ; free the buffer in BX
done:
.leave
ret
PrinterGetControlBits endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintRequestUIOptions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Request the UI options displayed by the printer driver,
and verify that the application's UI is valid
CALLED BY: PrintControlPrint
PASS: ES:BP = JobParameters
BX = JobParameters handle
DS:*SI = PrintControlClass object
RETURN: Carry = Clear (everything OK)
= Set (problem with options)
DESTROYED: AX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
Will also ask the application if its UI needs to be
verified. If so, then the application must bring down
the print dialog box. If not, this routine will request
that the dialog box come down.
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/3/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintRequestUIOptions proc near
class PrintControlClass
uses bx, si
.enter
; Get the print driver UI (if displayed)
;
mov cx, bx ; JobParameters handle => CX
mov ax, MSG_SPOOL_SUMMONS_GET_PRINTER_OPTIONS
call PCCallSummons ; CX, DX holds options
call MemDerefES ; re-dereference JobParameters
tst ax ; check for success
jz done ; if successful, we're done
stc ; else fail
done:
.leave
ret
PrintRequestUIOptions endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintRequestAppVerify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Request the application to verify that printing should
ensue, if the application has the VERIFY attribute set
CALLED BY: PrintControlPrint
PASS: DS:*SI = PrintControlClass object
RETURN: Carry = Clear (not verification necessary)
= Set (application will call back)
DESTROYED: AX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintRequestAppVerify proc near
class PrintControlClass
.enter
; See if the application needs to verify its UI
;
mov di, ds:[si]
add di, ds:[di].PrintControl_offset
test ds:[di].PCI_attrs, mask PCA_VERIFY_PRINT
jz done
push bx, si
mov ax, MSG_PRINT_VERIFY_PRINT_REQUEST
mov bx, offset PCI_output
call PCSendToOutputOD ; send the message
pop bx, si
stc ; continue with processing
done:
.leave
ret
PrintRequestAppVerify endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintCreateSpoolFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a file in which to spool the print job
CALLED BY: PrintControlPrint
PASS: ES:BP = JobParameters
DS:*SI = PrintControl instance data
RETURN: AX = File handle
DI = GString handle
ES:BP = JobParameters
JP_fname filled in
Carry = Clear (no error)
- or -
Carry = Set (error)
DESTROYED: AX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/3/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintCreateSpoolFile proc near
uses bx, bp
.enter
; Create a spool file, unless someone has already done it
;
mov dx, es
push si ; save PrintControl chunk
mov si, offset JP_fname ; filename buffer => DX:SI
call SpoolCreateSpoolFile ; file handle => AX
pop si ; PC object => DS:*SI
mov_tr bx, ax ; file handle => BX
tst bx ; clears carry
jz error ; if error, notify user
; Create the GString
;
push si
mov cl, GST_STREAM ; signal a stream
call GrCreateGString ; Returns gstring => DI
mov_tr ax, bx ; file handle => AX
pop si
; Finally, allow the print driver to do something
;
push ax, di
mov ax, MSG_SPOOL_SUMMONS_PREPEND_APPEND_PAGE
mov cx, DR_PRINT_ESC_PREPEND_PAGE
mov dx, di
call PCCallSummons
pop ax, di
clc ; no errors
exit:
.leave
ret
; Error in creating a file - notify user
error:
mov ax, MSG_SPOOL_SUMMONS_REMOTE_ERROR
mov cx, PCERR_FAIL_FILE_CREATE ; error type
mov bp, MSG_META_DUMMY ; method to send...
call PCCallSummons ; call over to the summons
stc
jmp exit
PrintCreateSpoolFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintRequestDocName
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Request the document name of what is being printed.
CALLED BY: PrintControlPrint
PASS: DS:*SI = PrintControl instance data
RETURN: Nothing
DESTROYED: AX, CX, DX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/8/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintRequestDocName proc near
class PrintControlClass
uses bx, si, bp
.enter
; Send the request method to the OD
;
mov ax, MSG_PRINT_GET_DOC_NAME
mov bx, offset PCI_docNameOutput
mov bp, MSG_PRINT_CONTROL_SET_DOC_NAME
call PCSendToOutputOD ; send message to output
.leave
ret
PrintRequestDocName endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintCreateProgressDB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Bring the progress dialog box up on screen.
CALLED BY: GLOBAL
PASS: *DS:SI = PrintControl object
ES:BP = JobParameters
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintCreateProgressDB proc near
class PrintControlClass
uses ax, bx, cx, dx, di, si, bp
.enter
; First duplicate the UI, and then display it to the user
;
mov di, ds:[si]
add di, ds:[di].PrintControl_offset
mov ax, ds:[di].PCI_attrs ; PrintControlAttrs => AX
test ax, mask PCA_SHOW_PROGRESS ; show progress DB ??
jz done ; nope, so we're outta here
push si, bp, si, ax
mov cx, handle ProgressDialogBox ; resource handle => CX
mov dx, offset ProgressDialogBox ; chunk handle => DX
mov bp, offset TPCI_progressBox
call PCDuplicateBlock ; new dialog box OD => BX:SI
pop si, ax
; Set NOT_USABLE things we don't want to display
;
call PCAccessTemp ; TempPrintCtrlInstance => DS:DI
mov bx, ds:[di].TPCI_progressBox.handle
test ax, mask PCA_PROGRESS_PAGE
jnz percent
push ax
mov si, offset ProgressUI:ProgressPage
call PCSetNotUsable
pop ax
percent:
test ax, mask PCA_PROGRESS_PERCENT
jnz onScreen
mov si, offset ProgressUI:ProgressPercent
call PCSetNotUsable
onScreen:
mov si, offset ProgressUI:ProgressDialogBox
mov ax, MSG_GEN_INTERACTION_INITIATE
call PCObjMessageCall
; Now set the application name text
;
pop bp
mov si, offset ProgressUI:ProgressDocument
mov dx, es
add bp, offset JP_parent ; application name => DX:BP
call progressSetTextCommon ; set the text
; Finally set the initial page to be printed
;
pop si ; PC object => *DS:SI
mov ax, MSG_SPOOL_SUMMONS_GET_USER_PAGE_RANGE
call PCCallSummons
mov ax, MSG_PRINT_CONTROL_REPORT_PROGRESS
mov dx, cx ; first page => DX
mov cx, PCPT_PAGE
call ObjCallInstanceNoLock ; call the method handler
done:
.leave
ret
PrintCreateProgressDB endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintDestroyProgressDB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Bring the progress dialog box up on screen.
CALLED BY: GLOBAL
PASS: DS:DI = TempPrintCtrlInstance
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintDestroyProgressDB proc near
uses di
.enter
; Destroy the Progress dialog box
;
clr bx ; get objecct block handle
xchg bx, ds:[di].TPCI_progressBox.handle
tst bx ; any box up ??
jz done
mov si, offset ProgressDialogBox ; OD of verify box => BX:SI
call PCSetNotUsable ; first set it not usable...
mov ax, MSG_META_BLOCK_FREE
call PCObjMessageSend ; ...then free the block
done:
.leave
ret
PrintDestroyProgressDB endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintMarkAppBusy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Mark an application busy while printing
CALLED BY: INTERNAL
PASS: DS:DI = TempPrintCtrlInstance
DX = PrintControlAttrs
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/17/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintMarkAppBusy proc near
uses di
.enter
; Mark the application busy, as needed
;
mov ds:[di].TPCI_attrs, dx ; store these attributes
test dx, mask PCA_MARK_APP_BUSY
jz done
mov bx, ds:[LMBH_handle] ; my block handle => BX
call MemOwner ; process owning block => BX
call GeodeGetAppObject ; GenApplication obj => BX:SI
mov ax, MSG_GEN_APPLICATION_MARK_BUSY
call PCObjMessageCall
done:
.leave
ret
PrintMarkAppBusy endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintMarkAppNotBusy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Mark an application no longer busy, after printing
CALLED BY: INTERNAL
PASS: DS:DI = TempPrintCtrlInstance
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
don 1/17/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintMarkAppNotBusy proc near
uses ax, bx, cx, dx, bp, di, si
.enter
; Mark the application busy, as needed
;
clr ax
xchg ds:[di].TPCI_attrs, ax ; zero attributes
test ax, mask PCA_MARK_APP_BUSY ; was app marked busy ??
jz done
mov bx, ds:[LMBH_handle] ; my block handle => BX
call MemOwner ; process owning block => BX
call GeodeGetAppObject ; GenApplication obj => BX:SI
mov ax, MSG_GEN_APPLICATION_MARK_NOT_BUSY
call PCObjMessageCall
done:
.leave
ret
PrintMarkAppNotBusy endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProgressUpdatePage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the "page" being printer by the application
CALLED BY: PrintControlReportProgress
PASS: *DS:SI = PrintControl object
DS:DI = TempPrintCtrlInstance
DX = Page number
BX = Handle of ProgressDialogBox
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
Create the string "Printing page XX (YY more to go)", where
XX = current page
YY = # of pages left to print
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/17/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MAX_PROGRESS_PAGE_TEXT_LENGTH = 64
ProgressUpdatePage proc near
.enter
; Some set-up work
;
SBCS < sub sp, MAX_PROGRESS_PAGE_TEXT_LENGTH >
DBCS < sub sp, MAX_PROGRESS_PAGE_TEXT_LENGTH*(size wchar) >
mov di, sp
segmov es, ss ; text buffer => ES:DI
push di ; save start of text
push bx ; save Progress DB handle
mov bp, dx ; current page number => BP
mov ax, MSG_SPOOL_SUMMONS_GET_DRIVER_TYPE
call PCCallSummons
mov bl, cl ; PrinterDriverType => CL
mov ax, MSG_SPOOL_SUMMONS_GET_USER_PAGE_RANGE
call PCCallSummons ; range => CX, DX
sub dx, bp
mov cl, bl ; PrinterDriverType => CL
push dx ; save pages left to go
mov bx, handle Strings
call MemLock
mov ds, ax
assume ds:Strings
; Create the string to display
;
mov si, ds:[progressFaxingString]
cmp cl, PDT_FACSIMILE
je copyString
mov si, ds:[progressPrintingString]
copyString:
call PageCopyString ; "Printing/Faxing page "
call PageCopyPageNum ; "XX"
mov si, ds:[progressPageString2]
call PageCopyString ; " ("
pop bp
call PageCopyPageNum ; "YY"
mov si, ds:[progressPageString3]
call PageCopyString ; " to go)"
clr ax
LocalPutChar esdi, ax
; Now set the text, and clean up
;
mov dx, es
pop bx ; restore Progress DB handle
pop bp ; text buffer => DX:BP
mov si, offset ProgressUI:ProgressPage
call progressSetTextCommon ; set the text
mov bx, handle Strings
call MemUnlock
assume ds:dgroup
SBCS < add sp, MAX_PROGRESS_PAGE_TEXT_LENGTH >
DBCS < add sp, MAX_PROGRESS_PAGE_TEXT_LENGTH*(size wchar) >
.leave
ret
ProgressUpdatePage endp
PageCopyString proc near
ChunkSizePtr ds, si, cx
DBCS < shr cx, 1 ; cx <- length >
dec cx ; ignore NULL terminator
LocalCopyNString ; copy in string
ret
PageCopyString endp
PageCopyPageNum proc near
mov_tr ax, bp
clr dx
mov cx, mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii ; create the page
; number
DBCS < shl cx, 1 >
add di, cx ; point just after the string
ret
PageCopyPageNum endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProgressUpdatePercent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the percentage completed in the Print Progress DB
CALLED BY: PrintControlReportProgress
PASS: *DS:SI = PrintControl object
DS:DI = TempPrintCtrlInstance
DX = Page number
BX = Handle of ProgressDialogBox
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/17/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProgressUpdatePercent proc near
; Tell the percentage indicator what to display
;
mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE
mov cx, dx ; value => CX
clr bp ; "determinate"
mov si, offset ProgressUI:ProgressPercent
GOTO PCObjMessageCall
ProgressUpdatePercent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProgressUpdateText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the text displayed in the Print Progress DB
CALLED BY: PrintControlReportProgress
PASS: *DS:SI = PrintControl object
DS:DI = TempPrintCtrlInstance
DX:BP = Text to display
BX = Handle of ProgressDialogBox
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/17/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProgressUpdateText proc near
; Tell the text object to display some text
;
mov si, offset ProgressUI:ProgressText
progressSetTextCommon label near
clr cx ; text is NULL terminated
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
GOTO PCObjMessageCall
ProgressUpdateText endp
COMMENT @----------------------------------------------------------------------
METHOD: PrintDispatchEvent
DESCRIPTION: Intercept messages to be dispatched, watching for the
"GWNT_SPOOL_PRINTING_COMPLETE" message that the desktop
uses to know that its IACP message to the desktop is
"complete". We change this to mean not just that the
message arrived, but that the print sequence itself has
completed (or not possible, or has been canceled), so that
the desktop need merely wait for the return of its
completion message before going on to the next file to
be printed. Basically, a Hack :)
PASS:
*ds:si - instance data
es - segment of PrintControlClass
ax - MSG_META_DISPATCH_EVENT
^hcx - Event
dx - MessageFlags
RETURN:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 12/17/92 Initial version
SH 04/27/94 XIP'ed
------------------------------------------------------------------------------@
PrintDispatchEvent method PrintControlClass, MSG_META_DISPATCH_EVENT
; See if this event should be delayed or not
;
push cx, dx, si
mov bx, cx
mov si, -1 ; preserve event
mov ax, SEGMENT_CS ; ax <- vseg if XIP'ed
push ax
mov ax, offset PrintDispatchEventCallback
push ax
call MessageProcess
pop cx, dx, si
jc delayEvent
; Don't delay, so send the even right away
;
mov ax, MSG_META_DISPATCH_EVENT
mov di, offset PrintControlClass
GOTO ObjCallSuperNoLock
; Else save the event away in vardata
delayEvent:
push cx ; recorded event
push dx ; MessageFlags
; Dispatch any currently saved event -- weird case...
;
call DispatchPrintCompletionEvent
; Save away event for later dispatch
;
mov ax, TEMP_PRINT_COMPLETION_EVENT
mov cx, size TempPrintCompletionEventData
call ObjVarAddData
pop ds:[bx].TPCED_messageFlags
pop ds:[bx].TPCED_event
call CheckUpOnPrintCompletionMessage ; See if we should send out
ret ; completion message
PrintDispatchEvent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintDisplatEventCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Dispatch an event (maybe)
CALLED BY: MessageProcess (callback)
PASS: same as ObjMessage
RETURN: Carry = Set (delay)
= Clear (process now)
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 1/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintDispatchEventCallback proc far
cmp ax, MSG_META_NOTIFY
jne notEvent
cmp cx, MANUFACTURER_ID_GEOWORKS
jne notEvent
cmp dx, GWNT_SPOOL_PRINTING_COMPLETE
jne notEvent
stc
ret
notEvent:
clc
ret
PrintDispatchEventCallback endp
COMMENT @----------------------------------------------------------------------
MESSAGE: PrintNotifyEnabled
-- MSG_GEN_NOTIFY_ENABLED for PrintClass
DESCRIPTION: Handle the controller being set enabled
PASS:
*ds:si - instance data
es - segment of PrintClass
ax - The message
dl - VisUpdateMode
dh - NotifyEnabledFlags
RETURN:
carry set if visual state changed
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 3/31/92 Initial version
Doug 12/29/92 Changed to deal w/controllers not yet resolved
------------------------------------------------------------------------------@
PrintNotifyEnabled method dynamic PrintControlClass,
MSG_GEN_NOTIFY_ENABLED,
MSG_GEN_NOTIFY_NOT_ENABLED
mov di, ds:[si]
add di, ds:[di].Gen_offset
test ds:[di].GI_states, mask GS_USABLE
jz exit ;skip if not usable...
push ax, dx
mov di, offset PrintControlClass
call ObjCallSuperNoLock
lahf ; keep carry flag in ch
mov ch, ah
pop ax, dx
and dh, not mask NEF_STATE_CHANGING ; clear "this object" bit.
; if we have any dialogs up, deal with them as well
call PCGetSummons
jnc afterTools
push cx ; preserve saved flags
call PCObjMessageSend
pop cx
andnf ch, mask CPU_CARRY ; keep only the old carry flags
lahf
ornf ch, ah ; OR returned carry flags together
afterTools:
mov ah, ch ; return flags kept in ch
sahf
exit:
ret
PrintNotifyEnabled endm
PrintControlCode ends
|
#include <bits/stdc++.h>
using namespace std;
class Solution{
public:
ull getNthUglyNo(int n) {
set <long long int> s;
s.insert(1);
n--;
while(n--){
auto it = s.begin();
long long int x = *it;
s.erase(it);
s.insert(x*2);
s.insert(x*3);
s.insert(x*5);
}
return *s.begin();
}
};
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
Solution ob;
auto ans = ob.getNthUglyNo(n);
cout << ans << "\n";
}
return 0;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1068b, %rbp
nop
nop
nop
nop
nop
dec %rbx
mov $0x6162636465666768, %r8
movq %r8, (%rbp)
nop
nop
nop
nop
nop
cmp $55981, %rdi
lea addresses_normal_ht+0x15ef7, %rsi
lea addresses_UC_ht+0x1b3b7, %rdi
nop
nop
cmp $25923, %rax
mov $111, %rcx
rep movsb
and %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r14
push %rax
push %rbp
push %rdi
// Load
lea addresses_UC+0xdb17, %rax
nop
nop
nop
nop
and $28845, %rdi
vmovups (%rax), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %r14
nop
nop
nop
nop
xor $36362, %rax
// Load
lea addresses_WT+0x9ff7, %r12
nop
nop
nop
nop
add %r13, %r13
movb (%r12), %r14b
nop
nop
nop
nop
dec %rax
// Store
lea addresses_PSE+0x1cb97, %r10
nop
nop
nop
nop
nop
inc %rbp
movb $0x51, (%r10)
nop
nop
nop
nop
nop
and $34577, %r12
// Faulty Load
mov $0x2aa2c70000000db7, %rdi
clflush (%rdi)
and %r13, %r13
mov (%rdi), %r12
lea oracles, %r10
and $0xff, %r12
shlq $12, %r12
mov (%r10,%r12,1), %r12
pop %rdi
pop %rbp
pop %rax
pop %r14
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 4}}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 8, 'NT': True, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 1}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'ff': 12, '44': 15, '00': 21802}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; _________________
; // \\
; || HOW TO COMPILE IT ||
; \\_________________//
;
; ------ x86_64 ------
; nasm -f elf64 nice2meet64.asm
; ld -s -o nice2meet64 nice2meet64.o
;
; _________________
; // \\
; || DESCRIPTION ||
; \\_________________//
;
; The NASM "Hello, World!"
; with SYS_READ function
;
; LEVEL: 02
; ASM: NASM 64-bit
; ENVS: Linux
; AUTHOR: CosasDePuma
; DATE: August, 8rd 2017
[BITS 64] ; BITS directive to specify 64-bit code
section .data ; CONSTANTS
msg db 'Who are you?: ' ; message
msg_l equ $ - msg ; lenght of the message
nice db 'Nice to meet you, ' ; response
nice_l equ $ - nice ; response lenght
section .bss ; VARIABLES
name resb 10 ; res space to name var
; MACROS are multi-line %define
; %macro shortcut_name num_of_params
; ... code here ...
; %1 = first param,
; %2 = second param
; %endmacro
; sys_write : show msg in stdout
; params : message, message_lenght
%macro sys_write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; sys_read : read from stdin
; params : var, max_lenght
%macro sys_read 2
xor rax, rax
xor rdi, rdi
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; sys_exit : exit the program
; params : exit_status_code
%macro sys_exit 1
mov rax, 60
mov rdi, %1
syscall
%endmacro
section .text
global _start
_start:
sys_write msg, msg_l
sys_read name, 10
sys_write nice, nice_l
sys_write name, 10
sys_exit 0 |
/*=========================================================================
Program: Visualization Toolkit
Module: vtkInteractorStyleTerrain.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkInteractorStyleTerrain.h"
#include "vtkActor.h"
#include "vtkCallbackCommand.h"
#include "vtkCamera.h"
#include "vtkExtractEdges.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
vtkStandardNewMacro(vtkInteractorStyleTerrain);
//----------------------------------------------------------------------------
vtkInteractorStyleTerrain::vtkInteractorStyleTerrain()
{
this->LatLongLines = 0;
this->LatLongSphere = nullptr;
this->LatLongExtractEdges = nullptr;
this->LatLongMapper = nullptr;
this->LatLongActor = nullptr;
this->MotionFactor = 10.0;
}
//----------------------------------------------------------------------------
vtkInteractorStyleTerrain::~vtkInteractorStyleTerrain()
{
if (this->LatLongSphere != nullptr)
{
this->LatLongSphere->Delete();
}
if (this->LatLongMapper != nullptr)
{
this->LatLongMapper->Delete();
}
if (this->LatLongActor != nullptr)
{
this->LatLongActor->Delete();
}
if (this->LatLongExtractEdges != nullptr)
{
this->LatLongExtractEdges->Delete();
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnMouseMove()
{
int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1];
switch (this->State)
{
case VTKIS_ROTATE:
this->FindPokedRenderer(x, y);
this->Rotate();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break;
case VTKIS_PAN:
this->FindPokedRenderer(x, y);
this->Pan();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break;
case VTKIS_DOLLY:
this->FindPokedRenderer(x, y);
this->Dolly();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break;
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnLeftButtonDown()
{
this->FindPokedRenderer(
this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
if (this->CurrentRenderer == nullptr)
{
return;
}
this->GrabFocus(this->EventCallbackCommand);
this->StartRotate();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnLeftButtonUp()
{
switch (this->State)
{
case VTKIS_ROTATE:
this->EndRotate();
if (this->Interactor)
{
this->ReleaseFocus();
}
break;
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnMiddleButtonDown()
{
this->FindPokedRenderer(
this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
if (this->CurrentRenderer == nullptr)
{
return;
}
this->GrabFocus(this->EventCallbackCommand);
this->StartPan();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnMiddleButtonUp()
{
switch (this->State)
{
case VTKIS_PAN:
this->EndPan();
if (this->Interactor)
{
this->ReleaseFocus();
}
break;
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnRightButtonDown()
{
this->FindPokedRenderer(
this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
if (this->CurrentRenderer == nullptr)
{
return;
}
this->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnRightButtonUp()
{
switch (this->State)
{
case VTKIS_DOLLY:
this->EndDolly();
if (this->Interactor)
{
this->ReleaseFocus();
}
break;
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::Rotate()
{
if (this->CurrentRenderer == nullptr)
{
return;
}
vtkRenderWindowInteractor* rwi = this->Interactor;
int dx = -(rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0]);
int dy = -(rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1]);
const int* size = this->CurrentRenderer->GetRenderWindow()->GetSize();
double a = dx / static_cast<double>(size[0]) * 180.0;
double e = dy / static_cast<double>(size[1]) * 180.0;
if (rwi->GetShiftKey())
{
if (abs(dx) >= abs(dy))
{
e = 0.0;
}
else
{
a = 0.0;
}
}
// Move the camera.
// Make sure that we don't hit the north pole singularity.
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
camera->Azimuth(a);
double dop[3], vup[3];
camera->GetDirectionOfProjection(dop);
vtkMath::Normalize(dop);
camera->GetViewUp(vup);
vtkMath::Normalize(vup);
double angle = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(dop, vup)));
if ((angle + e) > 179.0 || (angle + e) < 1.0)
{
e = 0.0;
}
camera->Elevation(e);
if (this->AutoAdjustCameraClippingRange)
{
this->CurrentRenderer->ResetCameraClippingRange();
}
rwi->Render();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::Pan()
{
if (this->CurrentRenderer == nullptr)
{
return;
}
vtkRenderWindowInteractor* rwi = this->Interactor;
// Get the vector of motion
double fp[3], focalPoint[3], pos[3], v[3], p1[4], p2[4];
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
camera->GetPosition(pos);
camera->GetFocalPoint(fp);
this->ComputeWorldToDisplay(fp[0], fp[1], fp[2], focalPoint);
this->ComputeDisplayToWorld(
rwi->GetEventPosition()[0], rwi->GetEventPosition()[1], focalPoint[2], p1);
this->ComputeDisplayToWorld(
rwi->GetLastEventPosition()[0], rwi->GetLastEventPosition()[1], focalPoint[2], p2);
for (int i = 0; i < 3; i++)
{
v[i] = p2[i] - p1[i];
pos[i] += v[i];
fp[i] += v[i];
}
camera->SetPosition(pos);
camera->SetFocalPoint(fp);
if (rwi->GetLightFollowCamera())
{
this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
}
rwi->Render();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::Dolly()
{
if (this->CurrentRenderer == nullptr)
{
return;
}
vtkRenderWindowInteractor* rwi = this->Interactor;
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
double* center = this->CurrentRenderer->GetCenter();
int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
double dyf = this->MotionFactor * dy / center[1];
double zoomFactor = pow(1.1, dyf);
if (camera->GetParallelProjection())
{
camera->SetParallelScale(camera->GetParallelScale() / zoomFactor);
}
else
{
camera->Dolly(zoomFactor);
if (this->AutoAdjustCameraClippingRange)
{
this->CurrentRenderer->ResetCameraClippingRange();
}
}
if (rwi->GetLightFollowCamera())
{
this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
}
rwi->Render();
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::OnChar()
{
vtkRenderWindowInteractor* rwi = this->Interactor;
switch (rwi->GetKeyCode())
{
case 'l':
this->FindPokedRenderer(rwi->GetEventPosition()[0], rwi->GetEventPosition()[1]);
this->CreateLatLong();
if (this->LatLongLines)
{
this->LatLongLinesOff();
}
else
{
double bounds[6];
this->CurrentRenderer->ComputeVisiblePropBounds(bounds);
double radius = sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) +
(bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) +
(bounds[5] - bounds[4]) * (bounds[5] - bounds[4])) /
2.0;
this->LatLongSphere->SetRadius(radius);
this->LatLongSphere->SetCenter((bounds[0] + bounds[1]) / 2.0, (bounds[2] + bounds[3]) / 2.0,
(bounds[4] + bounds[5]) / 2.0);
this->LatLongLinesOn();
}
this->SelectRepresentation();
rwi->Render();
break;
default:
this->Superclass::OnChar();
break;
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::CreateLatLong()
{
if (this->LatLongSphere == nullptr)
{
this->LatLongSphere = vtkSphereSource::New();
this->LatLongSphere->SetPhiResolution(13);
this->LatLongSphere->SetThetaResolution(25);
this->LatLongSphere->LatLongTessellationOn();
}
if (this->LatLongExtractEdges == nullptr)
{
this->LatLongExtractEdges = vtkExtractEdges::New();
this->LatLongExtractEdges->SetInputConnection(this->LatLongSphere->GetOutputPort());
}
if (this->LatLongMapper == nullptr)
{
this->LatLongMapper = vtkPolyDataMapper::New();
this->LatLongMapper->SetInputConnection(this->LatLongExtractEdges->GetOutputPort());
}
if (this->LatLongActor == nullptr)
{
this->LatLongActor = vtkActor::New();
this->LatLongActor->SetMapper(this->LatLongMapper);
this->LatLongActor->PickableOff();
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::SelectRepresentation()
{
if (this->CurrentRenderer == nullptr)
{
return;
}
this->CurrentRenderer->RemoveActor(this->LatLongActor);
if (this->LatLongLines)
{
this->CurrentRenderer->AddActor(this->LatLongActor);
this->LatLongActor->VisibilityOn();
}
else
{
this->LatLongActor->VisibilityOff();
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleTerrain::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Latitude/Longitude Lines: " << (this->LatLongLines ? "On\n" : "Off\n");
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x14bbd, %r15
nop
nop
nop
add $40435, %r10
mov (%r15), %bp
nop
nop
nop
cmp $462, %rdi
lea addresses_WC_ht+0x161bd, %rsi
lea addresses_D_ht+0x1a46d, %rdi
inc %r11
mov $14, %rcx
rep movsq
nop
cmp $36428, %rbp
lea addresses_WC_ht+0x18bbd, %rbp
and $16900, %rdi
movb $0x61, (%rbp)
nop
nop
cmp %r10, %r10
lea addresses_WT_ht+0x14bbd, %rsi
lea addresses_normal_ht+0x73bd, %rdi
nop
nop
nop
and $38241, %r9
mov $112, %rcx
rep movsb
nop
cmp $47246, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r15
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r8
push %r9
push %rsi
// Load
lea addresses_D+0x103bd, %r10
nop
nop
nop
nop
nop
add $50621, %r11
vmovups (%r10), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %r9
nop
nop
nop
nop
sub $64077, %r9
// Store
lea addresses_A+0xcb25, %r10
sub $36802, %r14
mov $0x5152535455565758, %r13
movq %r13, (%r10)
nop
nop
nop
cmp $5012, %r8
// Store
lea addresses_RW+0xb29d, %r9
add %r13, %r13
mov $0x5152535455565758, %r10
movq %r10, %xmm7
movups %xmm7, (%r9)
nop
nop
add %r10, %r10
// Store
lea addresses_WT+0xa9d, %r13
nop
dec %r11
movw $0x5152, (%r13)
nop
nop
nop
nop
and $39703, %r9
// Store
lea addresses_A+0x16319, %rsi
nop
nop
nop
nop
nop
cmp $33428, %r14
mov $0x5152535455565758, %r9
movq %r9, %xmm1
movups %xmm1, (%rsi)
sub $36923, %r9
// Store
lea addresses_RW+0x18f3d, %r14
nop
dec %r10
mov $0x5152535455565758, %r9
movq %r9, (%r14)
nop
nop
nop
nop
nop
add %r11, %r11
// Store
lea addresses_WC+0x1ec25, %r14
nop
nop
add $47973, %r13
movl $0x51525354, (%r14)
nop
nop
nop
cmp %r9, %r9
// Store
lea addresses_UC+0x17f3d, %r14
nop
nop
and %r13, %r13
mov $0x5152535455565758, %r11
movq %r11, %xmm5
movntdq %xmm5, (%r14)
inc %r14
// Store
lea addresses_US+0xb7bd, %r14
nop
nop
nop
dec %r9
movw $0x5152, (%r14)
nop
nop
nop
and $18650, %r11
// Faulty Load
lea addresses_D+0x103bd, %r14
dec %r11
mov (%r14), %r8w
lea oracles, %r13
and $0xff, %r8
shlq $12, %r8
mov (%r13,%r8,1), %r8
pop %rsi
pop %r9
pop %r8
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_RW'}}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_RW'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WC'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_UC'}}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_US'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}}
{'36': 1092}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
TITLE 'SEE IF MEMBER IS IN THE PDS'
SPACE 3
CLEQUM10
BASEREG EQU 12
CLASMM10 CSECT
*******************************************************************
** SAVE REGISTERS, ETC.
*******************************************************************
STM R14,R12,12(R13) SAVE REGISTERS R14 THRU 12
LR BASEREG,R15 LOAD ENTRY POINT
USING CLASMM10,BASEREG ESTABLISH REGISTER
LA R4,SAVE GET ADDRESS OF SAVE AREA
ST R4,8(R13) CALLERS FORWARD CHAIN
ST R13,4(R4) MY BACKWARD CHAIN
LR R13,R4 LOAD R13 TO MY SAVE AREA
WTO ' CLASMM10 Starting',ROUTCDE=(11),DESC=(7)
CLAMAC10
L R15,=V(CLASMS10)
BASR R14,R15
WTO ' CLASMM10 Ending',ROUTCDE=(11),DESC=(7)
*******************************************************************
** GO BACK TO CALLING PROGRAM
*******************************************************************
GOBACK EQU *
L R13,SAVE+4 RESTORE REG 13
LM R14,R12,12(R13) RESTORE REGS 14 THRU 12
SR R15,R15 SET CONDCODE=0
BR R14 RETURN
*******************************************************************
* MAIN STORAGE
*******************************************************************
LTORG
DS 0F
SAVE DS 18F
END CLASMM10 |
LCNefertite label byte
word C_BLACK
Bitmap <71,100,BMC_PACKBITS,BMF_4BIT or mask BMT_MASK>
db 0x00, 0x1f, 0xfa, 0xff, 0x00, 0xf0
db 0x01, 0xdd, 0xd0, 0xe1, 0x00, 0x01, 0xdd, 0xd0
db 0x00, 0x7f, 0xfa, 0xff, 0x00, 0xfc
db 0x03, 0xd0, 0x07, 0x77, 0x78, 0xfb, 0x77, 0x00,
0x87, 0xfe, 0x77, 0x03, 0x7f, 0x77, 0x87, 0x87,
0xfe, 0x77, 0x0e, 0x78, 0x77, 0xf7, 0xf7, 0x77,
0xf7, 0x77, 0x77, 0x78, 0x77, 0x77, 0xf7, 0x77,
0x00, 0xd0
db 0x00, 0x7f, 0xfa, 0xff, 0x00, 0xfc
db 0x08, 0xd0, 0x77, 0x87, 0x87, 0x7f, 0x78, 0x77,
0x7f, 0x7f, 0xfe, 0x77, 0x00, 0x7f, 0xfd, 0x77,
0x01, 0xf7, 0x87, 0xfe, 0x77, 0x02, 0x87, 0x77,
0x78, 0xfe, 0x77, 0x02, 0x87, 0x87, 0xf8, 0xfe,
0x77, 0x01, 0x80, 0xd0
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x7f, 0xfe, 0x77, 0x04, 0x7f,
0x77, 0x78, 0x77, 0x7f, 0xfd, 0x77, 0x0b, 0x87,
0x77, 0x88, 0x77, 0xf7, 0x7f, 0x87, 0x77, 0x87,
0x87, 0x77, 0x78, 0xfe, 0x77, 0x05, 0x78, 0xff,
0x77, 0xf8, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x77, 0xe4, 0x00, 0x03, 0x07,
0x88, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x70, 0xe4, 0x99, 0x03, 0x90,
0x88, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x00,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x78, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf4, 0x99, 0x03, 0x9f,
0xff, 0xff, 0xf9, 0xf4, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf5, 0x99, 0x04, 0xff,
0xf7, 0x77, 0x77, 0x70, 0xf4, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf6, 0x99, 0x00, 0xff,
0xfc, 0x77, 0x00, 0x09, 0xf5, 0x99, 0x02, 0x08,
0x80, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0x00, 0xff,
0xfb, 0x77, 0x00, 0x70, 0xf5, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf8, 0x99, 0x00, 0x9f,
0xfa, 0x77, 0x00, 0x70, 0xf5, 0x99, 0x02, 0x07,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xf9, 0x99, 0x01, 0x9f,
0xf7, 0xf9, 0x77, 0x00, 0x09, 0xf6, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xf9, 0x99, 0x00, 0xf7,
0xf8, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xfa, 0x99, 0x00, 0x9f,
0xf7, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfb, 0x99, 0x01, 0x9f,
0xf7, 0xf9, 0x77, 0xfe, 0x00, 0xf6, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xfb, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x01, 0x70, 0x00, 0xf3, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xfc, 0x99, 0x00, 0x9f,
0xfa, 0x77, 0x01, 0x70, 0x09, 0xf2, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfc, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x00, 0x09, 0xfe, 0x99, 0xfe, 0xff,
0x00, 0x09, 0xf8, 0x99, 0x02, 0x08, 0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xfd, 0x99, 0x00, 0xff,
0xfa, 0x77, 0x04, 0x00, 0x99, 0x99, 0x9f, 0xff,
0xfe, 0x77, 0x00, 0x09, 0xf8, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfe, 0x99, 0x00, 0x9f,
0xfa, 0x77, 0x04, 0x70, 0x99, 0x99, 0x9f, 0xf7,
0xfd, 0x77, 0x00, 0x70, 0xf8, 0x99, 0x02, 0x00,
0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xfe, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x03, 0x09, 0x99, 0x99, 0xf7, 0xfb,
0x77, 0x00, 0x09, 0xf9, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x05, 0x07, 0x77, 0x09, 0x99, 0x99, 0x9f, 0xfa,
0x77, 0x03, 0x00, 0x99, 0x99, 0xff, 0xfa, 0x77,
0x00, 0x09, 0xf9, 0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x05, 0x07, 0x77, 0x09, 0x99, 0x99, 0xf7, 0xfb,
0x77, 0x03, 0x70, 0x99, 0x99, 0x9f, 0xf9, 0x77,
0x00, 0x70, 0xf9, 0x99, 0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x05, 0x07, 0x7f, 0x09, 0x99, 0x99, 0x9f, 0xfb,
0x77, 0x03, 0x09, 0x99, 0x99, 0xf7, 0xf9, 0x77,
0x00, 0x70, 0xf9, 0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfe, 0x99, 0x00, 0xf7,
0xfd, 0x77, 0x03, 0x70, 0x99, 0x99, 0xff, 0xf7,
0x77, 0x00, 0x09, 0xfa, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xfe, 0x99, 0x00, 0x9f,
0xfd, 0x77, 0x02, 0x70, 0x99, 0x9f, 0xf7, 0x77,
0x01, 0x70, 0x09, 0xfa, 0x99, 0x02, 0x07, 0x08,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfd, 0x99, 0x00, 0xf7,
0xfe, 0x77, 0x02, 0x09, 0x99, 0xf7, 0xf8, 0x77,
0x01, 0x70, 0x09, 0xf9, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfd, 0x99, 0x05, 0x9f,
0x77, 0x77, 0x70, 0x99, 0x9f, 0xf7, 0x77, 0x00,
0x09, 0xf8, 0x99, 0x02, 0x08, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfc, 0x99, 0x04, 0xf7,
0x77, 0x09, 0x99, 0x9f, 0xf8, 0x77, 0x00, 0x00,
0xf7, 0x99, 0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xfc, 0x99, 0x04, 0x9f,
0x77, 0x09, 0x99, 0xf7, 0xfc, 0x77, 0x03, 0x00,
0x77, 0x77, 0x70, 0xf6, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xfb, 0x99, 0x02, 0xf0,
0x99, 0x9f, 0xfd, 0x77, 0x05, 0x70, 0x00, 0x9f,
0x77, 0x77, 0x09, 0xfe, 0x99, 0x01, 0xff, 0xf0,
0xfb, 0x99, 0x02, 0x07, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf9, 0x99, 0x00, 0xf7,
0xfe, 0x77, 0x0b, 0x00, 0x09, 0x99, 0x9f, 0x77,
0x77, 0x70, 0x99, 0x99, 0x9f, 0x77, 0x70, 0xfb,
0x99, 0x02, 0x08, 0x80, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xf9, 0x99, 0xfd, 0x00,
0xfe, 0x99, 0x00, 0x9f, 0xfe, 0x77, 0x05, 0x09,
0x9f, 0xf7, 0x77, 0x77, 0x09, 0xfc, 0x99, 0x02,
0x08, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x77, 0x09, 0xf2, 0x99, 0x00, 0x9f,
0xfe, 0x77, 0x01, 0x09, 0xf7, 0xfe, 0x77, 0x00,
0x09, 0xfc, 0x99, 0x02, 0x08, 0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf4, 0x99, 0x02, 0xff,
0xff, 0xf7, 0xfe, 0x77, 0x05, 0x0f, 0x77, 0x77,
0x70, 0x07, 0x70, 0xfc, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf9, 0x99, 0xfc, 0xff,
0xfc, 0x77, 0x06, 0x70, 0xf7, 0x77, 0x70, 0x07,
0x70, 0x70, 0xfc, 0x99, 0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x87, 0x09, 0xf9, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x01, 0x00, 0x0f, 0xfe, 0x77, 0x03,
0x7f, 0x07, 0x77, 0x09, 0xfd, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf8, 0x99, 0x00, 0xf7,
0xfb, 0x77, 0x01, 0x70, 0xf7, 0xfd, 0x77, 0x03,
0x07, 0x07, 0x77, 0x70, 0xfd, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf8, 0x99, 0x00, 0x9f,
0xfc, 0x77, 0x03, 0x70, 0x0f, 0x7f, 0xf7, 0xfa,
0x77, 0x00, 0x09, 0xfe, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0x00, 0xf7,
0xfd, 0x77, 0x03, 0x09, 0x9f, 0x77, 0xf7, 0xfa,
0x77, 0x00, 0x70, 0xfe, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x8f, 0x09, 0xf7, 0x99, 0x00, 0x9f,
0xfe, 0x77, 0x03, 0x70, 0x99, 0x9f, 0x7f, 0xf8,
0x77, 0x05, 0x09, 0x99, 0x99, 0x08, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xf6, 0x99, 0x07, 0xf7,
0x77, 0x77, 0x09, 0x99, 0x9f, 0x77, 0x7f, 0xf9,
0x77, 0x05, 0x09, 0x99, 0x99, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x77, 0x09, 0xf6, 0x99, 0x07, 0x9f,
0x77, 0x70, 0x99, 0x99, 0xff, 0x77, 0x7f, 0xfa,
0x77, 0x00, 0x70, 0xfe, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf5, 0x99, 0x05, 0xf7,
0x09, 0x99, 0x9f, 0x77, 0xf7, 0xfa, 0x77, 0x01,
0x70, 0x09, 0xfe, 0x99, 0x02, 0x07, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf5, 0x99, 0x07, 0x9f,
0x09, 0x99, 0xf7, 0x77, 0xf7, 0x77, 0x07, 0xfb,
0x77, 0x00, 0x09, 0xfe, 0x99, 0x02, 0x08, 0x88,
0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xf3, 0x99, 0x04, 0x9f,
0x77, 0x77, 0x7f, 0x00, 0xfa, 0x77, 0x00, 0x09,
0xfe, 0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf3, 0x99, 0x00, 0x9f,
0xf7, 0x77, 0x01, 0x00, 0x09, 0xfe, 0x99, 0x02,
0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf3, 0x99, 0x00, 0xf7,
0xf7, 0x77, 0x01, 0x70, 0x09, 0xfe, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xf3, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x09, 0xfe, 0x99, 0x02, 0x00,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xf3, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x09, 0xfe, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xf3, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x09, 0xfe, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x78, 0x09, 0xf3, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x00, 0x70, 0xfe, 0x00, 0xfd, 0x99,
0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xf4, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x09, 0xfa, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xf4, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x09, 0xfa, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf4, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x00, 0x70, 0xf9, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf5, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x09, 0xf9, 0x99, 0x02, 0x07,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x78, 0x09, 0xf5, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x00, 0x70, 0xf8, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xf6, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x70, 0xf8, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf6, 0x99, 0x00, 0xf7,
0xf9, 0x77, 0x00, 0x09, 0xf8, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x7f, 0x09, 0xf7, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x70, 0xf7, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0x00, 0x9f,
0xf9, 0x77, 0x00, 0x70, 0xf7, 0x99, 0x02, 0x00,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0x00, 0xf7,
0xf9, 0x77, 0x00, 0x09, 0xf7, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0x02, 0x00,
0x00, 0x07, 0xfb, 0x77, 0x00, 0x09, 0xf7, 0x99,
0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xf5, 0x99, 0x01, 0x90,
0x07, 0xfd, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02,
0x08, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf8, 0x99, 0xfe, 0xff,
0x01, 0xf9, 0x90, 0xfd, 0x77, 0x00, 0x09, 0xf6,
0x99, 0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf9, 0x99, 0x00, 0x9f,
0xfe, 0x77, 0x02, 0x7f, 0xf9, 0x07, 0xfe, 0x77,
0x00, 0x09, 0xf6, 0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x77, 0x09, 0xf9, 0x99, 0x00, 0xf7,
0xfd, 0x77, 0x01, 0x7f, 0x90, 0xfe, 0x77, 0x00,
0x09, 0xf6, 0x99, 0x02, 0x08, 0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfa, 0x99, 0x00, 0x9f,
0xfb, 0x77, 0x04, 0xf9, 0x07, 0x77, 0x77, 0x09,
0xf6, 0x99, 0x02, 0x07, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfa, 0x99, 0x00, 0x9f,
0xfb, 0x77, 0x04, 0xf9, 0x07, 0x77, 0x77, 0x09,
0xf6, 0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xfa, 0x99, 0x00, 0xf7,
0xfb, 0x77, 0x03, 0x7f, 0x90, 0x00, 0x00, 0xf5,
0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfa, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x03, 0xf9, 0x99, 0x99, 0xf0, 0xf6,
0x99, 0x02, 0x08, 0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x08, 0x77, 0x09, 0xfa, 0x99, 0x00, 0xf7,
0xfa, 0x77, 0x03, 0x7f, 0xff, 0xff, 0x70, 0xf6,
0x99, 0x02, 0x08, 0x08, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfb, 0x99, 0x00, 0x9f,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x78, 0x09, 0xfb, 0x99, 0x00, 0x9f,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x87, 0x09, 0xfb, 0x99, 0x00, 0x9f,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x0f, 0x7f, 0x09, 0xfb, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfb, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xfb, 0x99, 0x00, 0xf7,
0xf6, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02, 0x08,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfb, 0x99, 0x01, 0xf0,
0x07, 0xf7, 0x77, 0x00, 0x70, 0xf6, 0x99, 0x02,
0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xfa, 0x99, 0x02, 0x90,
0x00, 0x00, 0xfa, 0x77, 0x01, 0x00, 0x09, 0xf6,
0x99, 0x02, 0x08, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xf7, 0x99, 0xfa, 0x00,
0xf4, 0x99, 0x02, 0x07, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x80, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x78, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xe3, 0x99, 0x02, 0x00,
0x78, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x7f, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x80, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x09, 0xe3, 0x99, 0x02, 0x07,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0xf7, 0x09, 0xe3, 0x99, 0x02, 0x08,
0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x70, 0xe4, 0x99, 0x03, 0x90,
0x88, 0x87, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x02, 0x07, 0x77, 0x88, 0xe4, 0x00, 0x03, 0x08,
0x80, 0x88, 0x00
db 0xf9, 0xff, 0x00, 0xfe
db 0x15, 0x07, 0x70, 0x88, 0x70, 0x88, 0x08, 0x88,
0x78, 0x87, 0x08, 0x88, 0x70, 0x78, 0x88, 0x88,
0x87, 0x88, 0x08, 0x87, 0x88, 0x88, 0x87, 0xfe,
0x88, 0x0a, 0x87, 0x88, 0x78, 0x88, 0x78, 0x80,
0x88, 0x88, 0x80, 0x88, 0x00
db 0x00, 0x7f, 0xfa, 0xff, 0x00, 0xfc
db 0x1c, 0xd0, 0x08, 0x78, 0x88, 0x87, 0x87, 0x80,
0x80, 0x08, 0x88, 0x08, 0x80, 0x88, 0x87, 0x88,
0x08, 0x88, 0x08, 0x80, 0x08, 0x87, 0x80, 0x88,
0x78, 0x88, 0x78, 0x80, 0x80, 0x78, 0xfe, 0x88,
0x03, 0x78, 0x88, 0x00, 0xd0
db 0x00, 0x7f, 0xfa, 0xff, 0x00, 0xfc
db 0x06, 0xd0, 0x08, 0x88, 0x08, 0x88, 0x88, 0x87,
0xfe, 0x88, 0x02, 0x78, 0x88, 0x88, 0xfe, 0x08,
0x03, 0x87, 0x88, 0x88, 0x87, 0xfd, 0x88, 0x00,
0x78, 0xfd, 0x88, 0x00, 0x78, 0xfd, 0x88, 0x01,
0x00, 0xd0
db 0x00, 0x1f, 0xfa, 0xff, 0x00, 0xf0
db 0x01, 0xdd, 0xd0, 0xe1, 0x00, 0x01, 0xdd, 0xd0
|
; void __FASTCALL__ *adt_QueueCreateS(struct adt_Queue *q)
; 11.2006 aralbrec
SECTION code_clib
PUBLIC adt_QueueCreateS
PUBLIC _adt_QueueCreateS
EXTERN l_setmem
; initialize an adt_Queue
;
; hl = struct adt_Queue*
.adt_QueueCreateS
._adt_QueueCreateS
xor a
jp l_setmem-11
|
ivpu_immediateJump:
mov rbx, 0x100000
test rbx, r15 #Check the architecture of the current instruction.
cmovz ebx, dword ptr [r13 + rdi + 4] #If the result of the check is 0, then this is a 32 bit instruction. As such, the instruction is only 4 bytes, se we use ebx to move the address in instruction part 2.
cmovnz rbx, qword ptr [r13 + rdi + 8] #If the result of the check is 1, then this is a 64 bit instruction, which is a full 8 bytes. We use ebx to move the address in instruction part 2.
mov rdi, rbx
jmp ivpu_fetch
|
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;
int main()
{
char a[10000];
while(1)
{
scanf("%s",a);
int sa=strlen(a);
if(a[0]=='0' && sa==1)
break;
int sum=0;
for(int i=0;i<sa;i++)
{
sum=(sum*10 + (a[i]-'0'))%17;
}
if(sum==0)
printf("1\n");
else
printf("0\n");
}
}
|
; A322008: 1/(1 - Integral_{x=0..1} x^(x^n) dx), rounded to the nearest integer.
; 2,5,10,17,26,37,50,65,82,101,123,146,171,198,227,258,291,326,364,403,444,487,532,579,628,679,733,788,845,904,965,1028,1093,1160,1230,1301,1374,1449,1526,1605,1686,1769,1855,1942,2031,2122,2215,2310,2407,2506,2608
mov $1,$0
sub $1,2
div $1,8
add $1,2
mov $2,$0
mul $2,2
add $1,$2
mov $3,$0
mul $3,$0
add $1,$3
|
; ======================================
; CryEd - cry editor for Pokémon Crystal
; ======================================
INCLUDE "macros.asm"
INCLUDE "constants.asm"
INCLUDE "wram.asm"
; =============
; Reset vectors
; =============
section "Reset $00",rom0[$00]
CallHL: jp hl
section "Reset $08",rom0[$08]
FillRAM:: jp _FillRAM
section "Reset $10",rom0[$10]
WaitVBlank:: jp _WaitVBlank
section "Reset $18",rom0[$18]
WaitTimer:: jp _WaitTimer
section "Reset $20",rom0[$20]
WaitLCDC:: jp _WaitLCDC
section "Reset $30",rom0[$30]
Panic:: jp _Panic
section "Reset $38",rom0[$38]
GenericTrap::
xor a
jp _Panic
; ==================
; Interrupt handlers
; ==================
section "VBlank IRQ",rom0[$40]
IRQ_VBlank:: jp DoVBlank
section "STAT IRQ",rom0[$48]
IRQ_Stat:: jp DoStat
section "Timer IRQ",rom0[$50]
IRQ_Timer:: jp DoTimer
section "Serial IRQ",rom0[$58]
IRQ_Serial:: reti ; not used
;section "Joypad IRQ",rom0[$60]
IRQ_Joypad:: reti ; not used
; ===============
; System routines
; ===============
include "SystemRoutines.asm"
; ==========
; ROM header
; ==========
section "ROM header",rom0[$100]
EntryPoint::
nop
jp ProgramStart
NintendoLogo: ; DO NOT MODIFY OR ROM WILL NOT BOOT!!!
db $ce,$ed,$66,$66,$cc,$0d,$00,$0b,$03,$73,$00,$83,$00,$0c,$00,$0d
db $00,$08,$11,$1f,$88,$89,$00,$0e,$dc,$cc,$6e,$e6,$dd,$dd,$d9,$99
db $bb,$bb,$67,$63,$6e,$0e,$ec,$cc,$dd,$dc,$99,$9f,$bb,$b9,$33,$3e
ROMTitle: romTitle "CRYED" ; ROM title (15 bytes)
GBCSupport: db $00 ; GBC support (0 = DMG only, $80 = DMG/GBC, $C0 = GBC only)
NewLicenseCode: db "DS" ; new license code (2 bytes)
SGBSupport: db 0 ; SGB support
CartType: db $1b ; Cart type, see hardware.inc for a list of values
ROMSize: ds 1 ; ROM size (handled by post-linking tool)
RAMSize: db 2 ; RAM size
DestCode: db 1 ; Destination code (0 = Japan, 1 = All others)
OldLicenseCode: db $33 ; Old license code (if $33, check new license code)
ROMVersion: db 0 ; ROM version
HeaderChecksum: ds 1 ; Header checksum (handled by post-linking tool)
ROMChecksum: ds 2 ; ROM checksum (2 bytes) (handled by post-linking tool)
; =====================
; Start of program code
; =====================
ProgramStart::
di
ld sp,$e000
push bc
push af
; disable LCD
.wait
ldh a,[rLY]
cp $90
jr nz,.wait
xor a
ldh [rLCDC],a
; init memory
ld hl,$c000 ; start of WRAM
ld bc,$1ffa ; don't clear stack
xor a
rst $08
ld hl,$8000 ; start of VRAM
ld bc,$2000
xor a
rst $08
; clear HRAM
ld bc,$7f80
xor a
.loop
ld [c],a
inc c
dec b
jr nz,.loop
call CopyDMARoutine
call $ff80 ; clear OAM
call LoadSaveScreen_SRAMCheck
jr nc,.noinitsram
ld a,$a
ld [rRAMG],a
xor a
ld hl,$a000
ld bc,$2000
rst $08
ld hl,.savestr
ld de,$a600
ld b,5
.strloop
ld a,[hl+]
ld [de],a
inc de
dec b
jr nz,.strloop
xor a
ld [$0000],a
jr .noinitsram
.savestr
db "SAVE!"
.noinitsram
; check GB type
; sets sys_GBType to 0 if DMG/SGB/GBP/GBL/SGB2, 1 if GBC, 2 if GBA/GBA SP/GB Player
; TODO: Improve checks to allow for GBP/SGB/SGB2 to be detected separately
pop af
pop bc
cp $11
jr nz,.dmg
.gbc
and 1 ; a = 1
add b ; b = 1 if on GBA
ld [sys_GBType],a
jr .continue
.dmg
xor a
ld [sys_GBType],a
.continue
InitCryEditor::
rst $10
xor a
ldh [rLCDC],a
ld a,9
ld [sys_MenuMax],a
xor a
ld [sys_MenuPos],a
call InitSound
; load font + graphics
CopyTileset1BPP Font,0,98
ld hl,CryEditorTilemap
call LoadMapText
; init rendering variables
SetDMGPal rBGP, 0,1,2,3
SetDMGPal rOBP0,0,0,2,3
SetDMGPal rOBP1,0,1,2,3
xor a
ldh [rSCX],a
ldh [rSCY],a
ldh [rWX],a
ldh [rWY],a
ld a,%10010001
ldh [rLCDC],a
ld a,IEF_VBLANK
ldh [rIE],a
ei
halt
CryEditorLoop::
ld a,[sys_btnPress]
bit A_BUTTON_F,a
jr nz,.playCry
bit START_F,a
jr nz,.playCry
bit B_BUTTON_F,a
jr nz,.resetCry
bit SELECT_F,a
jp nz,InitOptionsMenu
ld hl,sys_MenuPos
bit D_UP_F,a
jr nz,.editUp
bit D_DOWN_F,a
jr nz,.editDown
bit D_RIGHT_F,a
jr nz,.cursorNext
bit D_LEFT_F,a
jr nz,.cursorPrev
jr .continue
.resetCry
xor a
ld hl,CryEdit_CryBase
ld [hl+],a
ld [hl+],a
ld [hl+],a
ld [hl+],a
ld [hl+],a
jr .continue
.playCry
ld hl,CryEdit_CryBase
ld d,0
ld e,[hl]
inc hl
ld a,[hl+]
ld [wCryPitch],a
ld a,[hl+]
ld [wCryPitch+1],a
ld a,[hl+]
ld [wCryLength],a
ld a,[hl+]
ld [wCryLength+1],a
call CryEd_PreviewCry
jr .continue
.editUp
ld e,1
call CryEdit_EditNybble
jr .continue
.editDown
ld e,0
call CryEdit_EditNybble
jr .continue
.setItem
ld [hl],b
jr .continue
.cursorNext
ld b," "-32
call CryEditor_DrawCursor
inc [hl]
ld b,[hl]
ld a,[sys_MenuMax]
inc a
cp b
jr nz,.setItem
ld [hl],0
jr .continue
.cursorPrev
ld b," "-32
call CryEditor_DrawCursor
dec [hl]
ld a,[hl]
cp $ff
ld b,a
jr nz,.setItem
ld a,[sys_MenuMax]
ld [hl],a
; fall through to .continue
.continue
ld b,"^"-32
call CryEditor_DrawCursor
ld a,[CryEdit_CryBase]
ld hl,$9831
call DrawHex
ld a,[CryEdit_CryPitch+1]
ld hl,$986f
call DrawHex
ld a,[CryEdit_CryPitch]
call DrawHex
ld a,[CryEdit_CryLength+1]
ld hl,$98af
call DrawHex
ld a,[CryEdit_CryLength]
call DrawHex
halt
call UpdateSound
jp CryEditorLoop
; INPUT: b = char to use for cursor
; Destroys A.
CryEditor_DrawCursor::
push hl
ld a,[sys_MenuPos]
ld hl,CryEdit_CursorLocations
add a
add l
ld l,a
jr nc,.nocarry
inc h
.nocarry
ld a,[hl+]
ld h,[hl]
ld l,a
; write char
WaitForVRAM
ld [hl],b
pop hl
ret
CryEdit_EditNybble:
ld a,[sys_MenuPos]
ld b,a
add a
add b
ld hl,CryEdit_NybbleLocations
add l
ld l,a
jr nc,.nocarry
inc h
.nocarry
ld a,[hl+]
ld d,a
ld a,[hl+]
ld h,[hl]
ld l,a
ld a,d
and a
jr nz,.uppernybble
.lowernybble
ld a,e
and a
jr z,.sub1
jr .add1
.uppernybble
ld a,e
and a
jr z,.sub10
jr .add10
.add1
inc [hl]
ld a,[hl]
and $f
cp 0
ret nz
ld a,[hl]
sub $10
ld [hl],a
ret
.sub1
dec [hl]
ld a,[hl]
and $f
cp $f
ret nz
ld a,[hl]
add $10
ld [hl],a
ret
.add10
ld a,[hl]
add $10
ld [hl],a
ret
.sub10
ld a,[hl]
sub $10
ld [hl],a
ret
CryEdit_CursorLocations:
dw $9851,$9852 ; base
dw $988f,$9890,$9891,$9892 ; pitch
dw $98cf,$98d0,$98d1,$98d2 ; length
CryEdit_NybbleLocations:
dbw 1,CryEdit_CryBase
dbw 0,CryEdit_CryBase
dbw 1,CryEdit_CryPitch+1
dbw 0,CryEdit_CryPitch+1
dbw 1,CryEdit_CryPitch
dbw 0,CryEdit_CryPitch
dbw 1,CryEdit_CryLength+1
dbw 0,CryEdit_CryLength+1
dbw 1,CryEdit_CryLength
dbw 0,CryEdit_CryLength
Menu_DrawCursor::
push af
ld h,0
ld a,[sys_MenuPos]
ld l,a
add hl,hl ; x2
add hl,hl ; x4
add hl,hl ; x8
add hl,hl ; x16
add hl,hl ; x32
ld b,h
ld c,l
ld hl,$9861
add hl,bc
WaitForVRAM
pop af
ld [hl],a
ret
CryEditorTilemap::
; ####################
db " "
db " Base: $?? "
db " "
db " Pitch: $???? "
db " "
db " Length: $???? "
db " "
db " - CONTROLS - "
db "Left/Right Cursor"
db "Up/Down Edit value"
db "A/Start Test"
db "B Reset"
db "Select Menu"
db " "
db "Build date: "
.datestart
db __DATE__
.dateend
rept 20-(.dateend-.datestart)
db 20
endr
.timestart
db __TIME__
.timeend
rept 20-(.timeend-.timestart)
db 20
endr
db " "
; ####################
; ================================
InitOptionsMenu::
rst $10
xor a
ldh [rLCDC],a
ld a,2
ld [sys_MenuMax],a
xor a
ld [sys_MenuPos],a
call InitSound
; load font + graphics
CopyTileset1BPP Font,0,98
ld hl,OptionsMenuTilemap
call LoadMapText
xor a
call Options_PrintDescription
; init rendering variables
SetDMGPal rBGP, 0,1,2,3
SetDMGPal rOBP0,0,0,2,3
SetDMGPal rOBP1,0,1,2,3
xor a
ldh [rSCX],a
ldh [rSCY],a
ldh [rWX],a
ldh [rWY],a
ld a,%10010001
ldh [rLCDC],a
ld a,IEF_VBLANK
ldh [rIE],a
ei
ld de,6 ; SFX_MENU
call PlaySFX
halt
OptionsMenuLoop::
ld a,[sys_btnPress]
bit A_BUTTON_F,a
jr nz,.selectItem
bit B_BUTTON_F,a
jp nz,InitCryEditor
bit START_F,a
jr nz,.selectItem
bit SELECT_F,a
jr nz,.nextItem
bit D_UP_F,a
jr nz,.prevItem
bit D_DOWN_F,a
jr z,.continue
.nextItem
ld a," "-$20
call Menu_DrawCursor
ld a,[sys_MenuPos]
inc a
ld b,a
ld a,[sys_MenuMax]
inc a
cp b
ld a,b
jr nz,.setItem
xor a
.setItem
ld [sys_MenuPos],a
call Options_PrintDescription
jr .continue
.prevItem
ld a," "-$20
call Menu_DrawCursor
ld a,[sys_MenuPos]
dec a
cp $ff
jr nz,.setItem
ld a,[sys_MenuMax]
jr .setItem
.selectItem
ld hl,MenuItemPtrs_OptionsMenu
ld a,[sys_MenuPos]
add a
add l
ld l,a
jr nc,.nocarry
inc h
.nocarry
ld de,7 ; SFX_READ_TEXT
call PlaySFX
push af
; wait for SFX to finish playing
.waitSFX
call UpdateSound
halt
call IsSFXPlaying
jr nc,.waitSFX
call PtrToHL
rst $00
.continue
ld a,">"-$20
call Menu_DrawCursor
call UpdateSound
halt
jr OptionsMenuLoop
MenuItemPtrs_OptionsMenu::
dw .importCry
dw .loadSaveCry
dw .exit
.importCry
pop hl ; stack overflow prevention
jp InitCryImporter
.loadSaveCry
pop hl ; stack overflow prevention
xor a
jp InitLoadSaveScreen
.exit
pop hl ; stack overflow prevention
jp InitCryEditor
OptionsMenuTilemap::
; ####################
db " "
db " - OPTIONS - "
db " "
db " Import cry "
db " Load/save cry "
db " Exit "
db " "
db " "
db " "
db " "
db " "
db " "
db " "
db " "
db "DESCRIPTION LINE 1 "
db "DESCRIPTION LINE 2 "
db "DESCRIPTION LINE 3 "
db "DESCRIPTION LINE 4 "
OptionsMenu_DescriptionPointers:
dw .importCry
dw .loadSaveCry
dw .exit
.importCry
db "Import an existing "
db "cry. "
db " "
db " "
.loadSaveCry
db "Load or save a cry. "
db " "
db " "
db " "
.exit
db "Return to the cry "
db "editor. "
db " "
db " "
Options_PrintDescription:
ld bc,OptionsMenu_DescriptionPointers
ld h,0
ld l,a
add hl,hl
add hl,bc
ld a,[hl+]
ld h,[hl]
ld l,a
ld de,$99c0
ld bc,$414
.loop
ld a,[hl+]
sub 32
push af
WaitForVRAM
pop af
ld [de],a
inc de
dec c
jr nz,.loop
ld c,$14
ld a,e
add $c
jr nc,.continue
inc d
.continue
ld e,a
dec b
jr nz,.loop
ret
; ================
; Load/save screen
; ================
InitLoadSaveScreen:
rst $10
xor a
ldh [rLCDC],a
ld [sys_MenuPos],a
ld a,[SelectedSaveSlot]
ld [sys_MenuMax],a ; sys_MenuMax is repurposed as currently selected save slot
call InitSound
; load font + graphics
CopyTileset1BPP Font,0,98
CopyTileset1BPPInvert Font,$800,98
ld hl,LoadSaveScreenTilemap
call LoadMapText
xor a
ld hl,msg_dummy
call LoadSaveScreen_PrintLine
inc a
ld hl,msg_dummy
call LoadSaveScreen_PrintLine
; init rendering variables
SetDMGPal rBGP, 0,1,2,3
SetDMGPal rOBP0,0,0,2,3
SetDMGPal rOBP1,0,1,2,3
xor a
ldh [rSCX],a
ldh [rSCY],a
ldh [rWX],a
ldh [rWY],a
ld a,%10010001
ldh [rLCDC],a
ld a,IEF_VBLANK
ldh [rIE],a
ei
halt
LoadSaveScreenLoop:
call UpdateSound
ld hl,sys_MenuMax
ld a,[sys_btnPress]
bit A_BUTTON_F,a
jp nz,.selectSlot
bit B_BUTTON_F,a
jr nz,.exit
bit SELECT_F,a
jr nz,.previewCry
bit D_UP_F,a
jr nz,.add16
bit D_DOWN_F,a
jr nz,.sub16
bit D_RIGHT_F,a
jr nz,.add1
bit D_LEFT_F,a
jr nz,.sub1
.continue
ld a,[sys_MenuMax]
ld [SelectedSaveSlot],a
ld hl,$9871
call DrawHex
halt
jr LoadSaveScreenLoop
.previewCry
call LoadSaveScreen_SRAMCheck
jr c,.previewfail
ld a,[sys_MenuMax]
call LoadSaveScreen_GetPtr
ld a,$a
ld [rRAMG],a
push hl
call LoadSave_CheckIfCryExists
jp nc,.crydoesntexist
pop hl
ld a,[hl+]
ld d,0
ld e,a
inc hl
ld a,[hl+]
ld [wCryPitch],a
ld a,[hl+]
ld [wCryPitch+1],a
ld a,[hl+]
ld [wCryLength],a
ld a,[hl+]
ld [wCryLength+1],a
call CryEd_PreviewCry
jr .continue
.previewfail
call InitSound
ld de,$19 ; SFX_WRONG
call PlaySFX
ld hl,msg_previewfail
jp .doprintmessage
.sub1
dec [hl]
jr .continue
.add1
inc [hl]
jr .continue
.sub16
ld a,[hl]
sub 16
ld [hl],a
jr .continue
.add16
ld a,[hl]
add 16
ld [hl],a
jr .continue
.exit
call InitSound
ld de,$e
call PlaySFX
.waitSFX
call UpdateSound
halt
call IsSFXPlaying
jr nc,.waitSFX
jp InitCryEditor
.selectSlot
call InitSound
ld de,$7
call PlaySFX
.loop1
xor a
ld hl,msg_loadsave
call LoadSaveScreen_PrintLine
inc a
ld hl,prompt_loadsave
call LoadSaveScreen_PrintLine
call LoadSaveScreen_WaitForPrompt
cp $ff
jp z,.cancel
and a
jp nz,.doSave
dec a
jr nz,.doLoad
jp .continue
.doLoad
call LoadSaveScreen_SRAMCheck
jr c,.loadfail
call LoadSaveScreen_GetPtr
ld a,$a
ld [rRAMG],a
push hl
call LoadSave_CheckIfCryExists
jr nc,.crydoesntexist
pop hl
ld a,[hl+]
ld [CryEdit_CryBase],a
inc hl
ld a,[hl+]
ld [CryEdit_CryPitch],a
ld a,[hl+]
ld [CryEdit_CryPitch+1],a
ld a,[hl+]
ld [CryEdit_CryLength],a
ld a,[hl]
ld [CryEdit_CryLength+1],a
xor a
ld [rRAMG],a
call InitSound
ld de,$22
call PlaySFX
ld hl,msg_loaded
jr .doprintmessage
.crydoesntexist
xor a
ld [rRAMG],a
call InitSound
ld de,$19 ; SFX_WRONG
call PlaySFX
ld hl,msg_slotempty
jr .doprintmessage
.loadfail
call InitSound
ld de,$19 ; SFX_WRONG
call PlaySFX
ld hl,msg_loadfail
jr .doprintmessage
.savefail
xor a
ld [rRAMG],a
call InitSound
ld de,$19 ; SFX_WRONG
call PlaySFX
ld hl,msg_savefail
.doprintmessage
xor a
call LoadSaveScreen_PrintLine
inc a
ld hl,msg_dummy
call LoadSaveScreen_PrintLine
call LoadSaveScreen_WaitForButton
ld b,60
.loop
push bc
call UpdateSound
halt
pop bc
dec b
jr nz,.loop
; fall through to .cancel
.cancel
xor a
ld [rRAMG],a
ld hl,msg_dummy
call LoadSaveScreen_PrintLine
inc a
ld hl,msg_dummy
call LoadSaveScreen_PrintLine
jp .continue
.doSave
; save check
ld a,$a
ld [rRAMG],a
ld hl,$a606
ld a,$ed
ld [hl],a
ld b,a
ld a,[hl]
cp b
jr nz,.savefail
ld a,[sys_MenuMax]
call LoadSaveScreen_GetPtr
push hl
; check if cry exists
call LoadSave_CheckIfCryExists
jr nc,.crydoesntexist2
xor a
ld hl,msg_overwrite
call LoadSaveScreen_PrintLine
inc a
ld hl,prompt_yesno
call LoadSaveScreen_PrintLine
call InitSound
ld de,$7
call PlaySFX
call LoadSaveScreen_WaitForPrompt
cp $ff
jr z,.cancel
and a
jr nz,.crydoesntexist2
jr .cancel
.crydoesntexist2
pop de
ld hl,CryEdit_CryBase
ld a,[hl+]
ld [de],a
inc de
inc de
ld b,4
.saveloop
ld a,[hl+]
ld [de],a
inc de
dec b
jr nz,.saveloop
xor a
ld [rRAMG],a
call InitSound
ld de,$22
call PlaySFX
ld hl,msg_saved
jp .doprintmessage
; carry = 1 if cry exists
LoadSave_CheckIfCryExists:
ld b,3
.loop
ld c,0
ld a,[hl+]
add c
ld c,a
ld a,[hl+]
add c
ld c,a
cp 0
jr nz,.exists
dec b
jr nz,.loop
and a ; clear carry
ret
.exists
scf
ret
LoadSaveScreen_GetPtr:
ld a,[sys_MenuMax]
ld e,a
ld d,0
ld hl,$a000
add hl,de
add hl,de
add hl,de
add hl,de
add hl,de
add hl,de
ret
LoadSaveScreen_SRAMCheck:
ld a,$a
ld [rRAMG],a ; enable SRAM
ld hl,$a600
ld b,5
ld c,0
.loop
ld a,[hl+]
add c
ld c,a
dec b
jr nz,.loop
xor a
ld [rRAMG],a
ld a,c
cp $50
scf
ret nz ; return carry = 1 if check failed
ccf ; return carry = 0 if check passed
ret
LoadSaveScreen_WaitForButton:
call UpdateSound
halt
ld a,[sys_btnPress]
and a
jr nz,LoadSaveScreen_WaitForButton
ret
; OUTPUT: 0 if item 1 selected, 1 if item 2 selected, $ff if user cancelled
LoadSaveScreen_WaitForPrompt:
xor a
ld [sys_MenuPos],a
halt
.loop
ld a,[sys_btnPress]
bit D_LEFT_F,a
jr nz,.toggle
bit D_RIGHT_F,a
jr nz,.toggle
bit A_BUTTON_F,a
jr nz,.select
bit B_BUTTON_F,a
jr nz,.cancel
.continue
ld a,[sys_MenuPos]
and a
jr nz,.right
.left
ld hl,$9a21
ld de,$9a2b
jr .drawcursor
.right
ld hl,$9a2b
ld de,$9a21
.drawcursor
WaitForVRAM
ld a,">"+$60
ld [hl],a
ld a," "+$60
ld [de],a
call UpdateSound
halt
jr .loop
.toggle
ld a,[sys_MenuPos]
xor 1
ld [sys_MenuPos],a
jr .continue
.select
ld a,[sys_MenuPos]
ret
.cancel
ld a,$ff
ret
LoadSaveScreenTilemap:
; ####################
db " "
db " - LOAD/SAVE - "
db " "
db " Save slot: $?? "
db " "
db " - CONTROLS - "
db "A Load/save"
db "B Cancel"
db "Select Preview"
db "D-pad Select"
db " "
db " "
db " "
db " "
db " "
db " "
db "MESSAGE GOES HERE "
db "PROMPT GOES HERE "
LoadSaveScreenMessages:
msg_dummy: db " "
msg_loadsave: db " LOAD OR SAVE? "
msg_overwrite: db " OVERWRITE? "
msg_saved: db " CRY SAVED "
msg_loaded: db " CRY LOADED "
msg_slotempty: db " SLOT EMPTY "
msg_savefail: db " SAVE FAILED! "
msg_loadfail: db " LOAD FAILED! "
msg_previewfail: db " PREVIEW FAILED! "
;msg_free: db " Free slot "
;msg_notfree: db " Slot in use "
prompt_loadsave: db " > Load Save "
prompt_yesno: db " > No Yes "
; INPUT: hl = string pointer, a = line no.
LoadSaveScreen_PrintLine:
push af
ld b,20
and a
jr nz,.line1
.line0
ld de,$9a00
jr .loop
.line1
ld de,$9a20
.loop
ld a,[hl+]
add $60
push af
WaitForVRAM
pop af
ld [de],a
inc de
dec b
jr nz,.loop
pop af
ret
; =============
; Misc routines
; =============
CryEd_PreviewCry:
ld a,[hROMBank]
push af
ld a,BANK(_PlayCry)
ld [hROMBank],a
ld [rROMB0],a
call _PlayCry
pop af
ld [hROMBank],a
ld [rROMB0],a
ret
; Fill RAM with a value.
; INPUT: a = value
; hl = address
; bc = size
_FillRAM::
ld e,a
.loop
ld [hl],e
inc hl
dec bc
ld a,b
or c
jr nz,.loop
ret
; Fill up to 256 bytes of RAM with a value.
; INPUT: a = value
; hl = address
; b = size
_FillRAMSmall::
ld e,a
.loop
ld [hl],e
inc hl
dec b
jr nz,.loop
ret
; Copy up to 65536 bytes to RAM.
; INPUT: hl = source
; de = destination
; bc = size
_CopyRAM::
ld a,[hl+]
ld [de],a
inc de
dec bc
ld a,b
or c
jr nz,_CopyRAM
ret
; Copy up to 256 bytes to RAM.
; INPUT: hl = source
; de = destination
; b = size
_CopyRAMSmall::
ld a,[hl+]
ld [de],a
inc de
dec b
jr nz,_CopyRAMSmall
ret
; ==================
; Interrupt handlers
; ==================
DoVBlank::
push af
push bc ; CheckInput uses bc
ld a,[sys_CurrentFrame]
inc a
ld [sys_CurrentFrame],a ; increment current frame
call CheckInput ; get button input for current frame
; A+B+Start+Select restart sequence
ld a,[sys_btnHold]
cp A_BUTTON+B_BUTTON+START+SELECT ; is A+B+Start+Select pressed
jr nz,.noreset ; if not, skip
ld a,[sys_ResetTimer] ; get reset timer
inc a
ld [sys_ResetTimer],a ; store reset timer
cp 60 ; has 1 second passed?
jr nz,.continue ; if not, skip
ld a,[sys_GBType] ; get current GB model
dec a ; GBC?
jr z,.gbc ; if yes, jump
dec a ; GBA?
jr z,.gba ; if yes, jump
.dmg ; default case: assume DMG
xor a ; a = 0, b = whatever
jr .dorestart
.gbc ; a = $11, b = 0
ld a,$11
ld b,0
jr .dorestart
.gba ; a = $11, b = 1
ld a,$11
ld b,1
; fall through to .dorestart
.dorestart
jp ProgramStart ; restart game
.noreset ; if A+B+Start+Select aren't held...
xor a
ld [sys_ResetTimer],a ; reset timer
.continue
; done
ld a,1
ld [sys_VBlankFlag],a ; set VBlank flag
pop bc
pop af
reti
DoStat::
push af
ld a,1
ld [sys_LCDCFlag],a
pop af
reti
DoTimer::
push af
ld a,1
ld [sys_TimerFlag],a
pop af
reti
; =======================
; Error handling routines
; =======================
_Panic::
jr _Panic
; =======================
; Interrupt wait routines
; =======================
_WaitVBlank::
ldh a,[rIE]
bit IEF_VBLANK,a
ret z ;if vblank interupt is off, return
.wait
halt ;wait for interupt
ld a,[sys_VBlankFlag]
and a
jr nz,.wait ;loop until sys_VBlankFlag is unset
xor a
ld [sys_VBlankFlag],a ;then load 0 into it? when it has to be 0 to get here? this code is probably broken.
ret
_WaitTimer::
ldh a,[rIE]
bit IEF_TIMER,a
ret z
.wait
halt
ld a,[sys_TimerFlag]
and a
jr nz,.wait
xor a
ld [sys_VBlankFlag],a
ret
_WaitLCDC::
ldh a,[rIE]
bit IEF_LCDC,a
ret z
.wait
halt
ld a,[sys_LCDCFlag]
and a
jr nz,.wait
xor a
ld [sys_LCDCFlag],a
ret
; =================
; Graphics routines
; =================
_CopyTileset:: ; WARNING: Do not use while LCD is on!
ld a,[hl+] ; get byte
ld [de],a ; write byte
inc de
dec bc
ld a,b ; check if bc = 0
or c
jr nz,_CopyTileset ; if bc != 0, loop
ret
_CopyTilesetSafe:: ; same as _CopyTileset, but waits for VRAM accessibility before writing data
ldh a,[rSTAT]
and 2 ; check if VRAM is accessible
jr nz,_CopyTilesetSafe ; if it isn't, loop until it is
ld a,[hl+] ; get byte
ld [de],a ; write byte
inc de
dec bc
ld a,b ; check if bc = 0
or c
jr nz,_CopyTilesetSafe ; if bc != 0, loop
ret
_CopyTileset1BPP:: ; WARNING: Do not use while LCD is on!
ld a,[hl+] ; get byte
ld [de],a ; write byte
inc de ; increment destination address
ld [de],a ; write byte again
inc de ; increment destination address again
dec bc
dec bc ; since we're copying two bytes, we need to dec bc twice
ld a,b ; check if bc = 0
or c
jr nz,_CopyTileset1BPP ; if bc != 0, loop
ret
_CopyTileset1BPPInvert:: ; WARNING: Do not use while LCD is on!
ld a,[hl+] ; get byte
cpl ; invert byte
ld [de],a ; write byte
inc de ; increment destination address
ld [de],a ; write byte again
inc de ; increment destination address again
dec bc
dec bc ; since we're copying two bytes, we need to dec bc twice
ld a,b ; check if bc = 0
or c
jr nz,_CopyTileset1BPPInvert ; if bc != 0, loop
ret
_CopyTileset1BPPSafe:: ; same as _CopyTileset1BPP, but waits for VRAM accessibility before writing data
ldh a,[rSTAT]
and 2 ; check if VRAM is accessible
jr nz,_CopyTileset1BPPSafe ; if it isn't, loop until it is
ld a,[hl+] ; get byte
ld [de],a ; write byte
inc de ; increment destination address
ld [de],a ; write byte again
inc de ; increment destination address again
dec bc
dec bc ; since we're copying two bytes, we need to dec bc twice
ld a,b ; check if bc = 0
or c
jr nz,_CopyTileset1BPP ; if bc != 0, loop
ret
; =============
; Graphics data
; =============
Font:: incbin "GFX/Font.bin"
; ================================
InitCryImporter::
rst $10
xor a
ldh [rLCDC],a
call InitSound
; load font + graphics
CopyTileset1BPP Font,0,98
ld hl,CryImporterTilemap
call LoadMapText
; init rendering variables
SetDMGPal rBGP, 0,1,2,3
SetDMGPal rOBP0,0,0,2,3
SetDMGPal rOBP1,0,1,2,3
xor a
ldh [rSCX],a
ldh [rSCY],a
ldh [rWX],a
ldh [rWY],a
ld a,%10010001
ldh [rLCDC],a
ld a,IEF_VBLANK
ldh [rIE],a
ei
halt
CryImporterLoop::
ld a,[sys_btnPress]
bit A_BUTTON_F,a
jr nz,.importCry
bit B_BUTTON_F,a
jp nz,InitCryEditor
bit START_F,a
jr nz,.importCry
bit SELECT_F,a
jp nz,.previewCry
ld hl,sys_ImportPos
bit D_UP_F,a
jr nz,.add16
bit D_DOWN_F,a
jr nz,.sub16
bit D_RIGHT_F,a
jr nz,.add1
bit D_LEFT_F,a
jr nz,.sub1
jp .continue
.add16
ld d,[hl]
inc hl
ld a,[hld]
add 16
ld e, a
ld a, 0
adc d
ld [hli],a
ld [hl],e
jr .continue
.sub16
ld d,[hl]
inc hl
ld a,[hld]
sub 16
ld e, a
ld a, d
sbc 0
ld [hli],a
ld [hl],e
jr .continue
.add1
ld d,[hl]
inc hl
ld a,[hld]
ld e, a
inc de
ld [hl],d
inc hl
ld [hl],e
jr .continue
.sub1
ld d,[hl]
inc hl
ld a,[hld]
ld e, a
dec de
ld [hl],d
inc hl
ld [hl],e
jr .continue
.previewCry
ld a,[sys_ImportPos]
ld d,a
ld a,[sys_ImportPos + 1]
ld e,a
call PlayCry
jr .continue
.importCry
ld a,[sys_ImportPos]
ld d,a
ld a,[sys_ImportPos + 1]
ld e,a
call PlayCry
.cryloop
halt
call UpdateSound
call IsSFXPlaying
jr nc,.cryloop
; bankchange to PokemonCries
ld a, [hROMBank]
push af
ld a, BANK(PokemonCries)
ld [hROMBank], a
ld [rROMB0], a
ld hl,PokemonCries
add hl,de
add hl,de
add hl,de
add hl,de
add hl,de
add hl,de
ld a,[hl+]
inc hl
ld [CryEdit_CryBase],a
ld a,[hl+]
ld [CryEdit_CryPitch],a
ld a,[hl+]
ld [CryEdit_CryPitch+1],a
ld a,[hl+]
ld [CryEdit_CryLength],a
ld a,[hl]
ld [CryEdit_CryLength+1],a
;bankchange back
pop af
ld [hROMBank], a
ld [rROMB0], a
jp InitCryEditor
.nocry
ld de,$19 ; SFX_WRONG
call PlaySFX
.continue
ld a,[sys_ImportPos]
ld hl,$986F
call DrawHex
ld a,[sys_ImportPos+1]
ld hl,$9871
call DrawHex
ld a,[sys_ImportPos]
ld h,a
ld a,[sys_ImportPos+1]
ld l,a
ld bc,$9881
call PrintMonName
call UpdateSound
halt
jp CryImporterLoop
CryImporterTilemap::
; ####################
db " "
db " - CRY IMPORTER - "
db " "
db " Cry ID: $???? "
db " ???????????? "
db " "
db " - CONTROLS - "
db " Left/Right +- 1 "
db " Up/Down +- 16 "
db " A/Start Import "
db " B Exit "
db " Select Preview "
db " "
db " "
db " "
db " "
db " "
db " "
db " "
; Input: hl = Pokemon ID, bc = screen pos
PrintMonName:
ld a, h
cp HIGH(NUM_MONS - 1)
jr c, .continue
jr nz, .noname
ld a, l
cp LOW(NUM_MONS - 1)
jr c, .continue
jr nz, .noname
.continue
add hl,hl ; x2
ld d,h
ld e,l
add hl,hl ; x4
add hl,de ; x6
add hl,hl ; x12
ld a,bank(PokemonNames)
ld [rROMB0],a
ld de,PokemonNames
add hl,de
ld d,b
ld e,c
ld b,12
.loop
WaitForVRAM
ld a,[hl+]
sub 32
ld [de],a
inc de
dec b
jr nz,.loop
ld a,1
ld [rROMB0],a
ret
.noname
ld hl, OutOfBoundText
ld d,b
ld e,c
ld b,12
.nonameloop
WaitForVRAM
ld a,[hl+]
sub 32
ld [de],a
inc de
dec b
jr nz,.nonameloop
ret
OutOfBoundText:
db "OUT OF BOUND"
; ============
; Sprite stuff
; ============
CopyDMARoutine::
ld bc,$80 + ((_OAM_DMA_End-_OAM_DMA) << 8)
ld hl,_OAM_DMA
.loop
ld a,[hl+]
ld [c],a
inc c
dec b
jr nz,.loop
ret
_OAM_DMA::
ld a,high(SpriteBuffer)
ldh [rDMA],a
ld a,$28
.wait
dec a
jr nz,.wait
ret
_OAM_DMA_End:
; =============
; Misc routines
; =============
PtrToHL::
ld a,[hl+]
ld h,[hl]
ld l,a
ret
PtrToDE::
ld a,[hl+]
ld d,[hl]
ld e,a
ret
; ===========
; Sound stuff
; ===========
include "audio.asm"
; =============
; Pokemon names
; =============
NUM_MONS = 898 ;put the number of pokemon names added here
SECTION "Pokemon names",romx,bank[2]
PokemonNames::
db "BULBASAUR "
db "IVYSAUR "
db "VENUSAUR "
db "CHARMANDER "
db "CHARMELEON "
db "CHARIZARD "
db "SQUIRTLE "
db "WARTORTLE "
db "BLASTOISE "
db "CATERPIE "
db "METAPOD "
db "BUTTERFREE "
db "WEEDLE "
db "KAKUNA "
db "BEEDRILL "
db "PIDGEY "
db "PIDGEOTTO "
db "PIDGEOT "
db "RATTATA "
db "RATICATE "
db "SPEAROW "
db "FEAROW "
db "EKANS "
db "ARBOK "
db "PIKACHU "
db "RAICHU "
db "SANDSHREW "
db "SANDSLASH "
db "NIDORAN",$80," "
db "NIDORINA "
db "NIDOQUEEN "
db "NIDORAN",$81," "
db "NIDORINO "
db "NIDOKING "
db "CLEFAIRY "
db "CLEFABLE "
db "VULPIX "
db "NINETALES "
db "JIGGLYPUFF "
db "WIGGLYTUFF "
db "ZUBAT "
db "GOLBAT "
db "ODDISH "
db "GLOOM "
db "VILEPLUME "
db "PARAS "
db "PARASECT "
db "VENONAT "
db "VENOMOTH "
db "DIGLETT "
db "DUGTRIO "
db "MEOWTH "
db "PERSIAN "
db "PSYDUCK "
db "GOLDUCK "
db "MANKEY "
db "PRIMEAPE "
db "GROWLITHE "
db "ARCANINE "
db "POLIWAG "
db "POLIWHIRL "
db "POLIWRATH "
db "ABRA "
db "KADABRA "
db "ALAKAZAM "
db "MACHOP "
db "MACHOKE "
db "MACHAMP "
db "BELLSPROUT "
db "WEEPINBELL "
db "VICTREEBEL "
db "TENTACOOL "
db "TENTACRUEL "
db "GEODUDE "
db "GRAVELER "
db "GOLEM "
db "PONYTA "
db "RAPIDASH "
db "SLOWPOKE "
db "SLOWBRO "
db "MAGNEMITE "
db "MAGNETON "
db "FARFETCHD "
db "DODUO "
db "DODRIO "
db "SEEL "
db "DEWGONG "
db "GRIMER "
db "MUK "
db "SHELLDER "
db "CLOYSTER "
db "GASTLY "
db "HAUNTER "
db "GENGAR "
db "ONIX "
db "DROWZEE "
db "HYPNO "
db "KRABBY "
db "KINGLER "
db "VOLTORB "
db "ELECTRODE "
db "EXEGGCUTE "
db "EXEGGUTOR "
db "CUBONE "
db "MAROWAK "
db "HITMONLEE "
db "HITMONCHAN "
db "LICKITUNG "
db "KOFFING "
db "WEEZING "
db "RHYHORN "
db "RHYDON "
db "CHANSEY "
db "TANGELA "
db "KANGASKHAN "
db "HORSEA "
db "SEADRA "
db "GOLDEEN "
db "SEAKING "
db "STARYU "
db "STARMIE "
db "MR. MIME "
db "SCYTHER "
db "JYNX "
db "ELECTABUZZ "
db "MAGMAR "
db "PINSIR "
db "TAUROS "
db "MAGIKARP "
db "GYARADOS "
db "LAPRAS "
db "DITTO "
db "EEVEE "
db "VAPOREON "
db "JOLTEON "
db "FLAREON "
db "PORYGON "
db "OMANYTE "
db "OMASTAR "
db "KABUTO "
db "KABUTOPS "
db "AERODACTYL "
db "SNORLAX "
db "ARTICUNO "
db "ZAPDOS "
db "MOLTRES "
db "DRATINI "
db "DRAGONAIR "
db "DRAGONITE "
db "MEWTWO "
db "MEW "
db "CHIKORITA "
db "BAYLEEF "
db "MEGANIUM "
db "CYNDAQUIL "
db "QUILAVA "
db "TYPHLOSION "
db "TOTODILE "
db "CROCONAW "
db "FERALIGATR "
db "SENTRET "
db "FURRET "
db "HOOTHOOT "
db "NOCTOWL "
db "LEDYBA "
db "LEDIAN "
db "SPINARAK "
db "ARIADOS "
db "CROBAT "
db "CHINCHOU "
db "LANTURN "
db "PICHU "
db "CLEFFA "
db "IGGLYBUFF "
db "TOGEPI "
db "TOGETIC "
db "NATU "
db "XATU "
db "MAREEP "
db "FLAAFFY "
db "AMPHAROS "
db "BELLOSSOM "
db "MARILL "
db "AZUMARILL "
db "SUDOWOODO "
db "POLITOED "
db "HOPPIP "
db "SKIPLOOM "
db "JUMPLUFF "
db "AIPOM "
db "SUNKERN "
db "SUNFLORA "
db "YANMA "
db "WOOPER "
db "QUAGSIRE "
db "ESPEON "
db "UMBREON "
db "MURKROW "
db "SLOWKING "
db "MISDREAVUS "
db "UNOWN "
db "WOBBUFFET "
db "GIRAFARIG "
db "PINECO "
db "FORRETRESS "
db "DUNSPARCE "
db "GLIGAR "
db "STEELIX "
db "SNUBBULL "
db "GRANBULL "
db "QWILFISH "
db "SCIZOR "
db "SHUCKLE "
db "HERACROSS "
db "SNEASEL "
db "TEDDIURSA "
db "URSARING "
db "SLUGMA "
db "MAGCARGO "
db "SWINUB "
db "PILOSWINE "
db "CORSOLA "
db "REMORAID "
db "OCTILLERY "
db "DELIBIRD "
db "MANTINE "
db "SKARMORY "
db "HOUNDOUR "
db "HOUNDOOM "
db "KINGDRA "
db "PHANPY "
db "DONPHAN "
db "PORYGON2 "
db "STANTLER "
db "SMEARGLE "
db "TYROGUE "
db "HITMONTOP "
db "SMOOCHUM "
db "ELEKID "
db "MAGBY "
db "MILTANK "
db "BLISSEY "
db "RAIKOU "
db "ENTEI "
db "SUICUNE "
db "LARVITAR "
db "PUPITAR "
db "TYRANITAR "
db "LUGIA "
db "HO-OH "
db "CELEBI "
db "TREECKO "
db "GROVYLE "
db "SCEPTILE "
db "TORCHIC "
db "COMBUSKEN "
db "BLAZIKEN "
db "MUDKIP "
db "MARSHTOMP "
db "SWAMPERT "
db "POOCHYENA "
db "MIGHTYENA "
db "ZIGZAGOON "
db "LINOONE "
db "WURMPLE "
db "SILCOON "
db "BEAUTIFLY "
db "CASCOON "
db "DUSTOX "
db "LOTAD "
db "LOMBRE "
db "LUDICOLO "
db "SEEDOT "
db "NUZLEAF "
db "SHIFTRY "
db "TAILLOW "
db "SWELLOW "
db "WINGULL "
db "PELIPPER "
db "RALTS "
db "KIRLIA "
db "GARDEVOIR "
db "SURSKIT "
db "MASQUERAIN "
db "SHROOMISH "
db "BRELOOM "
db "SLAKOTH "
db "VIGOROTH "
db "SLAKING "
db "NINCADA "
db "NINJASK "
db "SHEDINJA "
db "WHISMUR "
db "LOUDRED "
db "EXPLOUD "
db "MAKUHITA "
db "HARIYAMA "
db "AZURILL "
db "NOSEPASS "
db "SKITTY "
db "DELCATTY "
db "SABLEYE "
db "MAWILE "
db "ARON "
db "LAIRON "
db "AGGRON "
db "MEDITITE "
db "MEDICHAM "
db "ELECTRIKE "
db "MANECTRIC "
db "PLUSLE "
db "MINUN "
db "VOLBEAT "
db "ILLUMISE "
db "ROSELIA "
db "GULPIN "
db "SWALOT "
db "CARVANHA "
db "SHARPEDO "
db "WAILMER "
db "WAILORD "
db "NUMEL "
db "CAMERUPT "
db "TORKOAL "
db "SPOINK "
db "GRUMPIG "
db "SPINDA "
db "TRAPINCH "
db "VIBRAVA "
db "FLYGON "
db "CACNEA "
db "CACTURNE "
db "SWABLU "
db "ALTARIA "
db "ZANGOOSE "
db "SEVIPER "
db "LUNATONE "
db "SOLROCK "
db "BARBOACH "
db "WHISCASH "
db "CORPHISH "
db "CRAWDAUNT "
db "BALTOY "
db "CLAYDOL "
db "LILEEP "
db "CRADILY "
db "ANORITH "
db "ARMALDO "
db "FEEBAS "
db "MILOTIC "
db "CASTFORM "
db "KECLEON "
db "SHUPPET "
db "BANETTE "
db "DUSKULL "
db "DUSCLOPS "
db "TROPIUS "
db "CHIMECHO "
db "ABSOL "
db "WYNAUT "
db "SNORUNT "
db "GLALIE "
db "SPHEAL "
db "SEALEO "
db "WALREIN "
db "CLAMPERL "
db "HUNTAIL "
db "GOREBYSS "
db "RELICANTH "
db "LUVDISC "
db "BAGON "
db "SHELGON "
db "SALAMENCE "
db "BELDUM "
db "METANG "
db "METAGROSS "
db "REGIROCK "
db "REGICE "
db "REGISTEEL "
db "LATIAS "
db "LATIOS "
db "KYOGRE "
db "GROUDON "
db "RAYQUAZA "
db "JIRACHI "
db "DEOXYS "
db "TURTWIG "
db "GROTLE "
db "TORTERRA "
db "CHIMCHAR "
db "MONFERNO "
db "INFERNAPE "
db "PIPLUP "
db "PRINPLUP "
db "EMPOLEON "
db "STARLY "
db "STARAVIA "
db "STARAPTOR "
db "BIDOOF "
db "BIBAREL "
db "KRICKETOT "
db "KRICKETUNE "
db "SHINX "
db "LUXIO "
db "LUXRAY "
db "BUDEW "
db "ROSERADE "
db "CRANIDOS "
db "RAMPARDOS "
db "SHIELDON "
db "BASTIODON "
db "BURMY "
db "WORMADAM "
db "MOTHIM "
db "COMBEE "
db "VESPIQUEN "
db "PACHIRISU "
db "BUIZEL "
db "FLOATZEL "
db "CHERUBI "
db "CHERRIM "
db "SHELLOS "
db "GASTRODON "
db "AMBIPOM "
db "DRIFLOON "
db "DRIFBLIM "
db "BUNEARY "
db "LOPUNNY "
db "MISMAGIUS "
db "HONCHKROW "
db "GLAMEOW "
db "PURUGLY "
db "CHINGLING "
db "STUNKY "
db "SKUNTANK "
db "BRONZOR "
db "BRONZONG "
db "BONSLY "
db "MIME JR. "
db "HAPPINY "
db "CHATOT "
db "SPIRITOMB "
db "GIBLE "
db "GABITE "
db "GARCHOMP "
db "MUNCHLAX "
db "RIOLU "
db "LUCARIO "
db "HIPPOPOTAS "
db "HIPPOWDON "
db "SKORUPI "
db "DRAPION "
db "CROAGUNK "
db "TOXICROAK "
db "CARNIVINE "
db "FINNEON "
db "LUMINEON "
db "MANTYKE "
db "SNOVER "
db "ABOMASNOW "
db "WEAVILE "
db "MAGNEZONE "
db "LICKILICKY "
db "RHYPERIOR "
db "TANGROWTH "
db "ELECTIVIRE "
db "MAGMORTAR "
db "TOGEKISS "
db "YANMEGA "
db "LEAFEON "
db "GLACEON "
db "GLISCOR "
db "MAMOSWINE "
db "PORYGON-Z "
db "GALLADE "
db "PROBOPASS "
db "DUSKNOIR "
db "FROSLASS "
db "ROTOM "
db "UXIE "
db "MESPRIT "
db "AZELF "
db "DIALGA "
db "PALKIA "
db "HEATRAN "
db "REGIGIGAS "
db "GIRATINA "
db "CRESSELIA "
db "PHIONE "
db "MANAPHY "
db "DARKRAI "
db "SHAYMIN "
db "ARCEUS "
db "VICTINI "
db "SNIVY "
db "SERVINE "
db "SERPERIOR "
db "TEPIG "
db "PIGNITE "
db "EMBOAR "
db "OSHAWOTT "
db "DEWOTT "
db "SAMUROTT "
db "PATRAT "
db "WATCHOG "
db "LILLIPUP "
db "HERDIER "
db "STOUTLAND "
db "PURRLOIN "
db "LIEPARD "
db "PANSAGE "
db "SIMISAGE "
db "PANSEAR "
db "SIMISEAR "
db "PANPOUR "
db "SIMIPOUR "
db "MUNNA "
db "MUSHARNA "
db "PIDOVE "
db "TRANQUILL "
db "UNFEZANT "
db "BLITZLE "
db "ZEBSTRIKA "
db "ROGGENROLA "
db "BOLDORE "
db "GIGALITH "
db "WOOBAT "
db "SWOOBAT "
db "DRILBUR "
db "EXCADRILL "
db "AUDINO "
db "TIMBURR "
db "GURDURR "
db "CONKELDURR "
db "TYMPOLE "
db "PALPITOAD "
db "SEISMITOAD "
db "THROH "
db "SAWK "
db "SEWADDLE "
db "SWADLOON "
db "LEAVANNY "
db "VENIPEDE "
db "WHIRLIPEDE "
db "SCOLIPEDE "
db "COTTONEE "
db "WHIMSICOTT "
db "PETILIL "
db "LILLIGANT "
db "BASCULIN "
db "SANDILE "
db "KROKOROK "
db "KROOKODILE "
db "DARUMAKA "
db "DARMANITAN "
db "MARACTUS "
db "DWEBBLE "
db "CRUSTLE "
db "SCRAGGY "
db "SCRAFTY "
db "SIGILYPH "
db "YAMASK "
db "COFAGRIGUS "
db "TIRTOUGA "
db "CARRACOSTA "
db "ARCHEN "
db "ARCHEOPS "
db "TRUBBISH "
db "GARBODOR "
db "ZORUA "
db "ZOROARK "
db "MINCCINO "
db "CINCCINO "
db "GOTHITA "
db "GOTHORITA "
db "GOTHITELLE "
db "SOLOSIS "
db "DUOSION "
db "REUNICLUS "
db "DUCKLETT "
db "SWANNA "
db "VANILLITE "
db "VANILLISH "
db "VANILLUXE "
db "DEERLING "
db "SAWSBUCK "
db "EMOLGA "
db "KARRABLAST "
db "ESCAVALIER "
db "FOONGUS "
db "AMOONGUSS "
db "FRILLISH "
db "JELLICENT "
db "ALOMOMOLA "
db "JOLTIK "
db "GALVANTULA "
db "FERROSEED "
db "FERROTHORN "
db "KLINK "
db "KLANG "
db "KLINKLANG "
db "TYNAMO "
db "EELEKTRIK "
db "EELEKTROSS "
db "ELGYEM "
db "BEHEEYEM "
db "LITWICK "
db "LAMPENT "
db "CHANDELURE "
db "AXEW "
db "FRAXURE "
db "HAXORUS "
db "CUBCHOO "
db "BEARTIC "
db "CRYOGONAL "
db "SHELMET "
db "ACCELGOR "
db "STUNFISK "
db "MIENFOO "
db "MIENSHAO "
db "DRUDDIGON "
db "GOLETT "
db "GOLURK "
db "PAWNIARD "
db "BISHARP "
db "BOUFFALANT "
db "RUFFLET "
db "BRAVIARY "
db "VULLABY "
db "MANDIBUZZ "
db "HEATMOR "
db "DURANT "
db "DEINO "
db "ZWEILOUS "
db "HYDREIGON "
db "LARVESTA "
db "VOLCARONA "
db "COBALION "
db "TERRAKION "
db "VIRIZION "
db "TORNADUS "
db "THUNDURUS "
db "RESHIRAM "
db "ZEKROM "
db "LANDORUS "
db "KYUREM "
db "KELDEO "
db "MELOETTA "
db "GENESECT "
db "CHESPIN "
db "QUILLADIN "
db "CHESNAUGHT "
db "FENNEKIN "
db "BRAIXEN "
db "DELPHOX "
db "FROAKIE "
db "FROGADIER "
db "GRENINJA "
db "BUNNELBY "
db "DIGGERSBY "
db "FLETCHLING "
db "FLETCHINDER "
db "TALONFLAME "
db "SCATTERBUG "
db "SPEWPA "
db "VIVILLON "
db "LITLEO "
db "PYROAR "
db "FLABEBE "
db "FLOETTE "
db "FLORGES "
db "SKIDDO "
db "GOGOAT "
db "PANCHAM "
db "PANGORO "
db "FURFROU "
db "ESPURR "
db "MEOWSTIC "
db "HONEDGE "
db "DOUBLADE "
db "AEGISLASH "
db "SPRITZEE "
db "AROMATISSE "
db "SWIRLIX "
db "SLURPUFF "
db "INKAY "
db "MALAMAR "
db "BINACLE "
db "BARBARACLE "
db "SKRELP "
db "DRAGALGE "
db "CLAUNCHER "
db "CLAWITZER "
db "HELIOPTILE "
db "HELIOLISK "
db "TYRUNT "
db "TYRANTRUM "
db "AMAURA "
db "AURORUS "
db "SYLVEON "
db "HAWLUCHA "
db "DEDENNE "
db "CARBINK "
db "GOOMY "
db "SLIGGOO "
db "GOODRA "
db "KLEFKI "
db "PHANTUMP "
db "TREVENANT "
db "PUMPKABOO "
db "GOURGEIST "
db "BERGMITE "
db "AVALUGG "
db "NOIBAT "
db "NOIVERN "
db "XERNEAS "
db "YVELTAL "
db "ZYGARDE "
db "DIANCIE "
db "HOOPA "
db "VOLCANION "
db "ROWLET "
db "DARTRIX "
db "DECIDUEYE "
db "LITTEN "
db "TORRACAT "
db "INCINEROAR "
db "POPPLIO "
db "BRIONNE "
db "PRIMARINA "
db "PIKIPEK "
db "TRUMBEAK "
db "TOUCANNON "
db "YUNGOOS "
db "GUMSHOOS "
db "GRUBBIN "
db "CHARJABUG "
db "VIKAVOLT "
db "CRABRAWLER "
db "CRABOMINABLE"
db "ORICORIO "
db "CUTIEFLY "
db "RIBOMBEE "
db "ROCKRUFF "
db "LYCANROC "
db "WISHIWASHI "
db "MAREANIE "
db "TOXAPEX "
db "MUDBRAY "
db "MUDSDALE "
db "DEWPIDER "
db "ARAQUANID "
db "FOMANTIS "
db "LURANTIS "
db "MORELULL "
db "SHIINOTIC "
db "SALANDIT "
db "SALAZZLE "
db "STUFFUL "
db "BEWEAR "
db "BOUNSWEET "
db "STEENEE "
db "TSAREENA "
db "COMFEY "
db "ORANGURU "
db "PASSIMIAN "
db "WIMPOD "
db "GOLISOPOD "
db "SANDYGAST "
db "PALOSSAND "
db "PYUKUMUKU "
db "TYPE: NULL "
db "SILVALLY "
db "MINIOR "
db "KOMALA "
db "TURTONATOR "
db "TOGEDEMARU "
db "MIMIKYU "
db "BRUXISH "
db "DRAMPA "
db "DHELMISE "
db "JANGMO-O "
db "HAKAMO-O "
db "KOMMO-O "
db "TAPU KOKO "
db "TAPU LELE "
db "TAPU BULU "
db "TAPU FINI "
db "COSMOG "
db "COSMOEM "
db "SOLGALEO "
db "LUNALA "
db "NIHILEGO "
db "BUZZWOLE "
db "PHEROMOSA "
db "XURKITREE "
db "CELESTEELA "
db "KARTANA "
db "GUZZLORD "
db "NECROZMA "
db "MAGEARNA "
db "MARSHADOW "
db "POIPOLE "
db "NAGANADEL "
db "STAKATAKA "
db "BLACEPHALON "
db "ZERAORA "
db "MELTAN "
db "MELMETAL "
db "GROOKEY "
db "THWACKEY "
db "RILLABOOM "
db "SCORBUNNY "
db "RABOOT "
db "CINDERACE "
db "SOBBLE "
db "DRIZZILE "
db "INTELEON "
db "SKWOVET "
db "GREEDENT "
db "ROOKIDEE "
db "CORVISQUIRE "
db "CORVIKNIGHT "
db "BLIPBUG "
db "DOTTLER "
db "ORBEETLE "
db "NICKIT "
db "THIEVUL "
db "GOSSIFLEUR "
db "ELDEGOSS "
db "WOOLOO "
db "DUBWOOL "
db "CHEWTLE "
db "DREDNAW "
db "YAMPER "
db "BOLTUND "
db "ROLYCOLY "
db "CARKOL "
db "COALOSSAL "
db "APPLIN "
db "FLAPPLE "
db "APPLETUN "
db "SILICOBRA "
db "SANDACONDA "
db "CRAMORANT "
db "ARROKUDA "
db "BARRASKEWDA "
db "TOXEL "
db "TOXTRICITY "
db "SIZZLIPEDE "
db "CENTISKORCH "
db "CLOBBOPUS "
db "GRAPPLOCT "
db "SINISTEA "
db "POLTEAGEIST "
db "HATENNA "
db "HATTREM "
db "HATTERENE "
db "IMPIDIMP "
db "MORGREM "
db "GRIMMSNARL "
db "OBSTAGOON "
db "PERRSERKER "
db "CURSOLA "
db "SIRFETCH’D "
db "MR. RIME "
db "RUNERIGUS "
db "MILCERY "
db "ALCREMIE "
db "FALINKS "
db "PINCURCHIN "
db "SNOM "
db "FROSMOTH "
db "STONJOURNER "
db "EISCUE "
db "INDEEDEE "
db "MORPEKO "
db "CUFANT "
db "COPPERAJAH "
db "DRACOZOLT "
db "ARCTOZOLT "
db "DRACOVISH "
db "ARCTOVISH "
db "DURALUDON "
db "DREEPY "
db "DRAKLOAK "
db "DRAGAPULT "
db "ZACIAN "
db "ZAMAZENTA "
db "ETERNATUS "
db "KUBFU "
db "URSHIFU "
db "ZARUDE "
db "REGIELEKI "
db "REGIDRAGO "
db "GLASTRIER "
db "SPECTRIER "
db "CALYREX "
|
/* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Copyright (C) Flamewing 2011-2016 <flamewing.sonic@gmail.com>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIB_BIGENDIAN_IO_HH
#define LIB_BIGENDIAN_IO_HH
#include <boost/mpl/has_xxx.hpp>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iterator>
#include <memory>
#include <string>
#include <type_traits>
#ifdef _MSC_VER
# include <stdlib.h>
# pragma intrinsic(_byteswap_ushort)
# pragma intrinsic(_byteswap_ulong)
# pragma intrinsic(_byteswap_uint64)
#endif
namespace detail {
// Meta-programming stuff.
// Negation (ported from C++17).
template <typename B>
struct negation : std::integral_constant<bool, !bool(B::value)> {};
// Conjunction (ported from C++17).
template <typename...>
struct conjunction : std::true_type {};
template <typename B1>
struct conjunction<B1> : B1 {};
template <typename B1, typename... Bn>
struct conjunction<B1, Bn...>
: std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
// Disjunction (ported from C++17).
template <typename...>
struct disjunction : std::false_type {};
template <typename B1>
struct disjunction<B1> : B1 {};
template <typename B1, typename... Bn>
struct disjunction<B1, Bn...>
: std::conditional_t<bool(B1::value), B1, disjunction<Bn...>> {};
template <typename Value, typename...>
struct is_any_of : std::false_type {};
template <typename Value, typename B1, typename... Bn>
struct is_any_of<Value, B1, Bn...>
: boost::mpl::bool_<
std::is_same<Value, B1>::value
|| is_any_of<Value, Bn...>::value> {};
template <typename Cont>
struct has_push_back : boost::mpl::bool_<std::is_same<
decltype(std::declval<Cont>().push_back(
typename Cont::value_type{})),
void>::value> {};
template <typename Cont>
struct has_size : boost::mpl::bool_<std::is_same<
decltype(std::declval<Cont>().size()),
typename Cont::size_type>::value> {};
template <typename Cont>
struct has_resize : boost::mpl::bool_<std::is_same<
decltype(std::declval<Cont>().resize(
typename Cont::size_type{})),
void>::value> {};
template <typename Cont>
struct has_data : boost::mpl::bool_<is_any_of<
decltype(std::declval<Cont>().data()),
typename Cont::pointer,
typename Cont::const_pointer>::value> {};
#ifdef __GNUG__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) // NOLINT
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator) // NOLINT
BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type) // NOLINT
BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) // NOLINT
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) // NOLINT
#ifdef __GNUG__
# pragma GCC diagnostic pop
#endif
template <typename Cont>
struct get_iterator_tag {
using type = typename Cont::iterator::iterator_category;
};
template <typename Cont>
using get_iterator_tag_t = typename get_iterator_tag<Cont>::type;
template <typename Iter>
struct get_iterator_traits {
using type = typename std::iterator_traits<Iter>;
};
template <typename Iter>
using get_iterator_traits_t = typename get_iterator_traits<Iter>::type;
template <typename Cont, typename Tag>
struct has_iterator_tag
: boost::mpl::bool_<
std::is_same<get_iterator_tag_t<Cont>, Tag>::value> {};
template <typename Ptr>
struct is_byte_pointer
: boost::mpl::bool_<conjunction<
std::is_pointer<Ptr>,
is_any_of<
typename std::iterator_traits<Ptr>::value_type,
char, unsigned char, signed char>>::value> {};
template <typename T>
struct is_void_pointer
: boost::mpl::bool_<conjunction<
std::is_pointer<T>,
std::is_same<
std::remove_cv_t<typename std::pointer_traits<
T>::element_type>,
void>>::value> {};
template <typename T>
struct is_pointer_like
: boost::mpl::bool_<conjunction<
negation<is_void_pointer<T>>,
has_iterator_category<get_iterator_traits_t<T>>>::value> {
};
template <typename T>
struct is_contiguous_container
: boost::mpl::bool_<conjunction<
std::is_class<T>, has_value_type<T>, has_iterator<T>,
has_size_type<T>, has_reference<T>, has_push_back<T>,
has_size<T>, has_resize<T>, has_data<T>,
has_iterator_tag<T, std::random_access_iterator_tag>>::
value> {};
template <typename T>
struct is_contiguous_container<T&> : is_contiguous_container<T> {};
template <typename T>
struct tag {
using type = T;
};
// base case: just fail
template <size_t Size, typename...>
struct select_unsigned;
// recursive case: check using numeric_limits
template <size_t Size, typename T, typename... Ts>
struct select_unsigned<Size, T, Ts...>
: std::conditional_t<
Size == sizeof(T), tag<T>, select_unsigned<Size, Ts...>> {
};
template <uint64_t Size>
using select_unsigned_t = typename select_unsigned<
Size, uint8_t, uint16_t, uint32_t, uint64_t>::type;
#ifdef __GNUG__
# define PURE __attribute__((const))
# define CONSTEXPR constexpr
#else
# define PURE
# define CONSTEXPR
#endif
CONSTEXPR PURE inline uint8_t bswap(uint8_t val) noexcept {
return val;
}
CONSTEXPR PURE inline uint16_t bswap(uint16_t val) noexcept {
#ifdef __GNUG__
return __builtin_bswap16(val);
#elif defined(_MSC_VER)
return _byteswap_ushort(val);
#else
return ((val & 0xffu) << 8) | ((val >> 8) & 0xffu);
#endif
}
CONSTEXPR PURE inline uint32_t bswap(uint32_t val) noexcept {
#ifdef __GNUG__
return __builtin_bswap32(val);
#elif defined(_MSC_VER)
return _byteswap_ulong(val);
#else
val = ((val & 0xffffu) << 16) | ((val >> 16) & 0xffffu);
return ((val & 0xff00ffu) << 8) | ((val >> 8) & 0xff00ffu);
#endif
}
CONSTEXPR PURE inline uint64_t bswap(uint64_t val) noexcept {
#ifdef __GNUG__
return __builtin_bswap64(val);
#elif defined(_MSC_VER)
return _byteswap_uint64(val);
#else
val = ((val & 0xffffffffull) << 32) | ((val >> 32) & 0xffffffffull);
val = ((val & 0xffff0000ffffull) << 16)
| ((val >> 16) & 0xffff0000ffffull);
return ((val & 0xff00ff00ff00ffull) << 8)
| ((val >> 8) & 0xff00ff00ff00ffull);
#endif
}
struct SourceEndian {
private:
// Both ReadBase versions generate optimal code in GCC and clang.
// I am splitting these cases because MSVC compiler does not understand
// memmove (which is called my std::copy which is called by
// std::copy_n).
template <typename Ptr, typename T>
static inline auto ReadBase(Ptr& in, T& val) noexcept
-> std::enable_if_t<detail::is_byte_pointer<Ptr>::value, void> {
std::memcpy(&val, in, sizeof(T));
}
template <typename Iter, typename T>
static inline auto ReadBase(Iter& in, T& val) noexcept
-> std::enable_if_t<!std::is_pointer<Iter>::value, void> {
char buffer[sizeof(T)];
std::copy_n(in, sizeof(T), buffer);
std::memcpy(&val, buffer, sizeof(T));
}
template <typename Iter, typename T>
static inline void ReadInternal(
Iter& in, T& val, std::forward_iterator_tag) noexcept {
ReadBase(in, val);
std::advance(in, sizeof(T));
}
template <typename Iter, typename T>
static inline void ReadInternal(
Iter& in, T& val, std::input_iterator_tag) noexcept {
ReadBase(in, val);
}
// Both ReadBase versions generate optimal code in GCC and clang.
// I am splitting these cases because MSVC compiler does not understand
// memmove.
template <typename Ptr, typename T>
static inline auto WriteBase(Ptr& out, T val) noexcept
-> std::enable_if_t<detail::is_byte_pointer<Ptr>::value, void> {
std::memcpy(out, &val, sizeof(T));
}
template <typename Iter, typename T>
static inline auto WriteBase(Iter& out, T val) noexcept
-> std::enable_if_t<!std::is_pointer<Iter>::value, void> {
char buffer[sizeof(T)];
std::memcpy(buffer, &val, sizeof(T));
std::copy_n(buffer, sizeof(T), out);
}
template <typename Ptr, typename T>
static inline void WriteInternal(
Ptr& out, T val, std::forward_iterator_tag) noexcept {
WriteBase(out, val);
std::advance(out, sizeof(T));
}
template <typename Iter, typename T>
static inline void WriteInternal(
Iter& out, T val, std::output_iterator_tag) noexcept {
WriteBase(out, val);
}
public:
template <typename T>
static inline void Read(std::istream& in, T& val) noexcept {
char buffer[sizeof(T)];
in.read(buffer, sizeof(T));
std::memcpy(&val, buffer, sizeof(T));
}
template <typename T>
static inline void Read(std::streambuf& in, T& val) noexcept {
char buffer[sizeof(T)];
in.sgetn(buffer, sizeof(T));
std::memcpy(&val, buffer, sizeof(T));
}
template <typename Iter, typename T>
static inline auto Read(Iter& in, T& val) noexcept -> std::enable_if_t<
detail::is_pointer_like<Iter>::value, void> {
ReadInternal(
in, val,
typename std::iterator_traits<Iter>::iterator_category());
}
template <typename T>
static inline void Write(std::ostream& out, T val) noexcept {
char buffer[sizeof(T)];
std::memcpy(buffer, &val, sizeof(T));
out.write(buffer, sizeof(T));
}
template <typename T>
static inline void Write(std::streambuf& out, T val) noexcept {
char buffer[sizeof(T)];
std::memcpy(buffer, &val, sizeof(T));
out.sputn(buffer, sizeof(T));
}
template <typename Cont, typename T>
static inline auto Write(Cont& out, T val) noexcept -> std::enable_if_t<
detail::is_contiguous_container<Cont>::value, void> {
auto sz = out.size();
out.resize(sz + sizeof(T));
std::memcpy(&out[sz], &val, sizeof(T));
}
template <typename Iter, typename T>
static inline auto Write(Iter& out, T val) noexcept -> std::enable_if_t<
detail::is_pointer_like<Iter>::value, void> {
WriteInternal(
out, val,
typename std::iterator_traits<Iter>::iterator_category());
}
};
struct ReverseEndian {
template <typename Src, typename T>
static inline void Read(Src& in, T& val) noexcept {
SourceEndian::Read(in, val);
val = detail::bswap(val);
}
template <typename Dst, typename T>
static inline void Write(Dst& out, T val) noexcept {
SourceEndian::Write(out, detail::bswap(val));
}
};
template <typename Base>
struct EndianBase {
template <typename Src>
static inline uint8_t Read1(Src& in) noexcept {
uint8_t val;
Base::Read(in, val);
return val;
}
template <typename Src>
static inline uint16_t Read2(Src& in) noexcept {
uint16_t val;
Base::Read(in, val);
return val;
}
template <typename Src>
static inline uint32_t Read4(Src& in) noexcept {
uint32_t val;
Base::Read(in, val);
return val;
}
template <typename Src>
static inline uint64_t Read8(Src& in) noexcept {
uint64_t val;
Base::Read(in, val);
return val;
}
template <typename Src, size_t Size>
static inline auto ReadN(Src& in) noexcept
-> detail::select_unsigned_t<Size> {
using uint_t = detail::select_unsigned_t<Size>;
uint_t val;
Base::Read(in, val);
return val;
}
template <typename Src, typename T>
static inline auto Read(Src& in, T& val) noexcept
-> std::enable_if_t<std::is_unsigned<T>::value, void> {
Base::Read(in, val);
}
template <typename Dst>
static inline void Write1(Dst& out, uint8_t val) noexcept {
Base::Write(out, val);
}
template <typename Dst>
static inline void Write2(Dst& out, uint16_t val) noexcept {
Base::Write(out, val);
}
template <typename Dst>
static inline void Write4(Dst& out, uint32_t val) noexcept {
Base::Write(out, val);
}
template <typename Dst>
static inline void Write8(Dst& out, uint64_t val) noexcept {
Base::Write(out, val);
}
template <
typename Dst, size_t Size,
typename Uint_t = detail::select_unsigned_t<Size>>
static inline void WriteN(Dst& out, Uint_t val) noexcept {
Base::Write(out, val);
}
template <typename Dst, typename T>
static inline auto Write(Dst& out, T val) noexcept
-> std::enable_if_t<std::is_unsigned<T>::value, void> {
Base::Write(out, val);
}
};
} // namespace detail
template <typename Src>
inline size_t Read1(Src& in) noexcept {
uint8_t val;
detail::SourceEndian::Read(in, val);
return val;
}
template <typename Dst>
inline void Write1(Dst& out, size_t const val) noexcept {
detail::SourceEndian::Write(out, uint8_t(val));
}
// TODO: Swap these around in big-endian architectures.
using BigEndian = detail::EndianBase<detail::ReverseEndian>;
using LittleEndian = detail::EndianBase<detail::SourceEndian>;
#endif // LIB_BIGENDIAN_IO_HH
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xee32, %rsi
lea addresses_normal_ht+0x1eca3, %rdi
nop
nop
cmp %r11, %r11
mov $7, %rcx
rep movsw
nop
nop
nop
dec %rbx
lea addresses_D_ht+0x16bab, %r9
clflush (%r9)
nop
add %r13, %r13
mov (%r9), %bx
nop
nop
inc %r11
lea addresses_WT_ht+0x11c23, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
and %rbx, %rbx
movb (%rdi), %r9b
nop
nop
nop
nop
nop
cmp $857, %rcx
lea addresses_A_ht+0xa8f3, %rbx
xor %rcx, %rcx
and $0xffffffffffffffc0, %rbx
vmovaps (%rbx), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %r11
nop
nop
nop
nop
cmp $50751, %r11
lea addresses_D_ht+0x35df, %r11
nop
nop
nop
nop
nop
and $8309, %rbx
mov $0x6162636465666768, %r13
movq %r13, %xmm5
movups %xmm5, (%r11)
nop
nop
add %rcx, %rcx
lea addresses_A_ht+0x16e23, %rdi
nop
nop
nop
nop
add %rsi, %rsi
movb (%rdi), %r11b
cmp $43895, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r15
push %rax
push %rdi
push %rdx
push %rsi
// Store
lea addresses_A+0x16313, %rax
nop
sub $41811, %rdx
movb $0x51, (%rax)
cmp $55821, %r11
// Store
lea addresses_UC+0x1de3, %rax
nop
nop
nop
add $57429, %r15
movw $0x5152, (%rax)
nop
nop
nop
sub $56063, %r11
// Store
mov $0xf8b590000000639, %rax
nop
nop
cmp %rdx, %rdx
mov $0x5152535455565758, %rdi
movq %rdi, %xmm1
vmovups %ymm1, (%rax)
nop
nop
nop
nop
and %rsi, %rsi
// Faulty Load
lea addresses_normal+0x1ae23, %r11
nop
nop
nop
nop
inc %r12
mov (%r11), %r15d
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rsi
pop %rdx
pop %rdi
pop %rax
pop %r15
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'34': 2661}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
/*
* Driver.cpp
* - Entry for Testing.
*
* Copyright (c) 2019~2021 numver8638(신진환, Jinhwan Shin)
* Released under the MIT License.
* See the LICENSE file in the project root to get more information.
*/
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp> |
; A276950: Characteristic function for A273670: 1 if there is at least one maximal digit present in the factorial representation of n (A007623), otherwise 0.
; 0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1
add $0,1
mov $2,2
mov $3,$0
mov $4,$0
mov $6,1
lpb $3
mov $5,$4
lpb $5
mov $1,$0
mod $1,$2
lpb $1
div $0,$2
add $0,$6
cmp $1,0
add $2,1
lpe
div $5,2
lpe
mov $1,$0
cmp $1,1
cmp $1,0
sub $3,$1
lpe
mov $0,$1
|
; A168995: Number of reduced words of length n in Coxeter group on 30 generators S_i with relations (S_i)^2 = (S_i S_j)^23 = I.
; 1,30,870,25230,731670,21218430,615334470,17844699630,517496289270,15007392388830,435214379276070,12621216999006030,366015292971174870,10614443496164071230,307818861388758065670,8926746980273983904430
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,29
lpe
mov $0,$2
div $0,29
|
!macro w_inc_08 .mem {
lda .mem ; load low byte
clc ; clear carry
adc #$08 ; add 8
sta .mem ; write back
bcc .cc ; carry clear, done
inc .mem+1 ; otherwise increment high byte
.cc
}
!macro w_mov .mem, .val16 {
lda #<.val16 ; load low byte of value
sta .mem ; store in .mem
lda #>.val16 ; load high byte of value
sta .mem+1 ; store in next address in memory
}
|
// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#include "dated_copy.h"
#include "dirname.h"
#include "basename.h"
#include <ctime>
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>
#if !defined(_WIN32)
#include <unistd.h>
IGL_INLINE bool igl::dated_copy(const std::string & src_path, const std::string & dir)
{
using namespace std;
// Get time and date as string
char buffer[80];
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
// ISO 8601 format with hyphens instead of colons and no timezone offset
strftime (buffer,80,"%Y-%m-%dT%H-%M-%S",timeinfo);
string src_basename = basename(src_path);
string dst_basename = src_basename+"-"+buffer;
string dst_path = dir+"/"+dst_basename;
cerr<<"Saving binary to "<<dst_path;
{
// http://stackoverflow.com/a/10195497/148668
ifstream src(src_path,ios::binary);
if (!src.is_open())
{
cerr<<" failed."<<endl;
return false;
}
ofstream dst(dst_path,ios::binary);
if(!dst.is_open())
{
cerr<<" failed."<<endl;
return false;
}
dst << src.rdbuf();
}
cerr<<" succeeded."<<endl;
cerr<<"Setting permissions of "<<dst_path;
{
int src_posix = fileno(fopen(src_path.c_str(),"r"));
if(src_posix == -1)
{
cerr<<" failed."<<endl;
return false;
}
struct stat fst;
fstat(src_posix,&fst);
int dst_posix = fileno(fopen(dst_path.c_str(),"r"));
if(dst_posix == -1)
{
cerr<<" failed."<<endl;
return false;
}
//update to the same uid/gid
if(fchown(dst_posix,fst.st_uid,fst.st_gid))
{
cerr<<" failed."<<endl;
return false;
}
//update the permissions
if(fchmod(dst_posix,fst.st_mode) == -1)
{
cerr<<" failed."<<endl;
return false;
}
cerr<<" succeeded."<<endl;
}
return true;
}
IGL_INLINE bool igl::dated_copy(const std::string & src_path)
{
return dated_copy(src_path,dirname(src_path));
}
#endif
|
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
namespace webrtc {
namespace rtcp {
// Loss Notification
// -----------------
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |V=2|P| FMT=15 | PT=206 | length |
// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
// 0 | SSRC of packet sender |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// 4 | SSRC of media source |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// 8 | Unique identifier 'L' 'N' 'T' 'F' |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// 12 | Last Decoded Sequence Number | Last Received SeqNum Delta |D|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
LossNotification::LossNotification()
: last_decoded_(0), last_received_(0), decodability_flag_(false) {}
LossNotification::LossNotification(uint16_t last_decoded,
uint16_t last_received,
bool decodability_flag)
: last_decoded_(last_decoded),
last_received_(last_received),
decodability_flag_(decodability_flag) {}
LossNotification::LossNotification(const LossNotification& rhs) = default;
LossNotification::~LossNotification() = default;
size_t LossNotification::BlockLength() const {
return kHeaderLength + kCommonFeedbackLength + kLossNotificationPayloadLength;
}
bool LossNotification::Create(uint8_t* packet,
size_t* index,
size_t max_length,
PacketReadyCallback callback) const {
while (*index + BlockLength() > max_length) {
if (!OnBufferFull(packet, index, callback))
return false;
}
const size_t index_end = *index + BlockLength();
// Note: `index` updated by the function below.
CreateHeader(Psfb::kAfbMessageType, kPacketType, HeaderLength(), packet,
index);
CreateCommonFeedback(packet + *index);
*index += kCommonFeedbackLength;
ByteWriter<uint32_t>::WriteBigEndian(packet + *index, kUniqueIdentifier);
*index += sizeof(uint32_t);
ByteWriter<uint16_t>::WriteBigEndian(packet + *index, last_decoded_);
*index += sizeof(uint16_t);
const uint16_t last_received_delta = last_received_ - last_decoded_;
RTC_DCHECK_LE(last_received_delta, 0x7fff);
const uint16_t last_received_delta_and_decodability =
(last_received_delta << 1) | (decodability_flag_ ? 0x0001 : 0x0000);
ByteWriter<uint16_t>::WriteBigEndian(packet + *index,
last_received_delta_and_decodability);
*index += sizeof(uint16_t);
RTC_DCHECK_EQ(index_end, *index);
return true;
}
bool LossNotification::Parse(const CommonHeader& packet) {
RTC_DCHECK_EQ(packet.type(), kPacketType);
RTC_DCHECK_EQ(packet.fmt(), Psfb::kAfbMessageType);
if (packet.payload_size_bytes() <
kCommonFeedbackLength + kLossNotificationPayloadLength) {
return false;
}
const uint8_t* const payload = packet.payload();
if (ByteReader<uint32_t>::ReadBigEndian(&payload[8]) != kUniqueIdentifier) {
return false;
}
ParseCommonFeedback(payload);
last_decoded_ = ByteReader<uint16_t>::ReadBigEndian(&payload[12]);
const uint16_t last_received_delta_and_decodability =
ByteReader<uint16_t>::ReadBigEndian(&payload[14]);
last_received_ = last_decoded_ + (last_received_delta_and_decodability >> 1);
decodability_flag_ = (last_received_delta_and_decodability & 0x0001);
return true;
}
bool LossNotification::Set(uint16_t last_decoded,
uint16_t last_received,
bool decodability_flag) {
const uint16_t delta = last_received - last_decoded;
if (delta > 0x7fff) {
return false;
}
last_received_ = last_received;
last_decoded_ = last_decoded;
decodability_flag_ = decodability_flag;
return true;
}
} // namespace rtcp
} // namespace webrtc
|
#include "ogpch.h"
#include "OpenGLContext.h"
#include <GLFW/glfw3.h>
#include "glad/glad.h"
namespace Orange {
OpenGLContext::OpenGLContext(GLFWwindow* windowHandle) : m_WindowHandle(windowHandle) {
OG_CORE_ASSERT(windowHandle, "Window handle is null!");
}
void OpenGLContext::Init() {
OG_PROFILE_FUNCTION();
glfwMakeContextCurrent(m_WindowHandle);
int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
OG_CORE_ASSERT(status, "Failed to initialize Glad!");
OG_CORE_INFO("OpenGL Info:");
OG_CORE_INFO(" Vendor: {0}", glGetString(GL_VENDOR));
OG_CORE_INFO(" Renderer: {0}", glGetString(GL_RENDERER));
OG_CORE_INFO(" Version: {0}", glGetString(GL_VERSION));
}
void OpenGLContext::SwapBuffers() {
OG_PROFILE_FUNCTION();
glfwSwapBuffers(m_WindowHandle);
}
}
|
; A025967: Expansion of 1/((1-2x)(1-4x)(1-6x)(1-9x)).
; Submitted by Jon Maiga
; 1,21,289,3321,34705,343257,3282913,30740457,283960369,2599944633,23667405697,214622461833,1941330570193,17530479823449,158125883415841,1425244488222249,12839878208747377,115635005126816505
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16306 ; Expansion of 1/((1-2*x)*(1-6*x)*(1-9*x)).
sub $0,$1
mul $1,5
add $1,$0
lpe
mov $0,$1
|
; A324128: a(n) = 2*n*Fibonacci(n) + (-1)^n + 1.
; 2,2,6,12,26,50,98,182,338,612,1102,1958,3458,6058,10558,18300,31586,54298,93026,158878,270602,459732,779286,1318222,2225666,3751250,6312438,10606572,17797418,29825282,49922402,83468678,139411778,232622148,387796318,645922550,1074985346,1787678458,2970700846,4933186908,8186732402,13577571562,22504800866,37280521582,61723968506,102141285300,168940695078,279294216862,461522589698,762316720802,1258626902502,2077231129548,3426933130298,5651526864338,9316897697378,15354224868950,25295360576306,41659623762468,68589260665966,112893199072838,185761050710402,305577155399242,502539702697246,826241260300092,1358106861788546,2231798423083450,3666681484658018,6022706408522302
mov $2,$0
gcd $2,2
cal $0,45925 ; a(n) = n*Fibonacci(n).
mov $1,$0
add $1,$2
sub $1,2
mul $1,2
add $1,2
|
; A198680: Multiples of 3 whose sum of base-3 digits are also multiples of 3.
; 0,15,21,33,39,45,57,63,78,87,93,99,111,117,132,135,150,156,165,171,186,189,204,210,222,228,234,249,255,261,273,279,294,297,312,318,327,333,348,351,366,372,384,390,396,405,420,426,438,444,450,462,468,483,489,495,510,513,528,534,546,552,558,567,582,588,600,606,612,624,630,645,654,660,666,678,684,699,702,717,723,735,741,747,759,765,780,783,798,804,813,819,834,837,852,858,870,876,882,891,906,912,924,930,936,948,954,969,975,981,996,999,1014,1020,1032,1038,1044,1053,1068,1074,1086,1092,1098,1110,1116,1131,1140,1146,1152,1164,1170,1185,1188,1203,1209,1215,1230,1236,1248,1254,1260,1272,1278,1293,1302,1308,1314,1326,1332,1347,1350,1365,1371,1380,1386,1401,1404,1419,1425,1437,1443,1449,1461,1467,1482,1485,1500,1506,1518,1524,1530,1539,1554,1560,1572,1578,1584,1596,1602,1617,1626,1632,1638,1650,1656,1671,1674,1689,1695,1701,1716,1722,1734,1740,1746,1758,1764,1779,1788,1794,1800,1812,1818,1833,1836,1851,1857,1866,1872,1887,1890,1905,1911,1923,1929,1935,1950,1956,1962,1974,1980,1995,1998,2013,2019,2028,2034,2049,2052,2067,2073,2085,2091,2097,2106,2121,2127,2139,2145,2151,2163,2169,2184,2193,2199,2205,2217,2223,2238,2241
mov $18,$0
mov $20,$0
lpb $20
mov $0,$18
sub $20,1
sub $0,$20
mov $14,$0
mov $16,2
lpb $16
clr $0,14
mov $0,$14
sub $16,1
add $0,$16
sub $0,1
mov $11,$0
lpb $0
add $2,$0
add $2,$0
div $0,3
lpe
lpb $2
mod $2,3
lpe
mov $1,$2
mov $13,$11
mul $13,4
add $1,$13
mov $17,$16
lpb $17
mov $15,$1
sub $17,1
lpe
lpe
lpb $14
mov $14,0
sub $15,$1
lpe
mov $1,$15
sub $1,1
mul $1,3
add $19,$1
lpe
mov $1,$19
|
INCLUDE "config_private.inc"
SECTION code_driver
PUBLIC asm_sd_cs_lower
;Lower the SC130 SD card CS using the GPIO address
;
;input (H)L = SD CS selector of 0 or 1
;uses AF
.asm_sd_cs_lower
in0 a,(CNTR) ;check the CSIO is not enabled
and CNTR_TE|CNTR_RE
jr NZ,asm_sd_cs_lower
ld a,l
and $01 ;isolate SD CS 0 and 1 (to prevent bad input).
inc a ;convert input 0/1 to SD1/2 CS
xor $03 ;invert bits to lower correct I/O bit.
rlca
rlca ;SC130 SD1 CS is on Bit 2 (SC126 SD2 is on Bit 3).
out (__IO_SYSTEM),a
ret
|
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01
; Generated by VC++ for Common Language Runtime
.file "E:\MegaTemp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp"
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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_4vect_dot_prod_avx(len, vec, *g_tbls, **buffs, **dests);
;;;
%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 tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r12 ; must be saved and restored
%define tmp5 r14 ; must be saved and restored
%define tmp6 r15 ; must be saved and restored
%define return rax
%macro SLDR 2
%endmacro
%define SSTR SLDR
%define PS 8
%define LOG_PS 3
%define func(x) x:
%macro FUNC_SAVE 0
push r12
push r13
push r14
push r15
%endmacro
%macro FUNC_RESTORE 0
pop r15
pop r14
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 tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r14 ; must be saved and restored
%define tmp5 rdi ; must be saved and restored
%define tmp6 rsi ; must be saved and restored
%define return rax
%macro SLDR 2
%endmacro
%define SSTR SLDR
%define PS 8
%define LOG_PS 3
%define stack_size 9*16 + 7*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
save_xmm128 xmm6, 0*16
save_xmm128 xmm7, 1*16
save_xmm128 xmm8, 2*16
save_xmm128 xmm9, 3*16
save_xmm128 xmm10, 4*16
save_xmm128 xmm11, 5*16
save_xmm128 xmm12, 6*16
save_xmm128 xmm13, 7*16
save_xmm128 xmm14, 8*16
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
save_reg rdi, 9*16 + 4*8
save_reg rsi, 9*16 + 5*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]
mov rdi, [rsp + 9*16 + 4*8]
mov rsi, [rsp + 9*16 + 5*8]
add rsp, stack_size
%endmacro
%endif
%ifidn __OUTPUT_FORMAT__, elf32
;;;================== High Address;
;;; arg4
;;; arg3
;;; arg2
;;; arg1
;;; arg0
;;; return
;;;<================= esp of caller
;;; ebp
;;;<================= ebp = esp
;;; var0
;;; var1
;;; var2
;;; var3
;;; esi
;;; edi
;;; ebx
;;;<================= esp of callee
;;;
;;;================== Low Address;
%define PS 4
%define LOG_PS 2
%define func(x) x:
%define arg(x) [ebp + PS*2 + PS*x]
%define var(x) [ebp - PS - PS*x]
%define trans ecx
%define trans2 esi
%define arg0 trans ;trans and trans2 are for the variables in stack
%define arg0_m arg(0)
%define arg1 ebx
%define arg2 arg2_m
%define arg2_m arg(2)
%define arg3 trans
%define arg3_m arg(3)
%define arg4 trans
%define arg4_m arg(4)
%define arg5 trans2
%define tmp edx
%define tmp2 edi
%define tmp3 trans2
%define tmp3_m var(0)
%define tmp4 trans2
%define tmp4_m var(1)
%define tmp5 trans2
%define tmp5_m var(2)
%define tmp6 trans2
%define tmp6_m var(3)
%define return eax
%macro SLDR 2 ;stack load/restore
mov %1, %2
%endmacro
%define SSTR SLDR
%macro FUNC_SAVE 0
push ebp
mov ebp, esp
sub esp, PS*4 ;4 local variables
push esi
push edi
push ebx
mov arg1, arg(1)
%endmacro
%macro FUNC_RESTORE 0
pop ebx
pop edi
pop esi
add esp, PS*4 ;4 local variables
pop ebp
%endmacro
%endif ; output formats
%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 dest4 tmp5
%define vskip3 tmp6
%define pos return
%ifidn PS,4 ;32-bit code
%define len_m arg0_m
%define src_m arg3_m
%define dest1_m arg4_m
%define dest2_m tmp3_m
%define dest3_m tmp4_m
%define dest4_m tmp5_m
%define vskip3_m tmp6_m
%endif
%ifndef EC_ALIGNED_ADDR
;;; Use Un-aligned load/store
%define XLDR vmovdqu
%define XSTR vmovdqu
%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
%ifidn PS,8 ; 64-bit code
default rel
[bits 64]
%endif
section .text
%ifidn PS,8 ;64-bit code
%define xmask0f xmm14
%define xgft1_lo xmm13
%define xgft1_hi xmm12
%define xgft2_lo xmm11
%define xgft2_hi xmm10
%define xgft3_lo xmm9
%define xgft3_hi xmm8
%define xgft4_lo xmm7
%define xgft4_hi xmm6
%define x0 xmm0
%define xtmpa xmm1
%define xp1 xmm2
%define xp2 xmm3
%define xp3 xmm4
%define xp4 xmm5
%else
%define xmm_trans xmm7 ;reuse xmask0f and xgft1_lo
%define xmask0f xmm_trans
%define xgft1_lo xmm_trans
%define xgft1_hi xmm6
%define xgft2_lo xgft1_lo
%define xgft2_hi xgft1_hi
%define xgft3_lo xgft1_lo
%define xgft3_hi xgft1_hi
%define xgft4_lo xgft1_lo
%define xgft4_hi xgft1_hi
%define x0 xmm0
%define xtmpa xmm1
%define xp1 xmm2
%define xp2 xmm3
%define xp3 xmm4
%define xp4 xmm5
%endif
align 16
global gf_4vect_dot_prod_avx:function
func(gf_4vect_dot_prod_avx)
FUNC_SAVE
SLDR len, len_m
sub len, 16
SSTR len_m, len
jl .return_fail
xor pos, pos
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
mov vskip3, vec
imul vskip3, 96
SSTR vskip3_m, vskip3
sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS
SLDR dest1, dest1_m
mov dest2, [dest1+PS]
SSTR dest2_m, dest2
mov dest3, [dest1+2*PS]
SSTR dest3_m, dest3
mov dest4, [dest1+3*PS]
SSTR dest4_m, dest4
mov dest1, [dest1]
SSTR dest1_m, dest1
.loop16:
vpxor xp1, xp1
vpxor xp2, xp2
vpxor xp3, xp3
vpxor xp4, xp4
mov tmp, mul_array
xor vec_i, vec_i
.next_vect:
SLDR src, src_m
mov ptr, [src+vec_i]
%ifidn PS,8 ;64-bit code
vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f}
vmovdqu xgft1_hi, [tmp+16] ; " Ax{00}, Ax{10}, ..., Ax{f0}
vmovdqu xgft2_lo, [tmp+vec*(32/PS)] ;Load array Bx{00}, Bx{01}, ..., Bx{0f}
vmovdqu xgft2_hi, [tmp+vec*(32/PS)+16] ; " Bx{00}, Bx{10}, ..., Bx{f0}
vmovdqu xgft3_lo, [tmp+vec*(64/PS)] ;Load array Cx{00}, Cx{01}, ..., Cx{0f}
vmovdqu xgft3_hi, [tmp+vec*(64/PS)+16] ; " Cx{00}, Cx{10}, ..., Cx{f0}
vmovdqu xgft4_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f}
vmovdqu xgft4_hi, [tmp+vskip3+16] ; " Dx{00}, Dx{10}, ..., Dx{f0}
XLDR x0, [ptr+pos] ;Get next source vector
add tmp, 32
add vec_i, PS
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
%else ;32-bit code
XLDR x0, [ptr+pos] ;Get next source vector
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f}
vmovdqu xgft1_hi, [tmp+16] ; " Ax{00}, Ax{10}, ..., Ax{f0}
%endif
vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft1_hi, xgft1_lo ;GF add high and low partials
vpxor xp1, xgft1_hi ;xp1 += partial
%ifidn PS,4 ;32-bit code
vmovdqu xgft2_lo, [tmp+vec*(32/PS)] ;Load array Bx{00}, Bx{01}, ..., Bx{0f}
vmovdqu xgft2_hi, [tmp+vec*(32/PS)+16] ; " Bx{00}, Bx{10}, ..., Bx{f0}
%endif
vpshufb xgft2_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft2_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft2_hi, xgft2_lo ;GF add high and low partials
vpxor xp2, xgft2_hi ;xp2 += partial
%ifidn PS,4 ;32-bit code
sal vec, 1
vmovdqu xgft3_lo, [tmp+vec*(32/PS)] ;Load array Cx{00}, Cx{01}, ..., Cx{0f}
vmovdqu xgft3_hi, [tmp+vec*(32/PS)+16] ; " Cx{00}, Cx{10}, ..., Cx{f0}
sar vec, 1
%endif
vpshufb xgft3_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft3_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft3_hi, xgft3_lo ;GF add high and low partials
vpxor xp3, xgft3_hi ;xp3 += partial
%ifidn PS,4 ;32-bit code
SLDR vskip3, vskip3_m
vmovdqu xgft4_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f}
vmovdqu xgft4_hi, [tmp+vskip3+16] ; " Dx{00}, Dx{10}, ..., Dx{f0}
add tmp, 32
add vec_i, PS
%endif
vpshufb xgft4_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft4_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft4_hi, xgft4_lo ;GF add high and low partials
vpxor xp4, xgft4_hi ;xp4 += partial
cmp vec_i, vec
jl .next_vect
SLDR dest1, dest1_m
SLDR dest2, dest2_m
XSTR [dest1+pos], xp1
XSTR [dest2+pos], xp2
SLDR dest3, dest3_m
XSTR [dest3+pos], xp3
SLDR dest4, dest4_m
XSTR [dest4+pos], xp4
SLDR len, len_m
add pos, 16 ;Loop on 16 bytes at a time
cmp pos, len
jle .loop16
lea tmp, [len + 16]
cmp pos, tmp
je .return_pass
;; Tail len
mov pos, len ;Overlapped offset length-16
jmp .loop16 ;Do one more overlap pass
.return_pass:
mov return, 0
FUNC_RESTORE
ret
.return_fail:
mov return, 1
FUNC_RESTORE
ret
endproc_frame
section .data
align 16
mask0f: ddq 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
%macro slversion 4
global %1_slver_%2%3%4
global %1_slver
%1_slver:
%1_slver_%2%3%4:
dw 0x%4
db 0x%3, 0x%2
%endmacro
;;; func core, ver, snum
slversion gf_4vect_dot_prod_avx, 02, 04, 0193
|
#include <StandAlone/tools/puda/AA_MMS.h>
#include <StandAlone/tools/puda/util.h>
#include <Core/DataArchive/DataArchive.h>
#include <Core/Exceptions/InvalidGrid.h>
#include <iomanip>
#include <fstream>
#include <vector>
using namespace Uintah;
using namespace std;
////////////////////////////////////////////////////////////////////////
// AA_MMS O P T I O N
// Compares the exact solution for the 1D or 3D axis aligned MMS problem with
// the MPM solution. Computes the L-infinity error on the displacement
// at each timestep and reports to the command line.
//
// Reference:
// M. Steffen, P.C. Wallstedt, J.E. Guilkey, R.M. Kirby, and M. Berzins
// "Examination and Analysis of Implementation Choices within the Material Point Method (MPM)
// CMES, vol. 31, no. 2, pp. 107-127, 2008
void
Uintah::AA_MMS( DataArchive * da, CommandLineFlags & clf )
{
vector<string> vars;
vector<int> num_matls;
vector<const Uintah::TypeDescription*> types;
da->queryVariables( vars, num_matls, types );
ASSERTEQ(vars.size(), types.size());
cout << "There are " << vars.size() << " variables:\n";
for(int i=0;i<(int)vars.size();i++)
cout << vars[i] << ": " << types[i]->getName() << endl;
vector<int> index;
vector<double> times;
da->queryTimesteps(index, times);
ASSERTEQ(index.size(), times.size());
cout << "There are " << index.size() << " timesteps:\n";
for( int i = 0; i < (int)index.size(); i++ ) {
cout << index[i] << ": " << times[i] << endl;
}
findTimestep_loopLimits( clf.tslow_set, clf.tsup_set, times, clf.time_step_lower, clf.time_step_upper);
for(unsigned long t=clf.time_step_lower;t<=clf.time_step_upper;t+=clf.time_step_inc){
double time = times[t];
GridP grid = da->queryGrid(t);
//__________________________________
// bulletproofing
IntVector low, high;
grid->getLevel(0)->findInteriorCellIndexRange(low, high);
IntVector cellNum = high-low;
int dir = -9;
int num1D_dirs=0;
for(int d = 0; d <3; d++){
if(cellNum[d] == 1){
num1D_dirs +=1;
}
if(cellNum[d] != 1){
dir = d;
}
}
// Is the grid 1D?
if (clf.do_AA_MMS_1 && num1D_dirs != 2){
ostringstream warn;
warn << "\nERROR: You cannot use the 1D MMS solution on a domain thatis not 1D. "
<< " Number of cells in each direction " <<cellNum << " num1D_dirs " << num1D_dirs <<" \n";
throw InvalidGrid(warn.str(), __FILE__, __LINE__);
}
// Is the grid 3D?
if (clf.do_AA_MMS_2 && num1D_dirs != 0){
ostringstream warn;
warn << "\nERROR: You cannot use the 3D MMS solution on a domain that is not 3D. "
<< " Number of cells in each direction " <<cellNum << " \n";
throw InvalidGrid(warn.str(), __FILE__, __LINE__);
}
//__________________________________
// hard coded constants!!!!
double mu = 3846.;
double bulk = 8333.;
double E = 9.*bulk*mu/(3.*bulk+mu);
double rho0 = 1.0;
double c = sqrt(E/rho0);
// double A0 = 1e-2; // << This is normalized below
int TotalNumParticles = 0;
double max_errorAllLevels = 0.0;
double TotalSumError = 0.0;
Point worstPosAllLevels = Point(-9,-9,-9);
IntVector worstCellAllLevels = IntVector(-9,-9,-9);
int numLevels = grid->numLevels();
vector<double> LinfLevel(numLevels);
vector<double> L2normLevel(numLevels);
vector<Point> worstPosLevel(numLevels);
vector<IntVector> worstCellLevel(numLevels);
vector<int> numParticles(numLevels);
//__________________________________
// Level loop
for(int l=0;l<numLevels;l++){
LevelP level = grid->getLevel(l);
double sumError = 0.0;
double max_error = 0;
numParticles[l] = 0;
Point worstPos = Point(-9,-9,-9);
IntVector worstCell(-9,-9,-9);
// Vector dx = level->dCell(); // you need to normalize the variable A by the
double A = 0.05;
//__________________________________
// Patch loop
for(Level::const_patch_iterator iter = level->patchesBegin();
iter != level->patchesEnd(); iter++){
const Patch* patch = *iter;
int matl = clf.matl;
ParticleVariable<Point> value_pos;
ParticleVariable<Vector> value_disp;
da->query(value_pos, "p.x", matl, patch, t);
da->query(value_disp, "p.displacement",matl, patch, t);
ParticleSubset* pset = value_pos.getParticleSubset();
numParticles[l] += pset->numParticles();
//__________________________________
// Compute the error.
if(pset->numParticles() > 0){ // are there particles on this patch
ParticleSubset::iterator iter = pset->begin();
for(;iter != pset->end(); iter++){
Point refx = value_pos[*iter]-value_disp[*iter];
Vector u_exact(0,0,0);
//__________________________________
// Equation 47 of reference
if (clf.do_AA_MMS_1 ){
double U = A * sin(2 * M_PI * refx(dir)) * cos(M_PI * c * time);
u_exact[dir] = U;
}
//__________________________________
// Equation 51 of reference
if (clf.do_AA_MMS_2 ){
u_exact = A*Vector(sin(M_PI * refx.x()) * sin(c * M_PI*time),
sin(M_PI * refx.y()) * sin( (2./3.) * M_PI + c * M_PI * time),
sin(M_PI * refx.z()) * sin( (4./3.) * M_PI + c * M_PI * time));
}
double error = (u_exact - value_disp[*iter]).length();
cout << refx(dir) << " " << error << endl;
sumError += error*error;
if (error>max_error){
max_error = error;
worstPos = value_pos[*iter];
worstCell = patch->getCellIndex(worstPos);
}
} // particle Loop
} //if
} // for patches
LinfLevel[l] = max_error;
worstPosLevel[l] = worstPos;
worstCellLevel[l] = worstCell;
if(sumError != 0){
L2normLevel[l] = sqrt( sumError/(double)numParticles[l]);
}else{
L2normLevel[l] = 0.0;
}
cout << " Level: " << level->getIndex() << " L_inf Error: " << LinfLevel[l] << ", L2norm: " << L2normLevel[l]
<< " numParticles: " << numParticles[l] << " , Worst particle: " << worstPos << ", " << worstCell << endl;
TotalSumError += sumError;
TotalNumParticles += numParticles[l];
if (max_error > max_errorAllLevels) {
max_errorAllLevels = max_error;
worstPosAllLevels = worstPos;
worstCellAllLevels = worstCell;
}
} // for levels
double L2norm = sqrt( TotalSumError /(double)TotalNumParticles );
cout << "time: " << time << " , L_inf Error: " << max_errorAllLevels << " , L2norm Error: "<< L2norm << " , Worst particle: " << worstPosAllLevels << " " << worstCellAllLevels << endl;
//__________________________________
// write data to the files (L_norms & L_normsPerLevels)
FILE *outFile;
// output level information
outFile = fopen("L_normsPerLevel","w");
fprintf(outFile, "#Time, Level, L_inf, L2norm, NumParticles\n");
for(int l=0;l<numLevels;l++){
fprintf(outFile, "%16.16le, %i, %16.16le, %16.16le %i\n", time, l, LinfLevel[l], L2normLevel[l],numParticles[l]);
}
fclose(outFile);
// overall
outFile = fopen("L_norms","w");
fprintf(outFile, "#Time, L_inf, L2norm\n");
fprintf(outFile, "%16.16le, %16.16le, %16.16le\n", time, max_errorAllLevels, L2norm);
fclose(outFile);
}
} // end AA_MMS()
|
; Copyright 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
;
; The GNU MP Library 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.
;
; The GNU MP Library 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 the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Translation of AT&T syntax code by Brian Gladman
section .text
global ___gmpn_mul_basecase
%ifdef DLL
export ___gmpn_mul_basecase
%endif
align 8
___gmpn_mul_basecase:
mov eax,[8+esp]
mov [8+esp],ebx
pxor mm0,mm0
mov edx,[16+esp]
mov [16+esp],esi
mov ebx,[4+esp]
mov [4+esp],ebp
mov esi,eax
movd mm7,[edx]
mov ecx,[12+esp]
mov ebp,[20+esp]
mov [20+esp],edi
mov edi,ebx
mul1:
movd mm1,[eax]
add eax,4
pmuludq mm1,mm7
paddq mm0,mm1
movd [ebx],mm0
add ebx,4
psrlq mm0,32
sub ecx,1
jnz mul1
movd [ebx],mm0
sub ebp,1
jz done
outer:
mov eax,esi
lea ebx,[4+edi]
add edi,4
movd mm7,[4+edx]
add edx,4
pxor mm0,mm0
mov ecx,[12+esp]
inner:
movd mm1,[eax]
lea eax,[4+eax]
movd mm2,[ebx]
pmuludq mm1,mm7
paddq mm1,mm2
paddq mm0,mm1
sub ecx,1
movd [ebx],mm0
psrlq mm0,32
lea ebx,[4+ebx]
jnz inner
movd [ebx],mm0
sub ebp,1
jnz outer
done:
mov ebx,[8+esp]
mov esi,[16+esp]
mov edi,[20+esp]
mov ebp,[4+esp]
emms
ret
end
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/color_utils.h"
#include <math.h>
#if defined(OS_WIN)
#include <windows.h>
#endif
#include <algorithm>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include "skia/ext/skia_utils_win.h"
#endif
#include "third_party/skia/include/core/SkBitmap.h"
namespace color_utils {
// Helper functions -----------------------------------------------------------
namespace {
int calcHue(double temp1, double temp2, double hue) {
if (hue < 0.0)
++hue;
else if (hue > 1.0)
--hue;
double result = temp1;
if (hue * 6.0 < 1.0)
result = temp1 + (temp2 - temp1) * hue * 6.0;
else if (hue * 2.0 < 1.0)
result = temp2;
else if (hue * 3.0 < 2.0)
result = temp1 + (temp2 - temp1) * (2.0 / 3.0 - hue) * 6.0;
// Scale the result from 0 - 255 and round off the value.
return static_cast<int>(result * 255 + .5);
}
// Next two functions' formulas from:
// http://www.w3.org/TR/WCAG20/#relativeluminancedef
// http://www.w3.org/TR/WCAG20/#contrast-ratiodef
double ConvertSRGB(double eight_bit_component) {
const double component = eight_bit_component / 255.0;
return (component <= 0.03928) ?
(component / 12.92) : pow((component + 0.055) / 1.055, 2.4);
}
SkColor LumaInvertColor(SkColor color) {
HSL hsl;
SkColorToHSL(color, &hsl);
hsl.l = 1.0 - hsl.l;
return HSLToSkColor(hsl, 255);
}
double ContrastRatio(double foreground_luminance, double background_luminance) {
DCHECK_GE(foreground_luminance, 0.0);
DCHECK_GE(background_luminance, 0.0);
foreground_luminance += 0.05;
background_luminance += 0.05;
return (foreground_luminance > background_luminance) ?
(foreground_luminance / background_luminance) :
(background_luminance / foreground_luminance);
}
} // namespace
// ----------------------------------------------------------------------------
unsigned char GetLuminanceForColor(SkColor color) {
return base::saturated_cast<unsigned char>(
(0.3 * SkColorGetR(color)) +
(0.59 * SkColorGetG(color)) +
(0.11 * SkColorGetB(color)));
}
double RelativeLuminance(SkColor color) {
return (0.2126 * ConvertSRGB(SkColorGetR(color))) +
(0.7152 * ConvertSRGB(SkColorGetG(color))) +
(0.0722 * ConvertSRGB(SkColorGetB(color)));
}
void SkColorToHSL(SkColor c, HSL* hsl) {
double r = static_cast<double>(SkColorGetR(c)) / 255.0;
double g = static_cast<double>(SkColorGetG(c)) / 255.0;
double b = static_cast<double>(SkColorGetB(c)) / 255.0;
double vmax = std::max(std::max(r, g), b);
double vmin = std::min(std::min(r, g), b);
double delta = vmax - vmin;
hsl->l = (vmax + vmin) / 2;
if (SkColorGetR(c) == SkColorGetG(c) && SkColorGetR(c) == SkColorGetB(c)) {
hsl->h = hsl->s = 0;
} else {
double dr = (((vmax - r) / 6.0) + (delta / 2.0)) / delta;
double dg = (((vmax - g) / 6.0) + (delta / 2.0)) / delta;
double db = (((vmax - b) / 6.0) + (delta / 2.0)) / delta;
// We need to compare for the max value because comparing vmax to r, g, or b
// can sometimes result in values overflowing registers.
if (r >= g && r >= b)
hsl->h = db - dg;
else if (g >= r && g >= b)
hsl->h = (1.0 / 3.0) + dr - db;
else // (b >= r && b >= g)
hsl->h = (2.0 / 3.0) + dg - dr;
if (hsl->h < 0.0)
++hsl->h;
else if (hsl->h > 1.0)
--hsl->h;
hsl->s = delta / ((hsl->l < 0.5) ? (vmax + vmin) : (2 - vmax - vmin));
}
}
SkColor HSLToSkColor(const HSL& hsl, SkAlpha alpha) {
double hue = hsl.h;
double saturation = hsl.s;
double lightness = hsl.l;
// If there's no color, we don't care about hue and can do everything based on
// brightness.
if (!saturation) {
uint8 light;
if (lightness < 0)
light = 0;
else if (lightness >= 1.0)
light = 255;
else
light = static_cast<uint8>(SkDoubleToFixed(lightness) >> 8);
return SkColorSetARGB(alpha, light, light, light);
}
double temp2 = (lightness < 0.5) ?
(lightness * (1.0 + saturation)) :
(lightness + saturation - (lightness * saturation));
double temp1 = 2.0 * lightness - temp2;
return SkColorSetARGB(alpha,
calcHue(temp1, temp2, hue + 1.0 / 3.0),
calcHue(temp1, temp2, hue),
calcHue(temp1, temp2, hue - 1.0 / 3.0));
}
bool IsWithinHSLRange(const HSL& hsl,
const HSL& lower_bound,
const HSL& upper_bound) {
DCHECK(hsl.h >= 0 && hsl.h <= 1) << hsl.h;
DCHECK(hsl.s >= 0 && hsl.s <= 1) << hsl.s;
DCHECK(hsl.l >= 0 && hsl.l <= 1) << hsl.l;
DCHECK(lower_bound.h < 0 || upper_bound.h < 0 ||
(lower_bound.h <= 1 && upper_bound.h <= lower_bound.h + 1))
<< "lower_bound.h: " << lower_bound.h
<< ", upper_bound.h: " << upper_bound.h;
DCHECK(lower_bound.s < 0 || upper_bound.s < 0 ||
(lower_bound.s <= upper_bound.s && upper_bound.s <= 1))
<< "lower_bound.s: " << lower_bound.s
<< ", upper_bound.s: " << upper_bound.s;
DCHECK(lower_bound.l < 0 || upper_bound.l < 0 ||
(lower_bound.l <= upper_bound.l && upper_bound.l <= 1))
<< "lower_bound.l: " << lower_bound.l
<< ", upper_bound.l: " << upper_bound.l;
// If the upper hue is >1, the given hue bounds wrap around at 1.
bool matches_hue = upper_bound.h > 1
? hsl.h >= lower_bound.h || hsl.h <= upper_bound.h - 1
: hsl.h >= lower_bound.h && hsl.h <= upper_bound.h;
return (upper_bound.h < 0 || lower_bound.h < 0 || matches_hue) &&
(upper_bound.s < 0 || lower_bound.s < 0 ||
(hsl.s >= lower_bound.s && hsl.s <= upper_bound.s)) &&
(upper_bound.l < 0 || lower_bound.l < 0 ||
(hsl.l >= lower_bound.l && hsl.l <= upper_bound.l));
}
void MakeHSLShiftValid(HSL* hsl) {
if (hsl->h < 0 || hsl->h > 1)
hsl->h = -1;
if (hsl->s < 0 || hsl->s > 1)
hsl->s = -1;
if (hsl->l < 0 || hsl->l > 1)
hsl->l = -1;
}
SkColor HSLShift(SkColor color, const HSL& shift) {
HSL hsl;
SkAlpha alpha = SkColorGetA(color);
SkColorToHSL(color, &hsl);
// Replace the hue with the tint's hue.
if (shift.h >= 0)
hsl.h = shift.h;
// Change the saturation.
if (shift.s >= 0) {
if (shift.s <= 0.5)
hsl.s *= shift.s * 2.0;
else
hsl.s += (1.0 - hsl.s) * ((shift.s - 0.5) * 2.0);
}
SkColor result = HSLToSkColor(hsl, alpha);
if (shift.l < 0)
return result;
// Lightness shifts in the style of popular image editors aren't actually
// represented in HSL - the L value does have some effect on saturation.
double r = static_cast<double>(SkColorGetR(result));
double g = static_cast<double>(SkColorGetG(result));
double b = static_cast<double>(SkColorGetB(result));
if (shift.l <= 0.5) {
r *= (shift.l * 2.0);
g *= (shift.l * 2.0);
b *= (shift.l * 2.0);
} else {
r += (255.0 - r) * ((shift.l - 0.5) * 2.0);
g += (255.0 - g) * ((shift.l - 0.5) * 2.0);
b += (255.0 - b) * ((shift.l - 0.5) * 2.0);
}
return SkColorSetARGB(alpha,
static_cast<int>(r),
static_cast<int>(g),
static_cast<int>(b));
}
void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) {
DCHECK_EQ(kN32_SkColorType, bitmap.colorType());
SkAutoLockPixels bitmap_lock(bitmap);
int pixel_width = bitmap.width();
int pixel_height = bitmap.height();
for (int y = 0; y < pixel_height; ++y) {
for (int x = 0; x < pixel_width; ++x)
++histogram[GetLuminanceForColor(bitmap.getColor(x, y))];
}
}
SkColor AlphaBlend(SkColor foreground, SkColor background, SkAlpha alpha) {
if (alpha == 0)
return background;
if (alpha == 255)
return foreground;
int f_alpha = SkColorGetA(foreground);
int b_alpha = SkColorGetA(background);
double normalizer = (f_alpha * alpha + b_alpha * (255 - alpha)) / 255.0;
if (normalizer == 0.0)
return SK_ColorTRANSPARENT;
double f_weight = f_alpha * alpha / normalizer;
double b_weight = b_alpha * (255 - alpha) / normalizer;
double r = (SkColorGetR(foreground) * f_weight +
SkColorGetR(background) * b_weight) / 255.0;
double g = (SkColorGetG(foreground) * f_weight +
SkColorGetG(background) * b_weight) / 255.0;
double b = (SkColorGetB(foreground) * f_weight +
SkColorGetB(background) * b_weight) / 255.0;
return SkColorSetARGB(static_cast<int>(normalizer),
static_cast<int>(r),
static_cast<int>(g),
static_cast<int>(b));
}
SkColor BlendTowardOppositeLuminance(SkColor color, SkAlpha alpha) {
unsigned char background_luminance =
color_utils::GetLuminanceForColor(color);
const SkColor blend_color =
(background_luminance < 128) ? SK_ColorWHITE : SK_ColorBLACK;
return color_utils::AlphaBlend(blend_color, color, alpha);
}
SkColor GetReadableColor(SkColor foreground, SkColor background) {
const SkColor foreground2 = LumaInvertColor(foreground);
const double background_luminance = RelativeLuminance(background);
return (ContrastRatio(RelativeLuminance(foreground), background_luminance) >=
ContrastRatio(RelativeLuminance(foreground2), background_luminance)) ?
foreground : foreground2;
}
SkColor InvertColor(SkColor color) {
return SkColorSetARGB(
SkColorGetA(color),
255 - SkColorGetR(color),
255 - SkColorGetG(color),
255 - SkColorGetB(color));
}
SkColor GetSysSkColor(int which) {
#if defined(OS_WIN)
return skia::COLORREFToSkColor(GetSysColor(which));
#else
NOTIMPLEMENTED();
return SK_ColorLTGRAY;
#endif
}
} // namespace color_utils
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1994. All rights reserved.
GEOWORKS CONFIDENTIAL
PROJECT: Pasta
MODULE: Fax
FILE: group3UI.asm
AUTHOR: Andy Chiu, Oct 10, 1993
ROUTINES:
Name Description
---- -----------
Methods:
FaxInfoVisOpen Sets up the fax printer driver UI.
FaxInfoVisClose Makes sure file that contains info for the
UI is closed.
FaxInfoGetFileHandle Returns the file handle of the fax information
file.
FaxInfoGetFileHandle Returns the file handle of the fax information
file.
FaxInfoGetQuickListHandles
Returns the mem and chunk handle to the
quick numbers list.
FaxInfoGetAddressBookUsed
Gets the information about which address
book is used
FaxInfoSetAddressBookUsed
Set the address book info that is being used.
FaxInfoSaveSenderInfo Save all the sender information fields.
FaxInfoResetSenderInfo Reset all the sender information fields.
FaxInfoUseCoverPage Automatically select "Use Cover Page" option.
Functions:
OpenFaxInfomationFile
Opens the file that contains the quick dial
entries plust the coversheet information.
GetFaxInformationFile
Gets all the info from the fax information file.
Group3GetSenderInfo Update UI objects with sender information.
SetupInitialData Calls the setup routines for the quick number
lists, address book info, and dial assist info.
FileInit Makes sure the the right extended attributes
is set to the fax information file.
Group3GetDialAssistInfo
Gets the dial assist info from the ini file
and puts them in the appropiate UI file.
Group3GetAddrBookInfo Get the address book information from the
fax info file.
InitializeQuickNumbersList
Makes sure that the quick numbers list knows
how many elements it has and put the first
number of the quick numbers list in the
number text.
Group3OptionsTriggerToggleEnabled
Toggles the enabled status of the trigger
when it receives this message.
FaxCallSpoolPrintControl
Send a method to the SpoolPrintControl
object above me in the generic tree
;
; Procedures when we're shutting down the print driver
;
UpdateQuickNumbers Makes sure the quick list is updated if any
items should be added.
CheckIfNameOrNumberInQuickList
Checks if the name or number in the number
or name text object is in the quick number
list.
AddNameOrNumberToQuickList
Adds the number or name/number to the quick
list depending on what the caller wants.
AddElementToQuickList Makes a new element in the quick list so we can
add new information to the quick list.
Will also delete old elements.
MakeChunkFromText This procedure gets the text from a text
object and and copies it to a chunk that
this procedure creates.
Group3WriteDialAssistInfo
Takes the dial assist info and writes it
to the ini file.
SwitchItemsInQuickList Switch the first element and the element
the user chose in the QuickNumberList in
the Chunk Array of phone numbers
DeleteElementInChunkArray
For a chosen element, it deletes the
entry and the chunks that the element points to.
UpdateAddrBookInfo Updates the fax information file so it know's
the address book that the user wants to use
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/10/93 Initial revision
DESCRIPTION:
Code for the ui objects that first appear in the Print Dialog box
$Id: group3UI.asm,v 1.1 97/04/18 11:53:01 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoVisOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Before the fax dialog is sent, we set up some information
in the UI so the user can obtain Quick number information
and cover page information.
CALLED BY: MSG_VIS_OPEN
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
bp - 0 if top window, else window for object to open on
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoVisOpen method dynamic FaxInfoClass,
MSG_VIS_OPEN
;
; Call the super class
;
mov di, offset FaxInfoClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset ; ds:di <- instance data
;
; Make sure the VM file is open so we can get the data we need.
openFile:
call OpenFaxInformationFile ; bx <- file handle
jc handleOpenFileError
call VMGrabExclusive
mov ds:[di].FII_fileHandle, bx
;
; Go to the file and get all the info from the fax file
;
call GetFaxInformationFile
jc deleteFileAndReleaseExclusive
;
; dx:bp <- handle to quick list (block and chunk)
; cx <- # of items in list
; dx:bp handles for chunk array
;
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset ; ds:di <- inst data
mov ds:[di].FII_qHeapHandle, dx
mov ds:[di].FII_qListHandle, bp
;
; Setup the quick list numbers, dial assist info, and address book info
; parameters are:
; cx = number of items in the quick list
; bx = file handle of fax information file
; *ds:si = FaxInfo class
; ds = segment of UI
;
call SetupInitialData
;
; Release the semaphore on the file
;
call VMReleaseExclusive
exit:
;
; Because of something weird with GeoCalc, we have to renable these
; buttons because they were disabled in FaxEvalMainUI.
;
mov ax, MSG_GEN_SET_ENABLED
mov dl, VUM_NOW
call ObjCallInstanceNoLock
ret
;
; ----------------------------
; E R R O R H A N D L E R S
; ----------------------------
;
;
; This examines the error code in al from OpenFaxInformationFile
handleOpenFileError:
cmp al, FIFEC_FILE_CANNOT_BE_CREATED
jz cannotOpenFile
; sanity checking. Only other error is FIFEC_FILE_MUST_BE_DELETED
EC < cmp al, FIFEC_FILE_MUST_BE_DELETED >
EC < ERROR_NZ FAX_INFO_FILE_ERROR_CODE_INVALID >
jmp deleteFile
;
; Else these are the handlers to delete the file and try to open
; the file again.
deleteFileAndReleaseExclusive:
call VMReleaseExclusive
deleteFile:
;
; Destroy the file and tell whoever is calling that the file needs
; to be recreated.
;
push ds ; save segment of UI
call FilePushDir
call PutThreadInFaxDir
segmov ds, cs ; ds:dx <- file name
mov dx, offset faxInformationFileName
call FileDelete ; carry set if error
pop ds
pushf
call FilePopDir
popf
jc cannotOpenFile
jmp openFile
;
; If we couldn't delete the file we will then just have to deal
; with it like the file couildn't be created.
cannotOpenFile:
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset ; ds:di <- inst data
clr bx, ; make null file handle
mov ds:[di].FII_qHeapHandle, bx ; clear out the qlist
mov ds:[di].FII_qListHandle, bx ; handles
mov cx, GROUP3_MIN_QUICK_DIAL_NUMBERS
call SetupInitialData
jmp exit
FaxInfoVisOpen endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OpenFaxInformationFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Opens the information needed by the user to fill out the
cover page and quick dial numbers.
CALLED BY: FaxInfoVisOpen
PASS: es = dgroup
RETURN: bx = VM file handle
carry set if file is invalid
al = error code returned.
DESTROYED: ah
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
OpenFaxInformationFile proc near
uses cx,dx,bp,si,di,ds,es
.enter
EC < call ECCheckDGroupES >
;
; Set the current directory to the fax directroy which is at
; SP_PRIVATE_DATA/FaxDir
;
call PutThreadInFaxDir
LONG jc pathError
;
; Open the file.
;
mov ax, (VMO_CREATE shl 8 ) or \
mask VMAF_FORCE_READ_WRITE or \
mask VMAF_FORCE_SHARED_MULTIPLE
clr cx ; default compression
mov dx, offset faxInformationFileName
segmov ds, cs ; ds:dx <- file name
call VMOpen ; bx <- filehandle
LONG jc openError
;
; Check to see if the file existed. If it did, then we have no
; problem. If it didn't then we must create the format.
;
cmp ax, VM_CREATE_OK
LONG jnz checkAttributes
;
; Make sure extended attributes are set correctly
;
call VMGrabExclusive
mov cx, cs
mov dx, offset faxDefaultsToken
call FileInit
;
; Create the block that will become the map block and contain all
; the initialized data that we will need.
;
mov cx, size FaxInformationFileInfo ; size of block
call VMAlloc ; ax <- VM block handle
EC < call ECVMCheckVMBlockHandle >
call VMSetMapBlock
mov_tr dx, ax ; dx <- VM block handle
mov di, bx ; save file handle
;
; Create an Lmem heap for the chunk array
;
mov ax, LMEM_TYPE_GENERAL
clr cx ; default block header size
call VMAllocLMem ; ax <- block handle
push ax ; save heap handle
;
; Make the chunk array for the phone numbers.
;
call VMLock ; ax <- segment
; bp <- mem handle
mov bx, size QuickNumberChunkHandles
mov ds, ax ; block for the new array
clr cx ; default header size
clr al
clr si
call ChunkArrayCreate ; *ds:si <- array
call VMDirty
call VMUnlock
;
; Save that block handle into the map block so we can find the
; heap later. Also clear out all the other fields.
;
mov ax, dx ; ax <- map block
mov bx, di ; bx <- file handle
EC < call ECVMCheckVMBlockHandle >
call VMLock ; ax <- segment of vm block
; bp <- mem handle
mov ds, ax
pop ds:[FIFI_heapBlock] ; <- heap handle
mov ds:[FIFI_chunkArrayHandle], si
clr al
mov {byte} ds:[FIFI_fromName], al
mov {byte} ds:[FIFI_fromCompany], al
mov {byte} ds:[FIFI_fromVoicePhone], al
mov {byte} ds:[FIFI_fromFaxPhone], al
mov {byte} ds:[FIFI_fromFaxID], al
;
; Write the default address book that should be used.
;
segmov es, ds
if _USE_PALM_ADDR_BOOK
mov di, FIFI_addrBookFileInfo
call CopyDefaultAddressBookFileInfo
endif
if 0
mov cx, FIFI_addrBookFileInfo
mov di, cx
add di, ABFI_name ; es:di <- dest
segmov ds, cs
mov si, offset addressBookFileName
LocalCopyString
mov di, cx
add di, ABFI_path
mov si, offset addressBookPath
LocalCopyString
mov di, cx
mov cl, ADDRESS_BOOK_DISK_HANDLES
mov {byte} es:[di].ABFI_diskHandle, cl
endif
;
; Unlock the this map block
;
call VMDirty
call VMUnlock
call VMReleaseExclusive
exitClear::
clc
done:
.leave
ret
checkAttributes:
mov cx, size ProtocolNumber
sub sp, cx
mov di, sp
segmov es, ss
mov ax, FEA_PROTOCOL
call FileGetHandleExtAttributes ; es:di <- filled
cmp es:[di].PN_major, FILE_MAJOR_PROTOCOL
jne short protocolError
cmp es:[di].PN_minor, FILE_MINOR_PROTOCOL
jne short protocolError
;
; ----------------------------
; E R R O R H A N D L E R S
; ----------------------------
;
;
; This is a clean exit when the file is already made and the protocol
; checks out OK
noError::
add sp, cx ; restore stack
clc
jmp done
;
; This error occurs when the protocols don't check out.
; Close the file and let the calling routine handle it.
protocolError:
add sp, cx ; restore stack
mov al, FILE_NO_ERRORS
call VMClose
mov al, FIFEC_FILE_MUST_BE_DELETED
stc
jmp done
;
; This error occurs when the thread can't go to nor make the fax
; directory
pathError:
mov si, offset CannotGoToFaxDir
mov ax, \
CustomDialogBoxFlags <1,CDT_ERROR,GIT_NOTIFICATION,0>
call DoDialog
mov al, FIFEC_FILE_CANNOT_BE_CREATED
stc
jmp done
;
; This error occurs when the fax information file was not able
; to be found nor made.
openError:
mov si, offset CannotOpenFaxInfoFile
mov ax, \
CustomDialogBoxFlags <1,CDT_ERROR,GIT_NOTIFICATION,0>
call DoDialog
mov al, FIFEC_FILE_CANNOT_BE_CREATED
stc
jmp done
OpenFaxInformationFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FileInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Makes sure extended attributes are set correctly to
the fax file.
CALLED BY: OpenFaxInformationFile
PASS: bx - file handle
cx:dx = GeodeToken
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
fProtocol ProtocolNumber < FILE_MAJOR_PROTOCOL,
FILE_MINOR_PROTOCOL >
fFlags GeosFileHeaderFlags mask GFHF_SHARED_MULTIPLE
FileInit proc near
uses ax, cx, di, es
.enter
sub sp, 3 * size FileExtAttrDesc
mov di, sp
segmov es, ss
mov es:[di][0*FileExtAttrDesc].FEAD_attr, FEA_TOKEN
mov es:[di][0*FileExtAttrDesc].FEAD_value.segment, cx
mov es:[di][0*FileExtAttrDesc].FEAD_value.offset, dx
mov es:[di][0*FileExtAttrDesc].FEAD_size, size GeodeToken
mov es:[di][1*FileExtAttrDesc].FEAD_attr, FEA_PROTOCOL
mov es:[di][1*FileExtAttrDesc].FEAD_value.segment, cs
mov es:[di][1*FileExtAttrDesc].FEAD_value.offset, offset fProtocol
mov es:[di][1*FileExtAttrDesc].FEAD_size, size fProtocol
mov es:[di][2*FileExtAttrDesc].FEAD_attr, FEA_FLAGS
mov es:[di][2*FileExtAttrDesc].FEAD_value.segment, cs
mov es:[di][2*FileExtAttrDesc].FEAD_value.offset, offset fFlags
mov es:[di][2*FileExtAttrDesc].FEAD_size, size fFlags
mov ax, FEA_MULTIPLE
mov cx, 3
call FileSetHandleExtAttributes
add sp, 3 * size FileExtAttrDesc
call VMUpdate
; Since there's no reason for the user to know if the update didn't go
; through, we are not going to handle any error that comes up.
.leave
ret
FileInit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetFaxInformationFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gets all the info from the fax information file.
CALLED BY: FaxInfoVisOpen
PASS: bx = file handle
ds = segment for UI
RETURN: dx:bp = handle to chunk array
cx = number of items in the chunk array
carry set if error
DESTROYED: nothing
SIDE EFFECTS:
Will release semaphore on file if the file has been corrupted.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 11/11/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetFaxInformationFile proc near
uses ax,bx,si,di,es
.enter
;
; Get the map block so we can initialize our data
;
call VMGetMapBlock ; ax <- map block handle
;
; Check to see if the file has been corrupted and there is no
; longer a map block. We will return an error to the calling routine.
;
tst ax
LONG jz error
;
; Lock the block and fill information into the text objects that are
; needed.
;
call VMLock ; ax <- segment
; bp <- mem handle
;
; Fill in the text objects with the sender information.
;
mov es, ax ; es = map block segment
call Group3GetSenderInfo
;
; Remember the local memory heap and and chunk array handles
;
mov ax, es:[FIFI_heapBlock]
mov si, es:[FIFI_chunkArrayHandle]
call VMUnlock
;
; We're going to copy the info into memory because more than one
; dialog might need to make a change to it.
;
; Get *ds:si to be pointing to the chunk array so we can use the
; chunk array routines.
;
EC < call ECVMCheckVMBlockHandle >
call VMLock ; ax <- segment
; bp <- mem handle
push ds ; save seg of ui
mov ds, ax ; *ds:si <- chunk array
;
; Find out the size of the LMemBlock. Allocate a new block
; and copy it to the new block. No error will be handled here
; because if it the system can't handle this allocation, they are
; screwed anyway.
;
push si
mov dx, ds:[LMBH_blockSize] ; size of copied block
mov ax, dx
mov cl, mask HF_SHARABLE or mask HF_SWAPABLE
mov ch, mask HAF_LOCK or mask HAF_NO_ERR
call MemAlloc ; bx - handle of block allocate
; ax - address of block
mov es, ax
clr di
clr si
mov cx, dx ; cx <- size of block
rep movsb
pop si
call MemUnlock ; unlock the allocated block
; bx is still the mem handle of the block
;
; Tell the quick numbers list how many items there should be
;
EC < call ECCheckChunkArray >
call ChunkArrayGetCount ; cx <- number of elements
tst cx
jnz unlockBlock
inc cx ; make sure at least
; 1 item is in the list
unlockBlock:
;
; Unlock the block that has the chunk array
;
call VMDirty
call VMUnlock
;
; dx:bp should be returned as handles for the chunk array.
;
pop ds ; ds <- segment of UI
mov dx, bx
mov bp, si
clc
exit:
.leave
ret
;
; ----------------------------
; E R R O R H A N D L E R S
; ----------------------------
;
;
; The information was not extractable from the file.
error:
stc
jmp exit
GetFaxInformationFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Group3GetSenderInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the sender information from the VM file and place
them into the text objects. Updates FromGlyph.
CALLED BY: FaxInfoResetSenderInfo
GetFaxInformationFile
PASS: es = segment of locked map block
bp = memory handle
bx = file handle of VM file
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
NOTE: Caller is responsible for locking block before
calling this routine and unlocking block after
this routine returns.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/ 8/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Group3GetSenderInfo proc near
uses ax,bx,cx,dx,si,bp
.enter
;
; Filling in the text of the text objects. For some reason
; dx and bp get trashed, so es needs to be preserved.
;
mov bx, 2 * (length FileInformationOffsets - 1)
; bx = offset into data
;
; Now write the information from the VM file to the text objects.
;
fillInTextObjectsLoop:
mov dx, es ; dx = seg of map block
mov bp, cs:FileInformationOffsets[bx]
mov si, cs:UIInformationObjChunks[bx]
clr cx
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjCallInstanceNoLock
dec bx
dec bx
jns fillInTextObjectsLoop
;
; Make sure the sender moniker is updated. Go back into the info file
; and use the info of what the sender's name is.
;
mov dx, es
mov bp, FIFI_fromName
clr cx
mov si, offset CoverPageFromSummaryText
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
mov si, offset CoverPageFromSummaryText
call ObjCallInstanceNoLock
mov ax, MSG_VIS_TEXT_SELECT_START
call ObjCallInstanceNoLock
.leave
ret
Group3GetSenderInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetupInitialData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calls the setup routines for the quick number lists,
address book info, and dial assist info.
CALLED BY: FaxInfoVisOpen
PASS: bx = file handle of fax information file
(bx = 0) if no file opened.
cx = number of items in the quick list.
ds = segment of UI
*ds:si = FaxInfoClass
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 3/22/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetupInitialData proc near
uses di
.enter
;
; Initialize the quick list
;
call InitializeQuickNumbersList
;
; Get the billing card information from the ini file.
;
call Group3GetDialAssistInfo
;
; Get the address book information.
;
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset
call Group3GetAddrBookInfo
.leave
ret
SetupInitialData endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Group3GetDialAssistInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gets the dial assist info from the ini file and puts them
in the appropiate UI file.
CALLED BY: FaxInfoVisOpen
DialAssistResetFields
PASS: ds = segment of UI
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 11/11/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Group3GetDialAssistInfo proc near
tempBuf local FAX_MAX_FIELD_LENGTH dup (char)
uses ax,bx,cx,dx,si,di,es
.enter
push bp
;
; Setup registers for the loop below. These are the registers
; that shouldn't change or need to be initialized.
;
segmov es, ss
lea di, ss:tempBuf ; es:di <- buf to fill
mov bx, 2 * (length FileInitKeyOffsets - 1)
grabAndEnterTextLoop:
push bx ; save counter
push ds ; save segment of UI
mov {byte} es:[di], 0 ; make it a null string
;
; Fill the buffer.
;
mov cx, cs
mov dx, cs:FileInitKeyOffsets[bx] ; cx:dx <- keys
mov ds, cx
mov si, offset fileInitFaxCategory ; ds:si <- category
mov bp, FAX_MAX_FIELD_LENGTH
call InitFileReadString ; cx <- # of bytes
; es:di <- filled
jnc putTextInTextObject
mov {byte} es:[di], 0 ; clr buffer
;
; Put it in the text object.
;
putTextInTextObject:
pop ds ; ds <- seg of UI
pop bx ; bx <- counter
mov dx, es
mov bp, di ; dx:bp <- buffer
mov si, cs:DialAssistTextOffsets[bx]
clr cx
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjCallInstanceNoLock
;
; See if we're done with the loop
;
dec bx
dec bx
jns grabAndEnterTextLoop
pop bp
.leave
ret
Group3GetDialAssistInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Group3GetAddrBookInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the address book information from the fax info file.
CALLED BY: FaxInfoVisOpen
PASS: ds:di = Instance data
bx = file handle to fax info
if bx is 0 then it means a file could not be opened.
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/29/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Group3GetAddrBookInfo proc near
class FaxInfoClass
uses ax,cx,si,di,bp,ds,es
.enter
;
; See if we were able to open the fax information file.
; if we weren't then, we will just use the defaults to make the
; as a temporary value for the address book.
;
tst bx
jnz getFileInfo
;
; es:di will point to the Instance Data of the fax info class
; write the address book info
;
lea di, ds:[di].FII_addrInfo
segmov es, ds
if _USE_PALM_ADDR_BOOK
call CopyDefaultAddressBookFileInfo
endif
jmp exit
;
; Get the map block so we can get information pertaining to
; the addr book
;
getFileInfo:
call VMGetMapBlock ; ax <- map block
call VMLock ; bp <- mem handle
; ax <- segment
lea di, ds:[di].FII_addrInfo
segmov es, ds ; es:di <- dest
mov ds, ax
mov si, FIFI_addrBookFileInfo ; ds:si <- src
if _USE_PALM_ADDR_BOOK
call CopyAddressBookFileInfo
endif
call VMUnlock
exit:
.leave
ret
Group3GetAddrBookInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeQuickNumbersList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Makes sure that the quick numbers list knows how many
elements it has and put the first number of the quick
numbers list in the number text.
CALLED BY: Group3GetFaxInformationFile
PASS: ds = segment of UI
cx = number of items in the chunk array
RETURN: nothing
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/11/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeQuickNumbersList proc near
uses ax, cx, dx, si, bp
.enter
;
; Tell the list how many items it should have
;
mov si, offset Group3UI:Group3QuickNumbersList
mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE
call ObjCallInstanceNoLock
;
; Make the first element of the quick numbers list selected and
;
clr dx
clr cx ; select first number
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
call ObjCallInstanceNoLock
;
; Have the text written in the number text box
;
mov ax, MSG_QUICK_NUMBERS_LIST_SET_CURRENT_SELECTION
clr cx
call ObjCallInstanceNoLock
.leave
ret
InitializeQuickNumbersList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoSetNumPages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Take note of the number of pages in the fax
CALLED BY: FaxInfoInitializeData
PASS: *ds:si - FaxInfoClass object
ds:di - instance data
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 2/02/91 Initial version
don 5/02/91 Change to request page information
ac 1/15/94 Added to Fax Project
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoSetNumPages proc near
class FaxInfoClass
npagesString local 11 dup(char)
uses ax, cx, dx, es
.enter
; Get the number of pages
;
push bp
mov ax, MSG_PRINT_CONTROL_GET_SELECTED_PAGE_RANGE
call FaxCallSpoolPrintControl
pop bp
sub dx, cx
inc dx ; number of pages => DX
mov ds:[di].FII_numPages, dx
; Now convert it to ascii for placing in the CovertSheetPages display
;
mov_tr ax, dx
inc ax ; Plus one for the cover sheet
clr dx
mov cx, mask UHTAF_NULL_TERMINATE
segmov es, ss
lea di, ss:[npagesString]
call UtilHex32ToAscii
; Put it in the object....
;
push bp ; save for locals
push si ; save FaxInfo handle
mov dx, ss
mov bp, di
clr cx ; null-terminated
mov si, offset CoverPageNumPages
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjCallInstanceNoLock
pop si ; restore FaxInfoHandle
pop bp ; restore for locals
;
; Instance data may have moved, so I will make sure it's been
; fixed up.
;
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset
.leave
ret
FaxInfoSetNumPages endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoVisClose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gives us a chance to close the file.
CALLED BY: MSG_VIS_CLOSE
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
bp - 0 if top window, else window for object to open on
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoVisClose method dynamic FaxInfoClass,
MSG_VIS_CLOSE
;
; Make sure the superclass is called
;
mov di, offset FaxInfoClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].FaxInfo_offset ; ds:di <- instance data
;
; Find out how many pages are in the fax not including
; the cover page.
;
call FaxInfoSetNumPages
;
; Free the local copy of the quick number list that we have.
; The handle is Zero, it means that we never had a copy of the
; heap handle.
;
clr bx
xchg bx, ds:[di].FII_qHeapHandle
tst bx
jz closeFile
call MemFree
;
; Save information back into the VM file. First get the map
; block and lock it down.
;
closeFile:
clr bx
xchg bx, ds:[di].FII_fileHandle ; save file handle
;
; If the file handle is Zero, it means that we are unable to open
; the file and that we proceeded as if nothing happened.
; So skip the part where it's updating the fax information file.
;
tst bx
jz closeAddressBook
call VMGrabExclusive
EC < call ECCheckFileHandle >
call VMGetMapBlock ; ax <- map block handle
call VMLock ; ax <- segment
; bp <- memory handle
;
; Remember all the new file info for the address book
;
call UpdateAddrBookInfo
mov es, ax
mov cx, es:[FIFI_chunkArrayHandle]
mov dx, es:[FIFI_heapBlock]
;
; Unlock the map block.
;
call VMDirty
call VMUnlock
;
; Update the quick number list and close the file.
;
EC < call ECCheckFileHandle >
call UpdateQuickNumbers
mov al, FILE_NO_ERRORS
call VMReleaseExclusive
call VMClose
;
; Make sure the address book is closed if we used it.
;
closeAddressBook:
if _USE_PALM_ADDR_BOOK
mov si, offset AddrBookList
mov ax, MSG_ADDRESS_BOOK_LIST_CLOSE_BOOK
call ObjCallInstanceNoLock
endif
ret
FaxInfoVisClose endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Group3WriteDialAssistInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Takes the dial assist info and writes it to the ini file.
CALLED BY: DialAssistSaveFields
PASS: ds = segment of UI
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 11/11/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Group3WriteDialAssistInfo proc near
tempBuf local FAX_MAX_FIELD_LENGTH dup (char)
uses ax,bx,cx,dx,si,di
.enter
push bp
lea di, ss:tempBuf
mov bx, 2 * (length FileInitKeyOffsets - 1)
segmov es, ss
writeINILoop:
push ds ; save segment of UI
mov dx, ss
mov bp, di
mov si, cs:DialAssistTextOffsets[bx]
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
call ObjCallInstanceNoLock
mov di, bp ; es:di <- string
mov cx, cs
mov dx, cs:FileInitKeyOffsets[bx] ; cx:dx <- key
mov ds, cx
mov si, offset fileInitFaxCategory ; ds:si <- category
call InitFileWriteString
pop ds ; ds <- segment of UI
dec bx
dec bx
jns writeINILoop
pop bp
call InitFileSave
.leave
ret
Group3WriteDialAssistInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateQuickNumbers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Makes sure the quick list is updated if any
items should be added.
CALLED BY: FaxInfoVisClose
PASS: ds = segment of UI
bx = file handle
cx = chunk array handle
dx = heap handle
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 11/30/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateQuickNumbers proc near
uses ax, bx, cx, dx, bp, si
.enter
push cx, dx ; optr to chunk array
if _USE_PALM_ADDR_BOOK
;
; Check to see if an address book entry was used.
;
mov si, offset AddrBookList
mov ax, MSG_ADDRESS_BOOK_LIST_IS_ADDRESS_BOOK_USED
call ObjCallInstanceNoLock
jc short checkIfAddressInQuickSelection
endif
;
; Check to see if the text in the number field matches any of the
; numbers in the quick numbers list
;
checkIfInList:
clr ax ; just check number
call CheckIfNameOrNumberInQuickList ; ax <- element number
jnc addNumber
switchItems::
;
; If the excution comes through here, then that means that
; the number chosen was not the first one, so we have to switch
; the order of the quick number lists
;
mov_tr cx, ax ; cx <- element to choose
pop si, ax
EC < call ECVMCheckVMBlockHandle >
call SwitchItemsInQuickList
exit:
.leave
ret
checkIfAddressInQuickSelection:
;
; Check to see if it's name has changed and it's an address book entry
; if so, then we add the number.
;
push cx, dx
mov si, offset Group3NameText
mov ax, MSG_GEN_TEXT_IS_MODIFIED
call ObjCallInstanceNoLock
pop cx, dx
jc checkIfInList
push cx, dx
mov si, offset Group3NumberText
mov ax, MSG_GEN_TEXT_IS_MODIFIED
call ObjCallInstanceNoLock
pop cx, dx
jc checkIfInList
mov ax, si ; make si non zero
call CheckIfNameOrNumberInQuickList ; ax <- item found
jc switchItems
addNameAndNumber::
;
; Add the new number as a name and number in the list
; Because we have determined it's an address book entry that should
; be in the list.
;
pop si, ax
mov cx, ax ; make cx non-zero
call AddNameOrNumberToQuickList
jmp exit
addNumber:
;
; Add the number to the list.
;
pop si, ax ; optr to chunk array
clr cx ; add number only
call AddNameOrNumberToQuickList
jmp exit
UpdateQuickNumbers endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckIfNameOrNumberInQuickList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Checks if the name or number in the number or name text object
is in the quick number list.
CALLED BY: UpdateQuickNumbers
PASS: ds = segment of UI
bx = file handle
cx = chunk array handle
dx = VM block heap handle
ax = 0 if just number to check
= non-zero if name and number to check
RETURN: carry set if in the quick list
ax = element number if is in the list
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckIfNameOrNumberInQuickList proc near
; handle of heap that quick list is in
blockHan local hptr push dx
; chunk handle of the chunk array
chunkHan local nptr push cx
; flag to tell how the user wants to use this function
userFlag local word push ax
; temp buffer to hold the number string
tempNameBuf local FAX_MAX_FIELD_LENGTH dup (char)
tempNumberBuf local FAX_MAX_FIELD_LENGTH dup (char)
uses bx,cx,dx,si,di,bp,es,ds
.enter
;
; Check to see if we should know what is in the name field.
;
mov di, bp ; di <- bp for locals
tst ax
jz getNumberText
mov dx, ss
lea bp, ss:[tempNameBuf]
mov si, offset Group3NameText
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
call ObjCallInstanceNoLock ; cx <- length of string
mov bp, di
;
; Get the number from the text object
;
getNumberText:
mov dx, ss
lea bp, ss:[tempNumberBuf]
mov si, offset Group3NumberText
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
call ObjCallInstanceNoLock ; cx <- string length
;
; Lock down the chunk array from the file.
;
mov bp, di
mov si, ss:[chunkHan]
mov ax, ss:[blockHan]
EC < call ECVMCheckVMBlockHandle >
call VMLock ; bp <- mem handle
push bp ; save mem handle
mov ds, ax ; ds:si <- chunk array
;
; Check each number in the list. Read the chunk array from the
; file and check each entry.
;
mov bp, di
segmov es, ss
clr ax, cx ; ax <- counter
; cx indicates null term.
mov bx, si ; save c-array handle in bx
tst ss:[userFlag]
jz checkNumberString
checkNameAndNumberStringLoop:
call ChunkArrayElementToPtr ; ds:di <- new element
jc stringNotFound
tst ds:[di].QNCH_nameChunk
jz short continueNameAndNumberLoop
mov si, ds:[di].QNCH_nameChunk
mov si, ds:[si] ; ds:si <- new string
mov dx, di
lea di, ss:[tempNameBuf] ; es:di <- name text
call LocalCmpStrings
jnz short continueNameAndNumberLoop
; Name check was successful, check the number
mov di, dx
mov si, ds:[di].QNCH_numberChunk
mov si, ds:[si]
lea di, ss:[tempNumberBuf] ; es:di <- number text
call LocalCmpStrings
jz stringFound
continueNameAndNumberLoop:
mov si, bx
inc ax
jmp checkNameAndNumberStringLoop
checkNumberString:
lea dx, ss:[tempNumberBuf]
checkNumberStringLoop:
call ChunkArrayElementToPtr ; ds:di <- new element
jc stringNotFound
tst ds:[di].QNCH_nameChunk
jnz short continueNumberLoop
mov si, ds:[di].QNCH_numberChunk
mov si, ds:[si] ; ds:si <- new string
mov di, dx ; es:di <- number text
call LocalCmpStrings
jz stringFound
continueNumberLoop:
mov si, bx
inc ax
jmp checkNumberStringLoop
exit:
.leave
ret
stringFound:
pop bx
xchg bp, bx ; bp <- mem handle
call VMUnlock
xchg bp, bx ; bp <- for local vars
stc
jmp exit
stringNotFound:
pop bx
xchg bp, bx ; bp <- mem handle
call VMUnlock
xchg bp, bx ; bp <- for local vars
clc
jmp exit
CheckIfNameOrNumberInQuickList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AddNameOrNumberToQuickList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Adds in a number or name/number to the quick list depending
on what the caller wants.
CALLED BY: INTERNAL
PASS: ds = segment of UI
ax = heap handle of chunk array
si = handle to chunk array
cx = zero if just number wanted.
non-zero if name and number wanted.
RETURN: Element is added
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AddNameOrNumberToQuickList proc near
uses ax,bx,si,di,bp,es
.enter
;
; Lock the block for the chunk array.
;
call VMLock
mov es, ax ; *ds:si <- chunk array
mov di, si
;
; Check if we need to add the name
;
jcxz getNumber
;
; Get the name and add it into the list
;
mov si, offset Group3NameText
call MakeChunkFromText ; si <- new chunk
mov cx, si ; cx <- new chunk
getNumber:
;
; Get the number and add it to the list
;
mov si, offset Group3NumberText
call MakeChunkFromText ; si <- new chunk
;
; Make sure space in the chunk array is made for the element
;
push ds
segmov ds, es
mov bx, si ; bx <- new number chunk
mov si, di ; *ds:si <- chunk array
call AddElementToQuickList ; ds:di <- new element
mov ds:[di].QNCH_nameChunk, cx
mov ds:[di].QNCH_numberChunk, bx
pop ds
;
; Unlock the block for the chunk array
;
call VMDirty
call VMUnlock
.leave
ret
AddNameOrNumberToQuickList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AddElementToQuickList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Makes a new element in the quick list so we can
add new information to the quick list. Will also delete
old elements.
CALLED BY: INTERNAL
PASS: ds = segment of Heap
bx = VM file handle
si = chunk handle to chunk array
RETURN: ds:di = new element
DESTROYED: nothing
SIDE EFFECTS: Will also delete an old number if there are ten numbers
in the list. ds may have changed.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AddElementToQuickList proc near
uses ax,cx
.enter
;
; Get the count of elements in the chunk array. If it's Zero, we need
; to do an append. If it's greater than our max, then we need
; to also discard the last element.
;
EC < call ECCheckChunkArray >
call ChunkArrayGetCount ; cx <- number of elements
jcxz appendElement
;
; Test to see if we have to many elements. If so, we'll delete the
; last one.
;
mov ax, GROUP3_MAX_QUICK_DIAL_NUMBERS
cmp cx, ax
jl short getBeginingElement
;
; Delete 10th element.
;
dec ax
call ChunkArrayElementToPtr ; ds:di <- new element
call DeleteElementInChunkArray
getBeginingElement:
;
; Otherwise add it to the chunk array.
;
clr ax ; get first element
call ChunkArrayElementToPtr ; ds:di <- first element
call ChunkArrayInsertAt ; ds:di <- new element
exit:
.leave
ret ; ds:di <- new element
appendElement:
;
; This is the first element in the list, so we have to append it.
;
call ChunkArrayAppend ; ds:di <- new element
jmp exit
AddElementToQuickList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MakeChunkFromText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: This procedure gets the text from a text object and
and copies it to a chunk that this procedure creates.
CALLED BY: INTERNAL
PASS: ds = segment of UI
es = Lmem heap to create chunk in
si = offset to Text object wanted
RETURN: si = chunk handle of the copied text
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MakeChunkFromText proc near
uses ax,bx,cx,dx,bp
.enter
;
; Find out how large the text is, so we know how big of
; a chunk to allocate
;
mov ax, MSG_VIS_TEXT_GET_TEXT_SIZE
call ObjCallInstanceNoLock ; dx:ax <- text length
;
; Create the chunk that we need.
;
mov bx, ds ; save segment of UI
segmov ds, es
inc ax ; include null
mov_tr cx, ax
clr al ; no object flags
call LMemAlloc ; ax <- Handle of chunk
; ds may of changed
push ax
;
; Copy the text from the text object into the the chunk
;
mov_tr bp, ax
mov bp, ds:[bp]
mov dx, ds ; dx:bp <- location to copy to
mov ds, bx ; *ds:si <- text object
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
call ObjCallInstanceNoLock
;
; return the chunk handle for this proocedure
;
pop si
mov es, dx
.leave
ret
MakeChunkFromText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SwitchItemsInQuickList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Switch the first element and the element the user chose
in the QuickNumberList in the Chunk Array of phone numbers
CALLED BY: FaxInfoVisOpen
PASS: cx = element chose
si = handle to the chunk array
ax = handle to block of chunk array
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SwitchItemsInQuickList proc near
uses ax,bx,cx,di,ds
.enter
jcxz exit ; do nothing if first element
;
; Lock down block of the chunk array
;
call VMLock ; ax <- segment
; bp <- mem handle
mov ds, ax ; *ds:si <- chunk array
;
; Get the chosen element in the chunk array
;
mov_tr ax, cx ; ax <- chosen element
call ChunkArrayElementToPtr ; ds:di <- chosen element
EC < ERROR_C -1 >
pushdw ds:[di] ; save the value
;
; Delete that element in the chunk array
;
call ChunkArrayDelete
;
; Get the first element in the chunk array and insert
; at that point
;
clr ax
call ChunkArrayElementToPtr ; ds:di <- first element
call ChunkArrayInsertAt ; ds:di <- new element
;
; Read in the new value for the first element
;
popdw ds:[di]
;
; Unlock the block
;
call VMDirty
call VMUnlock
exit:
.leave
ret
SwitchItemsInQuickList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DeleteElementInChunkArray
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: For a chosen element, it deletes the entry and the
chunks that the element points to.
CALLED BY: INTERNAL
PASS: *ds:si = chunk array
ds:di = element
RETURN: ds:di = points to the same element (if it still exists)
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DeleteElementInChunkArray proc near
uses ax
.enter
;
; Find out what chunks the element is pointing to and free up
; those chunks
;
mov ax, ds:[di].QNCH_nameChunk
tst ax
jz freeNumber
call LMemFree
freeNumber:
mov ax, ds:[di].QNCH_numberChunk
EC < tst ax >
EC < ERROR_Z -1 >
call LMemFree
;
; Delete the element in the chunk array
;
call ChunkArrayDelete
.leave
ret
DeleteElementInChunkArray endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateAddrBookInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Updates the fax information file so it know's the
address book that the user wants to use
CALLED BY: FaxInfoClose
PASS: bx = file handle of fax information file
ds:di = instance data of FaxInfo
ax = segment of where to write data
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/27/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateAddrBookInfo proc near
class FaxInfoClass
uses si,di,es
.enter
;
; Get the place to write the fax information
;
lea si, ds:[di].FII_addrInfo ; ds:si <- src
mov es, ax
mov di, FIFI_addrBookFileInfo ; es:di <- dest.
if _USE_PALM_ADDR_BOOK
call CopyAddressBookFileInfo
endif
.leave
ret
UpdateAddrBookInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoGetFileHandle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the file handle of the fax information file.
CALLED BY: MSG_FAX_INFO_GET_FILE_HANDLE
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
RETURN: ax = file handle
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/ 6/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoGetFileHandle method dynamic FaxInfoClass,
MSG_FAX_INFO_GET_FILE_HANDLE
mov ax, ds:[di].FII_fileHandle
ret
FaxInfoGetFileHandle endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoGetQuickListHandles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the mem and chunk handle to the quick numbers list.
CALLED BY: MSG_FAX_INFO_GET_QUICK_LIST_HANDLES
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
RETURN: ax = block handle
cx = chunk handle
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/14/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoGetQuickListHandles method dynamic FaxInfoClass,
MSG_FAX_INFO_GET_QUICK_LIST_HANDLES
mov ax, ds:[di].FII_qHeapHandle
mov cx, ds:[di].FII_qListHandle
ret
FaxInfoGetQuickListHandles endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoGetAddressBookUsed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Gets the information about which address book is used
CALLED BY: MSG_FAX_INFO_GET_ADDRESS_BOOK_USED
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
cx:dx = fptr to AddressBookFileInfo struc
RETURN: cx:dx = filled
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/23/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoGetAddressBookUsed method dynamic FaxInfoClass,
MSG_FAX_INFO_GET_ADDRESS_BOOK_USED
uses ax, cx, dx, bp
.enter
;
; Return the information into the stucture.
;
lea si, ds:[di].FII_addrInfo ; ds:si <- data to copy
mov es, cx
mov di, dx ; ds:di <- structure to fill
if _USE_PALM_ADDR_BOOK
call CopyAddressBookFileInfo
endif
.leave
ret
FaxInfoGetAddressBookUsed endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoSetAddressBookUsed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the address book info that is being used.
CALLED BY: MSG_FAX_INFO_SET_ADDRESS_BOOK_USED
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
ds:bx = FaxInfoClass object (same as *ds:si)
es = segment of FaxInfoClass
ax = message #
cx:dx = AddressBookFileInfo struc
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 12/23/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoSetAddressBookUsed method dynamic FaxInfoClass,
MSG_FAX_INFO_SET_ADDRESS_BOOK_USED
uses ax, cx
.enter
;
; Copy the info in cx:dx into our instance data
;
add di, FII_addrInfo
segmov es, ds ; es:di <- where to write data
mov ds, cx
mov si, dx ; ds:si <- new file info
mov cx, size AddressBookFileInfo
rep movsb
.leave
ret
FaxInfoSetAddressBookUsed endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoResetSenderInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Reset all the sender information fields.
CALLED BY: MSG_FAX_INFO_RESET_SENDER_INFO
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
es = segment of FaxInfoClass
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Use the information copied out of the Fax Information File
to restore the fields of the text objects in the sender
information dialog. (This does not include the receiver
name.) Basically copied from GetFaxInformationFile.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/ 7/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoResetSenderInfo method dynamic FaxInfoClass,
MSG_FAX_INFO_RESET_SENDER_INFO
;
; Get the coversheet information out of the VM file.
;
mov bx, ds:[di].FII_fileHandle
tst bx
jz exit
call VMGrabExclusive
EC < call ECCheckFileHandle >
call VMGetMapBlock ; ax = map block handle
tst ax
jz done ; error, bail...
call VMLock ; ax = segment
; bp = memory handle
;
; Get the cover page information and place them in the text objects.
;
mov es, ax ; es = segment of map block
call Group3GetSenderInfo
call VMUnlock
done:
EC < call ECCheckFileHandle >
call VMReleaseExclusive
exit:
ret
FaxInfoResetSenderInfo endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoSaveSenderInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Save the new sender information to the VM file.
CALLED BY: MSG_FAX_INFO_SAVE_SENDER_INFO
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
es = segment of FaxInfoClass
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/ 8/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoSaveSenderInfo method dynamic FaxInfoClass,
MSG_FAX_INFO_SAVE_SENDER_INFO
;
; Save all the sender information back into the VM file, if there
; one exists.
;
mov bx, ds:[di].FII_fileHandle
tst bx
jz exit ; bail if no file
call VMGrabExclusive
EC < call ECCheckFileHandle >
call VMGetMapBlock ; ax = map block handle
tst ax
jz releaseExclusive
call VMLock ; ax = segment
; bp = memory handle
push bx ; save file handle
push bp ; save mem handle
;
; Now write the information from the text objects to the VM map
; block.
;
mov_tr dx, ax ; dx = map block segment
mov bx, 2 * (length FileInformationOffsets - 1)
; bx = offset into data
extractTextObjectsLoop:
mov bp, cs:FileInformationOffsets[bx]
mov si, cs:UIInformationObjChunks[bx]
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
call ObjCallInstanceNoLock
dec bx
dec bx
jns extractTextObjectsLoop
pop bp ; bp = mem handle
call VMDirty
call VMUnlock
pop bx
releaseExclusive:
EC < call ECCheckFileHandle >
call VMReleaseExclusive
exit:
ret
FaxInfoSaveSenderInfo endm
if 0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxInfoUseCoverPage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Automatically select to use cover page.
CALLED BY: MSG_FAX_INFO_USE_COVER_PAGE
PASS: *ds:si = FaxInfoClass object
ds:di = FaxInfoClass instance data
es = segment of FaxInfoClass
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/14/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxInfoUseCoverPage method dynamic FaxInfoClass,
MSG_FAX_INFO_USE_COVER_PAGE
mov si, offset Group3CoverPageItemGroup
mov cx, PO_COVER_PAGE
clr dx ; not indeterminate
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
GOTO ObjCallInstanceNoLock
FaxInfoUseCoverPage endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FaxCallSpoolPrintControl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send a method to the SpoolPrintControl object above me in
the generic tree
CALLED BY: INTERNAL
PASS: DS:*SI = FaxInfoClass object
AX = Method to send
CX }
DX = Data to send with method
BP }
RETURN: AX, CX, DX, BP
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 4/27/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FaxCallSpoolPrintControl proc near
uses bx, si, di
.enter
; Find the SpoolPrintControlClass object
;
push ax, cx, dx, bp
mov ax, MSG_GEN_GUP_FIND_OBJECT_OF_CLASS
mov cx, segment PrintControlClass
mov dx, offset PrintControlClass
call ObjCallInstanceNoLock ; ^lcx:dx = SPC
EC < ERROR_NC -1 >
; Now pass the method on to the SpoolPrintControl object
;
mov bx, cx
mov si, dx
pop ax, cx, dx, bp
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
.leave
ret
FaxCallSpoolPrintControl endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Group3OptionsTriggerToggleEnabled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Toggles the enabled status of the trigger when it receives
this message
CALLED BY: MSG_GROUP3_OPTIONS_TRIGGER_TOGGLE_ENABLED
PASS: *ds:si = Group3OptionsTriggerClass object
ds:di = Group3OptionsTriggerClass instance data
ds:bx = Group3OptionsTriggerClass object (same as *ds:si)
es = segment of Group3OptionsTriggerClass
ax = message #
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
AC 10/10/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GroupOptionsTriggerToggleEnabled method dynamic Group3OptionsTriggerClass,
MSG_GROUP3_OPTIONS_TRIGGER_TOGGLE_ENABLED
uses ax, cx, dx, bp
.enter
;
; Look in the instance data to see if it is enabled
;
test ds:[di].GI_states, mask GS_ENABLED
jnz disableTrigger
;
; Enable the trigger
;
mov ax, MSG_GEN_SET_ENABLED
jmp short sendMessage
disableTrigger:
;
; Disable the trigger
;
mov ax, MSG_GEN_SET_NOT_ENABLED
sendMessage:
;
; Send the appropiate message to the trigger
;
mov dl, VUM_NOW
call ObjCallInstanceNoLock
.leave
ret
GroupOptionsTriggerToggleEnabled endm
|
; SameBoy CGB bootstrap ROM
; Todo: use friendly names for HW registers instead of magic numbers
SECTION "BootCode", ROM0[$0]
Start:
; Init stack pointer
ld sp, $fffe
; Clear memory VRAM
call ClearMemoryPage8000
ld a, 2
ld c, $70
ld [c], a
; Clear RAM Bank 2 (Like the original boot ROM)
ld h, $D0
call ClearMemoryPage
ld [c], a
; Clear OAM
ld h, $fe
ld c, $a0
.clearOAMLoop
ldi [hl], a
dec c
jr nz, .clearOAMLoop
; Init waveform
ld c, $10
.waveformLoop
ldi [hl], a
cpl
dec c
jr nz, .waveformLoop
; Clear chosen input palette
ldh [InputPalette], a
; Clear title checksum
ldh [TitleChecksum], a
ld a, $80
ldh [$26], a
ldh [$11], a
ld a, $f3
ldh [$12], a
ldh [$25], a
ld a, $77
ldh [$24], a
ld hl, $FF30
; Init BG palette
ld a, $fc
ldh [$47], a
; Load logo from ROM.
; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8.
; Tiles are ordered left to right, top to bottom.
; These tiles are not used, but are required for DMG compatibility. This is done
; by the original CGB Boot ROM as well.
ld de, $104 ; Logo start
ld hl, $8010 ; This is where we load the tiles in VRAM
.loadLogoLoop
ld a, [de] ; Read 2 rows
ld b, a
call DoubleBitsAndWriteRowTwice
inc de
ld a, e
cp $34 ; End of logo
jr nz, .loadLogoLoop
call ReadTrademarkSymbol
; Clear the second VRAM bank
ld a, 1
ldh [$4F], a
call ClearMemoryPage8000
call LoadTileset
ld b, 3
IF DEF(FAST)
xor a
ldh [$4F], a
ELSE
; Load Tilemap
ld hl, $98C2
ld d, 3
ld a, 8
.tilemapLoop
ld c, $10
.tilemapRowLoop
call .write_with_palette
; Repeat the 3 tiles common between E and B. This saves 27 bytes after
; compression, with a cost of 17 bytes of code.
push af
sub $20
sub $3
jr nc, .notspecial
add $20
call .write_with_palette
dec c
.notspecial
pop af
add d ; d = 3 for SameBoy logo, d = 1 for Nintendo logo
dec c
jr nz, .tilemapRowLoop
sub 44
push de
ld de, $10
add hl, de
pop de
dec b
jr nz, .tilemapLoop
dec d
jr z, .endTilemap
dec d
ld a, $38
ld l, $a7
ld bc, $0107
jr .tilemapRowLoop
.write_with_palette
push af
; Switch to second VRAM Bank
ld a, 1
ldh [$4F], a
ld [hl], 8
; Switch to back first VRAM Bank
xor a
ldh [$4F], a
pop af
ldi [hl], a
ret
.endTilemap
ENDC
; Expand Palettes
ld de, AnimationColors
ld c, 8
ld hl, BgPalettes
xor a
.expandPalettesLoop:
cpl
; One white
ld [hli], a
ld [hli], a
; Mixed with white
ld a, [de]
inc e
or $20
ld b, a
ld a, [de]
dec e
or $84
rra
rr b
ld [hl], b
inc l
ld [hli], a
; One black
xor a
ld [hli], a
ld [hli], a
; One color
ld a, [de]
inc e
ld [hli], a
ld a, [de]
inc e
ld [hli], a
xor a
dec c
jr nz, .expandPalettesLoop
call LoadPalettesFromHRAM
; Turn on LCD
ld a, $91
ldh [$40], a
IF !DEF(FAST)
call DoIntroAnimation
ld a, 45
ldh [WaitLoopCounter], a
; Wait ~0.75 seconds
ld b, a
call WaitBFrames
; Play first sound
ld a, $83
call PlaySound
ld b, 5
call WaitBFrames
; Play second sound
ld a, $c1
call PlaySound
.waitLoop
call GetInputPaletteIndex
call WaitFrame
ld hl, WaitLoopCounter
dec [hl]
jr nz, .waitLoop
ELSE
ld a, $c1
call PlaySound
ENDC
call Preboot
IF DEF(AGB)
ld b, 1
ENDC
; Will be filled with NOPs
SECTION "BootGame", ROM0[$fe]
BootGame:
ldh [$50], a
SECTION "MoreStuff", ROM0[$200]
; Game Palettes Data
TitleChecksums:
db $00 ; Default
db $88 ; ALLEY WAY
db $16 ; YAKUMAN
db $36 ; BASEBALL, (Game and Watch 2)
db $D1 ; TENNIS
db $DB ; TETRIS
db $F2 ; QIX
db $3C ; DR.MARIO
db $8C ; RADARMISSION
db $92 ; F1RACE
db $3D ; YOSSY NO TAMAGO
db $5C ;
db $58 ; X
db $C9 ; MARIOLAND2
db $3E ; YOSSY NO COOKIE
db $70 ; ZELDA
db $1D ;
db $59 ;
db $69 ; TETRIS FLASH
db $19 ; DONKEY KONG
db $35 ; MARIO'S PICROSS
db $A8 ;
db $14 ; POKEMON RED, (GAMEBOYCAMERA G)
db $AA ; POKEMON GREEN
db $75 ; PICROSS 2
db $95 ; YOSSY NO PANEPON
db $99 ; KIRAKIRA KIDS
db $34 ; GAMEBOY GALLERY
db $6F ; POCKETCAMERA
db $15 ;
db $FF ; BALLOON KID
db $97 ; KINGOFTHEZOO
db $4B ; DMG FOOTBALL
db $90 ; WORLD CUP
db $17 ; OTHELLO
db $10 ; SUPER RC PRO-AM
db $39 ; DYNABLASTER
db $F7 ; BOY AND BLOB GB2
db $F6 ; MEGAMAN
db $A2 ; STAR WARS-NOA
db $49 ;
db $4E ; WAVERACE
db $43 | $80 ;
db $68 ; LOLO2
db $E0 ; YOSHI'S COOKIE
db $8B ; MYSTIC QUEST
db $F0 ;
db $CE ; TOPRANKINGTENNIS
db $0C ; MANSELL
db $29 ; MEGAMAN3
db $E8 ; SPACE INVADERS
db $B7 ; GAME&WATCH
db $86 ; DONKEYKONGLAND95
db $9A ; ASTEROIDS/MISCMD
db $52 ; STREET FIGHTER 2
db $01 ; DEFENDER/JOUST
db $9D ; KILLERINSTINCT95
db $71 ; TETRIS BLAST
db $9C ; PINOCCHIO
db $BD ;
db $5D ; BA.TOSHINDEN
db $6D ; NETTOU KOF 95
db $67 ;
db $3F ; TETRIS PLUS
db $6B ; DONKEYKONGLAND 3
; For these games, the 4th letter is taken into account
FirstChecksumWithDuplicate:
; Let's play hangman!
db $B3 ; ???[B]????????
db $46 ; SUP[E]R MARIOLAND
db $28 ; GOL[F]
db $A5 ; SOL[A]RSTRIKER
db $C6 ; GBW[A]RS
db $D3 ; KAE[R]UNOTAMENI
db $27 ; ???[B]????????
db $61 ; POK[E]MON BLUE
db $18 ; DON[K]EYKONGLAND
db $66 ; GAM[E]BOY GALLERY2
db $6A ; DON[K]EYKONGLAND 2
db $BF ; KID[ ]ICARUS
db $0D ; TET[R]IS2
db $F4 ; ???[-]????????
db $B3 ; MOG[U]RANYA
db $46 ; ???[R]????????
db $28 ; GAL[A]GA&GALAXIAN
db $A5 ; BT2[R]AGNAROKWORLD
db $C6 ; KEN[ ]GRIFFEY JR
db $D3 ; ???[I]????????
db $27 ; MAG[N]ETIC SOCCER
db $61 ; VEG[A]S STAKES
db $18 ; ???[I]????????
db $66 ; MIL[L]I/CENTI/PEDE
db $6A ; MAR[I]O & YOSHI
db $BF ; SOC[C]ER
db $0D ; POK[E]BOM
db $F4 ; G&W[ ]GALLERY
db $B3 ; TET[R]IS ATTACK
ChecksumsEnd:
PalettePerChecksum:
; | $80 means game requires DMG boot tilemap
db 0 ; Default Palette
db 4 ; ALLEY WAY
db 5 ; YAKUMAN
db 35 ; BASEBALL, (Game and Watch 2)
db 34 ; TENNIS
db 3 ; TETRIS
db 31 ; QIX
db 15 ; DR.MARIO
db 10 ; RADARMISSION
db 5 ; F1RACE
db 19 ; YOSSY NO TAMAGO
db 36 ;
db 7 | $80 ; X
db 37 ; MARIOLAND2
db 30 ; YOSSY NO COOKIE
db 44 ; ZELDA
db 21 ;
db 32 ;
db 31 ; TETRIS FLASH
db 20 ; DONKEY KONG
db 5 ; MARIO'S PICROSS
db 33 ;
db 13 ; POKEMON RED, (GAMEBOYCAMERA G)
db 14 ; POKEMON GREEN
db 5 ; PICROSS 2
db 29 ; YOSSY NO PANEPON
db 5 ; KIRAKIRA KIDS
db 18 ; GAMEBOY GALLERY
db 9 ; POCKETCAMERA
db 3 ;
db 2 ; BALLOON KID
db 26 ; KINGOFTHEZOO
db 25 ; DMG FOOTBALL
db 25 ; WORLD CUP
db 41 ; OTHELLO
db 42 ; SUPER RC PRO-AM
db 26 ; DYNABLASTER
db 45 ; BOY AND BLOB GB2
db 42 ; MEGAMAN
db 45 ; STAR WARS-NOA
db 36 ;
db 38 ; WAVERACE
db 26 ;
db 42 ; LOLO2
db 30 ; YOSHI'S COOKIE
db 41 ; MYSTIC QUEST
db 34 ;
db 34 ; TOPRANKINGTENNIS
db 5 ; MANSELL
db 42 ; MEGAMAN3
db 6 ; SPACE INVADERS
db 5 ; GAME&WATCH
db 33 ; DONKEYKONGLAND95
db 25 ; ASTEROIDS/MISCMD
db 42 ; STREET FIGHTER 2
db 42 ; DEFENDER/JOUST
db 40 ; KILLERINSTINCT95
db 2 ; TETRIS BLAST
db 16 ; PINOCCHIO
db 25 ;
db 42 ; BA.TOSHINDEN
db 42 ; NETTOU KOF 95
db 5 ;
db 0 ; TETRIS PLUS
db 39 ; DONKEYKONGLAND 3
db 36 ;
db 22 ; SUPER MARIOLAND
db 25 ; GOLF
db 6 ; SOLARSTRIKER
db 32 ; GBWARS
db 12 ; KAERUNOTAMENI
db 36 ;
db 11 ; POKEMON BLUE
db 39 ; DONKEYKONGLAND
db 18 ; GAMEBOY GALLERY2
db 39 ; DONKEYKONGLAND 2
db 24 ; KID ICARUS
db 31 ; TETRIS2
db 50 ;
db 17 ; MOGURANYA
db 46 ;
db 6 ; GALAGA&GALAXIAN
db 27 ; BT2RAGNAROKWORLD
db 0 ; KEN GRIFFEY JR
db 47 ;
db 41 ; MAGNETIC SOCCER
db 41 ; VEGAS STAKES
db 0 ;
db 0 ; MILLI/CENTI/PEDE
db 19 ; MARIO & YOSHI
db 34 ; SOCCER
db 23 ; POKEBOM
db 18 ; G&W GALLERY
db 29 ; TETRIS ATTACK
Dups4thLetterArray:
db "BEFAARBEKEK R-URAR INAILICE R"
; We assume the last three arrays fit in the same $100 byte page!
PaletteCombinations:
palette_comb: MACRO ; Obj0, Obj1, Bg
db (\1) * 8, (\2) * 8, (\3) *8
ENDM
raw_palette_comb: MACRO ; Obj0, Obj1, Bg
db (\1) * 2, (\2) * 2, (\3) * 2
ENDM
palette_comb 4, 4, 29
palette_comb 18, 18, 18
palette_comb 20, 20, 20
palette_comb 24, 24, 24
palette_comb 9, 9, 9
palette_comb 0, 0, 0
palette_comb 27, 27, 27
palette_comb 5, 5, 5
palette_comb 12, 12, 12
palette_comb 26, 26, 26
palette_comb 16, 8, 8
palette_comb 4, 28, 28
palette_comb 4, 2, 2
palette_comb 3, 4, 4
palette_comb 4, 29, 29
palette_comb 28, 4, 28
palette_comb 2, 17, 2
palette_comb 16, 16, 8
palette_comb 4, 4, 7
palette_comb 4, 4, 18
palette_comb 4, 4, 20
palette_comb 19, 19, 9
raw_palette_comb 4 * 4 - 1, 4 * 4 - 1, 11 * 4
palette_comb 17, 17, 2
palette_comb 4, 4, 2
palette_comb 4, 4, 3
palette_comb 28, 28, 0
palette_comb 3, 3, 0
palette_comb 0, 0, 1
palette_comb 18, 22, 18
palette_comb 20, 22, 20
palette_comb 24, 22, 24
palette_comb 16, 22, 8
palette_comb 17, 4, 13
raw_palette_comb 28 * 4 - 1, 0 * 4, 14 * 4
raw_palette_comb 28 * 4 - 1, 4 * 4, 15 * 4
palette_comb 19, 22, 9
palette_comb 16, 28, 10
palette_comb 4, 23, 28
palette_comb 17, 22, 2
palette_comb 4, 0, 2
palette_comb 4, 28, 3
palette_comb 28, 3, 0
palette_comb 3, 28, 4
palette_comb 21, 28, 4
palette_comb 3, 28, 0
palette_comb 25, 3, 28
palette_comb 0, 28, 8
palette_comb 4, 3, 28
palette_comb 28, 3, 6
palette_comb 4, 28, 29
; SameBoy "Exclusives"
palette_comb 30, 30, 30 ; CGA
palette_comb 31, 31, 31 ; DMG LCD
palette_comb 28, 4, 1
palette_comb 0, 0, 2
Palettes:
dw $7FFF, $32BF, $00D0, $0000
dw $639F, $4279, $15B0, $04CB
dw $7FFF, $6E31, $454A, $0000
dw $7FFF, $1BEF, $0200, $0000
dw $7FFF, $421F, $1CF2, $0000
dw $7FFF, $5294, $294A, $0000
dw $7FFF, $03FF, $012F, $0000
dw $7FFF, $03EF, $01D6, $0000
dw $7FFF, $42B5, $3DC8, $0000
dw $7E74, $03FF, $0180, $0000
dw $67FF, $77AC, $1A13, $2D6B
dw $7ED6, $4BFF, $2175, $0000
dw $53FF, $4A5F, $7E52, $0000
dw $4FFF, $7ED2, $3A4C, $1CE0
dw $03ED, $7FFF, $255F, $0000
dw $036A, $021F, $03FF, $7FFF
dw $7FFF, $01DF, $0112, $0000
dw $231F, $035F, $00F2, $0009
dw $7FFF, $03EA, $011F, $0000
dw $299F, $001A, $000C, $0000
dw $7FFF, $027F, $001F, $0000
dw $7FFF, $03E0, $0206, $0120
dw $7FFF, $7EEB, $001F, $7C00
dw $7FFF, $3FFF, $7E00, $001F
dw $7FFF, $03FF, $001F, $0000
dw $03FF, $001F, $000C, $0000
dw $7FFF, $033F, $0193, $0000
dw $0000, $4200, $037F, $7FFF
dw $7FFF, $7E8C, $7C00, $0000
dw $7FFF, $1BEF, $6180, $0000
; SameBoy "Exclusives"
dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1
dw $4778, $3290, $1D87, $0861 ; DMG LCD
KeyCombinationPalettes:
db 1 * 3 ; Right
db 48 * 3 ; Left
db 5 * 3 ; Up
db 8 * 3 ; Down
db 0 * 3 ; Right + A
db 40 * 3 ; Left + A
db 43 * 3 ; Up + A
db 3 * 3 ; Down + A
db 6 * 3 ; Right + B
db 7 * 3 ; Left + B
db 28 * 3 ; Up + B
db 49 * 3 ; Down + B
; SameBoy "Exclusives"
db 51 * 3 ; Right + A + B
db 52 * 3 ; Left + A + B
db 53 * 3 ; Up + A + B
db 54 * 3 ; Down + A + B
TrademarkSymbol:
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
SameBoyLogo:
incbin "SameBoyLogo.pb12"
AnimationColors:
dw $7FFF ; White
dw $774F ; Cyan
dw $22C7 ; Green
dw $039F ; Yellow
dw $017D ; Orange
dw $241D ; Red
dw $6D38 ; Purple
dw $7102 ; Blue
AnimationColorsEnd:
; Helper Functions
DoubleBitsAndWriteRowTwice:
call .twice
.twice
; Double the most significant 4 bits, b is shifted by 4
ld a, 4
ld c, 0
.doubleCurrentBit
sla b
push af
rl c
pop af
rl c
dec a
jr nz, .doubleCurrentBit
ld a, c
; Write as two rows
ldi [hl], a
inc hl
ldi [hl], a
inc hl
ret
WaitFrame:
push hl
ld hl, $FF0F
res 0, [hl]
.wait
bit 0, [hl]
jr z, .wait
pop hl
ret
WaitBFrames:
call GetInputPaletteIndex
call WaitFrame
dec b
jr nz, WaitBFrames
ret
PlaySound:
ldh [$13], a
ld a, $87
ldh [$14], a
ret
ClearMemoryPage8000:
ld hl, $8000
; Clear from HL to HL | 0x2000
ClearMemoryPage:
xor a
ldi [hl], a
bit 5, h
jr z, ClearMemoryPage
ret
ReadTwoTileLines:
call ReadTileLine
; c = $f0 for even lines, $f for odd lines.
ReadTileLine:
ld a, [de]
and c
ld b, a
inc e
inc e
ld a, [de]
dec e
dec e
and c
swap a
or b
bit 0, c
jr z, .dontSwap
swap a
.dontSwap
inc hl
ldi [hl], a
swap c
ret
ReadCGBLogoHalfTile:
call .do_twice
.do_twice
call ReadTwoTileLines
inc e
ld a, e
ret
; LoadTileset using PB12 codec, 2020 Jakub Kądziołka
; (based on PB8 codec, 2019 Damian Yerrick)
SameBoyLogo_dst = $8080
SameBoyLogo_length = (128 * 24) / 64
LoadTileset:
ld hl, SameBoyLogo
ld de, SameBoyLogo_dst - 1
ld c, SameBoyLogo_length
.refill
; Register map for PB12 decompression
; HL: source address in boot ROM
; DE: destination address in VRAM
; A: Current literal value
; B: Repeat bits, terminated by 1000...
; Source address in HL lets the repeat bits go straight to B,
; bypassing A and avoiding spilling registers to the stack.
ld b, [hl]
dec b
jr z, .sameboyLogoEnd
inc b
inc hl
; Shift a 1 into lower bit of shift value. Once this bit
; reaches the carry, B becomes 0 and the byte is over
scf
rl b
.loop
; If not a repeat, load a literal byte
jr c, .simple_repeat
sla b
jr c, .shifty_repeat
ld a, [hli]
jr .got_byte
.shifty_repeat
sla b
jr nz, .no_refill_during_shift
ld b, [hl] ; see above. Also, no, factoring it out into a callable
inc hl ; routine doesn't save bytes, even with conditional calls
scf
rl b
.no_refill_during_shift
ld c, a
jr nc, .shift_left
srl a
db $fe ; eat the add a with cp d8
.shift_left
add a
sla b
jr c, .go_and
or c
db $fe ; eat the and c with cp d8
.go_and
and c
jr .got_byte
.simple_repeat
sla b
jr c, .got_byte
; far repeat
dec de
ld a, [de]
inc de
.got_byte
inc de
ld [de], a
sla b
jr nz, .loop
jr .refill
; End PB12 decoding. The rest uses HL as the destination
.sameboyLogoEnd
ld h, d
ld l, $80
; Copy (unresized) ROM logo
ld de, $104
.CGBROMLogoLoop
ld c, $f0
call ReadCGBLogoHalfTile
add a, 22
ld e, a
call ReadCGBLogoHalfTile
sub a, 22
ld e, a
cp $1c
jr nz, .CGBROMLogoLoop
inc hl
; fallthrough
ReadTrademarkSymbol:
ld de, TrademarkSymbol
ld c,$08
.loadTrademarkSymbolLoop:
ld a,[de]
inc de
ldi [hl],a
inc hl
dec c
jr nz, .loadTrademarkSymbolLoop
ret
DoIntroAnimation:
; Animate the intro
ld a, 1
ldh [$4F], a
ld d, 26
.animationLoop
ld b, 2
call WaitBFrames
ld hl, $98C0
ld c, 3 ; Row count
.loop
ld a, [hl]
cp $F ; Already blue
jr z, .nextTile
inc [hl]
and $7
jr z, .nextLine ; Changed a white tile, go to next line
.nextTile
inc hl
jr .loop
.nextLine
ld a, l
or $1F
ld l, a
inc hl
dec c
jr nz, .loop
dec d
jr nz, .animationLoop
ret
Preboot:
IF !DEF(FAST)
ld b, 32 ; 32 times to fade
.fadeLoop
ld c, 32 ; 32 colors to fade
ld hl, BgPalettes
.frameLoop
push bc
; Brighten Color
ld a, [hli]
ld e, a
ld a, [hld]
ld d, a
; RGB(1,1,1)
ld bc, $421
; Is blue maxed?
ld a, e
and $1F
cp $1F
jr nz, .blueNotMaxed
dec c
.blueNotMaxed
; Is green maxed?
ld a, e
cp $E0
jr c, .greenNotMaxed
ld a, d
and $3
cp $3
jr nz, .greenNotMaxed
res 5, c
.greenNotMaxed
; Is red maxed?
ld a, d
and $7C
cp $7C
jr nz, .redNotMaxed
res 2, b
.redNotMaxed
; add de, bc
; ld [hli], de
ld a, e
add c
ld [hli], a
ld a, d
adc b
ld [hli], a
pop bc
dec c
jr nz, .frameLoop
call WaitFrame
call LoadPalettesFromHRAM
call WaitFrame
dec b
jr nz, .fadeLoop
ENDC
ld a, 1
call ClearVRAMViaHDMA
call _ClearVRAMViaHDMA
call ClearVRAMViaHDMA ; A = $40, so it's bank 0
ld a, $ff
ldh [$00], a
; Final values for CGB mode
ld d, a
ld e, c
ld l, $0d
ld a, [$143]
bit 7, a
call z, EmulateDMG
bit 7, a
ldh [$4C], a
ldh a, [TitleChecksum]
ld b, a
jr z, .skipDMGForCGBCheck
ldh a, [InputPalette]
and a
jr nz, .emulateDMGForCGBGame
.skipDMGForCGBCheck
IF DEF(AGB)
; Set registers to match the original AGB-CGB boot
; AF = $1100, C = 0
xor a
ld c, a
add a, $11
ld h, c
; B is set to 1 after ret
ELSE
; Set registers to match the original CGB boot
; AF = $1180, C = 0
xor a
ld c, a
ld a, $11
ld h, c
; B is set to the title checksum
ENDC
ret
.emulateDMGForCGBGame
call EmulateDMG
ldh [$4C], a
ld a, $1
ret
GetKeyComboPalette:
ld hl, KeyCombinationPalettes - 1 ; Return value is 1-based, 0 means nothing down
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
ret
EmulateDMG:
ld a, 1
ldh [$6C], a ; DMG Emulation
call GetPaletteIndex
bit 7, a
call nz, LoadDMGTilemap
and $7F
ld b, a
ldh a, [InputPalette]
and a
jr z, .nothingDown
call GetKeyComboPalette
jr .paletteFromKeys
.nothingDown
ld a, b
.paletteFromKeys
call WaitFrame
call LoadPalettesFromIndex
ld a, 4
; Set the final values for DMG mode
ld de, 8
ld l, $7c
ret
GetPaletteIndex:
ld hl, $14B
ld a, [hl] ; Old Licensee
cp $33
jr z, .newLicensee
dec a ; 1 = Nintendo
jr nz, .notNintendo
jr .doChecksum
.newLicensee
ld l, $44
ld a, [hli]
cp "0"
jr nz, .notNintendo
ld a, [hl]
cp "1"
jr nz, .notNintendo
.doChecksum
ld l, $34
ld c, $10
xor a
.checksumLoop
add [hl]
inc l
dec c
jr nz, .checksumLoop
ld b, a
; c = 0
ld hl, TitleChecksums
.searchLoop
ld a, l
sub LOW(ChecksumsEnd) ; use sub to zero out a
ret z
ld a, [hli]
cp b
jr nz, .searchLoop
; We might have a match, Do duplicate/4th letter check
ld a, l
sub FirstChecksumWithDuplicate - TitleChecksums
jr c, .match ; Does not have a duplicate, must be a match!
; Has a duplicate; check 4th letter
push hl
ld a, l
add Dups4thLetterArray - FirstChecksumWithDuplicate - 1 ; -1 since hl was incremented
ld l, a
ld a, [hl]
pop hl
ld c, a
ld a, [$134 + 3] ; Get 4th letter
cp c
jr nz, .searchLoop ; Not a match, continue
.match
ld a, l
add PalettePerChecksum - TitleChecksums - 1; -1 since hl was incremented
ld l, a
ld a, b
ldh [TitleChecksum], a
ld a, [hl]
ret
.notNintendo
xor a
ret
; optimizations in callers rely on this returning with b = 0
GetPaletteCombo:
ld hl, PaletteCombinations
ld b, 0
ld c, a
add hl, bc
ret
LoadPalettesFromIndex: ; a = index of combination
call GetPaletteCombo
; Obj Palettes
ld e, 0
.loadObjPalette
ld a, [hli]
push hl
ld hl, Palettes
; b is already 0
ld c, a
add hl, bc
ld d, 8
ld c, $6A
call LoadPalettes
pop hl
bit 3, e
jr nz, .loadBGPalette
ld e, 8
jr .loadObjPalette
.loadBGPalette
;BG Palette
ld c, [hl]
; b is already 0
ld hl, Palettes
add hl, bc
ld d, 8
jr LoadBGPalettes
LoadPalettesFromHRAM:
ld hl, BgPalettes
ld d, 64
LoadBGPalettes:
ld e, 0
ld c, $68
LoadPalettes:
ld a, $80
or e
ld [c], a
inc c
.loop
ld a, [hli]
ld [c], a
dec d
jr nz, .loop
ret
ClearVRAMViaHDMA:
ldh [$4F], a
ld hl, HDMAData
_ClearVRAMViaHDMA:
ld c, $51
ld b, 5
.loop
ld a, [hli]
ldh [c], a
inc c
dec b
jr nz, .loop
ret
; clobbers AF and HL
GetInputPaletteIndex:
ld a, $20 ; Select directions
ldh [$00], a
ldh a, [$00]
cpl
and $F
ret z ; No direction keys pressed, no palette
ld l, 0
.directionLoop
inc l
rra
jr nc, .directionLoop
; c = 1: Right, 2: Left, 3: Up, 4: Down
ld a, $10 ; Select buttons
ldh [$00], a
ldh a, [$00]
cpl
rla
rla
and $C
add l
ld l, a
ldh a, [InputPalette]
cp l
ret z ; No change, don't load
ld a, l
ldh [InputPalette], a
; Slide into change Animation Palette
ChangeAnimationPalette:
push bc
push de
call GetKeyComboPalette
call GetPaletteCombo
inc l
inc l
ld c, [hl]
ld hl, Palettes + 1
add hl, bc
ld a, [hld]
cp $7F ; Is white color?
jr nz, .isWhite
inc hl
inc hl
.isWhite
push af
ld a, [hli]
push hl
ld hl, BgPalettes ; First color, all palettes
call ReplaceColorInAllPalettes
ld l, LOW(BgPalettes + 2) ; Second color, all palettes
call ReplaceColorInAllPalettes
pop hl
ldh [BgPalettes + 6], a ; Fourth color, first palette
ld a, [hli]
push hl
ld hl, BgPalettes + 1 ; First color, all palettes
call ReplaceColorInAllPalettes
ld l, LOW(BgPalettes + 3) ; Second color, all palettes
call ReplaceColorInAllPalettes
pop hl
ldh [BgPalettes + 7], a ; Fourth color, first palette
pop af
jr z, .isNotWhite
inc hl
inc hl
.isNotWhite
; Mixing code by ISSOtm
ldh a, [BgPalettes + 7 * 8 + 2]
and ~$21
ld b, a
ld a, [hli]
and ~$21
add a, b
ld b, a
ld a, [BgPalettes + 7 * 8 + 3]
res 2, a ; and ~$04, but not touching carry
ld c, [hl]
res 2, c ; and ~$04, but not touching carry
adc a, c
rra ; Carry sort of "extends" the accumulator, we're bringing that bit back home
ld [BgPalettes + 7 * 8 + 3], a
ld a, b
rra
ld [BgPalettes + 7 * 8 + 2], a
dec l
ld a, [hli]
ldh [BgPalettes + 7 * 8 + 6], a ; Fourth color, 7th palette
ld a, [hli]
ldh [BgPalettes + 7 * 8 + 7], a ; Fourth color, 7th palette
ld a, [hli]
ldh [BgPalettes + 4], a ; Third color, first palette
ld a, [hli]
ldh [BgPalettes + 5], a ; Third color, first palette
call WaitFrame
call LoadPalettesFromHRAM
; Delay the wait loop while the user is selecting a palette
ld a, 45
ldh [WaitLoopCounter], a
pop de
pop bc
ret
ReplaceColorInAllPalettes:
ld de, 8
ld c, e
.loop
ld [hl], a
add hl, de
dec c
jr nz, .loop
ret
LoadDMGTilemap:
push af
call WaitFrame
ld a, $19 ; Trademark symbol
ld [$9910], a ; ... put in the superscript position
ld hl,$992f ; Bottom right corner of the logo
ld c,$c ; Tiles in a logo row
.tilemapLoop
dec a
jr z, .tilemapDone
ldd [hl], a
dec c
jr nz, .tilemapLoop
ld l, $0f ; Jump to top row
jr .tilemapLoop
.tilemapDone
pop af
ret
HDMAData:
db $88, $00, $98, $A0, $12
db $88, $00, $80, $00, $40
BootEnd:
IF BootEnd > $900
FAIL "BootROM overflowed: {BootEnd}"
ENDC
SECTION "HRAM", HRAM[$FF80]
TitleChecksum:
ds 1
BgPalettes:
ds 8 * 4 * 2
InputPalette:
ds 1
WaitLoopCounter:
ds 1
|
; uchar __FASTCALL__ *zx_cy2aaddr(uchar row)
; Stefano, 2014.12
SECTION code_clib
PUBLIC zx_cy2aaddr
PUBLIC _zx_cy2aaddr
EXTERN HRG_LineStart
.zx_cy2aaddr
._zx_cy2aaddr
ld a,l
; rra
; rra
; rra
and $1f
ld b,a
IF FORlambda
ld hl,8319
ELSE
ld hl,HRG_LineStart+2+32768
ENDIF
jr z,zrow
IF FORlambda
ld de,33
ELSE
ld de,35
ENDIF
.rloop
add hl,de
djnz rloop
.zrow
ret
|
;******************************************************************************
;* AAC Spectral Band Replication decoding functions
;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
;*
;* 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
; mask equivalent for multiply by -1.0 1.0
ps_mask times 2 dd 1<<31, 0
ps_mask2 times 2 dd 0, 1<<31
ps_mask3 dd 0, 0, 0, 1<<31
ps_noise0 times 2 dd 1.0, 0.0,
ps_noise2 times 2 dd -1.0, 0.0
ps_noise13 dd 0.0, 1.0, 0.0, -1.0
dd 0.0, -1.0, 0.0, 1.0
dd 0.0, 1.0, 0.0, -1.0
cextern sbr_noise_table
cextern ps_neg
SECTION_TEXT
INIT_XMM sse
cglobal sbr_sum_square, 2, 3, 6
mov r2, r1
xorps m0, m0
xorps m1, m1
sar r2, 3
jz .prepare
.loop:
movu m2, [r0 + 0]
movu m3, [r0 + 16]
movu m4, [r0 + 32]
movu m5, [r0 + 48]
mulps m2, m2
mulps m3, m3
mulps m4, m4
mulps m5, m5
addps m0, m2
addps m1, m3
addps m0, m4
addps m1, m5
add r0, 64
dec r2
jnz .loop
.prepare:
and r1, 7
sar r1, 1
jz .end
; len is a multiple of 2, thus there are at least 4 elements to process
.endloop:
movu m2, [r0]
add r0, 16
mulps m2, m2
dec r1
addps m0, m2
jnz .endloop
.end:
addps m0, m1
movhlps m2, m0
addps m0, m2
movss m1, m0
shufps m0, m0, 1
addss m0, m1
%if ARCH_X86_64 == 0
movss r0m, m0
fld dword r0m
%endif
RET
%define STEP 40*4*2
cglobal sbr_hf_g_filt, 5, 6, 5
lea r1, [r1 + 8*r4] ; offset by ixh elements into X_high
mov r5, r3
and r3, 0xFC
lea r2, [r2 + r3*4]
lea r0, [r0 + r3*8]
neg r3
jz .loop1
.loop4:
movlps m0, [r2 + 4*r3 + 0]
movlps m1, [r2 + 4*r3 + 8]
movlps m2, [r1 + 0*STEP]
movlps m3, [r1 + 2*STEP]
movhps m2, [r1 + 1*STEP]
movhps m3, [r1 + 3*STEP]
unpcklps m0, m0
unpcklps m1, m1
mulps m0, m2
mulps m1, m3
movu [r0 + 8*r3 + 0], m0
movu [r0 + 8*r3 + 16], m1
add r1, 4*STEP
add r3, 4
jnz .loop4
and r5, 3 ; number of single element loops
jz .end
.loop1: ; element 0 and 1 can be computed at the same time
movss m0, [r2]
movlps m2, [r1]
unpcklps m0, m0
mulps m2, m0
movlps [r0], m2
add r0, 8
add r2, 4
add r1, STEP
dec r5
jnz .loop1
.end:
RET
; void ff_sbr_hf_gen_sse(float (*X_high)[2], const float (*X_low)[2],
; const float alpha0[2], const float alpha1[2],
; float bw, int start, int end)
;
cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
; load alpha factors
%define bw m0
%if ARCH_X86_64 == 0 || WIN64
movss bw, BWm
%endif
movlps m2, [alpha1q]
movlps m1, [alpha0q]
shufps bw, bw, 0
mulps m2, bw ; (a1[0] a1[1])*bw
mulps m1, bw ; (a0[0] a0[1])*bw = (a2 a3)
mulps m2, bw ; (a1[0] a1[1])*bw*bw = (a0 a1)
mova m3, m1
mova m4, m2
; Set pointers
%if ARCH_X86_64 == 0 || WIN64
; start and end 6th and 7th args on stack
mov r2d, Sm
mov r3d, Em
%define start r2q
%define end r3q
%else
; BW does not actually occupy a register, so shift by 1
%define start BWq
%define end Sq
%endif
sub start, end ; neg num of loops
lea X_highq, [X_highq + end*2*4]
lea X_lowq, [X_lowq + end*2*4 - 2*2*4]
shl start, 3 ; offset from num loops
mova m0, [X_lowq + start]
shufps m3, m3, q1111
shufps m4, m4, q1111
xorps m3, [ps_mask]
shufps m1, m1, q0000
shufps m2, m2, q0000
xorps m4, [ps_mask]
.loop2:
movu m7, [X_lowq + start + 8] ; BbCc
mova m6, m0
mova m5, m7
shufps m0, m0, q2301 ; aAbB
shufps m7, m7, q2301 ; bBcC
mulps m0, m4
mulps m7, m3
mulps m6, m2
mulps m5, m1
addps m7, m0
mova m0, [X_lowq + start +16] ; CcDd
addps m7, m0
addps m6, m5
addps m7, m6
mova [X_highq + start], m7
add start, 16
jnz .loop2
RET
cglobal sbr_sum64x5, 1,2,4,z
lea r1q, [zq+ 256]
.loop:
mova m0, [zq+ 0]
mova m2, [zq+ 16]
mova m1, [zq+ 256]
mova m3, [zq+ 272]
addps m0, [zq+ 512]
addps m2, [zq+ 528]
addps m1, [zq+ 768]
addps m3, [zq+ 784]
addps m0, [zq+1024]
addps m2, [zq+1040]
addps m0, m1
addps m2, m3
mova [zq], m0
mova [zq+16], m2
add zq, 32
cmp zq, r1q
jne .loop
REP_RET
INIT_XMM sse
cglobal sbr_qmf_post_shuffle, 2,3,4,W,z
lea r2q, [zq + (64-4)*4]
mova m3, [ps_neg]
.loop:
mova m1, [zq]
xorps m0, m3, [r2q]
shufps m0, m0, m0, q0123
unpcklps m2, m0, m1
unpckhps m0, m0, m1
mova [Wq + 0], m2
mova [Wq + 16], m0
add Wq, 32
sub r2q, 16
add zq, 16
cmp zq, r2q
jl .loop
REP_RET
INIT_XMM sse
cglobal sbr_neg_odd_64, 1,2,4,z
lea r1q, [zq+256]
.loop:
mova m0, [zq+ 0]
mova m1, [zq+16]
mova m2, [zq+32]
mova m3, [zq+48]
xorps m0, [ps_mask2]
xorps m1, [ps_mask2]
xorps m2, [ps_mask2]
xorps m3, [ps_mask2]
mova [zq+ 0], m0
mova [zq+16], m1
mova [zq+32], m2
mova [zq+48], m3
add zq, 64
cmp zq, r1q
jne .loop
REP_RET
; void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1)
%macro SBR_QMF_DEINT_BFLY 0
cglobal sbr_qmf_deint_bfly, 3,5,8, v,src0,src1,vrev,c
mov cq, 64*4-2*mmsize
lea vrevq, [vq + 64*4]
.loop:
mova m0, [src0q+cq]
mova m1, [src1q]
mova m4, [src0q+cq+mmsize]
mova m5, [src1q+mmsize]
%if cpuflag(sse2)
pshufd m2, m0, q0123
pshufd m3, m1, q0123
pshufd m6, m4, q0123
pshufd m7, m5, q0123
%else
shufps m2, m0, m0, q0123
shufps m3, m1, m1, q0123
shufps m6, m4, m4, q0123
shufps m7, m5, m5, q0123
%endif
addps m5, m2
subps m0, m7
addps m1, m6
subps m4, m3
mova [vrevq], m1
mova [vrevq+mmsize], m5
mova [vq+cq], m0
mova [vq+cq+mmsize], m4
add src1q, 2*mmsize
add vrevq, 2*mmsize
sub cq, 2*mmsize
jge .loop
REP_RET
%endmacro
INIT_XMM sse
SBR_QMF_DEINT_BFLY
INIT_XMM sse2
SBR_QMF_DEINT_BFLY
INIT_XMM sse2
cglobal sbr_qmf_pre_shuffle, 1,4,6,z
%define OFFSET (32*4-2*mmsize)
mov r3q, OFFSET
lea r1q, [zq + (32+1)*4]
lea r2q, [zq + 64*4]
mova m5, [ps_neg]
.loop:
movu m0, [r1q]
movu m2, [r1q + mmsize]
movu m1, [zq + r3q + 4 + mmsize]
movu m3, [zq + r3q + 4]
pxor m2, m5
pxor m0, m5
pshufd m2, m2, q0123
pshufd m0, m0, q0123
SBUTTERFLY dq, 2, 3, 4
SBUTTERFLY dq, 0, 1, 4
mova [r2q + 2*r3q + 0*mmsize], m2
mova [r2q + 2*r3q + 1*mmsize], m3
mova [r2q + 2*r3q + 2*mmsize], m0
mova [r2q + 2*r3q + 3*mmsize], m1
add r1q, 2*mmsize
sub r3q, 2*mmsize
jge .loop
movq m2, [zq]
movq [r2q], m2
REP_RET
%ifdef PIC
%define NREGS 1
%if UNIX64
%define NOISE_TABLE r6q ; r5q is m_max
%else
%define NOISE_TABLE r5q
%endif
%else
%define NREGS 0
%define NOISE_TABLE sbr_noise_table
%endif
%macro LOAD_NST 1
%ifdef PIC
lea NOISE_TABLE, [%1]
mova m0, [kxq + NOISE_TABLE]
%else
mova m0, [kxq + %1]
%endif
%endmacro
INIT_XMM sse2
; sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m,
; const float *q_filt, int noise,
; int kx, int m_max)
cglobal sbr_hf_apply_noise_0, 5,5+NREGS+UNIX64,8, Y,s_m,q_filt,noise,kx,m_max
mova m0, [ps_noise0]
jmp apply_noise_main
; sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m,
; const float *q_filt, int noise,
; int kx, int m_max)
cglobal sbr_hf_apply_noise_1, 5,5+NREGS+UNIX64,8, Y,s_m,q_filt,noise,kx,m_max
and kxq, 1
shl kxq, 4
LOAD_NST ps_noise13
jmp apply_noise_main
; sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m,
; const float *q_filt, int noise,
; int kx, int m_max)
cglobal sbr_hf_apply_noise_2, 5,5+NREGS+UNIX64,8, Y,s_m,q_filt,noise,kx,m_max
mova m0, [ps_noise2]
jmp apply_noise_main
; sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m,
; const float *q_filt, int noise,
; int kx, int m_max)
cglobal sbr_hf_apply_noise_3, 5,5+NREGS+UNIX64,8, Y,s_m,q_filt,noise,kx,m_max
and kxq, 1
shl kxq, 4
LOAD_NST ps_noise13+16
apply_noise_main:
%if ARCH_X86_64 == 0 || WIN64
mov kxd, m_maxm
%define count kxq
%else
%define count m_maxq
%endif
dec noiseq
shl count, 2
%ifdef PIC
lea NOISE_TABLE, [sbr_noise_table]
%endif
lea Yq, [Yq + 2*count]
add s_mq, count
add q_filtq, count
shl noiseq, 3
pxor m5, m5
neg count
.loop:
mova m1, [q_filtq + count]
movu m3, [noiseq + NOISE_TABLE + 1*mmsize]
movu m4, [noiseq + NOISE_TABLE + 2*mmsize]
add noiseq, 2*mmsize
and noiseq, 0x1ff<<3
punpckhdq m2, m1, m1
punpckldq m1, m1
mulps m1, m3 ; m2 = q_filt[m] * ff_sbr_noise_table[noise]
mulps m2, m4 ; m2 = q_filt[m] * ff_sbr_noise_table[noise]
mova m3, [s_mq + count]
; TODO: replace by a vpermd in AVX2
punpckhdq m4, m3, m3
punpckldq m3, m3
pcmpeqd m6, m3, m5 ; m6 == 0
pcmpeqd m7, m4, m5 ; m7 == 0
mulps m3, m0 ; s_m[m] * phi_sign
mulps m4, m0 ; s_m[m] * phi_sign
pand m1, m6
pand m2, m7
movu m6, [Yq + 2*count]
movu m7, [Yq + 2*count + mmsize]
addps m3, m1
addps m4, m2
addps m6, m3
addps m7, m4
movu [Yq + 2*count], m6
movu [Yq + 2*count + mmsize], m7
add count, mmsize
jl .loop
RET
INIT_XMM sse
cglobal sbr_qmf_deint_neg, 2,4,4,v,src,vrev,c
%define COUNT 32*4
%define OFFSET 32*4
mov cq, -COUNT
lea vrevq, [vq + OFFSET + COUNT]
add vq, OFFSET-mmsize
add srcq, 2*COUNT
mova m3, [ps_neg]
.loop:
mova m0, [srcq + 2*cq + 0*mmsize]
mova m1, [srcq + 2*cq + 1*mmsize]
shufps m2, m0, m1, q2020
shufps m1, m0, q1313
xorps m2, m3
mova [vq], m1
mova [vrevq + cq], m2
sub vq, mmsize
add cq, mmsize
jl .loop
REP_RET
%macro SBR_AUTOCORRELATE 0
cglobal sbr_autocorrelate, 2,3,8,32, x, phi, cnt
mov cntq, 37*8
add xq, cntq
neg cntq
%if cpuflag(sse3)
%define MOVH movsd
movddup m5, [xq+cntq]
%else
%define MOVH movlps
movlps m5, [xq+cntq]
movlhps m5, m5
%endif
MOVH m7, [xq+cntq+8 ]
MOVH m1, [xq+cntq+16]
shufps m7, m7, q0110
shufps m1, m1, q0110
mulps m3, m5, m7 ; x[0][0] * x[1][0], x[0][1] * x[1][1], x[0][0] * x[1][1], x[0][1] * x[1][0]
mulps m4, m5, m5 ; x[0][0] * x[0][0], x[0][1] * x[0][1];
mulps m5, m1 ; real_sum2 = x[0][0] * x[2][0], x[0][1] * x[2][1]; imag_sum2 = x[0][0] * x[2][1], x[0][1] * x[2][0]
movaps [rsp ], m3
movaps [rsp+16], m4
add cntq, 8
MOVH m2, [xq+cntq+16]
movlhps m7, m7
shufps m2, m2, q0110
mulps m6, m7, m1 ; real_sum1 = x[1][0] * x[2][0], x[1][1] * x[2][1]; imag_sum1 += x[1][0] * x[2][1], x[1][1] * x[2][0]
mulps m4, m7, m2
mulps m7, m7 ; real_sum0 = x[1][0] * x[1][0], x[1][1] * x[1][1];
addps m5, m4 ; real_sum2 += x[1][0] * x[3][0], x[1][1] * x[3][1]; imag_sum2 += x[1][0] * x[3][1], x[1][1] * x[3][0]
align 16
.loop:
add cntq, 8
MOVH m0, [xq+cntq+16]
movlhps m1, m1
shufps m0, m0, q0110
mulps m3, m1, m2
mulps m4, m1, m0
mulps m1, m1
addps m6, m3 ; real_sum1 += x[i][0] * x[i + 1][0], x[i][1] * x[i + 1][1]; imag_sum1 += x[i][0] * x[i + 1][1], x[i][1] * x[i + 1][0];
addps m5, m4 ; real_sum2 += x[i][0] * x[i + 2][0], x[i][1] * x[i + 2][1]; imag_sum2 += x[i][0] * x[i + 2][1], x[i][1] * x[i + 2][0];
addps m7, m1 ; real_sum0 += x[i][0] * x[i][0], x[i][1] * x[i][1];
add cntq, 8
MOVH m1, [xq+cntq+16]
movlhps m2, m2
shufps m1, m1, q0110
mulps m3, m2, m0
mulps m4, m2, m1
mulps m2, m2
addps m6, m3 ; real_sum1 += x[i][0] * x[i + 1][0], x[i][1] * x[i + 1][1]; imag_sum1 += x[i][0] * x[i + 1][1], x[i][1] * x[i + 1][0];
addps m5, m4 ; real_sum2 += x[i][0] * x[i + 2][0], x[i][1] * x[i + 2][1]; imag_sum2 += x[i][0] * x[i + 2][1], x[i][1] * x[i + 2][0];
addps m7, m2 ; real_sum0 += x[i][0] * x[i][0], x[i][1] * x[i][1];
add cntq, 8
MOVH m2, [xq+cntq+16]
movlhps m0, m0
shufps m2, m2, q0110
mulps m3, m0, m1
mulps m4, m0, m2
mulps m0, m0
addps m6, m3 ; real_sum1 += x[i][0] * x[i + 1][0], x[i][1] * x[i + 1][1]; imag_sum1 += x[i][0] * x[i + 1][1], x[i][1] * x[i + 1][0];
addps m5, m4 ; real_sum2 += x[i][0] * x[i + 2][0], x[i][1] * x[i + 2][1]; imag_sum2 += x[i][0] * x[i + 2][1], x[i][1] * x[i + 2][0];
addps m7, m0 ; real_sum0 += x[i][0] * x[i][0], x[i][1] * x[i][1];
jl .loop
movlhps m1, m1
mulps m4, m1, m2
mulps m1, m1
addps m4, m6 ; real_sum1 + x[38][0] * x[39][0], x[38][1] * x[39][1]; imag_sum1 + x[38][0] * x[39][1], x[38][1] * x[39][0];
addps m1, m7 ; real_sum0 + x[38][0] * x[38][0], x[38][1] * x[38][1];
addps m6, [rsp ] ; real_sum1 + x[ 0][0] * x[ 1][0], x[ 0][1] * x[ 1][1]; imag_sum1 + x[ 0][0] * x[ 1][1], x[ 0][1] * x[ 1][0];
addps m7, [rsp+16] ; real_sum0 + x[ 0][0] * x[ 0][0], x[ 0][1] * x[ 0][1];
xorps m4, [ps_mask3]
xorps m5, [ps_mask3]
xorps m6, [ps_mask3]
%if cpuflag(sse3)
movshdup m2, m1
haddps m4, m5
haddps m7, m6
addss m1, m2
%else
movaps m3, m4
movaps m2, m5
movaps m0, m6
shufps m3, m3, q0301
shufps m2, m2, q0301
shufps m0, m0, q0301
addps m4, m3
addps m5, m2
addps m6, m0
movss m2, m7
movss m3, m1
shufps m7, m7, q0001
shufps m1, m1, q0001
addss m7, m2
addss m1, m3
shufps m4, m5, q2020
shufps m7, m6, q2020
%endif
movaps [phiq ], m4
movhps [phiq+0x18], m7
movss [phiq+0x28], m7
movss [phiq+0x10], m1
RET
%endmacro
INIT_XMM sse
SBR_AUTOCORRELATE
INIT_XMM sse3
SBR_AUTOCORRELATE
|
; A114607: Start with 1 0 1 0 then add a one every time (e.g. 1 1 0 1 1 1 0 1 1 1 1 0 ...).
; 1,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1
sub $0,1
lpb $0
add $2,1
sub $0,$2
sub $0,1
lpe
lpb $0
div $0,5
mov $1,1
lpe
|
LMNefertite label byte
word C_BLACK
Bitmap <71,100,0,BMF_MONO>
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04
db 0x00, 0x02, 0x10, 0x22, 0x40, 0x88, 0x88, 0x00,
0x84
db 0x00, 0x81, 0x00, 0x80, 0x00, 0x20, 0x21, 0x04,
0x44
db 0x80, 0x10, 0x00, 0x01, 0x08, 0x00, 0x44, 0x20,
0x0c
db 0xa0, 0x00, 0x00, 0x90, 0x00, 0x10, 0x00, 0x40,
0x1f
db 0xa2, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xbf
db 0x85, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x77
db 0x82, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xbf
db 0x95, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x7f
db 0x8a, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xbf
db 0x95, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x77
db 0x82, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa,
0xbf
db 0xc5, 0x55, 0x55, 0x54, 0x01, 0x55, 0x55, 0x55,
0x7f
db 0x82, 0xaa, 0xaa, 0xa0, 0x00, 0xaa, 0xaa, 0xaa,
0xbf
db 0x85, 0x55, 0x55, 0x40, 0x00, 0x55, 0x55, 0x55,
0x7f
db 0xc2, 0xaa, 0xaa, 0x80, 0x00, 0x6a, 0xaa, 0xaa,
0xaf
db 0x95, 0x55, 0x54, 0x00, 0x00, 0x35, 0x55, 0x55,
0x7f
db 0x82, 0xaa, 0xa8, 0x00, 0x00, 0x1a, 0xaa, 0xaa,
0xb7
db 0x95, 0x55, 0x50, 0x00, 0x00, 0x15, 0x55, 0x55,
0x7f
db 0x82, 0xaa, 0xa0, 0x00, 0x03, 0xfa, 0xaa, 0xaa,
0xbf
db 0x85, 0x55, 0x40, 0x00, 0x1d, 0x55, 0x55, 0x55,
0x7f
db 0x8a, 0xaa, 0x80, 0x00, 0x6a, 0xaa, 0xaa, 0xaa,
0xbf
db 0x95, 0x55, 0x00, 0x00, 0xd5, 0x03, 0x55, 0x55,
0x7c
db 0x82, 0xa8, 0x00, 0x03, 0xa8, 0x02, 0xaa, 0xaa,
0xbf
db 0x85, 0x50, 0x00, 0x05, 0x40, 0x01, 0x55, 0x55,
0x7f
db 0x82, 0xa0, 0x00, 0x0a, 0x80, 0x00, 0xaa, 0xaa,
0xbf
db 0xc5, 0x40, 0x00, 0x35, 0x00, 0x00, 0xd5, 0x55,
0x7f
db 0x82, 0x80, 0x00, 0x6a, 0x00, 0x00, 0x6a, 0xaa,
0xb7
db 0xc5, 0x40, 0x00, 0xd4, 0x00, 0x00, 0x55, 0x55,
0x7f
db 0x82, 0xa0, 0x01, 0xa0, 0x00, 0x00, 0x2a, 0xaa,
0xbf
db 0x95, 0x50, 0x01, 0x40, 0x00, 0x00, 0x75, 0x55,
0x6f
db 0x82, 0xa8, 0x02, 0x80, 0x00, 0x01, 0xaa, 0xaa,
0xbf
db 0x85, 0x54, 0x05, 0x00, 0x00, 0x03, 0x55, 0x55,
0x7f
db 0x82, 0xaa, 0x0a, 0x80, 0x00, 0x0e, 0xaa, 0xaa,
0xb7
db 0xa5, 0x55, 0x0d, 0x00, 0x0c, 0x15, 0x55, 0x55,
0x7f
db 0x82, 0xaa, 0x9a, 0x00, 0x78, 0x2a, 0x86, 0xaa,
0xaf
db 0x85, 0x55, 0x54, 0x03, 0xd0, 0x15, 0x05, 0x55,
0x7f
db 0xa2, 0xaa, 0xab, 0xfe, 0xa8, 0x0a, 0x02, 0xaa,
0xbf
db 0xc5, 0x55, 0x55, 0x55, 0x50, 0x0c, 0x03, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xaa, 0x00, 0x08, 0x19, 0xaa,
0xbf
db 0x85, 0x55, 0x54, 0x00, 0x00, 0x10, 0x65, 0x55,
0x77
db 0x82, 0xaa, 0xaa, 0x00, 0x00, 0xe0, 0x18, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x00, 0x01, 0x00, 0x28, 0x55,
0x74
db 0x92, 0xaa, 0xaa, 0x80, 0x06, 0x60, 0x00, 0x2a,
0xbc
db 0x85, 0x55, 0x55, 0x40, 0x0c, 0x20, 0x00, 0x15,
0x7c
db 0x82, 0xaa, 0xaa, 0xa0, 0x1a, 0x40, 0x00, 0x0a,
0xbc
db 0x95, 0x55, 0x55, 0x50, 0x34, 0x10, 0x00, 0x0d,
0x74
db 0x82, 0xaa, 0xaa, 0xa8, 0x69, 0x10, 0x00, 0x1a,
0xbc
db 0x95, 0x55, 0x55, 0x54, 0xd0, 0x80, 0x00, 0x75,
0x6c
db 0x82, 0xaa, 0xaa, 0xaa, 0xa0, 0x88, 0x00, 0x2a,
0xbc
db 0xa5, 0x55, 0x55, 0x55, 0x40, 0x70, 0x00, 0x35,
0x7c
db 0x82, 0xaa, 0xaa, 0xaa, 0xa0, 0x00, 0x00, 0xea,
0xb4
db 0x85, 0x55, 0x55, 0x55, 0x40, 0x00, 0x00, 0x75,
0x7c
db 0x8a, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x00, 0x2a,
0xbc
db 0x85, 0x55, 0x55, 0x55, 0x40, 0x00, 0x00, 0x35,
0x7c
db 0xa2, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x00, 0x2a,
0xbc
db 0x85, 0x55, 0x55, 0x55, 0x40, 0x00, 0x1f, 0xd5,
0x74
db 0xa2, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x2a, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x55, 0x00, 0x00, 0x35, 0x55,
0x7c
db 0xb2, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x6a, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x54, 0x00, 0x00, 0xd5, 0x55,
0x6c
db 0x8a, 0xaa, 0xaa, 0xa8, 0x00, 0x01, 0xaa, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x50, 0x00, 0x01, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xa0, 0x00, 0x02, 0xaa, 0xaa,
0xb4
db 0xa5, 0x55, 0x55, 0x40, 0x00, 0x05, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xa0, 0x00, 0x06, 0xaa, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x40, 0x00, 0x0d, 0x55, 0x55,
0x7c
db 0xca, 0xaa, 0xaa, 0xbe, 0x00, 0x0a, 0xaa, 0xaa,
0xb4
db 0xc5, 0x55, 0x55, 0x55, 0x80, 0x15, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0x01, 0x40, 0x2a, 0xaa, 0xaa,
0xb4
db 0x85, 0x55, 0x54, 0x00, 0x20, 0x35, 0x55, 0x55,
0x7c
db 0xe2, 0xaa, 0xa8, 0x00, 0x50, 0x2a, 0xaa, 0xaa,
0xb8
db 0x85, 0x55, 0x50, 0x00, 0x08, 0x35, 0x55, 0x55,
0x6c
db 0x82, 0xaa, 0xa8, 0x00, 0x18, 0x2a, 0xaa, 0xaa,
0xbc
db 0xc5, 0x55, 0x50, 0x00, 0x0f, 0xd5, 0x55, 0x55,
0x7c
db 0x92, 0xaa, 0xa0, 0x00, 0x05, 0x5a, 0xaa, 0xaa,
0xb4
db 0x85, 0x55, 0x50, 0x00, 0x00, 0x15, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xa0, 0x00, 0x00, 0x1a, 0xaa, 0xaa,
0xbc
db 0x95, 0x55, 0x40, 0x00, 0x00, 0x15, 0x55, 0x55,
0x7c
db 0xd2, 0xaa, 0xa0, 0x00, 0x00, 0x1a, 0xaa, 0xaa,
0xb4
db 0x85, 0x55, 0x40, 0x00, 0x00, 0x15, 0x55, 0x55,
0x78
db 0xa2, 0xaa, 0x80, 0x00, 0x00, 0x1a, 0xaa, 0xaa,
0xbc
db 0x85, 0x55, 0x40, 0x00, 0x00, 0x15, 0x55, 0x55,
0x74
db 0x92, 0xaa, 0x98, 0x00, 0x00, 0x1a, 0xaa, 0xaa,
0xbc
db 0x8d, 0x55, 0x57, 0xc0, 0x00, 0xf5, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xbf, 0xff, 0xaa, 0xaa, 0xaa,
0xac
db 0x85, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x7c
db 0xa2, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xb8
db 0x85, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xb4
db 0xa5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x7c
db 0x82, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xbc
db 0x85, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x6c
db 0x82, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xfc
db 0x95, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xf8
db 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfc
db 0x8d, 0xfd, 0xbd, 0x7e, 0xfb, 0xef, 0xed, 0xdf,
0xf8
db 0x17, 0xaf, 0xff, 0xef, 0xff, 0xbd, 0xdf, 0x7f,
0x78
db 0x0f, 0xfb, 0xf7, 0xff, 0xbe, 0xff, 0x7f, 0xdf,
0xe0
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00
|
lsrq {z1}
lsrq {z1} |
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
EXTERN OPENSSL_ia32cap_P
global rsaz_512_sqr
ALIGN 32
rsaz_512_sqr:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_sqr:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$sqr_body:
mov rbp,rdx
mov rdx,QWORD[rsi]
mov rax,QWORD[8+rsi]
mov QWORD[128+rsp],rcx
jmp NEAR $L$oop_sqr
ALIGN 32
$L$oop_sqr:
mov DWORD[((128+8))+rsp],r8d
mov rbx,rdx
mul rdx
mov r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
mul rbx
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
add r14,rax
mov rax,rbx
mov r15,rdx
adc r15,0
add r8,r8
mov rcx,r9
adc r9,r9
mul rax
mov QWORD[rsp],rax
add r8,rdx
adc r9,0
mov QWORD[8+rsp],r8
shr rcx,63
mov r8,QWORD[8+rsi]
mov rax,QWORD[16+rsi]
mul r8
add r10,rax
mov rax,QWORD[24+rsi]
mov rbx,rdx
adc rbx,0
mul r8
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r11,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r12,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r13,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r14,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r15,rax
mov rax,r8
adc rdx,0
add r15,rbx
mov r8,rdx
mov rdx,r10
adc r8,0
add rdx,rdx
lea r10,[r10*2+rcx]
mov rbx,r11
adc r11,r11
mul rax
add r9,rax
adc r10,rdx
adc r11,0
mov QWORD[16+rsp],r9
mov QWORD[24+rsp],r10
shr rbx,63
mov r9,QWORD[16+rsi]
mov rax,QWORD[24+rsi]
mul r9
add r12,rax
mov rax,QWORD[32+rsi]
mov rcx,rdx
adc rcx,0
mul r9
add r13,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r13,rcx
mov rcx,rdx
adc rcx,0
mul r9
add r14,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r14,rcx
mov rcx,rdx
adc rcx,0
mul r9
mov r10,r12
lea r12,[r12*2+rbx]
add r15,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r15,rcx
mov rcx,rdx
adc rcx,0
mul r9
shr r10,63
add r8,rax
mov rax,r9
adc rdx,0
add r8,rcx
mov r9,rdx
adc r9,0
mov rcx,r13
lea r13,[r13*2+r10]
mul rax
add r11,rax
adc r12,rdx
adc r13,0
mov QWORD[32+rsp],r11
mov QWORD[40+rsp],r12
shr rcx,63
mov r10,QWORD[24+rsi]
mov rax,QWORD[32+rsi]
mul r10
add r14,rax
mov rax,QWORD[40+rsi]
mov rbx,rdx
adc rbx,0
mul r10
add r15,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r15,rbx
mov rbx,rdx
adc rbx,0
mul r10
mov r12,r14
lea r14,[r14*2+rcx]
add r8,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r8,rbx
mov rbx,rdx
adc rbx,0
mul r10
shr r12,63
add r9,rax
mov rax,r10
adc rdx,0
add r9,rbx
mov r10,rdx
adc r10,0
mov rbx,r15
lea r15,[r15*2+r12]
mul rax
add r13,rax
adc r14,rdx
adc r15,0
mov QWORD[48+rsp],r13
mov QWORD[56+rsp],r14
shr rbx,63
mov r11,QWORD[32+rsi]
mov rax,QWORD[40+rsi]
mul r11
add r8,rax
mov rax,QWORD[48+rsi]
mov rcx,rdx
adc rcx,0
mul r11
add r9,rax
mov rax,QWORD[56+rsi]
adc rdx,0
mov r12,r8
lea r8,[r8*2+rbx]
add r9,rcx
mov rcx,rdx
adc rcx,0
mul r11
shr r12,63
add r10,rax
mov rax,r11
adc rdx,0
add r10,rcx
mov r11,rdx
adc r11,0
mov rcx,r9
lea r9,[r9*2+r12]
mul rax
add r15,rax
adc r8,rdx
adc r9,0
mov QWORD[64+rsp],r15
mov QWORD[72+rsp],r8
shr rcx,63
mov r12,QWORD[40+rsi]
mov rax,QWORD[48+rsi]
mul r12
add r10,rax
mov rax,QWORD[56+rsi]
mov rbx,rdx
adc rbx,0
mul r12
add r11,rax
mov rax,r12
mov r15,r10
lea r10,[r10*2+rcx]
adc rdx,0
shr r15,63
add r11,rbx
mov r12,rdx
adc r12,0
mov rbx,r11
lea r11,[r11*2+r15]
mul rax
add r9,rax
adc r10,rdx
adc r11,0
mov QWORD[80+rsp],r9
mov QWORD[88+rsp],r10
mov r13,QWORD[48+rsi]
mov rax,QWORD[56+rsi]
mul r13
add r12,rax
mov rax,r13
mov r13,rdx
adc r13,0
xor r14,r14
shl rbx,1
adc r12,r12
adc r13,r13
adc r14,r14
mul rax
add r11,rax
adc r12,rdx
adc r13,0
mov QWORD[96+rsp],r11
mov QWORD[104+rsp],r12
mov rax,QWORD[56+rsi]
mul rax
add r13,rax
adc rdx,0
add r14,rdx
mov QWORD[112+rsp],r13
mov QWORD[120+rsp],r14
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
mov rdx,r8
mov rax,r9
mov r8d,DWORD[((128+8))+rsp]
mov rsi,rdi
dec r8d
jnz NEAR $L$oop_sqr
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$sqr_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_sqr:
global rsaz_512_mul
ALIGN 32
rsaz_512_mul:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$mul_body:
DB 102,72,15,110,199
DB 102,72,15,110,201
mov QWORD[128+rsp],r8
mov rbx,QWORD[rdx]
mov rbp,rdx
call __rsaz_512_mul
DB 102,72,15,126,199
DB 102,72,15,126,205
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul:
global rsaz_512_mul_gather4
ALIGN 32
rsaz_512_mul_gather4:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_gather4:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
mov r9,QWORD[48+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
mov r9d,r9d
sub rsp,128+24
$L$mul_gather4_body:
mov eax,DWORD[64+r9*4+rdx]
DB 102,72,15,110,199
mov ebx,DWORD[r9*4+rdx]
DB 102,72,15,110,201
mov QWORD[128+rsp],r8
shl rax,32
or rbx,rax
mov rax,QWORD[rsi]
mov rcx,QWORD[8+rsi]
lea rbp,[128+r9*4+rdx]
mul rbx
mov QWORD[rsp],rax
mov rax,rcx
mov r8,rdx
mul rbx
movd xmm4,DWORD[rbp]
add r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
adc r9,0
mul rbx
movd xmm5,DWORD[64+rbp]
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
pslldq xmm5,4
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
por xmm4,xmm5
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
lea rbp,[128+rbp]
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
DB 102,72,15,126,227
add r14,rax
mov rax,QWORD[rsi]
mov r15,rdx
adc r15,0
lea rdi,[8+rsp]
mov ecx,7
jmp NEAR $L$oop_mul_gather
ALIGN 32
$L$oop_mul_gather:
mul rbx
add r8,rax
mov rax,QWORD[8+rsi]
mov QWORD[rdi],r8
mov r8,rdx
adc r8,0
mul rbx
movd xmm4,DWORD[rbp]
add r9,rax
mov rax,QWORD[16+rsi]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
movd xmm5,DWORD[64+rbp]
add r10,rax
mov rax,QWORD[24+rsi]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
pslldq xmm5,4
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r10,r11
mov r11,rdx
adc r11,0
mul rbx
por xmm4,xmm5
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r13,r14
mov r14,rdx
adc r14,0
mul rbx
DB 102,72,15,126,227
add r15,rax
mov rax,QWORD[rsi]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
lea rbp,[128+rbp]
lea rdi,[8+rdi]
dec ecx
jnz NEAR $L$oop_mul_gather
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
DB 102,72,15,126,199
DB 102,72,15,126,205
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_gather4_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_gather4:
global rsaz_512_mul_scatter4
ALIGN 32
rsaz_512_mul_scatter4:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_scatter4:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
mov r9,QWORD[48+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
mov r9d,r9d
sub rsp,128+24
$L$mul_scatter4_body:
lea r8,[r9*4+r8]
DB 102,72,15,110,199
DB 102,72,15,110,202
DB 102,73,15,110,208
mov QWORD[128+rsp],rcx
mov rbp,rdi
mov rbx,QWORD[rdi]
call __rsaz_512_mul
DB 102,72,15,126,199
DB 102,72,15,126,205
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
DB 102,72,15,126,214
sbb rcx,rcx
call __rsaz_512_subtract
mov DWORD[rsi],r8d
shr r8,32
mov DWORD[128+rsi],r9d
shr r9,32
mov DWORD[256+rsi],r10d
shr r10,32
mov DWORD[384+rsi],r11d
shr r11,32
mov DWORD[512+rsi],r12d
shr r12,32
mov DWORD[640+rsi],r13d
shr r13,32
mov DWORD[768+rsi],r14d
shr r14,32
mov DWORD[896+rsi],r15d
shr r15,32
mov DWORD[64+rsi],r8d
mov DWORD[192+rsi],r9d
mov DWORD[320+rsi],r10d
mov DWORD[448+rsi],r11d
mov DWORD[576+rsi],r12d
mov DWORD[704+rsi],r13d
mov DWORD[832+rsi],r14d
mov DWORD[960+rsi],r15d
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_scatter4_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_scatter4:
global rsaz_512_mul_by_one
ALIGN 32
rsaz_512_mul_by_one:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_by_one:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$mul_by_one_body:
mov rbp,rdx
mov QWORD[128+rsp],rcx
mov r8,QWORD[rsi]
pxor xmm0,xmm0
mov r9,QWORD[8+rsi]
mov r10,QWORD[16+rsi]
mov r11,QWORD[24+rsi]
mov r12,QWORD[32+rsi]
mov r13,QWORD[40+rsi]
mov r14,QWORD[48+rsi]
mov r15,QWORD[56+rsi]
movdqa XMMWORD[rsp],xmm0
movdqa XMMWORD[16+rsp],xmm0
movdqa XMMWORD[32+rsp],xmm0
movdqa XMMWORD[48+rsp],xmm0
movdqa XMMWORD[64+rsp],xmm0
movdqa XMMWORD[80+rsp],xmm0
movdqa XMMWORD[96+rsp],xmm0
call __rsaz_512_reduce
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_by_one_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_by_one:
ALIGN 32
__rsaz_512_reduce:
mov rbx,r8
imul rbx,QWORD[((128+8))+rsp]
mov rax,QWORD[rbp]
mov ecx,8
jmp NEAR $L$reduction_loop
ALIGN 32
$L$reduction_loop:
mul rbx
mov rax,QWORD[8+rbp]
neg r8
mov r8,rdx
adc r8,0
mul rbx
add r9,rax
mov rax,QWORD[16+rbp]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
add r10,rax
mov rax,QWORD[24+rbp]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
add r11,rax
mov rax,QWORD[32+rbp]
adc rdx,0
add r10,r11
mov rsi,QWORD[((128+8))+rsp]
adc rdx,0
mov r11,rdx
mul rbx
add r12,rax
mov rax,QWORD[40+rbp]
adc rdx,0
imul rsi,r8
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rbp]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rbp]
adc rdx,0
add r13,r14
mov r14,rdx
adc r14,0
mul rbx
mov rbx,rsi
add r15,rax
mov rax,QWORD[rbp]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
dec ecx
jne NEAR $L$reduction_loop
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_subtract:
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
mov r8,QWORD[rbp]
mov r9,QWORD[8+rbp]
neg r8
not r9
and r8,rcx
mov r10,QWORD[16+rbp]
and r9,rcx
not r10
mov r11,QWORD[24+rbp]
and r10,rcx
not r11
mov r12,QWORD[32+rbp]
and r11,rcx
not r12
mov r13,QWORD[40+rbp]
and r12,rcx
not r13
mov r14,QWORD[48+rbp]
and r13,rcx
not r14
mov r15,QWORD[56+rbp]
and r14,rcx
not r15
and r15,rcx
add r8,QWORD[rdi]
adc r9,QWORD[8+rdi]
adc r10,QWORD[16+rdi]
adc r11,QWORD[24+rdi]
adc r12,QWORD[32+rdi]
adc r13,QWORD[40+rdi]
adc r14,QWORD[48+rdi]
adc r15,QWORD[56+rdi]
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_mul:
lea rdi,[8+rsp]
mov rax,QWORD[rsi]
mul rbx
mov QWORD[rdi],rax
mov rax,QWORD[8+rsi]
mov r8,rdx
mul rbx
add r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
adc r9,0
mul rbx
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
add r14,rax
mov rax,QWORD[rsi]
mov r15,rdx
adc r15,0
lea rbp,[8+rbp]
lea rdi,[8+rdi]
mov ecx,7
jmp NEAR $L$oop_mul
ALIGN 32
$L$oop_mul:
mov rbx,QWORD[rbp]
mul rbx
add r8,rax
mov rax,QWORD[8+rsi]
mov QWORD[rdi],r8
mov r8,rdx
adc r8,0
mul rbx
add r9,rax
mov rax,QWORD[16+rsi]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
add r10,rax
mov rax,QWORD[24+rsi]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r10,r11
mov r11,rdx
adc r11,0
mul rbx
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r13,r14
mov r14,rdx
lea rbp,[8+rbp]
adc r14,0
mul rbx
add r15,rax
mov rax,QWORD[rsi]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
lea rdi,[8+rdi]
dec ecx
jnz NEAR $L$oop_mul
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
DB 0F3h,0C3h ;repret
global rsaz_512_scatter4
ALIGN 16
rsaz_512_scatter4:
lea rcx,[r8*4+rcx]
mov r9d,8
jmp NEAR $L$oop_scatter
ALIGN 16
$L$oop_scatter:
mov rax,QWORD[rdx]
lea rdx,[8+rdx]
mov DWORD[rcx],eax
shr rax,32
mov DWORD[64+rcx],eax
lea rcx,[128+rcx]
dec r9d
jnz NEAR $L$oop_scatter
DB 0F3h,0C3h ;repret
global rsaz_512_gather4
ALIGN 16
rsaz_512_gather4:
lea rdx,[r8*4+rdx]
mov r9d,8
jmp NEAR $L$oop_gather
ALIGN 16
$L$oop_gather:
mov eax,DWORD[rdx]
mov r8d,DWORD[64+rdx]
lea rdx,[128+rdx]
shl r8,32
or rax,r8
mov QWORD[rcx],rax
lea rcx,[8+rcx]
dec r9d
jnz NEAR $L$oop_gather
DB 0F3h,0C3h ;repret
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
mov rsi,QWORD[8+r9]
mov r11,QWORD[56+r9]
mov r10d,DWORD[r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jb NEAR $L$common_seh_tail
mov rax,QWORD[152+r8]
mov r10d,DWORD[4+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jae NEAR $L$common_seh_tail
lea rax,[((128+24+48))+rax]
mov rbx,QWORD[((-8))+rax]
mov rbp,QWORD[((-16))+rax]
mov r12,QWORD[((-24))+rax]
mov r13,QWORD[((-32))+rax]
mov r14,QWORD[((-40))+rax]
mov r15,QWORD[((-48))+rax]
mov QWORD[144+r8],rbx
mov QWORD[160+r8],rbp
mov QWORD[216+r8],r12
mov QWORD[224+r8],r13
mov QWORD[232+r8],r14
mov QWORD[240+r8],r15
$L$common_seh_tail:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_end_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_info_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_by_one wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_by_one wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_by_one wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_rsaz_512_sqr:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$sqr_body wrt ..imagebase,$L$sqr_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_body wrt ..imagebase,$L$mul_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_gather4:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_gather4_body wrt ..imagebase,$L$mul_gather4_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_scatter4:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_scatter4_body wrt ..imagebase,$L$mul_scatter4_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_by_one:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_by_one_body wrt ..imagebase,$L$mul_by_one_epilogue wrt ..imagebase
|
;
; Modified to run on the RC2014 and the YAZ180 by
; Phillip Stevens @feilipu https://feilipu.me
; February / March 2017
;
; Converted to z88dk z80asm for RC2014 and YAZ180 by
; Phillip Stevens @feilipu https://feilipu.me
; August 2017
;
INCLUDE "config_yaz180_private.inc"
EXTERN APU_ISR_NMI
EXTERN APU_INIT, APU_CHK_IDLE
EXTERN APU_OP_LD, APU_CMD_LD
EXTERN INPUT, CVRT
EXTERN LADD, LSUB, LMUL, LDIV, DSQRT
EXTERN APUStatus, APUError, APUIntCount
;==============================================================================
; RC2014 & YAZ180 DEFINES
;
DEFC RAMSTART_CA0 = $2000 ; Bottom of Common 0 RAM
; RAM Vector Address for Z80 RST Table, and for Z180 Vector Table
DEFC Z80_VECTOR_BASE = RAMSTART_CA0
; Z80 Interrupt Service Routine Addresses - rewrite as needed
DEFC Z180_TRAP_ADDR = Z80_VECTOR_BASE+$01
DEFC RST_08_ADDR = Z80_VECTOR_BASE+$05
DEFC RST_10_ADDR = Z80_VECTOR_BASE+$09
DEFC RST_18_ADDR = Z80_VECTOR_BASE+$0D
DEFC RST_20_ADDR = Z80_VECTOR_BASE+$11
DEFC RST_28_ADDR = Z80_VECTOR_BASE+$15
DEFC RST_30_ADDR = Z80_VECTOR_BASE+$19
DEFC INT_INT0_ADDR = Z80_VECTOR_BASE+$1D
DEFC INT_NMI_ADDR = Z80_VECTOR_BASE+$21
DEFC DEINT = $0C47 ;Function DEINT to get (IX+USR) into DE registers
DEFC ABPASS = $13BD ;Function ABPASS to put output into AB register for return
DEFC STACKTOP = $3FFE ; start of a global stack (any pushes pre-decrement)
;==============================================================================
; SIMPLE EXERCISE PROGRAM
;
DEFC SCRPG = $28 ; SCRATCH PAGE IS 2800H
DEFC OP1 = $00 ; STARTING LOCATION OF OPERAND 1
DEFC OP2 = OP1+$04 ; STARTING LOCATION OF OPERAND 2
DEFC RSULT = OP2+$04 ; STARTING LOCATION OF RESULT
DEFC SCR = RSULT+$04 ; STARTING LOCATION OF SCRATCH AREA
SECTION code_user ; ORIGIN FOR YAZ180 DURING TESTING
; start from 'X' jump, Basic prompt
PUBLIC _main
_main:
call DEINT ; get the USR(x) argument in de
LD (STACKTOP), sp ; store the old stack top, at top of new SP
LD sp, STACKTOP ; set new Stack Pointer, before decrement
LD HL, APU_HELLO ;LOAD HL ADDRESS OF HELLO
CALL pstring ;PRINT IT
call pnewline
;EXAMPLE CODE - LLLF ONE OPERAND COMMAND
; LD H,SCRPG ;SET H REGISTER TO RAM SCRATCH PAGE
; LD L,OP1 ;POINTER TO OPERAND 1
; LD C,SCR ;SCRATCH AREA
; CALL INPUT ;INPUT OPERAND 1 FROM TTY
;EXAMPLE CODE - LLLF TWO OPERAND COMMAND
; LD H,SCRPG ;SET H REGISTER TO RAM SCRATCH PAGE
; LD L,OP2 ;POINTER TO OPERAND 2
; LD C,SCR ;SCRATCH AREA
; CALL INPUT ;INPUT OPERAND 2 FROM TTY
; LD L,OP1 ;OPERAND 1 POINTER IN (H)L
; LD B,OP2 ;OPERAND 2 POINTER IN (H)B
; LD C,RSULT ;RESULT TO (H)C POINTER
; CALL LDIV ;DIVIDE OP1 BY OP2 AND PLACE RESULT IN RSULT
; CALL LMUL ;MULTIPLY OP1 BY OP2 AND PLACE RESULT IN RSULT
;EXAMPLE CODE - ONE OPERAND COMMAND
; LD L,OP1 ;OPERAND 1 POINTER IN (H)L
; LD B,RSULT ;RESULT TO (H)B POINTER
; LD C,SCR ;SCRATCH AREA
; CALL DSQRT ;SQUARE ROOT OF OP1 AND PLACE RESULT IN RSULT
LD HL, PYTHAGORAS ;LOAD HL ADDRESS OF PYTHAGORAS
CALL pstring ;PRINT IT
;EXAMPLE CODE - APU ONE OPERAND COMMAND
ld hl, INT_NMI_ADDR ;GET NMI VECTOR ADDRESS
CALL APU_INIT ;INITIALISE THE APU
;Am9511A I/O is from $Cn00 to $Cn01
ld hl, INPUT_DWD_PROMPT
call pstring
LD H, SCRPG ;SET H REGISTER TO RAM SCRATCH PAGE
LD L, OP1 ;POINTER TO OPERAND 1
LD C, SCR ;SCRATCH AREA
; CALL INPUT ;INPUT OPERAND 1 FROM TTY
call rhexdwd
LD D, SCRPG ;SET D REGISTER TO RAM SCRATCH PAGE
LD E, OP1 ;POINTER TO OPERAND 1
LD a, __IO_APU_OP_ENT32 ;ENTER 32 bit (double word from INPUT)
CALL APU_OP_LD ;POINTER TO OPERAND IN OPERAND BUFFER
;EXAMPLE CODE - APU TWO OPERAND COMMAND
ld hl, INPUT_DWD_PROMPT
call pstring
LD H, SCRPG ;SET H REGISTER TO RAM SCRATCH PAGE
LD L, OP2 ;POINTER TO OPERAND 2
LD C, SCR ;SCRATCH AREA
; CALL INPUT ;INPUT OPERAND 2 FROM TTY
call rhexdwd
LD D, SCRPG ;SET D REGISTER TO RAM SCRATCH PAGE
LD E, OP2 ;POINTER TO OPERAND 2
LD A, __IO_APU_OP_ENT32 ;ENTER 32 bit (double word from INPUT)
CALL APU_OP_LD ;POINTER TO OPERAND IN OPERAND BUFFER
LD A, __IO_APU_OP_FLTD ;COMMAND for FLTD (float double)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_PTOF ;COMMAND for PTOF (push float)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_FMUL ;COMMAND for FMUL (floating multiply)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_XCHF ;COMMAND for XCHF (swap float)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_FLTD ;COMMAND for FLTD (float double)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_PTOF ;COMMAND for PTOF (push floating)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_FMUL ;COMMAND for FMUL (floating multiply)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_FADD ;COMMAND for FADD (floating add)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_SQRT ;COMMAND for SQRT (floating square root)
CALL APU_CMD_LD ;ENTER a COMMAND
LD A, __IO_APU_OP_FIXD ;COMMAND for FIXD (fix double)
CALL APU_CMD_LD ;ENTER a COMMAND
LD D, SCRPG ;SET D REGISTER TO RAM SCRATCH PAGE
LD E, RSULT ;(D)E POINTER NOW RSULT
LD A, __IO_APU_OP_REM32 ;REMOVE 32 bit OPERAND
CALL APU_OP_LD
CALL APU_ISR_NMI ;KICK OFF APU PROCESS, WHICH THEN INTERRUPTS
CALL APU_CHK_IDLE ;CHECK, because it could be doing a last command
;EXAMPLE CODE - OUTPUT
call pnewline
ld hl, OUTPUT_DWD_PROMPT
call pstring
LD H, SCRPG ;SET H REGISTER TO RAM SCRATCH PAGE
LD L, RSULT ;(H)L POINTER NOW RSULT
LD C, SCR ;SCRATCH AREA
; call CVRT ;OUTPUT NUMBER STARTING IN LOCATION RSULT TO TTY
call phexdwd
call pnewline ;print newline
ld a, (APUIntCount) ; print how many times the interrupt was entered
call phex
call pnewline
LD SP, (STACKTOP) ;reenable old SP
ld a, (APUError) ;any errors ?
ld b, a
xor a
jp ABPASS ;output them
;==============================================================================
; INPUT SUBROUTINES
;
rhexdwd: ; returns 4 bytes LE, from address in hl
push af
inc hl
inc hl
inc hl
call rhex
ld (hl), a
call phex
dec hl
call rhex
ld (hl), a
call phex
dec hl
call rhex
ld (hl), a
call phex
dec hl
call rhex
ld (hl), a
call phex
pop af
ret
rhexwd: ; returns 2 bytes LE, from address in hl
push af
inc hl
call rhex
ld (hl), a
call phex
dec hl
call rhex
ld (hl), a
call phex
pop af
ret
rhex: ; Returns byte in a
push bc
rst 10H ; Rx byte
sub '0'
cp 10
jr c, rhexnbl2 ; if a<10 read the second nibble
sub 7 ; else subtract 'A'-'0' (17) and add 10
rhexnbl2:
rlca ; shift accumulator left by 4 bits
rlca
rlca
rlca
ld c, a ; temporarily store the first nibble in c
rst 10H ; Rx byte
sub '0'
cp 10
jr c, rhexend ; if a<10 finalize
sub 7 ; else subtract 'A' (17) and add 10
rhexend:
or c ; assemble two nibbles into one byte in a
pop bc
ret ; return the byte read in a
;==============================================================================
; OUTPUT SUBROUTINES
;
;print string
pstring:
ld a, (hl) ;Get character from HL
or a ;Is it $00 ?
ret z ;Then RETurn on terminator
rst 08H ;Print IT
inc hl ;Point to next character
jp pstring ;Continue until $00
;print CR/LF
pnewline:
ld a, CHAR_CR
rst 08
ld a, CHAR_LF
rst 08
ret
;print Double Word at address HL as 32 bit number in ASCII HEX
phexdwd:
push af
inc hl
inc hl
inc hl
ld a, (hl)
call phex
dec hl
ld a, (hl)
call phex
dec hl
ld a, (hl)
call phex
dec hl
ld a, (hl)
call phex
pop af
ret
;print Word at address HL as 16 bit number in ASCII HEX
phexwd:
push af
inc hl
ld a, (hl)
call phex
dec hl
ld a, (hl)
call phex
pop af
ret
;print contents of DEHL as 32 bit number in ASCII HEX
phexdwdreg:
push af
ld a, d
call phex
ld a, e
call phex
ld a, h
call phex
ld a, l
call phex
pop af
ret
;print contents of HL as 16 bit number in ASCII HEX
phexwdreg:
push af
ld a, h
call phex
ld a, l
call phex
pop af
ret
;print contents of A as 8 bit number in ASCII HEX
phex:
push af ;store the binary value
rlca ;shift accumulator left by 4 bits
rlca
rlca
rlca
and $0F ;now high nibble is low position
cp 10
jr c, phex_b ;jump if high nibble < 10
add a, 7 ;otherwise add 7 before adding '0'
phex_b:
add a, '0' ;add ASCII 0 to make a character
rst 08 ;print high nibble
pop af ;recover the binary value
phex1:
and $0F
cp 10
jr c, phex_c ;jump if low nibble < 10
add a, 7
phex_c:
add a, '0'
rst 08 ;print low nibble
ret
;------------------------------------------------------------------------------
;SECTION data_user
HELLO: DEFM CHAR_CR,CHAR_LF,"LLL Float ",0
APU_HELLO: DEFM CHAR_CR,CHAR_LF,"Am9511A Float ",0
PYTHAGORAS: DEFM CHAR_CR,CHAR_LF,"SQRT[ a^2 + b^2 ] ",0
INPUT_WD_PROMPT: DEFM CHAR_CR,CHAR_LF,"WD Input 0x",0
INPUT_DWD_PROMPT: DEFM CHAR_CR,CHAR_LF,"DWD Input 0x",0
OUTPUT_WD_PROMPT: DEFM CHAR_CR,CHAR_LF,"WD Output 0x",0
OUTPUT_DWD_PROMPT: DEFM CHAR_CR,CHAR_LF,"DWD Output 0x",0
;==============================================================================
;
;==============================================================================
|
# Copyright (C) 2000, 2001, 2008, 2009 Free Software Foundation, Inc.
# Written By Timothy Wall
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This file 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
# General Public License for more details.
#
# Under Section 7 of GPL version 3, you are granted additional
# permissions described in the GCC Runtime Library Exception, version
# 3.1, as published by the Free Software Foundation.
#
# You should have received a copy of the GNU General Public License and
# a copy of the GCC Runtime Library Exception along with this program;
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# <http://www.gnu.org/licenses/>.
# This file just make a stack frame for the contents of the .fini and
# .init sections. Users may put any desired instructions in those
# sections.
.section ".init"
.align 16
.global _init
_init:
.prologue 14, 33
.save ar.pfs, r34
alloc r34 = ar.pfs, 0, 4, 0, 0
.vframe r35
mov r35 = r12
.save rp, r33
mov r33 = b0
.body
.section ".fini"
.align 16
.global _fini
_fini:
.prologue 14, 33
.save ar.pfs, r34
alloc r34 = ar.pfs, 0, 4, 0, 0
.vframe r35
mov r35 = r12
.save rp, r33
mov r33 = b0
.body
# end of crti.asm
|
; A094304: Sum of all possible sums formed from all but one of the previous terms, starting 1.
; 1,0,1,4,18,96,600,4320,35280,322560,3265920,36288000,439084800,5748019200,80951270400,1220496076800,19615115520000,334764638208000,6046686277632000
mov $1,1
lpb $0,1
sub $0,1
gcd $2,$0
mov $1,$2
mov $3,$1
cal $1,142
mul $1,$3
sub $0,$0
lpe
|
//
// Event.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Event.h"
#include "Poco/DOM/Document.h"
namespace Poco {
namespace XML {
Event::Event(Document* pOwnerDocument, const XMLString& type):
_pOwner(pOwnerDocument),
_type(type),
_pTarget(0),
_pCurrentTarget(0),
_currentPhase(CAPTURING_PHASE),
_bubbles(true),
_cancelable(true),
_canceled(false),
_stopped(false)
{
}
Event::Event(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool isCancelable):
_pOwner(pOwnerDocument),
_type(type),
_pTarget(pTarget),
_pCurrentTarget(0),
_currentPhase(CAPTURING_PHASE),
_bubbles(canBubble),
_cancelable(isCancelable),
_canceled(false),
_stopped(false)
{
}
Event::~Event()
{
}
void Event::stopPropagation()
{
_stopped = true;
}
void Event::preventDefault()
{
_canceled = true;
}
void Event::initEvent(const XMLString& eventType, bool canBubble, bool isCancelable)
{
_type = eventType;
_bubbles = canBubble;
_cancelable = isCancelable;
_canceled = false;
_stopped = false;
}
void Event::setTarget(EventTarget* pTarget)
{
_pTarget = pTarget;
}
void Event::setCurrentPhase(PhaseType phase)
{
_currentPhase = phase;
}
void Event::setCurrentTarget(EventTarget* pTarget)
{
_pCurrentTarget = pTarget;
}
void Event::autoRelease()
{
_pOwner->autoReleasePool().add(this);
}
} } // namespace Poco::XML
|
addi x10, x0, 1
addi x11, x0, 2
addi x12, x0, 3
addi x13, x0, 4
fcvt.s.w f0, x10
fcvt.s.w f1, x11
fcvt.s.w f2, x12
fcvt.s.w f3, x13
fdiv.s f5, f0, f2
fmul.s f6, f5, f2
addi x15, x0, 5
fcvt.s.w f30, x15
fdiv.s f31, f30, f1
|
#include "../src/CollisionDetector.h"
#include "../src/DeltatimeMonitor.h"
#include "../src/EntityContainer.h"
#include "../src/EntityProperties.h"
#include "../src/EntityShape.h"
#include "EntityImpl.h"
#include "catch.hpp"
TEST_CASE("CollisionDetectorTests", "[collision]")
{
flat2d::DeltatimeMonitor* dtm;
flat2d::EntityContainer* container;
flat2d::CollisionDetector* detector;
flat2d::Entity* c1;
flat2d::Entity* c2;
flat2d::Entity* c3;
flat2d::Entity* c4;
flat2d::Entity* c5;
dtm = new flat2d::DeltatimeMonitor();
container = new flat2d::EntityContainer(dtm);
detector = new flat2d::CollisionDetector(container, dtm);
c1 = new EntityImpl(100, 100);
c2 = new EntityImpl(200, 100);
c3 = new EntityImpl(200, 200);
c4 = new EntityImpl(105, 105);
c5 = new EntityImpl(115, 115);
container->registerObject(c1);
container->registerObject(c2);
container->registerObject(c3);
container->registerObject(c4);
SECTION("Collision detection", "[collisions]")
{
REQUIRE(detector->AABB(c1->getEntityProperties().getColliderShape(),
c4->getEntityProperties().getColliderShape()));
REQUIRE(!detector->AABB(c1->getEntityProperties().getColliderShape(),
c2->getEntityProperties().getColliderShape()));
}
SECTION("Multi collisions", "[hide][collisions]")
{
// TODO(Linus): Need some new tests here after rewrite
//
// flat2d::Entity* o = detector->checkForCollisions( c4 );
// REQUIRE( o );
// REQUIRE( *c1 == *o );
// REQUIRE( !detector->checkForCollisions( c2 ) );
}
SECTION("Colliders", "[collisions]")
{
flat2d::EntityShape colliderBox = { 0, 0, 1, 1 };
c1->getEntityProperties().setColliderShape(colliderBox);
REQUIRE(!detector->AABB(c1->getEntityProperties().getColliderShape(),
c4->getEntityProperties().getColliderShape()));
}
SECTION("Moving object collision", "[collisions]")
{
flat2d::EntityProperties& props = c1->getEntityProperties();
props.setXvel(10);
props.setYvel(0);
float normaly, normalx;
float result = detector->sweptAABB(&c1->getEntityProperties(),
&c5->getEntityProperties(),
&normaly,
&normalx);
REQUIRE(result > 0.0f);
REQUIRE(result < 1.0f);
}
delete detector;
delete container;
delete dtm;
}
|
; generated by esotope-bfc (DCPU branch)
SET A, mem
SET [A], 0
SET [A+1], 23
SET [A+2], 0
SET [A+3], 0
:L0
IFE [A+1], 0
SET PC, L1
SET PUSH, 6
ADD PEEK, [A+1]
ADD [A+2], POP
ADD [A+3], [A+1]
SET PUSH, 90
ADD PEEK, [A+2]
SET [A+1], POP
SET PUSH, 65535
ADD PEEK, [A+3]
SET [A+2], POP
SET [A+3], 0
ADD A, 1
SET PC, L0
:L1
ADD [A+2], 9
SET PUSH, 3
SET B, [A+2]
MUL B, 9
ADD PEEK, B
SET [A+1], POP
ADD [A+3], 6
SET PUSH, 65534
SET B, [A+3]
SHL B, 3
ADD PEEK, B
SET [A+2], POP
SET PUSH, 65534
ADD PEEK, [A+2]
SET [A+3], POP
ADD [A+4], [A+2]
SET [A+2], [A+4]
ADD [A+5], 4
SET PUSH, 0
SET B, [A+5]
SHL B, 3
ADD PEEK, B
SET [A+4], POP
SET [A+5], 10
ADD [A+6], 9
SET PUSH, 0
SET B, [A+6]
MUL B, 11
ADD PEEK, B
ADD [A+7], POP
SET [A+6], 0
:L2
IFE [A+7], 0
SET PC, L3
ADD [A+8], [A+7]
ADD [A+9], [A+7]
ADD [A+10], [A+7]
SET [A+7], [A+8]
SET [A+8], 0
:L4
IFE [A+10], 0
SET PC, L5
ADD [A+11], [A+10]
ADD [A+12], [A+10]
SET [A+10], [A+12]
SET [A+12], 0
IFE [A+11], 0
SET PC, L6
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L7
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L8
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L9
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L10
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L11
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L12
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L13
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L14
SUB [A+11], 1
SUB [A+10], 1
IFE [A+11], 0
SET PC, L15
SUB [A+10], 1
ADD [A+8], 1
SUB [A+9], 10
SET [A+11], 0
:L15
SET [A+11], 0
:L14
SET [A+11], 0
:L13
SET [A+11], 0
:L12
SET [A+11], 0
:L11
SET [A+11], 0
:L10
SET [A+11], 0
:L9
SET [A+11], 0
:L8
SET [A+11], 0
:L7
SET [A+11], 0
:L6
SET [A+11], 0
SET PC, L4
:L5
:L16
IFE [A+8], 0
SET PC, L17
ADD [A+10], 12
SET PUSH, 0
SET B, [A+10]
SHL B, 2
ADD PEEK, B
ADD [A+8], POP
SET PUSH, 0
SET B, [A+10]
SHL B, 2
ADD PEEK, B
ADD [A+9], POP
SET [A+10], 0
:L18
IFE [A+8], 0
SET PC, L19
SET B, [A+8]
JSR putc
SET [A+8], 0
ADD A, 1
SET PC, L18
:L19
SUB A, 2
SET PC, L16
:L17
IFE [A+9], 0
SET PC, L20
ADD [A+8], 6
SET PUSH, 0
SET B, [A+8]
SHL B, 3
ADD PEEK, B
ADD [A+9], POP
SET [A+8], 0
SET B, [A+9]
JSR putc
SET [A+9], 0
:L20
SET [A+9], 0
SET B, [A+4]
JSR putc
SET B, [A+65535]
JSR putc
:L21
IFE [A+65535], 0
SET PC, L22
SUB A, 1
SET PC, L21
:L22
SET B, [A+8]
JSR putc
SET B, [A+3]
JSR putc
SET B, [A+3]
JSR putc
SET B, [A+11]
JSR putc
SET B, [A+18]
JSR putc
:L23
IFE [A+18], 0
SET PC, L24
ADD A, 1
SET PC, L23
:L24
ADD [A+20], [A+19]
ADD [A+21], [A+19]
SET [A+19], [A+20]
SET [A+20], 0
IFE [A+21], 0
SET PC, L25
SUB [A+21], 1
IFE [A+21], 0
SET PC, L26
SET [A+21], 0
ADD [A+20], 0x73
SET B, [A+20]
JSR putc
SET [A+20], 0
:L26
SET [A+21], 0
:L25
SET [A+21], 0
SET B, [A+16]
JSR putc
:L27
IFE [A+16], 0
SET PC, L28
SUB A, 1
SET PC, L27
:L28
SET B, [A+25]
JSR putc
SET B, [A+34]
JSR putc
:L29
IFE [A+34], 0
SET PC, L30
ADD A, 1
SET PC, L29
:L30
SET B, [A+32]
JSR putc
SET B, [A+27]
JSR putc
SET B, [A+24]
JSR putc
SET B, [A+24]
JSR putc
:L31
IFE [A+24], 0
SET PC, L32
SUB A, 1
SET PC, L31
:L32
SET B, [A+30]
JSR putc
:L33
IFE [A+30], 0
SET PC, L34
ADD A, 1
SET PC, L33
:L34
SET B, [A+28]
JSR putc
:L35
IFE [A+28], 0
SET PC, L36
SUB A, 1
SET PC, L35
:L36
SET B, [A+37]
JSR putc
SET B, [A+38]
JSR putc
:L37
IFE [A+38], 0
SET PC, L38
ADD A, 1
SET PC, L37
:L38
SET B, [A+36]
JSR putc
:L39
IFE [A+36], 0
SET PC, L40
SUB A, 1
SET PC, L39
:L40
SET B, [A+40]
JSR putc
SET B, [A+52]
JSR putc
SET B, [A+55]
JSR putc
:L41
IFE [A+55], 0
SET PC, L42
ADD A, 1
SET PC, L41
:L42
SET B, [A+53]
JSR putc
:L43
IFE [A+53], 0
SET PC, L44
SUB A, 1
SET PC, L43
:L44
SET B, [A+54]
JSR putc
:L45
IFE [A+54], 0
SET PC, L46
ADD A, 1
SET PC, L45
:L46
SET B, [A+48]
JSR putc
SET B, [A+37]
JSR putc
SET B, [A+37]
JSR putc
:L47
IFE [A+37], 0
SET PC, L48
ADD A, 1
SET PC, L47
:L48
SET B, [A+34]
JSR putc
SET B, [A+35]
JSR putc
:L49
IFE [A+35], 0
SET PC, L50
ADD A, 1
SET PC, L49
:L50
ADD [A+37], [A+36]
ADD [A+38], [A+36]
ADD [A+39], [A+36]
SET [A+36], [A+37]
SET [A+37], 0
:L51
IFE [A+39], 0
SET PC, L52
ADD [A+40], [A+39]
ADD [A+41], [A+39]
SET [A+39], [A+41]
SET [A+41], 0
IFE [A+40], 0
SET PC, L53
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L54
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L55
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L56
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L57
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L58
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L59
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L60
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L61
SUB [A+40], 1
SUB [A+39], 1
IFE [A+40], 0
SET PC, L62
SUB [A+39], 1
ADD [A+37], 1
SUB [A+38], 10
SET [A+40], 0
:L62
SET [A+40], 0
:L61
SET [A+40], 0
:L60
SET [A+40], 0
:L59
SET [A+40], 0
:L58
SET [A+40], 0
:L57
SET [A+40], 0
:L56
SET [A+40], 0
:L55
SET [A+40], 0
:L54
SET [A+40], 0
:L53
SET [A+40], 0
SET PC, L51
:L52
:L63
IFE [A+37], 0
SET PC, L64
ADD [A+39], 12
SET PUSH, 0
SET B, [A+39]
SHL B, 2
ADD PEEK, B
ADD [A+37], POP
SET PUSH, 0
SET B, [A+39]
SHL B, 2
ADD PEEK, B
ADD [A+38], POP
SET [A+39], 0
:L65
IFE [A+37], 0
SET PC, L66
SET B, [A+37]
JSR putc
SET [A+37], 0
ADD A, 1
SET PC, L65
:L66
SUB A, 2
SET PC, L63
:L64
IFE [A+38], 0
SET PC, L67
ADD [A+37], 6
SET PUSH, 0
SET B, [A+37]
SHL B, 3
ADD PEEK, B
ADD [A+38], POP
SET [A+37], 0
SET B, [A+38]
JSR putc
SET [A+38], 0
:L67
SET [A+38], 0
SET B, [A+33]
JSR putc
SET B, [A+28]
JSR putc
:L68
IFE [A+28], 0
SET PC, L69
SUB A, 1
SET PC, L68
:L69
SET B, [A+37]
JSR putc
SET B, [A+32]
JSR putc
SET B, [A+32]
JSR putc
SET B, [A+40]
JSR putc
SET B, [A+47]
JSR putc
:L70
IFE [A+47], 0
SET PC, L71
ADD A, 1
SET PC, L70
:L71
ADD [A+49], [A+48]
ADD [A+50], [A+48]
SET [A+48], [A+49]
SET [A+49], 0
IFE [A+50], 0
SET PC, L72
SUB [A+50], 1
IFE [A+50], 0
SET PC, L73
SET [A+50], 0
ADD [A+49], 0x73
SET B, [A+49]
JSR putc
SET [A+49], 0
:L73
SET [A+50], 0
:L72
SET [A+50], 0
SET B, [A+45]
JSR putc
:L74
IFE [A+45], 0
SET PC, L75
SUB A, 1
SET PC, L74
:L75
SET B, [A+54]
JSR putc
SET B, [A+63]
JSR putc
:L76
IFE [A+63], 0
SET PC, L77
ADD A, 1
SET PC, L76
:L77
SET B, [A+61]
JSR putc
SET B, [A+56]
JSR putc
SET B, [A+53]
JSR putc
SET B, [A+53]
JSR putc
:L78
IFE [A+53], 0
SET PC, L79
SUB A, 1
SET PC, L78
:L79
SET B, [A+59]
JSR putc
:L80
IFE [A+59], 0
SET PC, L81
ADD A, 1
SET PC, L80
:L81
SET B, [A+55]
JSR putc
SET B, [A+58]
JSR putc
SET B, [A+54]
JSR putc
SET B, [A+53]
JSR putc
SET B, [A+43]
JSR putc
SET B, [A+49]
JSR putc
:L82
IFE [A+49], 0
SET PC, L83
ADD A, 1
SET PC, L82
:L83
SET B, [A+47]
JSR putc
:L84
IFE [A+47], 0
SET PC, L85
SUB A, 1
SET PC, L84
:L85
SET B, [A+56]
JSR putc
SET B, [A+57]
JSR putc
SET B, [A+66]
JSR putc
:L86
IFE [A+66], 0
SET PC, L87
ADD A, 1
SET PC, L86
:L87
SET B, [A+64]
JSR putc
SET B, [A+57]
JSR putc
:L88
IFE [A+57], 0
SET PC, L89
SUB A, 1
SET PC, L88
:L89
SET B, [A+66]
JSR putc
:L90
IFE [A+66], 0
SET PC, L91
SUB A, 1
SET PC, L90
:L91
SET B, [A+67]
JSR putc
SET B, [A+76]
JSR putc
:L92
IFE [A+76], 0
SET PC, L93
ADD A, 1
SET PC, L92
:L93
SET B, [A+74]
JSR putc
SET B, [A+70]
JSR putc
SET B, [A+57]
JSR putc
:L94
IFE [A+57], 0
SET PC, L95
ADD A, 1
SET PC, L94
:L95
SET B, [A+48]
JSR putc
:L96
IFE [A+48], 0
SET PC, L97
ADD A, 1
SET PC, L96
:L97
SET B, [A+46]
JSR putc
:L98
IFE [A+46], 0
SET PC, L99
SUB A, 1
SET PC, L98
:L99
SET B, [A+54]
JSR putc
:L100
IFE [A+54], 0
SET PC, L101
ADD A, 1
SET PC, L100
:L101
SET B, [A+48]
JSR putc
:L102
IFE [A+48], 0
SET PC, L103
SUB A, 1
SET PC, L102
:L103
SET B, [A+53]
JSR putc
SET B, [A+53]
JSR putc
:L104
IFE [A+53], 0
SET PC, L105
ADD A, 1
SET PC, L104
:L105
SET B, [A+51]
JSR putc
SET B, [A+39]
JSR putc
:L106
IFE [A+39], 0
SET PC, L107
SUB A, 1
SET PC, L106
:L107
SET B, [A+43]
JSR putc
:L108
IFE [A+43], 0
SET PC, L109
ADD A, 1
SET PC, L108
:L109
SET B, [A+41]
JSR putc
SET B, [A+37]
JSR putc
:L110
IFE [A+37], 0
SET PC, L111
SUB A, 1
SET PC, L110
:L111
SET B, [A+43]
JSR putc
SET B, [A+46]
JSR putc
SET B, [A+40]
JSR putc
SET B, [A+47]
JSR putc
SET B, [A+57]
JSR putc
:L112
IFE [A+57], 0
SET PC, L113
ADD A, 1
SET PC, L112
:L113
SET B, [A+54]
JSR putc
SET B, [A+55]
JSR putc
SUB [A+58], 1
ADD [A+59], [A+58]
ADD [A+60], [A+58]
ADD [A+61], [A+58]
SET [A+58], [A+59]
SET [A+59], 0
:L114
IFE [A+61], 0
SET PC, L115
ADD [A+62], [A+61]
ADD [A+63], [A+61]
SET [A+61], [A+63]
SET [A+63], 0
IFE [A+62], 0
SET PC, L116
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L117
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L118
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L119
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L120
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L121
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L122
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L123
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L124
SUB [A+62], 1
SUB [A+61], 1
IFE [A+62], 0
SET PC, L125
SUB [A+61], 1
ADD [A+59], 1
SUB [A+60], 10
SET [A+62], 0
:L125
SET [A+62], 0
:L124
SET [A+62], 0
:L123
SET [A+62], 0
:L122
SET [A+62], 0
:L121
SET [A+62], 0
:L120
SET [A+62], 0
:L119
SET [A+62], 0
:L118
SET [A+62], 0
:L117
SET [A+62], 0
:L116
SET [A+62], 0
SET PC, L114
:L115
:L126
IFE [A+59], 0
SET PC, L127
ADD [A+61], 12
SET PUSH, 0
SET B, [A+61]
SHL B, 2
ADD PEEK, B
ADD [A+59], POP
SET PUSH, 0
SET B, [A+61]
SHL B, 2
ADD PEEK, B
ADD [A+60], POP
SET [A+61], 0
:L128
IFE [A+59], 0
SET PC, L129
SET B, [A+59]
JSR putc
SET [A+59], 0
ADD A, 1
SET PC, L128
:L129
SUB A, 2
SET PC, L126
:L127
IFE [A+60], 0
SET PC, L130
ADD [A+59], 6
SET PUSH, 0
SET B, [A+59]
SHL B, 3
ADD PEEK, B
ADD [A+60], POP
SET [A+59], 0
SET B, [A+60]
JSR putc
SET [A+60], 0
:L130
SET [A+60], [A+58]
ADD [A+59], [A+58]
SET [A+58], [A+59]
SET [A+59], 1
IFE [A+60], 0
SET PC, L131
SUB [A+59], 1
SET [A+60], 0
:L131
SET [A+60], 0
:L132
IFE [A+59], 0
SET PC, L133
SUB [A+59], 1
:L134
IFE [A+56], 0
SET PC, L135
SUB A, 1
SET PC, L134
:L135
SET B, [A+66]
JSR putc
SET B, [A+65]
JSR putc
:L136
IFE [A+65], 0
SET PC, L137
ADD A, 1
SET PC, L136
:L137
SET B, [A+63]
JSR putc
:L138
IFE [A+63], 0
SET PC, L139
SUB A, 1
SET PC, L138
:L139
SET B, [A+74]
JSR putc
SET B, [A+72]
JSR putc
SET B, [A+69]
JSR putc
:L140
IFE [A+69], 0
SET PC, L141
ADD A, 1
SET PC, L140
:L141
SET B, [A+59]
JSR putc
:L142
IFE [A+59], 0
SET PC, L143
ADD A, 1
SET PC, L142
:L143
ADD A, 2
SET PC, L132
:L133
SET B, [A+55]
JSR putc
SET B, [A+50]
JSR putc
:L144
IFE [A+50], 0
SET PC, L145
SUB A, 1
SET PC, L144
:L145
SET B, [A+59]
JSR putc
SET B, [A+54]
JSR putc
SET B, [A+54]
JSR putc
SET B, [A+62]
JSR putc
SET B, [A+69]
JSR putc
:L146
IFE [A+69], 0
SET PC, L147
ADD A, 1
SET PC, L146
:L147
ADD [A+71], [A+70]
ADD [A+72], [A+70]
SET [A+70], [A+71]
SET [A+71], 1
IFE [A+72], 0
SET PC, L148
SUB [A+72], 1
SUB [A+71], 1
IFE [A+72], 0
SET PC, L149
ADD [A+71], 1
SET [A+72], 0
:L149
SET [A+72], 0
:L148
SET [A+72], 0
IFE [A+71], 0
SET PC, L150
ADD [A+71], 8
SET PUSH, 2
SET B, [A+71]
MUL B, 13
SUB PEEK, B
SUB [A+72], POP
SET [A+71], 0
SET B, [A+72]
JSR putc
SET [A+72], 0
:L150
SET [A+71], 0
SET B, [A+67]
JSR putc
:L151
IFE [A+67], 0
SET PC, L152
SUB A, 1
SET PC, L151
:L152
SET B, [A+76]
JSR putc
SET B, [A+85]
JSR putc
:L153
IFE [A+85], 0
SET PC, L154
ADD A, 1
SET PC, L153
:L154
SET B, [A+83]
JSR putc
SET B, [A+78]
JSR putc
SET B, [A+75]
JSR putc
SET B, [A+75]
JSR putc
:L155
IFE [A+75], 0
SET PC, L156
SUB A, 1
SET PC, L155
:L156
SET B, [A+81]
JSR putc
:L157
IFE [A+81], 0
SET PC, L158
ADD A, 1
SET PC, L157
:L158
SET B, [A+79]
JSR putc
:L159
IFE [A+79], 0
SET PC, L160
SUB A, 1
SET PC, L159
:L160
SET B, [A+88]
JSR putc
SET B, [A+89]
JSR putc
:L161
IFE [A+89], 0
SET PC, L162
ADD A, 1
SET PC, L161
:L162
SET B, [A+87]
JSR putc
:L163
IFE [A+87], 0
SET PC, L164
SUB A, 1
SET PC, L163
:L164
SET B, [A+91]
JSR putc
SET B, [A+103]
JSR putc
SET B, [A+106]
JSR putc
:L165
IFE [A+106], 0
SET PC, L166
ADD A, 1
SET PC, L165
:L166
SET B, [A+104]
JSR putc
:L167
IFE [A+104], 0
SET PC, L168
SUB A, 1
SET PC, L167
:L168
SET B, [A+105]
JSR putc
:L169
IFE [A+105], 0
SET PC, L170
ADD A, 1
SET PC, L169
:L170
SET B, [A+99]
JSR putc
SET B, [A+88]
JSR putc
SET B, [A+88]
JSR putc
:L171
IFE [A+88], 0
SET PC, L172
ADD A, 1
SET PC, L171
:L172
SET B, [A+84]
JSR putc
SET B, [A+87]
JSR putc
SET B, [A+87]
JSR putc
ADD A, 82
SET PC, L2
:L3
SUB PC, 1
:screenoff
DAT 0
:newline
SET C, [screenoff]
AND C, 0xffe0
ADD C, 0x20
SET [screenoff], C
IFG 0x180, C
SET PC, POP
:scroll
SET C, 0
:scroll_loop
SET [C+0x8000], [C+0x8020]
ADD C, 1
IFG 0x160, C
SET PC, scroll_loop
:scroll_loop2
SET [C+0x8000], 0
ADD C, 1
IFG 0x180, C
SET PC, scroll_loop2
SUB [screenoff], 0x20
SET PC, POP
:putc
IFE B, 10
SET PC, newline
IFG [screenoff], 0x17e
JSR scroll
SET C, [screenoff]
BOR B, 0xf000
SET [C+0x8000], B
ADD C, 1
SET [screenoff], C
SET PC, POP
:mem
DAT 0 ; the start of memory
|
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; Add64RI8
mov rax, 0x2
;TEST_BEGIN_RECORDING
add rax, 0x7
;TEST_END_RECORDING
|
; A081503: Number of steps to reach a single digit when map in A081502 is iterated.
; 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,1,1,1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,2,3,3,2,2,2,2,2,3,3,3,2,2,2,2,3,3,3,2,2,2,2,3,3,3,2,2,2,2,3,3,3,3,2,2,2,3,3,3,3,3,3,2,3,3,3,3,3,3,2,3,3,3,3,3,3,2,3,3,3,3,3,3
lpb $0
mov $2,$0
seq $2,81502 ; Let n = 10x + y where 0 <= y <= 9, x >= 0. Then a(n) = 3x+y.
mov $0,$2
mov $3,$2
min $3,1
add $1,$3
lpe
mov $0,$1
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/quic/quic_sent_entropy_manager.h"
#include <algorithm>
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using std::make_pair;
using std::pair;
namespace net {
namespace test {
namespace {
class QuicSentEntropyManagerTest : public ::testing::Test {
protected:
QuicSentEntropyManager entropy_manager_;
};
TEST_F(QuicSentEntropyManagerTest, SentEntropyHash) {
EXPECT_EQ(0, entropy_manager_.GetCumulativeEntropy(0));
QuicPacketEntropyHash entropies[4] = {12, 1, 33, 3};
for (size_t i = 0; i < arraysize(entropies); ++i) {
entropy_manager_.RecordPacketEntropyHash(i + 1, entropies[i]);
}
QuicPacketEntropyHash hash = 0;
for (size_t i = 0; i < arraysize(entropies); ++i) {
hash ^= entropies[i];
EXPECT_EQ(hash, entropy_manager_.GetCumulativeEntropy(i + 1));
}
}
TEST_F(QuicSentEntropyManagerTest, IsValidEntropy) {
QuicPacketEntropyHash entropies[10] =
{12, 1, 33, 3, 32, 100, 28, 42, 22, 255};
for (size_t i = 0; i < arraysize(entropies); ++i) {
entropy_manager_.RecordPacketEntropyHash(i + 1, entropies[i]);
}
SequenceNumberSet missing_packets;
missing_packets.insert(1);
missing_packets.insert(4);
missing_packets.insert(7);
missing_packets.insert(8);
QuicPacketEntropyHash entropy_hash = 0;
for (size_t i = 0; i < arraysize(entropies); ++i) {
if (missing_packets.find(i + 1) == missing_packets.end()) {
entropy_hash ^= entropies[i];
}
}
EXPECT_TRUE(entropy_manager_.IsValidEntropy(10, missing_packets,
entropy_hash));
}
TEST_F(QuicSentEntropyManagerTest, ClearEntropiesBefore) {
QuicPacketEntropyHash entropies[10] =
{12, 1, 33, 3, 32, 100, 28, 42, 22, 255};
for (size_t i = 0; i < arraysize(entropies); ++i) {
entropy_manager_.RecordPacketEntropyHash(i + 1, entropies[i]);
}
// Discard the first 5 entropies and ensure IsValidEntropy and EntropyHash
// still return correct results.
entropy_manager_.ClearEntropyBefore(5);
SequenceNumberSet missing_packets;
missing_packets.insert(7);
missing_packets.insert(8);
QuicPacketEntropyHash entropy_hash = 0;
for (size_t i = 0; i < arraysize(entropies); ++i) {
if (missing_packets.find(i + 1) == missing_packets.end()) {
entropy_hash ^= entropies[i];
}
}
EXPECT_TRUE(entropy_manager_.IsValidEntropy(10, missing_packets,
entropy_hash));
entropy_hash = 0;
for (size_t i = 0; i < arraysize(entropies); ++i) {
entropy_hash ^= entropies[i];
}
EXPECT_EQ(entropy_hash, entropy_manager_.GetCumulativeEntropy(10));
}
} // namespace
} // namespace test
} // namespace net
|
BattleCommand_spite:
; spite
ld a, [wAttackMissed]
and a
jp nz, .failed
ld bc, PARTYMON_STRUCT_LENGTH ; ????
ld hl, wEnemyMonMoves
ldh a, [hBattleTurn]
and a
jr z, .got_moves
ld hl, wBattleMonMoves
.got_moves
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
jr z, .failed
ld b, a
push bc
ld bc, STRUGGLE
call CompareMove
pop bc
jr z, .failed
ld c, -1
.loop
inc c
ld a, [hli]
cp b
jr nz, .loop
ld [wNamedObjectIndexBuffer], a
dec hl
ld b, 0
push bc
ld c, wBattleMonPP - wBattleMonMoves
add hl, bc
pop bc
ld a, [hl]
and PP_MASK
jr z, .failed
push bc
call GetMoveName
; lose 2-5 PP
call BattleRandom
and %11
inc a
inc a
ld b, a
ld a, [hl]
and PP_MASK
cp b
jr nc, .deplete_pp
ld b, a
.deplete_pp
ld a, [hl]
sub b
ld [hl], a
push af
ld a, MON_PP
call OpponentPartyAttr
ld d, b
pop af
pop bc
add hl, bc
ld e, a
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVar
bit SUBSTATUS_TRANSFORMED, a
jr nz, .transformed
ldh a, [hBattleTurn]
and a
jr nz, .not_wildmon
ld a, [wBattleMode]
dec a
jr nz, .not_wildmon
ld hl, wWildMonPP
add hl, bc
.not_wildmon
ld [hl], e
.transformed
push de
call AnimateCurrentMove
pop de
ld a, d
ld [wDeciramBuffer], a
ld hl, SpiteEffectText
jp StdBattleTextbox
.failed
jp PrintDidntAffect2
|
DATA SEGMENT
NUM1 DB ?
NUM2 DB ?
RESULT DB ?
MSG1 DB 10,13,"ENTER INT 1 : $"
MSG2 DB 10,13,"ENTER INT 2 : $"
MSG3 DB 10,13,"MUL : $"
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM1,AL
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM2,AL
MUL NUM1
MOV RESULT,AL
AAM
ADD AH,30H
ADD AL,30H
MOV BX,AX
LEA DX,MSG3
MOV AH,9
INT 21H
MOV AH,2
MOV DL,BH
INT 21H
MOV AH,2
MOV DL,BL
INT 21H
MOV AH,4CH
INT 21H
ENDS
END START
|
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int n;
bool degenerate = true;
scanf("%d", &n);
int segments[n];
for(int i = 0; i < n; i++) scanf("%d", &segments[i]);
sort(segments, segments + n);
for(int i = 1; i < n - 1; i++){
if(segments[i - 1] + segments[i] > segments[i + 1]){
degenerate = false;
break;
}
}
if(!degenerate) printf("YES\n");
else printf("NO\n");
return 0;
}
/*
Si se tiene un triangulo con lados: x <= y <= z,
un triangulo degenerado es igual si se cumple esto: x + y = z,
en cambio el triangulo no degenerado o el normalito es igual a:
x + y > z, es por eso que organizo el vector, para obtener segmentos
tipo: x <= y <= z.
*/ |
; A172123: Number of ways to place 2 nonattacking bishops on an n X n board.
; 0,4,26,92,240,520,994,1736,2832,4380,6490,9284,12896,17472,23170,30160,38624,48756,60762,74860,91280,110264,132066,156952,185200,217100,252954,293076,337792,387440,442370,502944,569536,642532,722330,809340,903984,1006696,1117922,1238120,1367760,1507324,1657306,1818212,1990560,2174880,2371714,2581616,2805152,3042900,3295450,3563404,3847376,4147992,4465890,4801720,5156144,5529836,5923482,6337780,6773440,7231184,7711746,8215872,8744320,9297860,9877274,10483356,11116912,11778760,12469730,13190664,13942416,14725852,15541850,16391300,17275104,18194176,19149442,20141840,21172320,22241844,23351386,24501932,25694480,26930040,28209634,29534296,30905072,32323020,33789210,35304724,36870656,38488112,40158210,41882080,43660864,45495716,47387802,49338300,51348400,53419304,55552226,57748392,60009040,62335420,64728794,67190436,69721632,72323680,74997890,77745584,80568096,83466772,86442970,89498060,92633424,95850456,99150562,102535160,106005680,109563564,113210266,116947252,120776000,124698000,128714754,132827776,137038592,141348740,145759770,150273244,154890736,159613832,164444130,169383240,174432784,179594396,184869722,190260420,195768160,201394624,207141506,213010512,219003360,225121780,231367514,237742316,244247952,250886200,257658850,264567704,271614576,278801292,286129690,293601620,301218944,308983536,316897282,324962080,333179840,341552484,350081946,358770172,367619120,376630760,385807074,395150056,404661712,414344060,424199130,434228964,444435616,454821152,465387650,476137200,487071904,498193876,509505242,521008140,532704720,544597144,556687586,568978232,581471280,594168940,607073434,620186996,633511872,647050320,660804610,674777024,688969856,703385412,718026010,732893980,747991664,763321416,778885602,794686600,810726800,827008604,843534426,860306692,877327840,894600320,912126594,929909136,947950432,966252980,984819290,1003651884,1022753296,1042126072,1061772770,1081695960,1101898224,1122382156,1143150362,1164205460,1185550080,1207186864,1229118466,1251347552,1273876800,1296708900,1319846554,1343292476,1367049392,1391120040,1415507170,1440213544,1465241936,1490595132,1516275930,1542287140,1568631584,1595312096,1622331522,1649692720,1677398560,1705451924,1733855706,1762612812,1791726160,1821198680,1851033314,1881233016,1911800752,1942739500
lpb $0
add $3,$0
add $3,$0
sub $0,1
add $2,$3
add $2,$3
add $1,$2
sub $3,1
lpe
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/attestation/tpm_challenge_key_result.h"
#include <ostream>
#include "base/base64.h"
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/values.h"
namespace chromeos {
namespace attestation {
namespace {
std::string Base64EncodeStr(const std::string& str) {
std::string result;
base::Base64Encode(str, &result);
return result;
}
} // namespace
// These messages are exposed to the extensions that using
// chrome.enterprise.platformKeys API. Someone can rely on exectly these
// strings. Should be changed carefully.
const char TpmChallengeKeyResult::kDevicePolicyDisabledErrorMsg[] =
"Remote attestation is not enabled for your device.";
const char TpmChallengeKeyResult::kSignChallengeFailedErrorMsg[] =
"Failed to sign the challenge.";
const char TpmChallengeKeyResult::kUserNotManagedErrorMsg[] =
"The user account is not enterprise managed.";
const char TpmChallengeKeyResult::kKeyRegistrationFailedErrorMsg[] =
"Key registration failed.";
const char TpmChallengeKeyResult::kUserPolicyDisabledErrorMsg[] =
"Remote attestation is not enabled for your account.";
const char TpmChallengeKeyResult::kUserKeyNotAvailableErrorMsg[] =
"User keys cannot be challenged in this profile.";
const char TpmChallengeKeyResult::kNonEnterpriseDeviceErrorMsg[] =
"The device is not enterprise enrolled.";
const char TpmChallengeKeyResult::kDbusErrorMsg[] =
"Failed to get Enterprise certificate. Error code = 1";
const char TpmChallengeKeyResult::kUserRejectedErrorMsg[] =
"Failed to get Enterprise certificate. Error code = 2";
const char TpmChallengeKeyResult::kGetCertificateFailedErrorMsg[] =
"Failed to get Enterprise certificate. Error code = 3";
const char TpmChallengeKeyResult::kResetRequiredErrorMsg[] =
"Failed to get Enterprise certificate. Error code = 4";
const char TpmChallengeKeyResult::kAttestationUnsupportedErrorMsg[] =
"Failed to get Enterprise certificate. Error code = 5";
const char TpmChallengeKeyResult::kTimeoutErrorMsg[] =
"Device web based attestation failed with timeout error.";
const char TpmChallengeKeyResult::kDeviceWebBasedAttestationUrlErrorMsg[] =
"Device web based attestation is not enabled for the provided URL.";
const char TpmChallengeKeyResult::kExtensionNotWhitelistedErrorMsg[] =
"The extension does not have permission to call this function.";
const char TpmChallengeKeyResult::kChallengeBadBase64ErrorMsg[] =
"Challenge is not base64 encoded.";
const char TpmChallengeKeyResult::kDeviceWebBasedAttestationNotOobeErrorMsg[] =
"Device web based attestation is only available on the OOBE screen.";
const char TpmChallengeKeyResult::kGetPublicKeyFailedErrorMsg[] =
"Failed to get public key.";
// static
TpmChallengeKeyResult TpmChallengeKeyResult::MakeChallengeResponse(
const std::string& challenge_response) {
return TpmChallengeKeyResult{
/*result_code=*/TpmChallengeKeyResultCode::kSuccess,
/*public_key=*/"",
/*challenge_response=*/challenge_response};
}
// static
TpmChallengeKeyResult TpmChallengeKeyResult::MakePublicKey(
const std::string& public_key) {
return TpmChallengeKeyResult{
/*result_code=*/TpmChallengeKeyResultCode::kSuccess,
/*public_key=*/public_key,
/*challenge_response=*/""};
}
// static
TpmChallengeKeyResult TpmChallengeKeyResult::MakeSuccess() {
return TpmChallengeKeyResult{
/*result_code=*/TpmChallengeKeyResultCode::kSuccess,
/*public_key=*/"",
/*challenge_response=*/""};
}
// static
TpmChallengeKeyResult TpmChallengeKeyResult::MakeError(
TpmChallengeKeyResultCode error_code) {
DCHECK_NE(error_code, TpmChallengeKeyResultCode::kSuccess);
return TpmChallengeKeyResult{/*result_code=*/error_code,
/*public_key=*/"",
/*challenge_response=*/""};
}
const char* TpmChallengeKeyResult::GetErrorMessage() const {
switch (result_code) {
case TpmChallengeKeyResultCode::kDevicePolicyDisabledError:
return kDevicePolicyDisabledErrorMsg;
case TpmChallengeKeyResultCode::kSignChallengeFailedError:
return kSignChallengeFailedErrorMsg;
case TpmChallengeKeyResultCode::kUserNotManagedError:
return kUserNotManagedErrorMsg;
case TpmChallengeKeyResultCode::kKeyRegistrationFailedError:
return kKeyRegistrationFailedErrorMsg;
case TpmChallengeKeyResultCode::kUserKeyNotAvailableError:
return kUserKeyNotAvailableErrorMsg;
case TpmChallengeKeyResultCode::kUserPolicyDisabledError:
return kUserPolicyDisabledErrorMsg;
case TpmChallengeKeyResultCode::kNonEnterpriseDeviceError:
return kNonEnterpriseDeviceErrorMsg;
case TpmChallengeKeyResultCode::kDbusError:
return kDbusErrorMsg;
case TpmChallengeKeyResultCode::kUserRejectedError:
return kUserRejectedErrorMsg;
case TpmChallengeKeyResultCode::kGetCertificateFailedError:
return kGetCertificateFailedErrorMsg;
case TpmChallengeKeyResultCode::kResetRequiredError:
return kResetRequiredErrorMsg;
case TpmChallengeKeyResultCode::kAttestationUnsupportedError:
return kAttestationUnsupportedErrorMsg;
case TpmChallengeKeyResultCode::kTimeoutError:
return kTimeoutErrorMsg;
case TpmChallengeKeyResultCode::kDeviceWebBasedAttestationUrlError:
return kDeviceWebBasedAttestationUrlErrorMsg;
case TpmChallengeKeyResultCode::kExtensionNotWhitelistedError:
return kExtensionNotWhitelistedErrorMsg;
case TpmChallengeKeyResultCode::kChallengeBadBase64Error:
return kChallengeBadBase64ErrorMsg;
case TpmChallengeKeyResultCode::kDeviceWebBasedAttestationNotOobeError:
return kDeviceWebBasedAttestationNotOobeErrorMsg;
case TpmChallengeKeyResultCode::kGetPublicKeyFailedError:
return kGetPublicKeyFailedErrorMsg;
case TpmChallengeKeyResultCode::kSuccess:
// Not an error message.
NOTREACHED();
return "";
}
NOTREACHED() << static_cast<int>(result_code);
}
bool TpmChallengeKeyResult::IsSuccess() const {
return result_code == TpmChallengeKeyResultCode::kSuccess;
}
bool TpmChallengeKeyResult::operator==(
const TpmChallengeKeyResult& other) const {
return ((result_code == other.result_code) &&
(public_key == other.public_key) &&
(challenge_response == other.challenge_response));
}
bool TpmChallengeKeyResult::operator!=(
const TpmChallengeKeyResult& other) const {
return !(*this == other);
}
std::ostream& operator<<(std::ostream& os,
const TpmChallengeKeyResult& result) {
base::Value value(base::Value::Type::DICTIONARY);
value.SetIntKey("result_code", static_cast<int>(result.result_code));
if (!result.IsSuccess()) {
value.SetStringKey("error_message", result.GetErrorMessage());
}
value.SetStringKey("public_key", Base64EncodeStr(result.public_key));
value.SetStringKey("challenge_response",
Base64EncodeStr(result.challenge_response));
os << value;
return os;
}
} // namespace attestation
} // namespace chromeos
|
##Writer: Minhas Kamal
##Date: 02-MAY-2014
##Function: This program is a simple demonstration of stack.
#####**data**#####
.data
prompt: .asciiz "\n# What operation do you want to perform?\nPress-\t1.for push \n\t2.for pop \n\t3.for print all \n\t4.for exit \nSelection: "
prompt2: .asciiz "Enter the value: "
conf_pop: .asciiz "\nOperation pop is successful.\n"
conf_push: .asciiz "Operation push is successful.\n"
exit_msg: .asciiz "\n\n\nProgram exits...."
comma_space: .asciiz ", "
num: .double 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
.double 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
capacity: .word 40
init: .double 0.0
#####**text**#####
.text
main:
lw $t1, capacity #load capacity
l.d $f4, init #load the initial value
li $t2, 0 #initial index is 0
loop:
la $a0, prompt #prompt
li $v0, 4
syscall
li $v0, 5 #take choice from user
syscall
la $t0, num #load array
beq $v0, 1, push
beq $v0, 2, pop
beq $v0, 3, print_all
j exit
#-------------------------------------------------------------------------------------------------------------------
#pushes one number on top
push:
li $t3, 0
beq $t2, $t1, loop #return when capacity is full
push_loop: #find the address
add $t0, $t0, 8
add $t3, $t3, 1
ble $t3, $t2, push_loop
sub $t0, $t0, 8 #subtract once
la $a0, prompt2 #prompt for input
li $v0, 4
syscall
li $v0, 7 #take input
syscall
s.d $f0, ($t0) #store the value
add $t2, $t2, 1 #increase index
la $a0, conf_push #confirmation
li $v0, 4
syscall
j loop #return
#-------------------------------------------------------------------------------------------------------------------
#pops up top number
pop:
li $t3, 0
beq $t2, $t3, loop #return when nothing to pop
pop_loop: #find the number
add $t0, $t0, 8
add $t3, $t3, 1
blt $t3, $t2, pop_loop
sub $t0, $t0, 8 #subtract once
l.d $f12, ($t0) #print the number
li $v0, 3
syscall
s.d $f4, ($t0) #initialize
sub $t2, $t2, 1 #reduce index
la $a0, conf_pop #confirmation
li $v0, 4
syscall
j loop #return
#-------------------------------------------------------------------------------------------------------------------
#prints all the values
print_all:
li $t3, 0
print_loop:
l.d $f12, ($t0) #print the number
li $v0, 3
syscall
la $a0, comma_space #seperate ", "
li $v0, 4
syscall
add $t0, $t0, 8
add $t3, $t3, 1 #increase the loop counter
blt $t3, $t1, print_loop
j loop
#-------------------------------------------------------------------------------------------------------------------
#exit from the program
exit:
la $a0, exit_msg #exit message
li $v0, 4
syscall
li $v0, 10
syscall
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x387a, %rsi
lea addresses_WC_ht+0x3f7a, %rdi
nop
nop
nop
sub $4718, %rbx
mov $36, %rcx
rep movsw
nop
nop
nop
xor $63497, %r11
lea addresses_A_ht+0x1b69e, %rsi
nop
nop
nop
nop
sub $32247, %rcx
mov $0x6162636465666768, %rbx
movq %rbx, (%rsi)
nop
nop
nop
nop
dec %rbx
lea addresses_WT_ht+0x1323a, %r12
nop
nop
cmp %rdx, %rdx
vmovups (%r12), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %rcx
nop
nop
xor $6744, %rbx
lea addresses_WT_ht+0xa4ea, %rsi
lea addresses_D_ht+0xe77a, %rdi
nop
nop
nop
nop
xor %r9, %r9
mov $46, %rcx
rep movsw
nop
nop
nop
dec %rsi
lea addresses_WC_ht+0xe47a, %rsi
lea addresses_UC_ht+0xbb7a, %rdi
nop
nop
nop
nop
nop
and %rbx, %rbx
mov $102, %rcx
rep movsl
and $12005, %rdi
lea addresses_normal_ht+0x537a, %rdi
and %r11, %r11
mov (%rdi), %r9d
nop
nop
inc %rsi
lea addresses_WT_ht+0x1af1a, %rdi
clflush (%rdi)
nop
nop
sub %r12, %r12
mov (%rdi), %ecx
nop
nop
nop
and $59545, %rdi
lea addresses_A_ht+0xab7a, %r12
nop
xor $53951, %r11
mov (%r12), %rsi
and $55860, %r11
lea addresses_normal_ht+0xfbbc, %rsi
lea addresses_D_ht+0x1e0a, %rdi
clflush (%rdi)
nop
nop
sub $65340, %r11
mov $25, %rcx
rep movsb
nop
nop
nop
inc %rcx
lea addresses_WC_ht+0x1ca48, %rcx
nop
nop
nop
nop
nop
cmp $39560, %rbx
vmovups (%rcx), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %rdi
nop
nop
nop
nop
nop
dec %r9
lea addresses_UC_ht+0xa162, %rbx
cmp $53795, %rcx
movb (%rbx), %r11b
nop
nop
sub %rdx, %rdx
lea addresses_WC_ht+0x18d7a, %rcx
nop
nop
nop
nop
nop
cmp $43417, %rdx
mov (%rcx), %r9
nop
add %r9, %r9
lea addresses_A_ht+0x12724, %rsi
lea addresses_WC_ht+0x10726, %rdi
nop
nop
nop
nop
nop
add $882, %rbx
mov $109, %rcx
rep movsl
nop
nop
nop
cmp %rdx, %rdx
lea addresses_A_ht+0xee7a, %r11
nop
nop
nop
nop
cmp %rsi, %rsi
movups (%r11), %xmm0
vpextrq $0, %xmm0, %rcx
nop
nop
add %r11, %r11
lea addresses_WT_ht+0x27a, %rsi
lea addresses_WC_ht+0x1b0c6, %rdi
nop
nop
nop
and $55269, %rbx
mov $115, %rcx
rep movsb
nop
cmp $9208, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r8
push %rax
push %rbp
push %rdi
// Store
lea addresses_RW+0x739a, %r8
nop
nop
nop
nop
nop
add %rbp, %rbp
mov $0x5152535455565758, %r12
movq %r12, %xmm0
vmovaps %ymm0, (%r8)
inc %r11
// Store
lea addresses_US+0x16c5d, %rbp
nop
nop
nop
nop
and $28061, %rax
movb $0x51, (%rbp)
nop
nop
nop
xor $3114, %rax
// Faulty Load
mov $0x2f7f73000000077a, %r14
nop
nop
nop
cmp $56895, %r8
movups (%r14), %xmm7
vpextrq $0, %xmm7, %rax
lea oracles, %r12
and $0xff, %rax
shlq $12, %rax
mov (%r12,%rax,1), %rax
pop %rdi
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': True, 'size': 32, 'NT': True, 'same': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 2}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': True}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}}
{'00': 3522}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A093359: Primes of the form 28n + 1.
; Submitted by Jon Maiga
; 29,113,197,281,337,421,449,617,673,701,757,953,1009,1093,1289,1373,1429,1597,1709,1877,1933,2017,2129,2213,2269,2297,2381,2437,2521,2549,2633,2689,2801,2857,2969,3109,3137,3221,3361,3389,3529,3557,3613,3697,4201,4229,4397,4481,4621,4649,4733,4789,4817,4957,5153,5209,5237,5573,5657,5741,5881,6133,6217,6301,6329,6469,6553,6581,6637,6833,6917,7001,7057,7253,7309,7393,7477,7561,7589,7673,7757,7841,8009,8093,8233,8317,8429,8513,8597,8681,8737,8821,8849,8933,9157,9241,9437,9521,9661,9689
mov $2,$0
add $2,2
pow $2,2
lpb $2
add $1,28
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
add $0,29
|
; double pow(double x, double y)
SECTION code_clib
SECTION code_fp_math48
PUBLIC am48_pow
EXTERN mm48_pwr
; compute (AC')^(AC)
;
; enter : AC' = double x
; AC = double y
;
; exit : success
;
; AC' = x^y
; carry reset
;
; fail if out of domain or overflow
;
; AC' = +-inf or zero
; carry set, errno set
;
; uses : af, af', bc', de', hl'
defc am48_pow = mm48_pwr
|
; ===============================================================
; Dec 2013
; ===============================================================
;
; size_t strlen(const char *s)
;
; Return length of string s.
;
; ===============================================================
SECTION code_string
PUBLIC asm_strlen
asm_strlen:
; enter: hl = char *s
;
; exit : hl = length
; bc = -(length + 1)
; a = 0
; z flag set if 0 length
; carry reset
;
; uses : af, bc, hl
xor a
ld c,a
ld b,a
cpir
ld hl,$ffff
sbc hl,bc
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.