text
stringlengths
1
1.05M
; A097804: a(n) = 3*(2*5^n + 1). ; 9,33,153,753,3753,18753,93753,468753,2343753,11718753,58593753,292968753,1464843753,7324218753,36621093753,183105468753,915527343753,4577636718753,22888183593753,114440917968753,572204589843753,2861022949218753,14305114746093753,71525573730468753,357627868652343753,1788139343261718753,8940696716308593753,44703483581542968753,223517417907714843753,1117587089538574218753,5587935447692871093753,27939677238464355468753,139698386192321777343753,698491930961608886718753,3492459654808044433593753,17462298274040222167968753,87311491370201110839843753,436557456851005554199218753,2182787284255027770996093753,10913936421275138854980468753,54569682106375694274902343753,272848410531878471374511718753,1364242052659392356872558593753,6821210263296961784362792968753,34106051316484808921813964843753,170530256582424044609069824218753,852651282912120223045349121093753,4263256414560601115226745605468753,21316282072803005576133728027343753,106581410364015027880668640136718753,532907051820075139403343200683593753 mov $1,5 pow $1,$0 mul $1,6 add $1,3 mov $0,$1
; @file ; This file provides assembly 64-bit atomic reads/writes required for memory initialization. ; ; Copyright (c) 2019 Intel Corporation. All rights reserved. <BR> ; ; SPDX-License-Identifier: BSD-2-Clause-Patent ; SECTION .text ;----------------------------------------------------------------------------- ; ; Section: SaMmioRead64 ; ; Description: Read 64 bits from the Memory Mapped I/O space. ; Use MMX instruction for atomic access, because some MC registers have side effect. ; ; @param[in] Address - Memory mapped I/O address. ; ;----------------------------------------------------------------------------- ;UINT64 ;SaMmioRead64 ( ; IN UINTN Address ; ) global ASM_PFX(SaMmioRead64) ASM_PFX(SaMmioRead64): sub esp, 16 movq [esp], mm0 ;Save mm0 on stack mov edx, [esp + 20] ;edx = Address movq mm0, [edx] ;mm0 = [Address] movq [esp + 8], mm0 ;Store mm0 on Stack movq mm0, [esp] ;Restore mm0 emms mov eax, [esp + 8] ;eax = [Address][31:0] mov edx, [esp + 12] ;edx = [Address][64:32] add esp, 16 ret ;----------------------------------------------------------------------------- ; ; Section: SaMmioWrite64 ; ; Description: Write 64 bits to the Memory Mapped I/O space. ; Use MMX instruction for atomic access, because some MC registers have side effect. ; ; @param[in] Address - Memory mapped I/O address. ; @param[in] Value - The value to write. ; ;----------------------------------------------------------------------------- ;UINT64 ;SaMmioWrite64 ( ; IN UINTN Address, ; IN UINT64 Value ; ) global ASM_PFX(SaMmioWrite64) ASM_PFX(SaMmioWrite64): sub esp, 8 movq [esp], mm0 ;Save mm0 on Stack mov edx, [esp + 12] ;edx = Address movq mm0, [esp + 16] ;mm0 = Value movq [edx], mm0 ;[Address] = Value movq mm0, [esp] ;Restore mm0 emms mov eax, [esp + 16] ;eax = Value[31:0] mov edx, [esp + 20] ;edx = Value[64:32] add esp, 8 ret ;----------------------------------------------------------------------------- ; Intel Silicon View Technology check point interface based on IO port reading ; ; @param CheckPoint Check point AH value. ; AH = 0x10: End of MRC State ; AH = 0x20: End of DXE State ; AH = 0x30: Ready to boot before INT-19h or UEFI boot ; AH = 0x40: After OS booting, need a timer SMI trigger to implement (TBD); ; ; @param PortReading IO port reading address used for breakpoints ;----------------------------------------------------------------------------- ;VOID ;EFIAPI ;IsvtCheckPoint ( ; IN UINT32 CheckPoint, ; IN UINT32 PortReading ; ) global ASM_PFX(IsvtCheckPoint) ASM_PFX(IsvtCheckPoint): push eax push edx ; Stack layout at this point: ;------------- ; PortReading ESP + 16 ;------------- ; CheckPoint ESP + 12 ;------------- ; EIP ESP + 8 ;------------- ; EAX ESP + 4 ;------------- ; EDX <-- ESP ;------------- mov ah, BYTE [esp + 12] ; CheckPoint mov dx, WORD [esp + 16] ; PortReading in al, dx ; signal debugger pop edx pop eax ret
; Z88 Small C+ Run time Library ; l_gint variant to be used sometimes by the peephole optimizer ; PUBLIC l_gintspsp .l_gintspsp add hl,sp inc hl inc hl ld a,(hl) inc hl ld h,(hl) ld l,a ex (sp),hl jp (hl)
#pragma once #include <xgt/chain/xgt_fwd.hpp> #include <xgt/protocol/authority.hpp> #include <xgt/protocol/operations.hpp> #include <xgt/protocol/xgt_operations.hpp> #include <xgt/chain/buffer_type.hpp> #include <xgt/chain/xgt_object_types.hpp> #include <xgt/chain/witness_objects.hpp> namespace xgt { namespace chain { class operation_object : public object< operation_object_type, operation_object > { XGT_STD_ALLOCATOR_CONSTRUCTOR( operation_object ) public: template< typename Constructor, typename Allocator > operation_object( Constructor&& c, allocator< Allocator > a ) :serialized_op( a ) { c( *this ); } id_type id; transaction_id_type trx_id; uint32_t block = 0; uint32_t trx_in_block = 0; uint32_t op_in_trx = 0; uint32_t virtual_op = 0; time_point_sec timestamp; buffer_type serialized_op; uint64_t get_virtual_op() const { return virtual_op; } }; struct by_location; struct by_transaction_id; typedef multi_index_container< operation_object, indexed_by< ordered_unique< tag< by_id >, member< operation_object, operation_id_type, &operation_object::id > >, ordered_unique< tag< by_location >, composite_key< operation_object, member< operation_object, uint32_t, &operation_object::block >, member< operation_object, operation_id_type, &operation_object::id > > > #ifndef SKIP_BY_TX_ID , ordered_unique< tag< by_transaction_id >, composite_key< operation_object, member< operation_object, transaction_id_type, &operation_object::trx_id>, member< operation_object, operation_id_type, &operation_object::id> > > #endif >, allocator< operation_object > > operation_index; class account_history_object : public object< account_history_object_type, account_history_object > { public: template< typename Constructor, typename Allocator > account_history_object( Constructor&& c, allocator< Allocator > a ) { c( *this ); } account_history_object() {} id_type id; wallet_name_type account; uint32_t sequence = 0; operation_id_type op; }; struct by_account; struct by_account_rev; typedef multi_index_container< account_history_object, indexed_by< ordered_unique< tag< by_id >, member< account_history_object, account_history_id_type, &account_history_object::id > >, ordered_unique< tag< by_account >, composite_key< account_history_object, member< account_history_object, wallet_name_type, &account_history_object::account>, member< account_history_object, uint32_t, &account_history_object::sequence> >, composite_key_compare< std::less< wallet_name_type >, std::greater< uint32_t > > > >, allocator< account_history_object > > account_history_index; } } #ifdef ENABLE_MIRA namespace mira { template<> struct is_static_length< xgt::chain::account_history_object > : public boost::true_type {}; } // mira #endif FC_REFLECT( xgt::chain::operation_object, (id)(trx_id)(block)(trx_in_block)(op_in_trx)(virtual_op)(timestamp)(serialized_op) ) CHAINBASE_SET_INDEX_TYPE( xgt::chain::operation_object, xgt::chain::operation_index ) FC_REFLECT( xgt::chain::account_history_object, (id)(account)(sequence)(op) ) CHAINBASE_SET_INDEX_TYPE( xgt::chain::account_history_object, xgt::chain::account_history_index ) namespace helpers { template <> class index_statistic_provider<xgt::chain::operation_index> { public: typedef xgt::chain::operation_index IndexType; index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const { index_statistic_info info; gather_index_static_data(index, &info); if(onlyStaticInfo == false) { for(const auto& o : index) info._item_additional_allocation += o.serialized_op.capacity()*sizeof(xgt::chain::buffer_type::value_type); } return info; } }; template <> class index_statistic_provider<xgt::chain::account_history_index> { public: typedef xgt::chain::account_history_index IndexType; index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const { index_statistic_info info; gather_index_static_data(index, &info); if(onlyStaticInfo == false) { //for(const auto& o : index) // info._item_additional_allocation += o.get_ops().capacity()* // sizeof(xgt::chain::account_history_object::operation_container::value_type); } return info; } }; } /// namespace helpers
// Copyright 2019 Your Name <your_email> #include <gtest/gtest.h> #include "header.hpp" #include <iostream> #include <string> #include <any> #include <map> #include <vector> #include <sstream> #include <fstream> TEST(Parse, Text){ std::string json = "{\n" " \"lastname\" : \"Ivanov\",\n" " \"firstname\" : \"Ivan\",\n" " \"age\" : 25,\n" " \"islegal\" : false,\n" " \"marks\" : [\n" " \t4,5,5,5,2,3\n" " ],\n" " \"address\" : {\n" " \t\"city\" : \"Moscow\",\n" " \"street\" : \"Vozdvijenka\"\n" " }\n" "}"; Json object = Json::parse(json); EXPECT_EQ(std::any_cast<std::string>(object["lastname"]), "Ivanov"); EXPECT_EQ(std::any_cast<bool>(object["islegal"]), false); EXPECT_EQ(std::any_cast<int>(object["age"]), 25); auto marks = std::any_cast<Json>(object["marks"]); EXPECT_EQ(std::any_cast<int>(marks[0]), 4); EXPECT_EQ(std::any_cast<int>(marks[1]), 5); auto address = std::any_cast<Json>(object["address"]); EXPECT_EQ(std::any_cast<std::string>(address["city"]), "Moscow"); EXPECT_EQ(std::any_cast<std::string>(address["street"]), "Vozdvijenka"); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
; ;================================================================================================== ; ROMWBW 2.X CONFIGURATION DEFAULTS FOR ZETA V2 ;================================================================================================== ; ; THIS FILE CONTAINS THE FULL SET OF DEFAULT CONFIGURATION SETTINGS FOR THE PLATFORM ; INDICATED ABOVE. THIS FILE SHOULD *NOT* NORMALLY BE CHANGED. INSTEAD, YOU SHOULD ; OVERRIDE ANY SETTINGS YOU WANT USING A CONFIGURATION FILE IN THE CONFIG DIRECTORY ; UNDER THIS DIRECTORY. ; ; THIS FILE CAN BE CONSIDERED A REFERENCE THAT LISTS ALL POSSIBLE CONFIGURATION SETTINGS ; FOR THE PLATFORM. ; #DEFINE PLATFORM_NAME "ZETA V2" ; PLATFORM .EQU PLT_ZETA2 ; PLT_[SBC|ZETA|ZETA2|N8|MK4|UNA|RCZ80|RCZ180|EZZ80|SCZ180|DYNO|RCZ280|MBC] CPUFAM .EQU CPU_Z80 ; CPU FAMILY: CPU_[Z80|Z180|Z280] BIOS .EQU BIOS_WBW ; HARDWARE BIOS: BIOS_[WBW|UNA] BATCOND .EQU FALSE ; ENABLE LOW BATTERY WARNING MESSAGE HBIOS_MUTEX .EQU FALSE ; ENABLE REENTRANT CALLS TO HBIOS (ADDS OVERHEAD) USELZSA2 .EQU TRUE ; ENABLE FONT COMPRESSION TICKFREQ .EQU 50 ; DESIRED PERIODIC TIMER INTERRUPT FREQUENCY (HZ) ; BOOT_TIMEOUT .EQU -1 ; AUTO BOOT TIMEOUT IN SECONDS, -1 TO DISABLE, 0 FOR IMMEDIATE ; CPUSPDCAP .EQU SPD_FIXED ; CPU SPEED CHANGE CAPABILITY SPD_FIXED|SPD_HILO CPUSPDDEF .EQU SPD_HIGH ; CPU SPEED DEFAULT SPD_UNSUP|SPD_HIGH|SPD_LOW CPUOSC .EQU 20000000 ; CPU OSC FREQ IN MHZ INTMODE .EQU 2 ; INTERRUPTS: 0=NONE, 1=MODE 1, 2=MODE 2, 3=MODE 3 (Z280) DEFSERCFG .EQU SER_38400_8N1 ; DEFAULT SERIAL LINE CONFIG (SEE STD.ASM) ; RAMSIZE .EQU 512 ; SIZE OF RAM IN KB (MUST MATCH YOUR HARDWARE!!!) PLT_RAM_R .EQU 0 ; RESERVE FIRST N KB OF RAM (USUALLY 0) PLT_ROM_R .EQU 0 ; RESERVE FIRST N KB OR ROM (USUALLY 0) MEMMGR .EQU MM_Z2 ; MEMORY MANAGER: MM_[SBC|Z2|N8|Z180|Z280|MBC] MPGSEL_0 .EQU $78 ; Z2 MEM MGR BANK 0 PAGE SELECT REG (WRITE ONLY) MPGSEL_1 .EQU $79 ; Z2 MEM MGR BANK 1 PAGE SELECT REG (WRITE ONLY) MPGSEL_2 .EQU $7A ; Z2 MEM MGR BANK 2 PAGE SELECT REG (WRITE ONLY) MPGSEL_3 .EQU $7B ; Z2 MEM MGR BANK 3 PAGE SELECT REG (WRITE ONLY) MPGENA .EQU $7C ; Z2 MEM MGR PAGING ENABLE REGISTER (BIT 0, WRITE ONLY) ; RTCIO .EQU $70 ; RTC LATCH REGISTER ADR ; KIOENABLE .EQU FALSE ; ENABLE ZILOG KIO SUPPORT KIOBASE .EQU $80 ; KIO BASE I/O ADDRESS ; CTCENABLE .EQU TRUE ; ENABLE ZILOG CTC SUPPORT CTCDEBUG .EQU FALSE ; ENABLE CTC DRIVER DEBUG OUTPUT CTCBASE .EQU $20 ; CTC BASE I/O ADDRESS CTCTIMER .EQU TRUE ; ENABLE CTC PERIODIC TIMER CTCMODE .EQU CTCMODE_CTR ; CTC MODE: CTCMODE_[NONE|CTR|TIM16|TIM256] CTCPRE .EQU 256 ; PRESCALE CONSTANT (1-256) CTCPRECH .EQU 0 ; PRESCALE CHANNEL (0-3) CTCTIMCH .EQU 1 ; TIMER CHANNEL (0-3) CTCOSC .EQU 921600 ; CTC CLOCK FREQUENCY ; EIPCENABLE .EQU FALSE ; EIPC: ENABLE Z80 EIPC (Z84C15) INITIALIZATION ; SKZENABLE .EQU FALSE ; ENABLE SERGEY'S Z80-512K FEATURES ; WDOGMODE .EQU WDOG_NONE ; WATCHDOG MODE: WDOG_[NONE|EZZ80|SKZ] ; DIAGENABLE .EQU FALSE ; ENABLES OUTPUT TO 8 BIT LED DIAGNOSTIC PORT DIAGPORT .EQU $00 ; DIAGNOSTIC PORT ADDRESS DIAGDISKIO .EQU TRUE ; ENABLES DISK I/O ACTIVITY ON DIAGNOSTIC LEDS ; LEDENABLE .EQU FALSE ; ENABLES STATUS LED LEDMODE .EQU LEDMODE_RTC ; LEDMODE_[STD|RTC] LEDPORT .EQU RTCIO ; STATUS LED PORT ADDRESS LEDDISKIO .EQU TRUE ; ENABLES DISK I/O ACTIVITY ON STATUS LED ; DSKYENABLE .EQU FALSE ; ENABLES DSKY DSKYMODE .EQU DSKYMODE_V1 ; DSKY VERSION: DSKYMODE_[V1|NG] DSKYPPIBASE .EQU $60 ; BASE I/O ADDRESS OF DSKY PPI DSKYOSC .EQU 3000000 ; OSCILLATOR FREQ FOR DSKYNG (IN HZ) ; BOOTCON .EQU 0 ; BOOT CONSOLE DEVICE CRTACT .EQU FALSE ; ACTIVATE CRT (VDU,CVDU,PROPIO,ETC) AT STARTUP VDAEMU .EQU EMUTYP_ANSI ; VDA EMULATION: EMUTYP_[TTY|ANSI] ANSITRACE .EQU 1 ; ANSI DRIVER TRACE LEVEL (0=NO,1=ERRORS,2=ALL) MKYENABLE .EQU FALSE ; MSX 5255 PPI KEYBOARD COMPATIBLE DRIVER (REQUIRES TMS VDA DRIVER) ; DSRTCENABLE .EQU TRUE ; DSRTC: ENABLE DS-1302 CLOCK DRIVER (DSRTC.ASM) DSRTCMODE .EQU DSRTCMODE_STD ; DSRTC: OPERATING MODE: DSRTC_[STD|MFPIC] DSRTCCHG .EQU FALSE ; DSRTC: FORCE BATTERY CHARGE ON (USE WITH CAUTION!!!) ; BQRTCENABLE .EQU FALSE ; BQRTC: ENABLE BQ4845 CLOCK DRIVER (BQRTC.ASM) BQRTC_BASE .EQU $50 ; BQRTC: I/O BASE ADDRESS ; INTRTCENABLE .EQU FALSE ; ENABLE PERIODIC INTERRUPT CLOCK DRIVER (INTRTC.ASM) ; RP5RTCENABLE .EQU FALSE ; RP5C01 RTC BASED CLOCK (RP5RTC.ASM) ; HTIMENABLE .EQU FALSE ; ENABLE SIMH TIMER SUPPORT SIMRTCENABLE .EQU FALSE ; ENABLE SIMH CLOCK DRIVER (SIMRTC.ASM) ; DS7RTCENABLE .EQU FALSE ; DS7RTC: ENABLE DS-1307 I2C CLOCK DRIVER (DS7RTC.ASM) DS7RTCMODE .EQU DS7RTCMODE_PCF ; DS7RTC: OPERATING MODE: DS7RTC_[PCF] ; DUARTENABLE .EQU FALSE ; DUART: ENABLE 2681/2692 SERIAL DRIVER (DUART.ASM) ; UARTENABLE .EQU TRUE ; UART: ENABLE 8250/16550-LIKE SERIAL DRIVER (UART.ASM) UARTOSC .EQU 1843200 ; UART: OSC FREQUENCY IN MHZ UARTINTS .EQU FALSE ; UART: INCLUDE INTERRUPT SUPPORT UNDER IM1/2/3 UARTCFG .EQU DEFSERCFG ; UART: LINE CONFIG FOR UART PORTS UARTCASSPD .EQU SER_300_8N1 ; UART: ECB CASSETTE UART DEFAULT SPEED UARTSBC .EQU TRUE ; UART: AUTO-DETECT SBC/ZETA ONBOARD UART UARTCAS .EQU FALSE ; UART: AUTO-DETECT ECB CASSETTE UART UARTMFP .EQU FALSE ; UART: AUTO-DETECT MF/PIC UART UART4 .EQU FALSE ; UART: AUTO-DETECT 4UART UART UARTRC .EQU FALSE ; UART: AUTO-DETECT RC UART ; ASCIENABLE .EQU FALSE ; ASCI: ENABLE Z180 ASCI SERIAL DRIVER (ASCI.ASM) ; Z2UENABLE .EQU FALSE ; Z2U: ENABLE Z280 UART SERIAL DRIVER (Z2U.ASM) ; ACIAENABLE .EQU FALSE ; ACIA: ENABLE MOTOROLA 6850 ACIA DRIVER (ACIA.ASM) ; SIOENABLE .EQU FALSE ; SIO: ENABLE ZILOG SIO SERIAL DRIVER (SIO.ASM) ; XIOCFG .EQU DEFSERCFG ; XIO: SERIAL LINE CONFIG ; VDUENABLE .EQU FALSE ; VDU: ENABLE VDU VIDEO/KBD DRIVER (VDU.ASM) CVDUENABLE .EQU FALSE ; CVDU: ENABLE CVDU VIDEO/KBD DRIVER (CVDU.ASM) NECENABLE .EQU FALSE ; NEC: ENABLE NEC UPD7220 VIDEO/KBD DRIVER (NEC.ASM) TMSENABLE .EQU FALSE ; TMS: ENABLE TMS9918 VIDEO/KBD DRIVER (TMS.ASM) TMSTIMENABLE .EQU FALSE ; TMS: ENABLE TIMER INTERRUPTS (REQUIRES IM1) VGAENABLE .EQU FALSE ; VGA: ENABLE VGA VIDEO/KBD DRIVER (VGA.ASM) ; MDENABLE .EQU TRUE ; MD: ENABLE MEMORY (ROM/RAM) DISK DRIVER (MD.ASM) MDROM .EQU TRUE ; MD: ENABLE ROM DISK MDRAM .EQU TRUE ; MD: ENABLE RAM DISK MDTRACE .EQU 1 ; MD: TRACE LEVEL (0=NO,1=ERRORS,2=ALL) MDFFENABLE .EQU FALSE ; MD: ENABLE FLASH FILE SYSTEM ; FDENABLE .EQU TRUE ; FD: ENABLE FLOPPY DISK DRIVER (FD.ASM) FDMODE .EQU FDMODE_ZETA2 ; FD: DRIVER MODE: FDMODE_[DIO|ZETA|ZETA2|DIDE|N8|DIO3|RCSMC|RCWDC|DYNO|EPFDC|MBC] FDCNT .EQU 1 ; FD: NUMBER OF FLOPPY DRIVES ON THE INTERFACE (1-2) FDTRACE .EQU 1 ; FD: TRACE LEVEL (0=NO,1=FATAL,2=ERRORS,3=ALL) FDMEDIA .EQU FDM144 ; FD: DEFAULT MEDIA FORMAT FDM[720|144|360|120|111] FDMEDIAALT .EQU FDM720 ; FD: ALTERNATE MEDIA FORMAT FDM[720|144|360|120|111] FDMAUTO .EQU TRUE ; FD: AUTO SELECT DEFAULT/ALTERNATE MEDIA FORMATS ; RFENABLE .EQU FALSE ; RF: ENABLE RAM FLOPPY DRIVER ; IDEENABLE .EQU FALSE ; IDE: ENABLE IDE DISK DRIVER (IDE.ASM) ; PPIDEENABLE .EQU FALSE ; PPIDE: ENABLE PARALLEL PORT IDE DISK DRIVER (PPIDE.ASM) PPIDETRACE .EQU 1 ; PPIDE: TRACE LEVEL (0=NO,1=ERRORS,2=ALL) PPIDECNT .EQU 1 ; PPIDE: NUMBER OF PPI CHIPS TO DETECT (1-3), 2 DRIVES PER CHIP PPIDE0BASE .EQU $60 ; PPIDE 0: PPI REGISTERS BASE ADR PPIDE0A8BIT .EQU FALSE ; PPIDE 0A (MASTER): 8 BIT XFER PPIDE0B8BIT .EQU FALSE ; PPIDE 0B (SLAVE): 8 BIT XFER ; SDENABLE .EQU FALSE ; SD: ENABLE SD CARD DISK DRIVER (SD.ASM) SDMODE .EQU SDMODE_PPI ; SD: DRIVER MODE: SDMODE_[JUHA|N8|CSIO|PPI|UART|DSD|MK4|SC|MT] SDPPIBASE .EQU $60 ; SD: BASE I/O ADDRESS OF PPI FOR PPI MODDE SDCNT .EQU 1 ; SD: NUMBER OF SD CARD DEVICES (1-2), FOR DSD & SC ONLY SDTRACE .EQU 1 ; SD: TRACE LEVEL (0=NO,1=ERRORS,2=ALL) SDCSIOFAST .EQU FALSE ; SD: ENABLE TABLE-DRIVEN BIT INVERTER IN CSIO MODE ; PRPENABLE .EQU FALSE ; PRP: ENABLE ECB PROPELLER IO BOARD DRIVER (PRP.ASM) ; PPPENABLE .EQU FALSE ; PPP: ENABLE ZETA PARALLEL PORT PROPELLER BOARD DRIVER (PPP.ASM) PPPBASE .EQU $60 ; PPP: PPI REGISTERS BASE ADDRESS PPPSDENABLE .EQU TRUE ; PPP: ENABLE PPP DRIVER SD CARD SUPPORT PPPSDTRACE .EQU 1 ; PPP: SD CARD TRACE LEVEL (0=NO,1=ERRORS,2=ALL) PPPCONENABLE .EQU TRUE ; PPP: ENABLE PPP DRIVER VIDEO/KBD SUPPORT ; HDSKENABLE .EQU FALSE ; HDSK: ENABLE SIMH HDSK DISK DRIVER (HDSK.ASM) ; PIO_4P .EQU FALSE ; PIO: ENABLE PARALLEL PORT DRIVER FOR ECB 4P BOARD PIO_ZP .EQU FALSE ; PIO: ENABLE PARALLEL PORT DRIVER FOR ECB ZILOG PERIPHERALS BOARD (PIO.ASM) PIO_SBC .EQU FALSE ; PIO: ENABLE PARALLEL PORT DRIVER FOR 8255 CHIP PIOSBASE .EQU $60 ; PIO: PIO REGISTERS BASE ADR FOR SBC PPI ; UFENABLE .EQU FALSE ; UF: ENABLE ECB USB FIFO DRIVER (UF.ASM) ; SN76489ENABLE .EQU FALSE ; SN76489 SOUND DRIVER AY38910ENABLE .EQU FALSE ; AY: AY-3-8910 / YM2149 SOUND DRIVER SPKENABLE .EQU FALSE ; SPK: ENABLE RTC LATCH IOBIT SOUND DRIVER (SPK.ASM) ; ; DMAENABLE .EQU FALSE ; DMA: ENABLE DMA DRIVER (DMA.ASM) DMABASE .EQU $E0 ; DMA: DMA BASE ADDRESS DMAMODE .EQU DMAMODE_NONE ; DMA: DMA MODE (NONE|ECB|Z180|Z280|RC|MBC)
//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2018 ArangoDB GmbH, Cologne, Germany /// /// 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Simon Grätzer //////////////////////////////////////////////////////////////////////////////// #include "ActiveFailoverJob.h" #include "Agency/AgentInterface.h" #include "Agency/Job.h" #include "Agency/JobContext.h" #include "Agency/Store.h" #include "Cluster/ClusterHelpers.h" #include "VocBase/voc-types.h" using namespace arangodb; using namespace arangodb::consensus; ActiveFailoverJob::ActiveFailoverJob(Node const& snapshot, AgentInterface* agent, std::string const& jobId, std::string const& creator, std::string const& failed) : Job(NOTFOUND, snapshot, agent, jobId, creator), _server(failed) {} ActiveFailoverJob::ActiveFailoverJob(Node const& snapshot, AgentInterface* agent, JOB_STATUS status, std::string const& jobId) : Job(status, snapshot, agent, jobId) { // Get job details from agency: std::string path = pos[status] + _jobId + "/"; auto tmp_server = _snapshot.hasAsString(path + "server"); auto tmp_creator = _snapshot.hasAsString(path + "creator"); if (tmp_server.second && tmp_creator.second) { _server = tmp_server.first; _creator = tmp_creator.first; } else { std::stringstream err; err << "Failed to find job " << _jobId << " in agency."; LOG_TOPIC("c756b", ERR, Logger::SUPERVISION) << err.str(); finish(tmp_server.first, "", false, err.str()); _status = FAILED; } } ActiveFailoverJob::~ActiveFailoverJob() {} void ActiveFailoverJob::run(bool& aborts) { runHelper(_server, "", aborts); } bool ActiveFailoverJob::create(std::shared_ptr<VPackBuilder> envelope) { LOG_TOPIC("3f7ab", DEBUG, Logger::SUPERVISION) << "Todo: Handle failover for leader " + _server; bool selfCreate = (envelope == nullptr); // Do we create ourselves? if (selfCreate) { _jb = std::make_shared<Builder>(); } else { _jb = envelope; } auto now = timepointToString(std::chrono::system_clock::now()); { VPackArrayBuilder transaction(_jb.get()); { VPackObjectBuilder operations(_jb.get()); // Todo entry _jb->add(VPackValue(toDoPrefix + _jobId)); { VPackObjectBuilder todo(_jb.get()); _jb->add("creator", VPackValue(_creator)); _jb->add("type", VPackValue("activeFailover")); _jb->add("server", VPackValue(_server)); _jb->add("jobId", VPackValue(_jobId)); _jb->add("timeCreated", VPackValue(now)); } // todo // FailedServers entry [] _jb->add(VPackValue(failedServersPrefix + "/" + _server)); { VPackArrayBuilder failedServers(_jb.get()); } } // Operations // Preconditions { VPackObjectBuilder health(_jb.get()); // Status should still be BAD addPreconditionServerHealth(*_jb, _server, Supervision::HEALTH_STATUS_BAD); // Target/FailedServers does not already include _server _jb->add(VPackValue(failedServersPrefix + "/" + _server)); { VPackObjectBuilder old(_jb.get()); _jb->add("oldEmpty", VPackValue(true)); } // Target/FailedServers is still as in the snapshot _jb->add(VPackValue(failedServersPrefix)); { VPackObjectBuilder old(_jb.get()); _jb->add("old", _snapshot(failedServersPrefix).toBuilder().slice()); } } // Preconditions } // transactions _status = TODO; if (!selfCreate) { return true; } write_ret_t res = singleWriteTransaction(_agent, *_jb); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { return true; } _status = NOTFOUND; LOG_TOPIC("3e5b0", INFO, Logger::SUPERVISION) << "Failed to insert job " + _jobId; return false; } bool ActiveFailoverJob::start(bool&) { // If anything throws here, the run() method catches it and finishes // the job. // Fail job, if Health back to not FAILED if (checkServerHealth(_snapshot, _server) != Supervision::HEALTH_STATUS_FAILED) { std::string reason = "Server " + _server + " is no longer failed. " + "Not starting ActiveFailoverJob job"; LOG_TOPIC("b1d34", INFO, Logger::SUPERVISION) << reason; return finish(_server, "", true, reason); // move to /Target/Finished } auto leader = _snapshot.hasAsSlice(asyncReplLeader); if (!leader.second || leader.first.compareString(_server) != 0) { std::string reason = "Server " + _server + " is not the current replication leader"; LOG_TOPIC("d468e", INFO, Logger::SUPERVISION) << reason; return finish(_server, "", true, reason); // move to /Target/Finished } // Abort job blocking server if abortable auto jobId = _snapshot.hasAsString(blockedServersPrefix + _server); if (jobId.second && !abortable(_snapshot, jobId.first)) { return false; } else if (jobId.second) { JobContext(PENDING, jobId.first, _snapshot, _agent).abort(); } // Todo entry Builder todo; { VPackArrayBuilder t(&todo); if (_jb == nullptr) { try { _snapshot(toDoPrefix + _jobId).toBuilder(todo); } catch (std::exception const&) { LOG_TOPIC("26fec", INFO, Logger::SUPERVISION) << "Failed to get key " + toDoPrefix + _jobId + " from agency snapshot"; return false; } } else { todo.add(_jb->slice()[0].get(toDoPrefix + _jobId)); } } // Todo entry std::string newLeader = findBestFollower(); if (newLeader.empty() || _server == newLeader) { LOG_TOPIC("a6da3", INFO, Logger::SUPERVISION) << "No follower for fail-over available, will retry"; return false; // job will retry later } LOG_TOPIC("2ef54", INFO, Logger::SUPERVISION) << "Selected '" << newLeader << "' as leader"; // Enter pending, remove todo Builder pending; { VPackArrayBuilder listOfTransactions(&pending); { VPackObjectBuilder operations(&pending); addPutJobIntoSomewhere(pending, "Finished", todo.slice()[0]); addRemoveJobFromSomewhere(pending, "ToDo", _jobId); pending.add(asyncReplLeader, VPackValue(newLeader)); } // mutation part of transaction done // Preconditions { VPackObjectBuilder precondition(&pending); // Failed condition persists addPreconditionServerHealth(pending, _server, Supervision::HEALTH_STATUS_FAILED); // Destination server still in good condition addPreconditionServerHealth(pending, newLeader, Supervision::HEALTH_STATUS_GOOD); // Destination server should not be blocked by another job addPreconditionServerNotBlocked(pending, newLeader); // AsyncReplication leader must be the failed server addPreconditionUnchanged(pending, asyncReplLeader, leader.first); } // precondition done } // array for transaction done // Transact to agency write_ret_t res = singleWriteTransaction(_agent, pending); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { _status = FINISHED; LOG_TOPIC("8c325", INFO, Logger::SUPERVISION) << "Finished: ActiveFailoverJob server " << _server << " failover to " << newLeader; return true; } LOG_TOPIC("bcf05", INFO, Logger::SUPERVISION) << "Precondition failed for ActiveFailoverJob " + _jobId; return false; } JOB_STATUS ActiveFailoverJob::status() { if (_status != PENDING) { return _status; } TRI_ASSERT(false); // PENDING is not an option for this job, since it // travels directly from ToDo to Finished or Failed return _status; } arangodb::Result ActiveFailoverJob::abort() { // We can assume that the job is in ToDo or not there: if (_status == NOTFOUND || _status == FINISHED || _status == FAILED) { return Result(TRI_ERROR_SUPERVISION_GENERAL_FAILURE, "Failed aborting addFollower job beyond pending stage"); } Result result; // Can now only be TODO or PENDING if (_status == TODO) { finish("", "", false, "job aborted"); return result; } TRI_ASSERT(false); // cannot happen, since job moves directly to FINISHED return result; } typedef std::pair<std::string, TRI_voc_tick_t> ServerTick; /// Try to select the follower most in-sync with failed leader std::string ActiveFailoverJob::findBestFollower() { std::vector<std::string> healthy = healthyServers(_snapshot); // the failed leader should never appear as healthy TRI_ASSERT(std::find(healthy.begin(), healthy.end(), _server) == healthy.end()); // blocked; (not sure if this can even happen) try { for (auto const& srv : _snapshot(blockedServersPrefix).children()) { healthy.erase(std::remove(healthy.begin(), healthy.end(), srv.first), healthy.end()); } } catch (...) { } std::vector<ServerTick> ticks; try { // collect tick values from transient state query_t trx = std::make_unique<VPackBuilder>(); { VPackArrayBuilder transactions(trx.get()); VPackArrayBuilder operations(trx.get()); trx->add(VPackValue("/" + Job::agencyPrefix + asyncReplTransientPrefix)); } trans_ret_t res = _agent->transient(std::move(trx)); if (!res.accepted) { LOG_TOPIC("dbce2", ERR, Logger::SUPERVISION) << "could not read from transient while" << " determining follower ticks"; return ""; } VPackSlice resp = res.result->slice(); if (!resp.isArray() || resp.length() == 0) { LOG_TOPIC("dd849", ERR, Logger::SUPERVISION) << "no follower ticks in transient store"; return ""; } VPackSlice obj = resp.at(0).get<std::string>( {Job::agencyPrefix, std::string("AsyncReplication")}); for (VPackObjectIterator::ObjectPair pair : VPackObjectIterator(obj)) { std::string srvUUID = pair.key.copyString(); bool isAvailable = std::find(healthy.begin(), healthy.end(), srvUUID) != healthy.end(); if (!isAvailable) { continue; // skip inaccessible servers } TRI_ASSERT(srvUUID != _server); // assumption: _server is unhealthy VPackSlice leader = pair.value.get("leader"); // broken leader VPackSlice lastTick = pair.value.get("lastTick"); if (leader.isString() && leader.isEqualString(_server) && lastTick.isNumber()) { ticks.emplace_back(std::move(srvUUID), lastTick.getUInt()); } } } catch (basics::Exception const& e) { LOG_TOPIC("66318", ERR, Logger::SUPERVISION) << "could not determine follower: " << e.message(); } catch (std::exception const& e) { LOG_TOPIC("92baa", ERR, Logger::SUPERVISION) << "could not determine follower: " << e.what(); } catch (...) { LOG_TOPIC("567b2", ERR, Logger::SUPERVISION) << "internal error while determining best follower"; } std::sort(ticks.begin(), ticks.end(), [&](ServerTick const& a, ServerTick const& b) { return a.second > b.second; }); if (!ticks.empty()) { TRI_ASSERT(ticks.size() == 1 || ticks[0].second >= ticks[1].second); return ticks[0].first; } LOG_TOPIC("f94ec", ERR, Logger::SUPERVISION) << "no follower ticks available"; return ""; // fallback to any available server }
/* MIT License Copyright (c) 2018 Antonio Alexander Brewer (tonton81) - https://github.com/tonton81 Designed and tested for PJRC Teensy 4.0. Forum link : https://forum.pjrc.com/threads/56035-FlexCAN_T4-FlexCAN-for-Teensy-4?highlight=flexcan_t4 Thanks goes to skpang, mjs513, and collin for tech/testing support 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 <isotp_server.h> #include "Arduino.h" int isotp_server_Base::buffer_hosts = 0; ISOTPSERVER_FUNC ISOTPSERVER_OPT::isotp_server() { _ISOTPSERVER_OBJ[isotp_server_Base::buffer_hosts] = this; isotp_server_Base::buffer_hosts++; for ( int i = 3; i > -1; i-- ) { if ( ((request >> (i * 8)) & 0xFF) ) break; request_size--; } header[0] = (1U << 4) | len >> 8; header[1] = (uint8_t)len; } ISOTPSERVER_FUNC void ISOTPSERVER_OPT::send_first_frame() { index_sequence = 1; CAN_message_t msg; msg.id = canid; msg.flags.extended = extended; if ( len <= 7 ) { memset(&msg.buf[0], padding_value, 8); msg.buf[0] = len; memmove(&msg.buf[1], &buffer[0], len); if ( _isotp_server_busToWrite ) _isotp_server_busToWrite->write(msg); return; } msg.len = 8; memmove(&msg.buf[0], &header[0], 2); memmove(&msg.buf[2], &buffer[0], 6); if ( _isotp_server_busToWrite ) _isotp_server_busToWrite->write(msg); } ISOTPSERVER_FUNC bool ISOTPSERVER_OPT::send_next_frame() { if ( index_pos >= len ) return 0; CAN_message_t msg; msg.id = canid; msg.flags.extended = extended; msg.len = 8; msg.buf[0] = (2U << 4) | (index_sequence & 0xF); memmove(&msg.buf[1], &buffer[index_pos], constrain((len - index_pos), 1, 7)); index_sequence++; if ((len - index_pos) < 7) for ( int i = (len - index_pos + 1); i < 8; i++ ) msg.buf[i] = 0xA5; if ( _isotp_server_busToWrite ) _isotp_server_busToWrite->write(msg); index_pos += 7; return 1; } ISOTPSERVER_FUNC void ISOTPSERVER_OPT::_process_frame_data(const CAN_message_t &msg) { if ( !isotp_enabled ) return; #if defined(TEENSYDUINO) if ( msg.bus != readBus ) return; #endif if ( msg.id == canid ) { CAN_message_t msgCopy = msg; uint8_t request_array[4] = { (uint8_t)(request >> 24), (uint8_t)(request >> 16), (uint8_t)(request >> 8), (uint8_t)(request) }; memmove(&msgCopy.buf[0], &request_array[4 - request_size], request_size); bool request_match = true; for ( int i = 0; i < 4; i++ ) { if ( msg.buf[i] != msgCopy.buf[i] ) { request_match = false; break; } } if ( request_match ) { send_first_frame(); index_pos = 6; return; } if ( msg.buf[0] & (3U << 4) ) { /* flow control frame */ if ( !msg.buf[1] ) { /* block size */ bool sent = 1; while ( sent ) { sent = send_next_frame(); if ( msg.buf[2] < 128 ) delay(msg.buf[2]); else if ( msg.buf[2] == constrain(msg.buf[2], 0xF1, 0xF9) ) { delayMicroseconds(map(msg.buf[2], 0xF1, 0xF9, 100, 900)); } } } else { for ( int i = 0; i < msg.buf[1]; i++ ) { send_next_frame(); if ( msg.buf[2] < 128 ) delay(msg.buf[2]); else if ( msg.buf[2] == constrain(msg.buf[2], 0xF1, 0xF9) ) { delayMicroseconds(map(msg.buf[2], 0xF1, 0xF9, 100, 900)); } } } } } } void ext_output3(const CAN_message_t &msg) { for ( int i = 0; i < isotp_server_Base::buffer_hosts; i++ ) if ( _ISOTPSERVER_OBJ[i] ) _ISOTPSERVER_OBJ[i]->_process_frame_data(msg); }
; A253887: Row index of n in A191450: a(3n) = 2n, a(3n+1) = 2n+1, a(3n+2) = a(n+1). ; 1,1,2,3,1,4,5,2,6,7,3,8,9,1,10,11,4,12,13,5,14,15,2,16,17,6,18,19,7,20,21,3,22,23,8,24,25,9,26,27,1,28,29,10,30,31,11,32,33,4,34,35,12,36,37,13,38,39,5,40,41,14,42,43,15,44,45,2,46,47,16,48,49,17,50,51,6,52,53,18,54,55,19,56,57,7,58,59,20,60,61,21,62,63,3,64,65,22,66,67,23,68,69,8,70,71,24,72,73,25,74,75,9,76,77,26,78,79,27,80,81,1,82,83,28,84,85,29,86,87,10,88,89,30,90,91,31,92,93,11,94,95,32,96,97,33,98,99,4,100,101,34,102,103,35,104,105,12,106,107,36,108,109,37,110,111,13,112,113,38,114,115,39,116,117,5,118,119,40,120,121,41,122,123,14,124,125,42,126,127,43,128,129,15,130,131,44,132,133,45,134,135,2,136,137,46,138,139,47,140,141,16,142,143,48,144,145,49,146,147,17,148,149,50,150,151,51,152,153,6,154,155,52,156,157,53,158,159,18,160,161,54,162,163,55,164,165,19,166,167 mul $0,2 cal $0,38502 ; Remove 3's from n. mov $1,$0 div $1,3 add $1,15127 mul $1,3 sub $1,45381 div $1,3 add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x1d3ca, %r15 clflush (%r15) nop nop nop dec %r14 vmovups (%r15), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %rax nop nop nop dec %rax lea addresses_D_ht+0xd98a, %rsi lea addresses_A_ht+0xc68a, %rdi nop nop nop nop nop and $18612, %rdx mov $99, %rcx rep movsl nop nop and $59760, %r14 lea addresses_D_ht+0x16bce, %rcx nop nop add %rdx, %rdx movups (%rcx), %xmm1 vpextrq $0, %xmm1, %rdi nop xor %rax, %rax lea addresses_WT_ht+0xa88a, %rsi lea addresses_WC_ht+0xda2a, %rdi nop nop nop nop nop add $10281, %rbx mov $118, %rcx rep movsq nop nop nop nop xor %rcx, %rcx lea addresses_WC_ht+0x18a, %r14 clflush (%r14) nop nop nop nop nop add $5967, %rdx mov (%r14), %r15d nop nop nop nop inc %r15 lea addresses_WC_ht+0x240a, %rsi nop dec %rax and $0xffffffffffffffc0, %rsi movaps (%rsi), %xmm5 vpextrq $1, %xmm5, %rbx nop sub $52534, %rsi lea addresses_UC_ht+0xce8a, %rsi lea addresses_UC_ht+0x3ba, %rdi nop nop and %rdx, %rdx mov $101, %rcx rep movsq nop add $43997, %rdx lea addresses_WC_ht+0x1078e, %rbx add $49928, %rsi movw $0x6162, (%rbx) nop nop add %rsi, %rsi lea addresses_D_ht+0xa48a, %rbx nop nop add $16463, %r14 movups (%rbx), %xmm4 vpextrq $1, %xmm4, %rax nop nop nop nop cmp %rax, %rax lea addresses_UC_ht+0x6496, %rsi lea addresses_WC_ht+0x1825d, %rdi nop xor $24669, %r15 mov $58, %rcx rep movsb and %rdx, %rdx lea addresses_WT_ht+0x308a, %rsi lea addresses_normal_ht+0x5b8a, %rdi nop nop nop xor %rdx, %rdx mov $85, %rcx rep movsw add %rdx, %rdx lea addresses_WT_ht+0x9c0a, %rax nop nop sub %r14, %r14 movw $0x6162, (%rax) nop nop nop nop nop sub $36474, %rdi lea addresses_A_ht+0x88ea, %rsi lea addresses_WT_ht+0xfe8a, %rdi nop dec %rbx mov $9, %rcx rep movsq nop nop nop xor $44779, %rbx lea addresses_WT_ht+0x85d6, %rsi nop nop nop nop and %rdx, %rdx movb (%rsi), %cl nop inc %r14 lea addresses_normal_ht+0x14cca, %rsi lea addresses_D_ht+0x4fd2, %rdi clflush (%rsi) clflush (%rdi) nop nop nop sub %rdx, %rdx mov $96, %rcx rep movsb nop nop nop inc %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r8 push %r9 push %rax push %rbx // Store lea addresses_UC+0xa583, %r10 cmp $16904, %r9 movw $0x5152, (%r10) nop nop nop nop nop add $15619, %r8 // Faulty Load lea addresses_UC+0x1268a, %r13 cmp %rbx, %rbx mov (%r13), %r10 lea oracles, %r9 and $0xff, %r10 shlq $12, %r10 mov (%r9,%r10,1), %r10 pop %rbx pop %rax pop %r9 pop %r8 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': True}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; Static Name Aliases ; TITLE bn_mulw.c .386 F_TEXT SEGMENT WORD USE16 PUBLIC 'CODE' F_TEXT ENDS _DATA SEGMENT WORD USE16 PUBLIC 'DATA' _DATA ENDS _CONST SEGMENT WORD USE16 PUBLIC 'CONST' _CONST ENDS _BSS SEGMENT WORD USE16 PUBLIC 'BSS' _BSS ENDS DGROUP GROUP _CONST, _BSS, _DATA ASSUME DS: DGROUP, SS: DGROUP F_TEXT SEGMENT ASSUME CS: F_TEXT PUBLIC _bn_mul_add_words _bn_mul_add_words PROC FAR ; Line 58 push bp push bx push esi push di push ds push es mov bp,sp ; w = 28 ; num = 26 ; ap = 22 ; rp = 18 xor esi,esi ;c=0; mov di,WORD PTR [bp+18] ; load r mov ds,WORD PTR [bp+20] ; load r mov bx,WORD PTR [bp+22] ; load a mov es,WORD PTR [bp+24] ; load a mov ecx,DWORD PTR [bp+28] ; load w mov bp,WORD PTR [bp+26] ; load num shr bp,1 ; div count by 4 and do groups of 4 shr bp,1 je $L555 $L546: mov eax,ecx mul DWORD PTR es:[bx] ; w* *a add eax,DWORD PTR ds:[di] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di],eax mov esi,edx ; mov eax,ecx mul DWORD PTR es:[bx+4] ; w* *a add eax,DWORD PTR ds:[di+4] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di+4],eax mov esi,edx ; mov eax,ecx mul DWORD PTR es:[bx+8] ; w* *a add eax,DWORD PTR ds:[di+8] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di+8],eax mov esi,edx ; mov eax,ecx mul DWORD PTR es:[bx+12] ; w* *a add eax,DWORD PTR ds:[di+12] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di+12],eax mov esi,edx ; add bx,16 add di,16 ; dec bp je $L555 jmp $L546 ; ; $L555: mov bp,sp mov bp,WORD PTR [bp+26] ; load num and bp,3 dec bp js $L547m mov eax,ecx mul DWORD PTR es:[bx] ; w* *a add eax,DWORD PTR ds:[di] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di],eax mov esi,edx dec bp js $L547m ; Note that we are now testing for -1 ; mov eax,ecx mul DWORD PTR es:[bx+4] ; w* *a add eax,DWORD PTR ds:[di+4] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di+4],eax mov esi,edx dec bp js $L547m ; mov eax,ecx mul DWORD PTR es:[bx+8] ; w* *a add eax,DWORD PTR ds:[di+8] ; + *r adc edx,0 adc eax,esi adc edx,0 mov DWORD PTR ds:[di+8],eax mov esi,edx $L547m: mov eax,esi mov edx,esi shr edx,16 pop es pop ds pop di pop esi pop bx pop bp ret nop _bn_mul_add_words ENDP PUBLIC _bn_mul_words _bn_mul_words PROC FAR ; Line 76 push bp push bx push esi push di push ds push es xor esi,esi mov bp,sp mov di,WORD PTR [bp+18] ; r mov ds,WORD PTR [bp+20] mov bx,WORD PTR [bp+22] ; a mov es,WORD PTR [bp+24] mov ecx,DWORD PTR [bp+28] ; w mov bp,WORD PTR [bp+26] ; num $FC743: mov eax,ecx mul DWORD PTR es:[bx] add eax,esi adc edx,0 mov DWORD PTR ds:[di],eax mov esi,edx dec bp je $L764 ; mov eax,ecx mul DWORD PTR es:[bx+4] add eax,esi adc edx,0 mov DWORD PTR ds:[di+4],eax mov esi,edx dec bp je $L764 ; mov eax,ecx mul DWORD PTR es:[bx+8] add eax,esi adc edx,0 mov DWORD PTR ds:[di+8],eax mov esi,edx dec bp je $L764 ; mov eax,ecx mul DWORD PTR es:[bx+12] add eax,esi adc edx,0 mov DWORD PTR ds:[di+12],eax mov esi,edx dec bp je $L764 ; add bx,16 add di,16 jmp $FC743 nop $L764: mov eax,esi mov edx,esi shr edx,16 pop es pop ds pop di pop esi pop bx pop bp ret nop _bn_mul_words ENDP PUBLIC _bn_sqr_words _bn_sqr_words PROC FAR ; Line 92 push bp push bx push si push di push ds push es mov bp,sp mov si,WORD PTR [bp+16] mov ds,WORD PTR [bp+18] mov di,WORD PTR [bp+20] mov es,WORD PTR [bp+22] mov bx,WORD PTR [bp+24] mov bp,bx ; save a memory lookup later shr bx,1 ; div count by 4 and do groups of 4 shr bx,1 je $L666 $L765: mov eax,DWORD PTR es:[di] mul eax mov DWORD PTR ds:[si],eax mov DWORD PTR ds:[si+4],edx ; mov eax,DWORD PTR es:[di+4] mul eax mov DWORD PTR ds:[si+8],eax mov DWORD PTR ds:[si+12],edx ; mov eax,DWORD PTR es:[di+8] mul eax mov DWORD PTR ds:[si+16],eax mov DWORD PTR ds:[si+20],edx ; mov eax,DWORD PTR es:[di+12] mul eax mov DWORD PTR ds:[si+24],eax mov DWORD PTR ds:[si+28],edx ; add di,16 add si,32 dec bx je $L666 jmp $L765 $L666: and bp,3 dec bp ; The copied value of bx (num) js $L645 ; mov eax,DWORD PTR es:[di] mul eax mov DWORD PTR ds:[si],eax mov DWORD PTR ds:[si+4],edx dec bp js $L645 ; mov eax,DWORD PTR es:[di+4] mul eax mov DWORD PTR ds:[si+8],eax mov DWORD PTR ds:[si+12],edx dec bp js $L645 ; mov eax,DWORD PTR es:[di+8] mul eax mov DWORD PTR ds:[si+16],eax mov DWORD PTR ds:[si+20],edx $L645: pop es pop ds pop di pop si pop bx pop bp ret _bn_sqr_words ENDP PUBLIC _bn_div64 _bn_div64 PROC FAR push bp mov bp,sp mov edx, DWORD PTR [bp+6] mov eax, DWORD PTR [bp+10] div DWORD PTR [bp+14] mov edx,eax shr edx,16 pop bp ret _bn_div64 ENDP PUBLIC _bn_add_words _bn_add_words PROC FAR ; Line 58 push bp push bx push esi push di push ds push es mov bp,sp ; w = 28 ; num = 26 ; ap = 22 ; rp = 18 xor esi,esi ;c=0; mov bx,WORD PTR [bp+18] ; load low r mov si,WORD PTR [bp+22] ; load a mov es,WORD PTR [bp+24] ; load a mov di,WORD PTR [bp+26] ; load b mov ds,WORD PTR [bp+28] ; load b mov dx,WORD PTR [bp+30] ; load num xor ecx,ecx dec dx js $L547a $L5477: mov eax,DWORD PTR es:[si] ; *a add eax,ecx mov ecx,0 adc ecx,0 add si,4 ; a++ add eax,DWORD PTR ds:[di] ; + *b adc ecx,0 mov ds,WORD PTR [bp+20] add di,4 mov DWORD PTR ds:[bx],eax mov ds,WORD PTR [bp+28] add bx,4 dec dx js $L547a ; Note that we are now testing for -1 jmp $L5477 ; $L547a: mov eax,ecx mov edx,ecx shr edx,16 pop es pop ds pop di pop esi pop bx pop bp ret nop _bn_add_words ENDP F_TEXT ENDS END
dnl MIPS32 umul_ppmm -- longlong.h support. dnl Copyright 1999, 2002 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 INPUT PARAMETERS C plp $4 C u $5 C v $6 ASM_START() PROLOGUE(mpn_umul_ppmm) multu $5,$6 mflo $3 mfhi $2 j $31 sw $3,0($4) EPILOGUE(mpn_umul_ppmm)
//===-- SlotIndexes.cpp - Slot Indexes Pass ------------------------------===// // // 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 // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/SlotIndexes.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Config/llvm-config.h" #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; #define DEBUG_TYPE "slotindexes" char SlotIndexes::ID = 0; SlotIndexes::SlotIndexes() : MachineFunctionPass(ID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); } SlotIndexes::~SlotIndexes() { // The indexList's nodes are all allocated in the BumpPtrAllocator. indexList.clearAndLeakNodesUnsafely(); } INITIALIZE_PASS(SlotIndexes, DEBUG_TYPE, "Slot index numbering", false, false) STATISTIC(NumLocalRenum, "Number of local renumberings"); void SlotIndexes::getAnalysisUsage(AnalysisUsage &au) const { au.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(au); } void SlotIndexes::releaseMemory() { mi2iMap.clear(); MBBRanges.clear(); idx2MBBMap.clear(); indexList.clear(); ileAllocator.Reset(); } bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) { // Compute numbering as follows: // Grab an iterator to the start of the index list. // Iterate over all MBBs, and within each MBB all MIs, keeping the MI // iterator in lock-step (though skipping it over indexes which have // null pointers in the instruction field). // At each iteration assert that the instruction pointed to in the index // is the same one pointed to by the MI iterator. This // FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should // only need to be set up once after the first numbering is computed. mf = &fn; // Check that the list contains only the sentinal. assert(indexList.empty() && "Index list non-empty at initial numbering?"); assert(idx2MBBMap.empty() && "Index -> MBB mapping non-empty at initial numbering?"); assert(MBBRanges.empty() && "MBB -> Index mapping non-empty at initial numbering?"); assert(mi2iMap.empty() && "MachineInstr -> Index mapping non-empty at initial numbering?"); unsigned index = 0; MBBRanges.resize(mf->getNumBlockIDs()); idx2MBBMap.reserve(mf->size()); indexList.push_back(createEntry(nullptr, index)); // Iterate over the function. for (MachineBasicBlock &MBB : *mf) { // Insert an index for the MBB start. SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block); for (MachineInstr &MI : MBB) { if (MI.isDebugOrPseudoInstr()) continue; // Insert a store index for the instr. indexList.push_back(createEntry(&MI, index += SlotIndex::InstrDist)); // Save this base index in the maps. mi2iMap.insert(std::make_pair( &MI, SlotIndex(&indexList.back(), SlotIndex::Slot_Block))); } // We insert one blank instructions between basic blocks. indexList.push_back(createEntry(nullptr, index += SlotIndex::InstrDist)); MBBRanges[MBB.getNumber()].first = blockStartIndex; MBBRanges[MBB.getNumber()].second = SlotIndex(&indexList.back(), SlotIndex::Slot_Block); idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, &MBB)); } // Sort the Idx2MBBMap llvm::sort(idx2MBBMap, less_first()); LLVM_DEBUG(mf->print(dbgs(), this)); // And we're done! return false; } void SlotIndexes::removeMachineInstrFromMaps(MachineInstr &MI, bool AllowBundled) { assert((AllowBundled || !MI.isBundledWithPred()) && "Use removeSingleMachineInstrFromMaps() instead"); Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI); if (mi2iItr == mi2iMap.end()) return; SlotIndex MIIndex = mi2iItr->second; IndexListEntry &MIEntry = *MIIndex.listEntry(); assert(MIEntry.getInstr() == &MI && "Instruction indexes broken."); mi2iMap.erase(mi2iItr); // FIXME: Eventually we want to actually delete these indexes. MIEntry.setInstr(nullptr); } void SlotIndexes::removeSingleMachineInstrFromMaps(MachineInstr &MI) { Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI); if (mi2iItr == mi2iMap.end()) return; SlotIndex MIIndex = mi2iItr->second; IndexListEntry &MIEntry = *MIIndex.listEntry(); assert(MIEntry.getInstr() == &MI && "Instruction indexes broken."); mi2iMap.erase(mi2iItr); // When removing the first instruction of a bundle update mapping to next // instruction. if (MI.isBundledWithSucc()) { // Only the first instruction of a bundle should have an index assigned. assert(!MI.isBundledWithPred() && "Should be first bundle instruction"); MachineBasicBlock::instr_iterator Next = std::next(MI.getIterator()); MachineInstr &NextMI = *Next; MIEntry.setInstr(&NextMI); mi2iMap.insert(std::make_pair(&NextMI, MIIndex)); return; } else { // FIXME: Eventually we want to actually delete these indexes. MIEntry.setInstr(nullptr); } } // Renumber indexes locally after curItr was inserted, but failed to get a new // index. void SlotIndexes::renumberIndexes(IndexList::iterator curItr) { // Number indexes with half the default spacing so we can catch up quickly. const unsigned Space = SlotIndex::InstrDist/2; static_assert((Space & 3) == 0, "InstrDist must be a multiple of 2*NUM"); IndexList::iterator startItr = std::prev(curItr); unsigned index = startItr->getIndex(); do { curItr->setIndex(index += Space); ++curItr; // If the next index is bigger, we have caught up. } while (curItr != indexList.end() && curItr->getIndex() <= index); LLVM_DEBUG(dbgs() << "\n*** Renumbered SlotIndexes " << startItr->getIndex() << '-' << index << " ***\n"); ++NumLocalRenum; } // Repair indexes after adding and removing instructions. void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End) { // FIXME: Is this really necessary? The only caller repairIntervalsForRange() // does the same thing. // Find anchor points, which are at the beginning/end of blocks or at // instructions that already have indexes. while (Begin != MBB->begin() && !hasIndex(*Begin)) --Begin; while (End != MBB->end() && !hasIndex(*End)) ++End; bool includeStart = (Begin == MBB->begin()); SlotIndex startIdx; if (includeStart) startIdx = getMBBStartIdx(MBB); else startIdx = getInstructionIndex(*Begin); SlotIndex endIdx; if (End == MBB->end()) endIdx = getMBBEndIdx(MBB); else endIdx = getInstructionIndex(*End); // FIXME: Conceptually, this code is implementing an iterator on MBB that // optionally includes an additional position prior to MBB->begin(), indicated // by the includeStart flag. This is done so that we can iterate MIs in a MBB // in parallel with SlotIndexes, but there should be a better way to do this. IndexList::iterator ListB = startIdx.listEntry()->getIterator(); IndexList::iterator ListI = endIdx.listEntry()->getIterator(); MachineBasicBlock::iterator MBBI = End; bool pastStart = false; while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) { assert(ListI->getIndex() >= startIdx.getIndex() && (includeStart || !pastStart) && "Decremented past the beginning of region to repair."); MachineInstr *SlotMI = ListI->getInstr(); MachineInstr *MI = (MBBI != MBB->end() && !pastStart) ? &*MBBI : nullptr; bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart); if (SlotMI == MI && !MBBIAtBegin) { --ListI; if (MBBI != Begin) --MBBI; else pastStart = true; } else if (MI && mi2iMap.find(MI) == mi2iMap.end()) { if (MBBI != Begin) --MBBI; else pastStart = true; } else { --ListI; if (SlotMI) removeMachineInstrFromMaps(*SlotMI); } } // In theory this could be combined with the previous loop, but it is tricky // to update the IndexList while we are iterating it. for (MachineBasicBlock::iterator I = End; I != Begin;) { --I; MachineInstr &MI = *I; if (!MI.isDebugOrPseudoInstr() && mi2iMap.find(&MI) == mi2iMap.end()) insertMachineInstrInMaps(MI); } } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void SlotIndexes::dump() const { for (const IndexListEntry &ILE : indexList) { dbgs() << ILE.getIndex() << " "; if (ILE.getInstr()) { dbgs() << *ILE.getInstr(); } else { dbgs() << "\n"; } } for (unsigned i = 0, e = MBBRanges.size(); i != e; ++i) dbgs() << "%bb." << i << "\t[" << MBBRanges[i].first << ';' << MBBRanges[i].second << ")\n"; } #endif // Print a SlotIndex to a raw_ostream. void SlotIndex::print(raw_ostream &os) const { if (isValid()) os << listEntry()->getIndex() << "Berd"[getSlot()]; else os << "invalid"; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) // Dump a SlotIndex to stderr. LLVM_DUMP_METHOD void SlotIndex::dump() const { print(dbgs()); dbgs() << "\n"; } #endif
; ; Copyright (c) 2020 Phillip Stevens ; ; This Source Code Form is subject to the terms of the Mozilla Public ; License, v. 2.0. If a copy of the MPL was not distributed with this ; file, You can obtain one at http://mozilla.org/MPL/2.0/. ; ; feilipu, August 2020 ; ;------------------------------------------------------------------------- ; asm_am9511_3_popf - am9511 APU pop float ;------------------------------------------------------------------------- ; ; Load IEEE-754 float from Am9511 APU stack ; ;------------------------------------------------------------------------- SECTION code_fp_am9511 EXTERN __IO_APU3_STATUS, __IO_APU3_DATA PUBLIC asm_am9511_3_popf .am9511_3_popf_wait ex (sp),hl ex (sp),hl .asm_am9511_3_popf ; float primitive ; pop a IEEE-754 floating point from the Am9511 stack. ; ; Convert from am9511_float to IEEE_float. ; ; enter : stack = ret0 ; ; exit : dehl = IEEE_float ; ; uses : af, bc, de, hl in a,(__IO_APU3_STATUS) ; read the APU status register rlca ; busy? and __IO_APU3_STATUS_BUSY jr C,am9511_3_popf_wait ld bc,__IO_APU3_DATA ; the address of the APU data port in bc in d,(c) ; load MSW from APU in e,(c) in h,(c) ; load LSW from APU in l,(c) and 07ch ; errors from status register jr NZ,errors sla e ; remove leading 1 from mantissa ld a,d ; capture exponent rla ; adjust twos complement exponent sra a ; with sign extention add 127-1 ; bias including shift binary point rl d ; get sign rra ; position sign and exponent rr e ; resposition exponent and mantissa ld d,a ; restore exponent ret .errors rrca ; relocate status bits (just for convenience) bit 5,a ; zero jr NZ,zero bit 1,a jr NZ,infinity ; overflow bit 2,a jr NZ,zero ; underflow .nan rl d ; get sign ld de,0feffh rr d ; nan exponent ld h,e ; nan mantissa ld l,e ret .infinity rl d ; get sign ld de,0fe80h rr d ; nan exponent ld hl,0 ; nan mantissa ret .zero ld de,0 ld h,d ld l,e ret
INCLUDE "graphics/grafix.inc" IF !__CPU_INTEL__ & !__CPU_GBZ80__ SECTION code_graphics PUBLIC Line EXTERN Line_r EXTERN __gfx_coords ; ; $Id: line.asm,v 1.7 2016-07-02 09:01:35 dom Exp $ ; ; ****************************************************************************** ; ; Draw a pixel line from (x0,y0) defined (H,L) - the starting point coordinate, ; to the end point (x1,y1). ; ; Design & programming by Gunther Strube, Copyright (C) InterLogic 1995 ; ; The routine checks the range of specified coordinates which is the boundaries ; of the graphics area (256x64 pixels). ; If a boundary error occurs the routine exits automatically. This may be ; useful if you are trying to draw a line longer than allowed or outside the ; graphics borders. Only the visible part will be drawn. ; ; Ths standard origin (0,0) is at the top left corner. ; ; The plot routine is defined by an address pointer in IX. ; This routine converts the absolute coordinates to a relative distance as (dx,dy) ; defining (COORDS) with (x0,y0) and a distance in (dx,dy). The drawing is then ; executed by Line_r ; ; IN: HL = (x0,y0) - x0 range is 0 to 255, y0 range is 0 to 63. ; DE = (x1,y1) - x1 range is 0 to 255, y1 range is 0 to 63. ; IX = pointer to plot routine that uses HL = (x,y) of plot coordinate. ; ; OUT: None. ; ; Registers changed after return: ; ..BCDEHL/IXIY/af...... same ; AF....../..../..bcdehl different ; .Line push de push hl IF maxx <> 256 ld a,h cp maxx jr nc, exit_line ; x0 coordinate out of range ld a,d cp maxx jr nc, exit_line ; x1 coordinate out of range ENDIF IF maxy <> 256 ld a,l cp maxy jr nc, exit_line ; y0 coordinate out of range ld a,e cp maxy jr nc, exit_line ; y1 coordinate out of range ENDIF ld (__gfx_coords),hl ; the starting point is now default push hl push de ld l,h ; L = x0 ld h,d ; H = x1 call distance ; x1 - x0 horisontal distance in HL pop de ex (sp),hl ; L = y0 ld h,e ; H = y1 call distance ; y1 - y0 vertical distance in HL pop de ex de,hl ; h.dist. = HL, v.dist. = DE call Line_r ; draw line... .exit_line pop hl pop de ret ; *************************************************************************** ; ; calculate distance ; IN: H = destination point ; L = source point ; ; OUT: h - l distance in HL ; .distance ld a,h sub l ld l,a ld h,0 ret nc ld h,-1 ret ENDIF
// Copyright 2018 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 "third_party/blink/renderer/platform/graphics/animation_worklet_mutator_dispatcher_impl.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/simple_test_tick_clock.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/platform/graphics/animation_worklet_mutator.h" #include "third_party/blink/renderer/platform/graphics/compositor_mutator_client.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_type.h" #include "third_party/blink/renderer/platform/testing/testing_platform_support.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include <memory> using ::testing::_; using ::testing::AtLeast; using ::testing::Mock; using ::testing::Return; using ::testing::Sequence; using ::testing::StrictMock; using ::testing::Truly; // This test uses actual threads since mutator logic requires it. This means we // have dependency on Blink platform to create threads. namespace blink { namespace { std::unique_ptr<Thread> CreateThread(const char* name) { return Platform::Current()->CreateThread( ThreadCreationParams(ThreadType::kTestThread).SetThreadNameForTest(name)); } class MockAnimationWorkletMutator : public GarbageCollected<MockAnimationWorkletMutator>, public AnimationWorkletMutator { public: MockAnimationWorkletMutator( scoped_refptr<base::SingleThreadTaskRunner> expected_runner) : expected_runner_(expected_runner) {} ~MockAnimationWorkletMutator() override {} std::unique_ptr<AnimationWorkletOutput> Mutate( std::unique_ptr<AnimationWorkletInput> input) override { return std::unique_ptr<AnimationWorkletOutput>(MutateRef(*input)); } // Blocks the worklet thread by posting a task that will complete only when // signaled. This blocking ensures that tests of async mutations do not // encounter race conditions when validating queuing strategies. void BlockWorkletThread() { PostCrossThreadTask( *expected_runner_, FROM_HERE, CrossThreadBindOnce( [](base::WaitableEvent* start_processing_event) { start_processing_event->Wait(); }, WTF::CrossThreadUnretained(&start_processing_event_))); } void UnblockWorkletThread() { start_processing_event_.Signal(); } MOCK_CONST_METHOD0(GetWorkletId, int()); MOCK_METHOD1(MutateRef, AnimationWorkletOutput*(const AnimationWorkletInput&)); scoped_refptr<base::SingleThreadTaskRunner> expected_runner_; base::WaitableEvent start_processing_event_; }; class MockCompositorMutatorClient : public CompositorMutatorClient { public: MockCompositorMutatorClient( std::unique_ptr<AnimationWorkletMutatorDispatcherImpl> mutator) : CompositorMutatorClient(std::move(mutator)) {} ~MockCompositorMutatorClient() override {} // gmock cannot mock methods with move-only args so we forward it to ourself. void SetMutationUpdate( std::unique_ptr<cc::MutatorOutputState> output_state) override { SetMutationUpdateRef(output_state.get()); } MOCK_METHOD1(SetMutationUpdateRef, void(cc::MutatorOutputState* output_state)); }; class AnimationWorkletMutatorDispatcherImplTest : public ::testing::Test { public: void SetUp() override { auto mutator = std::make_unique<AnimationWorkletMutatorDispatcherImpl>( /*main_thread_task_runner=*/true); mutator_ = mutator.get(); client_ = std::make_unique<::testing::StrictMock<MockCompositorMutatorClient>>( std::move(mutator)); } void TearDown() override { mutator_ = nullptr; } std::unique_ptr<::testing::StrictMock<MockCompositorMutatorClient>> client_; AnimationWorkletMutatorDispatcherImpl* mutator_; }; std::unique_ptr<AnimationWorkletDispatcherInput> CreateTestMutatorInput() { AnimationWorkletInput::AddAndUpdateState state1{ {11, 1}, "test1", 5000, nullptr, nullptr}; AnimationWorkletInput::AddAndUpdateState state2{ {22, 2}, "test2", 5000, nullptr, nullptr}; auto input = std::make_unique<AnimationWorkletDispatcherInput>(); input->Add(std::move(state1)); input->Add(std::move(state2)); return input; } bool OnlyIncludesAnimation1(const AnimationWorkletInput& in) { return in.added_and_updated_animations.size() == 1 && in.added_and_updated_animations[0].worklet_animation_id.animation_id == 1; } TEST_F(AnimationWorkletMutatorDispatcherImplTest, RegisteredAnimatorShouldOnlyReceiveInputForItself) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(Truly(OnlyIncludesAnimation1))) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); mutator_->MutateSynchronously(CreateTestMutatorInput()); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, RegisteredAnimatorShouldNotBeMutatedWhenNoInput) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)).Times(0); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); AnimationWorkletInput::AddAndUpdateState state{ {22, 2}, "test2", 5000, nullptr, nullptr}; auto input = std::make_unique<AnimationWorkletDispatcherInput>(); input->Add(std::move(state)); mutator_->MutateSynchronously(std::move(input)); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, MutationUpdateIsNotInvokedWithNoRegisteredAnimators) { EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); std::unique_ptr<AnimationWorkletDispatcherInput> input = std::make_unique<AnimationWorkletDispatcherInput>(); mutator_->MutateSynchronously(std::move(input)); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, MutationUpdateIsNotInvokedWithNullOutput) { // Create a thread to run mutator tasks. std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)).Times(1).WillOnce(Return(nullptr)); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); mutator_->MutateSynchronously(CreateTestMutatorInput()); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, MutationUpdateIsInvokedCorrectlyWithSingleRegisteredAnimator) { // Create a thread to run mutator tasks. std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); mutator_->MutateSynchronously(CreateTestMutatorInput()); // The above call blocks on mutator threads running their tasks so we can // safely verify here. Mock::VerifyAndClearExpectations(client_.get()); // Ensure mutator is not invoked after unregistration. EXPECT_CALL(*first_mutator, MutateRef(_)).Times(0); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); mutator_->UnregisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator)); mutator_->MutateSynchronously(CreateTestMutatorInput()); Mock::VerifyAndClearExpectations(client_.get()); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, MutationUpdateInvokedCorrectlyWithTwoRegisteredAnimatorsOnSameThread) { std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); MockAnimationWorkletMutator* second_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(second_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*second_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(22)); EXPECT_CALL(*second_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); mutator_->MutateSynchronously(CreateTestMutatorInput()); } TEST_F( AnimationWorkletMutatorDispatcherImplTest, MutationUpdateInvokedCorrectlyWithTwoRegisteredAnimatorsOnDifferentThreads) { std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); std::unique_ptr<Thread> second_thread = CreateThread("SecondAnimationThread"); MockAnimationWorkletMutator* second_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( second_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(second_mutator), second_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*second_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(22)); EXPECT_CALL(*second_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); mutator_->MutateSynchronously(CreateTestMutatorInput()); // The above call blocks on mutator threads running their tasks so we can // safely verify here. Mock::VerifyAndClearExpectations(client_.get()); // Ensure first_mutator is not invoked after unregistration. mutator_->UnregisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator)); EXPECT_CALL(*first_mutator, GetWorkletId()).Times(0); EXPECT_CALL(*first_mutator, MutateRef(_)).Times(0); EXPECT_CALL(*second_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(22)); EXPECT_CALL(*second_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); mutator_->MutateSynchronously(CreateTestMutatorInput()); Mock::VerifyAndClearExpectations(client_.get()); } TEST_F(AnimationWorkletMutatorDispatcherImplTest, DispatcherShouldNotHangWhenMutatorGoesAway) { // Create a thread to run mutator tasks. std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()).WillRepeatedly(Return(11)); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); // Shutdown the thread so its task runner no longer executes tasks. first_thread.reset(); mutator_->MutateSynchronously(CreateTestMutatorInput()); Mock::VerifyAndClearExpectations(client_.get()); } // ----------------------------------------------------------------------- // Asynchronous version of tests. using MutatorDispatcherRef = scoped_refptr<AnimationWorkletMutatorDispatcherImpl>; class AnimationWorkletMutatorDispatcherImplAsyncTest : public AnimationWorkletMutatorDispatcherImplTest { public: AnimationWorkletMutatorDispatcher::AsyncMutationCompleteCallback CreateIntermediateResultCallback(MutateStatus expected_result) { return CrossThreadBindOnce( &AnimationWorkletMutatorDispatcherImplAsyncTest :: VerifyExpectedMutationResult, CrossThreadUnretained(this), expected_result); } AnimationWorkletMutatorDispatcher::AsyncMutationCompleteCallback CreateNotReachedCallback() { return CrossThreadBindOnce([](MutateStatus unused) { NOTREACHED() << "Mutate complete callback should not have been triggered"; }); } AnimationWorkletMutatorDispatcher::AsyncMutationCompleteCallback CreateTestCompleteCallback( MutateStatus expected_result = MutateStatus::kCompletedWithUpdate) { return CrossThreadBindOnce( &AnimationWorkletMutatorDispatcherImplAsyncTest :: VerifyCompletedMutationResultAndFinish, CrossThreadUnretained(this), expected_result); } // Executes run loop until quit closure is called. void WaitForTestCompletion() { run_loop_.Run(); } void VerifyExpectedMutationResult(MutateStatus expectation, MutateStatus result) { EXPECT_EQ(expectation, result); IntermediateResultCallbackRef(); } void VerifyCompletedMutationResultAndFinish(MutateStatus expectation, MutateStatus result) { EXPECT_EQ(expectation, result); run_loop_.Quit(); } // Verifying that intermediate result callbacks are invoked the correct number // of times. MOCK_METHOD0(IntermediateResultCallbackRef, void()); static const MutateQueuingStrategy kNormalPriority = MutateQueuingStrategy::kQueueAndReplaceNormalPriority; static const MutateQueuingStrategy kHighPriority = MutateQueuingStrategy::kQueueHighPriority; private: base::RunLoop run_loop_; }; TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, RegisteredAnimatorShouldOnlyReceiveInputForItself) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, RegisteredAnimatorShouldNotBeMutatedWhenNoInput) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); AnimationWorkletInput::AddAndUpdateState state{ {22, 2}, "test2", 5000, nullptr, nullptr}; auto input = std::make_unique<AnimationWorkletDispatcherInput>(); input->Add(std::move(state)); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_FALSE(mutator_->MutateAsynchronously(std::move(input), kNormalPriority, CreateNotReachedCallback())); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateIsNotInvokedWithNoRegisteredAnimators) { EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); std::unique_ptr<AnimationWorkletDispatcherInput> input = std::make_unique<AnimationWorkletDispatcherInput>(); EXPECT_FALSE(mutator_->MutateAsynchronously(std::move(input), kNormalPriority, CreateNotReachedCallback())); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateIsNotInvokedWithNullOutput) { // Create a thread to run mutator tasks. std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)).Times(1).WillOnce(Return(nullptr)); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(0); EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback(MutateStatus::kCompletedNoUpdate))); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateIsInvokedCorrectlyWithSingleRegisteredAnimator) { // Create a thread to run mutator tasks. std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); WaitForTestCompletion(); // Above call blocks until complete signal is received. Mock::VerifyAndClearExpectations(client_.get()); // Ensure mutator is not invoked after unregistration. mutator_->UnregisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator)); EXPECT_FALSE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateNotReachedCallback())); Mock::VerifyAndClearExpectations(client_.get()); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateInvokedCorrectlyWithTwoRegisteredAnimatorsOnSameThread) { std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); MockAnimationWorkletMutator* second_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(second_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*second_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(22)); EXPECT_CALL(*second_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); WaitForTestCompletion(); } TEST_F( AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateInvokedCorrectlyWithTwoRegisteredAnimatorsOnDifferentThreads) { std::unique_ptr<Thread> first_thread = CreateThread("FirstAnimationThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); std::unique_ptr<Thread> second_thread = CreateThread("SecondAnimationThread"); MockAnimationWorkletMutator* second_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( second_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(second_mutator), second_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*second_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(22)); EXPECT_CALL(*second_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateDroppedWhenBusy) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(1)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(1) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(1); // Block Responses until all requests have been queued. first_mutator->BlockWorkletThread(); // Response for first mutator call is blocked until after the second // call is sent. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); // Second request dropped since busy processing first. EXPECT_FALSE(mutator_->MutateAsynchronously(CreateTestMutatorInput(), MutateQueuingStrategy::kDrop, CreateNotReachedCallback())); // Unblock first request. first_mutator->UnblockWorkletThread(); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateQueuedWhenBusy) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(2)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(2) .WillOnce(Return(new AnimationWorkletOutput())) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); EXPECT_CALL(*this, IntermediateResultCallbackRef()).Times(1); // Block Responses until all requests have been queued. first_mutator->BlockWorkletThread(); // Response for first mutator call is blocked until after the second // call is sent. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateIntermediateResultCallback(MutateStatus::kCompletedWithUpdate))); // First request still processing, queue request. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); // Unblock first request. first_mutator->UnblockWorkletThread(); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateQueueWithReplacementWhenBusy) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(2)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(2) .WillOnce(Return(new AnimationWorkletOutput())) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); EXPECT_CALL(*this, IntermediateResultCallbackRef()).Times(2); // Block Responses until all requests have been queued. first_mutator->BlockWorkletThread(); // Response for first mutator call is blocked until after the second // call is sent. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateIntermediateResultCallback(MutateStatus::kCompletedWithUpdate))); // First request still processing, queue a second request, which will get // canceled by a third request. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateIntermediateResultCallback(MutateStatus::kCanceled))); // First request still processing, clobber second request in queue. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); // Unblock first request. first_mutator->UnblockWorkletThread(); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, MutationUpdateMultipleQueuesWhenBusy) { std::unique_ptr<Thread> first_thread = CreateThread("FirstThread"); MockAnimationWorkletMutator* first_mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( first_thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator( WrapCrossThreadPersistent(first_mutator), first_thread->GetTaskRunner()); EXPECT_CALL(*first_mutator, GetWorkletId()) .Times(AtLeast(3)) .WillRepeatedly(Return(11)); EXPECT_CALL(*first_mutator, MutateRef(_)) .Times(3) .WillOnce(Return(new AnimationWorkletOutput())) .WillOnce(Return(new AnimationWorkletOutput())) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(3); EXPECT_CALL(*this, IntermediateResultCallbackRef()).Times(2); // Block Responses until all requests have been queued. first_mutator->BlockWorkletThread(); // Response for first mutator call is blocked until after the second // call is sent. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateIntermediateResultCallback(MutateStatus::kCompletedWithUpdate))); // First request still processing, queue a second request. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); // First request still processing. This request uses a separate queue from the // second request. It should not replace the second request but should be // dispatched ahead of the second request. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kHighPriority, CreateIntermediateResultCallback(MutateStatus::kCompletedWithUpdate))); // Unblock first request. first_mutator->UnblockWorkletThread(); WaitForTestCompletion(); } TEST_F(AnimationWorkletMutatorDispatcherImplAsyncTest, HistogramTester) { const char* histogram_name = "Animation.AnimationWorklet.Dispatcher.AsynchronousMutateDuration"; base::HistogramTester histogram_tester; std::unique_ptr<base::TickClock> mock_clock = std::make_unique<base::SimpleTestTickClock>(); base::SimpleTestTickClock* mock_clock_ptr = static_cast<base::SimpleTestTickClock*>(mock_clock.get()); mutator_->SetClockForTesting(std::move(mock_clock)); std::unique_ptr<Thread> thread = CreateThread("MyThread"); MockAnimationWorkletMutator* mutator = MakeGarbageCollected<MockAnimationWorkletMutator>( thread->GetTaskRunner()); mutator_->RegisterAnimationWorkletMutator(WrapCrossThreadPersistent(mutator), thread->GetTaskRunner()); EXPECT_CALL(*mutator, GetWorkletId()) .Times(AtLeast(2)) .WillRepeatedly(Return(11)); EXPECT_CALL(*mutator, MutateRef(_)) .Times(2) .WillOnce(Return(new AnimationWorkletOutput())) .WillOnce(Return(new AnimationWorkletOutput())); EXPECT_CALL(*client_, SetMutationUpdateRef(_)).Times(2); // Block Responses until all requests have been queued. mutator->BlockWorkletThread(); base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(10); // Expected Elapsed time is the sum of all clock advancements until unblocked, // which totals to 30 ms. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kHighPriority, CreateIntermediateResultCallback(MutateStatus::kCompletedWithUpdate))); mock_clock_ptr->Advance(time_delta); // This request will get stomped by the next request, but the start time is // preserved. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateIntermediateResultCallback(MutateStatus::kCanceled))); mock_clock_ptr->Advance(time_delta); // Replaces previous request. Since 10 ms has elapsed prior to replacing the // previous request, the expected elapsed time is 20 ms. EXPECT_TRUE(mutator_->MutateAsynchronously( CreateTestMutatorInput(), kNormalPriority, CreateTestCompleteCallback())); mock_clock_ptr->Advance(time_delta); mutator->UnblockWorkletThread(); WaitForTestCompletion(); histogram_tester.ExpectTotalCount(histogram_name, 2); // Times are in microseconds. histogram_tester.ExpectBucketCount(histogram_name, 20000, 1); histogram_tester.ExpectBucketCount(histogram_name, 30000, 1); } } // namespace } // namespace blink
; A001700: a(n) = binomial(2*n+1, n+1): number of ways to put n+1 indistinguishable balls into n+1 distinguishable boxes = number of (n+1)-st degree monomials in n+1 variables = number of monotone maps from 1..n+1 to 1..n+1. ; 1,3,10,35,126,462,1716,6435,24310,92378,352716,1352078,5200300,20058300,77558760,300540195,1166803110,4537567650,17672631900,68923264410,269128937220,1052049481860,4116715363800,16123801841550,63205303218876,247959266474052,973469712824056,3824345300380220,15033633249770520,59132290782430712,232714176627630544,916312070471295267,3609714217008132870,14226520737620288370,56093138908331422716,221256270138418389602,873065282167813104916,3446310324346630677300,13608507434599516007800 mov $1,1 add $1,$0 add $1,$0 bin $1,$0 mov $0,$1
.file "vadd_c.c" .text .globl main .type main, @function main: .LFB2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl %edi, -4(%rbp) movq %rsi, -16(%rbp) movl $0, %eax popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE2: .size main, .-main .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609" .section .note.GNU-stack,"",@progbits
org $82FA00 print pc, " presets bank82 start" preset_load: { PHP LDA !MUSIC_DATA : STA !SRAM_MUSIC_DATA LDA !MUSIC_TRACK : STA !SRAM_MUSIC_TRACK JSL $809E93 ; Clear timer RAM JSR $819B ; Initialize IO registers JSR $82E2 ; Load standard BG3 tiles and sprite tiles, clear tilemaps JSR $82C5 ; Load initial palette if !FEATURE_PAL JSL $91DF72 ; Initialize Samus else JSL $91E00D ; Initialize Samus endif JSL preset_load_preset JSL preset_start_gameplay ; Start gameplay JSL $809A79 ; HUD routine when game is loading JSL $90AD22 ; Reset projectile data PHP REP #$30 LDY #$0020 LDX #$0000 .paletteLoop LDA $7EC180,x : STA $7EC380,x ; Target Samus' palette = [Samus' palette] INX #2 DEY #2 BNE .paletteLoop PLP LDA #$0000 STA $7EC400 ; Used as door fade timer STA $0727 ; Pause menu index LDA #$0001 STA $0723 ; Screen fade delay = 1 STA $0725 ; Screen fade counter = 1 JSL $80834B ; Enable NMI with $84 options JSL $868000 ; Enable enemy projectiles JSL $8483AD ; Enable PLMs JSL $8DC4C2 ; Enable palette FX objects JSL $888288 ; Enable HDMA objects JSL $878000 ; Enable animated tile objects JSL $908E0F ; Set liquid physics type LDA #$0006 : STA $0DA0 .loopSomething if !FEATURE_PAL JSL $A08CE7 ; Transfer enemy tiles to VRAM and initialize enemies else JSL $A08CD7 ; Transfer enemy tiles to VRAM and initialize enemies endif JSL $808338 ; Wait for NMI DEC $0DA0 ; Decrement $0DA0 BPL .loopSomething LDA #$0008 : STA !GAMEMODE %a8() : LDA #$0F : STA $51 : %a16() PHP REP #$30 LDY #$0200 LDX #$0000 .paletteLoop2 LDA $7EC200,x STA $7EC000,x ; Palettes = [target palettes] INX #2 DEY #2 BNE .paletteLoop2 PLP ; Fix Samus' palette if !FEATURE_PAL JSL $91DE1F else JSL $91DEBA endif ; Re-upload OOB viewer tiles if needed LDA !ram_oob_watch_active : BEQ .done_upload_sprite_oob_tiles JSL upload_sprite_oob_tiles .done_upload_sprite_oob_tiles JSL reset_all_counters STZ $0795 : STZ $0797 ; clear door transition flags ; Clear enemies if not in certain rooms LDA $079B : CMP #$9804 : BEQ .done_clearing_enemies CMP #$DD58 : BEQ .set_mb_state JSR clear_all_enemies .done_clearing_enemies PLP RTL .set_mb_state ; If glass is broken, assume we should skip MB1 LDA $7ED820 : BIT #$0004 : BEQ .done_clearing_enemies ; Set health to 1 as a hint this was done by a preset LDA #$0001 : STA $0FCC BRA .done_clearing_enemies } clear_all_enemies: { ; Clear enemies (8000 = solid to Samus, 0400 = Ignore Samus projectiles) LDA #$0000 .loop TAX : LDA $0F86,X : BIT #$8400 : BNE .done_clearing ORA #$0200 : STA $0F86,X .done_clearing TXA : CLC : ADC #$0040 : CMP #$0400 : BNE .loop STZ $0E52 ; unlock grey doors that require killing enemies RTS } preset_load_destination_state_and_tiles: { ; Original logic from $82E76B PHP : PHB REP #$30 PEA $8F00 PLB : PLB JSR $DDF1 ; Load destination room CRE bitset JSR $DE12 ; Load door header JSR $DE6F ; Load room header JSR $DEF2 ; Load state header if !RAW_TILE_GRAPHICS JML load_raw_tile_graphics else JMP $E78C endif } if !RAW_TILE_GRAPHICS ; This is similar to $82E97C except we overwrite the door dependent transfer to VRAM preset_load_library_background: { PHP : PHB : %ai16() JSL $80A29C ; Clear FX tilemap LDA $1964 : BEQ .done_fx_tilemap STA $4312 LDA #$5BE0 : STA $2116 LDA #$1801 : STA $4310 LDA #$008A : STA $4314 LDA #$0840 : STA $4315 %a8() LDA #$80 : STA $2115 LDA #$02 : STA $420B %a16() : CLC .done_fx_tilemap PEA $8F00 : PLB : PLB REP #$20 LDX $07BB LDY $0016,X : BPL .done .load_library_loop LDX $0000,Y : INY : INY JSR (preset_load_library_background_jump_table,X) BCC .load_library_loop .done PLB : PLP : RTL } preset_load_library_background_jump_table: dw $E9E5, $E9F9, $EA2D, $EA4E, $EA66, $EA56, $EA5E, preset_load_library_start_transfer_to_vram preset_load_library_start_transfer_to_vram: JML preset_load_library_transfer_to_vram preset_load_library_end_transfer_to_vram: RTS endif reset_all_counters: { LDA #$0000 STA !ram_room_has_set_rng STA $09DA : STA $09DC : STA $09DE : STA $09E0 STA !ram_seg_rt_frames : STA !ram_seg_rt_seconds : STA !ram_seg_rt_minutes STA !ram_realtime_room : STA !ram_last_realtime_room STA !ram_gametime_room : STA !ram_last_gametime_room STA !ram_last_room_lag : STA !ram_last_door_lag_frames : STA !ram_transition_counter RTL } startgame_seg_timer: { ; seg timer will be 1:50 (1 second, 50 frames) behind by the time it appears ; 20 frames more if the file was new ; initializing to 1:50 for now LDA #$0032 : STA !ram_seg_rt_frames LDA #$0001 : STA !ram_seg_rt_seconds LDA #$0000 : STA !ram_seg_rt_minutes JSL $808924 ; overwritten code RTL } preset_load_preset: { PHB LDA #$0000 STA $7E09D2 ; Current selected weapon STA $7E0A04 ; Auto-cancel item LDA #$5AFE : STA $0917 ; Load garbage into Layer 2 X position LDA #$FFFF : STA !ram_reset_segment_later ; check if custom preset is being loaded LDA !ram_custom_preset : BEQ .category_preset JSL custom_preset_load BRA .done .category_preset JSR category_preset_load .done PLB RTL } category_preset_load: { ; Get offset into preset data table LDA !sram_preset_category : STA $C3 ASL : CLC : ADC $C3 : TAX ; Get starting preset data bank into $C5 INX : LDA.l category_preset_data_table,X : STA $C4 : DEX ; Get preset address to load into $C3 LDA !ram_load_preset : STA !sram_last_preset : STA $C3 : STA $7F0002 LDA #$0000 : STA !ram_load_preset ; Get start of preset data into $C1 LDA.l category_preset_data_table,X : LDX #$0000 : STA $C1 ; If start of preset data is greater than preset address, ; then our preset address is in the next bank CMP $C3 : BCC .build_list_loop : BEQ .build_list_loop INC $C5 .build_list_loop ; Build list of presets to traverse LDA [$C3] : BEQ .prepare_traverse_list_loop INX : INX : STA $7F0002,X CMP $C3 : STA $C3 : BCC .build_list_loop ; We just crossed back into the starting bank DEC $C5 BRA .build_list_loop .prepare_traverse_list_loop ; Set bank to read data from STZ $00 : %a8() : LDA $C5 : PHA : PLB ; Set bank to store data to LDA #$7E : STA $C5 : %a16() .traverse_list_loop_with_bank_check ; Now traverse from the first preset until the last one LDA $7F0002,X : TAY : CMP $C1 : BCC .increment_bank_before_inner_loop INY : INY BRA .inner_loop_with_bank_check_load_address ; For each preset, load and store address and value pairs .inner_loop_with_bank_check STA $C3 : INY : INY CPY #$0000 : BEQ .increment_bank_before_load_value LDA ($00),Y : STA [$C3] : INY : INY .inner_loop_with_bank_check_load_address CPY #$0000 : BEQ .increment_bank_before_load_address LDA ($00),Y : CMP #$FFFF : BNE .inner_loop_with_bank_check DEX : DEX : BPL .traverse_list_loop_with_bank_check RTS .increment_bank_before_inner_loop %a8() : PHB : PLA : INC : PHA : PLB : %a16() INY : INY BRA .inner_loop_load_address .increment_bank_before_load_address %a8() : PHB : PLA : INC : PHA : PLB : %a16() LDY #$8000 BRA .inner_loop_load_address .increment_bank_before_load_value %a8() : PHB : PLA : INC : PHA : PLB : %a16() LDY #$8000 BRA .inner_loop_load_value .traverse_list_loop ; Continue traversing from the first preset until the last one LDA $7F0002,X : TAY : INY : INY BRA .inner_loop_load_address ; For each preset, load and store address and value pairs .inner_loop STA $C3 : INY : INY .inner_loop_load_value LDA ($00),Y : STA [$C3] : INY : INY .inner_loop_load_address LDA ($00),Y : CMP #$FFFF : BNE .inner_loop DEX : DEX : BPL .traverse_list_loop RTS } category_preset_data_table: dl preset_prkd_crateria_ceres_elevator dl preset_kpdr21_crateria_ceres_elevator dl preset_hundo_bombs_ceres_elevator dl preset_100early_crateria_ceres_elevator dl preset_rbo_bombs_ceres_elevator dl preset_pkrd_crateria_ceres_elevator dl preset_kpdr25_bombs_ceres_elevator dl preset_gtclassic_crateria_ceres_elevator dl preset_gtmax_crateria_ceres_elevator dl preset_14ice_crateria_ceres_elevator dl preset_14speed_crateria_ceres_elevator dl preset_100map_bombs_ceres_elevator dl preset_nintendopower_crateria_ceres_elevator dl preset_allbosskpdr_crateria_ceres_elevator dl preset_allbosspkdr_crateria_ceres_elevator dl preset_allbossprkd_crateria_ceres_elevator print pc, " presets bank82 end" org $82E8D9 JSL preset_room_setup_asm_fixes org $80F000 print pc, " presets bank80 start" ; This method is very similar to $80A07B (start gameplay) preset_start_gameplay: { PHP PHB PHK : PLB ; DB = $80 %ai16() SEI ; Disable IRQ STZ $420B ; Disable all (H)DMA STZ $07E9 ; Scrolling finished hook = 0 STZ $0943 ; Timer status = inactive JSL $828A9A ; Reset sound queues LDA #$FFFF : STA !DISABLE_SOUNDS JSL $80835D ; Disable NMI JSL $80985F ; Disable horizontal and vertical timer interrupts JSL preset_load_destination_state_and_tiles JSL $878016 ; Clear animated tile objects JSL $88829E ; Wait until the end of a v-blank and clear (H)DMA enable flags ; Set Samus last pose same as current pose LDA !SAMUS_POSE : STA !SAMUS_PREVIOUS_POSE LDA !SAMUS_POSE_DIRECTION : STA !SAMUS_PREVIOUS_POSE_DIRECTION ; Set Samus last position same as current position LDA !SAMUS_X : STA $0B10 : LDA !SAMUS_X_SUBPX : STA $0B12 LDA !SAMUS_Y : STA $0B14 : LDA !SAMUS_Y_SUBPX : STA $0B16 ; Set loading game state for Ceres LDA #$001F : STA $7ED914 LDA !AREA_ID : CMP #$0006 : BEQ .end_load_game_state ; Set loading game state for Zebes LDA #$0005 : STA $7ED914 LDA !SAMUS_POSE : BNE .end_load_game_state LDA !ROOM_ID : CMP #$91F8 : BNE .end_load_game_state ; If default pose at landing site then assume we are arriving on Zebes LDA #$0022 : STA $7ED914 LDA #$E8CD : STA $0A42 ; Lock Samus LDA #$E8DC : STA $0A44 ; Lock Samus .end_load_game_state ; Preserve layer 2 values we may have loaded from presets LDA $0919 : PHA LDA $0917 : PHA JSL $8882C1 ; Initialize special effects for new room JSL $8483C3 ; Clear PLMs JSL $868016 ; Clear enemy projectiles JSL $8DC4D8 ; Clear palette FX objects JSL $90AC8D ; Update beam graphics JSL $82E139 ; Load target colours for common sprites, beams and slashing enemies / pickups if !FEATURE_PAL JSL $A08A2E ; Load enemies else JSL $A08A1E ; Load enemies endif JSL $80A23F ; Clear BG2 tilemap if !RAW_TILE_GRAPHICS JSL preset_load_level_tile_tables_scrolls_plms_and_execute_asm else JSL $82E7D3 ; Load level data, CRE, tile table, scroll data, create PLMs and execute door ASM and room setup ASM endif JSL preset_scroll_fixes LDA !sram_preset_options : BIT !PRESETS_CLOSE_BLUE_DOORS : BNE .done_opening_doors LDA !SAMUS_POSE : BEQ .done_opening_doors CMP #$009B : BEQ .done_opening_doors JSR preset_open_all_blue_doors .done_opening_doors JSL $89AB82 ; Load FX if !RAW_TILE_GRAPHICS JSL preset_load_library_background else JSL $82E97C ; Load library background endif ; Pull layer 2 values, and use them if they are valid PLA : CMP #$5AFE : BEQ .calculate_layer_2 STA $0917 PLA : STA $0919 BRA .layer_2_loaded .calculate_layer_2 PLA ; Pull other layer 2 value but do not use it JSR $A2F9 ; Calculate layer 2 X position JSR $A33A ; Calculate layer 2 Y position LDA $0917 : STA $0921 ; BG2 X scroll = layer 2 X scroll position LDA $0919 : STA $0923 ; BG2 Y scroll = layer 2 Y scroll position .layer_2_loaded JSR $A37B ; Calculate BG positions ; Fix BG2 Y offsets for rooms with scrolling sky LDA !ROOM_ID : CMP #$91F8 : BEQ .bg_offsets_scrolling_sky CMP #$93FE : BEQ .bg_offsets_scrolling_sky CMP #$94FD : BEQ .bg_offsets_scrolling_sky BRA .bg_offsets_calculated .bg_offsets_scrolling_sky LDA $0915 : STA $0919 : STA $B7 STZ $0923 .bg_offsets_calculated JSL $80A176 ; Display the viewable part of the room ; Enable sounds STZ !DISABLE_SOUNDS JSL stop_all_sounds ; Clear music queue STZ $0629 : STZ $062B : STZ $062D : STZ $062F STZ $0631 : STZ $0633 : STZ $0635 : STZ $0637 STZ $0639 : STZ $063B : STZ $063D : STZ $063F ; If music fast off or preset off, treat music as already loaded LDA !sram_music_toggle : CMP #$0002 : BPL .done_music ; Compare to currently loaded music data LDA !SRAM_MUSIC_DATA : CMP !MUSIC_DATA : BEQ .done_load_music_data ; Clear track if necessary LDA !SRAM_MUSIC_TRACK : BEQ .load_music_data LDA #$0000 : JSL !MUSIC_ROUTINE .load_music_data LDA !MUSIC_DATA : TAX LDA !SRAM_MUSIC_DATA : STA !MUSIC_DATA TXA : CLC : ADC #$FF00 : JSL !MUSIC_ROUTINE BRA .load_music_track .done_load_music_data ; Compare to currently playing music LDA !SRAM_MUSIC_TRACK : CMP !MUSIC_TRACK : BEQ .done_music .load_music_track LDA !MUSIC_TRACK : TAX LDA !SRAM_MUSIC_TRACK : STA !MUSIC_TRACK TXA : JSL !MUSIC_ROUTINE .done_music JSL $80834B ; Enable NMI LDA #$0004 : STA $A7 ; Set optional next interrupt to Main gameplay JSL $80982A ; Enable horizontal and vertical timer interrupts LDA $7ED914 : CMP #$0022 : BEQ .done_unlock_samus LDA #$E695 : STA $0A42 ; Unlock Samus LDA #$E725 : STA $0A44 ; Unlock Samus .done_unlock_samus LDA #$9F55 : STA $0A6C ; Set X speed table pointer STZ $0E18 ; Set elevator to inactive STZ $1C1F ; Clear message box index STZ $0E1A ; Clear health bomb flag STZ $0795 : STZ $0797 ; Clear door transition flags LDA #$0000 : STA !ram_transition_flag LDA #$E737 : STA $099C ; Pointer to next frame's room transition code = $82:E737 if !RAW_TILE_GRAPHICS LDX $07BB : LDA $8F0018,X CMP #$91C9 : BEQ .post_preset_scrolling_sky CMP #$91CE : BEQ .post_preset_scrolling_sky PLB : PLP : RTL .post_preset_scrolling_sky JML $8FE89B else PLB : PLP : RTL endif } preset_open_all_blue_doors: { PHP : PHB : PHX : PHY LDA #$8484 : STA $C3 : PHA : PLB : PLB ; First resolve all door PLMs where the door has previously been opened LDX #$004E .plm_search_loop LDA $1C37,X : BEQ .plm_search_done LDY $1D27,X : LDA $0000,Y : CMP #$8A72 : BEQ .plm_door_found .plm_search_resume DEX : DEX : BRA .plm_search_loop .plm_door_found LDA $1DC7,X : BMI .plm_search_resume PHX : JSL $80818E : LDA $7ED8B0,X : PLX AND $05E7 : BEQ .plm_search_resume ; Door has been previously opened ; Execute the next PLM instruction to set the BTS as a blue door LDA $0002,Y : TAY LDA $0000,Y : CMP #$86BC : BEQ .plm_delete INY : INY JSL preset_execute_plm_instruction .plm_delete STZ $1C37,X BRA .plm_search_resume .plm_search_done ; Now search all of the room BTS for doors LDA !ROOM_WIDTH_SCROLLS : STA $C7 LDA !ROOM_WIDTH_BLOCKS : STA $C1 : ASL : STA $C3 LDA $7F0000 : LSR : TAY STZ $C5 : TDC : %a8() : LDA #$7F : PHA : PLB .bts_search_loop LDA $6401,Y : AND #$FC : CMP #$40 : BEQ .bts_found .bts_continue DEY : BNE .bts_search_loop ; All blue doors opened PLY : PLX : PLB : PLP : RTS .bts_found ; Convert BTS index to tile index ; Also verify this is a door and not a slope or half-tile %a16() : TYA : ASL : TAX : %a8() LDA $0001,X : BIT #$30 : BNE .bts_continue ; If this door has a red scroll, then leave it closed ; Most of the work is to determine the scroll index %a16() : TYA : DEC : LSR : LSR : LSR : LSR : STA $004204 %a8() : LDA $C7 : STA $004206 %a16() : PHA : PLA : PHA : PLA LDA $004216 : STA $C8 LDA $004214 : LSR : LSR : LSR : LSR %a8() : STA $004202 LDA $C7 : STA $004203 PHA : PLA : TDC LDA $004216 : CLC : ADC $C8 PHX : TAX : LDA $7ECD20,X : PLX CMP #$00 : BEQ .bts_continue ; Check what type of door we need to open LDA $6401,Y : BIT #$02 : BNE .bts_check_up_or_down BIT #$01 : BEQ .bts_facing_left_right LDA #$04 : STA $C6 .bts_facing_left_right %a16() : LDA #$0082 : ORA $C5 : STA $0000,X TXA : CLC : ADC $C3 : TAX : LDA #$00A2 : ORA $C5 : STA $0000,X TXA : CLC : ADC $C3 : TAX : LDA #$08A2 : ORA $C5 : STA $0000,X TXA : CLC : ADC $C3 : TAX : LDA #$0882 : ORA $C5 : STA $0000,X TDC : %a8() : STA $C6 : STA $6401,Y %a16() : TYA : CLC : ADC $C1 : TAX : TDC : %a8() : STA $6401,X %a16() : TXA : CLC : ADC $C1 : TAX : TDC : %a8() : STA $6401,X %a16() : TXA : CLC : ADC $C1 : TAX : TDC : %a8() : STA $6401,X BRL .bts_continue .bts_check_up_or_down BIT #$01 : BEQ .bts_facing_up_down LDA #$08 : STA $C6 .bts_facing_up_down %a16() : LDA #$0084 : ORA $C5 : STA $0006,X DEC : STA $0004,X : ORA #$0400 : STA $0002,X : INC : STA $0000,X TDC : %a8() : STA $C6 : STA $6401,Y STA $6402,Y : STA $6403,Y : STA $6404,Y BRL .bts_continue } preset_execute_plm_instruction: { ; A = Bank 84 PLM instruction to execute ; $C3 already set to $84 STA $C1 ; PLM instruction ends with an RTS, but we need an RTL ; Have the RTS return to $848031 which is an RTL PEA $8030 JML [$00C1] } preset_room_setup_asm_fixes: { ; Start with original logic PHP : PHB %ai16() LDX $07BB LDA $0018,X : BEQ .end ; Check if this is scrolling sky CMP #$91C9 : BEQ .scrolling_sky CMP #$91CE : BEQ .scrolling_sky .execute_setup_asm ; Resume execution JML $8FE89B .scrolling_sky ; If we got here through normal gameplay, allow scrolling sky LDA !GAMEMODE : CMP #$0006 : BEQ .execute_setup_asm CMP #$001F : BEQ .execute_setup_asm CMP #$0028 : BEQ .execute_setup_asm if !RAW_TILE_GRAPHICS ; Defer scrolling sky asm until later else ; Disable scrolling sky asm STZ $07DF ; Clear layer 2 library bits (change 0181 to 0080) LDA #$0080 : STA $091B endif .end PLB : PLP : RTL } transfer_cgram_long: { PHP %a16() %i8() JSR $933A PLP RTL } add_grapple_and_xray_to_hud: { ; Copied from $809AB1 to $809AC9 LDA $09A2 : BIT #$8000 : BEQ $04 JSL $809A3E ; Add x-ray to HUD tilemap LDA $09A2 : BIT #$4000 : BEQ $04 JSL $809A2E ; Add grapple to HUD tilemap JMP .resume_infohud_icon_initialization } print pc, " presets bank80 end" warnpc $80F800 ; $80:9AB1: Add x-ray and grapple HUD items if necessary org $809AB1 ; Skip x-ray and grapple if max HP is a multiple of 4, ; which is only possible if GT code was used LDA $09C4 : AND #$0003 : BEQ .resume_infohud_icon_initialization JMP add_grapple_and_xray_to_hud warnpc $809AC9 ; $80:9AC9: Resume original logic org $809AC9 .resume_infohud_icon_initialization ; ------------------- ; Category Menus/Data ; ------------------- org $EAE000 check bankcross off print pc, " preset data crossbank start" incsrc presets/14ice_data.asm incsrc presets/14speed_data.asm incsrc presets/100early_data.asm incsrc presets/100map_data.asm incsrc presets/allbosskpdr_data.asm incsrc presets/allbosspkdr_data.asm incsrc presets/allbossprkd_data.asm incsrc presets/gtclassic_data.asm incsrc presets/gtmax_data.asm incsrc presets/hundo_data.asm incsrc presets/kpdr21_data.asm incsrc presets/kpdr25_data.asm incsrc presets/nintendopower_data.asm incsrc presets/pkrd_data.asm incsrc presets/prkd_data.asm incsrc presets/rbo_data.asm print pc, " preset data crossbank end" warnpc $F08000 check bankcross on org $F18000 print pc, " preset menu bankF1 start" incsrc presets/14ice_menu.asm incsrc presets/14speed_menu.asm incsrc presets/100early_menu.asm incsrc presets/100map_menu.asm incsrc presets/allbosskpdr_menu.asm incsrc presets/allbosspkdr_menu.asm incsrc presets/allbossprkd_menu.asm incsrc presets/gtclassic_menu.asm print pc, " preset menu bankF1 end" org $F28000 print pc, " preset menu bankF2 start" incsrc presets/gtmax_menu.asm incsrc presets/hundo_menu.asm incsrc presets/kpdr21_menu.asm incsrc presets/kpdr25_menu.asm incsrc presets/nintendopower_menu.asm incsrc presets/pkrd_menu.asm incsrc presets/prkd_menu.asm incsrc presets/rbo_menu.asm print pc, " preset menu bankF2 end"
#ifndef VIENNACL_TOOLS_MATRIX_PROD_KERNEL_CLASS_DEDUCER_HPP_ #define VIENNACL_TOOLS_MATRIX_PROD_KERNEL_CLASS_DEDUCER_HPP_ /* ========================================================================= Copyright (c) 2010-2013, Institute for Microelectronics, Institute for Analysis and Scientific Computing, TU Wien. Portions of this software are copyright by UChicago Argonne, LLC. ----------------- ViennaCL - The Vienna Computing Library ----------------- Project Head: Karl Rupp rupp@iue.tuwien.ac.at (A list of authors and contributors can be found in the PDF manual) License: MIT (X11), see file LICENSE in the base directory ============================================================================= */ /** @file viennacl/tools/matrix_prod_kernel_class_deducer.hpp @brief Implementation of a helper meta class for deducing the correct kernels for matrix-matrix products */ #include <string> #include <fstream> #include <sstream> #include "viennacl/forwards.h" #include "viennacl/linalg/kernels/matrix_prod_col_col_col_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_col_col_row_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_col_row_col_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_col_row_row_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_row_col_col_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_row_col_row_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_row_row_col_kernels.h" #include "viennacl/linalg/kernels/matrix_prod_row_row_row_kernels.h" #include <vector> #include <map> namespace viennacl { namespace tools { /** @brief deduces kernel type for C=A*B, where A, B, C are MatrixType1, MatrixType2 and MatrixType3 respectively */ template <typename MatrixType1, typename MatrixType2, typename MatrixType3> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER { typedef typename MatrixType1::ERROR_INVALID_TEMPLATE_ARGUMENTS_PROVIDED ResultType; }; /** \cond */ template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major> > { typedef viennacl::linalg::kernels::matrix_prod_row_row_row<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major> > { typedef viennacl::linalg::kernels::matrix_prod_row_row_col<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major> > { typedef viennacl::linalg::kernels::matrix_prod_row_col_row<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major> > { typedef viennacl::linalg::kernels::matrix_prod_row_col_col<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major> > { typedef viennacl::linalg::kernels::matrix_prod_col_row_row<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major> > { typedef viennacl::linalg::kernels::matrix_prod_col_row_col<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::row_major> > { typedef viennacl::linalg::kernels::matrix_prod_col_col_row<SCALARTYPE, 1> ResultType; }; template <typename SCALARTYPE> struct MATRIX_PROD_KERNEL_CLASS_DEDUCER< viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major>, viennacl::matrix_base<SCALARTYPE, viennacl::column_major> > { typedef viennacl::linalg::kernels::matrix_prod_col_col_col<SCALARTYPE, 1> ResultType; }; /** \endcond */ } } #endif
;; ;; Copyright (c) 2012-2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ; routine to do AES cbc decrypt on 16n bytes doing AES by 4 ; XMM registers are clobbered. Saving/restoring must be done at a higher level ; void aes_cbc_dec_128_sse(void *in, ; UINT128 *IV, ; UINT128 keys[11], ; void *out, ; UINT64 len_bytes); ; ; arg 1: IN: pointer to input (cipher text) ; arg 2: IV: pointer to IV ; arg 3: KEYS: pointer to keys ; arg 4: OUT: pointer to output (plain text) ; arg 5: LEN: length in bytes (multiple of 16) ; %include "include/os.asm" %include "include/clear_regs.asm" %ifndef AES_CBC_DEC_128 %define AES_CBC_DEC_128 aes_cbc_dec_128_sse %endif %ifdef CBCS %define OFFSET 160 %else %define OFFSET 16 %endif %define MOVDQ movdqu %ifdef LINUX %define IN rdi %define IV rsi %define KEYS rdx %define OUT rcx %define BYTES r8 %else %define IN rcx %define IV rdx %define KEYS r8 %define OUT r9 %endif %define LEN rax %define IDX r10 %define TMP IDX %define TMP2 r11 %define XDATA0 xmm0 %define XDATA1 xmm1 %define XDATA2 xmm2 %define XDATA3 xmm3 %define XKEY0 xmm4 %define XKEY2 xmm5 %define XKEY4 xmm6 %define XKEY6 xmm7 %define XKEY8 xmm8 %define XKEY10 xmm9 %define XIV xmm10 %define XSAVED0 xmm11 %define XSAVED1 xmm12 %define XSAVED2 xmm13 %define XSAVED3 xmm14 %define XKEY xmm15 %define IV_TMP XSAVED3 section .text MKGLOBAL(AES_CBC_DEC_128,function,internal) AES_CBC_DEC_128: %ifndef LINUX mov LEN, [rsp + 8*5] %else mov LEN, BYTES %endif %ifdef CBCS ;; convert CBCS length to standard number of CBC blocks ;; ((len + 9 blocks) / 160) = num blocks to decrypt mov TMP2, rdx xor rdx, rdx ;; store and zero rdx for div add LEN, 9*16 mov TMP, 160 div TMP ;; divide by 160 shl LEN, 4 ;; multiply by 16 to get num bytes mov rdx, TMP2 %endif mov TMP, LEN and TMP, 3*16 jz initial_4 cmp TMP, 2*16 jb initial_1 ja initial_3 initial_2: ; load cipher text movdqu XDATA0, [IN + 0*OFFSET] movdqu XDATA1, [IN + 1*OFFSET] movdqa XKEY0, [KEYS + 0*16] ; save cipher text movdqa XSAVED0, XDATA0 movdqa XIV, XDATA1 pxor XDATA0, XKEY0 ; 0. ARK pxor XDATA1, XKEY0 movdqa XKEY2, [KEYS + 2*16] aesdec XDATA0, [KEYS + 1*16] ; 1. DEC aesdec XDATA1, [KEYS + 1*16] mov IDX, 2*OFFSET aesdec XDATA0, XKEY2 ; 2. DEC aesdec XDATA1, XKEY2 movdqa XKEY4, [KEYS + 4*16] aesdec XDATA0, [KEYS + 3*16] ; 3. DEC aesdec XDATA1, [KEYS + 3*16] movdqu IV_TMP, [IV] aesdec XDATA0, XKEY4 ; 4. DEC aesdec XDATA1, XKEY4 movdqa XKEY6, [KEYS + 6*16] aesdec XDATA0, [KEYS + 5*16] ; 5. DEC aesdec XDATA1, [KEYS + 5*16] aesdec XDATA0, XKEY6 ; 6. DEC aesdec XDATA1, XKEY6 movdqa XKEY8, [KEYS + 8*16] aesdec XDATA0, [KEYS + 7*16] ; 7. DEC aesdec XDATA1, [KEYS + 7*16] aesdec XDATA0, XKEY8 ; 8. DEC aesdec XDATA1, XKEY8 movdqa XKEY10, [KEYS + 10*16] aesdec XDATA0, [KEYS + 9*16] ; 9. DEC aesdec XDATA1, [KEYS + 9*16] aesdeclast XDATA0, XKEY10 ; 10. DEC aesdeclast XDATA1, XKEY10 pxor XDATA0, IV_TMP pxor XDATA1, XSAVED0 movdqu [OUT + 0*OFFSET], XDATA0 movdqu [OUT + 1*OFFSET], XDATA1 sub LEN, 2*16 jz done jmp main_loop align 16 initial_1: ; load cipher text movdqu XDATA0, [IN + 0*OFFSET] movdqa XKEY0, [KEYS + 0*16] ; save cipher text movdqa XIV, XDATA0 pxor XDATA0, XKEY0 ; 0. ARK movdqa XKEY2, [KEYS + 2*16] aesdec XDATA0, [KEYS + 1*16] ; 1. DEC mov IDX, 1*OFFSET aesdec XDATA0, XKEY2 ; 2. DEC movdqa XKEY4, [KEYS + 4*16] aesdec XDATA0, [KEYS + 3*16] ; 3. DEC movdqu IV_TMP, [IV] aesdec XDATA0, XKEY4 ; 4. DEC movdqa XKEY6, [KEYS + 6*16] aesdec XDATA0, [KEYS + 5*16] ; 5. DEC aesdec XDATA0, XKEY6 ; 6. DEC movdqa XKEY8, [KEYS + 8*16] aesdec XDATA0, [KEYS + 7*16] ; 7. DEC aesdec XDATA0, XKEY8 ; 8. DEC movdqa XKEY10, [KEYS + 10*16] aesdec XDATA0, [KEYS + 9*16] ; 9. DEC aesdeclast XDATA0, XKEY10 ; 10. DEC pxor XDATA0, IV_TMP movdqu [OUT + 0*OFFSET], XDATA0 sub LEN, 1*16 jz done jmp main_loop initial_3: ; load cipher text movdqu XDATA0, [IN + 0*OFFSET] movdqu XDATA1, [IN + 1*OFFSET] movdqu XDATA2, [IN + 2*OFFSET] movdqa XKEY0, [KEYS + 0*16] ; save cipher text movdqa XSAVED0, XDATA0 movdqa XSAVED1, XDATA1 movdqa XIV, XDATA2 movdqa XKEY, [KEYS + 1*16] pxor XDATA0, XKEY0 ; 0. ARK pxor XDATA1, XKEY0 pxor XDATA2, XKEY0 movdqa XKEY2, [KEYS + 2*16] aesdec XDATA0, XKEY ; 1. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY movdqa XKEY, [KEYS + 3*16] mov IDX, 3*OFFSET aesdec XDATA0, XKEY2 ; 2. DEC aesdec XDATA1, XKEY2 aesdec XDATA2, XKEY2 movdqa XKEY4, [KEYS + 4*16] aesdec XDATA0, XKEY ; 3. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY movdqa XKEY, [KEYS + 5*16] movdqu IV_TMP, [IV] aesdec XDATA0, XKEY4 ; 4. DEC aesdec XDATA1, XKEY4 aesdec XDATA2, XKEY4 movdqa XKEY6, [KEYS + 6*16] aesdec XDATA0, XKEY ; 5. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY movdqa XKEY, [KEYS + 7*16] aesdec XDATA0, XKEY6 ; 6. DEC aesdec XDATA1, XKEY6 aesdec XDATA2, XKEY6 movdqa XKEY8, [KEYS + 8*16] aesdec XDATA0, XKEY ; 7. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY movdqa XKEY, [KEYS + 9*16] aesdec XDATA0, XKEY8 ; 8. DEC aesdec XDATA1, XKEY8 aesdec XDATA2, XKEY8 movdqa XKEY10, [KEYS + 10*16] aesdec XDATA0, XKEY ; 9. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdeclast XDATA0, XKEY10 ; 10. DEC aesdeclast XDATA1, XKEY10 aesdeclast XDATA2, XKEY10 pxor XDATA0, IV_TMP pxor XDATA1, XSAVED0 pxor XDATA2, XSAVED1 movdqu [OUT + 0*OFFSET], XDATA0 movdqu [OUT + 1*OFFSET], XDATA1 movdqu [OUT + 2*OFFSET], XDATA2 sub LEN, 3*16 jz done jmp main_loop align 16 initial_4: ; load cipher text movdqu XDATA0, [IN + 0*OFFSET] movdqu XDATA1, [IN + 1*OFFSET] movdqu XDATA2, [IN + 2*OFFSET] movdqu XDATA3, [IN + 3*OFFSET] movdqa XKEY0, [KEYS + 0*16] ; save cipher text movdqa XSAVED0, XDATA0 movdqa XSAVED1, XDATA1 movdqa XSAVED2, XDATA2 movdqa XIV, XDATA3 movdqa XKEY, [KEYS + 1*16] pxor XDATA0, XKEY0 ; 0. ARK pxor XDATA1, XKEY0 pxor XDATA2, XKEY0 pxor XDATA3, XKEY0 movdqa XKEY2, [KEYS + 2*16] aesdec XDATA0, XKEY ; 1. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 3*16] mov IDX, 4*OFFSET aesdec XDATA0, XKEY2 ; 2. DEC aesdec XDATA1, XKEY2 aesdec XDATA2, XKEY2 aesdec XDATA3, XKEY2 movdqa XKEY4, [KEYS + 4*16] aesdec XDATA0, XKEY ; 3. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 5*16] movdqu IV_TMP, [IV] aesdec XDATA0, XKEY4 ; 4. DEC aesdec XDATA1, XKEY4 aesdec XDATA2, XKEY4 aesdec XDATA3, XKEY4 movdqa XKEY6, [KEYS + 6*16] aesdec XDATA0, XKEY ; 5. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 7*16] aesdec XDATA0, XKEY6 ; 6. DEC aesdec XDATA1, XKEY6 aesdec XDATA2, XKEY6 aesdec XDATA3, XKEY6 movdqa XKEY8, [KEYS + 8*16] aesdec XDATA0, XKEY ; 7. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 9*16] aesdec XDATA0, XKEY8 ; 8. DEC aesdec XDATA1, XKEY8 aesdec XDATA2, XKEY8 aesdec XDATA3, XKEY8 movdqa XKEY10, [KEYS + 10*16] aesdec XDATA0, XKEY ; 9. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY aesdeclast XDATA0, XKEY10 ; 10. DEC aesdeclast XDATA1, XKEY10 aesdeclast XDATA2, XKEY10 aesdeclast XDATA3, XKEY10 pxor XDATA0, IV_TMP pxor XDATA1, XSAVED0 pxor XDATA2, XSAVED1 pxor XDATA3, XSAVED2 movdqu [OUT + 0*OFFSET], XDATA0 movdqu [OUT + 1*OFFSET], XDATA1 movdqu [OUT + 2*OFFSET], XDATA2 movdqu [OUT + 3*OFFSET], XDATA3 sub LEN, 4*16 jz done jmp main_loop align 16 main_loop: ; load cipher text movdqu XDATA0, [IN + IDX + 0*OFFSET] movdqu XDATA1, [IN + IDX + 1*OFFSET] movdqu XDATA2, [IN + IDX + 2*OFFSET] movdqu XDATA3, [IN + IDX + 3*OFFSET] ; save cipher text movdqa XSAVED0, XDATA0 movdqa XSAVED1, XDATA1 movdqa XSAVED2, XDATA2 movdqa XSAVED3, XDATA3 movdqa XKEY, [KEYS + 1*16] pxor XDATA0, XKEY0 ; 0. ARK pxor XDATA1, XKEY0 pxor XDATA2, XKEY0 pxor XDATA3, XKEY0 add IDX, 4*OFFSET aesdec XDATA0, XKEY ; 1. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 3*16] aesdec XDATA0, XKEY2 ; 2. DEC aesdec XDATA1, XKEY2 aesdec XDATA2, XKEY2 aesdec XDATA3, XKEY2 aesdec XDATA0, XKEY ; 3. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 5*16] aesdec XDATA0, XKEY4 ; 4. DEC aesdec XDATA1, XKEY4 aesdec XDATA2, XKEY4 aesdec XDATA3, XKEY4 aesdec XDATA0, XKEY ; 5. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 7*16] aesdec XDATA0, XKEY6 ; 6. DEC aesdec XDATA1, XKEY6 aesdec XDATA2, XKEY6 aesdec XDATA3, XKEY6 aesdec XDATA0, XKEY ; 7. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY movdqa XKEY, [KEYS + 9*16] aesdec XDATA0, XKEY8 ; 8. DEC aesdec XDATA1, XKEY8 aesdec XDATA2, XKEY8 aesdec XDATA3, XKEY8 aesdec XDATA0, XKEY ; 9. DEC aesdec XDATA1, XKEY aesdec XDATA2, XKEY aesdec XDATA3, XKEY aesdeclast XDATA0, XKEY10 ; 10. DEC aesdeclast XDATA1, XKEY10 aesdeclast XDATA2, XKEY10 aesdeclast XDATA3, XKEY10 pxor XDATA0, XIV pxor XDATA1, XSAVED0 pxor XDATA2, XSAVED1 pxor XDATA3, XSAVED2 movdqu [OUT + IDX + 0*OFFSET - 4*OFFSET], XDATA0 movdqu [OUT + IDX + 1*OFFSET - 4*OFFSET], XDATA1 movdqu [OUT + IDX + 2*OFFSET - 4*OFFSET], XDATA2 movdqu [OUT + IDX + 3*OFFSET - 4*OFFSET], XDATA3 movdqa XIV, XSAVED3 sub LEN, 4*16 jnz main_loop done: %ifdef SAFE_DATA clear_all_xmms_sse_asm %endif ;; SAFE_DATA ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
list p=18f4550 #include<p18f4550.inc> CONFIG FOSC = XT_XT ; Oscillator Selection bits (XT oscillator (XT)) CONFIG PWRT = ON ; Power-up Timer Enable bit (PWRT enabled) CONFIG BOR = OFF ; Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software) CONFIG WDT = OFF ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit)) CONFIG PBADEN = OFF ; PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset) CONFIG LVP = OFF ; Single-Supply ICSP Enable bit (Single-Supply ICSP disabled) cblock 0x020 ;GPR label declaration i_var j_var k_var cuenta decena unidad endc org 0x0600 tabla_7s db 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67 org 0x0000 ;Reset vector goto set_up org 0x0008 ;High Priority Interrupt Vector goto Tmr0_ISR org 0x0020 set_up: clrf TRISD ;Set RD port as output movlw 0xFC movwf TRISB ;Set RB1 and RB0 as outputs movlw LOW tabla_7s movwf TBLPTRL movlw HIGH tabla_7s movwf TBLPTRH ;Set address location for table pointer ;Timer0 Setup: movlw 0xC8 movwf T0CON ;Timer0 ON, PSC 1:1, 8bit mode ;Interrupt Setup: movlw 0xA0 movwf INTCON ;Interrupt enabled for Timer0 clrf decena ;Clear variable decena clrf unidad ;Clear variable unidad loop: call delay_1s movlw .9 cpfseq unidad goto non1 clrf unidad movlw .2 cpfseq decena goto non2 clrf decena goto loop non1: incf unidad, f goto loop non2: incf decena, f goto loop delay_1s: movlw .100 movwf i_var oth1: call nest1 decfsz i_var, f goto oth1 return nest1: movlw .100 movwf j_var oth2: call nest2 decfsz j_var, f goto oth2 return nest2: movlw .100 movwf k_var oth3: nop decfsz k_var, f goto oth3 return Tmr0_ISR: bcf INTCON, TMR0IF movf decena, W movwf TBLPTRL TBLRD* movff TABLAT, LATD ;Load decoded decena to RD bcf LATB, 0 ;Enable first display call noops bsf LATB, 0 ;Disable first display movf unidad, W movwf TBLPTRL TBLRD* movff TABLAT, LATD ;Load decoded decena to RD ;movwf LATD ;Load decoded unidad to RD bcf LATB, 1 ;Enable second display call noops bsf LATB, 1 ;Disable second display retfie noops: nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop return end
// c:/Users/user/Documents/Programming/Error/IgnoredError/a_Macro.hpp #pragma once #include "../a_Macro.hpp" #ifdef DEBUG #define IGNORED_ERR( ... ) \ BREAK; \ IndicateIgnoredError( POSITION , ARGUMENTS( __VA_ARGS__ ) ) #else #define IGNORED_ERR( ... ) IndicateIgnoredError( POSITION , ARGUMENTS( __VA_ARGS__ ) ) #endif
#include <iostream> #include <thread> #include <mutex> enum order { ping, pong }; std::mutex m; int turn; void print_ping() { while (true) { std::lock_guard<std::mutex> lock(m); if (turn == order::ping) { std::cout << "ping" << ' '; turn = order::pong; } } } void print_pong() { while (true) { std::lock_guard<std::mutex> lock(m); if (turn == order::pong) { std::cout << "pong" << ' '; turn = order::ping; } } } void start_ping_pong_game() { std::thread t_ping(print_ping); std::thread t_pong(print_pong); t_ping.join(); t_pong.join(); } int main() { start_ping_pong_game(); return 0; }
; A081555: a(n) = 6*a(n-1) - a(n-2) - 4, a(0)=3, a(1)=7. ; 3,7,35,199,1155,6727,39203,228487,1331715,7761799,45239075,263672647,1536796803,8957108167,52205852195,304278004999,1773462177795,10336495061767,60245508192803,351136554095047,2046573816377475,11928306344169799,69523264248641315,405211279147678087,2361744410637427203,13765255184676885127,80229786697423883555,467613464999866416199,2725451003301774613635,15885092554810781265607,92585104325562912980003,539625533398566696614407,3145168096065837266706435,18331383042996456903624199 mov $1,2 lpb $0 sub $0,1 add $1,$2 add $2,$1 add $2,$1 add $1,$2 lpe add $1,1 mov $0,$1
section .data msg1 : db 'debug here --',10 l1 : equ $-msg1 msg2 : db 'Enter your string : ' l2 : equ $-msg2 msg3 : db 'The balanced string is : ' l3 : equ $-msg3 msg4 : db 'msg 4 here' l4: equ $-msg4 msg5 : db 'msg 5 here',10 l5: equ $-msg5 space:db ' ' newline:db '',10 section .bss num: resd 1 counter: resd 1 n: resd 10 string: resb 1000 section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, msg2 mov edx, l2 int 80h mov ebx, string call read_array_string call balance_string mov eax, 4 mov ebx, 1 mov ecx, msg3 mov edx, l3 int 80h mov ebx, bal_string call print_array_string mov eax, 4 mov ebx, 1 mov ecx, newline mov edx, 1 int 80h exit: mov eax,1 mov ebx,0 int 80h ; section for procedures ;---------------------------- balance_string: section .bss bal_string: resb 1000 bal_i: resd 1 bal_f: resd 1 str_i: resd 1 section .text push rax push rbx push rcx push rdx mov dword[bal_i],0 mov dword[bal_f],1 mov ebx, string bal_loop_1: mov ebx, string mov eax,[str_i] mov cl, byte[ebx+eax] cmp cl,0 ;; check for string ending je exit_bal_loop_1 cmp cl,')' jne skip_close_cond dec dword[bal_f] cmp dword[bal_f],0 jne continue_close inc dword[bal_f] jmp continue_bal_loop continue_close: mov ebx,bal_string mov eax,[bal_i] mov byte[ebx+eax],cl inc dword[bal_i] jmp continue_bal_loop skip_close_cond: cmp cl, '(' jne skip_open_cond inc dword[bal_f] skip_open_cond: mov ebx,bal_string mov eax,[bal_i] mov byte[ebx+eax],cl inc dword[bal_i] jmp continue_bal_loop continue_bal_loop: inc dword[str_i] jmp bal_loop_1 exit_bal_loop_1: mov cl,')' bal_loop_2: mov ax, word[bal_f] cmp ax,1 je exit_bal_loop_2 mov ebx,bal_string mov eax,[bal_i] mov byte[ebx+eax],cl dec dword[bal_f] inc dword[bal_i] jmp bal_loop_2 exit_bal_loop_2: mov ebx,bal_string mov eax,[bal_i] mov byte[ebx+eax],0 pop rdx pop rcx pop rbx pop rax ret debugger: section .data msg_debugger : db 'debug here --',10 msg_debugger_l : equ $-msg_debugger section .text push rax push rbx push rcx push rdx ; debug---- mov eax, 4 mov ebx, 1 mov ecx, msg_debugger mov edx, msg_debugger_l int 80h ;debug --- pop rdx pop rcx pop rbx pop rax ; action ret read_array_string: ;; usage ;-------- ; 1: string is read and stored in string variable ; 2: string length is stored in string_len section .bss string_len : resd 1 temp_read_str : resb 1 section .text push rax push rbx push rcx mov word[string_len],0 reading: push rbx mov eax, 3 mov ebx, 0 mov ecx, temp_read_str mov edx, 1 int 80h pop rbx cmp byte[temp_read_str], 10 ;; check if the input is ’Enter’ je end_reading inc byte[string_len] mov al,byte[temp_read_str] mov byte[ebx], al inc ebx jmp reading end_reading: ;; Similar to putting a null character at the end of a string mov byte[ebx], 0 pop rcx pop rbx pop rax ret print_array_string: ;; usage ;----------- ; 1: base address of string to print is stored in ebx section .bss temp_print_str : resb 1 section .text push rax push rbx push rcx printing: mov al, byte[ebx] mov byte[temp_print_str], al cmp byte[temp_print_str], 0 ;; checks if the character is NULL character je end_printing push rbx mov eax, 4 mov ebx, 1 mov ecx, temp_print_str mov edx, 1 int 80h pop rbx inc ebx jmp printing end_printing: pop rcx pop rbx pop rax ret print_array: ; usage ;------- ; 1: base address of array in ebx mov ebx,array ; 2: size of array in n push rax ; push all push rbx push rcx mov eax,0 print_loop: cmp eax,dword[n] je end_print1 mov cx,word[ebx+2*eax] mov word[num],cx ;;The number to be printed is copied to ’num’ ; before calling print num function push rax push rbx call print_num pop rbx pop rax inc eax jmp print_loop end_print1: ; popa pop rcx pop rbx pop rax ; pop all ret read_array: ; usage ;------- ; 1: base address of array in ebx mov ebx, array ; 2: size of array in n push rax ; push all push rbx push rcx mov eax ,0 read_loop: cmp eax,dword[n] je end_read_1 push rax push rbx call read_num pop rbx pop rax ;;read num stores the input in ’num’ mov cx,word[num] mov word[ebx+2*eax],cx inc eax ;;Here, each word consists of two bytes, so the counter should be ; incremented by multiples of two. If the array is declared in bytes do mov word[ebx+eax],cx jmp read_loop end_read_1: pop rcx pop rbx pop rax ; pop all ret print_num: ;usage ;------ ; 1: create a variable num(word) ; 2: move number to print to num (word) section .data nwl_for_printnum :db ' ' nwl_l_printnum : equ $-nwl_for_printnum show_zero :db '0 ' show_zero_l : equ $-show_zero section .bss count_printnum : resb 10 temp_printnum : resb 1 section .text push rax ; push all push rbx push rcx cmp word[num],0 je print_zero mov byte[count_printnum],0 ;call push_reg extract_no: cmp word[num], 0 je print_no inc byte[count_printnum] mov dx, 0 mov ax, word[num] mov bx, 10 div bx push dx ; recursion here mov word[num], ax jmp extract_no print_no: cmp byte[count_printnum], 0 je end_print dec byte[count_printnum] pop dx mov byte[temp_printnum], dl ; dx is further divided into dh and dl add byte[temp_printnum], 30h mov eax, 4 mov ebx, 1 mov ecx, temp_printnum mov edx, 1 int 80h jmp print_no end_print: mov eax,4 mov ebx,1 mov ecx,nwl_for_printnum mov edx,nwl_l_printnum int 80h ;;The memory location ’newline’ should be declared with the ASCII key for new popa ;call pop_reg jmp exit_printing print_zero: mov eax,4 mov ebx,1 mov ecx,show_zero mov edx,show_zero_l int 80h exit_printing: pop rcx pop rbx pop rax ; pop all ret read_num: ;usage ;------ ; 1: create a variable num(word) ; 2: the input number is stored into num(word) section .bss temp_for_read: resb 1 section .text push rax ; push all push rbx push rcx mov word[num], 0 loop_read: ;; read a digit mov eax, 3 mov ebx, 0 mov ecx, temp_for_read mov edx, 1 int 80h ;;check if the read digit is the end of number, i.e, the enter-key whose ASCII cmp byte[temp], 10 cmp byte[temp_for_read], 10 je end_read mov ax, word[num] mov bx, 10 mul bx mov bl, byte[temp_for_read] sub bl, 30h mov bh, 0 add ax, bx mov word[num], ax jmp loop_read end_read: ;;pop all the used registers from the stack using popa ;call pop_reg pop rcx pop rbx pop rax ret
324 06A0 324 06A0 324 06A0 ;void l2_draw_scan_line(uint8_t x, uint8_t y1, uint8_t y2, uint8_t color) 324 06A0 C_LINE 326,"Graphics\L2graphics.c" 326 06A0 ;{ 326 06A0 C_LINE 327,"Graphics\L2graphics.c" 327 06A0 327 06A0 ; Function l2_draw_scan_line flags 0x00000200 __smallc 327 06A0 ; void l2_draw_scan_line(unsigned char x, unsigned char y1, unsigned char y2, unsigned char color) 327 06A0 ; parameter 'unsigned char color' at 2 size(1) 327 06A0 ; parameter 'unsigned char y2' at 4 size(1) 327 06A0 ; parameter 'unsigned char y1' at 6 size(1) 327 06A0 ; parameter 'unsigned char x' at 8 size(1) 327 06A0 ._l2_draw_scan_line 327 06A0 C_LINE 327,"Graphics\L2graphics.c" 327 06A0 ; uint8_t y3,ylen; 327 06A0 C_LINE 328,"Graphics\L2graphics.c" 328 06A0 C_LINE 328,"Graphics\L2graphics.c" 328 06A0 ; 328 06A0 C_LINE 329,"Graphics\L2graphics.c" 329 06A0 ; l2_draw_horz_line(x, y2, 3, color); 329 06A0 C_LINE 330,"Graphics\L2graphics.c" 330 06A0 C_LINE 330,"Graphics\L2graphics.c" 330 06A0 C5 push bc 330 06A1 ;x; 330 06A1 C_LINE 331,"Graphics\L2graphics.c" 331 06A1 21 0A 00 ld hl,10 ;const 331 06A4 39 add hl,sp 331 06A5 6E ld l,(hl) 331 06A6 26 00 ld h,0 331 06A8 E5 push hl 331 06A9 ;y2; 331 06A9 C_LINE 331,"Graphics\L2graphics.c" 331 06A9 21 08 00 ld hl,8 ;const 331 06AC 39 add hl,sp 331 06AD 6E ld l,(hl) 331 06AE 26 00 ld h,0 331 06B0 E5 push hl 331 06B1 ;3; 331 06B1 C_LINE 331,"Graphics\L2graphics.c" 331 06B1 21 03 00 ld hl,3 ;const 331 06B4 E5 push hl 331 06B5 ;color; 331 06B5 C_LINE 331,"Graphics\L2graphics.c" 331 06B5 21 0A 00 ld hl,10 ;const 331 06B8 39 add hl,sp 331 06B9 6E ld l,(hl) 331 06BA 26 00 ld h,0 331 06BC E5 push hl 331 06BD CD 6D 01 call _l2_draw_horz_line 331 06C0 C1 pop bc 331 06C1 C1 pop bc 331 06C2 C1 pop bc 331 06C3 C1 pop bc 331 06C4 ; if (y1 < y2) 331 06C4 C_LINE 331,"Graphics\L2graphics.c" 331 06C4 C_LINE 331,"Graphics\L2graphics.c" 331 06C4 21 08 00 ld hl,8 ;const 331 06C7 39 add hl,sp 331 06C8 5E ld e,(hl) 331 06C9 16 00 ld d,0 331 06CB 21 06 00 ld hl,6 ;const 331 06CE 39 add hl,sp 331 06CF 6E ld l,(hl) 331 06D0 26 00 ld h,0 331 06D2 EB ex de,hl 331 06D3 A7 and a 331 06D4 ED 52 sbc hl,de 331 06D6 D2 06 07 jp nc,i_50 331 06D9 ; { 331 06D9 C_LINE 332,"Graphics\L2graphics.c" 332 06D9 C_LINE 332,"Graphics\L2graphics.c" 332 06D9 ; y3 = y1; 332 06D9 C_LINE 333,"Graphics\L2graphics.c" 333 06D9 C_LINE 333,"Graphics\L2graphics.c" 333 06D9 21 01 00 ld hl,1 ;const 333 06DC 39 add hl,sp 333 06DD E5 push hl 333 06DE 21 0A 00 ld hl,10 ;const 333 06E1 39 add hl,sp 333 06E2 7E ld a,(hl) 333 06E3 D1 pop de 333 06E4 12 ld (de),a 333 06E5 6F ld l,a 333 06E6 26 00 ld h,0 333 06E8 ; ylen = (y2 - y1 )+1; 333 06E8 C_LINE 334,"Graphics\L2graphics.c" 334 06E8 C_LINE 334,"Graphics\L2graphics.c" 334 06E8 21 00 00 ld hl,0 ;const 334 06EB 39 add hl,sp 334 06EC E5 push hl 334 06ED 21 08 00 ld hl,8 ;const 334 06F0 39 add hl,sp 334 06F1 5E ld e,(hl) 334 06F2 16 00 ld d,0 334 06F4 21 0A 00 ld hl,10 ;const 334 06F7 39 add hl,sp 334 06F8 6E ld l,(hl) 334 06F9 26 00 ld h,0 334 06FB EB ex de,hl 334 06FC A7 and a 334 06FD ED 52 sbc hl,de 334 06FF 23 inc hl 334 0700 D1 pop de 334 0701 7D ld a,l 334 0702 12 ld (de),a 334 0703 ; } 334 0703 C_LINE 335,"Graphics\L2graphics.c" 335 0703 ; else 335 0703 C_LINE 336,"Graphics\L2graphics.c" 336 0703 C3 30 07 jp i_51 336 0706 .i_50 336 0706 ; { 336 0706 C_LINE 337,"Graphics\L2graphics.c" 337 0706 C_LINE 337,"Graphics\L2graphics.c" 337 0706 ; y3 = y2; 337 0706 C_LINE 338,"Graphics\L2graphics.c" 338 0706 C_LINE 338,"Graphics\L2graphics.c" 338 0706 21 01 00 ld hl,1 ;const 338 0709 39 add hl,sp 338 070A E5 push hl 338 070B 21 08 00 ld hl,8 ;const 338 070E 39 add hl,sp 338 070F 7E ld a,(hl) 338 0710 D1 pop de 338 0711 12 ld (de),a 338 0712 6F ld l,a 338 0713 26 00 ld h,0 338 0715 ; ylen = (y1 - y2) + 1; 338 0715 C_LINE 339,"Graphics\L2graphics.c" 339 0715 C_LINE 339,"Graphics\L2graphics.c" 339 0715 21 00 00 ld hl,0 ;const 339 0718 39 add hl,sp 339 0719 E5 push hl 339 071A 21 0A 00 ld hl,10 ;const 339 071D 39 add hl,sp 339 071E 5E ld e,(hl) 339 071F 16 00 ld d,0 339 0721 21 08 00 ld hl,8 ;const 339 0724 39 add hl,sp 339 0725 6E ld l,(hl) 339 0726 26 00 ld h,0 339 0728 EB ex de,hl 339 0729 A7 and a 339 072A ED 52 sbc hl,de 339 072C 23 inc hl 339 072D D1 pop de 339 072E 7D ld a,l 339 072F 12 ld (de),a 339 0730 ; } 339 0730 C_LINE 340,"Graphics\L2graphics.c" 340 0730 .i_51 340 0730 ; l2_draw_vert_line(x, y3, ylen, color); 340 0730 C_LINE 341,"Graphics\L2graphics.c" 341 0730 C_LINE 341,"Graphics\L2graphics.c" 341 0730 ;x; 341 0730 C_LINE 342,"Graphics\L2graphics.c" 342 0730 21 0A 00 ld hl,10 ;const 342 0733 39 add hl,sp 342 0734 6E ld l,(hl) 342 0735 26 00 ld h,0 342 0737 E5 push hl 342 0738 ;y3; 342 0738 C_LINE 342,"Graphics\L2graphics.c" 342 0738 21 03 00 ld hl,3 ;const 342 073B 39 add hl,sp 342 073C 6E ld l,(hl) 342 073D 26 00 ld h,0 342 073F E5 push hl 342 0740 ;ylen; 342 0740 C_LINE 342,"Graphics\L2graphics.c" 342 0740 21 04 00 ld hl,4 ;const 342 0743 39 add hl,sp 342 0744 6E ld l,(hl) 342 0745 26 00 ld h,0 342 0747 E5 push hl 342 0748 ;color; 342 0748 C_LINE 342,"Graphics\L2graphics.c" 342 0748 21 0A 00 ld hl,10 ;const 342 074B 39 add hl,sp 342 074C 6E ld l,(hl) 342 074D 26 00 ld h,0 342 074F E5 push hl 342 0750 CD E0 02 call _l2_draw_vert_line 342 0753 C1 pop bc 342 0754 C1 pop bc 342 0755 C1 pop bc 342 0756 C1 pop bc 342 0757 ; l2_draw_vert_line(x+1, y3, ylen, color); 342 0757 C_LINE 342,"Graphics\L2graphics.c" 342 0757 C_LINE 342,"Graphics\L2graphics.c" 342 0757 ;x+1; 342 0757 C_LINE 343,"Graphics\L2graphics.c" 343 0757 21 0A 00 ld hl,10 ;const 343 075A 39 add hl,sp 343 075B 6E ld l,(hl) 343 075C 26 00 ld h,0 343 075E 23 inc hl 343 075F E5 push hl 343 0760 ;y3; 343 0760 C_LINE 343,"Graphics\L2graphics.c" 343 0760 21 03 00 ld hl,3 ;const 343 0763 39 add hl,sp 343 0764 6E ld l,(hl) 343 0765 26 00 ld h,0 343 0767 E5 push hl 343 0768 ;ylen; 343 0768 C_LINE 343,"Graphics\L2graphics.c" 343 0768 21 04 00 ld hl,4 ;const 343 076B 39 add hl,sp 343 076C 6E ld l,(hl) 343 076D 26 00 ld h,0 343 076F E5 push hl 343 0770 ;color; 343 0770 C_LINE 343,"Graphics\L2graphics.c" 343 0770 21 0A 00 ld hl,10 ;const 343 0773 39 add hl,sp 343 0774 6E ld l,(hl) 343 0775 26 00 ld h,0 343 0777 E5 push hl 343 0778 CD E0 02 call _l2_draw_vert_line 343 077B C1 pop bc 343 077C C1 pop bc 343 077D C1 pop bc 343 077E C1 pop bc 343 077F ;} 343 077F C_LINE 343,"Graphics\L2graphics.c" 343 077F C1 pop bc 343 0780 C9 ret 343 0781 343 0781 343 0781 ;void l2_draw_box(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1 , uint8_t color) 343 0781 C_LINE 345,"Graphics\L2graphics.c" 345 0781 ;{ 345 0781 C_LINE 346,"Graphics\L2graphics.c" 346 0781 346 0781 ; Function l2_draw_box flags 0x00000200 __smallc 346 0781 ; void l2_draw_box(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color) 346 0781 ; parameter 'unsigned char color' at 2 size(1) 346 0781 ; parameter 'unsigned char y1' at 4 size(1) 346 0781 ; parameter 'unsigned char x1' at 6 size(1) 346 0781 ; parameter 'unsigned char y0' at 8 size(1) 346 0781 ; parameter 'unsigned char x0' at 10 size(1) 346 0781 ._l2_draw_box 346 0781 C_LINE 346,"Graphics\L2graphics.c" 346 0781 ; l2_draw_horz_line(x0, y0,(x1-x0)+1, color); 346 0781 C_LINE 347,"Graphics\L2graphics.c" 347 0781 C_LINE 347,"Graphics\L2graphics.c" 347 0781 ;x0; 347 0781 C_LINE 348,"Graphics\L2graphics.c" 348 0781 21 0A 00 ld hl,10 ;const 348 0784 39 add hl,sp 348 0785 6E ld l,(hl) 348 0786 26 00 ld h,0 348 0788 E5 push hl 348 0789 ;y0; 348 0789 C_LINE 348,"Graphics\L2graphics.c" 348 0789 21 0A 00 ld hl,10 ;const 348 078C 39 add hl,sp 348 078D 6E ld l,(hl) 348 078E 26 00 ld h,0 348 0790 E5 push hl 348 0791 ;(x1-x0)+1; 348 0791 C_LINE 348,"Graphics\L2graphics.c" 348 0791 21 0A 00 ld hl,10 ;const 348 0794 39 add hl,sp 348 0795 5E ld e,(hl) 348 0796 16 00 ld d,0 348 0798 21 0E 00 ld hl,14 ;const 348 079B 39 add hl,sp 348 079C 6E ld l,(hl) 348 079D 26 00 ld h,0 348 079F EB ex de,hl 348 07A0 A7 and a 348 07A1 ED 52 sbc hl,de 348 07A3 23 inc hl 348 07A4 E5 push hl 348 07A5 ;color; 348 07A5 C_LINE 348,"Graphics\L2graphics.c" 348 07A5 21 08 00 ld hl,8 ;const 348 07A8 39 add hl,sp 348 07A9 6E ld l,(hl) 348 07AA 26 00 ld h,0 348 07AC E5 push hl 348 07AD CD 6D 01 call _l2_draw_horz_line 348 07B0 C1 pop bc 348 07B1 C1 pop bc 348 07B2 C1 pop bc 348 07B3 C1 pop bc 348 07B4 ; l2_draw_horz_line(x0, y1,(x1-x0)+1, color); 348 07B4 C_LINE 348,"Graphics\L2graphics.c" 348 07B4 C_LINE 348,"Graphics\L2graphics.c" 348 07B4 ;x0; 348 07B4 C_LINE 349,"Graphics\L2graphics.c" 349 07B4 21 0A 00 ld hl,10 ;const 349 07B7 39 add hl,sp 349 07B8 6E ld l,(hl) 349 07B9 26 00 ld h,0 349 07BB E5 push hl 349 07BC ;y1; 349 07BC C_LINE 349,"Graphics\L2graphics.c" 349 07BC 21 06 00 ld hl,6 ;const 349 07BF 39 add hl,sp 349 07C0 6E ld l,(hl) 349 07C1 26 00 ld h,0 349 07C3 E5 push hl 349 07C4 ;(x1-x0)+1; 349 07C4 C_LINE 349,"Graphics\L2graphics.c" 349 07C4 21 0A 00 ld hl,10 ;const 349 07C7 39 add hl,sp 349 07C8 5E ld e,(hl) 349 07C9 16 00 ld d,0 349 07CB 21 0E 00 ld hl,14 ;const 349 07CE 39 add hl,sp 349 07CF 6E ld l,(hl) 349 07D0 26 00 ld h,0 349 07D2 EB ex de,hl 349 07D3 A7 and a 349 07D4 ED 52 sbc hl,de 349 07D6 23 inc hl 349 07D7 E5 push hl 349 07D8 ;color; 349 07D8 C_LINE 349,"Graphics\L2graphics.c" 349 07D8 21 08 00 ld hl,8 ;const 349 07DB 39 add hl,sp 349 07DC 6E ld l,(hl) 349 07DD 26 00 ld h,0 349 07DF E5 push hl 349 07E0 CD 6D 01 call _l2_draw_horz_line 349 07E3 C1 pop bc 349 07E4 C1 pop bc 349 07E5 C1 pop bc 349 07E6 C1 pop bc 349 07E7 ; l2_draw_vert_line(x0, y0,(y1-y0)+1, color); 349 07E7 C_LINE 349,"Graphics\L2graphics.c" 349 07E7 C_LINE 349,"Graphics\L2graphics.c" 349 07E7 ;x0; 349 07E7 C_LINE 350,"Graphics\L2graphics.c" 350 07E7 21 0A 00 ld hl,10 ;const 350 07EA 39 add hl,sp 350 07EB 6E ld l,(hl) 350 07EC 26 00 ld h,0 350 07EE E5 push hl 350 07EF ;y0; 350 07EF C_LINE 350,"Graphics\L2graphics.c" 350 07EF 21 0A 00 ld hl,10 ;const 350 07F2 39 add hl,sp 350 07F3 6E ld l,(hl) 350 07F4 26 00 ld h,0 350 07F6 E5 push hl 350 07F7 ;(y1-y0)+1; 350 07F7 C_LINE 350,"Graphics\L2graphics.c" 350 07F7 21 08 00 ld hl,8 ;const 350 07FA 39 add hl,sp 350 07FB 5E ld e,(hl) 350 07FC 16 00 ld d,0 350 07FE 21 0C 00 ld hl,12 ;const 350 0801 39 add hl,sp 350 0802 6E ld l,(hl) 350 0803 26 00 ld h,0 350 0805 EB ex de,hl 350 0806 A7 and a 350 0807 ED 52 sbc hl,de 350 0809 23 inc hl 350 080A E5 push hl 350 080B ;color; 350 080B C_LINE 350,"Graphics\L2graphics.c" 350 080B 21 08 00 ld hl,8 ;const 350 080E 39 add hl,sp 350 080F 6E ld l,(hl) 350 0810 26 00 ld h,0 350 0812 E5 push hl 350 0813 CD E0 02 call _l2_draw_vert_line 350 0816 C1 pop bc 350 0817 C1 pop bc 350 0818 C1 pop bc 350 0819 C1 pop bc 350 081A ; l2_draw_vert_line(x1, y0,(y1-y0)+1, color); 350 081A C_LINE 350,"Graphics\L2graphics.c" 350 081A C_LINE 350,"Graphics\L2graphics.c" 350 081A ;x1; 350 081A C_LINE 351,"Graphics\L2graphics.c" 351 081A 21 06 00 ld hl,6 ;const 351 081D 39 add hl,sp 351 081E 6E ld l,(hl) 351 081F 26 00 ld h,0 351 0821 E5 push hl 351 0822 ;y0; 351 0822 C_LINE 351,"Graphics\L2graphics.c" 351 0822 21 0A 00 ld hl,10 ;const 351 0825 39 add hl,sp 351 0826 6E ld l,(hl) 351 0827 26 00 ld h,0 351 0829 E5 push hl 351 082A ;(y1-y0)+1; 351 082A C_LINE 351,"Graphics\L2graphics.c" 351 082A 21 08 00 ld hl,8 ;const 351 082D 39 add hl,sp 351 082E 5E ld e,(hl) 351 082F 16 00 ld d,0 351 0831 21 0C 00 ld hl,12 ;const 351 0834 39 add hl,sp 351 0835 6E ld l,(hl) 351 0836 26 00 ld h,0 351 0838 EB ex de,hl 351 0839 A7 and a 351 083A ED 52 sbc hl,de 351 083C 23 inc hl 351 083D E5 push hl 351 083E ;color; 351 083E C_LINE 351,"Graphics\L2graphics.c" 351 083E 21 08 00 ld hl,8 ;const 351 0841 39 add hl,sp 351 0842 6E ld l,(hl) 351 0843 26 00 ld h,0 351 0845 E5 push hl 351 0846 CD E0 02 call _l2_draw_vert_line 351 0849 C1 pop bc 351 084A C1 pop bc 351 084B C1 pop bc 351 084C C1 pop bc 351 084D ;} 351 084D C_LINE 351,"Graphics\L2graphics.c" 351 084D C9 ret 351 084E 351 084E 351 084E ; 351 084E C_LINE 352,"Graphics\L2graphics.c" 352 084E ; 352 084E C_LINE 353,"Graphics\L2graphics.c" 353 084E ; 353 084E C_LINE 354,"Graphics\L2graphics.c" 354 084E ;void l2_draw_diagonal (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1 , uint8_t color) 354 084E C_LINE 355,"Graphics\L2graphics.c" 355 084E ;{ 355 084E C_LINE 356,"Graphics\L2graphics.c" 356 084E 356 084E ; Function l2_draw_diagonal flags 0x00000200 __smallc 356 084E ; void l2_draw_diagonal(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color) 356 084E ; parameter 'unsigned char color' at 2 size(1) 356 084E ; parameter 'unsigned char y1' at 4 size(1) 356 084E ; parameter 'unsigned char x1' at 6 size(1) 356 084E ; parameter 'unsigned char y0' at 8 size(1) 356 084E ; parameter 'unsigned char x0' at 10 size(1) 356 084E ._l2_draw_diagonal 356 084E C_LINE 356,"Graphics\L2graphics.c" 356 084E ; 356 084E C_LINE 357,"Graphics\L2graphics.c" 357 084E ; if (y0 > y1) 357 084E C_LINE 358,"Graphics\L2graphics.c" 358 084E C_LINE 358,"Graphics\L2graphics.c" 358 084E 21 08 00 ld hl,8 ;const 358 0851 39 add hl,sp 358 0852 5E ld e,(hl) 358 0853 16 00 ld d,0 358 0855 21 04 00 ld hl,4 ;const 358 0858 39 add hl,sp 358 0859 6E ld l,(hl) 358 085A 26 00 ld h,0 358 085C A7 and a 358 085D ED 52 sbc hl,de 358 085F D2 8D 08 jp nc,i_52 358 0862 ; { 358 0862 C_LINE 359,"Graphics\L2graphics.c" 359 0862 C_LINE 359,"Graphics\L2graphics.c" 359 0862 ; l2_vx0 = x1; 359 0862 C_LINE 360,"Graphics\L2graphics.c" 360 0862 C_LINE 360,"Graphics\L2graphics.c" 360 0862 21 06 00 ld hl,6 ;const 360 0865 39 add hl,sp 360 0866 6E ld l,(hl) 360 0867 26 00 ld h,0 360 0869 22 A7 17 ld (_l2_vx0),hl 360 086C ; l2_vy0 = y1; 360 086C C_LINE 361,"Graphics\L2graphics.c" 361 086C C_LINE 361,"Graphics\L2graphics.c" 361 086C 21 04 00 ld hl,4 ;const 361 086F 39 add hl,sp 361 0870 6E ld l,(hl) 361 0871 26 00 ld h,0 361 0873 22 A9 17 ld (_l2_vy0),hl 361 0876 ; l2_vx1 = x0; 361 0876 C_LINE 362,"Graphics\L2graphics.c" 362 0876 C_LINE 362,"Graphics\L2graphics.c" 362 0876 21 0A 00 ld hl,10 ;const 362 0879 39 add hl,sp 362 087A 6E ld l,(hl) 362 087B 26 00 ld h,0 362 087D 22 AB 17 ld (_l2_vx1),hl 362 0880 ; l2_vy1 = y0; 362 0880 C_LINE 363,"Graphics\L2graphics.c" 363 0880 C_LINE 363,"Graphics\L2graphics.c" 363 0880 21 08 00 ld hl,8 ;const 363 0883 39 add hl,sp 363 0884 6E ld l,(hl) 363 0885 26 00 ld h,0 363 0887 22 AD 17 ld (_l2_vy1),hl 363 088A ; } 363 088A C_LINE 364,"Graphics\L2graphics.c" 364 088A ; else 364 088A C_LINE 365,"Graphics\L2graphics.c" 365 088A C3 B5 08 jp i_53 365 088D .i_52 365 088D ; { 365 088D C_LINE 366,"Graphics\L2graphics.c" 366 088D C_LINE 366,"Graphics\L2graphics.c" 366 088D ; l2_vx0 = x0; 366 088D C_LINE 367,"Graphics\L2graphics.c" 367 088D C_LINE 367,"Graphics\L2graphics.c" 367 088D 21 0A 00 ld hl,10 ;const 367 0890 39 add hl,sp 367 0891 6E ld l,(hl) 367 0892 26 00 ld h,0 367 0894 22 A7 17 ld (_l2_vx0),hl 367 0897 ; l2_vy0 = y0; 367 0897 C_LINE 368,"Graphics\L2graphics.c" 368 0897 C_LINE 368,"Graphics\L2graphics.c" 368 0897 21 08 00 ld hl,8 ;const 368 089A 39 add hl,sp 368 089B 6E ld l,(hl) 368 089C 26 00 ld h,0 368 089E 22 A9 17 ld (_l2_vy0),hl 368 08A1 ; l2_vx1 = x1; 368 08A1 C_LINE 369,"Graphics\L2graphics.c" 369 08A1 C_LINE 369,"Graphics\L2graphics.c" 369 08A1 21 06 00 ld hl,6 ;const 369 08A4 39 add hl,sp 369 08A5 6E ld l,(hl) 369 08A6 26 00 ld h,0 369 08A8 22 AB 17 ld (_l2_vx1),hl 369 08AB ; l2_vy1 = y1; 369 08AB C_LINE 370,"Graphics\L2graphics.c" 370 08AB C_LINE 370,"Graphics\L2graphics.c" 370 08AB 21 04 00 ld hl,4 ;const 370 08AE 39 add hl,sp 370 08AF 6E ld l,(hl) 370 08B0 26 00 ld h,0 370 08B2 22 AD 17 ld (_l2_vy1),hl 370 08B5 ; } 370 08B5 C_LINE 371,"Graphics\L2graphics.c" 371 08B5 .i_53 371 08B5 ; 371 08B5 C_LINE 372,"Graphics\L2graphics.c" 372 08B5 ; l2_dy = l2_vy1 - l2_vy0; 372 08B5 C_LINE 373,"Graphics\L2graphics.c" 373 08B5 C_LINE 373,"Graphics\L2graphics.c" 373 08B5 ED 5B AD 17 ld de,(_l2_vy1) 373 08B9 2A A9 17 ld hl,(_l2_vy0) 373 08BC EB ex de,hl 373 08BD A7 and a 373 08BE ED 52 sbc hl,de 373 08C0 22 A3 17 ld (_l2_dy),hl 373 08C3 ; l2_dx = l2_vx1 - l2_vx0; 373 08C3 C_LINE 374,"Graphics\L2graphics.c" 374 08C3 C_LINE 374,"Graphics\L2graphics.c" 374 08C3 ED 5B AB 17 ld de,(_l2_vx1) 374 08C7 2A A7 17 ld hl,(_l2_vx0) 374 08CA EB ex de,hl 374 08CB A7 and a 374 08CC ED 52 sbc hl,de 374 08CE 22 A5 17 ld (_l2_dx),hl 374 08D1 ; l2_layer_shift = 0; 374 08D1 C_LINE 375,"Graphics\L2graphics.c" 375 08D1 C_LINE 375,"Graphics\L2graphics.c" 375 08D1 21 00 00 ld hl,0 % 256 ;const 375 08D4 7D ld a,l 375 08D5 32 9C 17 ld (_l2_layer_shift),a 375 08D8 ; if (l2_dx < 0) 375 08D8 C_LINE 377,"Graphics\L2graphics.c" 377 08D8 C_LINE 377,"Graphics\L2graphics.c" 377 08D8 2A A5 17 ld hl,(_l2_dx) 377 08DB 7C ld a,h 377 08DC 17 rla 377 08DD D2 F2 08 jp nc,i_54 377 08E0 ; { 377 08E0 C_LINE 378,"Graphics\L2graphics.c" 378 08E0 C_LINE 378,"Graphics\L2graphics.c" 378 08E0 ; l2_dx = -l2_dx; 378 08E0 C_LINE 379,"Graphics\L2graphics.c" 379 08E0 C_LINE 379,"Graphics\L2graphics.c" 379 08E0 2A A5 17 ld hl,(_l2_dx) 379 08E3 CD 00 00 call l_neg 379 08E6 22 A5 17 ld (_l2_dx),hl 379 08E9 ; l2_stepx = -1; 379 08E9 C_LINE 380,"Graphics\L2graphics.c" 380 08E9 C_LINE 380,"Graphics\L2graphics.c" 380 08E9 21 FF FF ld hl,65535 ;const 380 08EC 22 9D 17 ld (_l2_stepx),hl 380 08EF ; } 380 08EF C_LINE 381,"Graphics\L2graphics.c" 381 08EF ; else 381 08EF C_LINE 382,"Graphics\L2graphics.c" 382 08EF C3 F8 08 jp i_55 382 08F2 .i_54 382 08F2 ; { 382 08F2 C_LINE 383,"Graphics\L2graphics.c" 383 08F2 C_LINE 383,"Graphics\L2graphics.c" 383 08F2 ; l2_stepx = 1; 383 08F2 C_LINE 384,"Graphics\L2graphics.c" 384 08F2 C_LINE 384,"Graphics\L2graphics.c" 384 08F2 21 01 00 ld hl,1 ;const 384 08F5 22 9D 17 ld (_l2_stepx),hl 384 08F8 ; } 384 08F8 C_LINE 385,"Graphics\L2graphics.c" 385 08F8 .i_55 385 08F8 ; l2_dy <<= 1; 385 08F8 C_LINE 386,"Graphics\L2graphics.c" 386 08F8 C_LINE 386,"Graphics\L2graphics.c" 386 08F8 2A A3 17 ld hl,(_l2_dy) 386 08FB 29 add hl,hl 386 08FC 22 A3 17 ld (_l2_dy),hl 386 08FF ; l2_dx <<= 1; 386 08FF C_LINE 387,"Graphics\L2graphics.c" 387 08FF C_LINE 387,"Graphics\L2graphics.c" 387 08FF 2A A5 17 ld hl,(_l2_dx) 387 0902 29 add hl,hl 387 0903 22 A5 17 ld (_l2_dx),hl 387 0906 ; l2_plot_pixel(l2_vx0,l2_vy0,color); 387 0906 C_LINE 388,"Graphics\L2graphics.c" 388 0906 C_LINE 388,"Graphics\L2graphics.c" 388 0906 ;l2_vx0; 388 0906 C_LINE 389,"Graphics\L2graphics.c" 389 0906 2A A7 17 ld hl,(_l2_vx0) 389 0909 26 00 ld h,0 389 090B E5 push hl 389 090C ;l2_vy0; 389 090C C_LINE 389,"Graphics\L2graphics.c" 389 090C 2A A9 17 ld hl,(_l2_vy0) 389 090F 26 00 ld h,0 389 0911 E5 push hl 389 0912 ;color; 389 0912 C_LINE 389,"Graphics\L2graphics.c" 389 0912 21 06 00 ld hl,6 ;const 389 0915 39 add hl,sp 389 0916 6E ld l,(hl) 389 0917 26 00 ld h,0 389 0919 E5 push hl 389 091A CD 32 01 call _l2_plot_pixel 389 091D C1 pop bc 389 091E C1 pop bc 389 091F C1 pop bc 389 0920 ; if (l2_dx > l2_dy) 389 0920 C_LINE 390,"Graphics\L2graphics.c" 390 0920 C_LINE 390,"Graphics\L2graphics.c" 390 0920 ED 5B A5 17 ld de,(_l2_dx) 390 0924 2A A3 17 ld hl,(_l2_dy) 390 0927 CD 00 00 call l_gt 390 092A D2 A1 09 jp nc,i_56 390 092D ; { 390 092D C_LINE 391,"Graphics\L2graphics.c" 391 092D C_LINE 391,"Graphics\L2graphics.c" 391 092D ; l2_fraction = l2_dy - (l2_dx >> 1); 391 092D C_LINE 392,"Graphics\L2graphics.c" 392 092D C_LINE 392,"Graphics\L2graphics.c" 392 092D 2A A3 17 ld hl,(_l2_dy) 392 0930 E5 push hl 392 0931 2A A5 17 ld hl,(_l2_dx) 392 0934 CB 2C sra h 392 0936 CB 1D rr l 392 0938 D1 pop de 392 0939 EB ex de,hl 392 093A A7 and a 392 093B ED 52 sbc hl,de 392 093D 22 A1 17 ld (_l2_fraction),hl 392 0940 ; while (l2_vx0 != l2_vx1) 392 0940 C_LINE 393,"Graphics\L2graphics.c" 393 0940 C_LINE 393,"Graphics\L2graphics.c" 393 0940 .i_57 393 0940 ED 5B A7 17 ld de,(_l2_vx0) 393 0944 2A AB 17 ld hl,(_l2_vx1) 393 0947 CD 00 00 call l_ne 393 094A D2 9E 09 jp nc,i_58 393 094D ; { 393 094D C_LINE 394,"Graphics\L2graphics.c" 394 094D C_LINE 394,"Graphics\L2graphics.c" 394 094D ; if (l2_fraction >= 0) 394 094D C_LINE 395,"Graphics\L2graphics.c" 395 094D C_LINE 395,"Graphics\L2graphics.c" 395 094D 2A A1 17 ld hl,(_l2_fraction) 395 0950 7C ld a,h 395 0951 17 rla 395 0952 3F ccf 395 0953 D2 6B 09 jp nc,i_59 395 0956 ; { 395 0956 C_LINE 396,"Graphics\L2graphics.c" 396 0956 C_LINE 396,"Graphics\L2graphics.c" 396 0956 ; ++l2_vy0; 396 0956 C_LINE 397,"Graphics\L2graphics.c" 397 0956 C_LINE 397,"Graphics\L2graphics.c" 397 0956 2A A9 17 ld hl,(_l2_vy0) 397 0959 23 inc hl 397 095A 22 A9 17 ld (_l2_vy0),hl 397 095D ; l2_fraction -= l2_dx; 397 095D C_LINE 398,"Graphics\L2graphics.c" 398 095D C_LINE 398,"Graphics\L2graphics.c" 398 095D ED 5B A1 17 ld de,(_l2_fraction) 398 0961 2A A5 17 ld hl,(_l2_dx) 398 0964 EB ex de,hl 398 0965 A7 and a 398 0966 ED 52 sbc hl,de 398 0968 22 A1 17 ld (_l2_fraction),hl 398 096B ; } 398 096B C_LINE 399,"Graphics\L2graphics.c" 399 096B ; l2_vx0 += l2_stepx; 399 096B C_LINE 400,"Graphics\L2graphics.c" 400 096B .i_59 400 096B C_LINE 400,"Graphics\L2graphics.c" 400 096B ED 5B A7 17 ld de,(_l2_vx0) 400 096F 2A 9D 17 ld hl,(_l2_stepx) 400 0972 19 add hl,de 400 0973 22 A7 17 ld (_l2_vx0),hl 400 0976 ; l2_fraction += l2_dy; 400 0976 C_LINE 401,"Graphics\L2graphics.c" 401 0976 C_LINE 401,"Graphics\L2graphics.c" 401 0976 ED 5B A1 17 ld de,(_l2_fraction) 401 097A 2A A3 17 ld hl,(_l2_dy) 401 097D 19 add hl,de 401 097E 22 A1 17 ld (_l2_fraction),hl 401 0981 ; l2_plot_pixel(l2_vx0,l2_vy0,color); 401 0981 C_LINE 402,"Graphics\L2graphics.c" 402 0981 C_LINE 402,"Graphics\L2graphics.c" 402 0981 ;l2_vx0; 402 0981 C_LINE 403,"Graphics\L2graphics.c" 403 0981 2A A7 17 ld hl,(_l2_vx0) 403 0984 26 00 ld h,0 403 0986 E5 push hl 403 0987 ;l2_vy0; 403 0987 C_LINE 403,"Graphics\L2graphics.c" 403 0987 2A A9 17 ld hl,(_l2_vy0) 403 098A 26 00 ld h,0 403 098C E5 push hl 403 098D ;color; 403 098D C_LINE 403,"Graphics\L2graphics.c" 403 098D 21 06 00 ld hl,6 ;const 403 0990 39 add hl,sp 403 0991 6E ld l,(hl) 403 0992 26 00 ld h,0 403 0994 E5 push hl 403 0995 CD 32 01 call _l2_plot_pixel 403 0998 C1 pop bc 403 0999 C1 pop bc 403 099A C1 pop bc 403 099B ; } 403 099B C_LINE 403,"Graphics\L2graphics.c" 403 099B C3 40 09 jp i_57 403 099E .i_58 403 099E ; } 403 099E C_LINE 404,"Graphics\L2graphics.c" 404 099E ; else 404 099E C_LINE 405,"Graphics\L2graphics.c" 405 099E C3 12 0A jp i_60 405 09A1 .i_56 405 09A1 ; { 405 09A1 C_LINE 406,"Graphics\L2graphics.c" 406 09A1 C_LINE 406,"Graphics\L2graphics.c" 406 09A1 ; l2_fraction = l2_dx - (l2_dy >> 1); 406 09A1 C_LINE 407,"Graphics\L2graphics.c" 407 09A1 C_LINE 407,"Graphics\L2graphics.c" 407 09A1 2A A5 17 ld hl,(_l2_dx) 407 09A4 E5 push hl 407 09A5 2A A3 17 ld hl,(_l2_dy) 407 09A8 CB 2C sra h 407 09AA CB 1D rr l 407 09AC D1 pop de 407 09AD EB ex de,hl 407 09AE A7 and a 407 09AF ED 52 sbc hl,de 407 09B1 22 A1 17 ld (_l2_fraction),hl 407 09B4 ; while (l2_vy0 != l2_vy1) 407 09B4 C_LINE 408,"Graphics\L2graphics.c" 408 09B4 C_LINE 408,"Graphics\L2graphics.c" 408 09B4 .i_61 408 09B4 ED 5B A9 17 ld de,(_l2_vy0) 408 09B8 2A AD 17 ld hl,(_l2_vy1) 408 09BB CD 00 00 call l_ne 408 09BE D2 12 0A jp nc,i_62 408 09C1 ; { 408 09C1 C_LINE 409,"Graphics\L2graphics.c" 409 09C1 C_LINE 409,"Graphics\L2graphics.c" 409 09C1 ; if (l2_fraction >= 0) 409 09C1 C_LINE 410,"Graphics\L2graphics.c" 410 09C1 C_LINE 410,"Graphics\L2graphics.c" 410 09C1 2A A1 17 ld hl,(_l2_fraction) 410 09C4 7C ld a,h 410 09C5 17 rla 410 09C6 3F ccf 410 09C7 D2 E3 09 jp nc,i_63 410 09CA ; { 410 09CA C_LINE 411,"Graphics\L2graphics.c" 411 09CA C_LINE 411,"Graphics\L2graphics.c" 411 09CA ; l2_vx0 += l2_stepx; 411 09CA C_LINE 412,"Graphics\L2graphics.c" 412 09CA C_LINE 412,"Graphics\L2graphics.c" 412 09CA ED 5B A7 17 ld de,(_l2_vx0) 412 09CE 2A 9D 17 ld hl,(_l2_stepx) 412 09D1 19 add hl,de 412 09D2 22 A7 17 ld (_l2_vx0),hl 412 09D5 ; l2_fraction -= l2_dy; 412 09D5 C_LINE 413,"Graphics\L2graphics.c" 413 09D5 C_LINE 413,"Graphics\L2graphics.c" 413 09D5 ED 5B A1 17 ld de,(_l2_fraction) 413 09D9 2A A3 17 ld hl,(_l2_dy) 413 09DC EB ex de,hl 413 09DD A7 and a 413 09DE ED 52 sbc hl,de 413 09E0 22 A1 17 ld (_l2_fraction),hl 413 09E3 ; } 413 09E3 C_LINE 414,"Graphics\L2graphics.c" 414 09E3 ; l2_fraction += l2_dx; 414 09E3 C_LINE 415,"Graphics\L2graphics.c" 415 09E3 .i_63 415 09E3 C_LINE 415,"Graphics\L2graphics.c" 415 09E3 ED 5B A1 17 ld de,(_l2_fraction) 415 09E7 2A A5 17 ld hl,(_l2_dx) 415 09EA 19 add hl,de 415 09EB 22 A1 17 ld (_l2_fraction),hl 415 09EE ; ++l2_vy0; 415 09EE C_LINE 416,"Graphics\L2graphics.c" 416 09EE C_LINE 416,"Graphics\L2graphics.c" 416 09EE 2A A9 17 ld hl,(_l2_vy0) 416 09F1 23 inc hl 416 09F2 22 A9 17 ld (_l2_vy0),hl 416 09F5 ; l2_plot_pixel(l2_vx0,l2_vy0,color); 416 09F5 C_LINE 417,"Graphics\L2graphics.c" 417 09F5 C_LINE 417,"Graphics\L2graphics.c" 417 09F5 ;l2_vx0; 417 09F5 C_LINE 418,"Graphics\L2graphics.c" 418 09F5 2A A7 17 ld hl,(_l2_vx0) 418 09F8 26 00 ld h,0 418 09FA E5 push hl 418 09FB ;l2_vy0; 418 09FB C_LINE 418,"Graphics\L2graphics.c" 418 09FB 2A A9 17 ld hl,(_l2_vy0) 418 09FE 26 00 ld h,0 418 0A00 E5 push hl 418 0A01 ;color; 418 0A01 C_LINE 418,"Graphics\L2graphics.c" 418 0A01 21 06 00 ld hl,6 ;const 418 0A04 39 add hl,sp 418 0A05 6E ld l,(hl) 418 0A06 26 00 ld h,0 418 0A08 E5 push hl 418 0A09 CD 32 01 call _l2_plot_pixel 418 0A0C C1 pop bc 418 0A0D C1 pop bc 418 0A0E C1 pop bc 418 0A0F ; } 418 0A0F C_LINE 418,"Graphics\L2graphics.c" 418 0A0F C3 B4 09 jp i_61 418 0A12 .i_62 418 0A12 ; } 418 0A12 C_LINE 419,"Graphics\L2graphics.c" 419 0A12 .i_60 419 0A12 ;} 419 0A12 C_LINE 421,"Graphics\L2graphics.c" 421 0A12 C9 ret 421 0A13 421 0A13 421 0A13 ; 421 0A13 C_LINE 423,"Graphics\L2graphics.c" 423 0A13 ;void l2_draw_diagonal_clip (int x0, int y0, int x1, int y1 , uint8_t color) 423 0A13 C_LINE 424,"Graphics\L2graphics.c" 424 0A13 ;{ 424 0A13 C_LINE 425,"Graphics\L2graphics.c" 425 0A13 425 0A13 ; Function l2_draw_diagonal_clip flags 0x00000200 __smallc 425 0A13 ; void l2_draw_diagonal_clip(int x0, int y0, int x1, int y1, unsigned char color) 425 0A13 ; parameter 'unsigned char color' at 2 size(1) 425 0A13 ; parameter 'int y1' at 4 size(2) 425 0A13 ; parameter 'int x1' at 6 size(2) 425 0A13 ; parameter 'int y0' at 8 size(2) 425 0A13 ; parameter 'int x0' at 10 size(2) 425 0A13 ._l2_draw_diagonal_clip 425 0A13 C_LINE 425,"Graphics\L2graphics.c" 425 0A13 ; 425 0A13 C_LINE 427,"Graphics\L2graphics.c" 427 0A13 ; if (y0 > y1) 427 0A13 C_LINE 428,"Graphics\L2graphics.c" 428 0A13 C_LINE 428,"Graphics\L2graphics.c" 428 0A13 21 08 00 ld hl,8 ;const 428 0A16 CD 00 00 call l_gintspsp ; 428 0A19 21 06 00 ld hl,6 ;const 428 0A1C 39 add hl,sp 428 0A1D CD 00 00 call l_gint ; 428 0A20 D1 pop de 428 0A21 CD 00 00 call l_gt 428 0A24 D2 52 0A jp nc,i_64 428 0A27 ; { 428 0A27 C_LINE 429,"Graphics\L2graphics.c" 429 0A27 C_LINE 429,"Graphics\L2graphics.c" 429 0A27 ; l2_vx0 = x1; 429 0A27 C_LINE 430,"Graphics\L2graphics.c" 430 0A27 C_LINE 430,"Graphics\L2graphics.c" 430 0A27 21 06 00 ld hl,6 ;const 430 0A2A 39 add hl,sp 430 0A2B CD 00 00 call l_gint ; 430 0A2E 22 A7 17 ld (_l2_vx0),hl 430 0A31 ; l2_vy0 = y1; 430 0A31 C_LINE 431,"Graphics\L2graphics.c" 431 0A31 C_LINE 431,"Graphics\L2graphics.c" 431 0A31 21 04 00 ld hl,4 ;const 431 0A34 39 add hl,sp 431 0A35 CD 00 00 call l_gint ; 431 0A38 22 A9 17 ld (_l2_vy0),hl 431 0A3B ; l2_vx1 = x0; 431 0A3B C_LINE 432,"Graphics\L2graphics.c" 432 0A3B C_LINE 432,"Graphics\L2graphics.c" 432 0A3B 21 0A 00 ld hl,10 ;const 432 0A3E 39 add hl,sp 432 0A3F CD 00 00 call l_gint ; 432 0A42 22 AB 17 ld (_l2_vx1),hl 432 0A45 ; l2_vy1 = y0; 432 0A45 C_LINE 433,"Graphics\L2graphics.c" 433 0A45 C_LINE 433,"Graphics\L2graphics.c" 433 0A45 21 08 00 ld hl,8 ;const 433 0A48 39 add hl,sp 433 0A49 CD 00 00 call l_gint ; 433 0A4C 22 AD 17 ld (_l2_vy1),hl 433 0A4F ; } 433 0A4F C_LINE 434,"Graphics\L2graphics.c" 434 0A4F ; else 434 0A4F C_LINE 435,"Graphics\L2graphics.c" 435 0A4F C3 7A 0A jp i_65 435 0A52 .i_64 435 0A52 ; { 435 0A52 C_LINE 436,"Graphics\L2graphics.c" 436 0A52 C_LINE 436,"Graphics\L2graphics.c" 436 0A52 ; l2_vx0 = x0; 436 0A52 C_LINE 437,"Graphics\L2graphics.c" 437 0A52 C_LINE 437,"Graphics\L2graphics.c" 437 0A52 21 0A 00 ld hl,10 ;const 437 0A55 39 add hl,sp 437 0A56 CD 00 00 call l_gint ; 437 0A59 22 A7 17 ld (_l2_vx0),hl 437 0A5C ; l2_vy0 = y0; 437 0A5C C_LINE 438,"Graphics\L2graphics.c" 438 0A5C C_LINE 438,"Graphics\L2graphics.c" 438 0A5C 21 08 00 ld hl,8 ;const 438 0A5F 39 add hl,sp 438 0A60 CD 00 00 call l_gint ; 438 0A63 22 A9 17 ld (_l2_vy0),hl 438 0A66 ; l2_vx1 = x1; 438 0A66 C_LINE 439,"Graphics\L2graphics.c" 439 0A66 C_LINE 439,"Graphics\L2graphics.c" 439 0A66 21 06 00 ld hl,6 ;const 439 0A69 39 add hl,sp 439 0A6A CD 00 00 call l_gint ; 439 0A6D 22 AB 17 ld (_l2_vx1),hl 439 0A70 ; l2_vy1 = y1; 439 0A70 C_LINE 440,"Graphics\L2graphics.c" 440 0A70 C_LINE 440,"Graphics\L2graphics.c" 440 0A70 21 04 00 ld hl,4 ;const 440 0A73 39 add hl,sp 440 0A74 CD 00 00 call l_gint ; 440 0A77 22 AD 17 ld (_l2_vy1),hl 440 0A7A ; } 440 0A7A C_LINE 441,"Graphics\L2graphics.c" 441 0A7A .i_65 441 0A7A ; 441 0A7A C_LINE 442,"Graphics\L2graphics.c" 442 0A7A ; l2_dy = l2_vy1 - l2_vy0; 442 0A7A C_LINE 443,"Graphics\L2graphics.c" 443 0A7A C_LINE 443,"Graphics\L2graphics.c" 443 0A7A ED 5B AD 17 ld de,(_l2_vy1) 443 0A7E 2A A9 17 ld hl,(_l2_vy0) 443 0A81 EB ex de,hl 443 0A82 A7 and a 443 0A83 ED 52 sbc hl,de 443 0A85 22 A3 17 ld (_l2_dy),hl 443 0A88 ; l2_dx = l2_vx1 - l2_vx0; 443 0A88 C_LINE 444,"Graphics\L2graphics.c" 444 0A88 C_LINE 444,"Graphics\L2graphics.c" 444 0A88 ED 5B AB 17 ld de,(_l2_vx1) 444 0A8C 2A A7 17 ld hl,(_l2_vx0) 444 0A8F EB ex de,hl 444 0A90 A7 and a 444 0A91 ED 52 sbc hl,de 444 0A93 22 A5 17 ld (_l2_dx),hl 444 0A96 ; l2_layer_shift = 0; 444 0A96 C_LINE 445,"Graphics\L2graphics.c" 445 0A96 C_LINE 445,"Graphics\L2graphics.c" 445 0A96 21 00 00 ld hl,0 % 256 ;const 445 0A99 7D ld a,l 445 0A9A 32 9C 17 ld (_l2_layer_shift),a 445 0A9D ; if (l2_dx < 0) 445 0A9D C_LINE 447,"Graphics\L2graphics.c" 447 0A9D C_LINE 447,"Graphics\L2graphics.c" 447 0A9D 2A A5 17 ld hl,(_l2_dx) 447 0AA0 7C ld a,h 447 0AA1 17 rla 447 0AA2 D2 B7 0A jp nc,i_66 447 0AA5 ; { 447 0AA5 C_LINE 448,"Graphics\L2graphics.c" 448 0AA5 C_LINE 448,"Graphics\L2graphics.c" 448 0AA5 ; l2_dx = -l2_dx; 448 0AA5 C_LINE 449,"Graphics\L2graphics.c" 449 0AA5 C_LINE 449,"Graphics\L2graphics.c" 449 0AA5 2A A5 17 ld hl,(_l2_dx) 449 0AA8 CD 00 00 call l_neg 449 0AAB 22 A5 17 ld (_l2_dx),hl 449 0AAE ; l2_stepx = -1; 449 0AAE C_LINE 450,"Graphics\L2graphics.c" 450 0AAE C_LINE 450,"Graphics\L2graphics.c" 450 0AAE 21 FF FF ld hl,65535 ;const 450 0AB1 22 9D 17 ld (_l2_stepx),hl 450 0AB4 ; } 450 0AB4 C_LINE 451,"Graphics\L2graphics.c" 451 0AB4 ; else 451 0AB4 C_LINE 452,"Graphics\L2graphics.c" 452 0AB4 C3 BD 0A jp i_67 452 0AB7 .i_66 452 0AB7 ; { 452 0AB7 C_LINE 453,"Graphics\L2graphics.c" 453 0AB7 C_LINE 453,"Graphics\L2graphics.c" 453 0AB7 ; l2_stepx = 1; 453 0AB7 C_LINE 454,"Graphics\L2graphics.c" 454 0AB7 C_LINE 454,"Graphics\L2graphics.c" 454 0AB7 21 01 00 ld hl,1 ;const 454 0ABA 22 9D 17 ld (_l2_stepx),hl 454 0ABD ; } 454 0ABD C_LINE 455,"Graphics\L2graphics.c" 455 0ABD .i_67 455 0ABD ; 455 0ABD C_LINE 456,"Graphics\L2graphics.c" 456 0ABD ; 456 0ABD C_LINE 457,"Graphics\L2graphics.c" 457 0ABD ; l2_dy <<= 1; 457 0ABD C_LINE 458,"Graphics\L2graphics.c" 458 0ABD C_LINE 458,"Graphics\L2graphics.c" 458 0ABD 2A A3 17 ld hl,(_l2_dy) 458 0AC0 29 add hl,hl 458 0AC1 22 A3 17 ld (_l2_dy),hl 458 0AC4 ; l2_dx <<= 1; 458 0AC4 C_LINE 459,"Graphics\L2graphics.c" 459 0AC4 C_LINE 459,"Graphics\L2graphics.c" 459 0AC4 2A A5 17 ld hl,(_l2_dx) 459 0AC7 29 add hl,hl 459 0AC8 22 A5 17 ld (_l2_dx),hl 459 0ACB ; if (l2_vx0 >0 && l2_vx0 <255 && l2_vy0 > 0 && l2_vy0 <= 127 ) l2_plot_pixel(l2_vx0,l2_vy0,color); 459 0ACB C_LINE 460,"Graphics\L2graphics.c" 460 0ACB C_LINE 460,"Graphics\L2graphics.c" 460 0ACB 2A A7 17 ld hl,(_l2_vx0) 460 0ACE 11 00 00 ld de,0 460 0AD1 EB ex de,hl 460 0AD2 CD 00 00 call l_gt 460 0AD5 D2 00 0B jp nc,i_69 460 0AD8 2A A7 17 ld hl,(_l2_vx0) 460 0ADB 7D ld a,l 460 0ADC D6 FF sub 255 460 0ADE 7C ld a,h 460 0ADF 17 rla 460 0AE0 3F ccf 460 0AE1 1F rra 460 0AE2 DE 80 sbc 128 460 0AE4 D2 00 0B jp nc,i_69 460 0AE7 2A A9 17 ld hl,(_l2_vy0) 460 0AEA 11 00 00 ld de,0 460 0AED EB ex de,hl 460 0AEE CD 00 00 call l_gt 460 0AF1 D2 00 0B jp nc,i_69 460 0AF4 2A A9 17 ld hl,(_l2_vy0) 460 0AF7 11 7F 00 ld de,127 460 0AFA EB ex de,hl 460 0AFB CD 00 00 call l_le 460 0AFE 38 03 jr c,i_70_i_69 460 0B00 .i_69 460 0B00 C3 1D 0B jp i_68 460 0B03 .i_70_i_69 460 0B03 ;l2_vx0; 460 0B03 C_LINE 461,"Graphics\L2graphics.c" 461 0B03 2A A7 17 ld hl,(_l2_vx0) 461 0B06 26 00 ld h,0 461 0B08 E5 push hl 461 0B09 ;l2_vy0; 461 0B09 C_LINE 461,"Graphics\L2graphics.c" 461 0B09 2A A9 17 ld hl,(_l2_vy0) 461 0B0C 26 00 ld h,0 461 0B0E E5 push hl 461 0B0F ;color; 461 0B0F C_LINE 461,"Graphics\L2graphics.c" 461 0B0F 21 06 00 ld hl,6 ;const 461 0B12 39 add hl,sp 461 0B13 6E ld l,(hl) 461 0B14 26 00 ld h,0 461 0B16 E5 push hl 461 0B17 CD 32 01 call _l2_plot_pixel 461 0B1A C1 pop bc 461 0B1B C1 pop bc 461 0B1C C1 pop bc 461 0B1D ; if (l2_dx > l2_dy) 461 0B1D C_LINE 462,"Graphics\L2graphics.c" 462 0B1D .i_68 462 0B1D C_LINE 462,"Graphics\L2graphics.c" 462 0B1D ED 5B A5 17 ld de,(_l2_dx) 462 0B21 2A A3 17 ld hl,(_l2_dy) 462 0B24 CD 00 00 call l_gt 462 0B27 D2 0A 0C jp nc,i_71 462 0B2A ; { 462 0B2A C_LINE 463,"Graphics\L2graphics.c" 463 0B2A C_LINE 463,"Graphics\L2graphics.c" 463 0B2A ; l2_fraction = l2_dy - (l2_dx >> 1); 463 0B2A C_LINE 464,"Graphics\L2graphics.c" 464 0B2A C_LINE 464,"Graphics\L2graphics.c" 464 0B2A 2A A3 17 ld hl,(_l2_dy) 464 0B2D E5 push hl 464 0B2E 2A A5 17 ld hl,(_l2_dx) 464 0B31 CB 2C sra h 464 0B33 CB 1D rr l 464 0B35 D1 pop de 464 0B36 EB ex de,hl 464 0B37 A7 and a 464 0B38 ED 52 sbc hl,de 464 0B3A 22 A1 17 ld (_l2_fraction),hl 464 0B3D ; while (l2_vx0 != l2_vx1) 464 0B3D C_LINE 465,"Graphics\L2graphics.c" 465 0B3D C_LINE 465,"Graphics\L2graphics.c" 465 0B3D .i_72 465 0B3D ED 5B A7 17 ld de,(_l2_vx0) 465 0B41 2A AB 17 ld hl,(_l2_vx1) 465 0B44 CD 00 00 call l_ne 465 0B47 D2 07 0C jp nc,i_73 465 0B4A ; { 465 0B4A C_LINE 466,"Graphics\L2graphics.c" 466 0B4A C_LINE 466,"Graphics\L2graphics.c" 466 0B4A ; if (l2_fraction >= 0) 466 0B4A C_LINE 467,"Graphics\L2graphics.c" 467 0B4A C_LINE 467,"Graphics\L2graphics.c" 467 0B4A 2A A1 17 ld hl,(_l2_fraction) 467 0B4D 7C ld a,h 467 0B4E 17 rla 467 0B4F 3F ccf 467 0B50 D2 68 0B jp nc,i_74 467 0B53 ; { 467 0B53 C_LINE 468,"Graphics\L2graphics.c" 468 0B53 C_LINE 468,"Graphics\L2graphics.c" 468 0B53 ; ++l2_vy0; 468 0B53 C_LINE 469,"Graphics\L2graphics.c" 469 0B53 C_LINE 469,"Graphics\L2graphics.c" 469 0B53 2A A9 17 ld hl,(_l2_vy0) 469 0B56 23 inc hl 469 0B57 22 A9 17 ld (_l2_vy0),hl 469 0B5A ; l2_fraction -= l2_dx; 469 0B5A C_LINE 470,"Graphics\L2graphics.c" 470 0B5A C_LINE 470,"Graphics\L2graphics.c" 470 0B5A ED 5B A1 17 ld de,(_l2_fraction) 470 0B5E 2A A5 17 ld hl,(_l2_dx) 470 0B61 EB ex de,hl 470 0B62 A7 and a 470 0B63 ED 52 sbc hl,de 470 0B65 22 A1 17 ld (_l2_fraction),hl 470 0B68 ; } 470 0B68 C_LINE 471,"Graphics\L2graphics.c" 471 0B68 ; l2_vx0 += l2_stepx; 471 0B68 C_LINE 472,"Graphics\L2graphics.c" 472 0B68 .i_74 472 0B68 C_LINE 472,"Graphics\L2graphics.c" 472 0B68 ED 5B A7 17 ld de,(_l2_vx0) 472 0B6C 2A 9D 17 ld hl,(_l2_stepx) 472 0B6F 19 add hl,de 472 0B70 22 A7 17 ld (_l2_vx0),hl 472 0B73 ; if (l2_stepx == 1 && l2_vx0 > 127 ) break; 472 0B73 C_LINE 473,"Graphics\L2graphics.c" 473 0B73 C_LINE 473,"Graphics\L2graphics.c" 473 0B73 2A 9D 17 ld hl,(_l2_stepx) 473 0B76 2B dec hl 473 0B77 7C ld a,h 473 0B78 B5 or l 473 0B79 C2 88 0B jp nz,i_76 473 0B7C 2A A7 17 ld hl,(_l2_vx0) 473 0B7F 11 7F 00 ld de,127 473 0B82 EB ex de,hl 473 0B83 CD 00 00 call l_gt 473 0B86 38 03 jr c,i_77_i_76 473 0B88 .i_76 473 0B88 C3 8E 0B jp i_75 473 0B8B .i_77_i_76 473 0B8B C3 07 0C jp i_73 473 0B8E ; if (l2_stepx == -1 && l2_vx0 < 0) break; 473 0B8E C_LINE 474,"Graphics\L2graphics.c" 474 0B8E .i_75 474 0B8E C_LINE 474,"Graphics\L2graphics.c" 474 0B8E 2A 9D 17 ld hl,(_l2_stepx) 474 0B91 11 FF FF ld de,65535 474 0B94 A7 and a 474 0B95 ED 52 sbc hl,de 474 0B97 C2 A1 0B jp nz,i_79 474 0B9A 2A A7 17 ld hl,(_l2_vx0) 474 0B9D 7C ld a,h 474 0B9E 17 rla 474 0B9F 38 03 jr c,i_80_i_79 474 0BA1 .i_79 474 0BA1 C3 A7 0B jp i_78 474 0BA4 .i_80_i_79 474 0BA4 C3 07 0C jp i_73 474 0BA7 ; l2_fraction += l2_dy; 474 0BA7 C_LINE 475,"Graphics\L2graphics.c" 475 0BA7 .i_78 475 0BA7 C_LINE 475,"Graphics\L2graphics.c" 475 0BA7 ED 5B A1 17 ld de,(_l2_fraction) 475 0BAB 2A A3 17 ld hl,(_l2_dy) 475 0BAE 19 add hl,de 475 0BAF 22 A1 17 ld (_l2_fraction),hl 475 0BB2 ; if (l2_vx0 >0 && l2_vx0 <255 && l2_vy0 > 0 && l2_vy0 <= 127 ) 475 0BB2 C_LINE 476,"Graphics\L2graphics.c" 476 0BB2 C_LINE 476,"Graphics\L2graphics.c" 476 0BB2 2A A7 17 ld hl,(_l2_vx0) 476 0BB5 11 00 00 ld de,0 476 0BB8 EB ex de,hl 476 0BB9 CD 00 00 call l_gt 476 0BBC D2 E7 0B jp nc,i_82 476 0BBF 2A A7 17 ld hl,(_l2_vx0) 476 0BC2 7D ld a,l 476 0BC3 D6 FF sub 255 476 0BC5 7C ld a,h 476 0BC6 17 rla 476 0BC7 3F ccf 476 0BC8 1F rra 476 0BC9 DE 80 sbc 128 476 0BCB D2 E7 0B jp nc,i_82 476 0BCE 2A A9 17 ld hl,(_l2_vy0) 476 0BD1 11 00 00 ld de,0 476 0BD4 EB ex de,hl 476 0BD5 CD 00 00 call l_gt 476 0BD8 D2 E7 0B jp nc,i_82 476 0BDB 2A A9 17 ld hl,(_l2_vy0) 476 0BDE 11 7F 00 ld de,127 476 0BE1 EB ex de,hl 476 0BE2 CD 00 00 call l_le 476 0BE5 38 03 jr c,i_83_i_82 476 0BE7 .i_82 476 0BE7 C3 04 0C jp i_81 476 0BEA .i_83_i_82 476 0BEA ; { 476 0BEA C_LINE 477,"Graphics\L2graphics.c" 477 0BEA C_LINE 477,"Graphics\L2graphics.c" 477 0BEA ; l2_plot_pixel(l2_vx0,l2_vy0,color); 477 0BEA C_LINE 478,"Graphics\L2graphics.c" 478 0BEA C_LINE 478,"Graphics\L2graphics.c" 478 0BEA ;l2_vx0; 478 0BEA C_LINE 479,"Graphics\L2graphics.c" 479 0BEA 2A A7 17 ld hl,(_l2_vx0) 479 0BED 26 00 ld h,0 479 0BEF E5 push hl 479 0BF0 ;l2_vy0; 479 0BF0 C_LINE 479,"Graphics\L2graphics.c" 479 0BF0 2A A9 17 ld hl,(_l2_vy0) 479 0BF3 26 00 ld h,0 479 0BF5 E5 push hl 479 0BF6 ;color; 479 0BF6 C_LINE 479,"Graphics\L2graphics.c" 479 0BF6 21 06 00 ld hl,6 ;const 479 0BF9 39 add hl,sp 479 0BFA 6E ld l,(hl) 479 0BFB 26 00 ld h,0 479 0BFD E5 push hl 479 0BFE CD 32 01 call _l2_plot_pixel 479 0C01 C1 pop bc 479 0C02 C1 pop bc 479 0C03 C1 pop bc 479 0C04 ; } 479 0C04 C_LINE 479,"Graphics\L2graphics.c" 479 0C04 ; } 479 0C04 C_LINE 480,"Graphics\L2graphics.c" 480 0C04 .i_81 480 0C04 C3 3D 0B jp i_72 480 0C07 .i_73 480 0C07 ; } 480 0C07 C_LINE 481,"Graphics\L2graphics.c" 481 0C07 ; else 481 0C07 C_LINE 482,"Graphics\L2graphics.c" 482 0C07 C3 C3 0C jp i_84 482 0C0A .i_71 482 0C0A ; { 482 0C0A C_LINE 483,"Graphics\L2graphics.c" 483 0C0A C_LINE 483,"Graphics\L2graphics.c" 483 0C0A ; l2_fraction = l2_dx - (l2_dy >> 1); 483 0C0A C_LINE 484,"Graphics\L2graphics.c" 484 0C0A C_LINE 484,"Graphics\L2graphics.c" 484 0C0A 2A A5 17 ld hl,(_l2_dx) 484 0C0D E5 push hl 484 0C0E 2A A3 17 ld hl,(_l2_dy) 484 0C11 CB 2C sra h 484 0C13 CB 1D rr l 484 0C15 D1 pop de 484 0C16 EB ex de,hl 484 0C17 A7 and a 484 0C18 ED 52 sbc hl,de 484 0C1A 22 A1 17 ld (_l2_fraction),hl 484 0C1D ; while (l2_vy0 != l2_vy1) 484 0C1D C_LINE 485,"Graphics\L2graphics.c" 485 0C1D C_LINE 485,"Graphics\L2graphics.c" 485 0C1D .i_85 485 0C1D ED 5B A9 17 ld de,(_l2_vy0) 485 0C21 2A AD 17 ld hl,(_l2_vy1) 485 0C24 CD 00 00 call l_ne 485 0C27 D2 C3 0C jp nc,i_86 485 0C2A ; { 485 0C2A C_LINE 486,"Graphics\L2graphics.c" 486 0C2A C_LINE 486,"Graphics\L2graphics.c" 486 0C2A ; if (l2_fraction >= 0) 486 0C2A C_LINE 487,"Graphics\L2graphics.c" 487 0C2A C_LINE 487,"Graphics\L2graphics.c" 487 0C2A 2A A1 17 ld hl,(_l2_fraction) 487 0C2D 7C ld a,h 487 0C2E 17 rla 487 0C2F 3F ccf 487 0C30 D2 4C 0C jp nc,i_87 487 0C33 ; { 487 0C33 C_LINE 488,"Graphics\L2graphics.c" 488 0C33 C_LINE 488,"Graphics\L2graphics.c" 488 0C33 ; l2_vx0 += l2_stepx; 488 0C33 C_LINE 489,"Graphics\L2graphics.c" 489 0C33 C_LINE 489,"Graphics\L2graphics.c" 489 0C33 ED 5B A7 17 ld de,(_l2_vx0) 489 0C37 2A 9D 17 ld hl,(_l2_stepx) 489 0C3A 19 add hl,de 489 0C3B 22 A7 17 ld (_l2_vx0),hl 489 0C3E ; l2_fraction -= l2_dy; 489 0C3E C_LINE 490,"Graphics\L2graphics.c" 490 0C3E C_LINE 490,"Graphics\L2graphics.c" 490 0C3E ED 5B A1 17 ld de,(_l2_fraction) 490 0C42 2A A3 17 ld hl,(_l2_dy) 490 0C45 EB ex de,hl 490 0C46 A7 and a 490 0C47 ED 52 sbc hl,de 490 0C49 22 A1 17 ld (_l2_fraction),hl 490 0C4C ; } 490 0C4C C_LINE 491,"Graphics\L2graphics.c" 491 0C4C ; l2_fraction += l2_dx; 491 0C4C C_LINE 492,"Graphics\L2graphics.c" 492 0C4C .i_87 492 0C4C C_LINE 492,"Graphics\L2graphics.c" 492 0C4C ED 5B A1 17 ld de,(_l2_fraction) 492 0C50 2A A5 17 ld hl,(_l2_dx) 492 0C53 19 add hl,de 492 0C54 22 A1 17 ld (_l2_fraction),hl 492 0C57 ; ++l2_vy0; 492 0C57 C_LINE 493,"Graphics\L2graphics.c" 493 0C57 C_LINE 493,"Graphics\L2graphics.c" 493 0C57 2A A9 17 ld hl,(_l2_vy0) 493 0C5A 23 inc hl 493 0C5B 22 A9 17 ld (_l2_vy0),hl 493 0C5E ; if (l2_vy0 > 127 ) break; 493 0C5E C_LINE 494,"Graphics\L2graphics.c" 494 0C5E C_LINE 494,"Graphics\L2graphics.c" 494 0C5E 2A A9 17 ld hl,(_l2_vy0) 494 0C61 11 7F 00 ld de,127 494 0C64 EB ex de,hl 494 0C65 CD 00 00 call l_gt 494 0C68 D2 6E 0C jp nc,i_88 494 0C6B C3 C3 0C jp i_86 494 0C6E ; if (l2_vx0 >0 && l2_vx0 <255 && l2_vy0 > 0 && l2_vy0 <= 127 ) 494 0C6E C_LINE 495,"Graphics\L2graphics.c" 495 0C6E .i_88 495 0C6E C_LINE 495,"Graphics\L2graphics.c" 495 0C6E 2A A7 17 ld hl,(_l2_vx0) 495 0C71 11 00 00 ld de,0 495 0C74 EB ex de,hl 495 0C75 CD 00 00 call l_gt 495 0C78 D2 A3 0C jp nc,i_90 495 0C7B 2A A7 17 ld hl,(_l2_vx0) 495 0C7E 7D ld a,l 495 0C7F D6 FF sub 255 495 0C81 7C ld a,h 495 0C82 17 rla 495 0C83 3F ccf 495 0C84 1F rra 495 0C85 DE 80 sbc 128 495 0C87 D2 A3 0C jp nc,i_90 495 0C8A 2A A9 17 ld hl,(_l2_vy0) 495 0C8D 11 00 00 ld de,0 495 0C90 EB ex de,hl 495 0C91 CD 00 00 call l_gt 495 0C94 D2 A3 0C jp nc,i_90 495 0C97 2A A9 17 ld hl,(_l2_vy0) 495 0C9A 11 7F 00 ld de,127 495 0C9D EB ex de,hl 495 0C9E CD 00 00 call l_le 495 0CA1 38 03 jr c,i_91_i_90 495 0CA3 .i_90 495 0CA3 C3 C0 0C jp i_89 495 0CA6 .i_91_i_90 495 0CA6 ; { 495 0CA6 C_LINE 496,"Graphics\L2graphics.c" 496 0CA6 C_LINE 496,"Graphics\L2graphics.c" 496 0CA6 ; l2_plot_pixel(l2_vx0,l2_vy0,color); 496 0CA6 C_LINE 497,"Graphics\L2graphics.c" 497 0CA6 C_LINE 497,"Graphics\L2graphics.c" 497 0CA6 ;l2_vx0; 497 0CA6 C_LINE 498,"Graphics\L2graphics.c" 498 0CA6 2A A7 17 ld hl,(_l2_vx0) 498 0CA9 26 00 ld h,0 498 0CAB E5 push hl 498 0CAC ;l2_vy0; 498 0CAC C_LINE 498,"Graphics\L2graphics.c" 498 0CAC 2A A9 17 ld hl,(_l2_vy0) 498 0CAF 26 00 ld h,0 498 0CB1 E5 push hl 498 0CB2 ;color; 498 0CB2 C_LINE 498,"Graphics\L2graphics.c" 498 0CB2 21 06 00 ld hl,6 ;const 498 0CB5 39 add hl,sp 498 0CB6 6E ld l,(hl) 498 0CB7 26 00 ld h,0 498 0CB9 E5 push hl 498 0CBA CD 32 01 call _l2_plot_pixel 498 0CBD C1 pop bc 498 0CBE C1 pop bc 498 0CBF C1 pop bc 498 0CC0 ; } 498 0CC0 C_LINE 498,"Graphics\L2graphics.c" 498 0CC0 ; } 498 0CC0 C_LINE 499,"Graphics\L2graphics.c" 499 0CC0 .i_89 499 0CC0 C3 1D 0C jp i_85 499 0CC3 .i_86 499 0CC3 ; } 499 0CC3 C_LINE 500,"Graphics\L2graphics.c" 500 0CC3 .i_84 500 0CC3 ;} 500 0CC3 C_LINE 502,"Graphics\L2graphics.c" 502 0CC3 C9 ret 502 0CC4 502 0CC4 502 0CC4 ; 502 0CC4 C_LINE 503,"Graphics\L2graphics.c" 503 0CC4 ;void l2_draw_line (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1 , uint8_t color) 503 0CC4 C_LINE 504,"Graphics\L2graphics.c" 504 0CC4 ;{ 504 0CC4 C_LINE 505,"Graphics\L2graphics.c" 505 0CC4 505 0CC4 ; Function l2_draw_line flags 0x00000200 __smallc 505 0CC4 ; void l2_draw_line(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color) 505 0CC4 ; parameter 'unsigned char color' at 2 size(1) 505 0CC4 ; parameter 'unsigned char y1' at 4 size(1) 505 0CC4 ; parameter 'unsigned char x1' at 6 size(1) 505 0CC4 ; parameter 'unsigned char y0' at 8 size(1) 505 0CC4 ; parameter 'unsigned char x0' at 10 size(1) 505 0CC4 ._l2_draw_line 505 0CC4 C_LINE 505,"Graphics\L2graphics.c" 505 0CC4 ; if (x0 == x1) 505 0CC4 C_LINE 506,"Graphics\L2graphics.c" 506 0CC4 C_LINE 506,"Graphics\L2graphics.c" 506 0CC4 21 0A 00 ld hl,10 ;const 506 0CC7 39 add hl,sp 506 0CC8 5E ld e,(hl) 506 0CC9 16 00 ld d,0 506 0CCB 21 06 00 ld hl,6 ;const 506 0CCE 39 add hl,sp 506 0CCF 6E ld l,(hl) 506 0CD0 26 00 ld h,0 506 0CD2 CD 00 00 call l_eq 506 0CD5 D2 02 0D jp nc,i_92 506 0CD8 ; { 506 0CD8 C_LINE 507,"Graphics\L2graphics.c" 507 0CD8 C_LINE 507,"Graphics\L2graphics.c" 507 0CD8 ; l2_draw_horz_line_to(x0, x1, y1, color); 507 0CD8 C_LINE 508,"Graphics\L2graphics.c" 508 0CD8 C_LINE 508,"Graphics\L2graphics.c" 508 0CD8 ;x0; 508 0CD8 C_LINE 509,"Graphics\L2graphics.c" 509 0CD8 21 0A 00 ld hl,10 ;const 509 0CDB 39 add hl,sp 509 0CDC 6E ld l,(hl) 509 0CDD 26 00 ld h,0 509 0CDF E5 push hl 509 0CE0 ;x1; 509 0CE0 C_LINE 509,"Graphics\L2graphics.c" 509 0CE0 21 08 00 ld hl,8 ;const 509 0CE3 39 add hl,sp 509 0CE4 6E ld l,(hl) 509 0CE5 26 00 ld h,0 509 0CE7 E5 push hl 509 0CE8 ;y1; 509 0CE8 C_LINE 509,"Graphics\L2graphics.c" 509 0CE8 21 08 00 ld hl,8 ;const 509 0CEB 39 add hl,sp 509 0CEC 6E ld l,(hl) 509 0CED 26 00 ld h,0 509 0CEF E5 push hl 509 0CF0 ;color; 509 0CF0 C_LINE 509,"Graphics\L2graphics.c" 509 0CF0 21 08 00 ld hl,8 ;const 509 0CF3 39 add hl,sp 509 0CF4 6E ld l,(hl) 509 0CF5 26 00 ld h,0 509 0CF7 E5 push hl 509 0CF8 CD 21 05 call _l2_draw_horz_line_to 509 0CFB C1 pop bc 509 0CFC C1 pop bc 509 0CFD C1 pop bc 509 0CFE C1 pop bc 509 0CFF ; } 509 0CFF C_LINE 509,"Graphics\L2graphics.c" 509 0CFF ; else 509 0CFF C_LINE 510,"Graphics\L2graphics.c" 510 0CFF C3 70 0D jp i_93 510 0D02 .i_92 510 0D02 ; { 510 0D02 C_LINE 511,"Graphics\L2graphics.c" 511 0D02 C_LINE 511,"Graphics\L2graphics.c" 511 0D02 ; if (y0 == y1) 511 0D02 C_LINE 512,"Graphics\L2graphics.c" 512 0D02 C_LINE 512,"Graphics\L2graphics.c" 512 0D02 21 08 00 ld hl,8 ;const 512 0D05 39 add hl,sp 512 0D06 5E ld e,(hl) 512 0D07 16 00 ld d,0 512 0D09 21 04 00 ld hl,4 ;const 512 0D0C 39 add hl,sp 512 0D0D 6E ld l,(hl) 512 0D0E 26 00 ld h,0 512 0D10 CD 00 00 call l_eq 512 0D13 D2 40 0D jp nc,i_94 512 0D16 ; { 512 0D16 C_LINE 513,"Graphics\L2graphics.c" 513 0D16 C_LINE 513,"Graphics\L2graphics.c" 513 0D16 ; l2_draw_vert_line_to(x0, y0, y1, color); 513 0D16 C_LINE 514,"Graphics\L2graphics.c" 514 0D16 C_LINE 514,"Graphics\L2graphics.c" 514 0D16 ;x0; 514 0D16 C_LINE 515,"Graphics\L2graphics.c" 515 0D16 21 0A 00 ld hl,10 ;const 515 0D19 39 add hl,sp 515 0D1A 6E ld l,(hl) 515 0D1B 26 00 ld h,0 515 0D1D E5 push hl 515 0D1E ;y0; 515 0D1E C_LINE 515,"Graphics\L2graphics.c" 515 0D1E 21 0A 00 ld hl,10 ;const 515 0D21 39 add hl,sp 515 0D22 6E ld l,(hl) 515 0D23 26 00 ld h,0 515 0D25 E5 push hl 515 0D26 ;y1; 515 0D26 C_LINE 515,"Graphics\L2graphics.c" 515 0D26 21 08 00 ld hl,8 ;const 515 0D29 39 add hl,sp 515 0D2A 6E ld l,(hl) 515 0D2B 26 00 ld h,0 515 0D2D E5 push hl 515 0D2E ;color; 515 0D2E C_LINE 515,"Graphics\L2graphics.c" 515 0D2E 21 08 00 ld hl,8 ;const 515 0D31 39 add hl,sp 515 0D32 6E ld l,(hl) 515 0D33 26 00 ld h,0 515 0D35 E5 push hl 515 0D36 CD F0 05 call _l2_draw_vert_line_to 515 0D39 C1 pop bc 515 0D3A C1 pop bc 515 0D3B C1 pop bc 515 0D3C C1 pop bc 515 0D3D ; } 515 0D3D C_LINE 515,"Graphics\L2graphics.c" 515 0D3D ; else 515 0D3D C_LINE 516,"Graphics\L2graphics.c" 516 0D3D C3 70 0D jp i_95 516 0D40 .i_94 516 0D40 ; { 516 0D40 C_LINE 517,"Graphics\L2graphics.c" 517 0D40 C_LINE 517,"Graphics\L2graphics.c" 517 0D40 ; l2_draw_diagonal(x0, y0, x1, y1, color); 517 0D40 C_LINE 518,"Graphics\L2graphics.c" 518 0D40 C_LINE 518,"Graphics\L2graphics.c" 518 0D40 ;x0; 518 0D40 C_LINE 519,"Graphics\L2graphics.c" 519 0D40 21 0A 00 ld hl,10 ;const 519 0D43 39 add hl,sp 519 0D44 6E ld l,(hl) 519 0D45 26 00 ld h,0 519 0D47 E5 push hl 519 0D48 ;y0; 519 0D48 C_LINE 519,"Graphics\L2graphics.c" 519 0D48 21 0A 00 ld hl,10 ;const 519 0D4B 39 add hl,sp 519 0D4C 6E ld l,(hl) 519 0D4D 26 00 ld h,0 519 0D4F E5 push hl 519 0D50 ;x1; 519 0D50 C_LINE 519,"Graphics\L2graphics.c" 519 0D50 21 0A 00 ld hl,10 ;const 519 0D53 39 add hl,sp 519 0D54 6E ld l,(hl) 519 0D55 26 00 ld h,0 519 0D57 E5 push hl 519 0D58 ;y1; 519 0D58 C_LINE 519,"Graphics\L2graphics.c" 519 0D58 21 0A 00 ld hl,10 ;const 519 0D5B 39 add hl,sp 519 0D5C 6E ld l,(hl) 519 0D5D 26 00 ld h,0 519 0D5F E5 push hl 519 0D60 ;color; 519 0D60 C_LINE 519,"Graphics\L2graphics.c" 519 0D60 21 0A 00 ld hl,10 ;const 519 0D63 39 add hl,sp 519 0D64 6E ld l,(hl) 519 0D65 26 00 ld h,0 519 0D67 E5 push hl 519 0D68 CD 4E 08 call _l2_draw_diagonal 519 0D6B C1 pop bc 519 0D6C C1 pop bc 519 0D6D C1 pop bc 519 0D6E C1 pop bc 519 0D6F C1 pop bc 519 0D70 ; } 519 0D70 C_LINE 519,"Graphics\L2graphics.c" 519 0D70 .i_95 519 0D70 ; } 519 0D70 C_LINE 520,"Graphics\L2graphics.c" 520 0D70 .i_93 520 0D70 ;} 520 0D70 C_LINE 521,"Graphics\L2graphics.c" 521 0D70 C9 ret 521 0D71 521 0D71 521 0D71 ; 521 0D71 C_LINE 523,"Graphics\L2graphics.c" 523 0D71 ;void l2_draw_line_clip (int x0, int y0, int x1, int y1 , int color) 523 0D71 C_LINE 524,"Graphics\L2graphics.c" 524 0D71 ;{ 524 0D71 C_LINE 525,"Graphics\L2graphics.c" 525 0D71 525 0D71 ; Function l2_draw_line_clip flags 0x00000200 __smallc 525 0D71 ; void l2_draw_line_clip(int x0, int y0, int x1, int y1, int color) 525 0D71 ; parameter 'int color' at 2 size(2) 525 0D71 ; parameter 'int y1' at 4 size(2) 525 0D71 ; parameter 'int x1' at 6 size(2) 525 0D71 ; parameter 'int y0' at 8 size(2) 525 0D71 ; parameter 'int x0' at 10 size(2) 525 0D71 ._l2_draw_line_clip 525 0D71 C_LINE 525,"Graphics\L2graphics.c" 525 0D71 ; if (x0 == x1) 525 0D71 C_LINE 526,"Graphics\L2graphics.c" 526 0D71 C_LINE 526,"Graphics\L2graphics.c" 526 0D71 21 0A 00 ld hl,10 ;const 526 0D74 CD 00 00 call l_gintspsp ; 526 0D77 21 08 00 ld hl,8 ;const 526 0D7A 39 add hl,sp 526 0D7B CD 00 00 call l_gint ; 526 0D7E D1 pop de 526 0D7F CD 00 00 call l_eq 526 0D82 D2 7E 0E jp nc,i_96 526 0D85 ; { 526 0D85 C_LINE 527,"Graphics\L2graphics.c" 527 0D85 C_LINE 527,"Graphics\L2graphics.c" 527 0D85 ; if (y0 == y1) 527 0D85 C_LINE 528,"Graphics\L2graphics.c" 528 0D85 C_LINE 528,"Graphics\L2graphics.c" 528 0D85 21 08 00 ld hl,8 ;const 528 0D88 CD 00 00 call l_gintspsp ; 528 0D8B 21 06 00 ld hl,6 ;const 528 0D8E 39 add hl,sp 528 0D8F CD 00 00 call l_gint ; 528 0D92 D1 pop de 528 0D93 CD 00 00 call l_eq 528 0D96 D2 FC 0D jp nc,i_97 528 0D99 ; { 528 0D99 C_LINE 529,"Graphics\L2graphics.c" 529 0D99 C_LINE 529,"Graphics\L2graphics.c" 529 0D99 ; if (x0 >= 0 && x0 <= 255 && y0 >= 0 && y0 <= 127 ) 529 0D99 C_LINE 530,"Graphics\L2graphics.c" 530 0D99 C_LINE 530,"Graphics\L2graphics.c" 530 0D99 21 0A 00 ld hl,10 ;const 530 0D9C 39 add hl,sp 530 0D9D CD 00 00 call l_gint ; 530 0DA0 7C ld a,h 530 0DA1 17 rla 530 0DA2 3F ccf 530 0DA3 D2 D2 0D jp nc,i_99 530 0DA6 21 0A 00 ld hl,10 ;const 530 0DA9 39 add hl,sp 530 0DAA 5E ld e,(hl) 530 0DAB 23 inc hl 530 0DAC 56 ld d,(hl) 530 0DAD 21 FF 00 ld hl,255 530 0DB0 CD 00 00 call l_le 530 0DB3 D2 D2 0D jp nc,i_99 530 0DB6 21 08 00 ld hl,8 ;const 530 0DB9 39 add hl,sp 530 0DBA CD 00 00 call l_gint ; 530 0DBD 7C ld a,h 530 0DBE 17 rla 530 0DBF 3F ccf 530 0DC0 D2 D2 0D jp nc,i_99 530 0DC3 21 08 00 ld hl,8 ;const 530 0DC6 39 add hl,sp 530 0DC7 5E ld e,(hl) 530 0DC8 23 inc hl 530 0DC9 56 ld d,(hl) 530 0DCA 21 7F 00 ld hl,127 530 0DCD CD 00 00 call l_le 530 0DD0 38 03 jr c,i_100_i_99 530 0DD2 .i_99 530 0DD2 C3 F9 0D jp i_98 530 0DD5 .i_100_i_99 530 0DD5 ; { 530 0DD5 C_LINE 531,"Graphics\L2graphics.c" 531 0DD5 C_LINE 531,"Graphics\L2graphics.c" 531 0DD5 ; 531 0DD5 C_LINE 532,"Graphics\L2graphics.c" 532 0DD5 ; l2_plot_pixel(x0, y0, color); 532 0DD5 C_LINE 535,"Graphics\L2graphics.c" 535 0DD5 C_LINE 535,"Graphics\L2graphics.c" 535 0DD5 ;x0; 535 0DD5 C_LINE 536,"Graphics\L2graphics.c" 536 0DD5 21 0A 00 ld hl,10 ;const 536 0DD8 39 add hl,sp 536 0DD9 CD 00 00 call l_gint ; 536 0DDC 26 00 ld h,0 536 0DDE E5 push hl 536 0DDF ;y0; 536 0DDF C_LINE 536,"Graphics\L2graphics.c" 536 0DDF 21 0A 00 ld hl,10 ;const 536 0DE2 39 add hl,sp 536 0DE3 CD 00 00 call l_gint ; 536 0DE6 26 00 ld h,0 536 0DE8 E5 push hl 536 0DE9 ;color; 536 0DE9 C_LINE 536,"Graphics\L2graphics.c" 536 0DE9 21 06 00 ld hl,6 ;const 536 0DEC 39 add hl,sp 536 0DED CD 00 00 call l_gint ; 536 0DF0 26 00 ld h,0 536 0DF2 E5 push hl 536 0DF3 CD 32 01 call _l2_plot_pixel 536 0DF6 C1 pop bc 536 0DF7 C1 pop bc 536 0DF8 C1 pop bc 536 0DF9 ; } 536 0DF9 C_LINE 536,"Graphics\L2graphics.c" 536 0DF9 ; } 536 0DF9 C_LINE 537,"Graphics\L2graphics.c" 537 0DF9 .i_98 537 0DF9 ; else 537 0DF9 C_LINE 538,"Graphics\L2graphics.c" 538 0DF9 C3 7B 0E jp i_101 538 0DFC .i_97 538 0DFC ; { 538 0DFC C_LINE 539,"Graphics\L2graphics.c" 539 0DFC C_LINE 539,"Graphics\L2graphics.c" 539 0DFC ; l2_clipy0 = y0<0?0:y0; if (l2_clipy0> 127 ) l2_clipy0 = 127 ; 539 0DFC C_LINE 540,"Graphics\L2graphics.c" 540 0DFC C_LINE 540,"Graphics\L2graphics.c" 540 0DFC 21 08 00 ld hl,8 ;const 540 0DFF 39 add hl,sp 540 0E00 CD 00 00 call l_gint ; 540 0E03 7C ld a,h 540 0E04 17 rla 540 0E05 D2 0E 0E jp nc,i_102 540 0E08 21 00 00 ld hl,0 ;const 540 0E0B C3 15 0E jp i_103 540 0E0E .i_102 540 0E0E 21 08 00 ld hl,8 ;const 540 0E11 39 add hl,sp 540 0E12 CD 00 00 call l_gint ; 540 0E15 .i_103 540 0E15 22 9A 19 ld (_l2_clipy0),hl 540 0E18 11 7F 00 ld de,127 540 0E1B EB ex de,hl 540 0E1C CD 00 00 call l_gt 540 0E1F D2 28 0E jp nc,i_104 540 0E22 21 7F 00 ld hl,127 ;const 540 0E25 22 9A 19 ld (_l2_clipy0),hl 540 0E28 ; l2_clipy1 = y1<0?0:y1; if (l2_clipy1> 127 ) l2_clipy1 = 127 ; 540 0E28 C_LINE 541,"Graphics\L2graphics.c" 541 0E28 .i_104 541 0E28 C_LINE 541,"Graphics\L2graphics.c" 541 0E28 21 04 00 ld hl,4 ;const 541 0E2B 39 add hl,sp 541 0E2C CD 00 00 call l_gint ; 541 0E2F 7C ld a,h 541 0E30 17 rla 541 0E31 D2 3A 0E jp nc,i_105 541 0E34 21 00 00 ld hl,0 ;const 541 0E37 C3 41 0E jp i_106 541 0E3A .i_105 541 0E3A 21 04 00 ld hl,4 ;const 541 0E3D 39 add hl,sp 541 0E3E CD 00 00 call l_gint ; 541 0E41 .i_106 541 0E41 22 9E 19 ld (_l2_clipy1),hl 541 0E44 11 7F 00 ld de,127 541 0E47 EB ex de,hl 541 0E48 CD 00 00 call l_gt 541 0E4B D2 54 0E jp nc,i_107 541 0E4E 21 7F 00 ld hl,127 ;const 541 0E51 22 9E 19 ld (_l2_clipy1),hl 541 0E54 ; 541 0E54 C_LINE 542,"Graphics\L2graphics.c" 542 0E54 ; l2_draw_vert_line_to(x0, l2_clipy0, l2_clipy1, color); 542 0E54 C_LINE 545,"Graphics\L2graphics.c" 545 0E54 .i_107 545 0E54 C_LINE 545,"Graphics\L2graphics.c" 545 0E54 ;x0; 545 0E54 C_LINE 546,"Graphics\L2graphics.c" 546 0E54 21 0A 00 ld hl,10 ;const 546 0E57 39 add hl,sp 546 0E58 CD 00 00 call l_gint ; 546 0E5B 26 00 ld h,0 546 0E5D E5 push hl 546 0E5E ;l2_clipy0; 546 0E5E C_LINE 546,"Graphics\L2graphics.c" 546 0E5E 2A 9A 19 ld hl,(_l2_clipy0) 546 0E61 26 00 ld h,0 546 0E63 E5 push hl 546 0E64 ;l2_clipy1; 546 0E64 C_LINE 546,"Graphics\L2graphics.c" 546 0E64 2A 9E 19 ld hl,(_l2_clipy1) 546 0E67 26 00 ld h,0 546 0E69 E5 push hl 546 0E6A ;color; 546 0E6A C_LINE 546,"Graphics\L2graphics.c" 546 0E6A 21 08 00 ld hl,8 ;const 546 0E6D 39 add hl,sp 546 0E6E CD 00 00 call l_gint ; 546 0E71 26 00 ld h,0 546 0E73 E5 push hl 546 0E74 CD F0 05 call _l2_draw_vert_line_to 546 0E77 C1 pop bc 546 0E78 C1 pop bc 546 0E79 C1 pop bc 546 0E7A C1 pop bc 546 0E7B ; } 546 0E7B C_LINE 546,"Graphics\L2graphics.c" 546 0E7B .i_101 546 0E7B ; } 546 0E7B C_LINE 547,"Graphics\L2graphics.c" 547 0E7B ; else 547 0E7B C_LINE 548,"Graphics\L2graphics.c" 548 0E7B C3 57 0F jp i_108 548 0E7E .i_96 548 0E7E ; { 548 0E7E C_LINE 549,"Graphics\L2graphics.c" 549 0E7E C_LINE 549,"Graphics\L2graphics.c" 549 0E7E ; if (y0 == y1) 549 0E7E C_LINE 550,"Graphics\L2graphics.c" 550 0E7E C_LINE 550,"Graphics\L2graphics.c" 550 0E7E 21 08 00 ld hl,8 ;const 550 0E81 CD 00 00 call l_gintspsp ; 550 0E84 21 06 00 ld hl,6 ;const 550 0E87 39 add hl,sp 550 0E88 CD 00 00 call l_gint ; 550 0E8B D1 pop de 550 0E8C CD 00 00 call l_eq 550 0E8F D2 25 0F jp nc,i_109 550 0E92 ; { 550 0E92 C_LINE 551,"Graphics\L2graphics.c" 551 0E92 C_LINE 551,"Graphics\L2graphics.c" 551 0E92 ; if (y0 > 127 ) return; 551 0E92 C_LINE 552,"Graphics\L2graphics.c" 552 0E92 C_LINE 552,"Graphics\L2graphics.c" 552 0E92 21 08 00 ld hl,8 ;const 552 0E95 39 add hl,sp 552 0E96 5E ld e,(hl) 552 0E97 23 inc hl 552 0E98 56 ld d,(hl) 552 0E99 21 7F 00 ld hl,127 552 0E9C CD 00 00 call l_gt 552 0E9F D2 A3 0E jp nc,i_110 552 0EA2 C9 ret 552 0EA3 552 0EA3 552 0EA3 ; l2_clipx0 = x0<0?0:x0; if (l2_clipx0>255) l2_clipx0 = 255; 552 0EA3 C_LINE 553,"Graphics\L2graphics.c" 553 0EA3 .i_110 553 0EA3 C_LINE 553,"Graphics\L2graphics.c" 553 0EA3 21 0A 00 ld hl,10 ;const 553 0EA6 39 add hl,sp 553 0EA7 CD 00 00 call l_gint ; 553 0EAA 7C ld a,h 553 0EAB 17 rla 553 0EAC D2 B5 0E jp nc,i_111 553 0EAF 21 00 00 ld hl,0 ;const 553 0EB2 C3 BC 0E jp i_112 553 0EB5 .i_111 553 0EB5 21 0A 00 ld hl,10 ;const 553 0EB8 39 add hl,sp 553 0EB9 CD 00 00 call l_gint ; 553 0EBC .i_112 553 0EBC 22 98 19 ld (_l2_clipx0),hl 553 0EBF 11 FF 00 ld de,255 553 0EC2 EB ex de,hl 553 0EC3 CD 00 00 call l_gt 553 0EC6 D2 CF 0E jp nc,i_113 553 0EC9 21 FF 00 ld hl,255 ;const 553 0ECC 22 98 19 ld (_l2_clipx0),hl 553 0ECF ; l2_clipx1 = x1<0?0:x1; if (l2_clipx1>255) l2_clipx1 = 255; 553 0ECF C_LINE 554,"Graphics\L2graphics.c" 554 0ECF .i_113 554 0ECF C_LINE 554,"Graphics\L2graphics.c" 554 0ECF 21 06 00 ld hl,6 ;const 554 0ED2 39 add hl,sp 554 0ED3 CD 00 00 call l_gint ; 554 0ED6 7C ld a,h 554 0ED7 17 rla 554 0ED8 D2 E1 0E jp nc,i_114 554 0EDB 21 00 00 ld hl,0 ;const 554 0EDE C3 E8 0E jp i_115 554 0EE1 .i_114 554 0EE1 21 06 00 ld hl,6 ;const 554 0EE4 39 add hl,sp 554 0EE5 CD 00 00 call l_gint ; 554 0EE8 .i_115 554 0EE8 22 9C 19 ld (_l2_clipx1),hl 554 0EEB 11 FF 00 ld de,255 554 0EEE EB ex de,hl 554 0EEF CD 00 00 call l_gt 554 0EF2 D2 FB 0E jp nc,i_116 554 0EF5 21 FF 00 ld hl,255 ;const 554 0EF8 22 9C 19 ld (_l2_clipx1),hl 554 0EFB ; 554 0EFB C_LINE 555,"Graphics\L2graphics.c" 555 0EFB ; l2_draw_horz_line_to(l2_clipx0, l2_clipx1, y0, color); 555 0EFB C_LINE 558,"Graphics\L2graphics.c" 558 0EFB .i_116 558 0EFB C_LINE 558,"Graphics\L2graphics.c" 558 0EFB ;l2_clipx0; 558 0EFB C_LINE 559,"Graphics\L2graphics.c" 559 0EFB 2A 98 19 ld hl,(_l2_clipx0) 559 0EFE 26 00 ld h,0 559 0F00 E5 push hl 559 0F01 ;l2_clipx1; 559 0F01 C_LINE 559,"Graphics\L2graphics.c" 559 0F01 2A 9C 19 ld hl,(_l2_clipx1) 559 0F04 26 00 ld h,0 559 0F06 E5 push hl 559 0F07 ;y0; 559 0F07 C_LINE 559,"Graphics\L2graphics.c" 559 0F07 21 0C 00 ld hl,12 ;const 559 0F0A 39 add hl,sp 559 0F0B CD 00 00 call l_gint ; 559 0F0E 26 00 ld h,0 559 0F10 E5 push hl 559 0F11 ;color; 559 0F11 C_LINE 559,"Graphics\L2graphics.c" 559 0F11 21 08 00 ld hl,8 ;const 559 0F14 39 add hl,sp 559 0F15 CD 00 00 call l_gint ; 559 0F18 26 00 ld h,0 559 0F1A E5 push hl 559 0F1B CD 21 05 call _l2_draw_horz_line_to 559 0F1E C1 pop bc 559 0F1F C1 pop bc 559 0F20 C1 pop bc 559 0F21 C1 pop bc 559 0F22 ; } 559 0F22 C_LINE 559,"Graphics\L2graphics.c" 559 0F22 ; else 559 0F22 C_LINE 560,"Graphics\L2graphics.c" 560 0F22 C3 57 0F jp i_117 560 0F25 .i_109 560 0F25 ; { 560 0F25 C_LINE 561,"Graphics\L2graphics.c" 561 0F25 C_LINE 561,"Graphics\L2graphics.c" 561 0F25 ; 561 0F25 C_LINE 562,"Graphics\L2graphics.c" 562 0F25 ; l2_draw_diagonal_clip(x0, y0, x1, y1, color); 562 0F25 C_LINE 565,"Graphics\L2graphics.c" 565 0F25 C_LINE 565,"Graphics\L2graphics.c" 565 0F25 ;x0; 565 0F25 C_LINE 566,"Graphics\L2graphics.c" 566 0F25 21 0A 00 ld hl,10 ;const 566 0F28 39 add hl,sp 566 0F29 CD 00 00 call l_gint ; 566 0F2C E5 push hl 566 0F2D ;y0; 566 0F2D C_LINE 566,"Graphics\L2graphics.c" 566 0F2D 21 0A 00 ld hl,10 ;const 566 0F30 39 add hl,sp 566 0F31 CD 00 00 call l_gint ; 566 0F34 E5 push hl 566 0F35 ;x1; 566 0F35 C_LINE 566,"Graphics\L2graphics.c" 566 0F35 21 0A 00 ld hl,10 ;const 566 0F38 39 add hl,sp 566 0F39 CD 00 00 call l_gint ; 566 0F3C E5 push hl 566 0F3D ;y1; 566 0F3D C_LINE 566,"Graphics\L2graphics.c" 566 0F3D 21 0A 00 ld hl,10 ;const 566 0F40 39 add hl,sp 566 0F41 CD 00 00 call l_gint ; 566 0F44 E5 push hl 566 0F45 ;color; 566 0F45 C_LINE 566,"Graphics\L2graphics.c" 566 0F45 21 0A 00 ld hl,10 ;const 566 0F48 39 add hl,sp 566 0F49 CD 00 00 call l_gint ; 566 0F4C 26 00 ld h,0 566 0F4E E5 push hl 566 0F4F CD 13 0A call _l2_draw_diagonal_clip 566 0F52 C1 pop bc 566 0F53 C1 pop bc 566 0F54 C1 pop bc 566 0F55 C1 pop bc 566 0F56 C1 pop bc 566 0F57 ; } 566 0F57 C_LINE 566,"Graphics\L2graphics.c" 566 0F57 .i_117 566 0F57 ; } 566 0F57 C_LINE 567,"Graphics\L2graphics.c" 567 0F57 .i_108 567 0F57 ;} 567 0F57 C_LINE 568,"Graphics\L2graphics.c" 568 0F57 C9 ret 568 0F58 568 0F58 568 0F58 ; 568 0F58 C_LINE 569,"Graphics\L2graphics.c" 569 0F58 ; 569 0F58 C_LINE 570,"Graphics\L2graphics.c" 570 0F58 ;void l2_store_diagonal (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *targetArray) 570 0F58 C_LINE 571,"Graphics\L2graphics.c" 571 0F58 ;{ 571 0F58 C_LINE 572,"Graphics\L2graphics.c" 572 0F58 572 0F58 ; Function l2_store_diagonal flags 0x00000200 __smallc 572 0F58 ; void l2_store_diagonal(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char uint8_t*targetArray) 572 0F58 ; parameter 'unsigned char uint8_t*targetArray' at 2 size(2) 572 0F58 ; parameter 'unsigned char y1' at 4 size(1) 572 0F58 ; parameter 'unsigned char x1' at 6 size(1) 572 0F58 ; parameter 'unsigned char y0' at 8 size(1) 572 0F58 ; parameter 'unsigned char x0' at 10 size(1) 572 0F58 ._l2_store_diagonal 572 0F58 C_LINE 572,"Graphics\L2graphics.c" 572 0F58 ; 572 0F58 C_LINE 573,"Graphics\L2graphics.c" 573 0F58 ; if (y0 > y1) 573 0F58 C_LINE 574,"Graphics\L2graphics.c" 574 0F58 C_LINE 574,"Graphics\L2graphics.c" 574 0F58 21 08 00 ld hl,8 ;const 574 0F5B 39 add hl,sp 574 0F5C 5E ld e,(hl) 574 0F5D 16 00 ld d,0 574 0F5F 21 04 00 ld hl,4 ;const 574 0F62 39 add hl,sp 574 0F63 6E ld l,(hl) 574 0F64 26 00 ld h,0 574 0F66 A7 and a 574 0F67 ED 52 sbc hl,de 574 0F69 D2 97 0F jp nc,i_118 574 0F6C ; { 574 0F6C C_LINE 575,"Graphics\L2graphics.c" 575 0F6C C_LINE 575,"Graphics\L2graphics.c" 575 0F6C ; l2_vx0 = x1; 575 0F6C C_LINE 576,"Graphics\L2graphics.c" 576 0F6C C_LINE 576,"Graphics\L2graphics.c" 576 0F6C 21 06 00 ld hl,6 ;const 576 0F6F 39 add hl,sp 576 0F70 6E ld l,(hl) 576 0F71 26 00 ld h,0 576 0F73 22 A7 17 ld (_l2_vx0),hl 576 0F76 ; l2_vy0 = y1; 576 0F76 C_LINE 577,"Graphics\L2graphics.c" 577 0F76 C_LINE 577,"Graphics\L2graphics.c" 577 0F76 21 04 00 ld hl,4 ;const 577 0F79 39 add hl,sp 577 0F7A 6E ld l,(hl) 577 0F7B 26 00 ld h,0 577 0F7D 22 A9 17 ld (_l2_vy0),hl 577 0F80 ; l2_vx1 = x0; 577 0F80 C_LINE 578,"Graphics\L2graphics.c" 578 0F80 C_LINE 578,"Graphics\L2graphics.c" 578 0F80 21 0A 00 ld hl,10 ;const 578 0F83 39 add hl,sp 578 0F84 6E ld l,(hl) 578 0F85 26 00 ld h,0 578 0F87 22 AB 17 ld (_l2_vx1),hl 578 0F8A ; l2_vy1 = y0; 578 0F8A C_LINE 579,"Graphics\L2graphics.c" 579 0F8A C_LINE 579,"Graphics\L2graphics.c" 579 0F8A 21 08 00 ld hl,8 ;const 579 0F8D 39 add hl,sp 579 0F8E 6E ld l,(hl) 579 0F8F 26 00 ld h,0 579 0F91 22 AD 17 ld (_l2_vy1),hl 579 0F94 ; } 579 0F94 C_LINE 580,"Graphics\L2graphics.c" 580 0F94 ; else 580 0F94 C_LINE 581,"Graphics\L2graphics.c" 581 0F94 C3 BF 0F jp i_119 581 0F97 .i_118 581 0F97 ; { 581 0F97 C_LINE 582,"Graphics\L2graphics.c" 582 0F97 C_LINE 582,"Graphics\L2graphics.c" 582 0F97 ; l2_vx0 = x0; 582 0F97 C_LINE 583,"Graphics\L2graphics.c" 583 0F97 C_LINE 583,"Graphics\L2graphics.c" 583 0F97 21 0A 00 ld hl,10 ;const 583 0F9A 39 add hl,sp 583 0F9B 6E ld l,(hl) 583 0F9C 26 00 ld h,0 583 0F9E 22 A7 17 ld (_l2_vx0),hl 583 0FA1 ; l2_vy0 = y0; 583 0FA1 C_LINE 584,"Graphics\L2graphics.c" 584 0FA1 C_LINE 584,"Graphics\L2graphics.c" 584 0FA1 21 08 00 ld hl,8 ;const 584 0FA4 39 add hl,sp 584 0FA5 6E ld l,(hl) 584 0FA6 26 00 ld h,0 584 0FA8 22 A9 17 ld (_l2_vy0),hl 584 0FAB ; l2_vx1 = x1; 584 0FAB C_LINE 585,"Graphics\L2graphics.c" 585 0FAB C_LINE 585,"Graphics\L2graphics.c" 585 0FAB 21 06 00 ld hl,6 ;const 585 0FAE 39 add hl,sp 585 0FAF 6E ld l,(hl) 585 0FB0 26 00 ld h,0 585 0FB2 22 AB 17 ld (_l2_vx1),hl 585 0FB5 ; l2_vy1 = y1; 585 0FB5 C_LINE 586,"Graphics\L2graphics.c" 586 0FB5 C_LINE 586,"Graphics\L2graphics.c" 586 0FB5 21 04 00 ld hl,4 ;const 586 0FB8 39 add hl,sp 586 0FB9 6E ld l,(hl) 586 0FBA 26 00 ld h,0 586 0FBC 22 AD 17 ld (_l2_vy1),hl 586 0FBF ; } 586 0FBF C_LINE 587,"Graphics\L2graphics.c" 587 0FBF .i_119 587 0FBF ; 587 0FBF C_LINE 588,"Graphics\L2graphics.c" 588 0FBF ; l2_dy = l2_vy1 - l2_vy0; 588 0FBF C_LINE 589,"Graphics\L2graphics.c" 589 0FBF C_LINE 589,"Graphics\L2graphics.c" 589 0FBF ED 5B AD 17 ld de,(_l2_vy1) 589 0FC3 2A A9 17 ld hl,(_l2_vy0) 589 0FC6 EB ex de,hl 589 0FC7 A7 and a 589 0FC8 ED 52 sbc hl,de 589 0FCA 22 A3 17 ld (_l2_dy),hl 589 0FCD ; l2_dx = l2_vx1 - l2_vx0; 589 0FCD C_LINE 590,"Graphics\L2graphics.c" 590 0FCD C_LINE 590,"Graphics\L2graphics.c" 590 0FCD ED 5B AB 17 ld de,(_l2_vx1) 590 0FD1 2A A7 17 ld hl,(_l2_vx0) 590 0FD4 EB ex de,hl 590 0FD5 A7 and a 590 0FD6 ED 52 sbc hl,de 590 0FD8 22 A5 17 ld (_l2_dx),hl 590 0FDB ; if (l2_dx < 0) 590 0FDB C_LINE 592,"Graphics\L2graphics.c" 592 0FDB C_LINE 592,"Graphics\L2graphics.c" 592 0FDB 2A A5 17 ld hl,(_l2_dx) 592 0FDE 7C ld a,h 592 0FDF 17 rla 592 0FE0 D2 F5 0F jp nc,i_120 592 0FE3 ; { 592 0FE3 C_LINE 593,"Graphics\L2graphics.c" 593 0FE3 C_LINE 593,"Graphics\L2graphics.c" 593 0FE3 ; l2_dx = -l2_dx; 593 0FE3 C_LINE 594,"Graphics\L2graphics.c" 594 0FE3 C_LINE 594,"Graphics\L2graphics.c" 594 0FE3 2A A5 17 ld hl,(_l2_dx) 594 0FE6 CD 00 00 call l_neg 594 0FE9 22 A5 17 ld (_l2_dx),hl 594 0FEC ; l2_stepx = -1; 594 0FEC C_LINE 595,"Graphics\L2graphics.c" 595 0FEC C_LINE 595,"Graphics\L2graphics.c" 595 0FEC 21 FF FF ld hl,65535 ;const 595 0FEF 22 9D 17 ld (_l2_stepx),hl 595 0FF2 ; } 595 0FF2 C_LINE 596,"Graphics\L2graphics.c" 596 0FF2 ; else 596 0FF2 C_LINE 597,"Graphics\L2graphics.c" 597 0FF2 C3 FB 0F jp i_121 597 0FF5 .i_120 597 0FF5 ; { 597 0FF5 C_LINE 598,"Graphics\L2graphics.c" 598 0FF5 C_LINE 598,"Graphics\L2graphics.c" 598 0FF5 ; l2_stepx = 1; 598 0FF5 C_LINE 599,"Graphics\L2graphics.c" 599 0FF5 C_LINE 599,"Graphics\L2graphics.c" 599 0FF5 21 01 00 ld hl,1 ;const 599 0FF8 22 9D 17 ld (_l2_stepx),hl 599 0FFB ; } 599 0FFB C_LINE 600,"Graphics\L2graphics.c" 600 0FFB .i_121 600 0FFB ; l2_dy <<= 1; 600 0FFB C_LINE 602,"Graphics\L2graphics.c" 602 0FFB C_LINE 602,"Graphics\L2graphics.c" 602 0FFB 2A A3 17 ld hl,(_l2_dy) 602 0FFE 29 add hl,hl 602 0FFF 22 A3 17 ld (_l2_dy),hl 602 1002 ; l2_dx <<= 1; 602 1002 C_LINE 603,"Graphics\L2graphics.c" 603 1002 C_LINE 603,"Graphics\L2graphics.c" 603 1002 2A A5 17 ld hl,(_l2_dx) 603 1005 29 add hl,hl 603 1006 22 A5 17 ld (_l2_dx),hl 603 1009 ; 603 1009 C_LINE 604,"Graphics\L2graphics.c" 604 1009 ; targetArray[y0] = l2_vx0; 604 1009 C_LINE 605,"Graphics\L2graphics.c" 605 1009 C_LINE 605,"Graphics\L2graphics.c" 605 1009 21 02 00 ld hl,2 ;const 605 100C 39 add hl,sp 605 100D 5E ld e,(hl) 605 100E 23 inc hl 605 100F 56 ld d,(hl) 605 1010 21 08 00 ld hl,8 ;const 605 1013 39 add hl,sp 605 1014 6E ld l,(hl) 605 1015 26 00 ld h,0 605 1017 19 add hl,de 605 1018 EB ex de,hl 605 1019 2A A7 17 ld hl,(_l2_vx0) 605 101C 7D ld a,l 605 101D 12 ld (de),a 605 101E ; if (l2_dx > l2_dy) 605 101E C_LINE 607,"Graphics\L2graphics.c" 607 101E C_LINE 607,"Graphics\L2graphics.c" 607 101E ED 5B A5 17 ld de,(_l2_dx) 607 1022 2A A3 17 ld hl,(_l2_dy) 607 1025 CD 00 00 call l_gt 607 1028 D2 94 10 jp nc,i_122 607 102B ; { 607 102B C_LINE 608,"Graphics\L2graphics.c" 608 102B C_LINE 608,"Graphics\L2graphics.c" 608 102B ; l2_fraction = l2_dy - (l2_dx >> 1); 608 102B C_LINE 609,"Graphics\L2graphics.c" 609 102B C_LINE 609,"Graphics\L2graphics.c" 609 102B 2A A3 17 ld hl,(_l2_dy) 609 102E E5 push hl 609 102F 2A A5 17 ld hl,(_l2_dx) 609 1032 CB 2C sra h 609 1034 CB 1D rr l 609 1036 D1 pop de 609 1037 EB ex de,hl 609 1038 A7 and a 609 1039 ED 52 sbc hl,de 609 103B 22 A1 17 ld (_l2_fraction),hl 609 103E ; while (l2_vx0 != l2_vx1) 609 103E C_LINE 610,"Graphics\L2graphics.c" 610 103E C_LINE 610,"Graphics\L2graphics.c" 610 103E .i_123 610 103E ED 5B A7 17 ld de,(_l2_vx0) 610 1042 2A AB 17 ld hl,(_l2_vx1) 610 1045 CD 00 00 call l_ne 610 1048 D2 91 10 jp nc,i_124 610 104B ; { 610 104B C_LINE 611,"Graphics\L2graphics.c" 611 104B C_LINE 611,"Graphics\L2graphics.c" 611 104B ; if (l2_fraction >= 0) 611 104B C_LINE 612,"Graphics\L2graphics.c" 612 104B C_LINE 612,"Graphics\L2graphics.c" 612 104B 2A A1 17 ld hl,(_l2_fraction) 612 104E 7C ld a,h 612 104F 17 rla 612 1050 3F ccf 612 1051 D2 69 10 jp nc,i_125 612 1054 ; { 612 1054 C_LINE 613,"Graphics\L2graphics.c" 613 1054 C_LINE 613,"Graphics\L2graphics.c" 613 1054 ; ++l2_vy0; 613 1054 C_LINE 614,"Graphics\L2graphics.c" 614 1054 C_LINE 614,"Graphics\L2graphics.c" 614 1054 2A A9 17 ld hl,(_l2_vy0) 614 1057 23 inc hl 614 1058 22 A9 17 ld (_l2_vy0),hl 614 105B ; l2_fraction -= l2_dx; 614 105B C_LINE 615,"Graphics\L2graphics.c" 615 105B C_LINE 615,"Graphics\L2graphics.c" 615 105B ED 5B A1 17 ld de,(_l2_fraction) 615 105F 2A A5 17 ld hl,(_l2_dx) 615 1062 EB ex de,hl 615 1063 A7 and a 615 1064 ED 52 sbc hl,de 615 1066 22 A1 17 ld (_l2_fraction),hl 615 1069 ; } 615 1069 C_LINE 616,"Graphics\L2graphics.c" 616 1069 ; l2_vx0 += l2_stepx; 616 1069 C_LINE 617,"Graphics\L2graphics.c" 617 1069 .i_125 617 1069 C_LINE 617,"Graphics\L2graphics.c" 617 1069 ED 5B A7 17 ld de,(_l2_vx0) 617 106D 2A 9D 17 ld hl,(_l2_stepx) 617 1070 19 add hl,de 617 1071 22 A7 17 ld (_l2_vx0),hl 617 1074 ; l2_fraction += l2_dy; 617 1074 C_LINE 618,"Graphics\L2graphics.c" 618 1074 C_LINE 618,"Graphics\L2graphics.c" 618 1074 ED 5B A1 17 ld de,(_l2_fraction) 618 1078 2A A3 17 ld hl,(_l2_dy) 618 107B 19 add hl,de 618 107C 22 A1 17 ld (_l2_fraction),hl 618 107F ; targetArray[l2_vy0] = l2_vx0; 618 107F C_LINE 619,"Graphics\L2graphics.c" 619 107F C_LINE 619,"Graphics\L2graphics.c" 619 107F C1 pop bc 619 1080 E1 pop hl 619 1081 E5 push hl 619 1082 C5 push bc 619 1083 EB ex de,hl 619 1084 2A A9 17 ld hl,(_l2_vy0) 619 1087 19 add hl,de 619 1088 EB ex de,hl 619 1089 2A A7 17 ld hl,(_l2_vx0) 619 108C 7D ld a,l 619 108D 12 ld (de),a 619 108E ; } 619 108E C_LINE 620,"Graphics\L2graphics.c" 620 108E C3 3E 10 jp i_123 620 1091 .i_124 620 1091 ; } 620 1091 C_LINE 621,"Graphics\L2graphics.c" 621 1091 ; else 621 1091 C_LINE 622,"Graphics\L2graphics.c" 622 1091 C3 FA 10 jp i_126 622 1094 .i_122 622 1094 ; { 622 1094 C_LINE 623,"Graphics\L2graphics.c" 623 1094 C_LINE 623,"Graphics\L2graphics.c" 623 1094 ; l2_fraction = l2_dx - (l2_dy >> 1); 623 1094 C_LINE 624,"Graphics\L2graphics.c" 624 1094 C_LINE 624,"Graphics\L2graphics.c" 624 1094 2A A5 17 ld hl,(_l2_dx) 624 1097 E5 push hl 624 1098 2A A3 17 ld hl,(_l2_dy) 624 109B CB 2C sra h 624 109D CB 1D rr l 624 109F D1 pop de 624 10A0 EB ex de,hl 624 10A1 A7 and a 624 10A2 ED 52 sbc hl,de 624 10A4 22 A1 17 ld (_l2_fraction),hl 624 10A7 ; while (l2_vy0 != l2_vy1) 624 10A7 C_LINE 625,"Graphics\L2graphics.c" 625 10A7 C_LINE 625,"Graphics\L2graphics.c" 625 10A7 .i_127 625 10A7 ED 5B A9 17 ld de,(_l2_vy0) 625 10AB 2A AD 17 ld hl,(_l2_vy1) 625 10AE CD 00 00 call l_ne 625 10B1 D2 FA 10 jp nc,i_128 625 10B4 ; { 625 10B4 C_LINE 626,"Graphics\L2graphics.c" 626 10B4 C_LINE 626,"Graphics\L2graphics.c" 626 10B4 ; if (l2_fraction >= 0) 626 10B4 C_LINE 627,"Graphics\L2graphics.c" 627 10B4 C_LINE 627,"Graphics\L2graphics.c" 627 10B4 2A A1 17 ld hl,(_l2_fraction) 627 10B7 7C ld a,h 627 10B8 17 rla 627 10B9 3F ccf 627 10BA D2 D6 10 jp nc,i_129 627 10BD ; { 627 10BD C_LINE 628,"Graphics\L2graphics.c" 628 10BD C_LINE 628,"Graphics\L2graphics.c" 628 10BD ; l2_vx0 += l2_stepx; 628 10BD C_LINE 629,"Graphics\L2graphics.c" 629 10BD C_LINE 629,"Graphics\L2graphics.c" 629 10BD ED 5B A7 17 ld de,(_l2_vx0) 629 10C1 2A 9D 17 ld hl,(_l2_stepx) 629 10C4 19 add hl,de 629 10C5 22 A7 17 ld (_l2_vx0),hl 629 10C8 ; l2_fraction -= l2_dy; 629 10C8 C_LINE 630,"Graphics\L2graphics.c" 630 10C8 C_LINE 630,"Graphics\L2graphics.c" 630 10C8 ED 5B A1 17 ld de,(_l2_fraction) 630 10CC 2A A3 17 ld hl,(_l2_dy) 630 10CF EB ex de,hl 630 10D0 A7 and a 630 10D1 ED 52 sbc hl,de 630 10D3 22 A1 17 ld (_l2_fraction),hl 630 10D6 ; } 630 10D6 C_LINE 631,"Graphics\L2graphics.c" 631 10D6 ; l2_fraction += l2_dx; 631 10D6 C_LINE 632,"Graphics\L2graphics.c" 632 10D6 .i_129 632 10D6 C_LINE 632,"Graphics\L2graphics.c" 632 10D6 ED 5B A1 17 ld de,(_l2_fraction) 632 10DA 2A A5 17 ld hl,(_l2_dx) 632 10DD 19 add hl,de 632 10DE 22 A1 17 ld (_l2_fraction),hl 632 10E1 ; ++l2_vy0; 632 10E1 C_LINE 633,"Graphics\L2graphics.c" 633 10E1 C_LINE 633,"Graphics\L2graphics.c" 633 10E1 2A A9 17 ld hl,(_l2_vy0) 633 10E4 23 inc hl 633 10E5 22 A9 17 ld (_l2_vy0),hl 633 10E8 ; targetArray[l2_vy0] = l2_vx0; 633 10E8 C_LINE 634,"Graphics\L2graphics.c" 634 10E8 C_LINE 634,"Graphics\L2graphics.c" 634 10E8 C1 pop bc 634 10E9 E1 pop hl 634 10EA E5 push hl 634 10EB C5 push bc 634 10EC EB ex de,hl 634 10ED 2A A9 17 ld hl,(_l2_vy0) 634 10F0 19 add hl,de 634 10F1 EB ex de,hl 634 10F2 2A A7 17 ld hl,(_l2_vx0) 634 10F5 7D ld a,l 634 10F6 12 ld (de),a 634 10F7 ; } 634 10F7 C_LINE 635,"Graphics\L2graphics.c" 635 10F7 C3 A7 10 jp i_127 635 10FA .i_128 635 10FA ; } 635 10FA C_LINE 636,"Graphics\L2graphics.c" 636 10FA .i_126 636 10FA ;} 636 10FA C_LINE 637,"Graphics\L2graphics.c" 637 10FA C9 ret 637 10FB 637 10FB 637 10FB ; 637 10FB C_LINE 639,"Graphics\L2graphics.c" 639 10FB ; 639 10FB C_LINE 658,"Graphics\L2graphics.c" 658 10FB ;void l2_draw_circle_px(int xc, int yc, int x, int y, uint8_t color) 658 10FB C_LINE 659,"Graphics\L2graphics.c" 659 10FB ;{ 659 10FB C_LINE 660,"Graphics\L2graphics.c" 660 10FB 660 10FB ; Function l2_draw_circle_px flags 0x00000200 __smallc 660 10FB ; void l2_draw_circle_px(int xc, int yc, int x, int y, unsigned char color) 660 10FB ; parameter 'unsigned char color' at 2 size(1) 660 10FB ; parameter 'int y' at 4 size(2) 660 10FB ; parameter 'int x' at 6 size(2) 660 10FB ; parameter 'int yc' at 8 size(2) 660 10FB ; parameter 'int xc' at 10 size(2) 660 10FB ._l2_draw_circle_px 660 10FB C_LINE 660,"Graphics\L2graphics.c" 660 10FB ; l2_plot_pixel(xc+x, yc+y, color); 660 10FB C_LINE 661,"Graphics\L2graphics.c" 661 10FB C_LINE 661,"Graphics\L2graphics.c" 661 10FB ;xc+x; 661 10FB C_LINE 662,"Graphics\L2graphics.c" 662 10FB 21 0A 00 ld hl,10 ;const 662 10FE CD 00 00 call l_gintspsp ; 662 1101 21 08 00 ld hl,8 ;const 662 1104 39 add hl,sp 662 1105 CD 00 00 call l_gint ; 662 1108 D1 pop de 662 1109 19 add hl,de 662 110A 26 00 ld h,0 662 110C E5 push hl 662 110D ;yc+y; 662 110D C_LINE 662,"Graphics\L2graphics.c" 662 110D 21 0A 00 ld hl,10 ;const 662 1110 CD 00 00 call l_gintspsp ; 662 1113 21 08 00 ld hl,8 ;const 662 1116 39 add hl,sp 662 1117 CD 00 00 call l_gint ; 662 111A D1 pop de 662 111B 19 add hl,de 662 111C 26 00 ld h,0 662 111E E5 push hl 662 111F ;color; 662 111F C_LINE 662,"Graphics\L2graphics.c" 662 111F 21 06 00 ld hl,6 ;const 662 1122 39 add hl,sp 662 1123 6E ld l,(hl) 662 1124 26 00 ld h,0 662 1126 E5 push hl 662 1127 CD 32 01 call _l2_plot_pixel 662 112A C1 pop bc 662 112B C1 pop bc 662 112C C1 pop bc 662 112D ; l2_plot_pixel(xc-x, yc+y, color); 662 112D C_LINE 662,"Graphics\L2graphics.c" 662 112D C_LINE 662,"Graphics\L2graphics.c" 662 112D ;xc-x; 662 112D C_LINE 663,"Graphics\L2graphics.c" 663 112D 21 0A 00 ld hl,10 ;const 663 1130 CD 00 00 call l_gintspsp ; 663 1133 21 08 00 ld hl,8 ;const 663 1136 39 add hl,sp 663 1137 CD 00 00 call l_gint ; 663 113A D1 pop de 663 113B EB ex de,hl 663 113C A7 and a 663 113D ED 52 sbc hl,de 663 113F 26 00 ld h,0 663 1141 E5 push hl 663 1142 ;yc+y; 663 1142 C_LINE 663,"Graphics\L2graphics.c" 663 1142 21 0A 00 ld hl,10 ;const 663 1145 CD 00 00 call l_gintspsp ; 663 1148 21 08 00 ld hl,8 ;const 663 114B 39 add hl,sp 663 114C CD 00 00 call l_gint ; 663 114F D1 pop de 663 1150 19 add hl,de 663 1151 26 00 ld h,0 663 1153 E5 push hl 663 1154 ;color; 663 1154 C_LINE 663,"Graphics\L2graphics.c" 663 1154 21 06 00 ld hl,6 ;const 663 1157 39 add hl,sp 663 1158 6E ld l,(hl) 663 1159 26 00 ld h,0 663 115B E5 push hl 663 115C CD 32 01 call _l2_plot_pixel 663 115F C1 pop bc 663 1160 C1 pop bc 663 1161 C1 pop bc 663 1162 ; l2_plot_pixel(xc+x, yc-y, color); 663 1162 C_LINE 663,"Graphics\L2graphics.c" 663 1162 C_LINE 663,"Graphics\L2graphics.c" 663 1162 ;xc+x; 663 1162 C_LINE 664,"Graphics\L2graphics.c" 664 1162 21 0A 00 ld hl,10 ;const 664 1165 CD 00 00 call l_gintspsp ; 664 1168 21 08 00 ld hl,8 ;const 664 116B 39 add hl,sp 664 116C CD 00 00 call l_gint ; 664 116F D1 pop de 664 1170 19 add hl,de 664 1171 26 00 ld h,0 664 1173 E5 push hl 664 1174 ;yc-y; 664 1174 C_LINE 664,"Graphics\L2graphics.c" 664 1174 21 0A 00 ld hl,10 ;const 664 1177 CD 00 00 call l_gintspsp ; 664 117A 21 08 00 ld hl,8 ;const 664 117D 39 add hl,sp 664 117E CD 00 00 call l_gint ; 664 1181 D1 pop de 664 1182 EB ex de,hl 664 1183 A7 and a 664 1184 ED 52 sbc hl,de 664 1186 26 00 ld h,0 664 1188 E5 push hl 664 1189 ;color; 664 1189 C_LINE 664,"Graphics\L2graphics.c" 664 1189 21 06 00 ld hl,6 ;const 664 118C 39 add hl,sp 664 118D 6E ld l,(hl) 664 118E 26 00 ld h,0 664 1190 E5 push hl 664 1191 CD 32 01 call _l2_plot_pixel 664 1194 C1 pop bc 664 1195 C1 pop bc 664 1196 C1 pop bc 664 1197 ; l2_plot_pixel(xc-x, yc-y, color); 664 1197 C_LINE 664,"Graphics\L2graphics.c" 664 1197 C_LINE 664,"Graphics\L2graphics.c" 664 1197 ;xc-x; 664 1197 C_LINE 665,"Graphics\L2graphics.c" 665 1197 21 0A 00 ld hl,10 ;const 665 119A CD 00 00 call l_gintspsp ; 665 119D 21 08 00 ld hl,8 ;const 665 11A0 39 add hl,sp 665 11A1 CD 00 00 call l_gint ; 665 11A4 D1 pop de 665 11A5 EB ex de,hl 665 11A6 A7 and a 665 11A7 ED 52 sbc hl,de 665 11A9 26 00 ld h,0 665 11AB E5 push hl 665 11AC ;yc-y; 665 11AC C_LINE 665,"Graphics\L2graphics.c" 665 11AC 21 0A 00 ld hl,10 ;const 665 11AF CD 00 00 call l_gintspsp ; 665 11B2 21 08 00 ld hl,8 ;const 665 11B5 39 add hl,sp 665 11B6 CD 00 00 call l_gint ; 665 11B9 D1 pop de 665 11BA EB ex de,hl 665 11BB A7 and a 665 11BC ED 52 sbc hl,de 665 11BE 26 00 ld h,0 665 11C0 E5 push hl 665 11C1 ;color; 665 11C1 C_LINE 665,"Graphics\L2graphics.c" 665 11C1 21 06 00 ld hl,6 ;const 665 11C4 39 add hl,sp 665 11C5 6E ld l,(hl) 665 11C6 26 00 ld h,0 665 11C8 E5 push hl 665 11C9 CD 32 01 call _l2_plot_pixel 665 11CC C1 pop bc 665 11CD C1 pop bc 665 11CE C1 pop bc 665 11CF ; l2_plot_pixel(xc+y, yc+x, color); 665 11CF C_LINE 665,"Graphics\L2graphics.c" 665 11CF C_LINE 665,"Graphics\L2graphics.c" 665 11CF ;xc+y; 665 11CF C_LINE 666,"Graphics\L2graphics.c" 666 11CF 21 0A 00 ld hl,10 ;const 666 11D2 CD 00 00 call l_gintspsp ; 666 11D5 21 06 00 ld hl,6 ;const 666 11D8 39 add hl,sp 666 11D9 CD 00 00 call l_gint ; 666 11DC D1 pop de 666 11DD 19 add hl,de 666 11DE 26 00 ld h,0 666 11E0 E5 push hl 666 11E1 ;yc+x; 666 11E1 C_LINE 666,"Graphics\L2graphics.c" 666 11E1 21 0A 00 ld hl,10 ;const 666 11E4 CD 00 00 call l_gintspsp ; 666 11E7 21 0A 00 ld hl,10 ;const 666 11EA 39 add hl,sp 666 11EB CD 00 00 call l_gint ; 666 11EE D1 pop de 666 11EF 19 add hl,de 666 11F0 26 00 ld h,0 666 11F2 E5 push hl 666 11F3 ;color; 666 11F3 C_LINE 666,"Graphics\L2graphics.c" 666 11F3 21 06 00 ld hl,6 ;const 666 11F6 39 add hl,sp 666 11F7 6E ld l,(hl) 666 11F8 26 00 ld h,0 666 11FA E5 push hl 666 11FB CD 32 01 call _l2_plot_pixel 666 11FE C1 pop bc 666 11FF C1 pop bc 666 1200 C1 pop bc 666 1201 ; l2_plot_pixel(xc-y, yc+x, color); 666 1201 C_LINE 666,"Graphics\L2graphics.c" 666 1201 C_LINE 666,"Graphics\L2graphics.c" 666 1201 ;xc-y; 666 1201 C_LINE 667,"Graphics\L2graphics.c" 667 1201 21 0A 00 ld hl,10 ;const 667 1204 CD 00 00 call l_gintspsp ; 667 1207 21 06 00 ld hl,6 ;const 667 120A 39 add hl,sp 667 120B CD 00 00 call l_gint ; 667 120E D1 pop de 667 120F EB ex de,hl 667 1210 A7 and a 667 1211 ED 52 sbc hl,de 667 1213 26 00 ld h,0 667 1215 E5 push hl 667 1216 ;yc+x; 667 1216 C_LINE 667,"Graphics\L2graphics.c" 667 1216 21 0A 00 ld hl,10 ;const 667 1219 CD 00 00 call l_gintspsp ; 667 121C 21 0A 00 ld hl,10 ;const 667 121F 39 add hl,sp 667 1220 CD 00 00 call l_gint ; 667 1223 D1 pop de 667 1224 19 add hl,de 667 1225 26 00 ld h,0 667 1227 E5 push hl 667 1228 ;color; 667 1228 C_LINE 667,"Graphics\L2graphics.c" 667 1228 21 06 00 ld hl,6 ;const 667 122B 39 add hl,sp 667 122C 6E ld l,(hl) 667 122D 26 00 ld h,0 667 122F E5 push hl 667 1230 CD 32 01 call _l2_plot_pixel 667 1233 C1 pop bc 667 1234 C1 pop bc 667 1235 C1 pop bc 667 1236 ; l2_plot_pixel(xc+y, yc-x, color); 667 1236 C_LINE 667,"Graphics\L2graphics.c" 667 1236 C_LINE 667,"Graphics\L2graphics.c" 667 1236 ;xc+y; 667 1236 C_LINE 668,"Graphics\L2graphics.c" 668 1236 21 0A 00 ld hl,10 ;const 668 1239 CD 00 00 call l_gintspsp ; 668 123C 21 06 00 ld hl,6 ;const 668 123F 39 add hl,sp 668 1240 CD 00 00 call l_gint ; 668 1243 D1 pop de 668 1244 19 add hl,de 668 1245 26 00 ld h,0 668 1247 E5 push hl 668 1248 ;yc-x; 668 1248 C_LINE 668,"Graphics\L2graphics.c" 668 1248 21 0A 00 ld hl,10 ;const 668 124B CD 00 00 call l_gintspsp ; 668 124E 21 0A 00 ld hl,10 ;const 668 1251 39 add hl,sp 668 1252 CD 00 00 call l_gint ; 668 1255 D1 pop de 668 1256 EB ex de,hl 668 1257 A7 and a 668 1258 ED 52 sbc hl,de 668 125A 26 00 ld h,0 668 125C E5 push hl 668 125D ;color; 668 125D C_LINE 668,"Graphics\L2graphics.c" 668 125D 21 06 00 ld hl,6 ;const 668 1260 39 add hl,sp 668 1261 6E ld l,(hl) 668 1262 26 00 ld h,0 668 1264 E5 push hl 668 1265 CD 32 01 call _l2_plot_pixel 668 1268 C1 pop bc 668 1269 C1 pop bc 668 126A C1 pop bc 668 126B ; l2_plot_pixel(xc-y, yc-x, color); 668 126B C_LINE 668,"Graphics\L2graphics.c" 668 126B C_LINE 668,"Graphics\L2graphics.c" 668 126B ;xc-y; 668 126B C_LINE 669,"Graphics\L2graphics.c" 669 126B 21 0A 00 ld hl,10 ;const 669 126E CD 00 00 call l_gintspsp ; 669 1271 21 06 00 ld hl,6 ;const 669 1274 39 add hl,sp 669 1275 CD 00 00 call l_gint ; 669 1278 D1 pop de 669 1279 EB ex de,hl 669 127A A7 and a 669 127B ED 52 sbc hl,de 669 127D 26 00 ld h,0 669 127F E5 push hl 669 1280 ;yc-x; 669 1280 C_LINE 669,"Graphics\L2graphics.c" 669 1280 21 0A 00 ld hl,10 ;const 669 1283 CD 00 00 call l_gintspsp ; 669 1286 21 0A 00 ld hl,10 ;const 669 1289 39 add hl,sp 669 128A CD 00 00 call l_gint ; 669 128D D1 pop de 669 128E EB ex de,hl 669 128F A7 and a 669 1290 ED 52 sbc hl,de 669 1292 26 00 ld h,0 669 1294 E5 push hl 669 1295 ;color; 669 1295 C_LINE 669,"Graphics\L2graphics.c" 669 1295 21 06 00 ld hl,6 ;const 669 1298 39 add hl,sp 669 1299 6E ld l,(hl) 669 129A 26 00 ld h,0 669 129C E5 push hl 669 129D CD 32 01 call _l2_plot_pixel 669 12A0 C1 pop bc 669 12A1 C1 pop bc 669 12A2 C1 pop bc 669 12A3 ;} 669 12A3 C_LINE 669,"Graphics\L2graphics.c" 669 12A3 C9 ret 669 12A4 669 12A4 669 12A4 ; 669 12A4 C_LINE 670,"Graphics\L2graphics.c" 670 12A4 ; 670 12A4 C_LINE 671,"Graphics\L2graphics.c" 671 12A4 ;void l2_draw_circle(int xc, int yc, int r,uint8_t color) 671 12A4 C_LINE 672,"Graphics\L2graphics.c" 672 12A4 ;{ 672 12A4 C_LINE 673,"Graphics\L2graphics.c" 673 12A4 673 12A4 ; Function l2_draw_circle flags 0x00000200 __smallc 673 12A4 ; void l2_draw_circle(int xc, int yc, int r, unsigned char color) 673 12A4 ; parameter 'unsigned char color' at 2 size(1) 673 12A4 ; parameter 'int r' at 4 size(2) 673 12A4 ; parameter 'int yc' at 6 size(2) 673 12A4 ; parameter 'int xc' at 8 size(2) 673 12A4 ._l2_draw_circle 673 12A4 C_LINE 673,"Graphics\L2graphics.c" 673 12A4 ; l2_circle_x = 0; 673 12A4 C_LINE 674,"Graphics\L2graphics.c" 674 12A4 C_LINE 674,"Graphics\L2graphics.c" 674 12A4 21 00 00 ld hl,0 ;const 674 12A7 22 AF 17 ld (_l2_circle_x),hl 674 12AA ; l2_circle_y = r; 674 12AA C_LINE 675,"Graphics\L2graphics.c" 675 12AA C_LINE 675,"Graphics\L2graphics.c" 675 12AA 21 04 00 ld hl,4 ;const 675 12AD 39 add hl,sp 675 12AE CD 00 00 call l_gint ; 675 12B1 22 B1 17 ld (_l2_circle_y),hl 675 12B4 ; l2_circle_d = 3 - (2 * r); 675 12B4 C_LINE 676,"Graphics\L2graphics.c" 676 12B4 C_LINE 676,"Graphics\L2graphics.c" 676 12B4 21 04 00 ld hl,4 ;const 676 12B7 39 add hl,sp 676 12B8 CD 00 00 call l_gint ; 676 12BB 29 add hl,hl 676 12BC 11 03 00 ld de,3 676 12BF EB ex de,hl 676 12C0 A7 and a 676 12C1 ED 52 sbc hl,de 676 12C3 22 B3 17 ld (_l2_circle_d),hl 676 12C6 ; l2_draw_circle_px(xc, yc, l2_circle_x, l2_circle_y,color); 676 12C6 C_LINE 677,"Graphics\L2graphics.c" 677 12C6 C_LINE 677,"Graphics\L2graphics.c" 677 12C6 ;xc; 677 12C6 C_LINE 678,"Graphics\L2graphics.c" 678 12C6 21 08 00 ld hl,8 ;const 678 12C9 39 add hl,sp 678 12CA CD 00 00 call l_gint ; 678 12CD E5 push hl 678 12CE ;yc; 678 12CE C_LINE 678,"Graphics\L2graphics.c" 678 12CE 21 08 00 ld hl,8 ;const 678 12D1 39 add hl,sp 678 12D2 CD 00 00 call l_gint ; 678 12D5 E5 push hl 678 12D6 ;l2_circle_x; 678 12D6 C_LINE 678,"Graphics\L2graphics.c" 678 12D6 2A AF 17 ld hl,(_l2_circle_x) 678 12D9 E5 push hl 678 12DA ;l2_circle_y; 678 12DA C_LINE 678,"Graphics\L2graphics.c" 678 12DA 2A B1 17 ld hl,(_l2_circle_y) 678 12DD E5 push hl 678 12DE ;color; 678 12DE C_LINE 678,"Graphics\L2graphics.c" 678 12DE 21 0A 00 ld hl,10 ;const 678 12E1 39 add hl,sp 678 12E2 6E ld l,(hl) 678 12E3 26 00 ld h,0 678 12E5 E5 push hl 678 12E6 CD FB 10 call _l2_draw_circle_px 678 12E9 C1 pop bc 678 12EA C1 pop bc 678 12EB C1 pop bc 678 12EC C1 pop bc 678 12ED C1 pop bc 678 12EE ; while (l2_circle_y >= l2_circle_x) 678 12EE C_LINE 678,"Graphics\L2graphics.c" 678 12EE C_LINE 678,"Graphics\L2graphics.c" 678 12EE .i_130 678 12EE ED 5B B1 17 ld de,(_l2_circle_y) 678 12F2 2A AF 17 ld hl,(_l2_circle_x) 678 12F5 CD 00 00 call l_ge 678 12F8 D2 70 13 jp nc,i_131 678 12FB ; { 678 12FB C_LINE 679,"Graphics\L2graphics.c" 679 12FB C_LINE 679,"Graphics\L2graphics.c" 679 12FB ; 679 12FB C_LINE 680,"Graphics\L2graphics.c" 680 12FB ; ++l2_circle_x; 680 12FB C_LINE 681,"Graphics\L2graphics.c" 681 12FB C_LINE 681,"Graphics\L2graphics.c" 681 12FB 2A AF 17 ld hl,(_l2_circle_x) 681 12FE 23 inc hl 681 12FF 22 AF 17 ld (_l2_circle_x),hl 681 1302 ; 681 1302 C_LINE 682,"Graphics\L2graphics.c" 682 1302 ; if (l2_circle_d > 0) 682 1302 C_LINE 683,"Graphics\L2graphics.c" 683 1302 C_LINE 683,"Graphics\L2graphics.c" 683 1302 2A B3 17 ld hl,(_l2_circle_d) 683 1305 11 00 00 ld de,0 683 1308 EB ex de,hl 683 1309 CD 00 00 call l_gt 683 130C D2 33 13 jp nc,i_132 683 130F ; { 683 130F C_LINE 684,"Graphics\L2graphics.c" 684 130F C_LINE 684,"Graphics\L2graphics.c" 684 130F ; --l2_circle_y; 684 130F C_LINE 685,"Graphics\L2graphics.c" 685 130F C_LINE 685,"Graphics\L2graphics.c" 685 130F 2A B1 17 ld hl,(_l2_circle_y) 685 1312 2B dec hl 685 1313 22 B1 17 ld (_l2_circle_y),hl 685 1316 ; l2_circle_d = l2_circle_d + 4 * (l2_circle_x - l2_circle_y) + 10; 685 1316 C_LINE 686,"Graphics\L2graphics.c" 686 1316 C_LINE 686,"Graphics\L2graphics.c" 686 1316 2A B3 17 ld hl,(_l2_circle_d) 686 1319 E5 push hl 686 131A ED 5B AF 17 ld de,(_l2_circle_x) 686 131E 2A B1 17 ld hl,(_l2_circle_y) 686 1321 EB ex de,hl 686 1322 A7 and a 686 1323 ED 52 sbc hl,de 686 1325 29 add hl,hl 686 1326 29 add hl,hl 686 1327 D1 pop de 686 1328 19 add hl,de 686 1329 ED 34 0A 00 add hl,10 686 132D 22 B3 17 ld (_l2_circle_d),hl 686 1330 ; } 686 1330 C_LINE 687,"Graphics\L2graphics.c" 687 1330 ; else 687 1330 C_LINE 688,"Graphics\L2graphics.c" 688 1330 C3 45 13 jp i_133 688 1333 .i_132 688 1333 ; { 688 1333 C_LINE 689,"Graphics\L2graphics.c" 689 1333 C_LINE 689,"Graphics\L2graphics.c" 689 1333 ; l2_circle_d = l2_circle_d + 4 * l2_circle_x + 6; 689 1333 C_LINE 690,"Graphics\L2graphics.c" 690 1333 C_LINE 690,"Graphics\L2graphics.c" 690 1333 2A B3 17 ld hl,(_l2_circle_d) 690 1336 E5 push hl 690 1337 2A AF 17 ld hl,(_l2_circle_x) 690 133A 29 add hl,hl 690 133B 29 add hl,hl 690 133C D1 pop de 690 133D 19 add hl,de 690 133E ED 34 06 00 add hl,6 690 1342 22 B3 17 ld (_l2_circle_d),hl 690 1345 ; } 690 1345 C_LINE 691,"Graphics\L2graphics.c" 691 1345 .i_133 691 1345 ; l2_draw_circle_px(xc, yc, l2_circle_x, l2_circle_y,color); 691 1345 C_LINE 692,"Graphics\L2graphics.c" 692 1345 C_LINE 692,"Graphics\L2graphics.c" 692 1345 ;xc; 692 1345 C_LINE 693,"Graphics\L2graphics.c" 693 1345 21 08 00 ld hl,8 ;const 693 1348 39 add hl,sp 693 1349 CD 00 00 call l_gint ; 693 134C E5 push hl 693 134D ;yc; 693 134D C_LINE 693,"Graphics\L2graphics.c" 693 134D 21 08 00 ld hl,8 ;const 693 1350 39 add hl,sp 693 1351 CD 00 00 call l_gint ; 693 1354 E5 push hl 693 1355 ;l2_circle_x; 693 1355 C_LINE 693,"Graphics\L2graphics.c" 693 1355 2A AF 17 ld hl,(_l2_circle_x) 693 1358 E5 push hl 693 1359 ;l2_circle_y; 693 1359 C_LINE 693,"Graphics\L2graphics.c" 693 1359 2A B1 17 ld hl,(_l2_circle_y) 693 135C E5 push hl 693 135D ;color; 693 135D C_LINE 693,"Graphics\L2graphics.c" 693 135D 21 0A 00 ld hl,10 ;const 693 1360 39 add hl,sp 693 1361 6E ld l,(hl) 693 1362 26 00 ld h,0 693 1364 E5 push hl 693 1365 CD FB 10 call _l2_draw_circle_px 693 1368 C1 pop bc 693 1369 C1 pop bc 693 136A C1 pop bc 693 136B C1 pop bc 693 136C C1 pop bc 693 136D ; } 693 136D C_LINE 693,"Graphics\L2graphics.c" 693 136D C3 EE 12 jp i_130 693 1370 .i_131 693 1370 ;} 693 1370 C_LINE 694,"Graphics\L2graphics.c" 694 1370 C9 ret 694 1371 694 1371 694 1371 ; 694 1371 C_LINE 696,"Graphics\L2graphics.c" 696 1371 ;void l2_draw_circle_fill_px(int xc, int yc, int x, int y, uint8_t color) 696 1371 C_LINE 697,"Graphics\L2graphics.c" 697 1371 ;{ 697 1371 C_LINE 698,"Graphics\L2graphics.c" 698 1371 698 1371 ; Function l2_draw_circle_fill_px flags 0x00000200 __smallc 698 1371 ; void l2_draw_circle_fill_px(int xc, int yc, int x, int y, unsigned char color) 698 1371 ; parameter 'unsigned char color' at 2 size(1) 698 1371 ; parameter 'int y' at 4 size(2) 698 1371 ; parameter 'int x' at 6 size(2) 698 1371 ; parameter 'int yc' at 8 size(2) 698 1371 ; parameter 'int xc' at 10 size(2) 698 1371 ._l2_draw_circle_fill_px 698 1371 C_LINE 698,"Graphics\L2graphics.c" 698 1371 ; l2_circle_doublex = x << 1; 698 1371 C_LINE 699,"Graphics\L2graphics.c" 699 1371 C_LINE 699,"Graphics\L2graphics.c" 699 1371 21 06 00 ld hl,6 ;const 699 1374 39 add hl,sp 699 1375 CD 00 00 call l_gint ; 699 1378 29 add hl,hl 699 1379 26 00 ld h,0 699 137B 7D ld a,l 699 137C 32 B5 17 ld (_l2_circle_doublex),a 699 137F ; l2_circle_doubley = y << 1; 699 137F C_LINE 700,"Graphics\L2graphics.c" 700 137F C_LINE 700,"Graphics\L2graphics.c" 700 137F 21 04 00 ld hl,4 ;const 700 1382 39 add hl,sp 700 1383 CD 00 00 call l_gint ; 700 1386 29 add hl,hl 700 1387 26 00 ld h,0 700 1389 7D ld a,l 700 138A 32 B6 17 ld (_l2_circle_doubley),a 700 138D ; l2_draw_horz_line(xc-x, yc+y, l2_circle_doublex, color); 700 138D C_LINE 701,"Graphics\L2graphics.c" 701 138D C_LINE 701,"Graphics\L2graphics.c" 701 138D ;xc-x; 701 138D C_LINE 702,"Graphics\L2graphics.c" 702 138D 21 0A 00 ld hl,10 ;const 702 1390 CD 00 00 call l_gintspsp ; 702 1393 21 08 00 ld hl,8 ;const 702 1396 39 add hl,sp 702 1397 CD 00 00 call l_gint ; 702 139A D1 pop de 702 139B EB ex de,hl 702 139C A7 and a 702 139D ED 52 sbc hl,de 702 139F 26 00 ld h,0 702 13A1 E5 push hl 702 13A2 ;yc+y; 702 13A2 C_LINE 702,"Graphics\L2graphics.c" 702 13A2 21 0A 00 ld hl,10 ;const 702 13A5 CD 00 00 call l_gintspsp ; 702 13A8 21 08 00 ld hl,8 ;const 702 13AB 39 add hl,sp 702 13AC CD 00 00 call l_gint ; 702 13AF D1 pop de 702 13B0 19 add hl,de 702 13B1 26 00 ld h,0 702 13B3 E5 push hl 702 13B4 ;l2_circle_doublex; 702 13B4 C_LINE 702,"Graphics\L2graphics.c" 702 13B4 2A B5 17 ld hl,(_l2_circle_doublex) 702 13B7 26 00 ld h,0 702 13B9 E5 push hl 702 13BA ;color; 702 13BA C_LINE 702,"Graphics\L2graphics.c" 702 13BA 21 08 00 ld hl,8 ;const 702 13BD 39 add hl,sp 702 13BE 6E ld l,(hl) 702 13BF 26 00 ld h,0 702 13C1 E5 push hl 702 13C2 CD 6D 01 call _l2_draw_horz_line 702 13C5 C1 pop bc 702 13C6 C1 pop bc 702 13C7 C1 pop bc 702 13C8 C1 pop bc 702 13C9 ; l2_draw_horz_line(xc-x, yc-y, l2_circle_doublex, color); 702 13C9 C_LINE 702,"Graphics\L2graphics.c" 702 13C9 C_LINE 702,"Graphics\L2graphics.c" 702 13C9 ;xc-x; 702 13C9 C_LINE 703,"Graphics\L2graphics.c" 703 13C9 21 0A 00 ld hl,10 ;const 703 13CC CD 00 00 call l_gintspsp ; 703 13CF 21 08 00 ld hl,8 ;const 703 13D2 39 add hl,sp 703 13D3 CD 00 00 call l_gint ; 703 13D6 D1 pop de 703 13D7 EB ex de,hl 703 13D8 A7 and a 703 13D9 ED 52 sbc hl,de 703 13DB 26 00 ld h,0 703 13DD E5 push hl 703 13DE ;yc-y; 703 13DE C_LINE 703,"Graphics\L2graphics.c" 703 13DE 21 0A 00 ld hl,10 ;const 703 13E1 CD 00 00 call l_gintspsp ; 703 13E4 21 08 00 ld hl,8 ;const 703 13E7 39 add hl,sp 703 13E8 CD 00 00 call l_gint ; 703 13EB D1 pop de 703 13EC EB ex de,hl 703 13ED A7 and a 703 13EE ED 52 sbc hl,de 703 13F0 26 00 ld h,0 703 13F2 E5 push hl 703 13F3 ;l2_circle_doublex; 703 13F3 C_LINE 703,"Graphics\L2graphics.c" 703 13F3 2A B5 17 ld hl,(_l2_circle_doublex) 703 13F6 26 00 ld h,0 703 13F8 E5 push hl 703 13F9 ;color; 703 13F9 C_LINE 703,"Graphics\L2graphics.c" 703 13F9 21 08 00 ld hl,8 ;const 703 13FC 39 add hl,sp 703 13FD 6E ld l,(hl) 703 13FE 26 00 ld h,0 703 1400 E5 push hl 703 1401 CD 6D 01 call _l2_draw_horz_line 703 1404 C1 pop bc 703 1405 C1 pop bc 703 1406 C1 pop bc 703 1407 C1 pop bc 703 1408 ; l2_draw_horz_line(xc-y, yc+x, l2_circle_doubley, color); 703 1408 C_LINE 703,"Graphics\L2graphics.c" 703 1408 C_LINE 703,"Graphics\L2graphics.c" 703 1408 ;xc-y; 703 1408 C_LINE 704,"Graphics\L2graphics.c" 704 1408 21 0A 00 ld hl,10 ;const 704 140B CD 00 00 call l_gintspsp ; 704 140E 21 06 00 ld hl,6 ;const 704 1411 39 add hl,sp 704 1412 CD 00 00 call l_gint ; 704 1415 D1 pop de 704 1416 EB ex de,hl 704 1417 A7 and a 704 1418 ED 52 sbc hl,de 704 141A 26 00 ld h,0 704 141C E5 push hl 704 141D ;yc+x; 704 141D C_LINE 704,"Graphics\L2graphics.c" 704 141D 21 0A 00 ld hl,10 ;const 704 1420 CD 00 00 call l_gintspsp ; 704 1423 21 0A 00 ld hl,10 ;const 704 1426 39 add hl,sp 704 1427 CD 00 00 call l_gint ; 704 142A D1 pop de 704 142B 19 add hl,de 704 142C 26 00 ld h,0 704 142E E5 push hl 704 142F ;l2_circle_doubley; 704 142F C_LINE 704,"Graphics\L2graphics.c" 704 142F 2A B6 17 ld hl,(_l2_circle_doubley) 704 1432 26 00 ld h,0 704 1434 E5 push hl 704 1435 ;color; 704 1435 C_LINE 704,"Graphics\L2graphics.c" 704 1435 21 08 00 ld hl,8 ;const 704 1438 39 add hl,sp 704 1439 6E ld l,(hl) 704 143A 26 00 ld h,0 704 143C E5 push hl 704 143D CD 6D 01 call _l2_draw_horz_line 704 1440 C1 pop bc 704 1441 C1 pop bc 704 1442 C1 pop bc 704 1443 C1 pop bc 704 1444 ; l2_draw_horz_line(xc-y, yc-x, l2_circle_doubley, color); 704 1444 C_LINE 704,"Graphics\L2graphics.c" 704 1444 C_LINE 704,"Graphics\L2graphics.c" 704 1444 ;xc-y; 704 1444 C_LINE 705,"Graphics\L2graphics.c" 705 1444 21 0A 00 ld hl,10 ;const 705 1447 CD 00 00 call l_gintspsp ; 705 144A 21 06 00 ld hl,6 ;const 705 144D 39 add hl,sp 705 144E CD 00 00 call l_gint ; 705 1451 D1 pop de 705 1452 EB ex de,hl 705 1453 A7 and a 705 1454 ED 52 sbc hl,de 705 1456 26 00 ld h,0 705 1458 E5 push hl 705 1459 ;yc-x; 705 1459 C_LINE 705,"Graphics\L2graphics.c" 705 1459 21 0A 00 ld hl,10 ;const 705 145C CD 00 00 call l_gintspsp ; 705 145F 21 0A 00 ld hl,10 ;const 705 1462 39 add hl,sp 705 1463 CD 00 00 call l_gint ; 705 1466 D1 pop de 705 1467 EB ex de,hl 705 1468 A7 and a 705 1469 ED 52 sbc hl,de 705 146B 26 00 ld h,0 705 146D E5 push hl 705 146E ;l2_circle_doubley; 705 146E C_LINE 705,"Graphics\L2graphics.c" 705 146E 2A B6 17 ld hl,(_l2_circle_doubley) 705 1471 26 00 ld h,0 705 1473 E5 push hl 705 1474 ;color; 705 1474 C_LINE 705,"Graphics\L2graphics.c" 705 1474 21 08 00 ld hl,8 ;const 705 1477 39 add hl,sp 705 1478 6E ld l,(hl) 705 1479 26 00 ld h,0 705 147B E5 push hl 705 147C CD 6D 01 call _l2_draw_horz_line 705 147F C1 pop bc 705 1480 C1 pop bc 705 1481 C1 pop bc 705 1482 C1 pop bc 705 1483 ;} 705 1483 C_LINE 705,"Graphics\L2graphics.c" 705 1483 C9 ret 705 1484 705 1484 705 1484 ; 705 1484 C_LINE 706,"Graphics\L2graphics.c" 706 1484 ; 706 1484 C_LINE 707,"Graphics\L2graphics.c" 707 1484 ;void l2_draw_circle_fill(int xc, int yc, int r,uint8_t color) 707 1484 C_LINE 708,"Graphics\L2graphics.c" 708 1484 ;{ 708 1484 C_LINE 709,"Graphics\L2graphics.c" 709 1484 709 1484 ; Function l2_draw_circle_fill flags 0x00000200 __smallc 709 1484 ; void l2_draw_circle_fill(int xc, int yc, int r, unsigned char color) 709 1484 ; parameter 'unsigned char color' at 2 size(1) 709 1484 ; parameter 'int r' at 4 size(2) 709 1484 ; parameter 'int yc' at 6 size(2) 709 1484 ; parameter 'int xc' at 8 size(2) 709 1484 ._l2_draw_circle_fill 709 1484 C_LINE 709,"Graphics\L2graphics.c" 709 1484 ; l2_circle_x = 0; 709 1484 C_LINE 710,"Graphics\L2graphics.c" 710 1484 C_LINE 710,"Graphics\L2graphics.c" 710 1484 21 00 00 ld hl,0 ;const 710 1487 22 AF 17 ld (_l2_circle_x),hl 710 148A ; l2_circle_y = r; 710 148A C_LINE 711,"Graphics\L2graphics.c" 711 148A C_LINE 711,"Graphics\L2graphics.c" 711 148A 21 04 00 ld hl,4 ;const 711 148D 39 add hl,sp 711 148E CD 00 00 call l_gint ; 711 1491 22 B1 17 ld (_l2_circle_y),hl 711 1494 ; l2_circle_d = 3 - 2 * r; 711 1494 C_LINE 712,"Graphics\L2graphics.c" 712 1494 C_LINE 712,"Graphics\L2graphics.c" 712 1494 21 04 00 ld hl,4 ;const 712 1497 39 add hl,sp 712 1498 CD 00 00 call l_gint ; 712 149B 29 add hl,hl 712 149C 11 03 00 ld de,3 712 149F EB ex de,hl 712 14A0 A7 and a 712 14A1 ED 52 sbc hl,de 712 14A3 22 B3 17 ld (_l2_circle_d),hl 712 14A6 ; 712 14A6 C_LINE 713,"Graphics\L2graphics.c" 713 14A6 ; l2_draw_circle_fill_px(xc, yc, l2_circle_x, l2_circle_y,color); 713 14A6 C_LINE 714,"Graphics\L2graphics.c" 714 14A6 C_LINE 714,"Graphics\L2graphics.c" 714 14A6 ;xc; 714 14A6 C_LINE 715,"Graphics\L2graphics.c" 715 14A6 21 08 00 ld hl,8 ;const 715 14A9 39 add hl,sp 715 14AA CD 00 00 call l_gint ; 715 14AD E5 push hl 715 14AE ;yc; 715 14AE C_LINE 715,"Graphics\L2graphics.c" 715 14AE 21 08 00 ld hl,8 ;const 715 14B1 39 add hl,sp 715 14B2 CD 00 00 call l_gint ; 715 14B5 E5 push hl 715 14B6 ;l2_circle_x; 715 14B6 C_LINE 715,"Graphics\L2graphics.c" 715 14B6 2A AF 17 ld hl,(_l2_circle_x) 715 14B9 E5 push hl 715 14BA ;l2_circle_y; 715 14BA C_LINE 715,"Graphics\L2graphics.c" 715 14BA 2A B1 17 ld hl,(_l2_circle_y) 715 14BD E5 push hl 715 14BE ;color; 715 14BE C_LINE 715,"Graphics\L2graphics.c" 715 14BE 21 0A 00 ld hl,10 ;const 715 14C1 39 add hl,sp 715 14C2 6E ld l,(hl) 715 14C3 26 00 ld h,0 715 14C5 E5 push hl 715 14C6 CD 71 13 call _l2_draw_circle_fill_px 715 14C9 C1 pop bc 715 14CA C1 pop bc 715 14CB C1 pop bc 715 14CC C1 pop bc 715 14CD C1 pop bc 715 14CE ; while (l2_circle_y >= l2_circle_x) 715 14CE C_LINE 715,"Graphics\L2graphics.c" 715 14CE C_LINE 715,"Graphics\L2graphics.c" 715 14CE .i_134 715 14CE ED 5B B1 17 ld de,(_l2_circle_y) 715 14D2 2A AF 17 ld hl,(_l2_circle_x) 715 14D5 CD 00 00 call l_ge 715 14D8 D2 50 15 jp nc,i_135 715 14DB ; { 715 14DB C_LINE 716,"Graphics\L2graphics.c" 716 14DB C_LINE 716,"Graphics\L2graphics.c" 716 14DB ; 716 14DB C_LINE 717,"Graphics\L2graphics.c" 717 14DB ; ++l2_circle_x; 717 14DB C_LINE 718,"Graphics\L2graphics.c" 718 14DB C_LINE 718,"Graphics\L2graphics.c" 718 14DB 2A AF 17 ld hl,(_l2_circle_x) 718 14DE 23 inc hl 718 14DF 22 AF 17 ld (_l2_circle_x),hl 718 14E2 ; 718 14E2 C_LINE 719,"Graphics\L2graphics.c" 719 14E2 ; if (l2_circle_d > 0) 719 14E2 C_LINE 720,"Graphics\L2graphics.c" 720 14E2 C_LINE 720,"Graphics\L2graphics.c" 720 14E2 2A B3 17 ld hl,(_l2_circle_d) 720 14E5 11 00 00 ld de,0 720 14E8 EB ex de,hl 720 14E9 CD 00 00 call l_gt 720 14EC D2 13 15 jp nc,i_136 720 14EF ; { 720 14EF C_LINE 721,"Graphics\L2graphics.c" 721 14EF C_LINE 721,"Graphics\L2graphics.c" 721 14EF ; --l2_circle_y; 721 14EF C_LINE 722,"Graphics\L2graphics.c" 722 14EF C_LINE 722,"Graphics\L2graphics.c" 722 14EF 2A B1 17 ld hl,(_l2_circle_y) 722 14F2 2B dec hl 722 14F3 22 B1 17 ld (_l2_circle_y),hl 722 14F6 ; l2_circle_d = l2_circle_d + 4 * (l2_circle_x - l2_circle_y) + 10; 722 14F6 C_LINE 723,"Graphics\L2graphics.c" 723 14F6 C_LINE 723,"Graphics\L2graphics.c" 723 14F6 2A B3 17 ld hl,(_l2_circle_d) 723 14F9 E5 push hl 723 14FA ED 5B AF 17 ld de,(_l2_circle_x) 723 14FE 2A B1 17 ld hl,(_l2_circle_y) 723 1501 EB ex de,hl 723 1502 A7 and a 723 1503 ED 52 sbc hl,de 723 1505 29 add hl,hl 723 1506 29 add hl,hl 723 1507 D1 pop de 723 1508 19 add hl,de 723 1509 ED 34 0A 00 add hl,10 723 150D 22 B3 17 ld (_l2_circle_d),hl 723 1510 ; } 723 1510 C_LINE 724,"Graphics\L2graphics.c" 724 1510 ; else 724 1510 C_LINE 725,"Graphics\L2graphics.c" 725 1510 C3 25 15 jp i_137 725 1513 .i_136 725 1513 ; { 725 1513 C_LINE 726,"Graphics\L2graphics.c" 726 1513 C_LINE 726,"Graphics\L2graphics.c" 726 1513 ; l2_circle_d = l2_circle_d + 4 * l2_circle_x + 6; 726 1513 C_LINE 727,"Graphics\L2graphics.c" 727 1513 C_LINE 727,"Graphics\L2graphics.c" 727 1513 2A B3 17 ld hl,(_l2_circle_d) 727 1516 E5 push hl 727 1517 2A AF 17 ld hl,(_l2_circle_x) 727 151A 29 add hl,hl 727 151B 29 add hl,hl 727 151C D1 pop de 727 151D 19 add hl,de 727 151E ED 34 06 00 add hl,6 727 1522 22 B3 17 ld (_l2_circle_d),hl 727 1525 ; } 727 1525 C_LINE 728,"Graphics\L2graphics.c" 728 1525 .i_137 728 1525 ; l2_draw_circle_fill_px(xc, yc, l2_circle_x, l2_circle_y,color); 728 1525 C_LINE 729,"Graphics\L2graphics.c" 729 1525 C_LINE 729,"Graphics\L2graphics.c" 729 1525 ;xc; 729 1525 C_LINE 730,"Graphics\L2graphics.c" 730 1525 21 08 00 ld hl,8 ;const 730 1528 39 add hl,sp 730 1529 CD 00 00 call l_gint ; 730 152C E5 push hl 730 152D ;yc; 730 152D C_LINE 730,"Graphics\L2graphics.c" 730 152D 21 08 00 ld hl,8 ;const 730 1530 39 add hl,sp 730 1531 CD 00 00 call l_gint ; 730 1534 E5 push hl 730 1535 ;l2_circle_x; 730 1535 C_LINE 730,"Graphics\L2graphics.c" 730 1535 2A AF 17 ld hl,(_l2_circle_x) 730 1538 E5 push hl 730 1539 ;l2_circle_y; 730 1539 C_LINE 730,"Graphics\L2graphics.c" 730 1539 2A B1 17 ld hl,(_l2_circle_y) 730 153C E5 push hl 730 153D ;color; 730 153D C_LINE 730,"Graphics\L2graphics.c" 730 153D 21 0A 00 ld hl,10 ;const 730 1540 39 add hl,sp 730 1541 6E ld l,(hl) 730 1542 26 00 ld h,0 730 1544 E5 push hl 730 1545 CD 71 13 call _l2_draw_circle_fill_px 730 1548 C1 pop bc 730 1549 C1 pop bc 730 154A C1 pop bc 730 154B C1 pop bc 730 154C C1 pop bc 730 154D ; } 730 154D C_LINE 730,"Graphics\L2graphics.c" 730 154D C3 CE 14 jp i_134 730 1550 .i_135 730 1550 ;} 730 1550 C_LINE 731,"Graphics\L2graphics.c" 731 1550 C9 ret 731 1551 731 1551 731 1551 ; 731 1551 C_LINE 776,"Graphics\L2graphics.c" 776 1551 ; 776 1551 C_LINE 777,"Graphics\L2graphics.c" 777 1551 ; 777 1551 C_LINE 778,"Graphics\L2graphics.c" 778 1551 ; 778 1551 C_LINE 779,"Graphics\L2graphics.c" 779 1551 ; 779 1551 C_LINE 780,"Graphics\L2graphics.c" 780 1551 ; 780 1551 C_LINE 781,"Graphics\L2graphics.c" 781 1551 ; 781 1551 C_LINE 782,"Graphics\L2graphics.c" 782 1551 ; 782 1551 C_LINE 783,"Graphics\L2graphics.c" 783 1551 ; 783 1551 C_LINE 784,"Graphics\L2graphics.c" 784 1551 ; 784 1551 C_LINE 785,"Graphics\L2graphics.c" 785 1551 ; 785 1551 C_LINE 786,"Graphics\L2graphics.c" 786 1551 ; 786 1551 C_LINE 787,"Graphics\L2graphics.c" 787 1551 ; 787 1551 C_LINE 788,"Graphics\L2graphics.c" 788 1551 ; 788 1551 C_LINE 789,"Graphics\L2graphics.c" 789 1551 ; 789 1551 C_LINE 790,"Graphics\L2graphics.c" 790 1551 ; 790 1551 C_LINE 791,"Graphics\L2graphics.c" 791 1551 ; 791 1551 C_LINE 792,"Graphics\L2graphics.c" 792 1551 ; 792 1551 C_LINE 793,"Graphics\L2graphics.c" 793 1551 ; 793 1551 C_LINE 796,"Graphics\L2graphics.c" 796 1551 ; 796 1551 C_LINE 806,"Graphics\L2graphics.c" 806 1551 ; 806 1551 C_LINE 813,"Graphics\L2graphics.c" 813 1551 ; 813 1551 C_LINE 816,"Graphics\L2graphics.c" 816 1551 ; 816 1551 C_LINE 820,"Graphics\L2graphics.c" 820 1551 ; 820 1551 C_LINE 823,"Graphics\L2graphics.c" 823 1551 ; 823 1551 C_LINE 830,"Graphics\L2graphics.c" 830 1551 ; 830 1551 C_LINE 832,"Graphics\L2graphics.c" 832 1551 ; 832 1551 C_LINE 835,"Graphics\L2graphics.c" 835 1551 ; 835 1551 C_LINE 842,"Graphics\L2graphics.c" 842 1551 ; 842 1551 C_LINE 844,"Graphics\L2graphics.c" 844 1551 ; 844 1551 C_LINE 847,"Graphics\L2graphics.c" 847 1551 ; 847 1551 C_LINE 854,"Graphics\L2graphics.c" 854 1551 ; 854 1551 C_LINE 857,"Graphics\L2graphics.c" 857 1551 ; 857 1551 C_LINE 858,"Graphics\L2graphics.c" 858 1551 ; 858 1551 C_LINE 859,"Graphics\L2graphics.c" 859 1551 ; 859 1551 C_LINE 860,"Graphics\L2graphics.c" 860 1551 ; 860 1551 C_LINE 862,"Graphics\L2graphics.c" 862 1551 ; 862 1551 C_LINE 865,"Graphics\L2graphics.c" 865 1551 ; 865 1551 C_LINE 872,"Graphics\L2graphics.c" 872 1551 ; 872 1551 C_LINE 877,"Graphics\L2graphics.c" 877 1551 ; 877 1551 C_LINE 878,"Graphics\L2graphics.c" 878 1551 ; 878 1551 C_LINE 879,"Graphics\L2graphics.c" 879 1551 ; 879 1551 C_LINE 880,"Graphics\L2graphics.c" 880 1551 ; 880 1551 C_LINE 882,"Graphics\L2graphics.c" 882 1551 ; 882 1551 C_LINE 884,"Graphics\L2graphics.c" 884 1551 ; 884 1551 C_LINE 885,"Graphics\L2graphics.c" 885 1551 ; 885 1551 C_LINE 887,"Graphics\L2graphics.c" 887 1551 ;void l2_print_chr_at(uint8_t x, uint8_t y, char chrText, uint8_t colour) 887 1551 C_LINE 895,"Graphics\L2graphics.c" 895 1551 ;{ 895 1551 C_LINE 896,"Graphics\L2graphics.c" 896 1551 896 1551 ; Function l2_print_chr_at flags 0x00000200 __smallc 896 1551 ; void l2_print_chr_at(unsigned char x, unsigned char y, char chrText, unsigned char colour) 896 1551 ; parameter 'unsigned char colour' at 2 size(1) 896 1551 ; parameter 'char chrText' at 4 size(1) 896 1551 ; parameter 'unsigned char y' at 6 size(1) 896 1551 ; parameter 'unsigned char x' at 8 size(1) 896 1551 ._l2_print_chr_at 896 1551 C_LINE 896,"Graphics\L2graphics.c" 896 1551 ; if (chrText >= 32 && chrText <127) 896 1551 C_LINE 897,"Graphics\L2graphics.c" 897 1551 C_LINE 897,"Graphics\L2graphics.c" 897 1551 21 04 00 ld hl,4 ;const 897 1554 39 add hl,sp 897 1555 CD 00 00 call l_gchar 897 1558 7D ld a,l 897 1559 EE 80 xor 128 897 155B D6 A0 sub 160 897 155D 3F ccf 897 155E D2 6D 15 jp nc,i_139 897 1561 21 04 00 ld hl,4 ;const 897 1564 39 add hl,sp 897 1565 CD 00 00 call l_gchar 897 1568 7D ld a,l 897 1569 D6 7F sub 127 897 156B 38 03 jr c,i_140_i_139 897 156D .i_139 897 156D C3 7D 16 jp i_138 897 1570 .i_140_i_139 897 1570 ; { 897 1570 C_LINE 898,"Graphics\L2graphics.c" 898 1570 C_LINE 898,"Graphics\L2graphics.c" 898 1570 ; l2_charAddr = chrText; 898 1570 C_LINE 899,"Graphics\L2graphics.c" 899 1570 C_LINE 899,"Graphics\L2graphics.c" 899 1570 21 04 00 ld hl,4 ;const 899 1573 39 add hl,sp 899 1574 CD 00 00 call l_gchar 899 1577 22 99 17 ld (_l2_charAddr),hl 899 157A ; l2_charAddr = l2_charAddr << 3; 899 157A C_LINE 900,"Graphics\L2graphics.c" 900 157A C_LINE 900,"Graphics\L2graphics.c" 900 157A 2A 99 17 ld hl,(_l2_charAddr) 900 157D 29 add hl,hl 900 157E 29 add hl,hl 900 157F 29 add hl,hl 900 1580 22 99 17 ld (_l2_charAddr),hl 900 1583 ; l2_charAddr += 15360; 900 1583 C_LINE 901,"Graphics\L2graphics.c" 901 1583 C_LINE 901,"Graphics\L2graphics.c" 901 1583 2A 99 17 ld hl,(_l2_charAddr) 901 1586 ED 34 00 3C add hl,15360 901 158A 22 99 17 ld (_l2_charAddr),hl 901 158D ; l2_y_work_pca = y+1; 901 158D C_LINE 902,"Graphics\L2graphics.c" 902 158D C_LINE 902,"Graphics\L2graphics.c" 902 158D 21 06 00 ld hl,6 ;const 902 1590 39 add hl,sp 902 1591 6E ld l,(hl) 902 1592 26 00 ld h,0 902 1594 23 inc hl 902 1595 26 00 ld h,0 902 1597 7D ld a,l 902 1598 32 8E 17 ld (_l2_y_work_pca),a 902 159B ; l2_local_save = x+1; 902 159B C_LINE 903,"Graphics\L2graphics.c" 903 159B C_LINE 903,"Graphics\L2graphics.c" 903 159B 21 08 00 ld hl,8 ;const 903 159E 39 add hl,sp 903 159F 6E ld l,(hl) 903 15A0 26 00 ld h,0 903 15A2 23 inc hl 903 15A3 26 00 ld h,0 903 15A5 7D ld a,l 903 15A6 32 93 17 ld (_l2_local_save),a 903 15A9 ; for (l2_loopvar_charj = 1; l2_loopvar_charj < 8; ++l2_loopvar_charj) 903 15A9 C_LINE 904,"Graphics\L2graphics.c" 904 15A9 C_LINE 904,"Graphics\L2graphics.c" 904 15A9 21 01 00 ld hl,1 % 256 ;const 904 15AC 7D ld a,l 904 15AD 32 81 17 ld (_l2_loopvar_charj),a 904 15B0 C3 BD 15 jp i_143 904 15B3 .i_141 904 15B3 2A 81 17 ld hl,(_l2_loopvar_charj) 904 15B6 26 00 ld h,0 904 15B8 23 inc hl 904 15B9 7D ld a,l 904 15BA 32 81 17 ld (_l2_loopvar_charj),a 904 15BD .i_143 904 15BD 2A 81 17 ld hl,(_l2_loopvar_charj) 904 15C0 26 00 ld h,0 904 15C2 7D ld a,l 904 15C3 D6 08 sub 8 904 15C5 D2 7D 16 jp nc,i_142 904 15C8 ; { 904 15C8 C_LINE 905,"Graphics\L2graphics.c" 905 15C8 C_LINE 905,"Graphics\L2graphics.c" 905 15C8 ; l2_x_work_pca = l2_local_save; 905 15C8 C_LINE 906,"Graphics\L2graphics.c" 906 15C8 C_LINE 906,"Graphics\L2graphics.c" 906 15C8 2A 93 17 ld hl,(_l2_local_save) 906 15CB 26 00 ld h,0 906 15CD 7D ld a,l 906 15CE 32 8F 17 ld (_l2_x_work_pca),a 906 15D1 ; l2_byteToWrite = (*(unsigned char *)( l2_charAddr+l2_loopvar_charj )) ; 906 15D1 C_LINE 907,"Graphics\L2graphics.c" 907 15D1 C_LINE 907,"Graphics\L2graphics.c" 907 15D1 ED 5B 99 17 ld de,(_l2_charAddr) 907 15D5 2A 81 17 ld hl,(_l2_loopvar_charj) 907 15D8 26 00 ld h,0 907 15DA 19 add hl,de 907 15DB 6E ld l,(hl) 907 15DC 26 00 ld h,0 907 15DE 7D ld a,l 907 15DF 32 78 17 ld (_l2_byteToWrite),a 907 15E2 ; if (l2_byteToWrite != 0) 907 15E2 C_LINE 908,"Graphics\L2graphics.c" 908 15E2 C_LINE 908,"Graphics\L2graphics.c" 908 15E2 2A 78 17 ld hl,(_l2_byteToWrite) 908 15E5 26 00 ld h,0 908 15E7 7D ld a,l 908 15E8 A7 and a 908 15E9 CA 70 16 jp z,i_144 908 15EC ; { 908 15EC C_LINE 909,"Graphics\L2graphics.c" 909 15EC C_LINE 909,"Graphics\L2graphics.c" 909 15EC ; l2_byteToWrite = l2_byteToWrite << 1; 909 15EC C_LINE 910,"Graphics\L2graphics.c" 910 15EC C_LINE 910,"Graphics\L2graphics.c" 910 15EC 2A 78 17 ld hl,(_l2_byteToWrite) 910 15EF 26 00 ld h,0 910 15F1 29 add hl,hl 910 15F2 26 00 ld h,0 910 15F4 7D ld a,l 910 15F5 32 78 17 ld (_l2_byteToWrite),a 910 15F8 ; for (l2_loopvar_chark = 1; l2_loopvar_chark < 7; ++l2_loopvar_chark) 910 15F8 C_LINE 911,"Graphics\L2graphics.c" 911 15F8 C_LINE 911,"Graphics\L2graphics.c" 911 15F8 21 01 00 ld hl,1 % 256 ;const 911 15FB 7D ld a,l 911 15FC 32 82 17 ld (_l2_loopvar_chark),a 911 15FF C3 0C 16 jp i_147 911 1602 .i_145 911 1602 2A 82 17 ld hl,(_l2_loopvar_chark) 911 1605 26 00 ld h,0 911 1607 23 inc hl 911 1608 7D ld a,l 911 1609 32 82 17 ld (_l2_loopvar_chark),a 911 160C .i_147 911 160C 2A 82 17 ld hl,(_l2_loopvar_chark) 911 160F 26 00 ld h,0 911 1611 7D ld a,l 911 1612 D6 07 sub 7 911 1614 D2 70 16 jp nc,i_146 911 1617 ; { 911 1617 C_LINE 912,"Graphics\L2graphics.c" 912 1617 C_LINE 912,"Graphics\L2graphics.c" 912 1617 ; if ((l2_byteToWrite & 0x80) != 0) 912 1617 C_LINE 913,"Graphics\L2graphics.c" 913 1617 C_LINE 913,"Graphics\L2graphics.c" 913 1617 2A 78 17 ld hl,(_l2_byteToWrite) 913 161A 26 00 ld h,0 913 161C 3E 80 ld a,+(128 % 256) 913 161E A5 and l 913 161F 6F ld l,a 913 1620 A7 and a 913 1621 CA 41 16 jp z,i_148 913 1624 ; { 913 1624 C_LINE 914,"Graphics\L2graphics.c" 914 1624 C_LINE 914,"Graphics\L2graphics.c" 914 1624 ; l2_plot_pixel(l2_x_work_pca, l2_y_work_pca, colour); 914 1624 C_LINE 915,"Graphics\L2graphics.c" 915 1624 C_LINE 915,"Graphics\L2graphics.c" 915 1624 ;l2_x_work_pca; 915 1624 C_LINE 916,"Graphics\L2graphics.c" 916 1624 2A 8F 17 ld hl,(_l2_x_work_pca) 916 1627 26 00 ld h,0 916 1629 E5 push hl 916 162A ;l2_y_work_pca; 916 162A C_LINE 916,"Graphics\L2graphics.c" 916 162A 2A 8E 17 ld hl,(_l2_y_work_pca) 916 162D 26 00 ld h,0 916 162F E5 push hl 916 1630 ;colour; 916 1630 C_LINE 916,"Graphics\L2graphics.c" 916 1630 21 06 00 ld hl,6 ;const 916 1633 39 add hl,sp 916 1634 6E ld l,(hl) 916 1635 26 00 ld h,0 916 1637 E5 push hl 916 1638 CD 32 01 call _l2_plot_pixel 916 163B C1 pop bc 916 163C C1 pop bc 916 163D C1 pop bc 916 163E ; } 916 163E C_LINE 916,"Graphics\L2graphics.c" 916 163E ; else 916 163E C_LINE 917,"Graphics\L2graphics.c" 917 163E C3 57 16 jp i_149 917 1641 .i_148 917 1641 ; { 917 1641 C_LINE 918,"Graphics\L2graphics.c" 918 1641 C_LINE 918,"Graphics\L2graphics.c" 918 1641 ; l2_plot_pixel(l2_x_work_pca, l2_y_work_pca, 0xE3); 918 1641 C_LINE 919,"Graphics\L2graphics.c" 919 1641 C_LINE 919,"Graphics\L2graphics.c" 919 1641 ;l2_x_work_pca; 919 1641 C_LINE 920,"Graphics\L2graphics.c" 920 1641 2A 8F 17 ld hl,(_l2_x_work_pca) 920 1644 26 00 ld h,0 920 1646 E5 push hl 920 1647 ;l2_y_work_pca; 920 1647 C_LINE 920,"Graphics\L2graphics.c" 920 1647 2A 8E 17 ld hl,(_l2_y_work_pca) 920 164A 26 00 ld h,0 920 164C E5 push hl 920 164D ;0xE3; 920 164D C_LINE 920,"Graphics\L2graphics.c" 920 164D 21 E3 00 ld hl,227 ;const 920 1650 E5 push hl 920 1651 CD 32 01 call _l2_plot_pixel 920 1654 C1 pop bc 920 1655 C1 pop bc 920 1656 C1 pop bc 920 1657 ; } 920 1657 C_LINE 920,"Graphics\L2graphics.c" 920 1657 .i_149 920 1657 ; ++l2_x_work_pca; 920 1657 C_LINE 921,"Graphics\L2graphics.c" 921 1657 C_LINE 921,"Graphics\L2graphics.c" 921 1657 2A 8F 17 ld hl,(_l2_x_work_pca) 921 165A 26 00 ld h,0 921 165C 23 inc hl 921 165D 7D ld a,l 921 165E 32 8F 17 ld (_l2_x_work_pca),a 921 1661 ; l2_byteToWrite = l2_byteToWrite << 1; 921 1661 C_LINE 922,"Graphics\L2graphics.c" 922 1661 C_LINE 922,"Graphics\L2graphics.c" 922 1661 2A 78 17 ld hl,(_l2_byteToWrite) 922 1664 26 00 ld h,0 922 1666 29 add hl,hl 922 1667 26 00 ld h,0 922 1669 7D ld a,l 922 166A 32 78 17 ld (_l2_byteToWrite),a 922 166D ; } 922 166D C_LINE 923,"Graphics\L2graphics.c" 923 166D C3 02 16 jp i_145 923 1670 .i_146 923 1670 ; } 923 1670 C_LINE 924,"Graphics\L2graphics.c" 924 1670 ; ++l2_y_work_pca; 924 1670 C_LINE 925,"Graphics\L2graphics.c" 925 1670 .i_144 925 1670 C_LINE 925,"Graphics\L2graphics.c" 925 1670 2A 8E 17 ld hl,(_l2_y_work_pca) 925 1673 26 00 ld h,0 925 1675 23 inc hl 925 1676 7D ld a,l 925 1677 32 8E 17 ld (_l2_y_work_pca),a 925 167A ; } 925 167A C_LINE 926,"Graphics\L2graphics.c" 926 167A C3 B3 15 jp i_141 926 167D .i_142 926 167D ; } 926 167D C_LINE 927,"Graphics\L2graphics.c" 927 167D ;} 927 167D C_LINE 928,"Graphics\L2graphics.c" 928 167D .i_138 928 167D C9 ret 928 167E 928 167E 928 167E ;void l2_print_at(uint8_t x, uint8_t y, char *message, uint8_t colour) 928 167E C_LINE 930,"Graphics\L2graphics.c" 930 167E ;{ 930 167E C_LINE 931,"Graphics\L2graphics.c" 931 167E 931 167E ; Function l2_print_at flags 0x00000200 __smallc 931 167E ; void l2_print_at(unsigned char x, unsigned char y, char *message, unsigned char colour) 931 167E ; parameter 'unsigned char colour' at 2 size(1) 931 167E ; parameter 'char *message' at 4 size(2) 931 167E ; parameter 'unsigned char y' at 6 size(1) 931 167E ; parameter 'unsigned char x' at 8 size(1) 931 167E ._l2_print_at 931 167E C_LINE 931,"Graphics\L2graphics.c" 931 167E ; l2_x_work_pct = 0; 931 167E C_LINE 932,"Graphics\L2graphics.c" 932 167E C_LINE 932,"Graphics\L2graphics.c" 932 167E 21 00 00 ld hl,0 % 256 ;const 932 1681 7D ld a,l 932 1682 32 91 17 ld (_l2_x_work_pct),a 932 1685 ; 932 1685 C_LINE 933,"Graphics\L2graphics.c" 933 1685 ; while (message[l2_x_work_pct] != 0 && l2_x_work_pct < 32) 933 1685 C_LINE 934,"Graphics\L2graphics.c" 934 1685 C_LINE 934,"Graphics\L2graphics.c" 934 1685 .i_150 934 1685 21 04 00 ld hl,4 ;const 934 1688 39 add hl,sp 934 1689 5E ld e,(hl) 934 168A 23 inc hl 934 168B 56 ld d,(hl) 934 168C D5 push de 934 168D 2A 91 17 ld hl,(_l2_x_work_pct) 934 1690 26 00 ld h,0 934 1692 D1 pop de 934 1693 19 add hl,de 934 1694 7E ld a,(hl) 934 1695 A7 and a 934 1696 CA A0 16 jp z,i_152 934 1699 3A 91 17 ld a,(_l2_x_work_pct) 934 169C D6 20 sub 32 934 169E 38 03 jr c,i_153_i_152 934 16A0 .i_152 934 16A0 C3 CF 16 jp i_151 934 16A3 .i_153_i_152 934 16A3 ; { 934 16A3 C_LINE 935,"Graphics\L2graphics.c" 935 16A3 C_LINE 935,"Graphics\L2graphics.c" 935 16A3 ; messagebuffer[l2_x_work_pct] = message[l2_x_work_pct]; 935 16A3 C_LINE 936,"Graphics\L2graphics.c" 936 16A3 C_LINE 936,"Graphics\L2graphics.c" 936 16A3 11 48 19 ld de,_messagebuffer 936 16A6 2A 91 17 ld hl,(_l2_x_work_pct) 936 16A9 26 00 ld h,0 936 16AB 19 add hl,de 936 16AC E5 push hl 936 16AD 21 06 00 ld hl,6 ;const 936 16B0 39 add hl,sp 936 16B1 5E ld e,(hl) 936 16B2 23 inc hl 936 16B3 56 ld d,(hl) 936 16B4 D5 push de 936 16B5 2A 91 17 ld hl,(_l2_x_work_pct) 936 16B8 26 00 ld h,0 936 16BA D1 pop de 936 16BB 19 add hl,de 936 16BC CD 00 00 call l_gchar 936 16BF D1 pop de 936 16C0 7D ld a,l 936 16C1 12 ld (de),a 936 16C2 ; 936 16C2 C_LINE 937,"Graphics\L2graphics.c" 937 16C2 ; ++l2_x_work_pct; 937 16C2 C_LINE 938,"Graphics\L2graphics.c" 938 16C2 C_LINE 938,"Graphics\L2graphics.c" 938 16C2 2A 91 17 ld hl,(_l2_x_work_pct) 938 16C5 26 00 ld h,0 938 16C7 23 inc hl 938 16C8 7D ld a,l 938 16C9 32 91 17 ld (_l2_x_work_pct),a 938 16CC ; } 938 16CC C_LINE 939,"Graphics\L2graphics.c" 939 16CC C3 85 16 jp i_150 939 16CF .i_151 939 16CF ; messagebuffer[l2_x_work_pct] = 0; 939 16CF C_LINE 940,"Graphics\L2graphics.c" 940 16CF C_LINE 940,"Graphics\L2graphics.c" 940 16CF 11 48 19 ld de,_messagebuffer 940 16D2 2A 91 17 ld hl,(_l2_x_work_pct) 940 16D5 26 00 ld h,0 940 16D7 19 add hl,de 940 16D8 36 00 ld (hl),+(0 % 256) 940 16DA 6E ld l,(hl) 940 16DB 26 00 ld h,0 940 16DD ; 940 16DD C_LINE 941,"Graphics\L2graphics.c" 941 16DD ; l2_x_work_pct = x; 941 16DD C_LINE 942,"Graphics\L2graphics.c" 942 16DD C_LINE 942,"Graphics\L2graphics.c" 942 16DD 21 08 00 ld hl,8 ;const 942 16E0 39 add hl,sp 942 16E1 6E ld l,(hl) 942 16E2 26 00 ld h,0 942 16E4 7D ld a,l 942 16E5 32 91 17 ld (_l2_x_work_pct),a 942 16E8 ; l2_y_work_pct = y; 942 16E8 C_LINE 943,"Graphics\L2graphics.c" 943 16E8 C_LINE 943,"Graphics\L2graphics.c" 943 16E8 21 06 00 ld hl,6 ;const 943 16EB 39 add hl,sp 943 16EC 6E ld l,(hl) 943 16ED 26 00 ld h,0 943 16EF 7D ld a,l 943 16F0 32 90 17 ld (_l2_y_work_pct),a 943 16F3 ; 943 16F3 C_LINE 944,"Graphics\L2graphics.c" 944 16F3 ; l2_loopvar_chrat = 0; 944 16F3 C_LINE 945,"Graphics\L2graphics.c" 945 16F3 C_LINE 945,"Graphics\L2graphics.c" 945 16F3 21 00 00 ld hl,0 % 256 ;const 945 16F6 7D ld a,l 945 16F7 32 83 17 ld (_l2_loopvar_chrat),a 945 16FA ; while (l2_loopvar_chrat < 32 && messagebuffer[l2_loopvar_chrat] != 0) 945 16FA C_LINE 946,"Graphics\L2graphics.c" 946 16FA C_LINE 946,"Graphics\L2graphics.c" 946 16FA .i_154 946 16FA 3A 83 17 ld a,(_l2_loopvar_chrat) 946 16FD D6 20 sub 32 946 16FF D2 0F 17 jp nc,i_156 946 1702 11 48 19 ld de,_messagebuffer 946 1705 2A 83 17 ld hl,(_l2_loopvar_chrat) 946 1708 26 00 ld h,0 946 170A 19 add hl,de 946 170B 7E ld a,(hl) 946 170C A7 and a 946 170D 20 03 jr nz,i_157_i_156 946 170F .i_156 946 170F C3 77 17 jp i_155 946 1712 .i_157_i_156 946 1712 ; { 946 1712 C_LINE 947,"Graphics\L2graphics.c" 947 1712 C_LINE 947,"Graphics\L2graphics.c" 947 1712 ; 947 1712 C_LINE 948,"Graphics\L2graphics.c" 948 1712 ; l2_print_chr_at (l2_x_work_pct, l2_y_work_pct, messagebuffer[l2_loopvar_chrat], colour); 948 1712 C_LINE 949,"Graphics\L2graphics.c" 949 1712 C_LINE 949,"Graphics\L2graphics.c" 949 1712 ;l2_x_work_pct; 949 1712 C_LINE 950,"Graphics\L2graphics.c" 950 1712 2A 91 17 ld hl,(_l2_x_work_pct) 950 1715 26 00 ld h,0 950 1717 E5 push hl 950 1718 ;l2_y_work_pct; 950 1718 C_LINE 950,"Graphics\L2graphics.c" 950 1718 2A 90 17 ld hl,(_l2_y_work_pct) 950 171B 26 00 ld h,0 950 171D E5 push hl 950 171E ;messagebuffer[l2_loopvar_chrat]; 950 171E C_LINE 950,"Graphics\L2graphics.c" 950 171E 11 48 19 ld de,_messagebuffer 950 1721 2A 83 17 ld hl,(_l2_loopvar_chrat) 950 1724 26 00 ld h,0 950 1726 19 add hl,de 950 1727 CD 00 00 call l_gchar 950 172A E5 push hl 950 172B ;colour; 950 172B C_LINE 950,"Graphics\L2graphics.c" 950 172B 21 08 00 ld hl,8 ;const 950 172E 39 add hl,sp 950 172F 6E ld l,(hl) 950 1730 26 00 ld h,0 950 1732 E5 push hl 950 1733 CD 51 15 call _l2_print_chr_at 950 1736 C1 pop bc 950 1737 C1 pop bc 950 1738 C1 pop bc 950 1739 C1 pop bc 950 173A ; l2_x_work_pct += 8; 950 173A C_LINE 950,"Graphics\L2graphics.c" 950 173A C_LINE 950,"Graphics\L2graphics.c" 950 173A 2A 91 17 ld hl,(_l2_x_work_pct) 950 173D 26 00 ld h,0 950 173F ED 34 08 00 add hl,8 950 1743 26 00 ld h,0 950 1745 7D ld a,l 950 1746 32 91 17 ld (_l2_x_work_pct),a 950 1749 ; if (l2_x_work_pct > 250) 950 1749 C_LINE 951,"Graphics\L2graphics.c" 951 1749 C_LINE 951,"Graphics\L2graphics.c" 951 1749 2A 91 17 ld hl,(_l2_x_work_pct) 951 174C 26 00 ld h,0 951 174E 3E FA ld a,250 951 1750 95 sub l 951 1751 D2 6A 17 jp nc,i_158 951 1754 ; { 951 1754 C_LINE 952,"Graphics\L2graphics.c" 952 1754 C_LINE 952,"Graphics\L2graphics.c" 952 1754 ; l2_y_work_pct += 8; 952 1754 C_LINE 953,"Graphics\L2graphics.c" 953 1754 C_LINE 953,"Graphics\L2graphics.c" 953 1754 2A 90 17 ld hl,(_l2_y_work_pct) 953 1757 26 00 ld h,0 953 1759 ED 34 08 00 add hl,8 953 175D 26 00 ld h,0 953 175F 7D ld a,l 953 1760 32 90 17 ld (_l2_y_work_pct),a 953 1763 ; l2_x_work_pct = 0; 953 1763 C_LINE 954,"Graphics\L2graphics.c" 954 1763 C_LINE 954,"Graphics\L2graphics.c" 954 1763 21 00 00 ld hl,0 % 256 ;const 954 1766 7D ld a,l 954 1767 32 91 17 ld (_l2_x_work_pct),a 954 176A ; } 954 176A C_LINE 955,"Graphics\L2graphics.c" 955 176A ; ++l2_loopvar_chrat; 955 176A C_LINE 956,"Graphics\L2graphics.c" 956 176A .i_158 956 176A C_LINE 956,"Graphics\L2graphics.c" 956 176A 2A 83 17 ld hl,(_l2_loopvar_chrat) 956 176D 26 00 ld h,0 956 176F 23 inc hl 956 1770 7D ld a,l 956 1771 32 83 17 ld (_l2_loopvar_chrat),a 956 1774 ; } 956 1774 C_LINE 957,"Graphics\L2graphics.c" 957 1774 C3 FA 16 jp i_154 957 1777 .i_155 957 1777 ;} 957 1777 C_LINE 958,"Graphics\L2graphics.c" 958 1777 C9 ret 958 1778 958 1778 958 1778 958 1778 ; --- Start of Static Variables --- 958 1778 958 1778 00 ._l2_byteToWrite defs 1 958 1779 00 ._l2_y_parameter defs 1 958 177A 00 ._l2_x_parameter defs 1 958 177B 00 ._l2_col_parameter defs 1 958 177C 00 ._l2_loopvar defs 1 958 177D 00 ._l2_loopvar_dvs defs 1 958 177E 00 ._l2_loopvar_hzl defs 1 958 177F 00 ._l2_loopvar_tft defs 1 958 1780 00 ._l2_loopvar_bft defs 1 958 1781 00 ._l2_loopvar_charj defs 1 958 1782 00 ._l2_loopvar_chark defs 1 958 1783 00 ._l2_loopvar_chrat defs 1 958 1784 00 ._l2_y_in defs 1 958 1785 00 ._l2_x_in defs 1 958 1786 00 ._l2_col_in defs 1 958 1787 00 ._l2_y_out defs 1 958 1788 00 00 ._l2_addr_work defs 2 958 178A 00 ._l2_y_work defs 1 958 178B 00 ._l2_x_work defs 1 958 178C 00 ._l2_y_work_lvl2 defs 1 958 178D 00 ._l2_x_work_lvl2 defs 1 958 178E 00 ._l2_y_work_pca defs 1 958 178F 00 ._l2_x_work_pca defs 1 958 1790 00 ._l2_y_work_pct defs 1 958 1791 00 ._l2_x_work_pct defs 1 958 1792 00 ._l2_y_work_hzl defs 1 958 1793 00 ._l2_local_save defs 1 958 1794 00 ._l2_i defs 1 958 1795 00 ._l2_length defs 1 958 1796 00 ._l2_work defs 1 958 1797 00 00 ._l2_address defs 2 958 1799 00 00 ._l2_charAddr defs 2 958 179B 00 ._l2_length_work defs 1 958 179C 00 ._l2_layer_shift defs 1 958 179D 00 00 ._l2_stepx defs 2 958 179F 00 00 ._l2_stepy defs 2 958 17A1 00 00 ._l2_fraction defs 2 958 17A3 00 00 ._l2_dy defs 2 958 17A5 00 00 ._l2_dx defs 2 958 17A7 00 00 ._l2_vx0 defs 2 958 17A9 00 00 ._l2_vy0 defs 2 958 17AB 00 00 ._l2_vx1 defs 2 958 17AD 00 00 ._l2_vy1 defs 2 958 17AF 00 00 ._l2_circle_x defs 2 958 17B1 00 00 ._l2_circle_y defs 2 958 17B3 00 00 ._l2_circle_d defs 2 958 17B5 00 ._l2_circle_doublex defs 1 958 17B6 00 ._l2_circle_doubley defs 1 958 17B7 00 ._l2_dtri_tempx1 defs 1 958 17B8 00 ._l2_dtri_tempx2 defs 1 958 17B9 00 ._l2_dtri_tempy1 defs 1 958 17BA 00 00 ._l2_dtri_newx defs 2 958 17BC 00 00 ._l2_dtri_newx1 defs 2 958 17BE 00 00 ._l2_dtri_newx2 defs 2 958 17C0 00 ._l2_dtri_workx0 defs 1 958 17C1 00 ._l2_dtri_worky0 defs 1 958 17C2 00 ._l2_dtri_workx1 defs 1 958 17C3 00 ._l2_dtri_worky1 defs 1 958 17C4 00 ._l2_dtri_workx2 defs 1 958 17C5 00 ._l2_dtri_worky2 defs 1 958 17C6 00 ._l2_dtri_workx3 defs 1 958 17C7 00 ._l2_dtri_worky3 defs 1 958 17C8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17E8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1808 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1828 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1848 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1868 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ._l2_LineMaxX defs 192 958 1888 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18A8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18C8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18E8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1908 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1928 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ._l2_LineMinX defs 192 958 1948 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1968 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1988 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ._messagebuffer defs 80 958 1998 00 00 ._l2_clipx0 defs 2 958 199A 00 00 ._l2_clipy0 defs 2 958 199C 00 00 ._l2_clipx1 defs 2 958 199E 00 00 ._l2_clipy1 defs 2 958 19A0 958 19A0
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/gfx/mac/io_surface.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/hdr_metadata.h" #include "ui/gfx/mac/io_surface_hdr_metadata.h" namespace gfx { namespace { // Check that empty NSBezierPath is returned for empty SkPath. TEST(IOSurface, HDRMetadata) { gfx::HDRMetadata in; in.mastering_metadata.primary_r = PointF(1.0, 2.0); in.mastering_metadata.primary_g = PointF(4.0, 5.0); in.mastering_metadata.primary_b = PointF(7.0, 8.0); in.mastering_metadata.white_point = PointF(10.0, 11.0); in.mastering_metadata.luminance_max = 13; in.mastering_metadata.luminance_min = 14; in.max_content_light_level = 15; in.max_frame_average_light_level = 16; base::ScopedCFTypeRef<IOSurfaceRef> io_surface( CreateIOSurface(gfx::Size(100, 100), gfx::BufferFormat::BGRA_8888)); gfx::HDRMetadata out; EXPECT_FALSE(IOSurfaceGetHDRMetadata(io_surface, out)); IOSurfaceSetHDRMetadata(io_surface, in); EXPECT_TRUE(IOSurfaceGetHDRMetadata(io_surface, out)); EXPECT_EQ(in, out); } } // namespace } // namespace gfx
; A266302: Decimal representation of the n-th iteration of the "Rule 15" elementary cellular automaton starting with a single ON (black) cell. ; 1,6,1,126,1,2046,1,32766,1,524286,1,8388606,1,134217726,1,2147483646,1,34359738366,1,549755813886,1,8796093022206,1,140737488355326,1,2251799813685246,1,36028797018963966,1 mov $1,4 mov $2,$0 mod $2,2 mov $3,$2 add $2,$0 pow $1,$2 lpb $0,1 mul $0,$3 mod $1,2 lpe div $1,10 mul $1,5 add $1,1
#pragma once template <typename K, typename V> struct TreeAbst { virtual void insert(const K& key, const V& val) = 0; virtual void erase(const K& key) = 0; virtual bool find(const K& key, V& res) = 0; };
; A239463: A239460(n) / n^2. ; 11,12,103,104,1005,1006,1007,1008,1009,10010,10011,10012,10013,10014,10015,10016,10017,10018,10019,10020,10021,100022,100023,100024,100025,100026,100027,100028,100029,100030,100031,100032,100033,100034,100035,100036,100037,100038,100039,100040,100041,100042,100043,100044,100045,100046,1000047,1000048,1000049,1000050,1000051,1000052,1000053,1000054,1000055,1000056,1000057,1000058,1000059,1000060,1000061,1000062,1000063,1000064,1000065,1000066,1000067,1000068,1000069,1000070,1000071,1000072 mov $2,$0 add $2,1 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 mov $7,2 mov $8,$0 lpb $7 mov $0,$8 sub $7,1 add $0,$7 pow $0,3 mov $6,2 lpb $0 div $0,10 mul $6,10 lpe mov $3,$6 mov $5,$7 lpb $5 sub $5,1 mov $9,$3 lpe lpe lpb $8 mov $8,0 sub $9,$3 lpe mov $3,$9 div $3,20 mul $3,10 add $3,1 add $1,$3 lpe mov $0,$1
#include <spdlog/spdlog.h> int main(int argc, char* argv[]) { auto console = spdlog::stdout_logger_mt("console"); console->info("Hello from INFO"); }
; A167527: n^5 mod 49. ; 0,1,32,47,44,38,34,0,36,4,40,37,10,20,0,22,25,33,30,31,6,0,8,46,26,23,3,41,0,43,18,19,16,24,27,0,29,39,12,9,45,13,0,15,11,5,2,17,48,0,1,32,47,44,38,34,0,36,4,40,37,10,20,0,22,25,33,30,31,6,0,8,46,26,23,3 pow $0,5 mod $0,49
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and University of // of Connecticut School of Medicine. // All rights reserved. // Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and The University // of Manchester. // All rights reserved. // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., EML Research, gGmbH, University of Heidelberg, // and The University of Manchester. // All rights reserved. // Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc. and EML Research, gGmbH. // All rights reserved. #include "copasi.h" #include "CEvaluationNode.h" #include "sbml/math/ASTNode.h" #include "sbml/ConverterASTNode.h" #include "sbml/util/List.h" #include "utilities/CNodeIterator.h" #include "utilities/CValidatedUnit.h" // static const CEnumAnnotation< std::string, CEvaluationNode::MainType > CEvaluationNode::MainTypeName( { "INVALID", "NUMBER", "CONSTANT", "OPERATOR", "OBJECT", "FUNCTION", "CALL", "STRUCTURE", "CHOICE", "VARIABLE", "WHITESPACE", "LOGICAL", "MV_FUNCTION", // This not yet implemented "VECTOR", "DELAY", "UNIT" }); // static const CEnumAnnotation< std::string, CEvaluationNode::SubType > CEvaluationNode::SubTypeName( { "Abs", "And", "Arccos", "Arccosh", "Arccot", "Arccoth", "Arccsc", "Arccsch", "Arcsec", "Arcsech", "Arcsin", "Arcsinh", "Arctan", "Arctanh", "Avogadro", "CN", "Ceil", "Close", "Comma", "Cos", "Cosh", "Cot", "Coth", "Csc", "Csch", "Default", "Delay", "Divide", "Double", "Enotation", "Eq", "Exp", "Exponentiale", "Expression", "Factorial", "False", "Floor", "Function", "Ge", "Gt", "If", "Infinity", "Integer", "Invalid", "Le", "Log", "Log10", "Lt", "Max", "Min", "Minus", "Modulus", "Multiply", "NaN", "Ne", "Not", "Open", "Or", "Pi", "Plus", "Pointer", "Power", "Rationale", "Remainder", "Rgamma", "Rnormal", "Rpoisson", "Runiform", "Sec", "Sech", "Sign", "Sin", "Sinh", "Sqrt", "Tan", "Tanh", "True", "Vector", "VectorClose", "VectorOpen", "Xor", }); CEvaluationNode::CPrecedence::CPrecedence(const size_t & left, const size_t & right): left(left), right(right) {} CEvaluationNode::CPrecedence::CPrecedence(const CPrecedence & src): left(src.left), right(src.right) {} CEvaluationNode::CPrecedence::~CPrecedence() {} CEvaluationNode * CEvaluationNode::create(const CEvaluationNode::MainType & mainType, const CEvaluationNode::SubType & subType, const std::string & data) { CEvaluationNode * pNode = NULL; switch (mainType) { case MainType::CALL: pNode = new CEvaluationNodeCall(subType, data); break; case MainType::CHOICE: pNode = new CEvaluationNodeChoice(subType, data); break; case MainType::CONSTANT: pNode = new CEvaluationNodeConstant(subType, data); break; case MainType::DELAY: pNode = new CEvaluationNodeDelay(subType, data); break; case MainType::FUNCTION: pNode = new CEvaluationNodeFunction(subType, data); break; case MainType::LOGICAL: pNode = new CEvaluationNodeLogical(subType, data); break; case MainType::NUMBER: pNode = new CEvaluationNodeNumber(subType, data); break; case MainType::OBJECT: pNode = new CEvaluationNodeObject(subType, data); break; case MainType::OPERATOR: pNode = new CEvaluationNodeOperator(subType, data); break; case MainType::STRUCTURE: pNode = new CEvaluationNodeStructure(subType, data); break; case MainType::VARIABLE: pNode = new CEvaluationNodeVariable(subType, data); break; case MainType::VECTOR: pNode = new CEvaluationNodeVector(subType, data); break; case MainType::WHITESPACE: pNode = new CEvaluationNodeWhiteSpace(subType, data); break; case MainType::UNIT: pNode = new CEvaluationNodeUnit(subType, data); break; case MainType::INVALID: pNode = new CEvaluationNode(); break; case MainType::MV_FUNCTION: break; case MainType::__SIZE: break; } return pNode; } const CEvaluationNode::SubType & CEvaluationNode::subType() const { return mSubType; } const CEvaluationNode::MainType & CEvaluationNode::mainType() const { return mMainType; } // static const char * CEvaluationNode::Keywords[] = { "log", "LOG", "log10", "LOG10", "exp", "EXP", "sin", "SIN", "cos", "COS", "tan", "TAN", "sec", "SEC", "csc", "CSC", "cot", "COT", "sinh", "SINH", "cosh", "COSH", "tanh", "TANH", "sech", "SECH", "csch", "CSCH", "coth", "COTH", "asin", "ASIN", "acos", "ACOS", "atan", "ATAN", "arcsec", "ARCSEC", "arccsc", "ARCCSC", "arccot", "ARCCOT", "arcsinh", "ARCSINH", "arccosh", "ARCCOSH", "arctanh", "ARCTANH", "arcsech", "ARCSECH", "arccsch", "ARCCSCH", "arccoth", "ARCCOTH", "sqrt", "SQRT", "sign", "SIGN", "abs", "ABS", "floor", "FLOOR", "ceil", "CEIL", "factorial", "FACTORIAL", "uniform", "UNIFORM", "normal", "NORMAL", "gamma", "GAMMA", "poisson", "POISSON", "max", "MAX", "min", "MIN", "delay", "DELAY", "if", "IF", NULL }; // static bool CEvaluationNode::isKeyword(const std::string & str) { const char ** pKeyword = Keywords; for (; *pKeyword != NULL; ++pKeyword) if (!strcmp(str.c_str(), *pKeyword)) return true; return false; } CEvaluationNode::CEvaluationNode(): CCopasiNode<Data>(""), mMainType(MainType::INVALID), mSubType(SubType::INVALID), mValueType(ValueType::Unknown), mValue(std::numeric_limits<C_FLOAT64>::quiet_NaN()), mpValue(NULL), mPrecedence(PRECEDENCE_DEFAULT) { mpValue = & mValue; } CEvaluationNode::CEvaluationNode(const MainType & mainType, const SubType & subType, const Data & data): CCopasiNode<Data>(data), mMainType(mainType), mSubType(subType), mValueType(ValueType::Unknown), mValue(std::numeric_limits<C_FLOAT64>::quiet_NaN()), mpValue(NULL), mPrecedence(PRECEDENCE_DEFAULT) { mpValue = & mValue; } CEvaluationNode::CEvaluationNode(const CEvaluationNode & src): CCopasiNode<Data>(src), mMainType(src.mMainType), mSubType(src.mSubType), mValueType(src.mValueType), mValue(src.mValue), mpValue(NULL), mPrecedence(src.mPrecedence) { mpValue = & mValue; } CEvaluationNode::~CEvaluationNode() {} CIssue CEvaluationNode::compile(const CEvaluationTree * /* pTree */) {return CIssue::Success;} // virtual std::string CEvaluationNode::getInfix(const std::vector< std::string > & /* children */) const {return mData;} std::string CEvaluationNode::buildInfix() const { std::string Infix = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getInfix(it.context())); } else { Infix = it->getInfix(it.context()); } } } return Infix; } // virtual std::string CEvaluationNode::getDisplayString(const std::vector< std::string > & /* children */) const {return mData;} std::string CEvaluationNode::buildDisplayString() const { std::string DisplayString = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getDisplayString(it.context())); } else { DisplayString = it->getDisplayString(it.context()); } } } return DisplayString; } // virtual std::string CEvaluationNode::getCCodeString(const std::vector< std::string > & /* children */) const {return mData;} /** * Build the C-code string. */ std::string CEvaluationNode::buildCCodeString() const { std::string CCodeString = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getCCodeString(it.context())); } else { CCodeString = it->getCCodeString(it.context()); } } } return CCodeString; } // virtual std::string CEvaluationNode::getBerkeleyMadonnaString(const std::vector< std::string > & /* children */) const {return mData;} std::string CEvaluationNode::buildBerkeleyMadonnaString() const { std::string BerkeleyMadonnaString = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getBerkeleyMadonnaString(it.context())); } else { BerkeleyMadonnaString = it->getBerkeleyMadonnaString(it.context()); } } } return BerkeleyMadonnaString; } // virtual std::string CEvaluationNode::getXPPString(const std::vector< std::string > & /* children */) const {return mData;} std::string CEvaluationNode::buildXPPString() const { std::string BerkeleyMadonnaString = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getXPPString(it.context())); } else { BerkeleyMadonnaString = it->getXPPString(it.context()); } } } return BerkeleyMadonnaString; } // virtual bool CEvaluationNode::isBoolean() const { return mValueType == ValueType::Boolean; } // virtual CIssue CEvaluationNode::setValueType(const CEvaluationNode::ValueType & valueType) { if (mValueType != valueType) return CIssue(CIssue::eSeverity::Error, CIssue::eKind::ValueTypeMismatch); return CIssue::Success; } const CEvaluationNode::ValueType & CEvaluationNode::getValueType() const { return mValueType; } void CEvaluationNode::addChildren(const std::vector< CEvaluationNode * > & children) { std::vector< CEvaluationNode * >::const_iterator it = children.begin(); std::vector< CEvaluationNode * >::const_iterator end = children.end(); for (; it != end; ++it) { addChild(*it); } } bool CEvaluationNode::operator < (const CEvaluationNode & rhs) {return (mPrecedence.right < rhs.mPrecedence.left);} CEvaluationNode* CEvaluationNode::copyNode(CEvaluationNode* child1, CEvaluationNode* child2) const { std::vector<CEvaluationNode*> children; if (child1 != NULL) children.push_back(child1); if (child2 != NULL) children.push_back(child2); return copyNode(children); } CEvaluationNode* CEvaluationNode::copyNode(const std::vector<CEvaluationNode*>& children) const { CEvaluationNode * pNode = create(mMainType, mSubType, getData()); std::vector<CEvaluationNode*>::const_iterator it = children.begin(); std::vector<CEvaluationNode*>::const_iterator endit = children.end(); while (it != endit) { pNode->addChild(*it); ++it; } return pNode; } CEvaluationNode * CEvaluationNode::copyBranch() const { CEvaluationNode * pNode = NULL; CNodeContextIterator< const CEvaluationNode, std::vector< CEvaluationNode * > > itNode(this); while (itNode.next() != itNode.end()) { if (*itNode == NULL) { continue; } if (itNode.parentContextPtr() != NULL) { itNode.parentContextPtr()->push_back(itNode->copyNode(itNode.context())); } else { assert(*itNode == this); pNode = itNode->copyNode(itNode.context()); } } return pNode; } CEvaluationNode* CEvaluationNode::simplifyNode(const std::vector<CEvaluationNode*>& children) const { CEvaluationNode *newnode = copyNode(children); return newnode; } ASTNode* CEvaluationNode::toAST(const CDataModel* /*pDataModel*/) const { return new ASTNode(); } const C_FLOAT64 * CEvaluationNode::getValuePointer() const {return mpValue;} // virtual std::string CEvaluationNode::getMMLString(const std::vector< std::string > & /* children */, bool /* expand */, const std::vector< std::vector< std::string > > & /* variables */) const { return ""; } std::string CEvaluationNode::buildMMLString(bool expand, const std::vector< std::vector< std::string > > & variables) const { std::string MMLString = ""; CNodeContextIterator< const CEvaluationNode, std::vector< std::string > > it(this); while (it.next() != it.end()) { if (*it != NULL) { if (it.parentContextPtr() != NULL) { it.parentContextPtr()->push_back(it->getMMLString(it.context(), expand, variables)); } else { MMLString = it->getMMLString(it.context(), expand, variables); } } } return MMLString; } // TODO Replace the recursive call (not critical since only used for debug) void CEvaluationNode::printRecursively(std::ostream & os, int indent) const { int i; os << std::endl; for (i = 0; i < indent; ++i) os << " "; os << "mData: " << mData << std::endl; for (i = 0; i < indent; ++i) os << " "; os << "mType: " << CEvaluationNode::MainTypeName[mMainType] << " subType: " << CEvaluationNode::SubTypeName[mSubType] << std::endl; for (i = 0; i < indent; ++i) os << " "; os << "mValue: " << mValue << std::endl; CEvaluationNode* tmp; tmp = (CEvaluationNode*)getChild(); while (tmp) { tmp -> printRecursively(os, indent + 2); tmp = (CEvaluationNode*)tmp->getSibling(); } } void CEvaluationNode::printRecursively() const { this->printRecursively(std::cout, 0); } CEvaluationNode* CEvaluationNode::splitBranch(const CEvaluationNode* splitnode, bool left) const { if (splitnode == this) { const CEvaluationNode *child = dynamic_cast<const CEvaluationNode*>(this->getChild()); if (!child) return NULL; if (left) { return child->copyBranch(); } else { child = dynamic_cast<const CEvaluationNode*>(child->getSibling()); if (!child) return NULL; return child->copyBranch(); } } else { /* const CEvaluationNode *child1 = dynamic_cast<const CEvaluationNode*>(getChild()); CEvaluationNode *newchild1 = NULL; CEvaluationNode *newchild2 = NULL; if (child1 != NULL) { newchild1 = child1->splitBranch(splitnode, left); const CEvaluationNode *child2 = dynamic_cast<const CEvaluationNode*>(child1->getSibling()); if (child2 != NULL) { newchild2 = child2->splitBranch(splitnode, left); } } CEvaluationNode *newnode = copyNode(newchild1, newchild2); return newnode;*/ std::vector<CEvaluationNode*> children; const CEvaluationNode* child = dynamic_cast<const CEvaluationNode*>(getChild()); while (child != NULL) { CEvaluationNode *newchild = NULL; newchild = child->splitBranch(splitnode, left); children.push_back(newchild); child = dynamic_cast<const CEvaluationNode*>(child->getSibling()); } children.push_back(NULL); CEvaluationNode *newnode = copyNode(children); return newnode; } } const CEvaluationNode * CEvaluationNode::findTopMinus(const std::vector<CFunctionAnalyzer::CValue> & callParameters) const { CNodeContextIterator< const CEvaluationNode, std::vector< const CEvaluationNode * > > itNode(this); itNode.setProcessingModes(CNodeIteratorMode::Flag(CNodeIteratorMode::Before) | CNodeIteratorMode::After); const CEvaluationNode * pMinus = NULL; while (itNode.next() != itNode.end()) { if (*itNode == NULL) { continue; } switch (itNode.processingMode()) { case CNodeIteratorMode::Before: if (itNode->mainType() == MainType::OPERATOR && itNode->subType() == CEvaluationNode::SubType::MINUS) { // We found a minus no need to go down the tree. itNode.skipChildren(); pMinus = *itNode; if (itNode.parentContextPtr() != NULL) { itNode.parentContextPtr()->push_back(pMinus); } } break; case CNodeIteratorMode::After: if (itNode->mainType() == MainType::OPERATOR && itNode->subType() == CEvaluationNode::SubType::MULTIPLY) { // Left child if (itNode.context()[0] != NULL) { // Both children contain a minus, this is not a valid split point. if (itNode.context()[1] != NULL) { pMinus = NULL; } // Check whether the right is positive else if (CFunctionAnalyzer::evaluateNode(static_cast< const CEvaluationNode *>(itNode->getChild(1)), callParameters, CFunctionAnalyzer::NOOBJECT).isPositive()) { pMinus = itNode.context()[0]; } else { pMinus = NULL; } } // Right child else if (itNode.context()[1] != NULL) { // Check whether the left is positive if (CFunctionAnalyzer::evaluateNode(static_cast< const CEvaluationNode *>(itNode->getChild(0)), callParameters, CFunctionAnalyzer::NOOBJECT).isPositive()) pMinus = itNode.context()[1]; else pMinus = NULL; } else { pMinus = NULL; } } else if (itNode->mainType() == MainType::OPERATOR && itNode->subType() == CEvaluationNode::SubType::DIVIDE) { // Left child pMinus = itNode.context()[0]; } else { pMinus = NULL; } if (itNode.parentContextPtr() != NULL) { itNode.parentContextPtr()->push_back(pMinus); } break; default: // This will never happen break; } } return pMinus; } bool CEvaluationNode::operator!=(const CEvaluationNode& right) const { return !(*this == right); } bool CEvaluationNode::operator==(const CEvaluationNode& right) const { CNodeIterator< const CEvaluationNode > itLeft(this); CNodeIterator< const CEvaluationNode > itRight(&right); while (itLeft.next() != itLeft.end() && itRight.next() != itRight.end()) { if (*itLeft == NULL && *itRight == NULL) { continue; } if (*itLeft == NULL || *itRight == NULL) { return false; } if (itLeft->mainType() != itRight->mainType() || itLeft->subType() != itRight->subType() || itLeft->getData() != itRight->getData()) { return false; } } return true; } bool CEvaluationNode::operator<(const CEvaluationNode& right) const { if (mainType() != right.mainType()) { return mainType() < right.mainType(); } if (subType() != right.subType()) { return subType() < right.subType(); } switch (mainType()) { case MainType::CONSTANT: case MainType::NUMBER: case MainType::OBJECT: case MainType::CALL: case MainType::STRUCTURE: case MainType::VARIABLE: case MainType::WHITESPACE: return getData() < right.getData(); break; case MainType::OPERATOR: case MainType::FUNCTION: case MainType::CHOICE: case MainType::LOGICAL: case MainType::MV_FUNCTION: case MainType::VECTOR: case MainType::DELAY: case MainType::INVALID: break; case MainType::__SIZE: break; } const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(this->getChild()); const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(right.getChild()); while (true) { if (pChild1 == NULL || pChild2 == NULL) { return pChild1 < pChild2; } if (*pChild1 < *pChild2) return true; pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling()); pChild2 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling()); } return false; } //virtual CValidatedUnit CEvaluationNode::getUnit(const CMathContainer & /* math */, const std::vector< CValidatedUnit > & /*units*/) const { return CValidatedUnit(CBaseUnit::dimensionless, false); } // virtual CValidatedUnit CEvaluationNode::setUnit(const CMathContainer & /* container */, const std::map < CEvaluationNode * , CValidatedUnit > & currentUnits, std::map < CEvaluationNode * , CValidatedUnit > & targetUnits) const { std::map < CEvaluationNode * , CValidatedUnit >::const_iterator itTargetUnit = targetUnits.find(const_cast< CEvaluationNode * >(this)); std::map < CEvaluationNode * , CValidatedUnit >::const_iterator itCurrentUnit = currentUnits.find(const_cast< CEvaluationNode * >(this)); CValidatedUnit Result(CValidatedUnit::merge(itTargetUnit->second, itCurrentUnit->second)); if (Result.conflict() && (itCurrentUnit->second.isUndefined() || (getChild() != NULL && itTargetUnit->second == itCurrentUnit->second))) { Result.setConflict(false); } return Result; }
INCLUDE "config_private.inc" SECTION code_driver SECTION code_driver_terminal_input PUBLIC console_01_input_proc_getc EXTERN console_01_input_proc_echo, l_setmem_hl, asm_b_array_clear EXTERN console_01_input_proc_oterm, l_inc_sp, l_jpix, l_offset_ix_de EXTERN asm_b_array_push_back, asm_b_array_at, asm_toupper, error_zc, error_mc EXTERN device_return_error, device_set_error console_01_input_proc_getc: ; enter : ix = & FDSTRUCT.JP ; ; exit : success ; ; a = hl = char ; carry reset ; ; fail ; ; hl = 0 on stream error, -1 on eof ; carry set ; ; uses : af, hl push bc push de call getc pop de pop bc ret c ; if error ld l,a ld h,0 ; a = hl = char ret getc: bit 5,(ix+6) jr nz, line_mode char_mode: call state_machine_0 ; get char from device ret c ; if driver error push af ; save char call console_01_input_proc_echo ; output to terminal pop af ; a = char ret line_mode: ; try to get char from edit buffer ld hl,17 call l_offset_ix_de ; hl = & FDSTRUCT.read_index ld c,(hl) inc hl ld b,(hl) ; bc = read_index inc hl ; hl = & FDSTRUCT.b_array ; bc = read_index ; hl = & FDSTRUCT.b_array ld a,(hl) ; examine b_array.data inc hl or (hl) dec hl jr z, char_mode ; if edit buffer does not exist bit 6,(ix+7) jr nz, line_mode_readline ; if ioctl pushed edit buffer call line_mode_editbuf_1 ret nc ; if char retrieved from edit buffer line_mode_readline: ; hl = & FDSTRUCT.b_array dec hl dec hl ; hl = & FDSTRUCT.read_index xor a call l_setmem_hl - 4 ; FDSTRUCT.read_index = 0 push hl ; save b_array * ld a,ITERM_MSG_READLINE_BEGIN call console_01_input_proc_oterm ; inform output terminal that new line is starting pop hl ; hl = b_array * push hl bit 6,(ix+7) jr z, line_mode_readline_1 res 6,(ix+7) ; ioctl pushed edit buffer into terminal ; need to echo buffer chars to output terminal ld e,(hl) inc hl ld d,(hl) ; de = b_array.data inc hl ld c,(hl) inc hl ld b,(hl) ; bc = b_array.size ex de,hl push_loop: ld a,b or c jr z, readline_loop ld a,(hl) cp CHAR_LF jr nz, put_raw_0 ld a,'?' ; changed escaped LF to '?' put_raw_0: push bc push hl call console_01_input_proc_echo ; send char to output terminal pop hl pop bc inc hl dec bc jr push_loop line_mode_readline_1: call asm_b_array_clear ; empty the edit buffer readline_loop: ; stack = & FDSTRUCT.b_array ; print cursor ld a,(ix+6) ; a = ioctl_f0 flags add a,a jr nc, cursor_print_end ; if echo off bit 1,(ix+7) jr z, cursor_print_end ; if no cursor ld c,CHAR_CURSOR_LC and $30 ; isolate cook and caps flags cp $30 jr nz, cursor_print ; if !cook || !caps ld c,CHAR_CURSOR_UC cursor_print: ld a,ITERM_MSG_PRINT_CURSOR call console_01_input_proc_oterm ; instruct output terminal to print cursor cursor_print_end: ; read char from device ; stack = & FDSTRUCT.b_array call state_machine_0 ; a = next char ; erase cursor bit 7,(ix+6) jr z, cursor_erase_end ; if echo off bit 1,(ix+7) jr z, cursor_erase_end ; if no cursor pop hl push hl ; hl = & FDSTRUCT.b_array push af call edit_buff_params ; de = char *edit_buffer, bc = int edit_buffer_len ld a,ITERM_MSG_ERASE_CURSOR bit 6,(ix+6) jr z, cursor_not_pwd ; if not password mode ld a,ITERM_MSG_ERASE_CURSOR_PWD ld e,CHAR_PASSWORD cursor_not_pwd: call console_01_input_proc_oterm ; instruct output terminal to erase cursor pop af cursor_erase_end: ; process char ; a = char (carry on error with hl = 0 or -1) ; stack = & FDSTRUCT.b_array jr c, readline_error ; if device reports error bit 7,(ix+7) jr nz, escaped_char ; if this is an escaped char cp CHAR_CAPS jr z, readline_loop ; change cursor cp CHAR_BS jr nz, escaped_char ; if not backspace ; backspace ; stack = & FDSTRUCT.b_array pop hl push hl call edit_buff_params ; de = b_array.data ; bc = b_array.size ; stack = & FDSTRUCT.b_array ld a,b or c jr nz, not_empty ; if edit buffer is not empty ; cannot backspace bell: ld a,ITERM_MSG_BELL call console_01_input_proc_oterm ; send to output terminal jr readline_loop not_empty: bit 7,(ix+6) jr z, skip_bs ; if echo off push bc ; save b_array.size ld a,ITERM_MSG_BS bit 6,(ix+6) jr z, not_password_mode ld a,ITERM_MSG_BS_PWD ld e,CHAR_PASSWORD not_password_mode: call console_01_input_proc_oterm ; instruct output terminal to backspace pop bc ; bc = b_array.size skip_bs: pop hl push hl inc hl inc hl ; hl = & b_array.size dec bc ; b_array.size -- ld (hl),c inc hl ld (hl),b ; erase last char of edit buffer jp readline_loop escaped_char: ; a = char ; stack = & FDSTRUCT.b_array ; first check if char is rejected by driver ld c,a push bc ld a,ITERM_MSG_REJECT call l_jpix pop bc jr nc, bell ; if terminal rejected the char ; append char to edit buffer ; c = char ; stack = & FDSTRUCT.b_array pop hl push hl call asm_b_array_push_back ; append char to edit buffer jr c, bell ; if failed because buffer is full ; c = char ; stack = & FDSTRUCT.b_array ld a,c bit 7,(ix+7) jr z, put_raw ; if not an escaped char cp CHAR_LF jr nz, put_raw ld a,'?' ; changed escaped LF to '?' put_raw: push af ld c,a ld a,ITERM_MSG_INTERRUPT call l_jpix pop bc jr nc, interrupt_received ld a,b push af call console_01_input_proc_echo ; send char to output terminal pop af ; a = char cp CHAR_LF jp nz, readline_loop readline_done: readline_error: ; return a char from the edit buffer ; hl = 0 or -1 if error ; stack = & FDSTRUCT.b_array push hl ld a,ITERM_MSG_READLINE_END call console_01_input_proc_oterm ; inform output terminal that editing is done pop hl ex (sp),hl ; hl = & FDSTRUCT.b_array ld bc,0 ; read_index = 0 call line_mode_editbuf_1 jp nc, l_inc_sp - 2 ; if char successfully retrieved from buffer pop hl ; hl = 0 or -1 ret interrupt_received: set 0,(ix+6) ; place device in error state jr readline_done edit_buff_params: ; hl = & FDSTRUCT.b_array ld e,(hl) inc hl ld d,(hl) ; de = b_array.data inc hl ld c,(hl) inc hl ld b,(hl) ; bc = b_array.size ret line_mode_editbuf_1: ; enter : bc = read_index ; hl = & FDSTRUCT.b_array ; ; exit : success char available ; ; a = char from edit buffer ; carry reset ; ; fail no char in edit buffer ; ; hl = & FDSTRUCT.b_array ; carry set push hl ; save & FDSTRUCT.b_array call asm_b_array_at ; read char in edit buffer at index bc ld a,l ; a = char from edit buffer pop hl ; hl = & FDSTRUCT.b_array ret c ; if char not available inc bc ; read_index ++ dec hl ld (hl),b dec hl ld (hl),c ; store new read_index ret state_machine_0: ; return char in A or carry set with hl = 0 or -1 on driver error res 7,(ix+7) ; clear escaped char indicator ld a,(ix+16) ; a = pending char or a jr z, state_machine_1 ; if no pending char ld (ix+16),0 ; clear pending char jr state_machine_2 ; process pending char state_machine_1: ld a,(ix+6) and $03 ; check device state jp nz, device_return_error ld a,ITERM_MSG_GETC call l_jpix ; get char from device jp c, device_set_error state_machine_2: cp CHAR_CR jr nz, not_cr bit 0,(ix+7) ret z ; if not doing crlf conversion jr state_machine_1 ; reject CR not_cr: or a ; indicate no error bit 4,(ix+6) ret z ; if cook mode disabled sm_cook: cp CHAR_CAPS jr z, sm_capslock cp CHAR_ESC jr z, sm_escape ; regular character bit 3,(ix+6) call nz, asm_toupper ; if caps lock active or a ; indicate no error ret sm_capslock: ld a,(ix+6) xor $08 ; toggle caps lock bit ld (ix+6),a and $20 jr z, state_machine_1 ; read another if char mode ld a,CHAR_CAPS ret sm_escape: ld a,ITERM_MSG_GETC call l_jpix ; get char from device set 7,(ix+7) ; indicate an escaped char ret nc ; return raw char if no error sm_esc_exit: ld a,CHAR_ESC ; store ESC as pending char ; fall through to sm_exit sm_exit: ; stateful exit ld (ix+16),a ; store pending char ret
/*========================================================================= Program: GDCM (Grassroots DICOM). A DICOM library Copyright (c) 2006-2011 Mathieu Malaterre All rights reserved. See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "gdcmPixmap.h" namespace gdcm { /* * PICKER-16-MONO2-Nested_icon.dcm: (0088,0200) SQ (Sequence with undefined length #=1) # u/l, 1 PixmapSequence (fffe,e000) na (Item with undefined length #=10) # u/l, 1 Item (0028,0002) US 1 # 2, 1 SamplesPerPixel (0028,0004) CS [MONOCHROME2] # 12, 1 PhotometricInterpretation (0028,0010) US 64 # 2, 1 Rows (0028,0011) US 64 # 2, 1 Columns (0028,0034) IS [1\1] # 4, 2 PixelAspectRatio (0028,0100) US 8 # 2, 1 BitsAllocated (0028,0101) US 8 # 2, 1 BitsStored (0028,0102) US 7 # 2, 1 HighBit (0028,0103) US 0 # 2, 1 PixelRepresentation (7fe0,0010) OW 0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000... # 4096, 1 PixelData (fffe,e00d) na (ItemDelimitationItem) # 0, 0 ItemDelimitationItem (fffe,e0dd) na (SequenceDelimitationItem) # 0, 0 SequenceDelimitationItem */ Pixmap::Pixmap():Overlays(),Curves(),Icon(new IconImage) {} Pixmap::~Pixmap() {} bool Pixmap::AreOverlaysInPixelData() const { int total = 0; std::vector<Overlay>::const_iterator it = Overlays.begin(); for(; it != Overlays.end(); ++it) { total += (int)it->IsInPixelData(); } assert( total == (int)GetNumberOfOverlays() || !total ); return total != 0; } void Pixmap::Print(std::ostream &os) const { Bitmap::Print(os); for( std::vector<Overlay>::const_iterator it = Overlays.begin(); it != Overlays.end(); ++it) { it->Print( os ); } for( std::vector<Curve>::const_iterator it = Curves.begin(); it != Curves.end(); ++it) { it->Print( os ); } } }
#include "Interface/HLE/Syscalls.h" #include <stddef.h> #include <stdint.h> #include <signal.h> #include <time.h> namespace FEXCore::Core { struct InternalThreadState; } namespace FEXCore::HLE { uint64_t Timer_Create(FEXCore::Core::InternalThreadState *Thread, clockid_t clockid, struct sigevent *sevp, timer_t *timerid) { uint64_t Result = ::timer_create(clockid, sevp, timerid); SYSCALL_ERRNO(); } uint64_t Timer_Settime(FEXCore::Core::InternalThreadState *Thread, timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { uint64_t Result = ::timer_settime(timerid, flags, new_value, old_value); SYSCALL_ERRNO(); } uint64_t Timer_Gettime(FEXCore::Core::InternalThreadState *Thread, timer_t timerid, struct itimerspec *curr_value) { uint64_t Result = ::timer_gettime(timerid, curr_value); SYSCALL_ERRNO(); } uint64_t Timer_Getoverrun(FEXCore::Core::InternalThreadState *Thread, timer_t timerid) { uint64_t Result = ::timer_getoverrun(timerid); SYSCALL_ERRNO(); } uint64_t Timer_Delete(FEXCore::Core::InternalThreadState *Thread, timer_t timerid) { uint64_t Result = ::timer_delete(timerid); SYSCALL_ERRNO(); } }
; ba_priority_queue_t * ; ba_priority_queue_init(void *p, void *data, size_t capacity, int (*compar)(const void *, const void *)) SECTION code_adt_ba_priority_queue PUBLIC _ba_priority_queue_init EXTERN l0_ba_priority_queue_init_callee _ba_priority_queue_init: pop af pop hl pop de pop bc exx pop bc push bc push bc push de push hl push af jp l0_ba_priority_queue_init_callee
[org 0x7c00] KERNEL_OFFSET equ 0x1000 ; The same one we used when linking the kernel mov [BOOT_DRIVE], dl ; Remember that the BIOS sets us the boot drive in 'dl' on boot mov bp, 0x9000 mov sp, bp mov bx, MSG_REAL_MODE call print_string call print_nl call load_kernel ; read the kernel from disk call switch_to_pm ; disable interrupts, load GDT, etc. Finally jumps to 'BEGIN_PM' jmp $ ; Never executed %include "08_disk_read.asm" %include "10_32bit_protected_mode.asm" [bits 16] load_kernel: mov bx, MSG_LOAD_KERNEL call print_string call print_nl mov bx, KERNEL_OFFSET ; Read from disk and store in 0x1000 mov dh, 2 mov dl, [BOOT_DRIVE] call disk_load ret [bits 32] BEGIN_PM: mov ebx, MSG_PROT_MODE call print_string call KERNEL_OFFSET ; Give control to the kernel jmp $ ; Stay here when the kernel returns control to us (if ever) BOOT_DRIVE db 0 ; It is a good idea to store it in memory because 'dl' may get overwritten MSG_LOAD_KERNEL db "Loading kernel into memory", 0 ; Bootsector padding times 510-($-$$) db 0 dw 0xaa55
/* * Logger I2C Output Service * * org: 11/17/2014 * auth: Nels "Chip" Pearson * * Target: Tank Bot Demo Board, 20MHz, ATmega164P * * Logger: LCD_CDM-16100 Demo board with a five line 1x16 character display. * * This service is used to output debugging text to an I2C Logger device. * * A table of predefined labels are provided. * * Dependentcies * i2c_master.asm * */ // Avaliable Loggers .equ LCD_CDM_16100_DEMO = 0x25 // Logger Slave Address .equ SLAVE_ADDRESS = LCD_CDM_16100_DEMO // Define a data buffer. .equ I2C_BUFF_OUT_SIZE = 16 ; write Slave data from here. .DSEG log_buffer: .BYTE I2C_BUFF_OUT_SIZE ; Text output buffer. log_out_count: .BYTE 1 ; number of bytes in buffer. log_buffer_XH: .BYTE 1 ; running pointer into buffer. log_buffer_XL: .BYTE 1 .CSEG /* * Clear the output buffer and prepare for next message. * */ logger_clear_buffer: ldi r16, LOW(log_buffer) sts log_buffer_XL, r16 ldi r16, HIGH(log_buffer) sts log_buffer_XH, r16 clr r16 sts log_out_count, r16 ret /* * Send Output Buffer to Slave * */ logger_send: ldi r17, SLAVE_ADDRESS lds r18, log_out_count ; get number of bytes to send. ldi XL, LOW(log_buffer) ldi XH, HIGH(log_buffer) call i2c_write ret /* * Append Byte as 2 Char HEX ASCII bytes to Output Buffer * * input: R17 - 8bit Data * * This function will convert the data into two ASCII HEX character and * try to append them to the log_buffer and adjust the log_out_count value. * A running limit check is made to prevent overflowing the buffer. * */ logger_append_byte_text: lds r18, log_out_count lds XL, log_buffer_XL lds XH, log_buffer_XH // Check for room in the buffer cpi r18, I2C_BUFF_OUT_SIZE-1 brge labt_exit ; No room ; add MSB character mov r16, r17 andi r16, 0xF0 swap r16 call con_4bit2hex ; returns r16=HEX ASCII ; append to the buffer st X+, r16 inc r18 // Check for room in the buffer cpi r18, I2C_BUFF_OUT_SIZE-1 brge labt_exit ; No room ; add LSB character mov r16, r17 andi r16, 0x0F call con_4bit2hex ; returns r16=HEX ASCII ; append to the buffer st X+, r16 inc r18 ; labt_exit: sts log_out_count, r18 ; update sts log_buffer_XL, XL sts log_buffer_XH, XH ret /* * Append SRAM Text to Output Buffer * * input: Z - pointer to text in SRAM * R17 - Number of bytes to copy * * This function will append text to the log_buffer and adjust the * log_out_count value. * A running limit check is made to prevent overflowing the buffer. * * This function can be used to send non-ASCII values to the logger for * control functions if they are supported. * */ logger_append_sram_text: lds r16, log_out_count lds XL, log_buffer_XL lds XH, log_buffer_XH last_loop00: // Check for room in the buffer cpi r16, I2C_BUFF_OUT_SIZE-1 brge last_exit ; No room ; next character ld r18, Z+ ; get char tst r18 breq last_exit ; NULL..Done ; append to the buffer st X+, r18 inc r16 dec r17 brne last_loop00 ; last_exit: sts log_out_count, r16 ; update sts log_buffer_XL, XL sts log_buffer_XH, XH ret /* * Append Flash Text to Output Buffer * * input: Z - pointer to text in Flash. Text string is NULL terminated. * * This function will append text to the log_buffer and adjust the * log_out_count value. * A running limit check is made to prevent overflowing the buffer. * */ logger_append_flash_text: // Adjust address to 16bit (FlashAdrs<<1) lsl ZL rol ZH ; lds r16, log_out_count lds XL, log_buffer_XL lds XH, log_buffer_XH laft_loop00: // Check for room in the buffer cpi r16, I2C_BUFF_OUT_SIZE-1 brge laft_exit ; No room ; next character lpm r17, Z+ ; get char tst r17 breq laft_exit ; NULL..Done ; append to the buffer st X+, r17 inc r16 rjmp laft_loop00 ; laft_exit: sts log_out_count, r16 ; update sts log_buffer_XL, XL sts log_buffer_XH, XH ret // Preformatted Text .. NULL terminated. Must be MOD 2 in length. LOG_TEXT_BREAK_POINT: .db 'B','P',':',0 LOG_TEXT_SPACE: .db ' ',0 TANK_BOT_ALIVE: .db 'T','A','N','K',' ','B','O','T',0,0 log_text04: .db 'L','i','n','e',':','4',' ',' ',0,0 log_text05: .db 'L','i','n','e',':','0','0','5',0,0
; Floppy drive interface routines datasector dw 0x0000 cluster dw 0x0000 absoluteSector db 0x00 absoluteHead db 0x00 absoluteTrack db 0x00 ; Convert Cluster number to Linear-Block-Addressing (LBA) ; ; LBA = First data sector + (cluster - 2) * sectors per cluster ; ; Input: AX = Cluster number ; Output: AX = LBA value ClusterToLBA: sub ax, 2 ; Convert cluster number to zero-based movzx cx, byte [bpbSectorsPerCluster] ; Get sectors per cluster into CX mul cx add ax, word [datasector] ; Add the start of the data sectors for the disk. ret ; Convert Linear-Block-Addressing (LBA) to Cylinder-Head-Sector (CHS) address ; ; Input: AX = LBA Address to convert ; Output: ; CL = Absolute sector = (LBA address / sectors per track) + 1 (We add one since the sectors start from 0) ; DH = Absolute head = (LBA address / sectors per track) MOD number of heads ; CH = Absolute track = LBA address / (sectors per track * number of heads) LBAToCHS: xor dx, dx ; Divide by sectors per track div word [bpbSectorsPerTrack] ; DIV leaves result in AX and remainder in DX inc dl mov cl, dl xor dx, dx div word [bpbHeadsPerCylinder] mov dh, dl mov ch, al ret ; Read a series of sectors from disk. If a sector read fails, it will ; be attempted a total of five times. ; ; On input: ; CX = Number of sectors to read ; AX = Starting sector ; ES:BX => Buffer to read to ReadSectors: mov di, 5 ; We attempt each read 5 times if an error occurs AttemptRead: push ax push bx push cx push di call LBAToCHS ; Convert starting sector to CHS mov ah, 2 ; BIOS read sector function mov al, 1 ; Read one sector mov dl, byte [bsDriveNumber] int 13h ; invoke BIOS to read the sector jnc ReadSuccess ; Read was successful xor ax, ax ; If not successful, invoke BIOS call to reset disk int 13h pop di dec di ; Decrement error counter pop cx pop bx pop ax jnz AttemptRead ; Attempt to read again int 18h ; Read still failed. Reboot ReadSuccess: pop di pop cx pop bx pop ax add bx, word [bpbBytesPerSector] ; Update buffer pointer to point to next location to read to inc ax ; Increment LBA loop ReadSectors ; read next sector ret
/* +------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ // Note: Matrices unit tests have been split in different files since // building them with eigen3 eats a lot of RAM and may be a problem while // compiling in small systems. #include <mrpt/math/CMatrixFixedNumeric.h> #include <mrpt/math/CMatrixTemplateNumeric.h> #include <mrpt/math/utils.h> #include <mrpt/random.h> #include <gtest/gtest.h> using namespace mrpt; using namespace mrpt::math; using namespace mrpt::random; using namespace std; #define CHECK_AND_RET_ERROR(_COND_, _MSG_) EXPECT_FALSE(_COND_) << _MSG_; TEST(Matrices, HCHt_3x2_2x2_2x3) { const double dat_H[] = {0.2, -0.3, 0.1, 0.9, -0.07, 1.2}; CMatrixDouble H(3, 2, dat_H); const double dat_C[] = {0.8, -0.1, -0.1, 0.8}; CMatrixDouble C(2, 2, dat_C); const double dat_R[] = {0.11600, -0.21500, -0.32530, -0.21500, 0.63800, 0.85270, -0.32530, 0.85270, 1.17272}; CMatrixDouble R_REAL(3, 3, dat_R); CMatrixDouble R; H.multiply_HCHt(C, R); EXPECT_NEAR((R_REAL - R).array().abs().sum(), 0, 1e-4); } TEST(Matrices, HCHt_scalar_1x2_2x2_2x1) { const double dat_H[] = {0.2, -0.3}; CMatrixDouble H(1, 2, dat_H); const double dat_C[] = {0.8, -0.1, -0.1, 0.8}; CMatrixDouble C(2, 2, dat_C); const double r = H.multiply_HCHt_scalar(C); const double r2 = (H * C * H.transpose()).eval()(0, 0); CHECK_AND_RET_ERROR( fabs(r - r2) > 1e-4, "Error in HCHt_scalar: 1x2 * 2x2 * 2x1") } TEST(Matrices, det_2x2_dyn) { const double dat_A[] = {0.8, -0.3, -0.7, 0.1}; CMatrixDouble A(2, 2, dat_A); const double d = A.det(); const double d_R = -0.13; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 2x2 dyn") } TEST(Matrices, det_2x2_fix) { const double dat_A[] = {0.8, -0.3, -0.7, 0.1}; CMatrixDouble22 A(dat_A); const double d = A.det(); const double d_R = -0.13; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 2x2 fix") } TEST(Matrices, det_3x3_dyn) { const double dat_A[] = {-3.3304e-01, -2.0585e-01, 6.2026e-05, 1.4631e+00, 6.0985e-01, 2.3746e+00, -3.6451e-01, 4.8169e-01, -8.4419e-01}; CMatrixDouble A(3, 3, dat_A); const double d = A.det(); const double d_R = 0.476380435871666; // cout << "d: " << d << endl; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 3x3 dyn") } TEST(Matrices, det_3x3_fix) { const double dat_A[] = {-3.3304e-01, -2.0585e-01, 6.2026e-05, 1.4631e+00, 6.0985e-01, 2.3746e+00, -3.6451e-01, 4.8169e-01, -8.4419e-01}; CMatrixDouble33 A(dat_A); const double d = A.det(); const double d_R = 0.476380435871666; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 3x3 fix") } TEST(Matrices, det_4x4_dyn) { const double dat_A[] = {0.773931, -0.336130, 1.131764, 0.385890, 1.374906, -0.540629, -0.952902, 0.659769, -0.387254, -1.557355, 0.139683, -2.056635, -0.750078, -0.653811, 0.872027, 0.217554}; CMatrixDouble A(4, 4, dat_A); const double d = A.det(); const double d_R = -6.29527837425056; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 4x4 dyn") } TEST(Matrices, det_4x4_fix) { const double dat_A[] = {0.773931, -0.336130, 1.131764, 0.385890, 1.374906, -0.540629, -0.952902, 0.659769, -0.387254, -1.557355, 0.139683, -2.056635, -0.750078, -0.653811, 0.872027, 0.217554}; CMatrixDouble44 A(dat_A); const double d = A.det(); const double d_R = -6.29527837425056; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 4x4 fix") } TEST(Matrices, det_10x10_dyn) { const double dat_A[] = { 1.2305462976, -0.2944257811, 0.8176140437, -0.0487601371, 0.4418235581, -0.0088466980, -1.4100223408, -0.6219629815, 1.1089237266, -0.6450262619, -2.0862614547, 0.2699762709, -0.0705918517, 1.1763963161, -0.3461819597, -1.3013222580, -0.3310621595, -0.2595069675, -0.5188213591, 1.2261476224, -1.1334297957, 2.1452881319, 1.7856021357, 0.5406722888, 0.5497545623, 0.4282217402, -1.6175210256, -0.3522824764, 0.2773929603, 0.8507134453, 0.4046854117, -2.1638696195, 1.0044939778, 0.9755939720, 0.9640788301, 0.5641138097, 0.7382236207, -0.4422212587, 0.8507041571, 1.3764399072, 0.3446492224, 1.1681336612, -1.3440052449, 1.0120691406, -0.0430604384, 0.4823901171, 0.0881769800, 0.3984805283, -1.9988153178, 0.9509748328, 0.3202853059, 1.9688559025, 0.4020581289, -1.5558616735, -0.8753527614, 0.1207830427, 0.0457715031, -0.1557123759, -0.3161307172, -0.0759276933, -0.0417386037, 1.2079564736, -2.5839030155, -0.7648863647, 1.1541464803, 0.2127569446, -1.4882083860, -0.7630836781, 0.8550884427, -0.8440402465, -0.4903597050, -0.1457982930, 0.5893448560, -0.2353784687, 0.3474655757, 2.5874616045, 0.6608448038, -1.0105315509, -1.5276853710, -0.1400026815, -1.7630264416, 2.4048579514, -0.3111046623, 0.7463774799, -0.2800404492, -1.4175124130, -0.5708536580, -1.2085107661, 0.8169107561, -1.1659481510, -0.1406355512, 2.3507381980, 2.6346742737, -1.1028788167, -0.0533115044, 0.3752684649, -1.3799576309, -0.7274190037, 1.1188847602, -0.6624231096}; CMatrixDouble A(10, 10, dat_A); const double d = A.det(); const double d_R = 330.498518199239; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 10x10 dyn") } TEST(Matrices, det_10x10_fix) { const double dat_A[] = { 1.2305462976, -0.2944257811, 0.8176140437, -0.0487601371, 0.4418235581, -0.0088466980, -1.4100223408, -0.6219629815, 1.1089237266, -0.6450262619, -2.0862614547, 0.2699762709, -0.0705918517, 1.1763963161, -0.3461819597, -1.3013222580, -0.3310621595, -0.2595069675, -0.5188213591, 1.2261476224, -1.1334297957, 2.1452881319, 1.7856021357, 0.5406722888, 0.5497545623, 0.4282217402, -1.6175210256, -0.3522824764, 0.2773929603, 0.8507134453, 0.4046854117, -2.1638696195, 1.0044939778, 0.9755939720, 0.9640788301, 0.5641138097, 0.7382236207, -0.4422212587, 0.8507041571, 1.3764399072, 0.3446492224, 1.1681336612, -1.3440052449, 1.0120691406, -0.0430604384, 0.4823901171, 0.0881769800, 0.3984805283, -1.9988153178, 0.9509748328, 0.3202853059, 1.9688559025, 0.4020581289, -1.5558616735, -0.8753527614, 0.1207830427, 0.0457715031, -0.1557123759, -0.3161307172, -0.0759276933, -0.0417386037, 1.2079564736, -2.5839030155, -0.7648863647, 1.1541464803, 0.2127569446, -1.4882083860, -0.7630836781, 0.8550884427, -0.8440402465, -0.4903597050, -0.1457982930, 0.5893448560, -0.2353784687, 0.3474655757, 2.5874616045, 0.6608448038, -1.0105315509, -1.5276853710, -0.1400026815, -1.7630264416, 2.4048579514, -0.3111046623, 0.7463774799, -0.2800404492, -1.4175124130, -0.5708536580, -1.2085107661, 0.8169107561, -1.1659481510, -0.1406355512, 2.3507381980, 2.6346742737, -1.1028788167, -0.0533115044, 0.3752684649, -1.3799576309, -0.7274190037, 1.1188847602, -0.6624231096}; CMatrixFixedNumeric<double, 10, 10> A(dat_A); const double d = A.det(); const double d_R = 330.498518199239; CHECK_AND_RET_ERROR(fabs(d - d_R) > 1e-4, "Error in Determinant: 10x10 fix") } TEST(Matrices, chol_2x2_dyn) { const double dat_A[] = {1.0727710178, 0.6393375593, 0.6393375593, 0.8262219720}; CMatrixDouble A(2, 2, dat_A); CMatrixDouble C; A.chol(C); const double dat_CHOL[] = {1.0357465992, 0.6172721781, 0.0000000000, 0.6672308672}; CMatrixDouble CHOL(2, 2, dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 2x2 dyn") } TEST(Matrices, chol_2x2_fix) { const double dat_A[] = {1.0727710178, 0.6393375593, 0.6393375593, 0.8262219720}; CMatrixDouble22 A(dat_A); CMatrixDouble22 C; A.chol(C); const double dat_CHOL[] = {1.0357465992, 0.6172721781, 0.0000000000, 0.6672308672}; CMatrixDouble CHOL(2, 2, dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 2x2 fix") } TEST(Matrices, chol_3x3_dyn) { const double dat_A[] = { 0.515479426556448, 0.832723636299236, 0.249691538245735, 0.832723636299236, 1.401081397506934, 0.385539356127255, 0.249691538245735, 0.385539356127255, 0.128633962591437}; CMatrixDouble A(3, 3, dat_A); CMatrixDouble C; A.chol(C); const double dat_CHOL[] = { 0.717968959326549, 1.159832365288224, 0.347774837619643, 0.000000000000000, 0.236368952988455, -0.075395504153773, 0.000000000000000, 0.000000000000000, 0.044745311077990}; CMatrixDouble CHOL(3, 3, dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 3x3 dyn") } TEST(Matrices, chol_3x3_fix) { const double dat_A[] = { 0.515479426556448, 0.832723636299236, 0.249691538245735, 0.832723636299236, 1.401081397506934, 0.385539356127255, 0.249691538245735, 0.385539356127255, 0.128633962591437}; CMatrixDouble33 A(dat_A); CMatrixDouble33 C; A.chol(C); const double dat_CHOL[] = { 0.717968959326549, 1.159832365288224, 0.347774837619643, 0.000000000000000, 0.236368952988455, -0.075395504153773, 0.000000000000000, 0.000000000000000, 0.044745311077990}; CMatrixDouble33 CHOL(dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 3x3 fix") } TEST(Matrices, chol_10x10_dyn) { const double dat_A[] = { 2.8955668335, 2.3041932983, 1.9002381085, 1.7993158652, 1.8456197228, 2.9632296740, 1.9368565578, 2.1988923358, 2.0547605617, 2.5655678993, 2.3041932983, 3.8406914364, 2.1811218706, 3.2312564555, 2.4736403918, 3.4703311380, 1.4874417483, 3.1073538218, 2.1353324397, 2.9541115932, 1.9002381085, 2.1811218706, 2.4942067597, 1.6851007198, 1.4585872052, 2.3015952197, 1.0955231591, 2.2979627790, 1.3918738834, 2.1854562572, 1.7993158652, 3.2312564555, 1.6851007198, 3.1226161015, 1.6779632687, 2.7195826381, 1.2397348013, 2.3757864319, 1.6291224768, 2.4463194915, 1.8456197228, 2.4736403918, 1.4585872052, 1.6779632687, 2.8123267839, 2.5860688816, 1.4131630919, 2.1914803135, 1.5542420639, 2.7170092067, 2.9632296740, 3.4703311380, 2.3015952197, 2.7195826381, 2.5860688816, 4.1669180394, 2.1145239023, 3.3214801332, 2.6694845663, 3.0742063088, 1.9368565578, 1.4874417483, 1.0955231591, 1.2397348013, 1.4131630919, 2.1145239023, 1.8928811570, 1.7097998455, 1.7205860530, 1.8710847505, 2.1988923358, 3.1073538218, 2.2979627790, 2.3757864319, 2.1914803135, 3.3214801332, 1.7097998455, 3.4592638415, 2.1518695071, 2.8907499694, 2.0547605617, 2.1353324397, 1.3918738834, 1.6291224768, 1.5542420639, 2.6694845663, 1.7205860530, 2.1518695071, 2.1110960664, 1.6731209980, 2.5655678993, 2.9541115932, 2.1854562572, 2.4463194915, 2.7170092067, 3.0742063088, 1.8710847505, 2.8907499694, 1.6731209980, 3.9093678727}; CMatrixDouble A(10, 10, dat_A); CMatrixDouble C; A.chol(C); const double dat_CHOL[] = { 1.7016365163, 1.3541042851, 1.1167121124, 1.0574031810, 1.0846145491, 1.7413999087, 1.1382316607, 1.2922221137, 1.2075202560, 1.5077061845, 0.0000000000, 1.4167191047, 0.4722017314, 1.2701334167, 0.7093566960, 0.7851196867, -0.0380051491, 0.9582353452, 0.3530862859, 0.6441080558, 0.0000000000, 0.0000000000, 1.0120209201, -0.0943393725, -0.0865342379, -0.0136183214, -0.1557357390, 0.3976620401, -0.1218419159, 0.1952860421, 0.0000000000, 0.0000000000, 0.0000000000, 0.6183654266, -0.6113744707, -0.1944977093, 0.1127886805, -0.2752173394, -0.1741275611, 0.0847171764, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.8668818973, 0.0234194680, 0.3011475111, -0.0272963639, -0.1417917925, 0.8000162775, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.6924364129, 0.2527445784, 0.3919505633, 0.3715689962, -0.0817608778, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.6358623279, 0.4364121485, 0.4859857603, -0.0313828244, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.5408375843, -0.1995475524, 0.6258606925, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.2213262214, -0.2367037013, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.2838575216}; CMatrixDouble CHOL(10, 10, dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 10x10 dyn") } TEST(Matrices, chol_10x10_fix) { const double dat_A[] = { 2.8955668335, 2.3041932983, 1.9002381085, 1.7993158652, 1.8456197228, 2.9632296740, 1.9368565578, 2.1988923358, 2.0547605617, 2.5655678993, 2.3041932983, 3.8406914364, 2.1811218706, 3.2312564555, 2.4736403918, 3.4703311380, 1.4874417483, 3.1073538218, 2.1353324397, 2.9541115932, 1.9002381085, 2.1811218706, 2.4942067597, 1.6851007198, 1.4585872052, 2.3015952197, 1.0955231591, 2.2979627790, 1.3918738834, 2.1854562572, 1.7993158652, 3.2312564555, 1.6851007198, 3.1226161015, 1.6779632687, 2.7195826381, 1.2397348013, 2.3757864319, 1.6291224768, 2.4463194915, 1.8456197228, 2.4736403918, 1.4585872052, 1.6779632687, 2.8123267839, 2.5860688816, 1.4131630919, 2.1914803135, 1.5542420639, 2.7170092067, 2.9632296740, 3.4703311380, 2.3015952197, 2.7195826381, 2.5860688816, 4.1669180394, 2.1145239023, 3.3214801332, 2.6694845663, 3.0742063088, 1.9368565578, 1.4874417483, 1.0955231591, 1.2397348013, 1.4131630919, 2.1145239023, 1.8928811570, 1.7097998455, 1.7205860530, 1.8710847505, 2.1988923358, 3.1073538218, 2.2979627790, 2.3757864319, 2.1914803135, 3.3214801332, 1.7097998455, 3.4592638415, 2.1518695071, 2.8907499694, 2.0547605617, 2.1353324397, 1.3918738834, 1.6291224768, 1.5542420639, 2.6694845663, 1.7205860530, 2.1518695071, 2.1110960664, 1.6731209980, 2.5655678993, 2.9541115932, 2.1854562572, 2.4463194915, 2.7170092067, 3.0742063088, 1.8710847505, 2.8907499694, 1.6731209980, 3.9093678727}; CMatrixFixedNumeric<double, 10, 10> A(dat_A); CMatrixDouble C; A.chol(C); const double dat_CHOL[] = { 1.7016365163, 1.3541042851, 1.1167121124, 1.0574031810, 1.0846145491, 1.7413999087, 1.1382316607, 1.2922221137, 1.2075202560, 1.5077061845, 0.0000000000, 1.4167191047, 0.4722017314, 1.2701334167, 0.7093566960, 0.7851196867, -0.0380051491, 0.9582353452, 0.3530862859, 0.6441080558, 0.0000000000, 0.0000000000, 1.0120209201, -0.0943393725, -0.0865342379, -0.0136183214, -0.1557357390, 0.3976620401, -0.1218419159, 0.1952860421, 0.0000000000, 0.0000000000, 0.0000000000, 0.6183654266, -0.6113744707, -0.1944977093, 0.1127886805, -0.2752173394, -0.1741275611, 0.0847171764, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.8668818973, 0.0234194680, 0.3011475111, -0.0272963639, -0.1417917925, 0.8000162775, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.6924364129, 0.2527445784, 0.3919505633, 0.3715689962, -0.0817608778, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.6358623279, 0.4364121485, 0.4859857603, -0.0313828244, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.5408375843, -0.1995475524, 0.6258606925, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.2213262214, -0.2367037013, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.2838575216}; CMatrixDouble CHOL(10, 10, dat_CHOL); CHECK_AND_RET_ERROR( (CHOL - C).array().abs().sum() > 1e-4, "Error in Choleski, 10x10 fix") }
include 'format/format.inc' format PE64 GUI entry start section '.text' code readable executable start: sub rsp,8*5 ; reserve stack for API use and make stack dqword aligned mov r9d,0 lea r8,[_caption] lea rdx,[_message] mov rcx,0 call [MessageBoxA] mov ecx,eax call [ExitProcess] section '.data' data readable writeable _caption db 'Win64 assembly program',0 _message db 'Hello World!',0 section '.idata' import data readable writeable dd 0,0,0,RVA kernel_name,RVA kernel_table dd 0,0,0,RVA user_name,RVA user_table dd 0,0,0,0,0 kernel_table: ExitProcess dq RVA _ExitProcess dq 0 user_table: MessageBoxA dq RVA _MessageBoxA dq 0 kernel_name db 'KERNEL32.DLL',0 user_name db 'USER32.DLL',0 _ExitProcess dw 0 db 'ExitProcess',0 _MessageBoxA dw 0 db 'MessageBoxA',0
#include <iostream> #include <fstream> #include <exception> #include "BiChuLi.h" #include "KxianChuLi.h" using namespace std; bool ifChengbi(vector<Kxian> &tempKxianList, int direction) { if (tempKxianList.size() < 4) { // 如果连4根K线都没有的话肯定不是笔 return false; } if (direction == -1) { // 是不是向下成笔 // 先找有没有下降K线 unsigned int i = 2; while (true) { for (; i < tempKxianList.size(); i++) { if (tempKxianList.at(i).di < tempKxianList.at(i - 1).di && tempKxianList.at(i - 1).di < tempKxianList.at(i - 2).di) { // 找到下降K线 break; } } if (i >= tempKxianList.size()) { // 下降K线都没找到 return false; } // 找前面的最低价 float zuiDiJia = tempKxianList.at(i).di; // 如果出现了更低价,这个笔就成立了 for (unsigned int j = i + 1; j < tempKxianList.size(); j++) { if (tempKxianList.at(j).di < zuiDiJia) { return true; } } i = i + 1; } } else if (direction == 1) { // 是不是向上成笔 // 先找有没有上升K线 unsigned int i = 2; while (true) { for (; i < tempKxianList.size(); i++) { if (tempKxianList.at(i).gao > tempKxianList.at(i - 1).gao && tempKxianList.at(i - 1).gao > tempKxianList.at(i - 2).gao) { // 找到上升K线 break; } } if (i >= tempKxianList.size()) { // 上升K线都没找到 return false; } // 找前面的最高价 float zuiGaoJia = tempKxianList.at(i).gao; // 如果出现了更高价,这个笔就成立了 for (unsigned int j = i + 1; j < tempKxianList.size(); j++) { if (tempKxianList.at(j).gao > zuiGaoJia) { return true; } } i = i + 1; } } return false; } void BiChuLi::handle(vector<Kxian> &kxianList) { vector<Kxian> tempKxianList; // 临时未成笔K线的保存 for (vector<Kxian>::iterator iter = kxianList.begin(); iter != kxianList.end(); iter++) { if (this->biList.empty()) { // 第一笔生成中,也是假设第一笔是向上的 Bi bi; bi.fangXiang = 1; bi.kaiShi = (*iter).kaiShi; bi.jieShu = (*iter).jieShu; bi.gao = (*iter).gao; bi.di = (*iter).di; bi.kxianList.push_back(*iter); this->biList.push_back(bi); } else { if (this->biList.back().fangXiang == 1) { // 上一笔是向上笔 if ((*iter).gao >= this->biList.back().gao) { // 向上笔继续延续 this->biList.back().jieShu = (*iter).jieShu; this->biList.back().gao = (*iter).gao; if (tempKxianList.size() > 0) { for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { this->biList.back().kxianList.push_back(*it); } tempKxianList.clear(); } this->biList.back().kxianList.push_back(*iter); } else { tempKxianList.push_back(*iter); // 有没有成新的向下笔 if (ifChengbi(tempKxianList, -1)) { Bi bi; bi.fangXiang = -1; bi.kaiShi = this->biList.back().jieShu; bi.jieShu = tempKxianList.back().jieShu; bi.di = tempKxianList.back().di; bi.gao = this->biList.back().gao; for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { bi.kxianList.push_back(*it); } tempKxianList.clear(); this->biList.push_back(bi); } } } else if (this->biList.back().fangXiang == -1) { // 上一笔是向下笔 if ((*iter).di <= this->biList.back().di) { // 向下笔继续延续 this->biList.back().jieShu = (*iter).jieShu; this->biList.back().di = (*iter).di; if (tempKxianList.size() > 0) { for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { this->biList.back().kxianList.push_back(*it); } tempKxianList.clear(); } this->biList.back().kxianList.push_back(*iter); } else { tempKxianList.push_back(*iter); // 有没有成新的向上笔 if (ifChengbi(tempKxianList, 1)) { Bi bi; bi.fangXiang = 1; bi.kaiShi = this->biList.back().jieShu; bi.jieShu = tempKxianList.back().jieShu; bi.gao = tempKxianList.back().gao; bi.di = this->biList.back().di; for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { bi.kxianList.push_back(*it); } tempKxianList.clear(); this->biList.push_back(bi); } } } } } if (tempKxianList.size() >= 4) { if (this->biList.back().fangXiang == 1) { if (ifChengbi(tempKxianList, -1)) { Bi bi; bi.fangXiang = -1; bi.kaiShi = this->biList.back().jieShu; bi.jieShu = tempKxianList.back().jieShu; bi.di = tempKxianList.back().di; bi.gao = this->biList.back().gao; for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { bi.kxianList.push_back(*it); } tempKxianList.clear(); this->biList.push_back(bi); } } else if (this->biList.back().fangXiang == -1) { if (ifChengbi(tempKxianList, 1)) { Bi bi; bi.fangXiang = 1; bi.kaiShi = this->biList.back().jieShu; bi.jieShu = tempKxianList.back().jieShu; bi.gao = tempKxianList.back().gao; bi.di = this->biList.back().di; for (vector<Kxian>::iterator it = tempKxianList.begin(); it != tempKxianList.end(); it++) { bi.kxianList.push_back(*it); } tempKxianList.clear(); this->biList.push_back(bi); } } } }
// Copyright (c) 2014 Grant Mercer // Copyright (c) 2015 Daniel Bourgeois // Copyright (c) 2016-2018 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /// \file parallel/algorithms/copy.hpp #if !defined(HPX_PARALLEL_DETAIL_COPY_MAY_30_2014_0317PM) #define HPX_PARALLEL_DETAIL_COPY_MAY_30_2014_0317PM #include <hpx/config.hpp> #include <hpx/assertion.hpp> #include <hpx/traits/concepts.hpp> #include <hpx/traits/is_iterator.hpp> #include <hpx/util/invoke.hpp> #include <hpx/util/tagged_pair.hpp> #include <hpx/parallel/algorithms/detail/dispatch.hpp> #include <hpx/parallel/algorithms/detail/is_negative.hpp> #include <hpx/parallel/algorithms/detail/predicates.hpp> #include <hpx/parallel/algorithms/detail/transfer.hpp> #include <hpx/parallel/execution_policy.hpp> #include <hpx/parallel/tagspec.hpp> #include <hpx/parallel/traits/projected.hpp> #include <hpx/parallel/util/detail/algorithm_result.hpp> #include <hpx/parallel/util/foreach_partitioner.hpp> #include <hpx/parallel/util/loop.hpp> #include <hpx/parallel/util/projection_identity.hpp> #include <hpx/parallel/util/scan_partitioner.hpp> #include <hpx/parallel/util/transfer.hpp> #include <hpx/parallel/util/zip_iterator.hpp> #include <hpx/util/unused.hpp> #include <algorithm> #include <cstddef> #include <cstring> #include <iterator> #include <memory> #include <type_traits> #include <utility> #include <vector> #include <boost/shared_array.hpp> namespace hpx { namespace parallel { inline namespace v1 { /////////////////////////////////////////////////////////////////////////// // copy namespace detail { /// \cond NOINTERNAL struct copy_iteration { template <typename Iter> HPX_HOST_DEVICE HPX_FORCEINLINE void operator()(Iter part_begin, std::size_t part_size, std::size_t) { using hpx::util::get; auto iters = part_begin.get_iterator_tuple(); util::copy_n(get<0>(iters), part_size, get<1>(iters)); } }; template <typename IterPair> struct copy : public detail::algorithm<copy<IterPair>, IterPair> { copy() : copy::algorithm("copy") {} template <typename ExPolicy, typename InIter, typename OutIter> static std::pair<InIter, OutIter> sequential(ExPolicy, InIter first, InIter last, OutIter dest) { std::pair<InIter, OutIter> result = util::copy(first, last, dest); util::copy_synchronize(first, dest); return result; } template <typename ExPolicy, typename FwdIter1, typename FwdIter2> static typename util::detail::algorithm_result< ExPolicy, std::pair<FwdIter1, FwdIter2> >::type parallel(ExPolicy && policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest) { #if defined(HPX_COMPUTE_DEVICE_CODE) HPX_ASSERT(false); typename util::detail::algorithm_result< ExPolicy, std::pair<FwdIter1, FwdIter2> >::type *dummy = nullptr; return std::move(*dummy); #else typedef hpx::util::zip_iterator<FwdIter1, FwdIter2> zip_iterator; return get_iter_pair( util::foreach_partitioner<ExPolicy>::call( std::forward<ExPolicy>(policy), hpx::util::make_zip_iterator(first, dest), std::distance(first, last), copy_iteration(), [](zip_iterator && last) -> zip_iterator { using hpx::util::get; auto iters = last.get_iterator_tuple(); util::copy_synchronize(get<0>(iters), get<1>(iters)); return std::move(last); })); #endif } }; #if defined(HPX_COMPUTE_DEVICE_CODE) template<typename FwdIter1, typename FwdIter2, typename Enable = void> struct copy_iter : public copy<std::pair<FwdIter1, FwdIter2> > {}; #else /////////////////////////////////////////////////////////////////////// template<typename FwdIter1, typename FwdIter2, typename Enable = void> struct copy_iter; template <typename FwdIter1, typename FwdIter2> struct copy_iter< FwdIter1, FwdIter2, typename std::enable_if< iterators_are_segmented<FwdIter1, FwdIter2>::value >::type> : public copy<std::pair< typename hpx::traits::segmented_iterator_traits<FwdIter1> ::local_iterator, typename hpx::traits::segmented_iterator_traits<FwdIter2> ::local_iterator > > {}; template<typename FwdIter1, typename FwdIter2> struct copy_iter< FwdIter1, FwdIter2, typename std::enable_if< iterators_are_not_segmented<FwdIter1, FwdIter2>::value >::type> : public copy<std::pair<FwdIter1, FwdIter2> > {}; #endif /// \endcond } /// Copies the elements in the range, defined by [first, last), to another /// range beginning at \a dest. /// /// \note Complexity: Performs exactly \a last - \a first assignments. /// /// \tparam ExPolicy The type of the execution policy to use (deduced). /// It describes the manner in which the execution /// of the algorithm may be parallelized and the manner /// in which it executes the assignments. /// \tparam FwdIter1 The type of the source iterators used (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// \tparam FwdIter2 The type of the iterator representing the /// destination range (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// /// \param policy The execution policy to use for the scheduling of /// the iterations. /// \param first Refers to the beginning of the sequence of elements /// the algorithm will be applied to. /// \param last Refers to the end of the sequence of elements the /// algorithm will be applied to. /// \param dest Refers to the beginning of the destination range. /// /// The assignments in the parallel \a copy algorithm invoked with an /// execution policy object of type \a sequenced_policy /// execute in sequential order in the calling thread. /// /// The assignments in the parallel \a copy algorithm invoked with /// an execution policy object of type \a parallel_policy or /// \a parallel_task_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// /// \returns The \a copy algorithm returns a /// \a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > /// if the execution policy is of type /// \a sequenced_task_policy or /// \a parallel_task_policy and /// returns \a tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> /// otherwise. /// The \a copy algorithm returns the pair of the input iterator /// \a last and the output iterator to the /// element in the destination range, one past the last element /// copied. /// template <typename ExPolicy, typename FwdIter1, typename FwdIter2, HPX_CONCEPT_REQUIRES_( execution::is_execution_policy<ExPolicy>::value && hpx::traits::is_iterator<FwdIter1>::value && hpx::traits::is_iterator<FwdIter2>::value)> typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> >::type copy(ExPolicy && policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest) { return detail::transfer<detail::copy_iter<FwdIter1, FwdIter2> >( std::forward<ExPolicy>(policy), first, last, dest); } ///////////////////////////////////////////////////////////////////////////// // copy_n namespace detail { /// \cond NOINTERNAL // sequential copy_n template <typename IterPair> struct copy_n : public detail::algorithm<copy_n<IterPair>, IterPair> { copy_n() : copy_n::algorithm("copy_n") {} template <typename ExPolicy, typename InIter, typename OutIter> static std::pair<InIter, OutIter> sequential(ExPolicy, InIter first, std::size_t count, OutIter dest) { return util::copy_n(first, count, dest); } template <typename ExPolicy, typename FwdIter1, typename FwdIter2> static typename util::detail::algorithm_result< ExPolicy, std::pair<FwdIter1, FwdIter2> >::type parallel(ExPolicy && policy, FwdIter1 first, std::size_t count, FwdIter2 dest) { typedef hpx::util::zip_iterator<FwdIter1, FwdIter2> zip_iterator; return get_iter_pair( util::foreach_partitioner<ExPolicy>::call( std::forward<ExPolicy>(policy), hpx::util::make_zip_iterator(first, dest), count, [](zip_iterator part_begin, std::size_t part_size, std::size_t) { using hpx::util::get; auto iters = part_begin.get_iterator_tuple(); util::copy_n(get<0>(iters), part_size, get<1>(iters)); }, [](zip_iterator && last) -> zip_iterator { using hpx::util::get; auto iters = last.get_iterator_tuple(); util::copy_synchronize(get<0>(iters), get<1>(iters)); return std::move(last); })); } }; /// \endcond } /// Copies the elements in the range [first, first + count), starting from /// first and proceeding to first + count - 1., to another range beginning /// at dest. /// /// \note Complexity: Performs exactly \a count assignments, if /// count > 0, no assignments otherwise. /// /// \tparam ExPolicy The type of the execution policy to use (deduced). /// It describes the manner in which the execution /// of the algorithm may be parallelized and the manner /// in which it executes the assignments. /// \tparam FwdIter1 The type of the source iterators used (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// \tparam Size The type of the argument specifying the number of /// elements to apply \a f to. /// \tparam FwdIter2 The type of the iterator representing the /// destination range (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// /// \param policy The execution policy to use for the scheduling of /// the iterations. /// \param first Refers to the beginning of the sequence of elements /// the algorithm will be applied to. /// \param count Refers to the number of elements starting at /// \a first the algorithm will be applied to. /// \param dest Refers to the beginning of the destination range. /// /// The assignments in the parallel \a copy_n algorithm invoked with /// an execution policy object of type \a sequenced_policy /// execute in sequential order in the calling thread. /// /// The assignments in the parallel \a copy_n algorithm invoked with /// an execution policy object of type \a parallel_policy or /// \a parallel_task_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// /// \returns The \a copy_n algorithm returns a /// \a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > /// if the execution policy is of type /// \a sequenced_task_policy or /// \a parallel_task_policy and /// returns \a tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> /// otherwise. /// The \a copy algorithm returns the pair of the input iterator /// forwarded to the first element after the last in the input /// sequence and the output iterator to the /// element in the destination range, one past the last element /// copied. /// template <typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2, HPX_CONCEPT_REQUIRES_( execution::is_execution_policy<ExPolicy>::value && hpx::traits::is_iterator<FwdIter1>::value && hpx::traits::is_iterator<FwdIter2>::value)> typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> >::type copy_n(ExPolicy && policy, FwdIter1 first, Size count, FwdIter2 dest) { static_assert( (hpx::traits::is_forward_iterator<FwdIter1>::value), "Required at least forward iterator."); static_assert( (hpx::traits::is_forward_iterator<FwdIter2>::value), "Requires at least forward iterator."); typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq; using hpx::util::tagged_pair; using hpx::util::make_tagged_pair; // if count is representing a negative value, we do nothing if (detail::is_negative(count)) { return util::detail::algorithm_result< ExPolicy, tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> >::get(make_tagged_pair<tag::in, tag::out>(first, dest)); } return make_tagged_pair<tag::in, tag::out>( detail::copy_n<std::pair<FwdIter1, FwdIter2> >().call( std::forward<ExPolicy>(policy), is_seq(), first, std::size_t(count), dest)); } ///////////////////////////////////////////////////////////////////////////// // copy_if namespace detail { /// \cond NOINTERNAL // sequential copy_if with projection function template <typename InIter, typename OutIter, typename Pred, typename Proj> inline std::pair<InIter, OutIter> sequential_copy_if(InIter first, InIter last, OutIter dest, Pred && pred, Proj && proj) { while (first != last) { if (hpx::util::invoke(pred, hpx::util::invoke(proj, *first))) *dest++ = *first; first++; } return std::make_pair(first, dest); } template <typename IterPair> struct copy_if : public detail::algorithm<copy_if<IterPair>, IterPair> { copy_if() : copy_if::algorithm("copy_if") {} template <typename ExPolicy, typename InIter, typename OutIter, typename Pred, typename Proj = util::projection_identity> static std::pair<InIter, OutIter> sequential(ExPolicy, InIter first, InIter last, OutIter dest, Pred && pred, Proj && proj/* = Proj()*/) { return sequential_copy_if(first, last, dest, std::forward<Pred>(pred), std::forward<Proj>(proj)); } template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename Pred, typename Proj = util::projection_identity> static typename util::detail::algorithm_result< ExPolicy, std::pair<FwdIter1, FwdIter2> >::type parallel(ExPolicy && policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, Pred && pred, Proj && proj/* = Proj()*/) { typedef hpx::util::zip_iterator<FwdIter1, bool*> zip_iterator; typedef util::detail::algorithm_result< ExPolicy, std::pair<FwdIter1, FwdIter2> > result; typedef typename std::iterator_traits<FwdIter1>::difference_type difference_type; if (first == last) return result::get(std::make_pair(last, dest)); difference_type count = std::distance(first, last); boost::shared_array<bool> flags(new bool[count]); std::size_t init = 0; using hpx::util::get; using hpx::util::make_zip_iterator; typedef util::scan_partitioner< ExPolicy, std::pair<FwdIter1, FwdIter2>, std::size_t > scan_partitioner_type; auto f1 = [HPX_CAPTURE_FORWARD(pred), HPX_CAPTURE_FORWARD(proj) ](zip_iterator part_begin, std::size_t part_size) -> std::size_t { std::size_t curr = 0; // MSVC complains if proj is captured by ref below util::loop_n<ExPolicy>( part_begin, part_size, [&pred, proj, &curr](zip_iterator it) mutable { bool f = hpx::util::invoke(pred, hpx::util::invoke(proj, get<0>(*it))); if ((get<1>(*it) = f)) ++curr; }); return curr; }; auto f3 = [dest, flags]( zip_iterator part_begin, std::size_t part_size, hpx::shared_future<std::size_t> curr, hpx::shared_future<std::size_t> next ) mutable { HPX_UNUSED(flags); next.get(); // rethrow exceptions std::advance(dest, curr.get()); util::loop_n<ExPolicy>( part_begin, part_size, [&dest](zip_iterator it) mutable { if (get<1>(*it)) *dest++ = get<0>(*it); }); }; auto f4 = [last, dest, flags]( std::vector<hpx::shared_future<std::size_t>>&& items, std::vector<hpx::future<void>>&&) mutable -> std::pair<FwdIter1, FwdIter2> { HPX_UNUSED(flags); std::advance(dest, items.back().get()); return std::make_pair(last, dest); }; return scan_partitioner_type::call( std::forward<ExPolicy>(policy), make_zip_iterator(first, flags.get()), count, init, // step 1 performs first part of scan algorithm std::move(f1), // step 2 propagates the partition results from left // to right hpx::util::unwrapping(std::plus<std::size_t>()), // step 3 runs final accumulation on each partition std::move(f3), // step 4 use this return value std::move(f4)); } }; /// \endcond } /// Copies the elements in the range, defined by [first, last), to another /// range beginning at \a dest. Copies only the elements for which the /// predicate \a f returns true. The order of the elements that are not /// removed is preserved. /// /// \note Complexity: Performs not more than \a last - \a first /// assignments, exactly \a last - \a first applications of the /// predicate \a f. /// /// \tparam ExPolicy The type of the execution policy to use (deduced). /// It describes the manner in which the execution /// of the algorithm may be parallelized and the manner /// in which it executes the assignments. /// \tparam FwdIter1 The type of the source iterators used (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// \tparam FwdIter2 The type of the iterator representing the /// destination range (deduced). /// This iterator type must meet the requirements of an /// forward iterator. /// \tparam F The type of the function/function object to use /// (deduced). Unlike its sequential form, the parallel /// overload of \a copy_if requires \a F to meet the /// requirements of \a CopyConstructible. /// \tparam Proj The type of an optional projection function. This /// defaults to \a util::projection_identity /// /// \param policy The execution policy to use for the scheduling of /// the iterations. /// \param first Refers to the beginning of the sequence of elements /// the algorithm will be applied to. /// \param last Refers to the end of the sequence of elements the /// algorithm will be applied to. /// \param dest Refers to the beginning of the destination range. /// \param f Specifies the function (or function object) which /// will be invoked for each of the elements in the /// sequence specified by [first, last).This is an /// unary predicate which returns \a true for the /// required elements. The signature of this predicate /// should be equivalent to: /// \code /// bool pred(const Type &a); /// \endcode \n /// The signature does not need to have const&, but /// the function must not modify the objects passed to /// it. The type \a Type must be such that an object of /// type \a FwdIter1 can be dereferenced and then /// implicitly converted to Type. /// \param proj Specifies the function (or function object) which /// will be invoked for each of the elements as a /// projection operation before the actual predicate /// \a is invoked. /// /// The assignments in the parallel \a copy_if algorithm invoked with /// an execution policy object of type \a sequenced_policy /// execute in sequential order in the calling thread. /// /// The assignments in the parallel \a copy_if algorithm invoked with /// an execution policy object of type \a parallel_policy or /// \a parallel_task_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// /// \returns The \a copy_if algorithm returns a /// \a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> > /// if the execution policy is of type /// \a sequenced_task_policy or /// \a parallel_task_policy and /// returns \a tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> /// otherwise. /// The \a copy algorithm returns the pair of the input iterator /// forwarded to the first element after the last in the input /// sequence and the output iterator to the /// element in the destination range, one past the last element /// copied. /// template <typename ExPolicy, typename FwdIter1, typename FwdIter2, typename F, typename Proj = util::projection_identity, HPX_CONCEPT_REQUIRES_( execution::is_execution_policy<ExPolicy>::value && hpx::traits::is_iterator<FwdIter1>::value && hpx::traits::is_iterator<FwdIter2>::value && traits::is_projected<Proj, FwdIter1>::value && traits::is_indirect_callable< ExPolicy, F, traits::projected<Proj, FwdIter1> >::value)> typename util::detail::algorithm_result< ExPolicy, hpx::util::tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> >::type copy_if(ExPolicy&& policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest, F && f, Proj && proj = Proj()) { static_assert( (hpx::traits::is_forward_iterator<FwdIter1>::value), "Required at least forward iterator."); static_assert( (hpx::traits::is_forward_iterator<FwdIter2>::value), "Requires at least forward iterator."); typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq; return hpx::util::make_tagged_pair<tag::in, tag::out>( detail::copy_if<std::pair<FwdIter1, FwdIter2> >().call( std::forward<ExPolicy>(policy), is_seq(), first, last, dest, std::forward<F>(f), std::forward<Proj>(proj))); } }}} #endif
section .bss res resb 1 section .data msg db "The result is:", 0x20, 0xA, 0xD len equ $ - msg section .text global _start _start: mov ax, '8' sub ax, '0' mov bl, '2' sub bl, '0' div bl add ax, '0' mov [res], ax mov ecx, msg mov edx, len call _print mov ecx, res mov edx, 1 call _print mov eax, 1 xor ebx, ebx int 80h _print: mov eax, 4 mov ebx, 1 int 80h ret
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. ; ==++== ; ; ; ==--== ifdef FEATURE_COMINTEROP include AsmMacros.inc include asmconstants.inc extern CallDescrWorkerUnwindFrameChainHandler:proc extern ReverseComUnwindFrameChainHandler:proc extern COMToCLRWorker:proc extern JIT_FailFast:proc extern s_gsCookie:qword NESTED_ENTRY GenericComCallStub, _TEXT, ReverseComUnwindFrameChainHandler ; ; Set up a ComMethodFrame and call COMToCLRWorker. ; ; Stack frame layout: ; ; (stack parameters) ; ... ; r9 ; r8 ; rdx ; rcx ; UnmanagedToManagedFrame::m_ReturnAddress ; UnmanagedToManagedFrame::m_Datum ; Frame::m_Next ; __VFN_table <-- rsp + GenericComCallStub_ComMethodFrame_OFFSET ; GSCookie ; (optional padding to qword align xmm save area) ; xmm3 ; xmm2 ; xmm1 ; xmm0 <-- rsp + GenericComCallStub_XMM_SAVE_OFFSET ; r12 ; r13 ; r14 ; (optional padding to qword align rsp) ; callee's r9 ; callee's r8 ; callee's rdx ; callee's rcx GenericComCallStub_STACK_FRAME_SIZE = 0 ; ComMethodFrame MUST be the highest part of the stack frame, immediately ; below the return address and MethodDesc*, so that ; UnmanagedToManagedFrame::m_ReturnAddress and ; UnmanagedToManagedFrame::m_Datum are the right place. GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + (SIZEOF__ComMethodFrame - 8) GenericComCallStub_ComMethodFrame_NEGOFFSET = GenericComCallStub_STACK_FRAME_SIZE GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + SIZEOF_GSCookie ; Ensure that the offset of the XMM save area will be 16-byte aligned. if ((GenericComCallStub_STACK_FRAME_SIZE + 8) MOD 16) ne 0 GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + 8 endif ; XMM save area MUST be immediately below GenericComCallStub ; (w/ alignment padding) GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + 4*16 GenericComCallStub_XMM_SAVE_NEGOFFSET = GenericComCallStub_STACK_FRAME_SIZE ; Add in the callee scratch area size. GenericComCallStub_CALLEE_SCRATCH_SIZE = 4*8 GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + GenericComCallStub_CALLEE_SCRATCH_SIZE ; Now we have the full size of the stack frame. The offsets have been computed relative to the ; top, so negate them to make them relative to the post-prologue rsp. GenericComCallStub_ComMethodFrame_OFFSET = GenericComCallStub_STACK_FRAME_SIZE - GenericComCallStub_ComMethodFrame_NEGOFFSET GenericComCallStub_XMM_SAVE_OFFSET = GenericComCallStub_STACK_FRAME_SIZE - GenericComCallStub_XMM_SAVE_NEGOFFSET OFFSETOF_GSCookie = GenericComCallStub_ComMethodFrame_OFFSET - SIZEOF_GSCookie .allocstack 8 ; UnmanagedToManagedFrame::m_Datum, pushed by prepad ; ; Allocate the remainder of the ComMethodFrame. The fields ; will be filled in by COMToCLRWorker ; alloc_stack SIZEOF__ComMethodFrame - 10h ; ; Save ComMethodFrame* to pass to COMToCLRWorker ; mov r10, rsp alloc_stack GenericComCallStub_ComMethodFrame_OFFSET ; ; Save argument registers ; SAVE_ARGUMENT_REGISTERS GenericComCallStub_STACK_FRAME_SIZE + 8h ; ; spill the fp args ; SAVE_FLOAT_ARGUMENT_REGISTERS GenericComCallStub_XMM_SAVE_OFFSET END_PROLOGUE mov rcx, s_gsCookie mov [rsp + OFFSETOF_GSCookie], rcx ; ; Call COMToCLRWorker. Note that the first parameter (pThread) is ; filled in by callee. ; ifdef _DEBUG mov rcx, 0cccccccccccccccch endif mov rdx, r10 call COMToCLRWorker ifdef _DEBUG mov rcx, s_gsCookie cmp [rsp + OFFSETOF_GSCookie], rcx je GoodGSCookie call JIT_FailFast GoodGSCookie: endif ; _DEBUG ; ; epilogue ; add rsp, GenericComCallStub_STACK_FRAME_SIZE ret NESTED_END GenericComCallStub, _TEXT ; ARG_SLOT COMToCLRDispatchHelperWithStack(DWORD dwStackSlots, // rcx ; ComMethodFrame *pFrame, // rdx ; PCODE pTarget, // r8 ; PCODE pSecretArg, // r9 ; INT_PTR pDangerousThis // rbp+40h ; ); NESTED_ENTRY COMToCLRDispatchHelperWithStack, _TEXT, CallDescrWorkerUnwindFrameChainHandler ComMethodFrame_Arguments_OFFSET = SIZEOF__ComMethodFrame ComMethodFrame_XMM_SAVE_OFFSET = GenericComCallStub_XMM_SAVE_OFFSET - GenericComCallStub_ComMethodFrame_OFFSET push_nonvol_reg rdi ; save nonvolatile registers push_nonvol_reg rsi ; push_nonvol_reg rbp ; set_frame rbp, 0 ; set frame pointer END_PROLOGUE ; ; copy stack ; lea rsi, [rdx + ComMethodFrame_Arguments_OFFSET] add ecx, 4 ; outgoing argument homes mov eax, ecx ; number of stack slots shl eax, 3 ; compute number of argument bytes add eax, 8h ; alignment padding and rax, 0FFFFFFFFFFFFFFf0h ; for proper stack alignment, v-liti remove partial register stall sub rsp, rax ; allocate argument list mov rdi, rsp ; set destination argument list address rep movsq ; copy arguments to the stack ; Stack layout: ; ; callee's rcx (to be loaded into rcx) <- rbp+40h ; r9 (to be loaded into r10) ; r8 (IL stub entry point) ; rdx (ComMethodFrame ptr) ; rcx (number of stack slots to repush) ; return address ; saved rdi ; saved rsi ; saved rbp <- rbp ; alignment ; (stack parameters) ; callee's r9 ; callee's r8 ; callee's rdx ; callee's rcx (not loaded into rcx) <- rsp ; ; load fp registers ; movdqa xmm0, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 00h] movdqa xmm1, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 10h] movdqa xmm2, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 20h] movdqa xmm3, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 30h] ; ; load secret arg and target ; mov r10, r9 mov rax, r8 ; ; load argument registers ; mov rcx, [rbp + 40h] ; ignoring the COM IP at [rsp] mov rdx, [rsp + 08h] mov r8, [rsp + 10h] mov r9, [rsp + 18h] ; ; call the target ; call rax ; It is important to have an instruction between the previous call and the epilog. ; If the return address is in epilog, OS won't call personality routine because ; it thinks personality routine does not help in this case. nop ; ; epilog ; lea rsp, 0[rbp] ; deallocate argument list pop rbp ; restore nonvolatile register pop rsi ; pop rdi ; ret NESTED_END COMToCLRDispatchHelperWithStack, _TEXT ; ARG_SLOT COMToCLRDispatchHelper(DWORD dwStackSlots, // rcx ; ComMethodFrame *pFrame, // rdx ; PCODE pTarget, // r8 ; PCODE pSecretArg, // r9 ; INT_PTR pDangerousThis // rsp + 28h on entry ; ); NESTED_ENTRY COMToCLRDispatchHelper, _TEXT, CallDescrWorkerUnwindFrameChainHandler ; ; Check to see if we have stack to copy and, if so, tail call to ; the routine that can handle that. ; test ecx, ecx jnz COMToCLRDispatchHelperWithStack alloc_stack 28h ; alloc scratch space + alignment, pDangerousThis moves to [rsp+50] END_PROLOGUE ; get pointer to arguments lea r11, [rdx + ComMethodFrame_Arguments_OFFSET] ; ; load fp registers ; movdqa xmm0, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 00h] movdqa xmm1, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 10h] movdqa xmm2, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 20h] movdqa xmm3, [rdx + ComMethodFrame_XMM_SAVE_OFFSET + 30h] ; ; load secret arg and target ; mov r10, r9 mov rax, r8 ; ; load argument registers ; mov rcx, [rsp + 50h] ; ignoring the COM IP at [r11 + 00h] mov rdx, [r11 + 08h] mov r8, [r11 + 10h] mov r9, [r11 + 18h] ; ; call the target ; call rax ; It is important to have an instruction between the previous call and the epilog. ; If the return address is in epilog, OS won't call personality routine because ; it thinks personality routine does not help in this case. nop ; ; epilog ; add rsp, 28h ret NESTED_END COMToCLRDispatchHelper, _TEXT endif ; FEATURE_COMINTEROP end
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #pragma once #include <krabs.hpp> #include <string> #include "../NativePtr.hpp" #include "Predicate.hpp" using namespace System; using namespace System::Runtime::InteropServices; namespace adpt = krabs::predicates::adapters; namespace Microsoft { namespace O365 { namespace Security { namespace ETW { /// <summary> /// Enables a more convenient mechanism to specify filters in /// managed C++/C#. /// </summary> /// <remarks> /// The idea here is that chains of complicated filters are built /// iteratively, using the methods on this class. These chains are passed /// into the native layer a single time, where they are used to do /// filtering before they are bubbled up to the managed layer. /// </remarks> public ref class Filter { public: // Event Properties // -------------------------------------------------------------------- /// <summary> /// Used to negate the result of the predicate argument. /// </summary> /// <param name="other">the predicate to negate</param> /// <returns>negated form of the predicate passed in</returns> static Predicate ^Not(Predicate ^other) { return Predicate::make_predicate<KPD::not_filter<krabs::filter_predicate>>(*other->predicate_); } /// <summary> /// Accepts any events. /// </summary> /// <returns>a predicate that accepts any event</returns> static Predicate ^AnyEvent() { return Predicate::make_predicate<krabs::predicates::details::any_event>(); } /// <summary> /// Used to verify that an event opcode matches the expected value /// </summary> /// <param name="opcode">event opcode to verify</param> /// <returns>predicate that verifies an event's opcode</returns> static Predicate ^EventOpcodeIs(int opcode) { return Predicate::make_predicate<krabs::predicates::opcode_is>(opcode); } /// <summary> /// Used to verify that an event matches the given id. /// </summary> /// <param name="id">the event id to match on</param> /// <returns>a predicate that will match an event with the provided id</returns> static Predicate ^EventIdIs(int id) { return Predicate::make_predicate<krabs::predicates::id_is>(id); } /// <summary> /// Used to verify that an event version is the given version. /// </summary> /// <param name="version">the version to match on</param> /// <returns>a predicate that matches events of the specified version</returns> static Predicate ^EventVersionIs(int version) { return Predicate::make_predicate<krabs::predicates::version_is>(version); } /// <summary> /// Used to verify that an event was emitted by a specific PID. /// </summary> /// <param name="processId">the PID to match on</param> /// <returns>a predicate that matches events of the specified PID</returns> static Predicate ^ProcessIdIs(int processId) { return Predicate::make_predicate<krabs::predicates::process_id_is>(processId); } /// <summary> /// Used to verify that an event was emitted with a specific UInt32 property. /// </summary> /// <param name="propertyName">the name of the property to match on</param> /// <param name="value">the value of the property to match on</param> /// <returns>a predicate that matches events of the specified UInt32 property</returns> static Predicate ^IsUInt32(String ^propertyName, UInt32 value) { return gcnew Predicate(krabs::predicates::property_is<UInt32>( msclr::interop::marshal_as<std::wstring>(propertyName), value)); } }; } } } }
MXECOMRC TITLE 'MXE COMMON RECOVERY' *--------+---------+---------+---------+---------+---------+---------+- * Name : MXECOMRC * * Function : General purpose recovery routine * * Populate the MXECATCH control block with SDWA info * and retry (if possible) * * MXECATCH control block passed as a parm to this * recovery routine by the following means : * * ESTAE - Passed via "PARAM" keyword * * ARR - Stored in the linkage stack via MSTA * * FRR - Stored in the FRR parm area * * MXECOMRC is part of the MXE LPA function pack * * * Register Usage : * r1 - parameter passed : SDWA * r2 - * r3 - * r4 - SDWA * r5 - * r6 - * r7 - SDWARC1 * r8 - MXECATCH * r9 - Retry routine * r10 - * r11 - Return address * r12 - Data * r13 - * *--------+---------+---------+---------+---------+---------+---------+- * Changes * 2019/01/09 RDS Code Written *--------+---------+---------+---------+---------+---------+---------+- MXECOMRC MXEMAIN DATAREG=(R12),BAKR=NO,PARMS=(R4) *--------+---------+---------+---------+---------+---------+---------+- * Copy the regs passed by RTM *--------+---------+---------+---------+---------+---------+---------+- LGR R5,R0 Entry code LGR R8,R2 Possible MXECATCH address *--------+---------+---------+---------+---------+---------+---------+- * Init code *--------+---------+---------+---------+---------+---------+---------+- LGR R11,R14 Save return address IF (C,R5,EQ,=F'12') No SDWA ? MXEMAC ZERO,(R15) ..Percolate BR R11 ..Return to caller ENDIF *--------+---------+---------+---------+---------+---------+---------+- * We have an SDWA - and maybe an MXECATCH if this is "us" *--------+---------+---------+---------+---------+---------+---------+- USING SDWA,R4 Address SDWA USING MXECATCH,R8 Address possible MXECATCH *--------+---------+---------+---------+---------+---------+---------+- * Ensure that the passed parm is an MXECATCH and that the recovery * environment was established OK. *--------+---------+---------+---------+---------+---------+---------+- DO , DOEXIT (LTGR,R8,R8,Z) no address - quit MXEMAC VER_ID,MXECATCH Check eye-catchcer DOEXIT (LTR,R15,R15,NZ) Bad eye-catcher DOEXIT (TM,MXECATCH_FLG1,MXECATCH@FLG1_INIT,NO) Init OK? *--------+---------+---------+---------+---------+---------+---------+- * If the "invoked" flag is on, then we have recursively entered * this routine and most likely this is not intentional, so we * percolate if so. *--------+---------+---------+---------+---------+---------+---------+- DOEXIT (TM,MXECATCH_FLG1,MXECATCH@FLG1_INVOKED,O) *--------+---------+---------+---------+---------+---------+---------+- * Indicate that we have been invoked and that we have found SDWA *--------+---------+---------+---------+---------+---------+---------+- MXEMAC BIT_ON,MXECATCH@FLG1_INVOKED MXEMAC BIT_ON,MXECATCH@FLG1_SDWA *--------+---------+---------+---------+---------+---------+---------+- * Copy all of the failure info from the SDWA into the MXECATCH *--------+---------+---------+---------+---------+---------+---------+- LLGT R6,SDWAXPAD Get SDWAPTRS address USING SDWAPTRS,R6 MVC MXECATCH_EC1,SDWAEC1 Copy PSW MVC MXECATCH_ABCC,SDWAABCC Copy completion code LLGT R7,SDWASRVP Get SDWARC1 USING SDWARC1,R7 MVC MXECATCH_CRC,SDWACRC Copy reason code MVC MXECATCH_FAIN,SDWAFAIN Copy failing instruction MVC MXECATCH_AR,SDWAARER Copy ARs MVC MXECATCH_NXT1,SDWANXT1 Copy next instruction address MVC MXECATCH_PASN,SDWAPRIM Primary address space MVC MXECATCH_SASN,SDWASCND Secondary address space MVC MXECATCH_HASN,SDWAASID Home address space *--------+---------+---------+---------+---------+---------+---------+- * Copy the 31-bit general regs at time of error *--------+---------+---------+---------+---------+---------+---------+- LAE R15,SDWAGRSV 31-bit regs LAE R1,MXECATCH_GR Reg area to save them in DO FROM=(R14,=F'16') MXEMAC ZERO,(R0) Clear reg ICM R0,B'1111',0(R15) Get SDWA reg value STG R0,0(,R1) Store as 64-bit LAE R15,4(,R15) Next 31-bit LAE R1,8(,R1) Next 64-bit ENDDO *--------+---------+---------+---------+---------+---------+---------+- * Attempt to get any 64-bit information *--------+---------+---------+---------+---------+---------+---------+- IF (ICM,R10,B'1111',SDWAXEME,NZ) 64-bit stuff present? USING SDWARC4,R10 MVC MXECATCH_GR,SDWAG64 Copy GPRs MVC MXECATCH_TEA,SDWATRNE MVC MXECATCH_BEA,SDWABEA ENDIF *--------+---------+---------+---------+---------+---------+---------+- * Do we have a retry routine address and is retry allowed? *--------+---------+---------+---------+---------+---------+---------+- DOEXIT (ICM,R9,B'1111',MXECATCH_RETRY,Z) DOEXIT (TM,SDWAERRD,SDWACLUP,O) Retry allowed ? *--------+---------+---------+---------+---------+---------+---------+- * Go back to RTM and request retry *--------+---------+---------+---------+---------+---------+---------+- SETRP RC=4, + WKAREA=(R4), + DUMP=NO, + RECORD=YES, + FRESDWA=YES, + RETREGS=YES, + RETADDR=(R9) BR R11 ENDDO *--------+---------+---------+---------+---------+---------+---------+- * Percolate back to RTM (retry noy possible or not MXE env) *--------+---------+---------+---------+---------+---------+---------+- SETRP RC=0,WKAREA=(R4),RECORD=NO,DUMP=NO BR R11 MXEMAIN RETURN *--------+---------+---------+---------+---------+---------+---------+- * Local constants *--------+---------+---------+---------+---------+---------+---------+- MXEMAIN END * * *--------+---------+---------+---------+---------+---------+---------+- * DSECTs *--------+---------+---------+---------+---------+---------+---------+- * * IHASDWA IKJRB IHACDE * MXECATCH DSECT=YES MXEMAC REG_EQU END
; A004759: Binary expansion starts 111. ; 7,14,15,28,29,30,31,56,57,58,59,60,61,62,63,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,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,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484 mov $2,$0 lpb $0 sub $0,1 div $0,2 mul $1,2 add $1,3 lpe mul $1,2 add $1,7 add $1,$2 mov $0,$1
SECTION rodata_font SECTION rodata_font_fzx PUBLIC _ff_dkud3_QuaUni _ff_dkud3_QuaUni: BINARY "font/fzx/fonts/dkud3/QuaUni/qua+uni.fzx"
/* * Copyright 2013+ Ruslan Nigmatullin <euroelessar@yandex.ru> * * 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. */ #ifndef IOREMAP_SWARM_EV_EVENT_LOOP_H #define IOREMAP_SWARM_EV_EVENT_LOOP_H #include "event_loop.hpp" #include <blackhole/platform/compiler.hpp> #include <mutex> #include <list> #if !defined(__clang__) && defined(HAVE_GCC46) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif //!@note: This is workaround libev bug //! http://stackoverflow.com/questions/16660816/libev-4-15-doesnt-compile-on-osx-10-8 //! On OSX EV_ERROR declared in `ev.h` conflicts with that declared //! in `/usr/include/sys/event.h`. #if defined(__APPLE__) && defined(EV_ERROR) #undef EV_ERROR #endif #define EV_MULTIPLICITY 1 #include <ev++.h> #if !defined(__clang__) && defined(HAVE_GCC46) #pragma GCC diagnostic pop #endif namespace ioremap { namespace swarm { /*! * \brief The ev_event_loop is libev-based event loop. */ class ev_event_loop : public event_loop { public: ev_event_loop(ev::loop_ref &loop, const swarm::logger &logger); int socket_request(int socket, poll_option what, void *data); int timer_request(long timeout_ms); void post(const std::function<void ()> &func); protected: void on_socket_event(ev::io &io, int revent); void on_timer(ev::timer &, int); void on_async(ev::async &, int); private: ev::loop_ref &m_loop; ev::timer m_timer; ev::async m_async; std::mutex m_mutex; std::list<std::function<void ()>> m_events; }; } // namespace swarm } // namespace ioremap #endif // IOREMAP_SWARM_EV_EVENT_LOOP_H
; =============================================================== ; Jun 2007 ; =============================================================== ; ; uint zx_aaddr2px(void *attraddr) ; ; Attribute address to pixel x coordinate. ; ; =============================================================== SECTION code_clib SECTION code_arch PUBLIC asm_zx_aaddr2px asm_zx_aaddr2px: ; enter : hl = valid attribute address ; ; exit : hl = pixel x coordinate of leftmost pixel in attr square ; ; uses : af, hl ld a,l rla rla rla and $f8 ld l,a ld h,0 ret
; Addr3Bytes.asm - returns an address that was 3 bytes higher in memory than the return address currently on the stack INCLUDE Irvine32.inc .code main PROC mov eax, 4 call AddrUp3 invoke ExitProcess, 0 main ENDP AddrUp3 PROC pop eax add eax, 0Ch push eax ret AddrUp3 endp END main
title Display Registers page 65,131 include struct.mac ; ; regdisp.asm ; ; Displays all the 8086 registers on the right side of the screen. ; The registers are sampled and displayed roughly 18 times per second. ; Toggle on and off by holding down both shift keys. ; To use with the monochromatic monitor, DISP_BUFFER should be equated ; to 0B000H. In addition, the code in 'outchar' that is involved in ; waiting for horizontal retrace to write a character can be removed. ; This program is loaded into memory and stays resident. It is activated by ; each clock tick (about 18/sec) and is a cpu hog (at least with the ; graphics monitor; about 40% of the cpu is consumed when using the ; graphics monitor due mainly to the busy waits used in writing to the ; screen). ; ; Installation: ; masm regdisp; ; link regdisp; (should get 'No STACK segment' message) ; exe2bin regdisp ; copy regdisp.bin regdisp.com ; DISP_BUFFER equ 0B000H LINE_SIZE equ 19 ON equ 049 ; 254 is alternate OFF equ 032 ; 250 RED equ 4 GREEN equ 2 BLUE equ 1 xx STRUC s_di dw ? s_si dw ? s_es dw ? s_ds dw ? s_dx dw ? s_cx dw ? s_bx dw ? s_ax dw ? s_sp dw ? s_bp dw ? s_pc dw ? s_cs dw ? s_fl dw ? xx ends REGOUT MACRO LINE, REG_NAME, REG_VAL, ATT .xlist mov si,offset REG_NAME mov di,160*LINE - LINE_SIZE*2 mov bh,ATT call w_label mov si,offset rptr mov dx,REG_VAL call w_bits .list endm ERASE MACRO LINE .xlist mov cx,LINE_SIZE mov di,160*LINE - LINE_SIZE*2 rep stosw .list endm abs segment at 0 zero proc far zero endp abs ends cseg segment org 100H assume cs:cseg assume ds:cseg start proc near jmp initial ; ; data block for display d_fl db 'FL:' d_si db 'SI:' d_di db 'DI:' d_ss db 'SS:' d_es db 'ES:' d_ds db 'DS:' d_sp db 'SP:' d_bp db 'BP:' d_dx db 'DX:' d_cx db 'CX:' d_bx db 'BX:' d_ax db 'AX:' display_cs equ $ db 'CS:' display_pc equ $ db 'PC:' rptr db RED,RED,RED,RED db RED+GREEN,RED+GREEN,RED+GREEN,RED+GREEN db RED,RED,RED,RED db RED+GREEN,RED+GREEN,RED+GREEN,RED+GREEN fts db 0 display_flag db 0 intr equ $ sti push bp mov bp,sp add bp,8 push bp ; contents of sp before interrupt push ax push bx push cx push dx push ds push es push si push di mov bp,sp push cs pop ds ; address the data ; mov al,020H ; out 020H,al cld mov ax,40H ; BIOS data area mov es,ax mov cx,es:[17H] ; KB_FLAG and cl,11B xor cl,11B .if z ; left and right shift keys pressed cmp fts,0 jnz once_already xor display_flag,1 ; toggle the display flag .if nz call set_up .endif mov fts,1 ; set the flag jmp once_already .endif mov fts,0 ; reset the flag once_already: .ifs display_flag,1 jmp exit .endif testloc equ $ mov ax,DISP_BUFFER ; display buffer address mov es,ax ; setup for STOSW REGOUT 1,display_pc,[bp].s_pc,BLUE REGOUT 2,display_cs,[bp].s_cs,BLUE+GREEN REGOUT 3,d_ss,ss,BLUE+GREEN REGOUT 4,d_es,[bp].s_es,BLUE+GREEN REGOUT 5,d_ds,[bp].s_ds,BLUE+GREEN REGOUT 6,d_sp,[bp].s_sp,RED REGOUT 7,d_bp,[bp].s_bp,RED REGOUT 8,d_si,[bp].s_si,GREEN REGOUT 9,d_di,[bp].s_di,GREEN REGOUT 10,d_ax,[bp].s_ax,BLUE+RED REGOUT 11,d_bx,[bp].s_bx,BLUE+RED REGOUT 12,d_cx,[bp].s_cx,BLUE+RED REGOUT 13,d_dx,[bp].s_dx,BLUE+RED REGOUT 14,d_fl,[bp].s_fl,BLUE exit: pop di pop si pop es pop ds pop dx pop cx pop bx pop ax pop bp ;dummy pop bp jmploc: jmp zero ; ; ; output character and attribute in bx to word at es:[di]. dx, ax are destroyed. ; di is incremented by 2 outchar: push dx mov dx,03DAH if disp_buffer-0b000H ; test for graphics buffer in al,dx .ifc al,8 ; if in the midst of vertical retrace, do the write .repeat in al,dx ; wait for partial horiz retrace to finish test al,1 .until z .repeat in al,dx ; wait for start of horiz or vert retrace test al,9 .until nz .endif endif mov ax,bx stosw pop dx ret w_label: mov cx,3 .repeat mov bl,[si] call outchar inc si .until loop ret w_bits: mov cx,16 .repeat shl dx,1 .if c mov bl,ON .else mov bl,OFF .endif mov bh,[si] call outchar inc si .until loop ret set_up: mov ax,DISP_BUFFER ; display buffer address mov es,ax mov ax,700H+' ' ; blank out display buffer ERASE 1 ERASE 2 ERASE 3 ERASE 4 ERASE 5 ERASE 6 ERASE 7 ERASE 8 ERASE 9 ERASE 10 ERASE 11 ERASE 12 ERASE 13 ERASE 14 ret initial: push ds xor ax,ax mov ds,ax ; address interrupt vectors mov si,ds:[20H] ; pickup TIMER interrupt values mov cx,ds:[22H] mov ds,cx ; entry to interrupt code mov bx,cs:testloc .if <word ptr [si+testloc-intr]> e bx pop ds int 20H ; exit .endif pop ds mov word ptr jmploc+1,si mov word ptr jmploc+3,cx mov dx,offset intr mov ax,2508H ; setup new timer call int 21H mov dx,offset initial int 27H ; terminal and stay resident start endp cseg ends end start 
* Close file V0.05  1985 Tony Tebby QJUMP * section utils * xdef ut_fclos close file xdef ut_fceof close file eof is OK xdef ut_eofok set eof to OK xdef ut_ok * include dev8_sbsext_ext_keys * ut_fceof bsr.s ut_eofok set end of file to ok ut_fclos move.l d0,-(sp) save error code moveq #io.close,d0 close file trap #2 move.l (sp)+,d0 rts * ut_eofok moveq #err.ef,d4 test for eof cmp.l d0,d4 is it? bne.s utfc_rts ... no, leave it ut_ok moveq #0,d0 ... yes, clear it utfc_rts rts end
; A106189: Expansion of 1/((1-2x^2)sqrt(1-4x)). ; Submitted by Jamie Morken(w3) ; 1,2,8,24,86,300,1096,4032,15062,56684,214880,818800,3133916,12038200,46384432,179193920,693849254,2691994060,10462833808,40729251920,158772196436,619716378280,2421643356592,9472863484160,37090890396284 mov $2,$0 add $2,1 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 mov $1,$0 add $1,$0 bin $1,$0 add $3,1 mul $4,2 add $4,$1 lpe mov $0,$4
; A344510: a(n) = Sum_{k=1..n} k * gcd(k,n). ; Submitted by Jamie Morken(s4) ; 1,5,12,24,35,63,70,112,135,185,176,312,247,371,450,512,425,729,532,920,903,935,782,1488,1125,1313,1458,1848,1247,2475,1426,2304,2277,2261,2660,3672,2035,2831,3198,4400,2501,4977,2752,4664,5265,4163,3290,6912,4459,6125,5508,6552 add $0,1 mov $2,$0 lpb $2 mov $3,$2 gcd $3,$0 mul $3,$2 add $1,$3 sub $2,1 lpe mov $0,$1
#ifndef BELLMAN #define BELLMAN 1 namespace nutshell { #include <iostream> #include <vector> #include "graph" using std::cout; using std::endl; using std::vector; class BellmanFord { public: bool _negativeCycle = false; vector<long> _dist; BellmanFord(Graph g, int source) { _dist.resize(g._n, INF); _dist[source] = 0; for (int t = 0; t < g._n; ++t) { relaxEdges(t, g); } } void relaxEdges(int t, Graph& g) { for (int u = 0; u < g._n; ++u) { if (_dist[u] == INF) { continue; } for (auto e : g._adjacencyList[u]) { if (_dist[e._v] > _dist[u] + e._value) { _dist[e._v] = _dist[u] + e._value; if (t == g._n - 1) { _negativeCycle = true; } } } } } void print() { if (_negativeCycle) { cout << "NEGATIVE CYCLE" << endl; } else { for (auto d : _dist) { if (d == INF) { cout << "INF" << endl; } else { cout << d << endl; } } } } }; } // namespace nutshell #endif // BELLMAN
#pragma once #include "routing_common/maxspeed_conversion.hpp" #include "base/small_map.hpp" #include "base/stl_helpers.hpp" #include <array> #include <cstdint> #include <functional> #include <initializer_list> #include <limits> #include <memory> #include <optional> #include <sstream> #include <string> #include <unordered_map> #include <utility> #include <vector> class Classificator; class FeatureType; namespace feature { class TypesHolder; } namespace routing { double constexpr kNotUsed = std::numeric_limits<double>::max(); struct InOutCityFactor; struct InOutCitySpeedKMpH; // Each value is equal to the corresponding type index from types.txt. // The ascending order is strict. Check for static_cast<HighwayType> in vehicle_model.cpp enum class HighwayType : uint32_t { HighwayResidential = 1, HighwayService = 2, HighwayUnclassified = 4, HighwayFootway = 6, HighwayTrack = 7, HighwayTertiary = 8, HighwaySecondary = 12, HighwayPath = 15, HighwayPrimary = 26, HighwayRoad = 30, HighwayCycleway = 36, HighwayMotorwayLink = 43, HighwayLivingStreet = 54, HighwayMotorway = 57, HighwaySteps = 58, HighwayTrunk = 65, HighwayPedestrian = 69, HighwayTrunkLink = 90, HighwayPrimaryLink = 95, ManMadePier = 119, HighwayBridleway = 167, HighwaySecondaryLink = 176, RouteFerry = 259, HighwayTertiaryLink = 272, RailwayRailMotorVehicle = 994, RouteShuttleTrain = 1054, }; using HighwayBasedFactors = base::SmallMap<HighwayType, InOutCityFactor>; using HighwayBasedSpeeds = base::SmallMap<HighwayType, InOutCitySpeedKMpH>; /// \brief Params for calculation of an approximate speed on a feature. struct SpeedParams { SpeedParams(bool forward, bool inCity, Maxspeed const & maxspeed) : m_maxspeed(maxspeed), m_forward(forward), m_inCity(inCity) { } Maxspeed m_maxspeed; // Retrieve forward (true) or backward (false) speed. bool m_forward; // If a corresponding feature lies inside a city of a town. bool m_inCity; }; /// \brief Speeds which are used for edge weight and ETA estimations. struct SpeedKMpH { constexpr SpeedKMpH() = default; constexpr SpeedKMpH(double weight) noexcept : m_weight(weight), m_eta(weight) {} constexpr SpeedKMpH(double weight, double eta) noexcept : m_weight(weight), m_eta(eta) {} bool operator==(SpeedKMpH const & rhs) const { return m_weight == rhs.m_weight && m_eta == rhs.m_eta; } bool operator!=(SpeedKMpH const & rhs) const { return !(*this == rhs); } bool IsValid() const { return m_weight > 0 && m_eta > 0; } double m_weight = 0.0; // KMpH double m_eta = 0.0; // KMpH }; /// \brief Factors which modify weight and ETA speed on feature in case of bad pavement (reduce) /// or good highway class (increase). /// Both should be greater then 0. struct SpeedFactor { constexpr SpeedFactor() = default; constexpr SpeedFactor(double factor) noexcept : m_weight(factor), m_eta(factor) {} constexpr SpeedFactor(double weight, double eta) noexcept : m_weight(weight), m_eta(eta) {} bool IsValid() const { return m_weight > 0.0 && m_eta > 0.0; } bool operator==(SpeedFactor const & rhs) const { return m_weight == rhs.m_weight && m_eta == rhs.m_eta; } bool operator!=(SpeedFactor const & rhs) const { return !(*this == rhs); } double m_weight = 1.0; double m_eta = 1.0; }; inline SpeedKMpH operator*(SpeedFactor const & factor, SpeedKMpH const & speed) { return {speed.m_weight * factor.m_weight, speed.m_eta * factor.m_eta}; } inline SpeedKMpH operator*(SpeedKMpH const & speed, SpeedFactor const & factor) { return {speed.m_weight * factor.m_weight, speed.m_eta * factor.m_eta}; } struct InOutCitySpeedKMpH { constexpr InOutCitySpeedKMpH() = default; constexpr explicit InOutCitySpeedKMpH(SpeedKMpH const & speed) noexcept : m_inCity(speed), m_outCity(speed) { } constexpr InOutCitySpeedKMpH(SpeedKMpH const & inCity, SpeedKMpH const & outCity) noexcept : m_inCity(inCity), m_outCity(outCity) { } bool operator==(InOutCitySpeedKMpH const & rhs) const { return m_inCity == rhs.m_inCity && m_outCity == rhs.m_outCity; } SpeedKMpH const & GetSpeed(bool isCity) const { return isCity ? m_inCity : m_outCity; } bool IsValid() const { return m_inCity.IsValid() && m_outCity.IsValid(); } SpeedKMpH m_inCity; SpeedKMpH m_outCity; }; struct InOutCityFactor { constexpr explicit InOutCityFactor(SpeedFactor const & factor) noexcept : m_inCity(factor), m_outCity(factor) { } constexpr InOutCityFactor(SpeedFactor const & inCity, SpeedFactor const & outCity) noexcept : m_inCity(inCity), m_outCity(outCity) { } bool operator==(InOutCityFactor const & rhs) const { return m_inCity == rhs.m_inCity && m_outCity == rhs.m_outCity; } SpeedFactor const & GetFactor(bool isCity) const { return isCity ? m_inCity : m_outCity; } bool IsValid() const { return m_inCity.IsValid() && m_outCity.IsValid(); } SpeedFactor m_inCity; SpeedFactor m_outCity; }; struct HighwayBasedInfo { HighwayBasedInfo(HighwayBasedSpeeds const & speeds, HighwayBasedFactors const & factors) : m_speeds(speeds) , m_factors(factors) { } HighwayBasedSpeeds const & m_speeds; HighwayBasedFactors const & m_factors; }; class VehicleModelInterface { public: enum class RoadAvailability { NotAvailable, Available, Unknown, }; virtual ~VehicleModelInterface() = default; /// @return Allowed weight and ETA speed in KMpH. /// 0 means that it's forbidden to move on this feature or it's not a road at all. /// Weight and ETA should be less than max model speed's values respectively. /// @param inCity is true if |f| lies in a city of town. virtual SpeedKMpH GetSpeed(FeatureType & f, SpeedParams const & speedParams) const = 0; virtual HighwayType GetHighwayType(FeatureType & f) const = 0; /// @return Maximum model weight speed. /// All speeds which the model returns must be less than or equal to this speed. virtual double GetMaxWeightSpeed() const = 0; /// @return Offroad speed in KMpH for vehicle. This speed should be used for non-feature routing /// e.g. to connect start point to nearest feature. virtual SpeedKMpH const & GetOffroadSpeed() const = 0; virtual bool IsOneWay(FeatureType & f) const = 0; /// @returns true iff feature |f| can be used for routing with corresponding vehicle model. virtual bool IsRoad(FeatureType & f) const = 0; /// @returns true iff feature |f| can be used for through passage with corresponding vehicle model. /// e.g. in Russia roads tagged "highway = service" are not allowed for through passage; /// however, road with this tag can be be used if it is close enough to the start or destination /// point of the route. /// Roads with additional types e.g. "path = ferry", "vehicle_type = yes" considered as allowed /// to pass through. virtual bool IsPassThroughAllowed(FeatureType & f) const = 0; }; class VehicleModelFactoryInterface { public: virtual ~VehicleModelFactoryInterface() = default; /// @return Default vehicle model which corresponds for all countrines, /// but it may be non optimal for some countries virtual std::shared_ptr<VehicleModelInterface> GetVehicleModel() const = 0; /// @return The most optimal vehicle model for specified country virtual std::shared_ptr<VehicleModelInterface> GetVehicleModelForCountry( std::string const & country) const = 0; }; class VehicleModel : public VehicleModelInterface { public: struct FeatureTypeLimits { std::vector<std::string> m_type; bool m_isPassThroughAllowed; // pass through this road type is allowed }; struct FeatureTypeSurface { std::vector<std::string> m_type; // road surface type 'psurface=*' SpeedFactor m_factor; }; struct AdditionalRoad { std::vector<std::string> m_type; InOutCitySpeedKMpH m_speed; }; using AdditionalRoadsList = std::initializer_list<AdditionalRoad>; using LimitsInitList = std::initializer_list<FeatureTypeLimits>; using SurfaceInitList = std::initializer_list<FeatureTypeSurface>; VehicleModel(Classificator const & classif, LimitsInitList const & featureTypeLimits, SurfaceInitList const & featureTypeSurface, HighwayBasedInfo const & info); /// @name VehicleModelInterface overrides. /// @{ SpeedKMpH GetSpeed(FeatureType & f, SpeedParams const & speedParams) const override; HighwayType GetHighwayType(FeatureType & f) const override; double GetMaxWeightSpeed() const override; bool IsOneWay(FeatureType & f) const override; bool IsRoad(FeatureType & f) const override; bool IsPassThroughAllowed(FeatureType & f) const override; /// @} public: /// @returns true if |m_highwayTypes| or |m_addRoadTypes| contains |type| and false otherwise. bool IsRoadType(uint32_t type) const; template <class TList> bool HasRoadType(TList const & types) const { for (uint32_t t : types) { if (IsRoadType(t)) return true; } return false; } bool EqualsForTests(VehicleModel const & rhs) const { return (m_roadTypes == rhs.m_roadTypes) && (m_addRoadTypes == rhs.m_addRoadTypes) && (m_onewayType == rhs.m_onewayType); } protected: /// @returns a special restriction which is set to the feature. virtual RoadAvailability GetRoadAvailability(feature::TypesHolder const & types) const; void AddAdditionalRoadTypes(Classificator const & classif, AdditionalRoadsList const & roads); static uint32_t PrepareToMatchType(uint32_t type); /// \returns true if |types| is a oneway feature. /// \note According to OSM, tag "oneway" could have value "-1". That means it's a oneway feature /// with reversed geometry. In that case at map generation the geometry of such features /// is reversed (the order of points is changed) so in vehicle model all oneway feature /// may be considered as features with forward geometry. bool HasOneWayType(feature::TypesHolder const & types) const; bool HasPassThroughType(feature::TypesHolder const & types) const; SpeedKMpH GetTypeSpeed(feature::TypesHolder const & types, SpeedParams const & speedParams) const; SpeedKMpH GetSpeedWihtoutMaxspeed(FeatureType & f, SpeedParams const & speedParams) const; /// \brief Maximum within all the speed limits set in a model (car model, bicycle model and so on). /// Do not mix with maxspeed value tag, which defines maximum legal speed on a feature. InOutCitySpeedKMpH m_maxModelSpeed; private: std::optional<HighwayType> GetHighwayType(uint32_t type) const; void GetSurfaceFactor(uint32_t type, SpeedFactor & factor) const; void GetAdditionalRoadSpeed(uint32_t type, bool isCityRoad, std::optional<SpeedKMpH> & speed) const; SpeedKMpH GetSpeedOnFeatureWithoutMaxspeed(HighwayType const & type, SpeedParams const & speedParams) const; SpeedKMpH GetSpeedOnFeatureWithMaxspeed(HighwayType const & type, SpeedParams const & speedParams) const; // HW type -> speed and factor. HighwayBasedInfo m_highwayBasedInfo; uint32_t m_onewayType; // HW type -> allow pass through. base::SmallMap<uint32_t, bool> m_roadTypes; // Mapping surface types psurface={paved_good/paved_bad/unpaved_good/unpaved_bad} to surface speed factors. base::SmallMapBase<uint32_t, SpeedFactor> m_surfaceFactors; /// @todo Do we really need a separate map here or can merge with the m_roadTypes map? base::SmallMapBase<uint32_t, InOutCitySpeedKMpH> m_addRoadTypes; }; class VehicleModelFactory : public VehicleModelFactoryInterface { public: // Callback which takes territory name (mwm graph node name) and returns its parent // territory name. Used to properly find local restrictions in GetVehicleModelForCountry. // For territories which do not have parent (countries) or have multiple parents // (disputed territories) it should return empty name. // For example "Munich" -> "Bavaria"; "Bavaria" -> "Germany"; "Germany" -> "" using CountryParentNameGetterFn = std::function<std::string(std::string const &)>; std::shared_ptr<VehicleModelInterface> GetVehicleModel() const override; std::shared_ptr<VehicleModelInterface> GetVehicleModelForCountry( std::string const & country) const override; protected: explicit VehicleModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn); std::string GetParent(std::string const & country) const; std::unordered_map<std::string, std::shared_ptr<VehicleModelInterface>> m_models; CountryParentNameGetterFn m_countryParentNameGetterFn; }; HighwayBasedFactors GetOneFactorsForBicycleAndPedestrianModel(); std::string DebugPrint(VehicleModelInterface::RoadAvailability const l); std::string DebugPrint(SpeedKMpH const & speed); std::string DebugPrint(SpeedFactor const & speedFactor); std::string DebugPrint(InOutCitySpeedKMpH const & speed); std::string DebugPrint(InOutCityFactor const & speedFactor); std::string DebugPrint(HighwayType type); } // namespace routing
#ifndef CENTURION_RASPBERRY_PI_HINTS_HEADER #define CENTURION_RASPBERRY_PI_HINTS_HEADER #include <SDL.h> #include "../core/str.hpp" #include "../detail/hints_impl.hpp" namespace cen::hint::raspberrypi { /// \addtogroup hints /// \{ struct video_layer final : detail::int_hint<video_layer> { [[nodiscard]] constexpr static auto name() noexcept -> str { return SDL_HINT_RPI_VIDEO_LAYER; } }; /// \} End of group hints } // namespace cen::hint::raspberrypi #endif // CENTURION_RASPBERRY_PI_HINTS_HEADER
// 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 "net/quic/reliable_quic_stream.h" #include "net/quic/quic_connection.h" #include "net/quic/quic_utils.h" #include "net/quic/test_tools/quic_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" using base::StringPiece; using testing::_; using testing::InSequence; using testing::Return; using testing::StrEq; namespace net { namespace test { namespace { const char kData1[] = "FooAndBar"; const char kData2[] = "EepAndBaz"; const size_t kDataLen = 9; class QuicReliableTestStream : public ReliableQuicStream { public: QuicReliableTestStream(QuicStreamId id, QuicSession* session) : ReliableQuicStream(id, session) { } virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE { return 0; } using ReliableQuicStream::WriteData; }; class ReliableQuicStreamTest : public ::testing::TestWithParam<bool> { public: ReliableQuicStreamTest() : connection_(new MockConnection(1, IPEndPoint())), session_(connection_, true), stream_(1, &session_) { } MockConnection* connection_; MockSession session_; QuicReliableTestStream stream_; }; TEST_F(ReliableQuicStreamTest, WriteAllData) { connection_->options()->max_packet_length = 1 + QuicPacketCreator::StreamFramePacketOverhead(1, !kIncludeVersion); // TODO(rch): figure out how to get StrEq working here. //EXPECT_CALL(session_, WriteData(_, StrEq(kData1), _, _)).WillOnce( EXPECT_CALL(session_, WriteData(1, _, _, _)).WillOnce( Return(QuicConsumedData(kDataLen, true))); EXPECT_EQ(kDataLen, stream_.WriteData(kData1, false).bytes_consumed); } TEST_F(ReliableQuicStreamTest, WriteData) { connection_->options()->max_packet_length = 1 + QuicPacketCreator::StreamFramePacketOverhead(1, !kIncludeVersion); // TODO(rch): figure out how to get StrEq working here. //EXPECT_CALL(session_, WriteData(_, StrEq(kData1), _, _)).WillOnce( EXPECT_CALL(session_, WriteData(_, _, _, _)).WillOnce( Return(QuicConsumedData(kDataLen - 1, false))); // The return will be kDataLen, because the last byte gets buffered. EXPECT_EQ(kDataLen, stream_.WriteData(kData1, false).bytes_consumed); // Queue a bytes_consumed write. EXPECT_EQ(kDataLen, stream_.WriteData(kData2, false).bytes_consumed); // Make sure we get the tail of the first write followed by the bytes_consumed InSequence s; //EXPECT_CALL(session_, WriteData(_, StrEq(&kData2[kDataLen - 1]), _, _)). EXPECT_CALL(session_, WriteData(_, _, _, _)). WillOnce(Return(QuicConsumedData(1, false))); //EXPECT_CALL(session_, WriteData(_, StrEq(kData2), _, _)). EXPECT_CALL(session_, WriteData(_, _, _, _)). WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); stream_.OnCanWrite(); // And finally the end of the bytes_consumed //EXPECT_CALL(session_, WriteData(_, StrEq(&kData2[kDataLen - 2]), _, _)). EXPECT_CALL(session_, WriteData(_, _, _, _)). WillOnce(Return(QuicConsumedData(2, true))); stream_.OnCanWrite(); } } // namespace } // namespace test } // namespace net
/******************************************************************** * COPYRIGHT: * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /* Modification History: * Date Name Description * 07/15/99 helena Ported to HPUX 10/11 CC. */ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING #include "numfmtst.h" #include "unicode/dcfmtsym.h" #include "unicode/decimfmt.h" #include "unicode/ucurr.h" #include "unicode/ustring.h" #include "unicode/measfmt.h" #include "unicode/curramt.h" #include "digitlst.h" #include "textfile.h" #include "tokiter.h" #include "charstr.h" #include "putilimp.h" #include "winnmtst.h" #include <float.h> #include <string.h> #include <stdlib.h> #include "cstring.h" #include "unicode/numsys.h" //#define NUMFMTST_CACHE_DEBUG 1 #include "stdio.h" /* for sprintf */ // #include "iostream" // for cout //#define NUMFMTST_DEBUG 1 static const UChar EUR[] = {69,85,82,0}; // "EUR" static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD" // ***************************************************************************** // class NumberFormatTest // ***************************************************************************** #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break #define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; } #define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; } void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) { // if (exec) logln((UnicodeString)"TestSuite DateFormatTest"); switch (index) { CASE(0,TestCurrencySign); CASE(1,TestCurrency); CASE(2,TestParse); CASE(3,TestRounding487); CASE(4,TestQuotes); CASE(5,TestExponential); CASE(6,TestPatterns); // Upgrade to alphaWorks - liu 5/99 CASE(7,TestExponent); CASE(8,TestScientific); CASE(9,TestPad); CASE(10,TestPatterns2); CASE(11,TestSecondaryGrouping); CASE(12,TestSurrogateSupport); CASE(13,TestAPI); CASE(14,TestCurrencyObject); CASE(15,TestCurrencyPatterns); //CASE(16,TestDigitList); CASE(16,TestWhiteSpaceParsing); CASE(17,TestComplexCurrency); // This test removed because CLDR no longer uses choice formats in currency symbols. CASE(18,TestRegCurrency); CASE(19,TestSymbolsWithBadLocale); CASE(20,TestAdoptDecimalFormatSymbols); CASE(21,TestScientific2); CASE(22,TestScientificGrouping); CASE(23,TestInt64); CASE(24,TestPerMill); CASE(25,TestIllegalPatterns); CASE(26,TestCases); CASE(27,TestCurrencyNames); CASE(28,TestCurrencyAmount); CASE(29,TestCurrencyUnit); CASE(30,TestCoverage); CASE(31,TestJB3832); CASE(32,TestHost); CASE(33,TestHostClone); CASE(34,TestCurrencyFormat); CASE(35,TestRounding); CASE(36,TestNonpositiveMultiplier); CASE(37,TestNumberingSystems); CASE(38,TestSpaceParsing); CASE(39,TestMultiCurrencySign); CASE(40,TestCurrencyFormatForMixParsing); CASE(41,TestDecimalFormatCurrencyParse); CASE(42,TestCurrencyIsoPluralFormat); CASE(43,TestCurrencyParsing); CASE(44,TestParseCurrencyInUCurr); CASE(45,TestFormatAttributes); CASE(46,TestFieldPositionIterator); CASE(47,TestDecimal); CASE(48,TestCurrencyFractionDigits); CASE(49,TestExponentParse); default: name = ""; break; } } // ------------------------------------- // Test API (increase code coverage) void NumberFormatTest::TestAPI(void) { logln("Test API"); UErrorCode status = U_ZERO_ERROR; NumberFormat *test = NumberFormat::createInstance("root", status); if(U_FAILURE(status)) { dataerrln("unable to create format object - %s", u_errorName(status)); } if(test != NULL) { test->setMinimumIntegerDigits(10); test->setMaximumIntegerDigits(2); test->setMinimumFractionDigits(10); test->setMaximumFractionDigits(2); UnicodeString result; FieldPosition pos; Formattable bla("Paja Patak"); // Donald Duck for non Serbian speakers test->format(bla, result, pos, status); if(U_SUCCESS(status)) { errln("Yuck... Formatted a duck... As a number!"); } else { status = U_ZERO_ERROR; } result.remove(); int64_t ll = 12; test->format(ll, result); if (result != "12.00"){ errln("format int64_t error"); } ParsePosition ppos; test->parseCurrency("",bla,ppos); if(U_FAILURE(status)) { errln("Problems accessing the parseCurrency function for NumberFormat"); } delete test; } } class StubNumberForamt :public NumberFormat{ public: StubNumberForamt(){}; virtual UnicodeString& format(double ,UnicodeString& appendTo,FieldPosition& ) const { return appendTo; } virtual UnicodeString& format(int32_t ,UnicodeString& appendTo,FieldPosition& ) const { return appendTo.append((UChar)0x0033); } virtual UnicodeString& format(int64_t number,UnicodeString& appendTo,FieldPosition& pos) const { return NumberFormat::format(number, appendTo, pos); } virtual UnicodeString& format(const Formattable& , UnicodeString& appendTo, FieldPosition& , UErrorCode& ) const { return appendTo; } virtual void parse(const UnicodeString& , Formattable& , ParsePosition& ) const {} virtual void parse( const UnicodeString& , Formattable& , UErrorCode& ) const {} virtual UClassID getDynamicClassID(void) const { static char classID = 0; return (UClassID)&classID; } virtual Format* clone() const {return NULL;} }; void NumberFormatTest::TestCoverage(void){ StubNumberForamt stub; UnicodeString agent("agent"); FieldPosition pos; int64_t num = 4; if (stub.format(num, agent, pos) != UnicodeString("agent3")){ errln("NumberFormat::format(int64, UnicodString&, FieldPosition&) should delegate to (int32, ,)"); }; } // Test various patterns void NumberFormatTest::TestPatterns(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols sym(Locale::getUS(), status); if (U_FAILURE(status)) { errcheckln(status, "FAIL: Could not construct DecimalFormatSymbols - %s", u_errorName(status)); return; } const char* pat[] = { "#.#", "#.", ".#", "#" }; int32_t pat_length = (int32_t)(sizeof(pat) / sizeof(pat[0])); const char* newpat[] = { "#0.#", "#0.", "#.0", "#" }; const char* num[] = { "0", "0.", ".0", "0" }; for (int32_t i=0; i<pat_length; ++i) { status = U_ZERO_ERROR; DecimalFormat fmt(pat[i], sym, status); if (U_FAILURE(status)) { errln((UnicodeString)"FAIL: DecimalFormat constructor failed for " + pat[i]); continue; } UnicodeString newp; fmt.toPattern(newp); if (!(newp == newpat[i])) errln((UnicodeString)"FAIL: Pattern " + pat[i] + " should transmute to " + newpat[i] + "; " + newp + " seen instead"); UnicodeString s; (*(NumberFormat*)&fmt).format((int32_t)0, s); if (!(s == num[i])) { errln((UnicodeString)"FAIL: Pattern " + pat[i] + " should format zero as " + num[i] + "; " + s + " seen instead"); logln((UnicodeString)"Min integer digits = " + fmt.getMinimumIntegerDigits()); } } } /* icu_2_4::DigitList::operator== 0 0 2 icuuc24d.dll digitlst.cpp Doug icu_2_4::DigitList::append 0 0 4 icuin24d.dll digitlst.h Doug icu_2_4::DigitList::operator!= 0 0 1 icuuc24d.dll digitlst.h Doug */ /* void NumberFormatTest::TestDigitList(void) { // API coverage for DigitList DigitList list1; list1.append('1'); list1.fDecimalAt = 1; DigitList list2; list2.set((int32_t)1); if (list1 != list2) { errln("digitlist append, operator!= or set failed "); } if (!(list1 == list2)) { errln("digitlist append, operator== or set failed "); } } */ // ------------------------------------- // Test exponential pattern void NumberFormatTest::TestExponential(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols sym(Locale::getUS(), status); if (U_FAILURE(status)) { errcheckln(status, "FAIL: Bad status returned by DecimalFormatSymbols ct - %s", u_errorName(status)); return; } const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" }; int32_t pat_length = (int32_t)(sizeof(pat) / sizeof(pat[0])); // The following #if statements allow this test to be built and run on // platforms that do not have standard IEEE numerics. For example, // S/390 doubles have an exponent range of -78 to +75. For the // following #if statements to work, float.h must define // DBL_MAX_10_EXP to be a compile-time constant. // This section may be expanded as needed. #if DBL_MAX_10_EXP > 300 double val[] = { 0.01234, 123456789, 1.23e300, -3.141592653e-271 }; int32_t val_length = (int32_t)(sizeof(val) / sizeof(val[0])); const char* valFormat[] = { // 0.####E0 "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271", // 00.000E00 "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272", // ##0.######E000 "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273", // 0.###E0;[0.###E0] "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]" }; double valParse[] = { 0.01234, 123460000, 1.23E300, -3.1416E-271, 0.01234, 123460000, 1.23E300, -3.1416E-271, 0.01234, 123456800, 1.23E300, -3.141593E-271, 0.01234, 123500000, 1.23E300, -3.142E-271, }; #elif DBL_MAX_10_EXP > 70 double val[] = { 0.01234, 123456789, 1.23e70, -3.141592653e-71 }; int32_t val_length = sizeof(val) / sizeof(val[0]); char* valFormat[] = { // 0.####E0 "1.234E-2", "1.2346E8", "1.23E70", "-3.1416E-71", // 00.000E00 "12.340E-03", "12.346E07", "12.300E69", "-31.416E-72", // ##0.######E000 "12.34E-003", "123.4568E006", "12.3E069", "-31.41593E-072", // 0.###E0;[0.###E0] "1.234E-2", "1.235E8", "1.23E70", "[3.142E-71]" }; double valParse[] = { 0.01234, 123460000, 1.23E70, -3.1416E-71, 0.01234, 123460000, 1.23E70, -3.1416E-71, 0.01234, 123456800, 1.23E70, -3.141593E-71, 0.01234, 123500000, 1.23E70, -3.142E-71, }; #else // Don't test double conversion double* val = 0; int32_t val_length = 0; char** valFormat = 0; double* valParse = 0; logln("Warning: Skipping double conversion tests"); #endif int32_t lval[] = { 0, -1, 1, 123456789 }; int32_t lval_length = (int32_t)(sizeof(lval) / sizeof(lval[0])); const char* lvalFormat[] = { // 0.####E0 "0E0", "-1E0", "1E0", "1.2346E8", // 00.000E00 "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07", // ##0.######E000 "0E000", "-1E000", "1E000", "123.4568E006", // 0.###E0;[0.###E0] "0E0", "[1E0]", "1E0", "1.235E8" }; int32_t lvalParse[] = { 0, -1, 1, 123460000, 0, -1, 1, 123460000, 0, -1, 1, 123456800, 0, -1, 1, 123500000, }; int32_t ival = 0, ilval = 0; for (int32_t p=0; p<pat_length; ++p) { DecimalFormat fmt(pat[p], sym, status); if (U_FAILURE(status)) { errln("FAIL: Bad status returned by DecimalFormat ct"); continue; } UnicodeString pattern; logln((UnicodeString)"Pattern \"" + pat[p] + "\" -toPattern-> \"" + fmt.toPattern(pattern) + "\""); int32_t v; for (v=0; v<val_length; ++v) { UnicodeString s; (*(NumberFormat*)&fmt).format(val[v], s); logln((UnicodeString)" " + val[v] + " -format-> " + s); if (s != valFormat[v+ival]) errln((UnicodeString)"FAIL: Expected " + valFormat[v+ival]); ParsePosition pos(0); Formattable af; fmt.parse(s, af, pos); double a; UBool useEpsilon = FALSE; if (af.getType() == Formattable::kLong) a = af.getLong(); else if (af.getType() == Formattable::kDouble) { a = af.getDouble(); #if defined(OS390) || defined(OS400) // S/390 will show a failure like this: //| -3.141592652999999e-271 -format-> -3.1416E-271 //| -parse-> -3.1416e-271 //| FAIL: Expected -3.141599999999999e-271 // To compensate, we use an epsilon-based equality // test on S/390 only. We don't want to do this in // general because it's less exacting. useEpsilon = TRUE; #endif } else { errln((UnicodeString)"FAIL: Non-numeric Formattable returned"); continue; } if (pos.getIndex() == s.length()) { logln((UnicodeString)" -parse-> " + a); // Use epsilon comparison as necessary if ((useEpsilon && (uprv_fabs(a - valParse[v+ival]) / a > (2*DBL_EPSILON))) || (!useEpsilon && a != valParse[v+ival])) { errln((UnicodeString)"FAIL: Expected " + valParse[v+ival]); } } else { errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a); errln((UnicodeString)" should be (" + s.length() + " chars) -> " + valParse[v+ival]); } } for (v=0; v<lval_length; ++v) { UnicodeString s; (*(NumberFormat*)&fmt).format(lval[v], s); logln((UnicodeString)" " + lval[v] + "L -format-> " + s); if (s != lvalFormat[v+ilval]) errln((UnicodeString)"ERROR: Expected " + lvalFormat[v+ilval] + " Got: " + s); ParsePosition pos(0); Formattable af; fmt.parse(s, af, pos); if (af.getType() == Formattable::kLong || af.getType() == Formattable::kInt64) { UErrorCode status = U_ZERO_ERROR; int32_t a = af.getLong(status); if (pos.getIndex() == s.length()) { logln((UnicodeString)" -parse-> " + a); if (a != lvalParse[v+ilval]) errln((UnicodeString)"FAIL: Expected " + lvalParse[v+ilval]); } else errln((UnicodeString)"FAIL: Partial parse (" + pos.getIndex() + " chars) -> " + a); } else errln((UnicodeString)"FAIL: Non-long Formattable returned for " + s + " Double: " + af.getDouble() + ", Long: " + af.getLong()); } ival += val_length; ilval += lval_length; } } void NumberFormatTest::TestScientific2() { // jb 2552 UErrorCode status = U_ZERO_ERROR; DecimalFormat* fmt = (DecimalFormat*)NumberFormat::createCurrencyInstance("en_US", status); if (U_SUCCESS(status)) { double num = 12.34; expect(*fmt, num, "$12.34"); fmt->setScientificNotation(TRUE); expect(*fmt, num, "$1.23E1"); fmt->setScientificNotation(FALSE); expect(*fmt, num, "$12.34"); } delete fmt; } void NumberFormatTest::TestScientificGrouping() { // jb 2552 UErrorCode status = U_ZERO_ERROR; DecimalFormat fmt("##0.00E0",status); if (U_SUCCESS(status)) { expect(fmt, .01234, "12.3E-3"); expect(fmt, .1234, "123E-3"); expect(fmt, 1.234, "1.23E0"); expect(fmt, 12.34, "12.3E0"); expect(fmt, 123.4, "123E0"); expect(fmt, 1234., "1.23E3"); } } /*static void setFromString(DigitList& dl, const char* str) { char c; UBool decimalSet = FALSE; dl.clear(); while ((c = *str++)) { if (c == '-') { dl.fIsPositive = FALSE; } else if (c == '+') { dl.fIsPositive = TRUE; } else if (c == '.') { dl.fDecimalAt = dl.fCount; decimalSet = TRUE; } else { dl.append(c); } } if (!decimalSet) { dl.fDecimalAt = dl.fCount; } }*/ void NumberFormatTest::TestInt64() { UErrorCode status = U_ZERO_ERROR; DecimalFormat fmt("#.#E0",status); fmt.setMaximumFractionDigits(20); if (U_SUCCESS(status)) { expect(fmt, (Formattable)(int64_t)0, "0E0"); expect(fmt, (Formattable)(int64_t)-1, "-1E0"); expect(fmt, (Formattable)(int64_t)1, "1E0"); expect(fmt, (Formattable)(int64_t)2147483647, "2.147483647E9"); expect(fmt, (Formattable)((int64_t)-2147483647-1), "-2.147483648E9"); expect(fmt, (Formattable)(int64_t)U_INT64_MAX, "9.223372036854775807E18"); expect(fmt, (Formattable)(int64_t)U_INT64_MIN, "-9.223372036854775808E18"); } // also test digitlist /* int64_t int64max = U_INT64_MAX; int64_t int64min = U_INT64_MIN; const char* int64maxstr = "9223372036854775807"; const char* int64minstr = "-9223372036854775808"; UnicodeString fail("fail: "); // test max int64 value DigitList dl; setFromString(dl, int64maxstr); { if (!dl.fitsIntoInt64(FALSE)) { errln(fail + int64maxstr + " didn't fit"); } int64_t int64Value = dl.getInt64(); if (int64Value != int64max) { errln(fail + int64maxstr); } dl.set(int64Value); int64Value = dl.getInt64(); if (int64Value != int64max) { errln(fail + int64maxstr); } } // test negative of max int64 value (1 shy of min int64 value) dl.fIsPositive = FALSE; { if (!dl.fitsIntoInt64(FALSE)) { errln(fail + "-" + int64maxstr + " didn't fit"); } int64_t int64Value = dl.getInt64(); if (int64Value != -int64max) { errln(fail + "-" + int64maxstr); } dl.set(int64Value); int64Value = dl.getInt64(); if (int64Value != -int64max) { errln(fail + "-" + int64maxstr); } } // test min int64 value setFromString(dl, int64minstr); { if (!dl.fitsIntoInt64(FALSE)) { errln(fail + "-" + int64minstr + " didn't fit"); } int64_t int64Value = dl.getInt64(); if (int64Value != int64min) { errln(fail + int64minstr); } dl.set(int64Value); int64Value = dl.getInt64(); if (int64Value != int64min) { errln(fail + int64minstr); } } // test negative of min int 64 value (1 more than max int64 value) dl.fIsPositive = TRUE; // won't fit { if (dl.fitsIntoInt64(FALSE)) { errln(fail + "-(" + int64minstr + ") didn't fit"); } }*/ } // ------------------------------------- // Test the handling of quotes void NumberFormatTest::TestQuotes(void) { UErrorCode status = U_ZERO_ERROR; UnicodeString *pat; DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), status); if (U_FAILURE(status)) { errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status)); delete sym; return; } pat = new UnicodeString("a'fo''o'b#"); DecimalFormat *fmt = new DecimalFormat(*pat, *sym, status); UnicodeString s; ((NumberFormat*)fmt)->format((int32_t)123, s); logln((UnicodeString)"Pattern \"" + *pat + "\""); logln((UnicodeString)" Format 123 -> " + escape(s)); if (!(s=="afo'ob123")) errln((UnicodeString)"FAIL: Expected afo'ob123"); s.truncate(0); delete fmt; delete pat; pat = new UnicodeString("a''b#"); fmt = new DecimalFormat(*pat, *sym, status); ((NumberFormat*)fmt)->format((int32_t)123, s); logln((UnicodeString)"Pattern \"" + *pat + "\""); logln((UnicodeString)" Format 123 -> " + escape(s)); if (!(s=="a'b123")) errln((UnicodeString)"FAIL: Expected a'b123"); delete fmt; delete pat; delete sym; } /** * Test the handling of the currency symbol in patterns. */ void NumberFormatTest::TestCurrencySign(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale::getUS(), status); UnicodeString pat; UChar currency = 0x00A4; if (U_FAILURE(status)) { errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status)); delete sym; return; } // "\xA4#,##0.00;-\xA4#,##0.00" pat.append(currency).append("#,##0.00;-"). append(currency).append("#,##0.00"); DecimalFormat *fmt = new DecimalFormat(pat, *sym, status); UnicodeString s; ((NumberFormat*)fmt)->format(1234.56, s); pat.truncate(0); logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\""); logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s)); if (s != "$1,234.56") dataerrln((UnicodeString)"FAIL: Expected $1,234.56"); s.truncate(0); ((NumberFormat*)fmt)->format(- 1234.56, s); logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s)); if (s != "-$1,234.56") dataerrln((UnicodeString)"FAIL: Expected -$1,234.56"); delete fmt; pat.truncate(0); // "\xA4\xA4 #,##0.00;\xA4\xA4 -#,##0.00" pat.append(currency).append(currency). append(" #,##0.00;"). append(currency).append(currency). append(" -#,##0.00"); fmt = new DecimalFormat(pat, *sym, status); s.truncate(0); ((NumberFormat*)fmt)->format(1234.56, s); logln((UnicodeString)"Pattern \"" + fmt->toPattern(pat) + "\""); logln((UnicodeString)" Format " + 1234.56 + " -> " + escape(s)); if (s != "USD 1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD 1,234.56"); s.truncate(0); ((NumberFormat*)fmt)->format(-1234.56, s); logln((UnicodeString)" Format " + (-1234.56) + " -> " + escape(s)); if (s != "USD -1,234.56") dataerrln((UnicodeString)"FAIL: Expected USD -1,234.56"); delete fmt; delete sym; if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + u_errorName(status)); } // ------------------------------------- static UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); } UnicodeString& NumberFormatTest::escape(UnicodeString& s) { UnicodeString buf; for (int32_t i=0; i<s.length(); ++i) { UChar c = s[(int32_t)i]; if (c <= (UChar)0x7F) buf += c; else { buf += (UChar)0x5c; buf += (UChar)0x55; buf += toHexString((c & 0xF000) >> 12); buf += toHexString((c & 0x0F00) >> 8); buf += toHexString((c & 0x00F0) >> 4); buf += toHexString(c & 0x000F); } } return (s = buf); } // ------------------------------------- static const char* testCases[][2]= { /* locale ID */ /* expected */ {"ca_ES_PREEURO", "1.150\\u00A0\\u20A7" }, {"de_LU_PREEURO", "1,150\\u00A0F" }, {"el_GR_PREEURO", "1.150,50\\u00A0\\u0394\\u03C1\\u03C7" }, {"en_BE_PREEURO", "1.150,50\\u00A0BF" }, {"es_ES_PREEURO", "\\u20A7\\u00A01.150" }, {"eu_ES_PREEURO", "1.150\\u00A0\\u20A7" }, {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" }, {"it_IT_PREEURO", "IT\\u20A4\\u00A01.150" }, {"pt_PT_PREEURO", "1,150$50\\u00A0Esc."}, {"en_US@currency=JPY", "\\u00A51,150"}, {"en_US@currency=jpy", "\\u00A51,150"}, {"en-US-u-cu-jpy", "\\u00A51,150"} }; /** * Test localized currency patterns. */ void NumberFormatTest::TestCurrency(void) { UErrorCode status = U_ZERO_ERROR; NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(Locale::getCanadaFrench(), status); if (U_FAILURE(status)) { dataerrln("Error calling NumberFormat::createCurrencyInstance()"); return; } UnicodeString s; currencyFmt->format(1.50, s); logln((UnicodeString)"Un pauvre ici a..........." + s); if (!(s==CharsToUnicodeString("1,50\\u00A0$"))) errln((UnicodeString)"FAIL: Expected 1,50<nbsp>$"); delete currencyFmt; s.truncate(0); char loc[256]={0}; int len = uloc_canonicalize("de_DE_PREEURO", loc, 256, &status); currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc),status); currencyFmt->format(1.50, s); logln((UnicodeString)"Un pauvre en Allemagne a.." + s); if (!(s==CharsToUnicodeString("1,50\\u00A0DM"))) errln((UnicodeString)"FAIL: Expected 1,50<nbsp>DM"); delete currencyFmt; s.truncate(0); len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status); currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status); currencyFmt->format(1.50, s); logln((UnicodeString)"Un pauvre en France a....." + s); if (!(s==CharsToUnicodeString("1,50\\u00A0F"))) errln((UnicodeString)"FAIL: Expected 1,50<nbsp>F"); delete currencyFmt; if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + (int32_t)status); for(int i=0; i < (int)(sizeof(testCases)/sizeof(testCases[i])); i++){ status = U_ZERO_ERROR; const char *localeID = testCases[i][0]; UnicodeString expected(testCases[i][1], -1, US_INV); expected = expected.unescape(); s.truncate(0); char loc[256]={0}; uloc_canonicalize(localeID, loc, 256, &status); currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status); if(U_FAILURE(status)){ errln("Could not create currency formatter for locale %s",localeID); continue; } currencyFmt->format(1150.50, s); if(s!=expected){ errln(UnicodeString("FAIL: Expected: ")+expected + UnicodeString(" Got: ") + s + UnicodeString( " for locale: ")+ UnicodeString(localeID) ); } if (U_FAILURE(status)){ errln((UnicodeString)"FAIL: Status " + (int32_t)status); } delete currencyFmt; } } // ------------------------------------- /** * Test the Currency object handling, new as of ICU 2.2. */ void NumberFormatTest::TestCurrencyObject() { UErrorCode ec = U_ZERO_ERROR; NumberFormat* fmt = NumberFormat::createCurrencyInstance(Locale::getUS(), ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getCurrencyInstance(US) - %s", u_errorName(ec)); delete fmt; return; } Locale null("", "", ""); expectCurrency(*fmt, null, 1234.56, "$1,234.56"); expectCurrency(*fmt, Locale::getFrance(), 1234.56, CharsToUnicodeString("\\u20AC1,234.56")); // Euro expectCurrency(*fmt, Locale::getJapan(), 1234.56, CharsToUnicodeString("\\u00A51,235")); // Yen expectCurrency(*fmt, Locale("fr", "CH", ""), 1234.56, "CHF1,234.55"); // 0.05 rounding expectCurrency(*fmt, Locale::getUS(), 1234.56, "$1,234.56"); delete fmt; fmt = NumberFormat::createCurrencyInstance(Locale::getFrance(), ec); if (U_FAILURE(ec)) { errln("FAIL: getCurrencyInstance(FRANCE)"); delete fmt; return; } expectCurrency(*fmt, null, 1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); expectCurrency(*fmt, Locale::getJapan(), 1234.56, CharsToUnicodeString("1 235 \\u00A5JP")); // Yen expectCurrency(*fmt, Locale("fr", "CH", ""), 1234.56, "1 234,55 CHF"); // 0.05 rounding expectCurrency(*fmt, Locale::getUS(), 1234.56, "1 234,56 $US"); expectCurrency(*fmt, Locale::getFrance(), 1234.56, CharsToUnicodeString("1 234,56 \\u20AC")); // Euro delete fmt; } // ------------------------------------- /** * Do rudimentary testing of parsing. */ void NumberFormatTest::TestParse(void) { UErrorCode status = U_ZERO_ERROR; UnicodeString arg("0"); DecimalFormat* format = new DecimalFormat("00", status); //try { Formattable n; format->parse(arg, n, status); logln((UnicodeString)"parse(" + arg + ") = " + n.getLong()); if (n.getType() != Formattable::kLong || n.getLong() != 0) errln((UnicodeString)"FAIL: Expected 0"); delete format; if (U_FAILURE(status)) errcheckln(status, (UnicodeString)"FAIL: Status " + u_errorName(status)); //} //catch(Exception e) { // errln((UnicodeString)"Exception caught: " + e); //} } // ------------------------------------- /** * Test proper rounding by the format method. */ void NumberFormatTest::TestRounding487(void) { UErrorCode status = U_ZERO_ERROR; NumberFormat *nf = NumberFormat::createInstance(status); if (U_FAILURE(status)) { dataerrln("Error calling NumberFormat::createInstance()"); return; } roundingTest(*nf, 0.00159999, 4, "0.0016"); roundingTest(*nf, 0.00995, 4, "0.01"); roundingTest(*nf, 12.3995, 3, "12.4"); roundingTest(*nf, 12.4999, 0, "12"); roundingTest(*nf, - 19.5, 0, "-20"); delete nf; if (U_FAILURE(status)) errln((UnicodeString)"FAIL: Status " + (int32_t)status); } /** * Test the functioning of the secondary grouping value. */ void NumberFormatTest::TestSecondaryGrouping(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols ct"); DecimalFormat f("#,##,###", US, status); CHECK(status, "DecimalFormat ct"); expect2(f, (int32_t)123456789L, "12,34,56,789"); expectPat(f, "#,##,###"); f.applyPattern("#,###", status); CHECK(status, "applyPattern"); f.setSecondaryGroupingSize(4); expect2(f, (int32_t)123456789L, "12,3456,789"); expectPat(f, "#,####,###"); NumberFormat *g = NumberFormat::createInstance(Locale("hi", "IN"), status); CHECK_DATA(status, "createInstance(hi_IN)"); UnicodeString out; int32_t l = (int32_t)1876543210L; g->format(l, out); delete g; // expect "1,87,65,43,210", but with Hindi digits // 01234567890123 UBool ok = TRUE; if (out.length() != 14) { ok = FALSE; } else { for (int32_t i=0; i<out.length(); ++i) { UBool expectGroup = FALSE; switch (i) { case 1: case 4: case 7: case 10: expectGroup = TRUE; break; } // Later -- fix this to get the actual grouping // character from the resource bundle. UBool isGroup = (out.charAt(i) == 0x002C); if (isGroup != expectGroup) { ok = FALSE; break; } } } if (!ok) { errln((UnicodeString)"FAIL Expected " + l + " x hi_IN -> \"1,87,65,43,210\" (with Hindi digits), got \"" + escape(out) + "\""); } else { logln((UnicodeString)"Ok " + l + " x hi_IN -> \"" + escape(out) + "\""); } } void NumberFormatTest::TestWhiteSpaceParsing(void) { UErrorCode ec = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), ec); DecimalFormat fmt("a b#0c ", US, ec); if (U_FAILURE(ec)) { errcheckln(ec, "FAIL: Constructor - %s", u_errorName(ec)); return; } int32_t n = 1234; expect(fmt, "a b1234c ", n); expect(fmt, "a b1234c ", n); } /** * Test currencies whose display name is a ChoiceFormat. */ void NumberFormatTest::TestComplexCurrency() { // UErrorCode ec = U_ZERO_ERROR; // Locale loc("kn", "IN", ""); // NumberFormat* fmt = NumberFormat::createCurrencyInstance(loc, ec); // if (U_SUCCESS(ec)) { // expect2(*fmt, 1.0, CharsToUnicodeString("Re.\\u00A01.00")); // Use .00392625 because that's 2^-8. Any value less than 0.005 is fine. // expect(*fmt, 1.00390625, CharsToUnicodeString("Re.\\u00A01.00")); // tricky // expect2(*fmt, 12345678.0, CharsToUnicodeString("Rs.\\u00A01,23,45,678.00")); // expect2(*fmt, 0.5, CharsToUnicodeString("Rs.\\u00A00.50")); // expect2(*fmt, -1.0, CharsToUnicodeString("-Re.\\u00A01.00")); // expect2(*fmt, -10.0, CharsToUnicodeString("-Rs.\\u00A010.00")); // } else { // errln("FAIL: getCurrencyInstance(kn_IN)"); // } // delete fmt; } // ------------------------------------- void NumberFormatTest::roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected) { nf.setMaximumFractionDigits(maxFractionDigits); UnicodeString out; nf.format(x, out); logln((UnicodeString)"" + x + " formats with " + maxFractionDigits + " fractional digits to " + out); if (!(out==expected)) errln((UnicodeString)"FAIL: Expected " + expected); } /** * Upgrade to alphaWorks */ void NumberFormatTest::TestExponent(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); DecimalFormat fmt1(UnicodeString("0.###E0"), US, status); CHECK(status, "DecimalFormat(0.###E0)"); DecimalFormat fmt2(UnicodeString("0.###E+0"), US, status); CHECK(status, "DecimalFormat(0.###E+0)"); int32_t n = 1234; expect2(fmt1, n, "1.234E3"); expect2(fmt2, n, "1.234E+3"); expect(fmt1, "1.234E+3", n); // Either format should parse "E+3" } /** * Upgrade to alphaWorks */ void NumberFormatTest::TestScientific(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); // Test pattern round-trip const char* PAT[] = { "#E0", "0.####E0", "00.000E00", "##0.####E000", "0.###E0;[0.###E0]" }; int32_t PAT_length = (int32_t)(sizeof(PAT) / sizeof(PAT[0])); int32_t DIGITS[] = { // min int, max int, min frac, max frac 0, 1, 0, 0, // "#E0" 1, 1, 0, 4, // "0.####E0" 2, 2, 3, 3, // "00.000E00" 1, 3, 0, 4, // "##0.####E000" 1, 1, 0, 3, // "0.###E0;[0.###E0]" }; for (int32_t i=0; i<PAT_length; ++i) { UnicodeString pat(PAT[i]); DecimalFormat df(pat, US, status); CHECK(status, "DecimalFormat constructor"); UnicodeString pat2; df.toPattern(pat2); if (pat == pat2) { logln(UnicodeString("Ok Pattern rt \"") + pat + "\" -> \"" + pat2 + "\""); } else { errln(UnicodeString("FAIL Pattern rt \"") + pat + "\" -> \"" + pat2 + "\""); } // Make sure digit counts match what we expect if (df.getMinimumIntegerDigits() != DIGITS[4*i] || df.getMaximumIntegerDigits() != DIGITS[4*i+1] || df.getMinimumFractionDigits() != DIGITS[4*i+2] || df.getMaximumFractionDigits() != DIGITS[4*i+3]) { errln(UnicodeString("FAIL \"" + pat + "\" min/max int; min/max frac = ") + df.getMinimumIntegerDigits() + "/" + df.getMaximumIntegerDigits() + ";" + df.getMinimumFractionDigits() + "/" + df.getMaximumFractionDigits() + ", expect " + DIGITS[4*i] + "/" + DIGITS[4*i+1] + ";" + DIGITS[4*i+2] + "/" + DIGITS[4*i+3]); } } // Test the constructor for default locale. We have to // manually set the default locale, as there is no // guarantee that the default locale has the same // scientific format. Locale def = Locale::getDefault(); Locale::setDefault(Locale::getUS(), status); expect2(NumberFormat::createScientificInstance(status), 12345.678901, "1.2345678901E4", status); Locale::setDefault(def, status); expect2(new DecimalFormat("#E0", US, status), 12345.0, "1.2345E4", status); expect(new DecimalFormat("0E0", US, status), 12345.0, "1E4", status); expect2(NumberFormat::createScientificInstance(Locale::getUS(), status), 12345.678901, "1.2345678901E4", status); expect(new DecimalFormat("##0.###E0", US, status), 12345.0, "12.34E3", status); expect(new DecimalFormat("##0.###E0", US, status), 12345.00001, "12.35E3", status); expect2(new DecimalFormat("##0.####E0", US, status), (int32_t) 12345, "12.345E3", status); expect2(NumberFormat::createScientificInstance(Locale::getFrance(), status), 12345.678901, "1,2345678901E4", status); expect(new DecimalFormat("##0.####E0", US, status), 789.12345e-9, "789.12E-9", status); expect2(new DecimalFormat("##0.####E0", US, status), 780.e-9, "780E-9", status); expect(new DecimalFormat(".###E0", US, status), 45678.0, ".457E5", status); expect2(new DecimalFormat(".###E0", US, status), (int32_t) 0, ".0E0", status); /* expect(new DecimalFormat[] { new DecimalFormat("#E0", US), new DecimalFormat("##E0", US), new DecimalFormat("####E0", US), new DecimalFormat("0E0", US), new DecimalFormat("00E0", US), new DecimalFormat("000E0", US), }, new Long(45678000), new String[] { "4.5678E7", "45.678E6", "4567.8E4", "5E7", "46E6", "457E5", } ); ! ! Unroll this test into individual tests below... ! */ expect2(new DecimalFormat("#E0", US, status), (int32_t) 45678000, "4.5678E7", status); expect2(new DecimalFormat("##E0", US, status), (int32_t) 45678000, "45.678E6", status); expect2(new DecimalFormat("####E0", US, status), (int32_t) 45678000, "4567.8E4", status); expect(new DecimalFormat("0E0", US, status), (int32_t) 45678000, "5E7", status); expect(new DecimalFormat("00E0", US, status), (int32_t) 45678000, "46E6", status); expect(new DecimalFormat("000E0", US, status), (int32_t) 45678000, "457E5", status); /* expect(new DecimalFormat("###E0", US, status), new Object[] { new Double(0.0000123), "12.3E-6", new Double(0.000123), "123E-6", new Double(0.00123), "1.23E-3", new Double(0.0123), "12.3E-3", new Double(0.123), "123E-3", new Double(1.23), "1.23E0", new Double(12.3), "12.3E0", new Double(123), "123E0", new Double(1230), "1.23E3", }); ! ! Unroll this test into individual tests below... ! */ expect2(new DecimalFormat("###E0", US, status), 0.0000123, "12.3E-6", status); expect2(new DecimalFormat("###E0", US, status), 0.000123, "123E-6", status); expect2(new DecimalFormat("###E0", US, status), 0.00123, "1.23E-3", status); expect2(new DecimalFormat("###E0", US, status), 0.0123, "12.3E-3", status); expect2(new DecimalFormat("###E0", US, status), 0.123, "123E-3", status); expect2(new DecimalFormat("###E0", US, status), 1.23, "1.23E0", status); expect2(new DecimalFormat("###E0", US, status), 12.3, "12.3E0", status); expect2(new DecimalFormat("###E0", US, status), 123.0, "123E0", status); expect2(new DecimalFormat("###E0", US, status), 1230.0, "1.23E3", status); /* expect(new DecimalFormat("0.#E+00", US, status), new Object[] { new Double(0.00012), "1.2E-04", new Long(12000), "1.2E+04", }); ! ! Unroll this test into individual tests below... ! */ expect2(new DecimalFormat("0.#E+00", US, status), 0.00012, "1.2E-04", status); expect2(new DecimalFormat("0.#E+00", US, status), (int32_t) 12000, "1.2E+04", status); } /** * Upgrade to alphaWorks */ void NumberFormatTest::TestPad(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); expect2(new DecimalFormat("*^##.##", US, status), int32_t(0), "^^^^0", status); expect2(new DecimalFormat("*^##.##", US, status), -1.3, "^-1.3", status); expect2(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status), int32_t(0), "0.0E0______ g-m/s^2", status); expect(new DecimalFormat("##0.0####E0*_ 'g-m/s^2'", US, status), 1.0/3, "333.333E-3_ g-m/s^2", status); expect2(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status), int32_t(0), "0.0______ g-m/s^2", status); expect(new DecimalFormat("##0.0####*_ 'g-m/s^2'", US, status), 1.0/3, "0.33333__ g-m/s^2", status); // Test padding before a sign const char *formatStr = "*x#,###,###,##0.0#;*x(###,###,##0.0#)"; expect2(new DecimalFormat(formatStr, US, status), int32_t(-10), "xxxxxxxxxx(10.0)", status); expect2(new DecimalFormat(formatStr, US, status), int32_t(-1000),"xxxxxxx(1,000.0)", status); expect2(new DecimalFormat(formatStr, US, status), int32_t(-1000000),"xxx(1,000,000.0)", status); expect2(new DecimalFormat(formatStr, US, status), -100.37, "xxxxxxxx(100.37)", status); expect2(new DecimalFormat(formatStr, US, status), -10456.37, "xxxxx(10,456.37)", status); expect2(new DecimalFormat(formatStr, US, status), -1120456.37, "xx(1,120,456.37)", status); expect2(new DecimalFormat(formatStr, US, status), -112045600.37, "(112,045,600.37)", status); expect2(new DecimalFormat(formatStr, US, status), -1252045600.37,"(1,252,045,600.37)", status); expect2(new DecimalFormat(formatStr, US, status), int32_t(10), "xxxxxxxxxxxx10.0", status); expect2(new DecimalFormat(formatStr, US, status), int32_t(1000),"xxxxxxxxx1,000.0", status); expect2(new DecimalFormat(formatStr, US, status), int32_t(1000000),"xxxxx1,000,000.0", status); expect2(new DecimalFormat(formatStr, US, status), 100.37, "xxxxxxxxxx100.37", status); expect2(new DecimalFormat(formatStr, US, status), 10456.37, "xxxxxxx10,456.37", status); expect2(new DecimalFormat(formatStr, US, status), 1120456.37, "xxxx1,120,456.37", status); expect2(new DecimalFormat(formatStr, US, status), 112045600.37, "xx112,045,600.37", status); expect2(new DecimalFormat(formatStr, US, status), 10252045600.37,"10,252,045,600.37", status); // Test padding between a sign and a number const char *formatStr2 = "#,###,###,##0.0#*x;(###,###,##0.0#*x)"; expect2(new DecimalFormat(formatStr2, US, status), int32_t(-10), "(10.0xxxxxxxxxx)", status); expect2(new DecimalFormat(formatStr2, US, status), int32_t(-1000),"(1,000.0xxxxxxx)", status); expect2(new DecimalFormat(formatStr2, US, status), int32_t(-1000000),"(1,000,000.0xxx)", status); expect2(new DecimalFormat(formatStr2, US, status), -100.37, "(100.37xxxxxxxx)", status); expect2(new DecimalFormat(formatStr2, US, status), -10456.37, "(10,456.37xxxxx)", status); expect2(new DecimalFormat(formatStr2, US, status), -1120456.37, "(1,120,456.37xx)", status); expect2(new DecimalFormat(formatStr2, US, status), -112045600.37, "(112,045,600.37)", status); expect2(new DecimalFormat(formatStr2, US, status), -1252045600.37,"(1,252,045,600.37)", status); expect2(new DecimalFormat(formatStr2, US, status), int32_t(10), "10.0xxxxxxxxxxxx", status); expect2(new DecimalFormat(formatStr2, US, status), int32_t(1000),"1,000.0xxxxxxxxx", status); expect2(new DecimalFormat(formatStr2, US, status), int32_t(1000000),"1,000,000.0xxxxx", status); expect2(new DecimalFormat(formatStr2, US, status), 100.37, "100.37xxxxxxxxxx", status); expect2(new DecimalFormat(formatStr2, US, status), 10456.37, "10,456.37xxxxxxx", status); expect2(new DecimalFormat(formatStr2, US, status), 1120456.37, "1,120,456.37xxxx", status); expect2(new DecimalFormat(formatStr2, US, status), 112045600.37, "112,045,600.37xx", status); expect2(new DecimalFormat(formatStr2, US, status), 10252045600.37,"10,252,045,600.37", status); //testing the setPadCharacter(UnicodeString) and getPadCharacterString() DecimalFormat fmt("#", US, status); CHECK(status, "DecimalFormat constructor"); UnicodeString padString("P"); fmt.setPadCharacter(padString); expectPad(fmt, "*P##.##", DecimalFormat::kPadBeforePrefix, 5, padString); fmt.setPadCharacter((UnicodeString)"^"); expectPad(fmt, "*^#", DecimalFormat::kPadBeforePrefix, 1, (UnicodeString)"^"); //commented untill implementation is complete /* fmt.setPadCharacter((UnicodeString)"^^^"); expectPad(fmt, "*^^^#", DecimalFormat::kPadBeforePrefix, 3, (UnicodeString)"^^^"); padString.remove(); padString.append((UChar)0x0061); padString.append((UChar)0x0302); fmt.setPadCharacter(padString); UChar patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000}; UnicodeString pattern(patternChars); expectPad(fmt, pattern , DecimalFormat::kPadBeforePrefix, 4, padString); */ } /** * Upgrade to alphaWorks */ void NumberFormatTest::TestPatterns2(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); DecimalFormat fmt("#", US, status); CHECK(status, "DecimalFormat constructor"); UChar hat = 0x005E; /*^*/ expectPad(fmt, "*^#", DecimalFormat::kPadBeforePrefix, 1, hat); expectPad(fmt, "$*^#", DecimalFormat::kPadAfterPrefix, 2, hat); expectPad(fmt, "#*^", DecimalFormat::kPadBeforeSuffix, 1, hat); expectPad(fmt, "#$*^", DecimalFormat::kPadAfterSuffix, 2, hat); expectPad(fmt, "$*^$#", ILLEGAL); expectPad(fmt, "#$*^$", ILLEGAL); expectPad(fmt, "'pre'#,##0*x'post'", DecimalFormat::kPadBeforeSuffix, 12, (UChar)0x0078 /*x*/); expectPad(fmt, "''#0*x", DecimalFormat::kPadBeforeSuffix, 3, (UChar)0x0078 /*x*/); expectPad(fmt, "'I''ll'*a###.##", DecimalFormat::kPadAfterPrefix, 10, (UChar)0x0061 /*a*/); fmt.applyPattern("AA#,##0.00ZZ", status); CHECK(status, "applyPattern"); fmt.setPadCharacter(hat); fmt.setFormatWidth(10); fmt.setPadPosition(DecimalFormat::kPadBeforePrefix); expectPat(fmt, "*^AA#,##0.00ZZ"); fmt.setPadPosition(DecimalFormat::kPadBeforeSuffix); expectPat(fmt, "AA#,##0.00*^ZZ"); fmt.setPadPosition(DecimalFormat::kPadAfterSuffix); expectPat(fmt, "AA#,##0.00ZZ*^"); // 12 3456789012 UnicodeString exp("AA*^#,##0.00ZZ", ""); fmt.setFormatWidth(12); fmt.setPadPosition(DecimalFormat::kPadAfterPrefix); expectPat(fmt, exp); fmt.setFormatWidth(13); // 12 34567890123 expectPat(fmt, "AA*^##,##0.00ZZ"); fmt.setFormatWidth(14); // 12 345678901234 expectPat(fmt, "AA*^###,##0.00ZZ"); fmt.setFormatWidth(15); // 12 3456789012345 expectPat(fmt, "AA*^####,##0.00ZZ"); // This is the interesting case fmt.setFormatWidth(16); // 12 34567890123456 expectPat(fmt, "AA*^#,###,##0.00ZZ"); } void NumberFormatTest::TestSurrogateSupport(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols custom(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); custom.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, "decimal"); custom.setSymbol(DecimalFormatSymbols::kPlusSignSymbol, "plus"); custom.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, " minus "); custom.setSymbol(DecimalFormatSymbols::kExponentialSymbol, "exponent"); UnicodeString patternStr("*\\U00010000##.##", ""); patternStr = patternStr.unescape(); UnicodeString expStr("\\U00010000\\U00010000\\U00010000\\U000100000", ""); expStr = expStr.unescape(); expect2(new DecimalFormat(patternStr, custom, status), int32_t(0), expStr, status); status = U_ZERO_ERROR; expect2(new DecimalFormat("*^##.##", custom, status), int32_t(0), "^^^^0", status); status = U_ZERO_ERROR; expect2(new DecimalFormat("##.##", custom, status), -1.3, " minus 1decimal3", status); status = U_ZERO_ERROR; expect2(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status), int32_t(0), "0decimal0exponent0 g-m/s^2", status); status = U_ZERO_ERROR; expect(new DecimalFormat("##0.0####E0 'g-m/s^2'", custom, status), 1.0/3, "333decimal333exponent minus 3 g-m/s^2", status); status = U_ZERO_ERROR; expect2(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status), int32_t(0), "0decimal0 g-m/s^2", status); status = U_ZERO_ERROR; expect(new DecimalFormat("##0.0#### 'g-m/s^2'", custom, status), 1.0/3, "0decimal33333 g-m/s^2", status); UnicodeString zero((UChar32)0x10000); UnicodeString one((UChar32)0x10001); UnicodeString two((UChar32)0x10002); UnicodeString five((UChar32)0x10005); custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, zero); custom.setSymbol(DecimalFormatSymbols::kOneDigitSymbol, one); custom.setSymbol(DecimalFormatSymbols::kTwoDigitSymbol, two); custom.setSymbol(DecimalFormatSymbols::kFiveDigitSymbol, five); expStr = UnicodeString("\\U00010001decimal\\U00010002\\U00010005\\U00010000", ""); expStr = expStr.unescape(); status = U_ZERO_ERROR; expect2(new DecimalFormat("##0.000", custom, status), 1.25, expStr, status); custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, (UChar)0x30); custom.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "units of money"); custom.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, "money separator"); patternStr = UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'"); patternStr = patternStr.unescape(); expStr = UnicodeString(" minus 20money separator00 units of money in your bank account", ""); status = U_ZERO_ERROR; expect2(new DecimalFormat(patternStr, custom, status), int32_t(-20), expStr, status); custom.setSymbol(DecimalFormatSymbols::kPercentSymbol, "percent"); patternStr = "'You''ve lost ' -0.00 %' of your money today'"; patternStr = patternStr.unescape(); expStr = UnicodeString(" minus You've lost minus 2000decimal00 percent of your money today", ""); status = U_ZERO_ERROR; expect2(new DecimalFormat(patternStr, custom, status), int32_t(-20), expStr, status); } void NumberFormatTest::TestCurrencyPatterns(void) { int32_t i, locCount; const Locale* locs = NumberFormat::getAvailableLocales(locCount); for (i=0; i<locCount; ++i) { UErrorCode ec = U_ZERO_ERROR; NumberFormat* nf = NumberFormat::createCurrencyInstance(locs[i], ec); if (U_FAILURE(ec)) { errln("FAIL: Can't create NumberFormat(%s) - %s", locs[i].getName(), u_errorName(ec)); } else { // Make sure currency formats do not have a variable number // of fraction digits int32_t min = nf->getMinimumFractionDigits(); int32_t max = nf->getMaximumFractionDigits(); if (min != max) { UnicodeString a, b; nf->format(1.0, a); nf->format(1.125, b); errln((UnicodeString)"FAIL: " + locs[i].getName() + " min fraction digits != max fraction digits; " "x 1.0 => " + escape(a) + "; x 1.125 => " + escape(b)); } // Make sure EURO currency formats have exactly 2 fraction digits DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf); if (df != NULL) { if (u_strcmp(EUR, df->getCurrency()) == 0) { if (min != 2 || max != 2) { UnicodeString a; nf->format(1.0, a); errln((UnicodeString)"FAIL: " + locs[i].getName() + " is a EURO format but it does not have 2 fraction digits; " "x 1.0 => " + escape(a)); } } } } delete nf; } } void NumberFormatTest::TestRegCurrency(void) { #if !UCONFIG_NO_SERVICE UErrorCode status = U_ZERO_ERROR; UChar USD[4]; ucurr_forLocale("en_US", USD, 4, &status); UChar YEN[4]; ucurr_forLocale("ja_JP", YEN, 4, &status); UChar TMP[4]; static const UChar QQQ[] = {0x51, 0x51, 0x51, 0}; if(U_FAILURE(status)) { errcheckln(status, "Unable to get currency for locale, error %s", u_errorName(status)); return; } UCurrRegistryKey enkey = ucurr_register(YEN, "en_US", &status); UCurrRegistryKey enUSEUROkey = ucurr_register(QQQ, "en_US_EURO", &status); ucurr_forLocale("en_US", TMP, 4, &status); if (u_strcmp(YEN, TMP) != 0) { errln("FAIL: didn't return YEN registered for en_US"); } ucurr_forLocale("en_US_EURO", TMP, 4, &status); if (u_strcmp(QQQ, TMP) != 0) { errln("FAIL: didn't return QQQ for en_US_EURO"); } int32_t fallbackLen = ucurr_forLocale("en_XX_BAR", TMP, 4, &status); if (fallbackLen) { errln("FAIL: tried to fallback en_XX_BAR"); } status = U_ZERO_ERROR; // reset if (!ucurr_unregister(enkey, &status)) { errln("FAIL: couldn't unregister enkey"); } ucurr_forLocale("en_US", TMP, 4, &status); if (u_strcmp(USD, TMP) != 0) { errln("FAIL: didn't return USD for en_US after unregister of en_US"); } status = U_ZERO_ERROR; // reset ucurr_forLocale("en_US_EURO", TMP, 4, &status); if (u_strcmp(QQQ, TMP) != 0) { errln("FAIL: didn't return QQQ for en_US_EURO after unregister of en_US"); } ucurr_forLocale("en_US_BLAH", TMP, 4, &status); if (u_strcmp(USD, TMP) != 0) { errln("FAIL: could not find USD for en_US_BLAH after unregister of en"); } status = U_ZERO_ERROR; // reset if (!ucurr_unregister(enUSEUROkey, &status)) { errln("FAIL: couldn't unregister enUSEUROkey"); } ucurr_forLocale("en_US_EURO", TMP, 4, &status); if (u_strcmp(EUR, TMP) != 0) { errln("FAIL: didn't return EUR for en_US_EURO after unregister of en_US_EURO"); } status = U_ZERO_ERROR; // reset #endif } void NumberFormatTest::TestCurrencyNames(void) { // Do a basic check of getName() // USD { "US$", "US Dollar" } // 04/04/1792- UErrorCode ec = U_ZERO_ERROR; static const UChar USD[] = {0x55, 0x53, 0x44, 0}; /*USD*/ static const UChar USX[] = {0x55, 0x53, 0x58, 0}; /*USX*/ static const UChar CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/ static const UChar ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/ UBool isChoiceFormat; int32_t len; const UBool possibleDataError = TRUE; // Warning: HARD-CODED LOCALE DATA in this test. If it fails, CHECK // THE LOCALE DATA before diving into the code. assertEquals("USD.getName(SYMBOL_NAME)", UnicodeString("$"), UnicodeString(ucurr_getName(USD, "en", UCURR_SYMBOL_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("USD.getName(LONG_NAME)", UnicodeString("US Dollar"), UnicodeString(ucurr_getName(USD, "en", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("CAD.getName(SYMBOL_NAME)", UnicodeString("CA$"), UnicodeString(ucurr_getName(CAD, "en", UCURR_SYMBOL_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("CAD.getName(SYMBOL_NAME)", UnicodeString("$"), UnicodeString(ucurr_getName(CAD, "en_CA", UCURR_SYMBOL_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("USD.getName(SYMBOL_NAME)", UnicodeString("US$"), UnicodeString(ucurr_getName(USD, "en_AU", UCURR_SYMBOL_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("CAD.getName(SYMBOL_NAME)", UnicodeString("CA$"), UnicodeString(ucurr_getName(CAD, "en_AU", UCURR_SYMBOL_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertEquals("USX.getName(LONG_NAME)", UnicodeString("USX"), UnicodeString(ucurr_getName(USX, "en_US", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec)), possibleDataError); assertSuccess("ucurr_getName", ec); ec = U_ZERO_ERROR; // Test that a default or fallback warning is being returned. JB 4239. ucurr_getName(CAD, "es_ES", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec); assertTrue("ucurr_getName (es_ES fallback)", U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError); ucurr_getName(CAD, "zh_TW", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec); assertTrue("ucurr_getName (zh_TW fallback)", U_USING_FALLBACK_WARNING == ec, TRUE, possibleDataError); ucurr_getName(CAD, "en_US", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec); assertTrue("ucurr_getName (en_US default)", U_USING_DEFAULT_WARNING == ec || U_USING_FALLBACK_WARNING == ec, TRUE); ucurr_getName(CAD, "vi", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec); assertTrue("ucurr_getName (vi default)", U_USING_DEFAULT_WARNING == ec, TRUE); // Test that a default warning is being returned when falling back to root. JB 4536. ucurr_getName(ITL, "cy", UCURR_LONG_NAME, &isChoiceFormat, &len, &ec); assertTrue("ucurr_getName (cy default to root)", U_USING_DEFAULT_WARNING == ec, TRUE); // TODO add more tests later } void NumberFormatTest::TestCurrencyUnit(void){ UErrorCode ec = U_ZERO_ERROR; static const UChar USD[] = {85, 83, 68, 0}; /*USD*/ CurrencyUnit cu(USD, ec); assertSuccess("CurrencyUnit", ec); const UChar * r = cu.getISOCurrency(); // who is the buffer owner ? assertEquals("getISOCurrency()", USD, r); CurrencyUnit cu2(cu); if (!(cu2 == cu)){ errln("CurrencyUnit copy constructed object should be same"); } CurrencyUnit * cu3 = (CurrencyUnit *)cu.clone(); if (!(*cu3 == cu)){ errln("CurrencyUnit cloned object should be same"); } delete cu3; } void NumberFormatTest::TestCurrencyAmount(void){ UErrorCode ec = U_ZERO_ERROR; static const UChar USD[] = {85, 83, 68, 0}; /*USD*/ CurrencyAmount ca(9, USD, ec); assertSuccess("CurrencyAmount", ec); CurrencyAmount ca2(ca); if (!(ca2 == ca)){ errln("CurrencyAmount copy constructed object should be same"); } ca2=ca; if (!(ca2 == ca)){ errln("CurrencyAmount assigned object should be same"); } CurrencyAmount *ca3 = (CurrencyAmount *)ca.clone(); if (!(*ca3 == ca)){ errln("CurrencyAmount cloned object should be same"); } delete ca3; } void NumberFormatTest::TestSymbolsWithBadLocale(void) { Locale locDefault; Locale locBad("x-crazy_ZZ_MY_SPECIAL_ADMINISTRATION_REGION_NEEDS_A_SPECIAL_VARIANT_WITH_A_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_NAME"); UErrorCode status = U_ZERO_ERROR; UnicodeString intlCurrencySymbol((UChar)0xa4); intlCurrencySymbol.append((UChar)0xa4); logln("Current locale is %s", Locale::getDefault().getName()); Locale::setDefault(locBad, status); logln("Current locale is %s", Locale::getDefault().getName()); DecimalFormatSymbols mySymbols(status); if (status != U_USING_FALLBACK_WARNING) { errln("DecimalFormatSymbols should returned U_USING_FALLBACK_WARNING."); } if (strcmp(mySymbols.getLocale().getName(), locBad.getName()) != 0) { errln("DecimalFormatSymbols does not have the right locale."); } int symbolEnum = (int)DecimalFormatSymbols::kDecimalSeparatorSymbol; for (; symbolEnum < (int)DecimalFormatSymbols::kFormatSymbolCount; symbolEnum++) { logln(UnicodeString("DecimalFormatSymbols[") + symbolEnum + UnicodeString("] = ") + prettify(mySymbols.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbolEnum))); if (mySymbols.getSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbolEnum).length() == 0 && symbolEnum != (int)DecimalFormatSymbols::kGroupingSeparatorSymbol && symbolEnum != (int)DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol) { errln("DecimalFormatSymbols has an empty string at index %d.", symbolEnum); } } status = U_ZERO_ERROR; Locale::setDefault(locDefault, status); logln("Current locale is %s", Locale::getDefault().getName()); } /** * Check that adoptDecimalFormatSymbols and setDecimalFormatSymbols * behave the same, except for memory ownership semantics. (No * version of this test on Java, since Java has only one method.) */ void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) { UErrorCode ec = U_ZERO_ERROR; DecimalFormatSymbols *sym = new DecimalFormatSymbols(Locale::getUS(), ec); if (U_FAILURE(ec)) { errcheckln(ec, "Fail: DecimalFormatSymbols constructor - %s", u_errorName(ec)); delete sym; return; } UnicodeString pat(" #,##0.00"); pat.insert(0, (UChar)0x00A4); DecimalFormat fmt(pat, sym, ec); if (U_FAILURE(ec)) { errln("Fail: DecimalFormat constructor"); return; } UnicodeString str; fmt.format(2350.75, str); if (str == "$ 2,350.75") { logln(str); } else { dataerrln("Fail: " + str + ", expected $ 2,350.75"); } sym = new DecimalFormatSymbols(Locale::getUS(), ec); if (U_FAILURE(ec)) { errln("Fail: DecimalFormatSymbols constructor"); delete sym; return; } sym->setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q"); fmt.adoptDecimalFormatSymbols(sym); str.truncate(0); fmt.format(2350.75, str); if (str == "Q 2,350.75") { logln(str); } else { dataerrln("Fail: adoptDecimalFormatSymbols -> " + str + ", expected Q 2,350.75"); } sym = new DecimalFormatSymbols(Locale::getUS(), ec); if (U_FAILURE(ec)) { errln("Fail: DecimalFormatSymbols constructor"); delete sym; return; } DecimalFormat fmt2(pat, sym, ec); if (U_FAILURE(ec)) { errln("Fail: DecimalFormat constructor"); return; } DecimalFormatSymbols sym2(Locale::getUS(), ec); if (U_FAILURE(ec)) { errln("Fail: DecimalFormatSymbols constructor"); return; } sym2.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "Q"); fmt2.setDecimalFormatSymbols(sym2); str.truncate(0); fmt2.format(2350.75, str); if (str == "Q 2,350.75") { logln(str); } else { dataerrln("Fail: setDecimalFormatSymbols -> " + str + ", expected Q 2,350.75"); } } void NumberFormatTest::TestPerMill() { UErrorCode ec = U_ZERO_ERROR; UnicodeString str; DecimalFormat fmt(ctou("###.###\\u2030"), ec); if (!assertSuccess("DecimalFormat ct", ec)) return; assertEquals("0.4857 x ###.###\\u2030", ctou("485.7\\u2030"), fmt.format(0.4857, str)); DecimalFormatSymbols sym(Locale::getUS(), ec); sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, ctou("m")); DecimalFormat fmt2("", sym, ec); fmt2.applyLocalizedPattern("###.###m", ec); if (!assertSuccess("setup", ec)) return; str.truncate(0); assertEquals("0.4857 x ###.###m", "485.7m", fmt2.format(0.4857, str)); } /** * Generic test for patterns that should be legal/illegal. */ void NumberFormatTest::TestIllegalPatterns() { // Test cases: // Prefix with "-:" for illegal patterns // Prefix with "+:" for legal patterns const char* DATA[] = { // Unquoted special characters in the suffix are illegal "-:000.000|###", "+:000.000'|###'", 0 }; for (int32_t i=0; DATA[i]; ++i) { const char* pat=DATA[i]; UBool valid = (*pat) == '+'; pat += 2; UErrorCode ec = U_ZERO_ERROR; DecimalFormat fmt(pat, ec); // locale doesn't matter here if (U_SUCCESS(ec) == valid) { logln("Ok: pattern \"%s\": %s", pat, u_errorName(ec)); } else { errcheckln(ec, "FAIL: pattern \"%s\" should have %s; got %s", pat, (valid?"succeeded":"failed"), u_errorName(ec)); } } } //---------------------------------------------------------------------- static const char* KEYWORDS[] = { /*0*/ "ref=", // <reference pattern to parse numbers> /*1*/ "loc=", // <locale for formats> /*2*/ "f:", // <pattern or '-'> <number> <exp. string> /*3*/ "fp:", // <pattern or '-'> <number> <exp. string> <exp. number> /*4*/ "rt:", // <pattern or '-'> <(exp.) number> <(exp.) string> /*5*/ "p:", // <pattern or '-'> <string> <exp. number> /*6*/ "perr:", // <pattern or '-'> <invalid string> /*7*/ "pat:", // <pattern or '-'> <exp. toPattern or '-' or 'err'> /*8*/ "fpc:", // <pattern or '-'> <curr.amt> <exp. string> <exp. curr.amt> 0 }; /** * Return an integer representing the next token from this * iterator. The integer will be an index into the given list, or * -1 if there are no more tokens, or -2 if the token is not on * the list. */ static int32_t keywordIndex(const UnicodeString& tok) { for (int32_t i=0; KEYWORDS[i]!=0; ++i) { if (tok==KEYWORDS[i]) { return i; } } return -1; } /** * Parse a CurrencyAmount using the given NumberFormat, with * the 'delim' character separating the number and the currency. */ static void parseCurrencyAmount(const UnicodeString& str, const NumberFormat& fmt, UChar delim, Formattable& result, UErrorCode& ec) { UnicodeString num, cur; int32_t i = str.indexOf(delim); str.extractBetween(0, i, num); str.extractBetween(i+1, INT32_MAX, cur); Formattable n; fmt.parse(num, n, ec); result.adoptObject(new CurrencyAmount(n, cur.getTerminatedBuffer(), ec)); } void NumberFormatTest::TestCases() { UErrorCode ec = U_ZERO_ERROR; TextFile reader("NumberFormatTestCases.txt", "UTF8", ec); if (U_FAILURE(ec)) { dataerrln("Couldn't open NumberFormatTestCases.txt"); return; } TokenIterator tokens(&reader); Locale loc("en", "US", ""); DecimalFormat *ref = 0, *fmt = 0; MeasureFormat *mfmt = 0; UnicodeString pat, tok, mloc, str, out, where, currAmt; Formattable n; for (;;) { ec = U_ZERO_ERROR; if (!tokens.next(tok, ec)) { break; } where = UnicodeString("(") + tokens.getLineNumber() + ") "; int32_t cmd = keywordIndex(tok); switch (cmd) { case 0: // ref= <reference pattern> if (!tokens.next(tok, ec)) goto error; delete ref; ref = new DecimalFormat(tok, new DecimalFormatSymbols(Locale::getUS(), ec), ec); if (U_FAILURE(ec)) { dataerrln("Error constructing DecimalFormat"); goto error; } break; case 1: // loc= <locale> if (!tokens.next(tok, ec)) goto error; loc = Locale::createFromName(CharString().appendInvariantChars(tok, ec).data()); break; case 2: // f: case 3: // fp: case 4: // rt: case 5: // p: if (!tokens.next(tok, ec)) goto error; if (tok != "-") { pat = tok; delete fmt; fmt = new DecimalFormat(pat, new DecimalFormatSymbols(loc, ec), ec); if (U_FAILURE(ec)) { errln("FAIL: " + where + "Pattern \"" + pat + "\": " + u_errorName(ec)); ec = U_ZERO_ERROR; if (!tokens.next(tok, ec)) goto error; if (!tokens.next(tok, ec)) goto error; if (cmd == 3) { if (!tokens.next(tok, ec)) goto error; } continue; } } if (cmd == 2 || cmd == 3 || cmd == 4) { // f: <pattern or '-'> <number> <exp. string> // fp: <pattern or '-'> <number> <exp. string> <exp. number> // rt: <pattern or '-'> <number> <string> UnicodeString num; if (!tokens.next(num, ec)) goto error; if (!tokens.next(str, ec)) goto error; ref->parse(num, n, ec); assertSuccess("parse", ec); assertEquals(where + "\"" + pat + "\".format(" + num + ")", str, fmt->format(n, out.remove(), ec)); assertSuccess("format", ec); if (cmd == 3) { // fp: if (!tokens.next(num, ec)) goto error; ref->parse(num, n, ec); assertSuccess("parse", ec); } if (cmd != 2) { // != f: Formattable m; fmt->parse(str, m, ec); assertSuccess("parse", ec); assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")", n, m); } } // p: <pattern or '-'> <string to parse> <exp. number> else { UnicodeString expstr; if (!tokens.next(str, ec)) goto error; if (!tokens.next(expstr, ec)) goto error; Formattable exp, n; ref->parse(expstr, exp, ec); assertSuccess("parse", ec); fmt->parse(str, n, ec); assertSuccess("parse", ec); assertEquals(where + "\"" + pat + "\".parse(\"" + str + "\")", exp, n); } break; case 8: // fpc: if (!tokens.next(tok, ec)) goto error; if (tok != "-") { mloc = tok; delete mfmt; mfmt = MeasureFormat::createCurrencyFormat( Locale::createFromName( CharString().appendInvariantChars(mloc, ec).data()), ec); if (U_FAILURE(ec)) { errln("FAIL: " + where + "Loc \"" + mloc + "\": " + u_errorName(ec)); ec = U_ZERO_ERROR; if (!tokens.next(tok, ec)) goto error; if (!tokens.next(tok, ec)) goto error; if (!tokens.next(tok, ec)) goto error; continue; } } // fpc: <loc or '-'> <curr.amt> <exp. string> <exp. curr.amt> if (!tokens.next(currAmt, ec)) goto error; if (!tokens.next(str, ec)) goto error; parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec); if (assertSuccess("parseCurrencyAmount", ec)) { assertEquals(where + "getCurrencyFormat(" + mloc + ").format(" + currAmt + ")", str, mfmt->format(n, out.remove(), ec)); assertSuccess("format", ec); } if (!tokens.next(currAmt, ec)) goto error; parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec); if (assertSuccess("parseCurrencyAmount", ec)) { Formattable m; mfmt->parseObject(str, m, ec); if (assertSuccess("parseCurrency", ec)) { assertEquals(where + "getCurrencyFormat(" + mloc + ").parse(\"" + str + "\")", n, m); } else { errln("FAIL: source " + str); } } break; case 6: // perr: <pattern or '-'> <invalid string> errln("FAIL: Under construction"); goto done; case 7: { // pat: <pattern> <exp. toPattern, or '-' or 'err'> UnicodeString testpat; UnicodeString exppat; if (!tokens.next(testpat, ec)) goto error; if (!tokens.next(exppat, ec)) goto error; UBool err = exppat == "err"; UBool existingPat = FALSE; if (testpat == "-") { if (err) { errln("FAIL: " + where + "Invalid command \"pat: - err\""); continue; } existingPat = TRUE; testpat = pat; } if (exppat == "-") exppat = testpat; DecimalFormat* f = 0; UErrorCode ec2 = U_ZERO_ERROR; if (existingPat) { f = fmt; } else { f = new DecimalFormat(testpat, ec2); } if (U_SUCCESS(ec2)) { if (err) { errln("FAIL: " + where + "Invalid pattern \"" + testpat + "\" was accepted"); } else { UnicodeString pat2; assertEquals(where + "\"" + testpat + "\".toPattern()", exppat, f->toPattern(pat2)); } } else { if (err) { logln("Ok: " + where + "Invalid pattern \"" + testpat + "\" failed: " + u_errorName(ec2)); } else { errln("FAIL: " + where + "Valid pattern \"" + testpat + "\" failed: " + u_errorName(ec2)); } } if (!existingPat) delete f; } break; case -1: errln("FAIL: " + where + "Unknown command \"" + tok + "\""); goto done; } } goto done; error: if (U_SUCCESS(ec)) { errln("FAIL: Unexpected EOF"); } else { errcheckln(ec, "FAIL: " + where + "Unexpected " + u_errorName(ec)); } done: delete mfmt; delete fmt; delete ref; } //---------------------------------------------------------------------- // Support methods //---------------------------------------------------------------------- UBool NumberFormatTest::equalValue(const Formattable& a, const Formattable& b) { if (a.getType() == b.getType()) { return a == b; } if (a.getType() == Formattable::kLong) { if (b.getType() == Formattable::kInt64) { return a.getLong() == b.getLong(); } else if (b.getType() == Formattable::kDouble) { return (double) a.getLong() == b.getDouble(); // TODO check use of double instead of long } } else if (a.getType() == Formattable::kDouble) { if (b.getType() == Formattable::kLong) { return a.getDouble() == (double) b.getLong(); } else if (b.getType() == Formattable::kInt64) { return a.getDouble() == (double)b.getInt64(); } } else if (a.getType() == Formattable::kInt64) { if (b.getType() == Formattable::kLong) { return a.getInt64() == (int64_t)b.getLong(); } else if (b.getType() == Formattable::kDouble) { return a.getInt64() == (int64_t)b.getDouble(); } } return FALSE; } void NumberFormatTest::expect3(NumberFormat& fmt, const Formattable& n, const UnicodeString& str) { // Don't round-trip format test, since we explicitly do it expect_rbnf(fmt, n, str, FALSE); expect_rbnf(fmt, str, n); } void NumberFormatTest::expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str) { // Don't round-trip format test, since we explicitly do it expect(fmt, n, str, FALSE); expect(fmt, str, n); } void NumberFormatTest::expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& exp, UErrorCode status) { if (fmt == NULL || U_FAILURE(status)) { dataerrln("FAIL: NumberFormat constructor"); } else { expect2(*fmt, n, exp); } delete fmt; } void NumberFormatTest::expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) { UErrorCode status = U_ZERO_ERROR; Formattable num; fmt.parse(str, num, status); if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: Parse failed for \"") + str + "\" - " + u_errorName(status)); return; } UnicodeString pat; ((DecimalFormat*) &fmt)->toPattern(pat); if (equalValue(num, n)) { logln(UnicodeString("Ok \"") + str + "\" x " + pat + " = " + toString(num)); } else { dataerrln(UnicodeString("FAIL \"") + str + "\" x " + pat + " = " + toString(num) + ", expected " + toString(n)); } } void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const UnicodeString& str, const Formattable& n) { UErrorCode status = U_ZERO_ERROR; Formattable num; fmt.parse(str, num, status); if (U_FAILURE(status)) { errln(UnicodeString("FAIL: Parse failed for \"") + str + "\""); return; } if (equalValue(num, n)) { logln(UnicodeString("Ok \"") + str + " = " + toString(num)); } else { errln(UnicodeString("FAIL \"") + str + " = " + toString(num) + ", expected " + toString(n)); } } void NumberFormatTest::expect_rbnf(NumberFormat& fmt, const Formattable& n, const UnicodeString& exp, UBool rt) { UnicodeString saw; FieldPosition pos; UErrorCode status = U_ZERO_ERROR; fmt.format(n, saw, pos, status); CHECK(status, "NumberFormat::format"); if (saw == exp) { logln(UnicodeString("Ok ") + toString(n) + " = \"" + escape(saw) + "\""); // We should be able to round-trip the formatted string => // number => string (but not the other way around: number // => string => number2, might have number2 != number): if (rt) { Formattable n2; fmt.parse(exp, n2, status); if (U_FAILURE(status)) { errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\""); return; } UnicodeString saw2; fmt.format(n2, saw2, pos, status); CHECK(status, "NumberFormat::format"); if (saw2 != exp) { errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) + " => \"" + saw2 + "\""); } } } else { errln(UnicodeString("FAIL ") + toString(n) + " = \"" + escape(saw) + "\", expected \"" + exp + "\""); } } void NumberFormatTest::expect(NumberFormat& fmt, const Formattable& n, const UnicodeString& exp, UBool rt) { UnicodeString saw; FieldPosition pos; UErrorCode status = U_ZERO_ERROR; fmt.format(n, saw, pos, status); CHECK(status, "NumberFormat::format"); UnicodeString pat; ((DecimalFormat*) &fmt)->toPattern(pat); if (saw == exp) { logln(UnicodeString("Ok ") + toString(n) + " x " + escape(pat) + " = \"" + escape(saw) + "\""); // We should be able to round-trip the formatted string => // number => string (but not the other way around: number // => string => number2, might have number2 != number): if (rt) { Formattable n2; fmt.parse(exp, n2, status); if (U_FAILURE(status)) { errln(UnicodeString("FAIL: Parse failed for \"") + exp + "\" - " + u_errorName(status)); return; } UnicodeString saw2; fmt.format(n2, saw2, pos, status); CHECK(status, "NumberFormat::format"); if (saw2 != exp) { errln((UnicodeString)"FAIL \"" + exp + "\" => " + toString(n2) + " => \"" + saw2 + "\""); } } } else { dataerrln(UnicodeString("FAIL ") + toString(n) + " x " + escape(pat) + " = \"" + escape(saw) + "\", expected \"" + exp + "\""); } } void NumberFormatTest::expect(NumberFormat* fmt, const Formattable& n, const UnicodeString& exp, UErrorCode status) { if (fmt == NULL || U_FAILURE(status)) { dataerrln("FAIL: NumberFormat constructor"); } else { expect(*fmt, n, exp); } delete fmt; } void NumberFormatTest::expectCurrency(NumberFormat& nf, const Locale& locale, double value, const UnicodeString& string) { UErrorCode ec = U_ZERO_ERROR; DecimalFormat& fmt = * (DecimalFormat*) &nf; const UChar DEFAULT_CURR[] = {45/*-*/,0}; UChar curr[4]; u_strcpy(curr, DEFAULT_CURR); if (*locale.getLanguage() != 0) { ucurr_forLocale(locale.getName(), curr, 4, &ec); assertSuccess("ucurr_forLocale", ec); fmt.setCurrency(curr, ec); assertSuccess("DecimalFormat::setCurrency", ec); fmt.setCurrency(curr); //Deprecated variant, for coverage only } UnicodeString s; fmt.format(value, s); s.findAndReplace((UChar32)0x00A0, (UChar32)0x0020); // Default display of the number yields "1234.5599999999999" // instead of "1234.56". Use a formatter to fix this. NumberFormat* f = NumberFormat::createInstance(Locale::getUS(), ec); UnicodeString v; if (U_FAILURE(ec)) { // Oops; bad formatter. Use default op+= display. v = (UnicodeString)"" + value; } else { f->setMaximumFractionDigits(4); f->setGroupingUsed(FALSE); f->format(value, v); } delete f; if (s == string) { logln((UnicodeString)"Ok: " + v + " x " + curr + " => " + prettify(s)); } else { errln((UnicodeString)"FAIL: " + v + " x " + curr + " => " + prettify(s) + ", expected " + prettify(string)); } } void NumberFormatTest::expectPat(DecimalFormat& fmt, const UnicodeString& exp) { UnicodeString pat; fmt.toPattern(pat); if (pat == exp) { logln(UnicodeString("Ok \"") + pat + "\""); } else { errln(UnicodeString("FAIL \"") + pat + "\", expected \"" + exp + "\""); } } void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat, int32_t pos) { expectPad(fmt, pat, pos, 0, (UnicodeString)""); } void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat, int32_t pos, int32_t width, UChar pad) { expectPad(fmt, pat, pos, width, UnicodeString(pad)); } void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat, int32_t pos, int32_t width, const UnicodeString& pad) { int32_t apos = 0, awidth = 0; UnicodeString apadStr; UErrorCode status = U_ZERO_ERROR; fmt.applyPattern(pat, status); if (U_SUCCESS(status)) { apos = fmt.getPadPosition(); awidth = fmt.getFormatWidth(); apadStr=fmt.getPadCharacterString(); } else { apos = -1; awidth = width; apadStr = pad; } if (apos == pos && awidth == width && apadStr == pad) { UnicodeString infoStr; if (pos == ILLEGAL) { infoStr = UnicodeString(" width=", "") + awidth + UnicodeString(" pad=", "") + apadStr; } logln(UnicodeString("Ok \"") + pat + "\" pos=" + apos + infoStr); } else { errln(UnicodeString("FAIL \"") + pat + "\" pos=" + apos + " width=" + awidth + " pad=" + apadStr + ", expected " + pos + " " + width + " " + pad); } } void NumberFormatTest::TestJB3832(){ const char* localeID = "pt_PT@currency=PTE"; Locale loc(localeID); UErrorCode status = U_ZERO_ERROR; UnicodeString expected(CharsToUnicodeString("1,150$50\\u00A0Esc.")); UnicodeString s; NumberFormat* currencyFmt = NumberFormat::createCurrencyInstance(loc, status); if(U_FAILURE(status)){ dataerrln("Could not create currency formatter for locale %s - %s", localeID, u_errorName(status)); return; } currencyFmt->format(1150.50, s); if(s!=expected){ errln(UnicodeString("FAIL: Expected: ")+expected + UnicodeString(" Got: ") + s + UnicodeString( " for locale: ")+ UnicodeString(localeID) ); } if (U_FAILURE(status)){ errln("FAIL: Status %s", u_errorName(status)); } delete currencyFmt; } void NumberFormatTest::TestHost() { #ifdef U_WINDOWS Win32NumberTest::testLocales(this); #endif for (NumberFormat::EStyles k = NumberFormat::kNumberStyle; k < NumberFormat::kStyleCount; k = (NumberFormat::EStyles)(k+1)) { UErrorCode status = U_ZERO_ERROR; Locale loc("en_US@compat=host"); NumberFormat *full = NumberFormat::createInstance(loc, status); if (full == NULL || U_FAILURE(status)) { dataerrln("FAIL: Can't create number instance for host - %s", u_errorName(status)); return; } UnicodeString result1; Formattable number(10.00); full->format(number, result1, status); if (U_FAILURE(status)) { errln("FAIL: Can't format for host"); return; } Formattable formattable; full->parse(result1, formattable, status); if (U_FAILURE(status)) { errln("FAIL: Can't parse for host"); return; } delete full; } } void NumberFormatTest::TestHostClone() { /* Verify that a cloned formatter gives the same results and is useable after the original has been deleted. */ // This is mainly important on Windows. UErrorCode status = U_ZERO_ERROR; Locale loc("en_US@compat=host"); UDate now = Calendar::getNow(); NumberFormat *full = NumberFormat::createInstance(loc, status); if (full == NULL || U_FAILURE(status)) { dataerrln("FAIL: Can't create Relative date instance - %s", u_errorName(status)); return; } UnicodeString result1; full->format(now, result1, status); Format *fullClone = full->clone(); delete full; full = NULL; UnicodeString result2; fullClone->format(now, result2, status); if (U_FAILURE(status)) { errln("FAIL: format failure."); } if (result1 != result2) { errln("FAIL: Clone returned different result from non-clone."); } delete fullClone; } void NumberFormatTest::TestCurrencyFormat() { // This test is here to increase code coverage. UErrorCode status = U_ZERO_ERROR; MeasureFormat *cloneObj; UnicodeString str; Formattable toFormat, result; static const UChar ISO_CODE[4] = {0x0047, 0x0042, 0x0050, 0}; Locale saveDefaultLocale = Locale::getDefault(); Locale::setDefault( Locale::getUK(), status ); if (U_FAILURE(status)) { errln("couldn't set default Locale!"); return; } MeasureFormat *measureObj = MeasureFormat::createCurrencyFormat(status); Locale::setDefault( saveDefaultLocale, status ); if (U_FAILURE(status)){ dataerrln("FAIL: Status %s", u_errorName(status)); return; } cloneObj = (MeasureFormat *)measureObj->clone(); if (cloneObj == NULL) { errln("Clone doesn't work"); return; } toFormat.adoptObject(new CurrencyAmount(1234.56, ISO_CODE, status)); measureObj->format(toFormat, str, status); measureObj->parseObject(str, result, status); if (U_FAILURE(status)){ errln("FAIL: Status %s", u_errorName(status)); } if (result != toFormat) { errln("measureObj does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat)); } status = U_ZERO_ERROR; str.truncate(0); cloneObj->format(toFormat, str, status); cloneObj->parseObject(str, result, status); if (U_FAILURE(status)){ errln("FAIL: Status %s", u_errorName(status)); } if (result != toFormat) { errln("Clone does not round trip. Formatted string was \"" + str + "\" Got: " + toString(result) + " Expected: " + toString(toFormat)); } if (*measureObj != *cloneObj) { errln("Cloned object is not equal to the original object"); } delete measureObj; delete cloneObj; status = U_USELESS_COLLATOR_ERROR; if (MeasureFormat::createCurrencyFormat(status) != NULL) { errln("createCurrencyFormat should have returned NULL."); } } /* Port of ICU4J rounding test. */ void NumberFormatTest::TestRounding() { UErrorCode status = U_ZERO_ERROR; DecimalFormat *df = (DecimalFormat*)NumberFormat::createCurrencyInstance(Locale::getEnglish(), status); if (U_FAILURE(status)) { dataerrln("Unable to create decimal formatter. - %s", u_errorName(status)); return; } int roundingIncrements[]={1, 2, 5, 20, 50, 100}; int testValues[]={0, 300}; for (int j=0; j<2; j++) { for (int mode=DecimalFormat::kRoundUp;mode<DecimalFormat::kRoundHalfEven;mode++) { df->setRoundingMode((DecimalFormat::ERoundingMode)mode); for (int increment=0; increment<6; increment++) { double base=testValues[j]; double rInc=roundingIncrements[increment]; checkRounding(df, base, 20, rInc); rInc=1.000000000/rInc; checkRounding(df, base, 20, rInc); } } } delete df; } void NumberFormatTest::checkRounding(DecimalFormat* df, double base, int iterations, double increment) { df->setRoundingIncrement(increment); double lastParsed=INT32_MIN; //Intger.MIN_VALUE for (int i=-iterations; i<=iterations;i++) { double iValue=base+(increment*(i*0.1)); double smallIncrement=0.00000001; if (iValue!=0) { smallIncrement*=iValue; } //we not only test the value, but some values in a small range around it lastParsed=checkRound(df, iValue-smallIncrement, lastParsed); lastParsed=checkRound(df, iValue, lastParsed); lastParsed=checkRound(df, iValue+smallIncrement, lastParsed); } } double NumberFormatTest::checkRound(DecimalFormat* df, double iValue, double lastParsed) { UErrorCode status=U_ZERO_ERROR; UnicodeString formattedDecimal; double parsed; Formattable result; df->format(iValue, formattedDecimal, status); if (U_FAILURE(status)) { errln("Error formatting number."); } df->parse(formattedDecimal, result, status); if (U_FAILURE(status)) { errln("Error parsing number."); } parsed=result.getDouble(); if (lastParsed>parsed) { errln("Rounding wrong direction! %d > %d", lastParsed, parsed); } return lastParsed; } void NumberFormatTest::TestNonpositiveMultiplier() { UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols US(Locale::getUS(), status); CHECK(status, "DecimalFormatSymbols constructor"); DecimalFormat df(UnicodeString("0"), US, status); CHECK(status, "DecimalFormat(0)"); // test zero multiplier int32_t mult = df.getMultiplier(); df.setMultiplier(0); if (df.getMultiplier() != mult) { errln("DecimalFormat.setMultiplier(0) did not ignore its zero input"); } // test negative multiplier df.setMultiplier(-1); if (df.getMultiplier() != -1) { errln("DecimalFormat.setMultiplier(-1) ignored its negative input"); return; } expect(df, "1122.123", -1122.123); expect(df, "-1122.123", 1122.123); expect(df, "1.2", -1.2); expect(df, "-1.2", 1.2); // Note: the tests with the final parameter of FALSE will not round trip. // The initial numeric value will format correctly, after the multiplier. // Parsing the formatted text will be out-of-range for an int64, however. // The expect() function could be modified to detect this and fall back // to looking at the decimal parsed value, but it doesn't. expect(df, U_INT64_MIN, "9223372036854775808", FALSE); expect(df, U_INT64_MIN+1, "9223372036854775807"); expect(df, (int64_t)-123, "123"); expect(df, (int64_t)123, "-123"); expect(df, U_INT64_MAX-1, "-9223372036854775806"); expect(df, U_INT64_MAX, "-9223372036854775807"); df.setMultiplier(-2); expect(df, -(U_INT64_MIN/2)-1, "-9223372036854775806"); expect(df, -(U_INT64_MIN/2), "-9223372036854775808"); expect(df, -(U_INT64_MIN/2)+1, "-9223372036854775810", FALSE); df.setMultiplier(-7); expect(df, -(U_INT64_MAX/7)-1, "9223372036854775814", FALSE); expect(df, -(U_INT64_MAX/7), "9223372036854775807"); expect(df, -(U_INT64_MAX/7)+1, "9223372036854775800"); // TODO: uncomment (and fix up) all the following int64_t tests once BigInteger is ported // (right now the big numbers get turned into doubles and lose tons of accuracy) //expect2(df, U_INT64_MAX, Int64ToUnicodeString(-U_INT64_MAX)); //expect2(df, U_INT64_MIN, UnicodeString(Int64ToUnicodeString(U_INT64_MIN), 1)); //expect2(df, U_INT64_MAX / 2, Int64ToUnicodeString(-(U_INT64_MAX / 2))); //expect2(df, U_INT64_MIN / 2, Int64ToUnicodeString(-(U_INT64_MIN / 2))); // TODO: uncomment (and fix up) once BigDecimal is ported and DecimalFormat can handle it //expect2(df, BigDecimal.valueOf(Long.MAX_VALUE), BigDecimal.valueOf(Long.MAX_VALUE).negate().toString()); //expect2(df, BigDecimal.valueOf(Long.MIN_VALUE), BigDecimal.valueOf(Long.MIN_VALUE).negate().toString()); //expect2(df, java.math.BigDecimal.valueOf(Long.MAX_VALUE), java.math.BigDecimal.valueOf(Long.MAX_VALUE).negate().toString()); //expect2(df, java.math.BigDecimal.valueOf(Long.MIN_VALUE), java.math.BigDecimal.valueOf(Long.MIN_VALUE).negate().toString()); } void NumberFormatTest::TestSpaceParsing() { // the data are: // the string to be parsed, parsed position, parsed error index const char* DATA[][3] = { {"$124", "4", "-1"}, {"$124 $124", "4", "-1"}, {"$124 ", "4", "-1"}, //{"$ 124 ", "5", "-1"}, // TODO: need to handle space correctly //{"$\\u00A0124 ", "5", "-1"}, // TODO: need to handle space correctly {"$ 124 ", "0", "0"}, {"$\\u00A0124 ", "0", "0"}, {" $ 124 ", "0", "0"}, // TODO: need to handle space correctly {"124$", "0", "3"}, // TODO: need to handle space correctly // {"124 $", "5", "-1"}, TODO: OK or not, need currency spacing rule {"124 $", "0", "3"}, }; UErrorCode status = U_ZERO_ERROR; NumberFormat* foo = NumberFormat::createCurrencyInstance(status); if (U_FAILURE(status)) { delete foo; return; } for (uint32_t i = 0; i < sizeof(DATA)/sizeof(DATA[0]); ++i) { ParsePosition parsePosition(0); UnicodeString stringToBeParsed = ctou(DATA[i][0]); int parsedPosition = atoi(DATA[i][1]); int errorIndex = atoi(DATA[i][2]); Formattable result; foo->parse(stringToBeParsed, result, parsePosition); if (parsePosition.getIndex() != parsedPosition || parsePosition.getErrorIndex() != errorIndex) { errln("FAILED parse " + stringToBeParsed + "; wrong position, expected: (" + parsedPosition + ", " + errorIndex + "); got (" + parsePosition.getIndex() + ", " + parsePosition.getErrorIndex() + ")"); } if (parsePosition.getErrorIndex() == -1 && result.getType() == Formattable::kLong && result.getLong() != 124) { errln("FAILED parse " + stringToBeParsed + "; wrong number, expect: 124, got " + result.getLong()); } } delete foo; } /** * Test using various numbering systems and numbering system keyword. */ void NumberFormatTest::TestNumberingSystems() { UErrorCode ec = U_ZERO_ERROR; Locale loc1("en", "US", "", "numbers=thai"); Locale loc2("en", "US", "", "numbers=hebr"); Locale loc3("en", "US", "", "numbers=arabext"); Locale loc4("en", "US", "", "numbers=foobar"); Locale loc5("ar", "EG", "", ""); // ar_EG uses arab numbering system Locale loc6("ar", "MA", "", ""); // ar_MA uses latn numbering system Locale loc7("en", "US", "", "numbers=hanidec"); NumberFormat* fmt1= NumberFormat::createInstance(loc1, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(en_US@numbers=thai) - %s", u_errorName(ec)); } NumberFormat* fmt2= NumberFormat::createInstance(loc2, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(en_US@numbers=hebr) - %s", u_errorName(ec)); } NumberFormat* fmt3= NumberFormat::createInstance(loc3, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(en_US@numbers=arabext) - %s", u_errorName(ec)); } NumberFormat* fmt5= NumberFormat::createInstance(loc5, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(ar_EG) - %s", u_errorName(ec)); } NumberFormat* fmt6= NumberFormat::createInstance(loc6, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(ar_MA) - %s", u_errorName(ec)); } NumberFormat* fmt7= NumberFormat::createInstance(loc7, ec); if (U_FAILURE(ec)) { dataerrln("FAIL: getInstance(en_US@numbers=hanidec) - %s", u_errorName(ec)); } if (U_SUCCESS(ec) && fmt1 != NULL && fmt2 != NULL && fmt3 != NULL && fmt5 != NULL && fmt6 != NULL && fmt7 != NULL) { expect2(*fmt1, 1234.567, CharsToUnicodeString("\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57")); expect3(*fmt2, 5678.0, CharsToUnicodeString("\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7")); expect2(*fmt3, 1234.567, CharsToUnicodeString("\\u06F1,\\u06F2\\u06F3\\u06F4.\\u06F5\\u06F6\\u06F7")); expect2(*fmt5, 1234.567, CharsToUnicodeString("\\u0661\\u066c\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667")); expect2(*fmt6, 1234.567, CharsToUnicodeString("1.234,567")); expect2(*fmt7, 1234.567, CharsToUnicodeString("\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03")); } // Test bogus keyword value NumberFormat* fmt4= NumberFormat::createInstance(loc4, ec); if ( ec != U_UNSUPPORTED_ERROR ) { errln("FAIL: getInstance(en_US@numbers=foobar) should have returned U_UNSUPPORTED_ERROR"); } ec = U_ZERO_ERROR; NumberingSystem *ns = NumberingSystem::createInstance(ec); if (U_FAILURE(ec)) { dataerrln("FAIL: NumberingSystem::createInstance(ec); - %s", u_errorName(ec)); } if ( ns != NULL ) { ns->getDynamicClassID(); ns->getStaticClassID(); } else { errln("FAIL: getInstance() returned NULL."); } NumberingSystem *ns1 = new NumberingSystem(*ns); if (ns1 == NULL) { errln("FAIL: NumberSystem copy constructor returned NULL."); } delete ns1; delete ns; delete fmt1; delete fmt2; delete fmt3; delete fmt4; delete fmt5; delete fmt6; delete fmt7; } void NumberFormatTest::TestMultiCurrencySign() { const char* DATA[][6] = { // the fields in the following test are: // locale, // currency pattern (with negative pattern), // currency number to be formatted, // currency format using currency symbol name, such as "$" for USD, // currency format using currency ISO name, such as "USD", // currency format using plural name, such as "US dollars". // for US locale {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1234.56", "$1,234.56", "USD1,234.56", "US dollars1,234.56"}, {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "-1234.56", "-$1,234.56", "-USD1,234.56", "-US dollars1,234.56"}, {"en_US", "\\u00A4#,##0.00;-\\u00A4#,##0.00", "1", "$1.00", "USD1.00", "US dollar1.00"}, // for CHINA locale {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1234.56", "\\uFFE51,234.56", "CNY1,234.56", "\\u4EBA\\u6C11\\u5E011,234.56"}, {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "-1234.56", "(\\uFFE51,234.56)", "(CNY1,234.56)", "(\\u4EBA\\u6C11\\u5E011,234.56)"}, {"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1", "\\uFFE51.00", "CNY1.00", "\\u4EBA\\u6C11\\u5E011.00"} }; const UChar doubleCurrencySign[] = {0xA4, 0xA4, 0}; UnicodeString doubleCurrencyStr(doubleCurrencySign); const UChar tripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0}; UnicodeString tripleCurrencyStr(tripleCurrencySign); for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) { const char* locale = DATA[i][0]; UnicodeString pat = ctou(DATA[i][1]); double numberToBeFormat = atof(DATA[i][2]); UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale(locale), status); if (U_FAILURE(status)) { delete sym; continue; } for (int j=1; j<=3; ++j) { // j represents the number of currency sign in the pattern. if (j == 2) { pat = pat.findAndReplace(ctou("\\u00A4"), doubleCurrencyStr); } else if (j == 3) { pat = pat.findAndReplace(ctou("\\u00A4\\u00A4"), tripleCurrencyStr); } DecimalFormat* fmt = new DecimalFormat(pat, new DecimalFormatSymbols(*sym), status); if (U_FAILURE(status)) { errln("FAILED init DecimalFormat "); delete fmt; continue; } UnicodeString s; ((NumberFormat*) fmt)->format(numberToBeFormat, s); // DATA[i][3] is the currency format result using a // single currency sign. // DATA[i][4] is the currency format result using // double currency sign. // DATA[i][5] is the currency format result using // triple currency sign. // DATA[i][j+2] is the currency format result using // 'j' number of currency sign. UnicodeString currencyFormatResult = ctou(DATA[i][2+j]); if (s.compare(currencyFormatResult)) { errln("FAIL format: Expected " + currencyFormatResult + "; Got " + s); } // mix style parsing for (int k=3; k<=5; ++k) { // DATA[i][3] is the currency format result using a // single currency sign. // DATA[i][4] is the currency format result using // double currency sign. // DATA[i][5] is the currency format result using // triple currency sign. UnicodeString oneCurrencyFormat = ctou(DATA[i][k]); UErrorCode status = U_ZERO_ERROR; Formattable parseRes; fmt->parse(oneCurrencyFormat, parseRes, status); if (U_FAILURE(status) || (parseRes.getType() == Formattable::kDouble && parseRes.getDouble() != numberToBeFormat) || (parseRes.getType() == Formattable::kLong && parseRes.getLong() != numberToBeFormat)) { errln("FAILED parse " + oneCurrencyFormat + "; (i, j, k): " + i + ", " + j + ", " + k); } } delete fmt; } delete sym; } } void NumberFormatTest::TestCurrencyFormatForMixParsing() { UErrorCode status = U_ZERO_ERROR; MeasureFormat* curFmt = MeasureFormat::createCurrencyFormat(Locale("en_US"), status); if (U_FAILURE(status)) { delete curFmt; return; } const char* formats[] = { "$1,234.56", // string to be parsed "USD1,234.56", "US dollars1,234.56", "1,234.56 US dollars" }; const CurrencyAmount* curramt = NULL; for (uint32_t i = 0; i < sizeof(formats)/sizeof(formats[0]); ++i) { UnicodeString stringToBeParsed = ctou(formats[i]); logln(UnicodeString("stringToBeParsed: ") + stringToBeParsed); Formattable result; UErrorCode status = U_ZERO_ERROR; curFmt->parseObject(stringToBeParsed, result, status); if (U_FAILURE(status)) { errln("FAIL: measure format parsing: '%s' ec: %s", formats[i], u_errorName(status)); } else if (result.getType() != Formattable::kObject || (curramt = dynamic_cast<const CurrencyAmount*>(result.getObject())) == NULL || curramt->getNumber().getDouble() != 1234.56 || UnicodeString(curramt->getISOCurrency()).compare(ISO_CURRENCY_USD) ) { errln("FAIL: getCurrencyFormat of default locale (en_US) failed roundtripping the number "); if (curramt->getNumber().getDouble() != 1234.56) { errln((UnicodeString)"wong number, expect: 1234.56" + ", got: " + curramt->getNumber().getDouble()); } if (curramt->getISOCurrency() != ISO_CURRENCY_USD) { errln((UnicodeString)"wong currency, expect: USD" + ", got: " + curramt->getISOCurrency()); } } } delete curFmt; } void NumberFormatTest::TestDecimalFormatCurrencyParse() { // Locale.US UErrorCode status = U_ZERO_ERROR; DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale("en_US"), status); if (U_FAILURE(status)) { delete sym; return; } UnicodeString pat; UChar currency = 0x00A4; // "\xA4#,##0.00;-\xA4#,##0.00" pat.append(currency).append(currency).append(currency).append("#,##0.00;-").append(currency).append(currency).append(currency).append("#,##0.00"); DecimalFormat* fmt = new DecimalFormat(pat, sym, status); if (U_FAILURE(status)) { delete fmt; errln("failed to new DecimalFormat in TestDecimalFormatCurrencyParse"); return; } const char* DATA[][2] = { // the data are: // string to be parsed, the parsed result (number) {"$1.00", "1"}, {"USD1.00", "1"}, {"1.00 US dollar", "1"}, {"$1,234.56", "1234.56"}, {"USD1,234.56", "1234.56"}, {"1,234.56 US dollar", "1234.56"}, }; for (uint32_t i = 0; i < sizeof(DATA)/sizeof(DATA[0]); ++i) { UnicodeString stringToBeParsed = ctou(DATA[i][0]); double parsedResult = atof(DATA[i][1]); UErrorCode status = U_ZERO_ERROR; Formattable result; fmt->parse(stringToBeParsed, result, status); if (U_FAILURE(status) || (result.getType() == Formattable::kDouble && result.getDouble() != parsedResult) || (result.getType() == Formattable::kLong && result.getLong() != parsedResult)) { errln((UnicodeString)"FAIL parse: Expected " + parsedResult); } } delete fmt; } void NumberFormatTest::TestCurrencyIsoPluralFormat() { const char* DATA[][6] = { // the data are: // locale, // currency amount to be formatted, // currency ISO code to be formatted, // format result using CURRENCYSTYLE, // format result using ISOCURRENCYSTYLE, // format result using PLURALCURRENCYSTYLE, {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"}, {"en_US", "1234.56", "USD", "$1,234.56", "USD1,234.56", "1,234.56 US dollars"}, {"en_US", "-1234.56", "USD", "($1,234.56)", "(USD1,234.56)", "-1,234.56 US dollars"}, {"zh_CN", "1", "USD", "US$1.00", "USD1.00", "1.00 \\u7F8E\\u5143"}, {"zh_CN", "1234.56", "USD", "US$1,234.56", "USD1,234.56", "1,234.56 \\u7F8E\\u5143"}, // wrong ISO code {"zh_CN", "1", "CHY", "CHY1.00", "CHY1.00", "1.00 CHY"}, // wrong ISO code {"zh_CN", "1234.56", "CHY", "CHY1,234.56", "CHY1,234.56", "1,234.56 CHY"}, {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"}, {"zh_CN", "1234.56", "CNY", "\\uFFE51,234.56", "CNY1,234.56", "1,234.56 \\u4EBA\\u6C11\\u5E01"}, {"ru_RU", "1", "RUB", "1,00\\u00A0\\u0440\\u0443\\u0431.", "1,00\\u00A0RUB", "1,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0439 \\u0440\\u0443\\u0431\\u043B\\u044C"}, {"ru_RU", "2", "RUB", "2,00\\u00A0\\u0440\\u0443\\u0431.", "2,00\\u00A0RUB", "2,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u044F"}, {"ru_RU", "5", "RUB", "5,00\\u00A0\\u0440\\u0443\\u0431.", "5,00\\u00A0RUB", "5,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0445 \\u0440\\u0443\\u0431\\u043B\\u0435\\u0439"}, // test locale without currency information {"root", "-1.23", "USD", "-US$\\u00A01.23", "-USD\\u00A01.23", "-1.23 USD"}, // test choice format {"es_AR", "1", "INR", "Rs\\u00A01,00", "INR\\u00A01,00", "1,00 rupia india"}, }; for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) { for (NumberFormat::EStyles k = NumberFormat::kCurrencyStyle; k <= NumberFormat::kPluralCurrencyStyle; k = (NumberFormat::EStyles)(k+1)) { // k represents currency format style. if ( k != NumberFormat::kCurrencyStyle && k != NumberFormat::kIsoCurrencyStyle && k != NumberFormat::kPluralCurrencyStyle ) { continue; } const char* localeString = DATA[i][0]; double numberToBeFormat = atof(DATA[i][1]); const char* currencyISOCode = DATA[i][2]; Locale locale(localeString); UErrorCode status = U_ZERO_ERROR; NumberFormat* numFmt = NumberFormat::createInstance(locale, k, status); if (U_FAILURE(status)) { delete numFmt; dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status)); continue; } UChar currencyCode[4]; u_charsToUChars(currencyISOCode, currencyCode, 4); numFmt->setCurrency(currencyCode, status); if (U_FAILURE(status)) { delete numFmt; errln((UnicodeString)"can not set currency:" + currencyISOCode); continue; } UnicodeString strBuf; numFmt->format(numberToBeFormat, strBuf); int resultDataIndex = k; if ( k == NumberFormat::kCurrencyStyle ) { resultDataIndex = k+2; } // DATA[i][resultDataIndex] is the currency format result // using 'k' currency style. UnicodeString formatResult = ctou(DATA[i][resultDataIndex]); if (strBuf.compare(formatResult)) { errln("FAIL: Expected " + formatResult + " actual: " + strBuf); } // test parsing, and test parsing for all currency formats. for (int j = 3; j < 6; ++j) { // DATA[i][3] is the currency format result using // CURRENCYSTYLE formatter. // DATA[i][4] is the currency format result using // ISOCURRENCYSTYLE formatter. // DATA[i][5] is the currency format result using // PLURALCURRENCYSTYLE formatter. UnicodeString oneCurrencyFormatResult = ctou(DATA[i][j]); UErrorCode status = U_ZERO_ERROR; Formattable parseResult; numFmt->parse(oneCurrencyFormatResult, parseResult, status); if (U_FAILURE(status) || (parseResult.getType() == Formattable::kDouble && parseResult.getDouble() != numberToBeFormat) || (parseResult.getType() == Formattable::kLong && parseResult.getLong() != numberToBeFormat)) { errln((UnicodeString)"FAIL: getCurrencyFormat of locale " + localeString + " failed roundtripping the number"); if (parseResult.getType() == Formattable::kDouble) { errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getDouble()); } else { errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong()); } } } delete numFmt; } } } void NumberFormatTest::TestCurrencyParsing() { const char* DATA[][6] = { // the data are: // locale, // currency amount to be formatted, // currency ISO code to be formatted, // format result using CURRENCYSTYLE, // format result using ISOCURRENCYSTYLE, // format result using PLURALCURRENCYSTYLE, {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"}, {"pa_IN", "1", "USD", "US$\\u00a0\\u0a67.\\u0a66\\u0a66", "USD\\u00a0\\u0a67.\\u0a66\\u0a66", "\\u0a67.\\u0a66\\u0a66 USD"}, {"es_AR", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 d\\u00f3lar estadounidense"}, {"ar_EG", "1", "USD", "US$\\u00a0\\u0661\\u066b\\u0660\\u0660", "USD\\u00a0\\u0661\\u066b\\u0660\\u0660", "\\u0661\\u066b\\u0660\\u0660 \\u062f\\u0648\\u0644\\u0627\\u0631 \\u0623\\u0645\\u0631\\u064a\\u0643\\u064a"}, {"fa_CA", "1", "USD", "\\u06f1\\u066b\\u06f0\\u06f0\\u00a0US$", "\\u06f1\\u066b\\u06f0\\u06f0\\u00a0USD", "\\u06f1\\u066b\\u06f0\\u06f0\\u0020\\u062f\\u0644\\u0627\\u0631\\u0020\\u0627\\u0645\\u0631\\u06cc\\u06a9\\u0627"}, {"he_IL", "1", "USD", "1.00\\u00a0US$", "1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"}, {"hr_HR", "1", "USD", "1,00\\u00a0$", "1,00\\u00a0USD", "1,00 Ameri\\u010dki dolar"}, {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 USD"}, {"it_IT", "1", "USD", "US$\\u00a01,00", "USD\\u00a01,00", "1,00 Dollaro Statunitense"}, {"ko_KR", "1", "USD", "US$1.00", "USD1.00", "1.00 \\ubbf8\\uad6d \\ub2ec\\ub7ec"}, {"ja_JP", "1", "USD", "$1.00", "USD1.00", "1.00 \\u7c73\\u30c9\\u30eb"}, {"zh_CN", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4EBA\\u6C11\\u5E01"}, {"zh_TW", "1", "CNY", "\\uFFE51.00", "CNY1.00", "1.00 \\u4eba\\u6c11\\u5e63"}, {"ru_RU", "1", "RUB", "1,00\\u00A0\\u0440\\u0443\\u0431.", "1,00\\u00A0RUB", "1,00 \\u0420\\u043E\\u0441\\u0441\\u0438\\u0439\\u0441\\u043A\\u0438\\u0439 \\u0440\\u0443\\u0431\\u043B\\u044C"}, }; #ifdef NUMFMTST_CACHE_DEBUG int deadloop = 0; for (;;) { printf("loop: %d\n", deadloop++); #endif for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) { for (NumberFormat::EStyles k = NumberFormat::kCurrencyStyle; k <= NumberFormat::kPluralCurrencyStyle; k = (NumberFormat::EStyles)(k+1)) { // k represents currency format style. if ( k != NumberFormat::kCurrencyStyle && k != NumberFormat::kIsoCurrencyStyle && k != NumberFormat::kPluralCurrencyStyle ) { continue; } const char* localeString = DATA[i][0]; double numberToBeFormat = atof(DATA[i][1]); const char* currencyISOCode = DATA[i][2]; Locale locale(localeString); UErrorCode status = U_ZERO_ERROR; NumberFormat* numFmt = NumberFormat::createInstance(locale, k, status); if (U_FAILURE(status)) { delete numFmt; dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status)); continue; } // TODO: need to be UChar* UChar currencyCode[4]; currencyCode[0] = currencyISOCode[0]; currencyCode[1] = currencyISOCode[1]; currencyCode[2] = currencyISOCode[2]; currencyCode[3] = currencyISOCode[3]; numFmt->setCurrency(currencyCode, status); if (U_FAILURE(status)) { delete numFmt; errln((UnicodeString)"can not set currency:" + currencyISOCode); continue; } /* UnicodeString strBuf; numFmt->format(numberToBeFormat, strBuf); int resultDataIndex = k; if ( k == NumberFormat::kCurrencyStyle ) { resultDataIndex = k+2; } // DATA[i][resultDataIndex] is the currency format result // using 'k' currency style. UnicodeString formatResult = ctou(DATA[i][resultDataIndex]); if (strBuf.compare(formatResult)) { errln("FAIL: Expected " + formatResult + " actual: " + strBuf); } */ // test parsing, and test parsing for all currency formats. for (int j = 3; j < 6; ++j) { // DATA[i][3] is the currency format result using // CURRENCYSTYLE formatter. // DATA[i][4] is the currency format result using // ISOCURRENCYSTYLE formatter. // DATA[i][5] is the currency format result using // PLURALCURRENCYSTYLE formatter. UnicodeString oneCurrencyFormatResult = ctou(DATA[i][j]); UErrorCode status = U_ZERO_ERROR; Formattable parseResult; numFmt->parse(oneCurrencyFormatResult, parseResult, status); if (U_FAILURE(status) || (parseResult.getType() == Formattable::kDouble && parseResult.getDouble() != numberToBeFormat) || (parseResult.getType() == Formattable::kLong && parseResult.getLong() != numberToBeFormat)) { errln((UnicodeString)"FAIL: getCurrencyFormat of locale " + localeString + " failed roundtripping the number" + "(i,k,j): " + i + ", " + k + ", " + j); if (parseResult.getType() == Formattable::kDouble) { errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getDouble()); } else { errln((UnicodeString)"expected: " + numberToBeFormat + "; actual: " +parseResult.getLong()); } } } delete numFmt; } } #ifdef NUMFMTST_CACHE_DEBUG } #endif } void NumberFormatTest::TestParseCurrencyInUCurr() { const char* DATA[] = { "1.00 US DOLLAR", // case in-sensitive "$1.00", "USD1.00", "US dollar1.00", "US dollars1.00", "$1.00", "AU$1.00", "ADP1.00", "ADP1.00", "AED1.00", "AED1.00", "AFA1.00", "AFA1.00", "AFN1.00", "ALL1.00", "AMD1.00", "ANG1.00", "AOA1.00", "AOK1.00", "AOK1.00", "AON1.00", "AON1.00", "AOR1.00", "AOR1.00", "AR$1.00", "ARA1.00", "ARA1.00", "ARP1.00", "ARP1.00", "ARS1.00", "ATS1.00", "ATS1.00", "AUD1.00", "AWG1.00", "AZM1.00", "AZM1.00", "AZN1.00", "Af1.00", "Afghan Afghani (1927-2002)1.00", "Afghan Afghani (AFA)1.00", "Afghan Afghani1.00", "Afghan Afghani1.00", "Afghan Afghanis (AFA)1.00", "Afghan Afghanis1.00", "Afl.1.00", "Albanian Lek1.00", "Albanian lek1.00", "Albanian lek\\u00eb1.00", "Algerian Dinar1.00", "Algerian dinar1.00", "Algerian dinars1.00", "Andorran Peseta1.00", "Andorran peseta1.00", "Andorran pesetas1.00", "Angolan Kwanza (1977-1991)1.00", "Angolan Readjusted Kwanza (1995-1999)1.00", "Angolan Kwanza1.00", "Angolan New Kwanza (1990-2000)1.00", "Angolan kwanza (1977-1991)1.00", "Angolan readjusted kwanza (1995-1999)1.00", "Angolan kwanza1.00", "Angolan kwanzas (1977-1991)1.00", "Angolan readjusted kwanzas (1995-1999)1.00", "Angolan kwanzas1.00", "Angolan new kwanza (1990-2000)1.00", "Angolan new kwanzas (1990-2000)1.00", "Argentine Austral1.00", "Argentine Peso (1983-1985)1.00", "Argentine Peso1.00", "Argentine austral1.00", "Argentine australs1.00", "Argentine peso (1983-1985)1.00", "Argentine peso1.00", "Argentine pesos (1983-1985)1.00", "Argentine pesos1.00", "Armenian Dram1.00", "Armenian dram1.00", "Armenian drams1.00", "Aruban Florin1.00", "Aruban florin1.00", "Australian Dollar1.00", "Australian dollar1.00", "Australian dollars1.00", "Austrian Schilling1.00", "Austrian schilling1.00", "Austrian schillings1.00", "Azerbaijani Manat (1993-2006)1.00", "Azerbaijani Manat1.00", "Azerbaijani manat (1993-2006)1.00", "Azerbaijani manat1.00", "Azerbaijani manats (1993-2006)1.00", "Azerbaijani manats1.00", "BN$1.00", "BAD1.00", "BAD1.00", "BAM1.00", "BBD1.00", "BD$1.00", "BDT1.00", "BEC1.00", "BEC1.00", "BEF1.00", "BEL1.00", "BEL1.00", "BF1.00", "BGL1.00", "BGN1.00", "BGN1.00", "BHD1.00", "BIF1.00", "BMD1.00", "BND1.00", "BOB1.00", "BOP1.00", "BOP1.00", "BOV1.00", "BOV1.00", "BRB1.00", "BRB1.00", "BRC1.00", "BRC1.00", "BRE1.00", "BRE1.00", "BRL1.00", "BRN1.00", "BRN1.00", "BRR1.00", "BRR1.00", "BSD1.00", "BSD1.00", "BTN1.00", "BUK1.00", "BUK1.00", "BWP1.00", "BYB1.00", "BYB1.00", "BYR1.00", "BZ$1.00", "BZD1.00", "Bahamian Dollar1.00", "Bahamian dollar1.00", "Bahamian dollars1.00", "Bahraini Dinar1.00", "Bahraini dinar1.00", "Bahraini dinars1.00", "Bangladeshi Taka1.00", "Bangladeshi taka1.00", "Bangladeshi takas1.00", "Barbadian Dollar1.00", "Barbadian dollar1.00", "Barbadian dollars1.00", "Bds$1.00", "Belarusian New Ruble (1994-1999)1.00", "Belarusian Ruble1.00", "Belarusian new ruble (1994-1999)1.00", "Belarusian new rubles (1994-1999)1.00", "Belarusian ruble1.00", "Belarusian rubles1.00", "Belgian Franc (convertible)1.00", "Belgian Franc (financial)1.00", "Belgian Franc1.00", "Belgian franc (convertible)1.00", "Belgian franc (financial)1.00", "Belgian franc1.00", "Belgian francs (convertible)1.00", "Belgian francs (financial)1.00", "Belgian francs1.00", "Belize Dollar1.00", "Belize dollar1.00", "Belize dollars1.00", "Bermudan Dollar1.00", "Bermudan dollar1.00", "Bermudan dollars1.00", "Bhutanese Ngultrum1.00", "Bhutanese ngultrum1.00", "Bhutanese ngultrums1.00", "Bolivian Mvdol1.00", "Bolivian Peso1.00", "Bolivian mvdol1.00", "Bolivian mvdols1.00", "Bolivian peso1.00", "Bolivian pesos1.00", "Bolivian Boliviano1.00", "Bolivian Boliviano1.00", "Bolivian Bolivianos1.00", "Bosnia-Herzegovina Convertible Mark1.00", "Bosnia-Herzegovina Dinar (1992-1994)1.00", "Bosnia-Herzegovina convertible mark1.00", "Bosnia-Herzegovina convertible marks1.00", "Bosnia-Herzegovina dinar (1992-1994)1.00", "Bosnia-Herzegovina dinars (1992-1994)1.00", "Botswanan Pula1.00", "Botswanan pula1.00", "Botswanan pulas1.00", "Br1.00", "Brazilian New Cruzado (1989-1990)1.00", "Brazilian Cruzado (1986-1989)1.00", "Brazilian Cruzeiro (1990-1993)1.00", "Brazilian New Cruzeiro (1967-1986)1.00", "Brazilian Cruzeiro (1993-1994)1.00", "Brazilian Real1.00", "Brazilian new cruzado (1989-1990)1.00", "Brazilian new cruzados (1989-1990)1.00", "Brazilian cruzado (1986-1989)1.00", "Brazilian cruzados (1986-1989)1.00", "Brazilian cruzeiro (1990-1993)1.00", "Brazilian new cruzeiro (1967-1986)1.00", "Brazilian cruzeiro (1993-1994)1.00", "Brazilian cruzeiros (1990-1993)1.00", "Brazilian new cruzeiros (1967-1986)1.00", "Brazilian cruzeiros (1993-1994)1.00", "Brazilian real1.00", "Brazilian reals1.00", "British Pound Sterling1.00", "British pound sterling1.00", "British pounds sterling1.00", "Brunei Dollar1.00", "Brunei dollar1.00", "Brunei dollars1.00", "Bs1.00", "Bs.F.1.00", "Bulgarian Hard Lev1.00", "Bulgarian Lev1.00", "Bulgarian Leva1.00", "Bulgarian hard lev1.00", "Bulgarian hard leva1.00", "Bulgarian lev1.00", "Burmese Kyat1.00", "Burmese kyat1.00", "Burmese kyats1.00", "Burundian Franc1.00", "Burundian franc1.00", "Burundian francs1.00", "C$1.00", "CA$1.00", "CAD1.00", "CDF1.00", "CDF1.00", "CF1.00", "CFA Franc BCEAO1.00", "CFA Franc BEAC1.00", "CFA franc BCEAO1.00", "CFA franc BEAC1.00", "CFA francs BCEAO1.00", "CFA francs BEAC1.00", "CFP Franc1.00", "CFP franc1.00", "CFP francs1.00", "CFPF1.00", "CHE1.00", "CHE1.00", "CHF1.00", "CHW1.00", "CHW1.00", "CL$1.00", "CLF1.00", "CLF1.00", "CLP1.00", "CNY1.00", "CO$1.00", "COP1.00", "COU1.00", "COU1.00", "CRC1.00", "CSD1.00", "CSD1.00", "CSK1.00", "CSK1.00", "CUP1.00", "CUP1.00", "CVE1.00", "CYP1.00", "CZK1.00", "Cambodian Riel1.00", "Cambodian riel1.00", "Cambodian riels1.00", "Canadian Dollar1.00", "Canadian dollar1.00", "Canadian dollars1.00", "Cape Verdean Escudo1.00", "Cape Verdean escudo1.00", "Cape Verdean escudos1.00", "Cayman Islands Dollar1.00", "Cayman Islands dollar1.00", "Cayman Islands dollars1.00", "Chilean Peso1.00", "Chilean Unit of Account (UF)1.00", "Chilean peso1.00", "Chilean pesos1.00", "Chilean unit of account (UF)1.00", "Chilean units of account (UF)1.00", "Chinese Yuan1.00", "Chinese yuan1.00", "Colombian Peso1.00", "Colombian peso1.00", "Colombian pesos1.00", "Comorian Franc1.00", "Comorian franc1.00", "Comorian francs1.00", "Congolese Franc1.00", "Congolese franc1.00", "Congolese francs1.00", "Costa Rican Col\\u00f3n1.00", "Costa Rican col\\u00f3n1.00", "Costa Rican col\\u00f3ns1.00", "Croatian Dinar1.00", "Croatian Kuna1.00", "Croatian dinar1.00", "Croatian dinars1.00", "Croatian kuna1.00", "Croatian kunas1.00", "Cuban Peso1.00", "Cuban peso1.00", "Cuban pesos1.00", "Cypriot Pound1.00", "Cypriot pound1.00", "Cypriot pounds1.00", "Czech Republic Koruna1.00", "Czech Republic koruna1.00", "Czech Republic korunas1.00", "Czechoslovak Hard Koruna1.00", "Czechoslovak hard koruna1.00", "Czechoslovak hard korunas1.00", "DA1.00", "DDM1.00", "DDM1.00", "DEM1.00", "DEM1.00", "DJF1.00", "DKK1.00", "DOP1.00", "DZD1.00", "Danish Krone1.00", "Danish krone1.00", "Danish kroner1.00", "Db1.00", "German Mark1.00", "German mark1.00", "German marks1.00", "Djiboutian Franc1.00", "Djiboutian franc1.00", "Djiboutian francs1.00", "Dkr1.00", "Dominican Peso1.00", "Dominican peso1.00", "Dominican pesos1.00", "EC$1.00", "ECS1.00", "ECS1.00", "ECV1.00", "ECV1.00", "EEK1.00", "EEK1.00", "EGP1.00", "EGP1.00", "ERN1.00", "ERN1.00", "ESA1.00", "ESA1.00", "ESB1.00", "ESB1.00", "ESP1.00", "ETB1.00", "EUR1.00", "East Caribbean Dollar1.00", "East Caribbean dollar1.00", "East Caribbean dollars1.00", "East German Mark1.00", "East German mark1.00", "East German marks1.00", "Ecuadorian Sucre1.00", "Ecuadorian Unit of Constant Value1.00", "Ecuadorian sucre1.00", "Ecuadorian sucres1.00", "Ecuadorian unit of constant value1.00", "Ecuadorian units of constant value1.00", "Egyptian Pound1.00", "Egyptian pound1.00", "Egyptian pounds1.00", "Salvadoran Col\\u00f3n1.00", "Salvadoran col\\u00f3n1.00", "Salvadoran colones1.00", "Equatorial Guinean Ekwele1.00", "Equatorial Guinean ekwele1.00", "Eritrean Nakfa1.00", "Eritrean nakfa1.00", "Eritrean nakfas1.00", "Esc1.00", "Estonian Kroon1.00", "Estonian kroon1.00", "Estonian kroons1.00", "Ethiopian Birr1.00", "Ethiopian birr1.00", "Ethiopian birrs1.00", "Euro1.00", "European Composite Unit1.00", "European Currency Unit1.00", "European Monetary Unit1.00", "European Unit of Account (XBC)1.00", "European Unit of Account (XBD)1.00", "European composite unit1.00", "European composite units1.00", "European currency unit1.00", "European currency units1.00", "European monetary unit1.00", "European monetary units1.00", "European unit of account (XBC)1.00", "European unit of account (XBD)1.00", "European units of account (XBC)1.00", "European units of account (XBD)1.00", "FJ$1.00", "FBu1.00", "FIM1.00", "FIM1.00", "FJD1.00", "FKP1.00", "FKP1.00", "FRF1.00", "FRF1.00", "Falkland Islands Pound1.00", "Falkland Islands pound1.00", "Falkland Islands pounds1.00", "Fdj1.00", "Fijian Dollar1.00", "Fijian dollar1.00", "Fijian dollars1.00", "Finnish Markka1.00", "Finnish markka1.00", "Finnish markkas1.00", "CHF1.00", "French Franc1.00", "French Gold Franc1.00", "French UIC-Franc1.00", "French UIC-franc1.00", "French UIC-francs1.00", "French franc1.00", "French francs1.00", "French gold franc1.00", "French gold francs1.00", "Ft1.00", "GY$1.00", "GBP1.00", "GEK1.00", "GEK1.00", "GEL1.00", "FG1.00", "GHC1.00", "GHC1.00", "GHS1.00", "GIP1.00", "GIP1.00", "GMD1.00", "GMD1.00", "GNF1.00", "GNS1.00", "GNS1.00", "GQE1.00", "GQE1.00", "GRD1.00", "GRD1.00", "GTQ1.00", "GWE1.00", "GWE1.00", "GWP1.00", "GWP1.00", "GYD1.00", "Gambian Dalasi1.00", "Gambian dalasi1.00", "Gambian dalasis1.00", "Georgian Kupon Larit1.00", "Georgian Lari1.00", "Georgian kupon larit1.00", "Georgian kupon larits1.00", "Georgian lari1.00", "Georgian laris1.00", "Ghanaian Cedi (1979-2007)1.00", "Ghanaian Cedi1.00", "Ghanaian cedi (1979-2007)1.00", "Ghanaian cedi1.00", "Ghanaian cedis (1979-2007)1.00", "Ghanaian cedis1.00", "Gibraltar Pound1.00", "Gibraltar pound1.00", "Gibraltar pounds1.00", "Gold1.00", "Gold1.00", "Greek Drachma1.00", "Greek drachma1.00", "Greek drachmas1.00", "Guatemalan Quetzal1.00", "Guatemalan quetzal1.00", "Guatemalan quetzals1.00", "Guinean Franc1.00", "Guinean Syli1.00", "Guinean franc1.00", "Guinean francs1.00", "Guinean syli1.00", "Guinean sylis1.00", "Guinea-Bissau Peso1.00", "Guinea-Bissau peso1.00", "Guinea-Bissau pesos1.00", "Guyanaese Dollar1.00", "Guyanaese dollar1.00", "Guyanaese dollars1.00", "HK$1.00", "HKD1.00", "HNL1.00", "HRD1.00", "HRD1.00", "HRK1.00", "HRK1.00", "HTG1.00", "HTG1.00", "HUF1.00", "Haitian Gourde1.00", "Haitian gourde1.00", "Haitian gourdes1.00", "Honduran Lempira1.00", "Honduran lempira1.00", "Honduran lempiras1.00", "Hong Kong Dollar1.00", "Hong Kong dollar1.00", "Hong Kong dollars1.00", "Hungarian Forint1.00", "Hungarian forint1.00", "Hungarian forints1.00", "IDR1.00", "IEP1.00", "ILP1.00", "ILP1.00", "ILS1.00", "INR1.00", "IQD1.00", "IRR1.00", "IR\\u00a31.00", "ISK1.00", "ISK1.00", "ITL1.00", "Icelandic Kr\\u00f3na1.00", "Icelandic kr\\u00f3na1.00", "Icelandic kr\\u00f3nur1.00", "Indian Rupee1.00", "Indian rupee1.00", "Indian rupees1.00", "Indonesian Rupiah1.00", "Indonesian rupiah1.00", "Indonesian rupiahs1.00", "Iranian Rial1.00", "Iranian rial1.00", "Iranian rials1.00", "Iraqi Dinar1.00", "Iraqi dinar1.00", "Iraqi dinars1.00", "Irish Pound1.00", "Irish pound1.00", "Irish pounds1.00", "Israeli Pound1.00", "Israeli new sheqel1.00", "Israeli pound1.00", "Israeli pounds1.00", "Italian Lira1.00", "Italian lira1.00", "Italian liras1.00", "J$1.00", "JD1.00", "JMD1.00", "JOD1.00", "JPY1.00", "Jamaican Dollar1.00", "Jamaican dollar1.00", "Jamaican dollars1.00", "Japanese Yen1.00", "Japanese yen1.00", "Jordanian Dinar1.00", "Jordanian dinar1.00", "Jordanian dinars1.00", "Ksh1.00", "KD1.00", "KES1.00", "KGS1.00", "KHR1.00", "KMF1.00", "KPW1.00", "KPW1.00", "KRW1.00", "KWD1.00", "KYD1.00", "KYD1.00", "KZT1.00", "Kazakhstani Tenge1.00", "Kazakhstani tenge1.00", "Kazakhstani tenges1.00", "Kenyan Shilling1.00", "Kenyan shilling1.00", "Kenyan shillings1.00", "Kuwaiti Dinar1.00", "Kuwaiti dinar1.00", "Kuwaiti dinars1.00", "Kyrgystani Som1.00", "Kyrgystani som1.00", "Kyrgystani soms1.00", "Kz1.00", "K\\u010d1.00", "HNL1.00", "LAK1.00", "LAK1.00", "LBP1.00", "LD1.00", "LKR1.00", "LB\\u00a31.00", "LRD1.00", "LRD1.00", "LSL1.00", "LTL1.00", "LTL1.00", "LTT1.00", "LTT1.00", "LUC1.00", "LUC1.00", "LUF1.00", "LUF1.00", "LUL1.00", "LUL1.00", "LVL1.00", "LVL1.00", "LVR1.00", "LVR1.00", "LYD1.00", "Laotian Kip1.00", "Laotian kip1.00", "Laotian kips1.00", "Latvian Lats1.00", "Latvian Ruble1.00", "Latvian lats1.00", "Latvian lati.00", "Latvian ruble1.00", "Latvian rubles1.00", "Lebanese Pound1.00", "Lebanese pound1.00", "Lebanese pounds1.00", "Lesotho Loti1.00", "Lesotho loti1.00", "Lesotho lotis1.00", "Liberian Dollar1.00", "Liberian dollar1.00", "Liberian dollars1.00", "Libyan Dinar1.00", "Libyan dinar1.00", "Libyan dinars1.00", "Lithuanian Litas1.00", "Lithuanian Talonas1.00", "Lithuanian litas1.00", "Lithuanian litai1.00", "Lithuanian talonas1.00", "Lithuanian talonases1.00", "Lm1.00", "Luxembourgian Convertible Franc1.00", "Luxembourg Financial Franc1.00", "Luxembourgian Franc1.00", "Luxembourgian convertible franc1.00", "Luxembourgian convertible francs1.00", "Luxembourg financial franc1.00", "Luxembourg financial francs1.00", "Luxembourgian franc1.00", "Luxembourgian francs1.00", "MAD1.00", "MAD1.00", "MAF1.00", "MAF1.00", "MDL1.00", "MDL1.00", "MX$1.00", "MGA1.00", "MGA1.00", "MGF1.00", "MGF1.00", "MKD1.00", "MLF1.00", "MLF1.00", "MMK1.00", "MMK1.00", "MNT1.00", "MOP1.00", "MOP1.00", "MRO1.00", "MTL1.00", "MTP1.00", "MTP1.00", "MTn1.00", "MUR1.00", "MUR1.00", "MVR1.00", "MVR1.00", "MWK1.00", "MXN1.00", "MXP1.00", "MXP1.00", "MXV1.00", "MXV1.00", "MYR1.00", "MZE1.00", "MZE1.00", "MZM1.00", "MZN1.00", "Macanese Pataca1.00", "Macanese pataca1.00", "Macanese patacas1.00", "Macedonian Denar1.00", "Macedonian denar1.00", "Macedonian denari1.00", "Malagasy Ariaries1.00", "Malagasy Ariary1.00", "Malagasy Ariary1.00", "Malagasy Franc1.00", "Malagasy franc1.00", "Malagasy francs1.00", "Malawian Kwacha1.00", "Malawian Kwacha1.00", "Malawian Kwachas1.00", "Malaysian Ringgit1.00", "Malaysian ringgit1.00", "Malaysian ringgits1.00", "Maldivian Rufiyaa1.00", "Maldivian rufiyaa1.00", "Maldivian rufiyaas1.00", "Malian Franc1.00", "Malian franc1.00", "Malian francs1.00", "Maltese Lira1.00", "Maltese Pound1.00", "Maltese lira1.00", "Maltese lira1.00", "Maltese pound1.00", "Maltese pounds1.00", "Mauritanian Ouguiya1.00", "Mauritanian ouguiya1.00", "Mauritanian ouguiyas1.00", "Mauritian Rupee1.00", "Mauritian rupee1.00", "Mauritian rupees1.00", "Mexican Peso1.00", "Mexican Silver Peso (1861-1992)1.00", "Mexican Investment Unit1.00", "Mexican peso1.00", "Mexican pesos1.00", "Mexican silver peso (1861-1992)1.00", "Mexican silver pesos (1861-1992)1.00", "Mexican investment unit1.00", "Mexican investment units1.00", "Moldovan Leu1.00", "Moldovan leu1.00", "Moldovan lei1.00", "Mongolian Tugrik1.00", "Mongolian tugrik1.00", "Mongolian tugriks1.00", "Moroccan Dirham1.00", "Moroccan Franc1.00", "Moroccan dirham1.00", "Moroccan dirhams1.00", "Moroccan franc1.00", "Moroccan francs1.00", "Mozambican Escudo1.00", "Mozambican Metical1.00", "Mozambican escudo1.00", "Mozambican escudos1.00", "Mozambican metical1.00", "Mozambican meticals1.00", "Mt1.00", "Myanma Kyat1.00", "Myanma kyat1.00", "Myanma kyats1.00", "N$1.00", "NAD1.00", "NAf.1.00", "NGN1.00", "NIC1.00", "NIO1.00", "NIO1.00", "Nkr1.00", "NLG1.00", "NLG1.00", "NOK1.00", "NPR1.00", "NT$1.00", "NZ$1.00", "NZD1.00", "Namibian Dollar1.00", "Namibian dollar1.00", "Namibian dollars1.00", "Nepalese Rupee1.00", "Nepalese rupee1.00", "Nepalese rupees1.00", "Netherlands Antillean Guilder1.00", "Netherlands Antillean guilder1.00", "Netherlands Antillean guilders1.00", "Dutch Guilder1.00", "Dutch guilder1.00", "Dutch guilders1.00", "Israeli New Sheqel1.00", "Israeli New Sheqels1.00", "New Zealand Dollar1.00", "New Zealand dollar1.00", "New Zealand dollars1.00", "Nicaraguan C\\u00f3rdoba1.00", "Nicaraguan C\\u00f3rdoba (1988-1991)1.00", "Nicaraguan c\\u00f3rdoba1.00", "Nicaraguan c\\u00f3rdobas1.00", "Nicaraguan c\\u00f3rdoba (1988-1991)1.00", "Nicaraguan c\\u00f3rdobas (1988-1991)1.00", "Nigerian Naira1.00", "Nigerian naira1.00", "Nigerian nairas1.00", "North Korean Won1.00", "North Korean won1.00", "North Korean won1.00", "Norwegian Krone1.00", "Norwegian krone1.00", "Norwegian kroner1.00", "NPRs1.00", "Nu.1.00", "OMR1.00", "Mozambican Metical (1980-2006)1.00", "Mozambican metical (1980-2006)1.00", "Mozambican meticals (1980-2006)1.00", "Romanian Lei (1952-2006)1.00", "Romanian Leu (1952-2006)1.00", "Romanian leu (1952-2006)1.00", "Serbian Dinar (2002-2006)1.00", "Serbian dinar (2002-2006)1.00", "Serbian dinars (2002-2006)1.00", "Sudanese Dinar (1992-2007)1.00", "Sudanese Pound (1957-1998)1.00", "Sudanese dinar (1992-2007)1.00", "Sudanese dinars (1992-2007)1.00", "Sudanese pound (1957-1998)1.00", "Sudanese pounds (1957-1998)1.00", "Turkish Lira (1922-2005)1.00", "Turkish Lira (1922-2005)1.00", "Omani Rial1.00", "Omani rial1.00", "Omani rials1.00", "PAB1.00", "PAB1.00", "PEI1.00", "PEI1.00", "PEN1.00", "PEN1.00", "PES1.00", "PES1.00", "PGK1.00", "PGK1.00", "PHP1.00", "PKR1.00", "PLN1.00", "PLZ1.00", "PLZ1.00", "PTE1.00", "PTE1.00", "PYG1.00", "Pakistani Rupee1.00", "Pakistani rupee1.00", "Pakistani rupees1.00", "Palladium1.00", "Palladium1.00", "Panamanian Balboa1.00", "Panamanian balboa1.00", "Panamanian balboas1.00", "Papua New Guinean Kina1.00", "Papua New Guinean kina1.00", "Papua New Guinean kina1.00", "Paraguayan Guarani1.00", "Paraguayan guarani1.00", "Paraguayan guaranis1.00", "Peruvian Inti1.00", "Peruvian Nuevo Sol1.00", "Peruvian Sol (1863-1965)1.00", "Peruvian inti1.00", "Peruvian intis1.00", "Peruvian nuevo sol1.00", "Peruvian nuevos soles1.00", "Peruvian sol (1863-1965)1.00", "Peruvian soles (1863-1965)1.00", "Philippine Peso1.00", "Philippine peso1.00", "Philippine pesos1.00", "Platinum1.00", "Platinum1.00", "Polish Zloty (1950-1995)1.00", "Polish Zloty1.00", "Polish zlotys1.00", "Polish zloty (PLZ)1.00", "Polish zloty1.00", "Polish zlotys (PLZ)1.00", "Portuguese Escudo1.00", "Portuguese Guinea Escudo1.00", "Portuguese Guinea escudo1.00", "Portuguese Guinea escudos1.00", "Portuguese escudo1.00", "Portuguese escudos1.00", "PKRs1.00", "GTQ1.00", "QAR1.00", "QR1.00", "Qatari Rial1.00", "Qatari rial1.00", "Qatari rials1.00", "R1.00", "R$1.00", "RD$1.00", "RHD1.00", "RHD1.00", "RINET Funds1.00", "RINET Funds1.00", "RM1.00", "CN\\u00a51.00", "ROL1.00", "ROL1.00", "RON1.00", "RON1.00", "RSD1.00", "RSD1.00", "RUB1.00", "RUB1.00", "RUR1.00", "RUR1.00", "RWF1.00", "RWF1.00", "Rhodesian Dollar1.00", "Rhodesian dollar1.00", "Rhodesian dollars1.00", "Romanian Leu1.00", "Romanian lei1.00", "Romanian leu1.00", "Rp1.00", "Russian Ruble (1991-1998)1.00", "Russian Ruble1.00", "Russian ruble (1991-1998)1.00", "Russian ruble1.00", "Russian rubles (1991-1998)1.00", "Russian rubles1.00", "Rwandan Franc1.00", "Rwandan franc1.00", "Rwandan francs1.00", "S$1.00", "SAR1.00", "SBD1.00", "SCR1.00", "SDD1.00", "SDD1.00", "SDG1.00", "SDG1.00", "SDP1.00", "SDP1.00", "SEK1.00", "SGD1.00", "SHP1.00", "SHP1.00", "SI$1.00", "SIT1.00", "SIT1.00", "SKK1.00", "Skr1.00", "SLRs1.00", "SLL1.00", "SLL1.00", "SOS1.00", "SRD1.00", "SRD1.00", "SRG1.00", "SRe1.00", "STD1.00", "SUR1.00", "SUR1.00", "SVC1.00", "SVC1.00", "SYP1.00", "SZL1.00", "Saint Helena Pound1.00", "Saint Helena pound1.00", "Saint Helena pounds1.00", "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra1.00", "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra1.00", "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras1.00", "Saudi Riyal1.00", "Saudi riyal1.00", "Saudi riyals1.00", "Serbian Dinar1.00", "Serbian dinar1.00", "Serbian dinars1.00", "Seychellois Rupee1.00", "Seychellois rupee1.00", "Seychellois rupees1.00", "Sf1.00", "Ssh1.00", "Sierra Leonean Leone1.00", "Sierra Leonean leone1.00", "Sierra Leonean leones1.00", "Silver1.00", "Silver1.00", "Singapore Dollar1.00", "Singapore dollar1.00", "Singapore dollars1.00", "Sk1.00", "Slovak Koruna1.00", "Slovak koruna1.00", "Slovak korunas1.00", "Slovenian Tolar1.00", "Slovenian tolar1.00", "Slovenian tolars1.00", "Solomon Islands Dollar1.00", "Solomon Islands dollar1.00", "Solomon Islands dollars1.00", "Somali Shilling1.00", "Somali shilling1.00", "Somali shillings1.00", "South African Rand (financial)1.00", "South African Rand1.00", "South African rand (financial)1.00", "South African rand1.00", "South African rands (financial)1.00", "South African rand1.00", "South Korean Won1.00", "South Korean won1.00", "South Korean won1.00", "Soviet Rouble1.00", "Soviet rouble1.00", "Soviet roubles1.00", "Spanish Peseta (A account)1.00", "Spanish Peseta (convertible account)1.00", "Spanish Peseta1.00", "Spanish peseta (A account)1.00", "Spanish peseta (convertible account)1.00", "Spanish peseta1.00", "Spanish pesetas (A account)1.00", "Spanish pesetas (convertible account)1.00", "Spanish pesetas1.00", "Special Drawing Rights1.00", "Sri Lankan Rupee1.00", "Sri Lankan rupee1.00", "Sri Lankan rupees1.00", "Sudanese Pound1.00", "Sudanese pound1.00", "Sudanese pounds1.00", "Surinamese Dollar1.00", "Surinamese dollar1.00", "Surinamese dollars1.00", "Surinamese Guilder1.00", "Surinamese guilder1.00", "Surinamese guilders1.00", "Swazi Lilangeni1.00", "Swazi lilangeni1.00", "Swazi emalangeni1.00", "Swedish Krona1.00", "Swedish krona1.00", "Swedish kronor1.00", "Swiss Franc1.00", "Swiss franc1.00", "Swiss francs1.00", "Syrian Pound1.00", "Syrian pound1.00", "Syrian pounds1.00", "TSh1.00", "T$1.00", "THB1.00", "TJR1.00", "TJR1.00", "TJS1.00", "TJS1.00", "TL1.00", "TMM1.00", "TMM1.00", "TND1.00", "TND1.00", "TOP1.00", "TPE1.00", "TPE1.00", "TRL1.00", "TRY1.00", "TRY1.00", "TT$1.00", "TTD1.00", "TWD1.00", "TZS1.00", "New Taiwan Dollar1.00", "New Taiwan dollar1.00", "New Taiwan dollars1.00", "Tajikistani Ruble1.00", "Tajikistani Somoni1.00", "Tajikistani ruble1.00", "Tajikistani rubles1.00", "Tajikistani somoni1.00", "Tajikistani somonis1.00", "Tanzanian Shilling1.00", "Tanzanian shilling1.00", "Tanzanian shillings1.00", "Testing Currency Code1.00", "Testing Currency Code1.00", "Thai Baht1.00", "Thai baht1.00", "Thai baht1.00", "Timorese Escudo1.00", "Timorese escudo1.00", "Timorese escudos1.00", "Tk1.00", "Tongan Pa\\u02bbanga1.00", "Tongan pa\\u02bbanga1.00", "Tongan pa\\u02bbanga1.00", "Trinidad and Tobago Dollar1.00", "Trinidad and Tobago dollar1.00", "Trinidad and Tobago dollars1.00", "Tunisian Dinar1.00", "Tunisian dinar1.00", "Tunisian dinars1.00", "Turkish Lira1.00", "Turkish Lira1.00", "Turkish lira1.00", "Turkmenistani Manat1.00", "Turkmenistani manat1.00", "Turkmenistani manat1.00", "USh1.00", "UAE dirham1.00", "UAE dirhams1.00", "UAH1.00", "UAK1.00", "UAK1.00", "UGS1.00", "UGS1.00", "UGX1.00", "UM1.00", "US Dollar (Next day)1.00", "US Dollar (Same day)1.00", "US Dollar1.00", "US dollar (next day)1.00", "US dollar (same day)1.00", "US dollar1.00", "US dollars (next day)1.00", "US dollars (same day)1.00", "US dollars1.00", "USD1.00", "USN1.00", "USN1.00", "USS1.00", "USS1.00", "UYI1.00", "UYI1.00", "UYP1.00", "UYP1.00", "UYU1.00", "UZS1.00", "UZS1.00", "Ugandan Shilling (1966-1987)1.00", "Ugandan Shilling1.00", "Ugandan shilling (1966-1987)1.00", "Ugandan shilling1.00", "Ugandan shillings (1966-1987)1.00", "Ugandan shillings1.00", "Ukrainian Hryvnia1.00", "Ukrainian Karbovanets1.00", "Ukrainian hryvnia1.00", "Ukrainian hryvnias1.00", "Ukrainian karbovanets1.00", "Ukrainian karbovantsiv1.00", "Colombian Real Value Unit1.00", "United Arab Emirates Dirham1.00", "Unknown Currency1.00", "$U1.00", "Uruguayan Peso (1975-1993)1.00", "Uruguayan Peso1.00", "Uruguayan Peso (Indexed Units)1.00", "Uruguayan peso (1975-1993)1.00", "Uruguayan peso (indexed units)1.00", "Uruguayan peso1.00", "Uruguayan pesos (1975-1993)1.00", "Uruguayan pesos (indexed units)1.00", "Uruguayan pesos1.00", "Uzbekistan Som1.00", "Uzbekistan som1.00", "Uzbekistan som1.00", "VEB1.00", "VEF1.00", "VND1.00", "VT1.00", "VUV1.00", "Vanuatu Vatu1.00", "Vanuatu vatu1.00", "Vanuatu vatus1.00", "Venezuelan Bol\\u00edvar1.00", "Venezuelan Bol\\u00edvar (1871-2008)1.00", "Venezuelan bol\\u00edvar1.00", "Venezuelan bol\\u00edvars1.00", "Venezuelan bol\\u00edvar (1871-2008)1.00", "Venezuelan bol\\u00edvars (1871-2008)1.00", "Vietnamese Dong1.00", "Vietnamese dong1.00", "Vietnamese dong1.00", "WIR Euro1.00", "WIR Franc1.00", "WIR euro1.00", "WIR euros1.00", "WIR franc1.00", "WIR francs1.00", "WST1.00", "WST1.00", "Samoan Tala1.00", "Samoan tala1.00", "Samoan tala1.00", "XAF1.00", "XAF1.00", "XAG1.00", "XAG1.00", "XAU1.00", "XAU1.00", "XBA1.00", "XBA1.00", "XBB1.00", "XBB1.00", "XBC1.00", "XBC1.00", "XBD1.00", "XBD1.00", "XCD1.00", "XDR1.00", "XDR1.00", "XEU1.00", "XEU1.00", "XFO1.00", "XFO1.00", "XFU1.00", "XFU1.00", "XOF1.00", "XOF1.00", "XPD1.00", "XPD1.00", "XPF1.00", "XPT1.00", "XPT1.00", "XRE1.00", "XRE1.00", "XTS1.00", "XTS1.00", "XXX1.00", "XXX1.00", "YDD1.00", "YDD1.00", "YER1.00", "YUD1.00", "YUD1.00", "YUM1.00", "YUM1.00", "YUN1.00", "YUN1.00", "Yemeni Dinar1.00", "Yemeni Rial1.00", "Yemeni dinar1.00", "Yemeni dinars1.00", "Yemeni rial1.00", "Yemeni rials1.00", "Yugoslavian Convertible Dinar (1990-1992)1.00", "Yugoslavian Hard Dinar (1966-1990)1.00", "Yugoslavian New Dinar (1994-2002)1.00", "Yugoslavian convertible dinar (1990-1992)1.00", "Yugoslavian convertible dinars (1990-1992)1.00", "Yugoslavian hard dinar (1966-1990)1.00", "Yugoslavian hard dinars (1966-1990)1.00", "Yugoslavian new dinar (1994-2002)1.00", "Yugoslavian new dinars (1994-2002)1.00", "Z$1.00", "ZAL1.00", "ZAL1.00", "ZAR1.00", "ZMK1.00", "ZMK1.00", "ZRN1.00", "ZRN1.00", "ZRZ1.00", "ZRZ1.00", "ZWD1.00", "Zairean New Zaire (1993-1998)1.00", "Zairean Zaire (1971-1993)1.00", "Zairean new zaire (1993-1998)1.00", "Zairean new zaires (1993-1998)1.00", "Zairean zaire (1971-1993)1.00", "Zairean zaires (1971-1993)1.00", "Zambian Kwacha1.00", "Zambian kwacha1.00", "Zambian kwachas1.00", "Zimbabwean Dollar (1980-2008)1.00", "Zimbabwean dollar (1980-2008)1.00", "Zimbabwean dollars (1980-2008)1.00", "euro1.00", "euros1.00", "man.1.00", "Turkish lira (1922-2005)1.00", "special drawing rights1.00", "Colombian real value unit1.00", "Colombian real value units1.00", "unknown/invalid currency1.00", "z\\u01421.00", "\\u00a31.00", "CY\\u00a31.00", "\\u00a51.00", "\\u0e3f1.00", "\\u20ab1.00", "\\u20a11.00", "Pts1.00", "\\u20aa1.00", "\\u20ac1.00", "Rs1.00", "\\u20a61.00", "\\u20ae1.00", "IT\\u20a41.00", // for GHS // for PHP // for PYG // for UAH // // Following has extra text, should be parsed correctly too "$1.00 random", "USD1.00 random", "1.00 US dollar random", "1.00 US dollars random", "1.00 Afghan Afghani random", "1.00 Afghan Afghani random", "1.00 Afghan Afghanis (AFA) random", "1.00 Afghan Afghanis random", "1.00 Albanian Lek random", "1.00 Albanian lek random", "1.00 Albanian lek\\u00eb random", "1.00 Algerian Dinar random", "1.00 Algerian dinar random", "1.00 Algerian dinars random", "1.00 Andorran Peseta random", "1.00 Andorran peseta random", "1.00 Andorran pesetas random", "1.00 Angolan Kwanza (1977-1990) random", "1.00 Angolan Readjusted Kwanza (1995-1999) random", "1.00 Angolan Kwanza random", "1.00 Angolan New Kwanza (1990-2000) random", "1.00 Angolan kwanza (1977-1991) random", "1.00 Angolan readjusted kwanza (1995-1999) random", "1.00 Angolan kwanza random", "1.00 Angolan kwanzas (1977-1991) random", "1.00 Angolan readjusted kwanzas (1995-1999) random", "1.00 Angolan kwanzas random", "1.00 Angolan new kwanza (1990-2000) random", "1.00 Angolan new kwanzas (1990-2000) random", "1.00 Argentine Austral random", "1.00 Argentine Peso (1983-1985) random", "1.00 Argentine Peso random", "1.00 Argentine austral random", "1.00 Argentine australs random", "1.00 Argentine peso (1983-1985) random", "1.00 Argentine peso random", "1.00 Argentine pesos (1983-1985) random", "1.00 Argentine pesos random", "1.00 Armenian Dram random", "1.00 Armenian dram random", "1.00 Armenian drams random", "1.00 Aruban Florin random", "1.00 Aruban florin random", "1.00 Australian Dollar random", "1.00 Australian dollar random", "1.00 Australian dollars random", "1.00 Austrian Schilling random", "1.00 Austrian schilling random", "1.00 Austrian schillings random", "1.00 Azerbaijani Manat (1993-2006) random", "1.00 Azerbaijani Manat random", "1.00 Azerbaijani manat (1993-2006) random", "1.00 Azerbaijani manat random", "1.00 Azerbaijani manats (1993-2006) random", "1.00 Azerbaijani manats random", "1.00 Bahamian Dollar random", "1.00 Bahamian dollar random", "1.00 Bahamian dollars random", "1.00 Bahraini Dinar random", "1.00 Bahraini dinar random", "1.00 Bahraini dinars random", "1.00 Bangladeshi Taka random", "1.00 Bangladeshi taka random", "1.00 Bangladeshi takas random", "1.00 Barbadian Dollar random", "1.00 Barbadian dollar random", "1.00 Barbadian dollars random", "1.00 Belarusian New Ruble (1994-1999) random", "1.00 Belarusian Ruble random", "1.00 Belarusian new ruble (1994-1999) random", "1.00 Belarusian new rubles (1994-1999) random", "1.00 Belarusian ruble random", "1.00 Belarusian rubles random", "1.00 Belgian Franc (convertible) random", "1.00 Belgian Franc (financial) random", "1.00 Belgian Franc random", "1.00 Belgian franc (convertible) random", "1.00 Belgian franc (financial) random", "1.00 Belgian franc random", "1.00 Belgian francs (convertible) random", "1.00 Belgian francs (financial) random", "1.00 Belgian francs random", "1.00 Belize Dollar random", "1.00 Belize dollar random", "1.00 Belize dollars random", "1.00 Bermudan Dollar random", "1.00 Bermudan dollar random", "1.00 Bermudan dollars random", "1.00 Bhutanese Ngultrum random", "1.00 Bhutanese ngultrum random", "1.00 Bhutanese ngultrums random", "1.00 Bolivian Mvdol random", "1.00 Bolivian Peso random", "1.00 Bolivian mvdol random", "1.00 Bolivian mvdols random", "1.00 Bolivian peso random", "1.00 Bolivian pesos random", "1.00 Bolivian Boliviano random", "1.00 Bolivian Boliviano random", "1.00 Bolivian Bolivianos random", "1.00 Bosnia-Herzegovina Convertible Mark random", "1.00 Bosnia-Herzegovina Dinar (1992-1994) random", "1.00 Bosnia-Herzegovina convertible mark random", "1.00 Bosnia-Herzegovina convertible marks random", "1.00 Bosnia-Herzegovina dinar (1992-1994) random", "1.00 Bosnia-Herzegovina dinars (1992-1994) random", "1.00 Botswanan Pula random", "1.00 Botswanan pula random", "1.00 Botswanan pulas random", "1.00 Brazilian New Cruzado (1989-1990) random", "1.00 Brazilian Cruzado (1986-1989) random", "1.00 Brazilian Cruzeiro (1990-1993) random", "1.00 Brazilian New Cruzeiro (1967-1986) random", "1.00 Brazilian Cruzeiro (1993-1994) random", "1.00 Brazilian Real random", "1.00 Brazilian new cruzado (1989-1990) random", "1.00 Brazilian new cruzados (1989-1990) random", "1.00 Brazilian cruzado (1986-1989) random", "1.00 Brazilian cruzados (1986-1989) random", "1.00 Brazilian cruzeiro (1990-1993) random", "1.00 Brazilian new cruzeiro (1967-1986) random", "1.00 Brazilian cruzeiro (1993-1994) random", "1.00 Brazilian cruzeiros (1990-1993) random", "1.00 Brazilian new cruzeiros (1967-1986) random", "1.00 Brazilian cruzeiros (1993-1994) random", "1.00 Brazilian real random", "1.00 Brazilian reals random", "1.00 British Pound Sterling random", "1.00 British pound sterling random", "1.00 British pounds sterling random", "1.00 Brunei Dollar random", "1.00 Brunei dollar random", "1.00 Brunei dollars random", "1.00 Bulgarian Hard Lev random", "1.00 Bulgarian Lev random", "1.00 Bulgarian Leva random", "1.00 Bulgarian hard lev random", "1.00 Bulgarian hard leva random", "1.00 Bulgarian lev random", "1.00 Burmese Kyat random", "1.00 Burmese kyat random", "1.00 Burmese kyats random", "1.00 Burundian Franc random", "1.00 Burundian franc random", "1.00 Burundian francs random", "1.00 Cambodian Riel random", "1.00 Cambodian riel random", "1.00 Cambodian riels random", "1.00 Canadian Dollar random", "1.00 Canadian dollar random", "1.00 Canadian dollars random", "1.00 Cape Verdean Escudo random", "1.00 Cape Verdean escudo random", "1.00 Cape Verdean escudos random", "1.00 Cayman Islands Dollar random", "1.00 Cayman Islands dollar random", "1.00 Cayman Islands dollars random", "1.00 Chilean Peso random", "1.00 Chilean Unit of Account (UF) random", "1.00 Chilean peso random", "1.00 Chilean pesos random", "1.00 Chilean unit of account (UF) random", "1.00 Chilean units of account (UF) random", "1.00 Chinese Yuan random", "1.00 Chinese yuan random", "1.00 Colombian Peso random", "1.00 Colombian peso random", "1.00 Colombian pesos random", "1.00 Comorian Franc random", "1.00 Comorian franc random", "1.00 Comorian francs random", "1.00 Congolese Franc Congolais random", "1.00 Congolese franc Congolais random", "1.00 Congolese francs Congolais random", "1.00 Costa Rican Col\\u00f3n random", "1.00 Costa Rican col\\u00f3n random", "1.00 Costa Rican col\\u00f3ns random", "1.00 Croatian Dinar random", "1.00 Croatian Kuna random", "1.00 Croatian dinar random", "1.00 Croatian dinars random", "1.00 Croatian kuna random", "1.00 Croatian kunas random", "1.00 Cuban Peso random", "1.00 Cuban peso random", "1.00 Cuban pesos random", "1.00 Cypriot Pound random", "1.00 Cypriot pound random", "1.00 Cypriot pounds random", "1.00 Czech Republic Koruna random", "1.00 Czech Republic koruna random", "1.00 Czech Republic korunas random", "1.00 Czechoslovak Hard Koruna random", "1.00 Czechoslovak hard koruna random", "1.00 Czechoslovak hard korunas random", "1.00 Danish Krone random", "1.00 Danish krone random", "1.00 Danish kroner random", "1.00 German Mark random", "1.00 German mark random", "1.00 German marks random", "1.00 Djiboutian Franc random", "1.00 Djiboutian franc random", "1.00 Djiboutian francs random", "1.00 Dominican Peso random", "1.00 Dominican peso random", "1.00 Dominican pesos random", "1.00 East Caribbean Dollar random", "1.00 East Caribbean dollar random", "1.00 East Caribbean dollars random", "1.00 East German Mark random", "1.00 East German mark random", "1.00 East German marks random", "1.00 Ecuadorian Sucre random", "1.00 Ecuadorian Unit of Constant Value random", "1.00 Ecuadorian sucre random", "1.00 Ecuadorian sucres random", "1.00 Ecuadorian unit of constant value random", "1.00 Ecuadorian units of constant value random", "1.00 Egyptian Pound random", "1.00 Egyptian pound random", "1.00 Egyptian pounds random", "1.00 Salvadoran Col\\u00f3n random", "1.00 Salvadoran col\\u00f3n random", "1.00 Salvadoran colones random", "1.00 Equatorial Guinean Ekwele random", "1.00 Equatorial Guinean ekwele random", "1.00 Eritrean Nakfa random", "1.00 Eritrean nakfa random", "1.00 Eritrean nakfas random", "1.00 Estonian Kroon random", "1.00 Estonian kroon random", "1.00 Estonian kroons random", "1.00 Ethiopian Birr random", "1.00 Ethiopian birr random", "1.00 Ethiopian birrs random", "1.00 European Composite Unit random", "1.00 European Currency Unit random", "1.00 European Monetary Unit random", "1.00 European Unit of Account (XBC) random", "1.00 European Unit of Account (XBD) random", "1.00 European composite unit random", "1.00 European composite units random", "1.00 European currency unit random", "1.00 European currency units random", "1.00 European monetary unit random", "1.00 European monetary units random", "1.00 European unit of account (XBC) random", "1.00 European unit of account (XBD) random", "1.00 European units of account (XBC) random", "1.00 European units of account (XBD) random", "1.00 Falkland Islands Pound random", "1.00 Falkland Islands pound random", "1.00 Falkland Islands pounds random", "1.00 Fijian Dollar random", "1.00 Fijian dollar random", "1.00 Fijian dollars random", "1.00 Finnish Markka random", "1.00 Finnish markka random", "1.00 Finnish markkas random", "1.00 French Franc random", "1.00 French Gold Franc random", "1.00 French UIC-Franc random", "1.00 French UIC-franc random", "1.00 French UIC-francs random", "1.00 French franc random", "1.00 French francs random", "1.00 French gold franc random", "1.00 French gold francs random", "1.00 Gambian Dalasi random", "1.00 Gambian dalasi random", "1.00 Gambian dalasis random", "1.00 Georgian Kupon Larit random", "1.00 Georgian Lari random", "1.00 Georgian kupon larit random", "1.00 Georgian kupon larits random", "1.00 Georgian lari random", "1.00 Georgian laris random", "1.00 Ghanaian Cedi (1979-2007) random", "1.00 Ghanaian Cedi random", "1.00 Ghanaian cedi (1979-2007) random", "1.00 Ghanaian cedi random", "1.00 Ghanaian cedis (1979-2007) random", "1.00 Ghanaian cedis random", "1.00 Gibraltar Pound random", "1.00 Gibraltar pound random", "1.00 Gibraltar pounds random", "1.00 Gold random", "1.00 Gold random", "1.00 Greek Drachma random", "1.00 Greek drachma random", "1.00 Greek drachmas random", "1.00 Guatemalan Quetzal random", "1.00 Guatemalan quetzal random", "1.00 Guatemalan quetzals random", "1.00 Guinean Franc random", "1.00 Guinean Syli random", "1.00 Guinean franc random", "1.00 Guinean francs random", "1.00 Guinean syli random", "1.00 Guinean sylis random", "1.00 Guinea-Bissau Peso random", "1.00 Guinea-Bissau peso random", "1.00 Guinea-Bissau pesos random", "1.00 Guyanaese Dollar random", "1.00 Guyanaese dollar random", "1.00 Guyanaese dollars random", "1.00 Haitian Gourde random", "1.00 Haitian gourde random", "1.00 Haitian gourdes random", "1.00 Honduran Lempira random", "1.00 Honduran lempira random", "1.00 Honduran lempiras random", "1.00 Hong Kong Dollar random", "1.00 Hong Kong dollar random", "1.00 Hong Kong dollars random", "1.00 Hungarian Forint random", "1.00 Hungarian forint random", "1.00 Hungarian forints random", "1.00 Icelandic Kr\\u00f3na random", "1.00 Icelandic kr\\u00f3na random", "1.00 Icelandic kr\\u00f3nur random", "1.00 Indian Rupee random", "1.00 Indian rupee random", "1.00 Indian rupees random", "1.00 Indonesian Rupiah random", "1.00 Indonesian rupiah random", "1.00 Indonesian rupiahs random", "1.00 Iranian Rial random", "1.00 Iranian rial random", "1.00 Iranian rials random", "1.00 Iraqi Dinar random", "1.00 Iraqi dinar random", "1.00 Iraqi dinars random", "1.00 Irish Pound random", "1.00 Irish pound random", "1.00 Irish pounds random", "1.00 Israeli Pound random", "1.00 Israeli new sheqel random", "1.00 Israeli pound random", "1.00 Israeli pounds random", "1.00 Italian Lira random", "1.00 Italian lira random", "1.00 Italian liras random", "1.00 Jamaican Dollar random", "1.00 Jamaican dollar random", "1.00 Jamaican dollars random", "1.00 Japanese Yen random", "1.00 Japanese yen random", "1.00 Jordanian Dinar random", "1.00 Jordanian dinar random", "1.00 Jordanian dinars random", "1.00 Kazakhstani Tenge random", "1.00 Kazakhstani tenge random", "1.00 Kazakhstani tenges random", "1.00 Kenyan Shilling random", "1.00 Kenyan shilling random", "1.00 Kenyan shillings random", "1.00 Kuwaiti Dinar random", "1.00 Kuwaiti dinar random", "1.00 Kuwaiti dinars random", "1.00 Kyrgystani Som random", "1.00 Kyrgystani som random", "1.00 Kyrgystani soms random", "1.00 Laotian Kip random", "1.00 Laotian kip random", "1.00 Laotian kips random", "1.00 Latvian Lats random", "1.00 Latvian Ruble random", "1.00 Latvian lats random", "1.00 Latvian lati random", "1.00 Latvian ruble random", "1.00 Latvian rubles random", "1.00 Lebanese Pound random", "1.00 Lebanese pound random", "1.00 Lebanese pounds random", "1.00 Lesotho Loti random", "1.00 Lesotho loti random", "1.00 Lesotho lotis random", "1.00 Liberian Dollar random", "1.00 Liberian dollar random", "1.00 Liberian dollars random", "1.00 Libyan Dinar random", "1.00 Libyan dinar random", "1.00 Libyan dinars random", "1.00 Lithuanian Litas random", "1.00 Lithuanian Talonas random", "1.00 Lithuanian litas random", "1.00 Lithuanian litai random", "1.00 Lithuanian talonas random", "1.00 Lithuanian talonases random", "1.00 Luxembourgian Convertible Franc random", "1.00 Luxembourg Financial Franc random", "1.00 Luxembourgian Franc random", "1.00 Luxembourgian convertible franc random", "1.00 Luxembourgian convertible francs random", "1.00 Luxembourg financial franc random", "1.00 Luxembourg financial francs random", "1.00 Luxembourgian franc random", "1.00 Luxembourgian francs random", "1.00 Macanese Pataca random", "1.00 Macanese pataca random", "1.00 Macanese patacas random", "1.00 Macedonian Denar random", "1.00 Macedonian denar random", "1.00 Macedonian denari random", "1.00 Malagasy Ariaries random", "1.00 Malagasy Ariary random", "1.00 Malagasy Ariary random", "1.00 Malagasy Franc random", "1.00 Malagasy franc random", "1.00 Malagasy francs random", "1.00 Malawian Kwacha random", "1.00 Malawian Kwacha random", "1.00 Malawian Kwachas random", "1.00 Malaysian Ringgit random", "1.00 Malaysian ringgit random", "1.00 Malaysian ringgits random", "1.00 Maldivian Rufiyaa random", "1.00 Maldivian rufiyaa random", "1.00 Maldivian rufiyaas random", "1.00 Malian Franc random", "1.00 Malian franc random", "1.00 Malian francs random", "1.00 Maltese Lira random", "1.00 Maltese Pound random", "1.00 Maltese lira random", "1.00 Maltese liras random", "1.00 Maltese pound random", "1.00 Maltese pounds random", "1.00 Mauritanian Ouguiya random", "1.00 Mauritanian ouguiya random", "1.00 Mauritanian ouguiyas random", "1.00 Mauritian Rupee random", "1.00 Mauritian rupee random", "1.00 Mauritian rupees random", "1.00 Mexican Peso random", "1.00 Mexican Silver Peso (1861-1992) random", "1.00 Mexican Investment Unit random", "1.00 Mexican peso random", "1.00 Mexican pesos random", "1.00 Mexican silver peso (1861-1992) random", "1.00 Mexican silver pesos (1861-1992) random", "1.00 Mexican investment unit random", "1.00 Mexican investment units random", "1.00 Moldovan Leu random", "1.00 Moldovan leu random", "1.00 Moldovan lei random", "1.00 Mongolian Tugrik random", "1.00 Mongolian tugrik random", "1.00 Mongolian tugriks random", "1.00 Moroccan Dirham random", "1.00 Moroccan Franc random", "1.00 Moroccan dirham random", "1.00 Moroccan dirhams random", "1.00 Moroccan franc random", "1.00 Moroccan francs random", "1.00 Mozambican Escudo random", "1.00 Mozambican Metical random", "1.00 Mozambican escudo random", "1.00 Mozambican escudos random", "1.00 Mozambican metical random", "1.00 Mozambican meticals random", "1.00 Myanma Kyat random", "1.00 Myanma kyat random", "1.00 Myanma kyats random", "1.00 Namibian Dollar random", "1.00 Namibian dollar random", "1.00 Namibian dollars random", "1.00 Nepalese Rupee random", "1.00 Nepalese rupee random", "1.00 Nepalese rupees random", "1.00 Netherlands Antillean Guilder random", "1.00 Netherlands Antillean guilder random", "1.00 Netherlands Antillean guilders random", "1.00 Dutch Guilder random", "1.00 Dutch guilder random", "1.00 Dutch guilders random", "1.00 Israeli New Sheqel random", "1.00 Israeli new sheqels random", "1.00 New Zealand Dollar random", "1.00 New Zealand dollar random", "1.00 New Zealand dollars random", "1.00 Nicaraguan C\\u00f3rdoba random", "1.00 Nicaraguan C\\u00f3rdoba (1988-1991) random", "1.00 Nicaraguan c\\u00f3rdoba random", "1.00 Nicaraguan c\\u00f3rdoba random", "1.00 Nicaraguan c\\u00f3rdoba (1988-1991) random", "1.00 Nicaraguan c\\u00f3rdobas (1988-1991) random", "1.00 Nigerian Naira random", "1.00 Nigerian naira random", "1.00 Nigerian nairas random", "1.00 North Korean Won random", "1.00 North Korean won random", "1.00 North Korean won random", "1.00 Norwegian Krone random", "1.00 Norwegian krone random", "1.00 Norwegian kroner random", "1.00 Mozambican Metical (1980-2006) random", "1.00 Mozambican metical (1980-2006) random", "1.00 Mozambican meticals (1980-2006) random", "1.00 Romanian Lei (1952-2006) random", "1.00 Romanian Leu (1952-2006) random", "1.00 Romanian leu (1952-2006) random", "1.00 Serbian Dinar (2002-2006) random", "1.00 Serbian dinar (2002-2006) random", "1.00 Serbian dinars (2002-2006) random", "1.00 Sudanese Dinar (1992-2007) random", "1.00 Sudanese Pound (1957-1998) random", "1.00 Sudanese dinar (1992-2007) random", "1.00 Sudanese dinars (1992-2007) random", "1.00 Sudanese pound (1957-1998) random", "1.00 Sudanese pounds (1957-1998) random", "1.00 Turkish Lira (1922-2005) random", "1.00 Turkish Lira (1922-2005) random", "1.00 Omani Rial random", "1.00 Omani rial random", "1.00 Omani rials random", "1.00 Pakistani Rupee random", "1.00 Pakistani rupee random", "1.00 Pakistani rupees random", "1.00 Palladium random", "1.00 Palladium random", "1.00 Panamanian Balboa random", "1.00 Panamanian balboa random", "1.00 Panamanian balboas random", "1.00 Papua New Guinean Kina random", "1.00 Papua New Guinean kina random", "1.00 Papua New Guinean kina random", "1.00 Paraguayan Guarani random", "1.00 Paraguayan guarani random", "1.00 Paraguayan guaranis random", "1.00 Peruvian Inti random", "1.00 Peruvian Nuevo Sol random", "1.00 Peruvian Sol (1863-1965) random", "1.00 Peruvian inti random", "1.00 Peruvian intis random", "1.00 Peruvian nuevo sol random", "1.00 Peruvian nuevos soles random", "1.00 Peruvian sol (1863-1965) random", "1.00 Peruvian soles (1863-1965) random", "1.00 Philippine Peso random", "1.00 Philippine peso random", "1.00 Philippine pesos random", "1.00 Platinum random", "1.00 Platinum random", "1.00 Polish Zloty (1950-1995) random", "1.00 Polish Zloty random", "1.00 Polish zlotys random", "1.00 Polish zloty (PLZ) random", "1.00 Polish zloty random", "1.00 Polish zlotys (PLZ) random", "1.00 Portuguese Escudo random", "1.00 Portuguese Guinea Escudo random", "1.00 Portuguese Guinea escudo random", "1.00 Portuguese Guinea escudos random", "1.00 Portuguese escudo random", "1.00 Portuguese escudos random", "1.00 Qatari Rial random", "1.00 Qatari rial random", "1.00 Qatari rials random", "1.00 RINET Funds random", "1.00 RINET Funds random", "1.00 Rhodesian Dollar random", "1.00 Rhodesian dollar random", "1.00 Rhodesian dollars random", "1.00 Romanian Leu random", "1.00 Romanian lei random", "1.00 Romanian leu random", "1.00 Russian Ruble (1991-1998) random", "1.00 Russian Ruble random", "1.00 Russian ruble (1991-1998) random", "1.00 Russian ruble random", "1.00 Russian rubles (1991-1998) random", "1.00 Russian rubles random", "1.00 Rwandan Franc random", "1.00 Rwandan franc random", "1.00 Rwandan francs random", "1.00 Saint Helena Pound random", "1.00 Saint Helena pound random", "1.00 Saint Helena pounds random", "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobra random", "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobra random", "1.00 S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe dobras random", "1.00 Saudi Riyal random", "1.00 Saudi riyal random", "1.00 Saudi riyals random", "1.00 Serbian Dinar random", "1.00 Serbian dinar random", "1.00 Serbian dinars random", "1.00 Seychellois Rupee random", "1.00 Seychellois rupee random", "1.00 Seychellois rupees random", "1.00 Sierra Leonean Leone random", "1.00 Sierra Leonean leone random", "1.00 Sierra Leonean leones random", "1.00 Singapore Dollar random", "1.00 Singapore dollar random", "1.00 Singapore dollars random", "1.00 Slovak Koruna random", "1.00 Slovak koruna random", "1.00 Slovak korunas random", "1.00 Slovenian Tolar random", "1.00 Slovenian tolar random", "1.00 Slovenian tolars random", "1.00 Solomon Islands Dollar random", "1.00 Solomon Islands dollar random", "1.00 Solomon Islands dollars random", "1.00 Somali Shilling random", "1.00 Somali shilling random", "1.00 Somali shillings random", "1.00 South African Rand (financial) random", "1.00 South African Rand random", "1.00 South African rand (financial) random", "1.00 South African rand random", "1.00 South African rands (financial) random", "1.00 South African rand random", "1.00 South Korean Won random", "1.00 South Korean won random", "1.00 South Korean won random", "1.00 Soviet Rouble random", "1.00 Soviet rouble random", "1.00 Soviet roubles random", "1.00 Spanish Peseta (A account) random", "1.00 Spanish Peseta (convertible account) random", "1.00 Spanish Peseta random", "1.00 Spanish peseta (A account) random", "1.00 Spanish peseta (convertible account) random", "1.00 Spanish peseta random", "1.00 Spanish pesetas (A account) random", "1.00 Spanish pesetas (convertible account) random", "1.00 Spanish pesetas random", "1.00 Special Drawing Rights random", "1.00 Sri Lankan Rupee random", "1.00 Sri Lankan rupee random", "1.00 Sri Lankan rupees random", "1.00 Sudanese Pound random", "1.00 Sudanese pound random", "1.00 Sudanese pounds random", "1.00 Surinamese Dollar random", "1.00 Surinamese dollar random", "1.00 Surinamese dollars random", "1.00 Surinamese Guilder random", "1.00 Surinamese guilder random", "1.00 Surinamese guilders random", "1.00 Swazi Lilangeni random", "1.00 Swazi lilangeni random", "1.00 Swazi emalangeni random", "1.00 Swedish Krona random", "1.00 Swedish krona random", "1.00 Swedish kronor random", "1.00 Swiss Franc random", "1.00 Swiss franc random", "1.00 Swiss francs random", "1.00 Syrian Pound random", "1.00 Syrian pound random", "1.00 Syrian pounds random", "1.00 New Taiwan Dollar random", "1.00 New Taiwan dollar random", "1.00 New Taiwan dollars random", "1.00 Tajikistani Ruble random", "1.00 Tajikistani Somoni random", "1.00 Tajikistani ruble random", "1.00 Tajikistani rubles random", "1.00 Tajikistani somoni random", "1.00 Tajikistani somonis random", "1.00 Tanzanian Shilling random", "1.00 Tanzanian shilling random", "1.00 Tanzanian shillings random", "1.00 Testing Currency Code random", "1.00 Testing Currency Code random", "1.00 Thai Baht random", "1.00 Thai baht random", "1.00 Thai baht random", "1.00 Timorese Escudo random", "1.00 Timorese escudo random", "1.00 Timorese escudos random", "1.00 Trinidad and Tobago Dollar random", "1.00 Trinidad and Tobago dollar random", "1.00 Trinidad and Tobago dollars random", "1.00 Tunisian Dinar random", "1.00 Tunisian dinar random", "1.00 Tunisian dinars random", "1.00 Turkish Lira random", "1.00 Turkish Lira random", "1.00 Turkish lira random", "1.00 Turkmenistani Manat random", "1.00 Turkmenistani manat random", "1.00 Turkmenistani manat random", "1.00 US Dollar (Next day) random", "1.00 US Dollar (Same day) random", "1.00 US Dollar random", "1.00 US dollar (next day) random", "1.00 US dollar (same day) random", "1.00 US dollar random", "1.00 US dollars (next day) random", "1.00 US dollars (same day) random", "1.00 US dollars random", "1.00 Ugandan Shilling (1966-1987) random", "1.00 Ugandan Shilling random", "1.00 Ugandan shilling (1966-1987) random", "1.00 Ugandan shilling random", "1.00 Ugandan shillings (1966-1987) random", "1.00 Ugandan shillings random", "1.00 Ukrainian Hryvnia random", "1.00 Ukrainian Karbovanets random", "1.00 Ukrainian hryvnia random", "1.00 Ukrainian hryvnias random", "1.00 Ukrainian karbovanets random", "1.00 Ukrainian karbovantsiv random", "1.00 Colombian Real Value Unit random", "1.00 United Arab Emirates Dirham random", "1.00 Unknown Currency random", "1.00 Uruguayan Peso (1975-1993) random", "1.00 Uruguayan Peso random", "1.00 Uruguayan Peso (Indexed Units) random", "1.00 Uruguayan peso (1975-1993) random", "1.00 Uruguayan peso (indexed units) random", "1.00 Uruguayan peso random", "1.00 Uruguayan pesos (1975-1993) random", "1.00 Uruguayan pesos (indexed units) random", "1.00 Uzbekistan Som random", "1.00 Uzbekistan som random", "1.00 Uzbekistan som random", "1.00 Vanuatu Vatu random", "1.00 Vanuatu vatu random", "1.00 Vanuatu vatus random", "1.00 Venezuelan Bol\\u00edvar random", "1.00 Venezuelan Bol\\u00edvar (1871-2008) random", "1.00 Venezuelan bol\\u00edvar random", "1.00 Venezuelan bol\\u00edvars random", "1.00 Venezuelan bol\\u00edvar (1871-2008) random", "1.00 Venezuelan bol\\u00edvars (1871-2008) random", "1.00 Vietnamese Dong random", "1.00 Vietnamese dong random", "1.00 Vietnamese dong random", "1.00 WIR Euro random", "1.00 WIR Franc random", "1.00 WIR euro random", "1.00 WIR euros random", "1.00 WIR franc random", "1.00 WIR francs random", "1.00 Samoan Tala random", "1.00 Samoan tala random", "1.00 Samoan tala random", "1.00 Yemeni Dinar random", "1.00 Yemeni Rial random", "1.00 Yemeni dinar random", "1.00 Yemeni dinars random", "1.00 Yemeni rial random", "1.00 Yemeni rials random", "1.00 Yugoslavian Convertible Dinar (1990-1992) random", "1.00 Yugoslavian Hard Dinar (1966-1990) random", "1.00 Yugoslavian New Dinar (1994-2002) random", "1.00 Yugoslavian convertible dinar (1990-1992) random", "1.00 Yugoslavian convertible dinars (1990-1992) random", "1.00 Yugoslavian hard dinar (1966-1990) random", "1.00 Yugoslavian hard dinars (1966-1990) random", "1.00 Yugoslavian new dinar (1994-2002) random", "1.00 Yugoslavian new dinars (1994-2002) random", "1.00 Zairean New Zaire (1993-1998) random", "1.00 Zairean Zaire (1971-1993) random", "1.00 Zairean new zaire (1993-1998) random", "1.00 Zairean new zaires (1993-1998) random", "1.00 Zairean zaire (1971-1993) random", "1.00 Zairean zaires (1971-1993) random", "1.00 Zambian Kwacha random", "1.00 Zambian kwacha random", "1.00 Zambian kwachas random", "1.00 Zimbabwean Dollar (1980-2008) random", "1.00 Zimbabwean dollar (1980-2008) random", "1.00 Zimbabwean dollars (1980-2008) random", "1.00 euro random", "1.00 euros random", "1.00 Turkish lira (1922-2005) random", "1.00 special drawing rights random", "1.00 Colombian real value unit random", "1.00 Colombian real value units random", "1.00 unknown/invalid currency random", }; const char* WRONG_DATA[] = { // Following are missing one last char in the currency name "usd1.00", // case sensitive "1.00 Nicaraguan Cordob", "1.00 Namibian Dolla", "1.00 Namibian dolla", "1.00 Nepalese Rupe", "1.00 Nepalese rupe", "1.00 Netherlands Antillean Guilde", "1.00 Netherlands Antillean guilde", "1.00 Dutch Guilde", "1.00 Dutch guilde", "1.00 Israeli New Sheqe", "1.00 New Zealand Dolla", "1.00 New Zealand dolla", "1.00 Nicaraguan cordob", "1.00 Nigerian Nair", "1.00 Nigerian nair", "1.00 North Korean Wo", "1.00 North Korean wo", "1.00 Norwegian Kron", "1.00 Norwegian kron", "1.00 US dolla", "1.00", "A1.00", "AD1.00", "AE1.00", "AF1.00", "AL1.00", "AM1.00", "AN1.00", "AO1.00", "AR1.00", "AT1.00", "AU1.00", "AW1.00", "AZ1.00", "Afghan Afghan1.00", "Afghan Afghani (1927-20021.00", "Afl1.00", "Albanian Le1.00", "Algerian Dina1.00", "Andorran Peset1.00", "Angolan Kwanz1.00", "Angolan Kwanza (1977-19901.00", "Angolan Readjusted Kwanza (1995-19991.00", "Angolan New Kwanza (1990-20001.00", "Argentine Austra1.00", "Argentine Pes1.00", "Argentine Peso (1983-19851.00", "Armenian Dra1.00", "Aruban Flori1.00", "Australian Dolla1.00", "Austrian Schillin1.00", "Azerbaijani Mana1.00", "Azerbaijani Manat (1993-20061.00", "B1.00", "BA1.00", "BB1.00", "BE1.00", "BG1.00", "BH1.00", "BI1.00", "BM1.00", "BN1.00", "BO1.00", "BR1.00", "BS1.00", "BT1.00", "BU1.00", "BW1.00", "BY1.00", "BZ1.00", "Bahamian Dolla1.00", "Bahraini Dina1.00", "Bangladeshi Tak1.00", "Barbadian Dolla1.00", "Bds1.00", "Belarusian New Ruble (1994-19991.00", "Belarusian Rubl1.00", "Belgian Fran1.00", "Belgian Franc (convertible1.00", "Belgian Franc (financial1.00", "Belize Dolla1.00", "Bermudan Dolla1.00", "Bhutanese Ngultru1.00", "Bolivian Mvdo1.00", "Bolivian Pes1.00", "Bolivian Bolivian1.00", "Bosnia-Herzegovina Convertible Mar1.00", "Bosnia-Herzegovina Dina1.00", "Botswanan Pul1.00", "Brazilian Cruzad1.00", "Brazilian Cruzado Nov1.00", "Brazilian Cruzeir1.00", "Brazilian Cruzeiro (1990-19931.00", "Brazilian New Cruzeiro (1967-19861.00", "Brazilian Rea1.00", "British Pound Sterlin1.00", "Brunei Dolla1.00", "Bulgarian Hard Le1.00", "Bulgarian Le1.00", "Burmese Kya1.00", "Burundian Fran1.00", "C1.00", "CA1.00", "CD1.00", "CFA Franc BCEA1.00", "CFA Franc BEA1.00", "CFP Fran1.00", "CFP1.00", "CH1.00", "CL1.00", "CN1.00", "CO1.00", "CS1.00", "CU1.00", "CV1.00", "CY1.00", "CZ1.00", "Cambodian Rie1.00", "Canadian Dolla1.00", "Cape Verdean Escud1.00", "Cayman Islands Dolla1.00", "Chilean Pes1.00", "Chilean Unit of Accoun1.00", "Chinese Yua1.00", "Colombian Pes1.00", "Comoro Fran1.00", "Congolese Fran1.00", "Costa Rican Col\\u00f31.00", "Croatian Dina1.00", "Croatian Kun1.00", "Cuban Pes1.00", "Cypriot Poun1.00", "Czech Republic Korun1.00", "Czechoslovak Hard Korun1.00", "D1.00", "DD1.00", "DE1.00", "DJ1.00", "DK1.00", "DO1.00", "DZ1.00", "Danish Kron1.00", "German Mar1.00", "Djiboutian Fran1.00", "Dk1.00", "Dominican Pes1.00", "EC1.00", "EE1.00", "EG1.00", "EQ1.00", "ER1.00", "ES1.00", "ET1.00", "EU1.00", "East Caribbean Dolla1.00", "East German Ostmar1.00", "Ecuadorian Sucr1.00", "Ecuadorian Unit of Constant Valu1.00", "Egyptian Poun1.00", "Ekwel1.00", "Salvadoran Col\\u00f31.00", "Equatorial Guinean Ekwel1.00", "Eritrean Nakf1.00", "Es1.00", "Estonian Kroo1.00", "Ethiopian Bir1.00", "Eur1.00", "European Composite Uni1.00", "European Currency Uni1.00", "European Monetary Uni1.00", "European Unit of Account (XBC1.00", "European Unit of Account (XBD1.00", "F1.00", "FB1.00", "FI1.00", "FJ1.00", "FK1.00", "FR1.00", "Falkland Islands Poun1.00", "Fd1.00", "Fijian Dolla1.00", "Finnish Markk1.00", "Fr1.00", "French Fran1.00", "French Gold Fran1.00", "French UIC-Fran1.00", "G1.00", "GB1.00", "GE1.00", "GH1.00", "GI1.00", "GM1.00", "GN1.00", "GQ1.00", "GR1.00", "GT1.00", "GW1.00", "GY1.00", "Gambian Dalas1.00", "Georgian Kupon Lari1.00", "Georgian Lar1.00", "Ghanaian Ced1.00", "Ghanaian Cedi (1979-20071.00", "Gibraltar Poun1.00", "Gol1.00", "Greek Drachm1.00", "Guatemalan Quetza1.00", "Guinean Fran1.00", "Guinean Syl1.00", "Guinea-Bissau Pes1.00", "Guyanaese Dolla1.00", "HK1.00", "HN1.00", "HR1.00", "HT1.00", "HU1.00", "Haitian Gourd1.00", "Honduran Lempir1.00", "Hong Kong Dolla1.00", "Hungarian Forin1.00", "I1.00", "IE1.00", "IL1.00", "IN1.00", "IQ1.00", "IR1.00", "IS1.00", "IT1.00", "Icelandic Kron1.00", "Indian Rupe1.00", "Indonesian Rupia1.00", "Iranian Ria1.00", "Iraqi Dina1.00", "Irish Poun1.00", "Israeli Poun1.00", "Italian Lir1.00", "J1.00", "JM1.00", "JO1.00", "JP1.00", "Jamaican Dolla1.00", "Japanese Ye1.00", "Jordanian Dina1.00", "K S1.00", "K1.00", "KE1.00", "KG1.00", "KH1.00", "KP1.00", "KR1.00", "KW1.00", "KY1.00", "KZ1.00", "Kazakhstani Teng1.00", "Kenyan Shillin1.00", "Kuwaiti Dina1.00", "Kyrgystani So1.00", "LA1.00", "LB1.00", "LK1.00", "LR1.00", "LT1.00", "LU1.00", "LV1.00", "LY1.00", "Laotian Ki1.00", "Latvian Lat1.00", "Latvian Rubl1.00", "Lebanese Poun1.00", "Lesotho Lot1.00", "Liberian Dolla1.00", "Libyan Dina1.00", "Lithuanian Lit1.00", "Lithuanian Talona1.00", "Luxembourgian Convertible Fran1.00", "Luxembourg Financial Fran1.00", "Luxembourgian Fran1.00", "MA1.00", "MD1.00", "MDe1.00", "MEX1.00", "MG1.00", "ML1.00", "MM1.00", "MN1.00", "MO1.00", "MR1.00", "MT1.00", "MU1.00", "MV1.00", "MW1.00", "MX1.00", "MY1.00", "MZ1.00", "Macanese Patac1.00", "Macedonian Dena1.00", "Malagasy Ariar1.00", "Malagasy Fran1.00", "Malawian Kwach1.00", "Malaysian Ringgi1.00", "Maldivian Rufiya1.00", "Malian Fran1.00", "Malot1.00", "Maltese Lir1.00", "Maltese Poun1.00", "Mauritanian Ouguiy1.00", "Mauritian Rupe1.00", "Mexican Pes1.00", "Mexican Silver Peso (1861-19921.00", "Mexican Investment Uni1.00", "Moldovan Le1.00", "Mongolian Tugri1.00", "Moroccan Dirha1.00", "Moroccan Fran1.00", "Mozambican Escud1.00", "Mozambican Metica1.00", "Myanma Kya1.00", "N1.00", "NA1.00", "NAf1.00", "NG1.00", "NI1.00", "NK1.00", "NL1.00", "NO1.00", "NP1.00", "NT1.00", "Namibian Dolla1.00", "Nepalese Rupe1.00", "Netherlands Antillean Guilde1.00", "Dutch Guilde1.00", "Israeli New Sheqe1.00", "New Zealand Dolla1.00", "Nicaraguan C\\u00f3rdoba (1988-19911.00", "Nicaraguan C\\u00f3rdob1.00", "Nigerian Nair1.00", "North Korean Wo1.00", "Norwegian Kron1.00", "Nr1.00", "OM1.00", "Old Mozambican Metica1.00", "Romanian Leu (1952-20061.00", "Serbian Dinar (2002-20061.00", "Sudanese Dinar (1992-20071.00", "Sudanese Pound (1957-19981.00", "Turkish Lira (1922-20051.00", "Omani Ria1.00", "PA1.00", "PE1.00", "PG1.00", "PH1.00", "PK1.00", "PL1.00", "PT1.00", "PY1.00", "Pakistani Rupe1.00", "Palladiu1.00", "Panamanian Balbo1.00", "Papua New Guinean Kin1.00", "Paraguayan Guaran1.00", "Peruvian Int1.00", "Peruvian Sol (1863-19651.00", "Peruvian Sol Nuev1.00", "Philippine Pes1.00", "Platinu1.00", "Polish Zlot1.00", "Polish Zloty (1950-19951.00", "Portuguese Escud1.00", "Portuguese Guinea Escud1.00", "Pr1.00", "QA1.00", "Qatari Ria1.00", "RD1.00", "RH1.00", "RINET Fund1.00", "RS1.00", "RU1.00", "RW1.00", "Rb1.00", "Rhodesian Dolla1.00", "Romanian Le1.00", "Russian Rubl1.00", "Russian Ruble (1991-19981.00", "Rwandan Fran1.00", "S1.00", "SA1.00", "SB1.00", "SC1.00", "SD1.00", "SE1.00", "SG1.00", "SH1.00", "SI1.00", "SK1.00", "SL R1.00", "SL1.00", "SO1.00", "ST1.00", "SU1.00", "SV1.00", "SY1.00", "SZ1.00", "Saint Helena Poun1.00", "S\\u00e3o Tom\\u00e9 and Pr\\u00edncipe Dobr1.00", "Saudi Riya1.00", "Serbian Dina1.00", "Seychellois Rupe1.00", "Sh1.00", "Sierra Leonean Leon1.00", "Silve1.00", "Singapore Dolla1.00", "Slovak Korun1.00", "Slovenian Tola1.00", "Solomon Islands Dolla1.00", "Somali Shillin1.00", "South African Ran1.00", "South African Rand (financial1.00", "South Korean Wo1.00", "Soviet Roubl1.00", "Spanish Peset1.00", "Spanish Peseta (A account1.00", "Spanish Peseta (convertible account1.00", "Special Drawing Right1.00", "Sri Lankan Rupe1.00", "Sudanese Poun1.00", "Surinamese Dolla1.00", "Surinamese Guilde1.00", "Swazi Lilangen1.00", "Swedish Kron1.00", "Swiss Fran1.00", "Syrian Poun1.00", "T S1.00", "TH1.00", "TJ1.00", "TM1.00", "TN1.00", "TO1.00", "TP1.00", "TR1.00", "TT1.00", "TW1.00", "TZ1.00", "New Taiwan Dolla1.00", "Tajikistani Rubl1.00", "Tajikistani Somon1.00", "Tanzanian Shillin1.00", "Testing Currency Cod1.00", "Thai Bah1.00", "Timorese Escud1.00", "Tongan Pa\\u20bbang1.00", "Trinidad and Tobago Dolla1.00", "Tunisian Dina1.00", "Turkish Lir1.00", "Turkmenistani Mana1.00", "U S1.00", "U1.00", "UA1.00", "UG1.00", "US Dolla1.00", "US Dollar (Next day1.00", "US Dollar (Same day1.00", "US1.00", "UY1.00", "UZ1.00", "Ugandan Shillin1.00", "Ugandan Shilling (1966-19871.00", "Ukrainian Hryvni1.00", "Ukrainian Karbovanet1.00", "Colombian Real Value Uni1.00", "United Arab Emirates Dirha1.00", "Unknown Currenc1.00", "Ur1.00", "Uruguay Peso (1975-19931.00", "Uruguay Peso Uruguay1.00", "Uruguay Peso (Indexed Units1.00", "Uzbekistan So1.00", "V1.00", "VE1.00", "VN1.00", "VU1.00", "Vanuatu Vat1.00", "Venezuelan Bol\\u00edva1.00", "Venezuelan Bol\\u00edvar Fuert1.00", "Vietnamese Don1.00", "WIR Eur1.00", "WIR Fran1.00", "WS1.00", "Samoa Tal1.00", "XA1.00", "XB1.00", "XC1.00", "XD1.00", "XE1.00", "XF1.00", "XO1.00", "XP1.00", "XR1.00", "XT1.00", "XX1.00", "YD1.00", "YE1.00", "YU1.00", "Yemeni Dina1.00", "Yemeni Ria1.00", "Yugoslavian Convertible Dina1.00", "Yugoslavian Hard Dinar (1966-19901.00", "Yugoslavian New Dina1.00", "Z1.00", "ZA1.00", "ZM1.00", "ZR1.00", "ZW1.00", "Zairean New Zaire (1993-19981.00", "Zairean Zair1.00", "Zambian Kwach1.00", "Zimbabwean Dollar (1980-20081.00", "dra1.00", "lar1.00", "le1.00", "man1.00", "so1.00", }; Locale locale("en_US"); for (uint32_t i=0; i<sizeof(DATA)/sizeof(DATA[0]); ++i) { UnicodeString formatted = ctou(DATA[i]); UErrorCode status = U_ZERO_ERROR; NumberFormat* numFmt = NumberFormat::createInstance(locale, NumberFormat::kCurrencyStyle, status); Formattable parseResult; if (numFmt != NULL && U_SUCCESS(status)) { numFmt->parse(formatted, parseResult, status); if (U_FAILURE(status) || (parseResult.getType() == Formattable::kDouble && parseResult.getDouble() != 1.0)) { errln("wrong parsing, " + formatted); errln("data: " + formatted); } } else { dataerrln("Unable to create NumberFormat. - %s", u_errorName(status)); delete numFmt; break; } delete numFmt; } for (uint32_t i=0; i<sizeof(WRONG_DATA)/sizeof(WRONG_DATA[0]); ++i) { UnicodeString formatted = ctou(WRONG_DATA[i]); UErrorCode status = U_ZERO_ERROR; NumberFormat* numFmt = NumberFormat::createInstance(locale, NumberFormat::kCurrencyStyle, status); Formattable parseResult; if (numFmt != NULL && U_SUCCESS(status)) { numFmt->parse(formatted, parseResult, status); if (!U_FAILURE(status) || (parseResult.getType() == Formattable::kDouble && parseResult.getDouble() == 1.0)) { errln("parsed but should not be: " + formatted); errln("data: " + formatted); } } else { dataerrln("Unable to create NumberFormat. - %s", u_errorName(status)); delete numFmt; break; } delete numFmt; } } const char* attrString(int32_t); // UnicodeString s; // std::string ss; // std::cout << s.toUTF8String(ss) void NumberFormatTest::expectPositions(FieldPositionIterator& iter, int32_t *values, int32_t tupleCount, const UnicodeString& str) { UBool found[10]; FieldPosition fp; if (tupleCount > 10) { assertTrue("internal error, tupleCount too large", FALSE); } else { for (int i = 0; i < tupleCount; ++i) { found[i] = FALSE; } } logln(str); while (iter.next(fp)) { UBool ok = FALSE; int32_t id = fp.getField(); int32_t start = fp.getBeginIndex(); int32_t limit = fp.getEndIndex(); // is there a logln using printf? char buf[128]; sprintf(buf, "%24s %3d %3d %3d", attrString(id), id, start, limit); logln(buf); for (int i = 0; i < tupleCount; ++i) { if (found[i]) { continue; } if (values[i*3] == id && values[i*3+1] == start && values[i*3+2] == limit) { found[i] = ok = TRUE; break; } } assertTrue((UnicodeString)"found [" + id + "," + start + "," + limit + "]", ok); } // check that all were found UBool ok = TRUE; for (int i = 0; i < tupleCount; ++i) { if (!found[i]) { ok = FALSE; assertTrue((UnicodeString) "missing [" + values[i*3] + "," + values[i*3+1] + "," + values[i*3+2] + "]", found[i]); } } assertTrue("no expected values were missing", ok); } void NumberFormatTest::expectPosition(FieldPosition& pos, int32_t id, int32_t start, int32_t limit, const UnicodeString& str) { logln(str); assertTrue((UnicodeString)"id " + id + " == " + pos.getField(), id == pos.getField()); assertTrue((UnicodeString)"begin " + start + " == " + pos.getBeginIndex(), start == pos.getBeginIndex()); assertTrue((UnicodeString)"end " + limit + " == " + pos.getEndIndex(), limit == pos.getEndIndex()); } void NumberFormatTest::TestFieldPositionIterator() { // bug 7372 UErrorCode status = U_ZERO_ERROR; FieldPositionIterator iter1; FieldPositionIterator iter2; FieldPosition pos; DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(status); if (failure(status, "NumberFormat::createInstance", TRUE)) return; double num = 1234.56; UnicodeString str1; UnicodeString str2; assertTrue((UnicodeString)"self==", iter1 == iter1); assertTrue((UnicodeString)"iter1==iter2", iter1 == iter2); decFmt->format(num, str1, &iter1, status); assertTrue((UnicodeString)"iter1 != iter2", iter1 != iter2); decFmt->format(num, str2, &iter2, status); assertTrue((UnicodeString)"iter1 == iter2 (2)", iter1 == iter2); iter1.next(pos); assertTrue((UnicodeString)"iter1 != iter2 (2)", iter1 != iter2); iter2.next(pos); assertTrue((UnicodeString)"iter1 == iter2 (3)", iter1 == iter2); // should format ok with no iterator str2.remove(); decFmt->format(num, str2, NULL, status); assertEquals("null fpiter", str1, str2); delete decFmt; } void NumberFormatTest::TestFormatAttributes() { Locale locale("en_US"); UErrorCode status = U_ZERO_ERROR; DecimalFormat *decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, NumberFormat::kCurrencyStyle, status); if (failure(status, "NumberFormat::createInstance", TRUE)) return; double val = 12345.67; { int32_t expected[] = { NumberFormat::kCurrencyField, 0, 1, NumberFormat::kGroupingSeparatorField, 3, 4, NumberFormat::kIntegerField, 1, 7, NumberFormat::kDecimalSeparatorField, 7, 8, NumberFormat::kFractionField, 8, 10, }; int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected)); FieldPositionIterator posIter; UnicodeString result; decFmt->format(val, result, &posIter, status); expectPositions(posIter, expected, tupleCount, result); } { FieldPosition fp(NumberFormat::kIntegerField); UnicodeString result; decFmt->format(val, result, fp); expectPosition(fp, NumberFormat::kIntegerField, 1, 7, result); } { FieldPosition fp(NumberFormat::kFractionField); UnicodeString result; decFmt->format(val, result, fp); expectPosition(fp, NumberFormat::kFractionField, 8, 10, result); } delete decFmt; decFmt = (DecimalFormat *) NumberFormat::createInstance(locale, NumberFormat::kScientificStyle, status); val = -0.0000123; { int32_t expected[] = { NumberFormat::kSignField, 0, 1, NumberFormat::kIntegerField, 1, 2, NumberFormat::kDecimalSeparatorField, 2, 3, NumberFormat::kFractionField, 3, 5, NumberFormat::kExponentSymbolField, 5, 6, NumberFormat::kExponentSignField, 6, 7, NumberFormat::kExponentField, 7, 8 }; int32_t tupleCount = sizeof(expected)/(3 * sizeof(*expected)); FieldPositionIterator posIter; UnicodeString result; decFmt->format(val, result, &posIter, status); expectPositions(posIter, expected, tupleCount, result); } { FieldPosition fp(NumberFormat::kIntegerField); UnicodeString result; decFmt->format(val, result, fp); expectPosition(fp, NumberFormat::kIntegerField, 1, 2, result); } { FieldPosition fp(NumberFormat::kFractionField); UnicodeString result; decFmt->format(val, result, fp); expectPosition(fp, NumberFormat::kFractionField, 3, 5, result); } delete decFmt; fflush(stderr); } const char* attrString(int32_t attrId) { switch (attrId) { case NumberFormat::kIntegerField: return "integer"; case NumberFormat::kFractionField: return "fraction"; case NumberFormat::kDecimalSeparatorField: return "decimal separator"; case NumberFormat::kExponentSymbolField: return "exponent symbol"; case NumberFormat::kExponentSignField: return "exponent sign"; case NumberFormat::kExponentField: return "exponent"; case NumberFormat::kGroupingSeparatorField: return "grouping separator"; case NumberFormat::kCurrencyField: return "currency"; case NumberFormat::kPercentField: return "percent"; case NumberFormat::kPermillField: return "permille"; case NumberFormat::kSignField: return "sign"; default: return ""; } } // // Test formatting & parsing of big decimals. // API test, not a comprehensive test. // See DecimalFormatTest/DataDrivenTests // #define ASSERT_SUCCESS(status) {if (U_FAILURE(status)) errln("file %s, line %d: status: %s", \ __FILE__, __LINE__, u_errorName(status));} #define ASSERT_EQUALS(expected, actual) {if ((expected) != (actual)) \ errln("file %s, line %d: %s != %s", __FILE__, __LINE__, #expected, #actual);} static UBool operator != (const char *s1, UnicodeString &s2) { // This function lets ASSERT_EQUALS("literal", UnicodeString) work. UnicodeString us1(s1); return us1 != s2; } void NumberFormatTest::TestDecimal() { { UErrorCode status = U_ZERO_ERROR; Formattable f("12.345678999987654321E666", status); ASSERT_SUCCESS(status); StringPiece s = f.getDecimalNumber(status); ASSERT_SUCCESS(status); ASSERT_EQUALS("1.2345678999987654321E+667", s); //printf("%s\n", s.data()); } { UErrorCode status = U_ZERO_ERROR; Formattable f1("this is not a number", status); ASSERT_EQUALS(U_DECIMAL_NUMBER_SYNTAX_ERROR, status); } { UErrorCode status = U_ZERO_ERROR; Formattable f; f.setDecimalNumber("123.45", status); ASSERT_SUCCESS(status); ASSERT_EQUALS( Formattable::kDouble, f.getType()); ASSERT_EQUALS(123.45, f.getDouble()); ASSERT_EQUALS(123.45, f.getDouble(status)); ASSERT_SUCCESS(status); ASSERT_EQUALS("123.45", f.getDecimalNumber(status)); ASSERT_SUCCESS(status); f.setDecimalNumber("4.5678E7", status); int32_t n; n = f.getLong(); ASSERT_EQUALS(45678000, n); status = U_ZERO_ERROR; f.setDecimalNumber("-123", status); ASSERT_SUCCESS(status); ASSERT_EQUALS( Formattable::kLong, f.getType()); ASSERT_EQUALS(-123, f.getLong()); ASSERT_EQUALS(-123, f.getLong(status)); ASSERT_SUCCESS(status); ASSERT_EQUALS("-123", f.getDecimalNumber(status)); ASSERT_SUCCESS(status); status = U_ZERO_ERROR; f.setDecimalNumber("1234567890123", status); // Number too big for 32 bits ASSERT_SUCCESS(status); ASSERT_EQUALS( Formattable::kInt64, f.getType()); ASSERT_EQUALS(1234567890123LL, f.getInt64()); ASSERT_EQUALS(1234567890123LL, f.getInt64(status)); ASSERT_SUCCESS(status); ASSERT_EQUALS("1234567890123", f.getDecimalNumber(status)); ASSERT_SUCCESS(status); } { UErrorCode status = U_ZERO_ERROR; NumberFormat *fmtr = NumberFormat::createInstance( Locale::getUS(), NumberFormat::kNumberStyle, status); if (U_FAILURE(status) || fmtr == NULL) { dataerrln("Unable to create NumberFormat"); } else { UnicodeString formattedResult; StringPiece num("244444444444444444444444444444444444446.4"); fmtr->format(num, formattedResult, NULL, status); ASSERT_SUCCESS(status); ASSERT_EQUALS("244,444,444,444,444,444,444,444,444,444,444,444,446.4", formattedResult); //std::string ss; std::cout << formattedResult.toUTF8String(ss); delete fmtr; } } { // Check formatting a DigitList. DigitList is internal, but this is // a critical interface that must work. UErrorCode status = U_ZERO_ERROR; NumberFormat *fmtr = NumberFormat::createInstance( Locale::getUS(), NumberFormat::kNumberStyle, status); if (U_FAILURE(status) || fmtr == NULL) { dataerrln("Unable to create NumberFormat"); } else { UnicodeString formattedResult; DigitList dl; StringPiece num("123.4566666666666666666666666666666666621E+40"); dl.set(num, status); ASSERT_SUCCESS(status); fmtr->format(dl, formattedResult, NULL, status); ASSERT_SUCCESS(status); ASSERT_EQUALS("1,234,566,666,666,666,666,666,666,666,666,666,666,621,000", formattedResult); status = U_ZERO_ERROR; num.set("666.666"); dl.set(num, status); FieldPosition pos(NumberFormat::FRACTION_FIELD); ASSERT_SUCCESS(status); formattedResult.remove(); fmtr->format(dl, formattedResult, pos, status); ASSERT_SUCCESS(status); ASSERT_EQUALS("666.666", formattedResult); ASSERT_EQUALS(4, pos.getBeginIndex()); ASSERT_EQUALS(7, pos.getEndIndex()); delete fmtr; } } { // Check a parse with a formatter with a multiplier. UErrorCode status = U_ZERO_ERROR; NumberFormat *fmtr = NumberFormat::createInstance( Locale::getUS(), NumberFormat::kPercentStyle, status); if (U_FAILURE(status) || fmtr == NULL) { dataerrln("Unable to create NumberFormat"); } else { UnicodeString input = "1.84%"; Formattable result; fmtr->parse(input, result, status); ASSERT_SUCCESS(status); ASSERT_EQUALS(0, strcmp("0.0184", result.getDecimalNumber(status).data())); //std::cout << result.getDecimalNumber(status).data(); delete fmtr; } } { // Check that a parse returns a decimal number with full accuracy UErrorCode status = U_ZERO_ERROR; NumberFormat *fmtr = NumberFormat::createInstance( Locale::getUS(), NumberFormat::kNumberStyle, status); if (U_FAILURE(status) || fmtr == NULL) { dataerrln("Unable to create NumberFormat"); } else { UnicodeString input = "1.002200044400088880000070000"; Formattable result; fmtr->parse(input, result, status); ASSERT_SUCCESS(status); ASSERT_EQUALS(0, strcmp("1.00220004440008888000007", result.getDecimalNumber(status).data())); ASSERT_EQUALS(1.00220004440008888, result.getDouble()); //std::cout << result.getDecimalNumber(status).data(); delete fmtr; } } } void NumberFormatTest::TestCurrencyFractionDigits() { UErrorCode status = U_ZERO_ERROR; UnicodeString text1, text2; double value = 99.12345; // Create currenct instance NumberFormat* fmt = NumberFormat::createCurrencyInstance("ja_JP", status); if (U_FAILURE(status) || fmt == NULL) { dataerrln("Unable to create NumberFormat"); } else { fmt->format(value, text1); // Reset the same currency and format the test value again fmt->setCurrency(fmt->getCurrency(), status); ASSERT_SUCCESS(status); fmt->format(value, text2); if (text1 != text2) { errln((UnicodeString)"NumberFormat::format() should return the same result - text1=" + text1 + " text2=" + text2); } delete fmt; } } void NumberFormatTest::TestExponentParse() { UErrorCode status = U_ZERO_ERROR; Formattable result; ParsePosition parsePos(0); // set the exponent symbol status = U_ZERO_ERROR; DecimalFormatSymbols *symbols = new DecimalFormatSymbols(Locale::getDefault(), status); if(U_FAILURE(status)) { dataerrln((UnicodeString)"ERROR: Could not create DecimalFormatSymbols (Default)"); return; } symbols->setSymbol(DecimalFormatSymbols::kExponentialSymbol,"e"); // create format instance status = U_ZERO_ERROR; DecimalFormat fmt("#####", symbols, status); if(U_FAILURE(status)) { errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols*)"); } // parse the text fmt.parse("123E4", result, parsePos); if(result.getType() != Formattable::kDouble && result.getDouble() != (double)123 && parsePos.getIndex() != 3 ) { errln("ERROR: parse failed - expected 123.0, 3 - returned %d, %i", result.getDouble(), parsePos.getIndex()); } } #endif /* #if !UCONFIG_NO_FORMATTING */
; Program 5.1 ; Conditional Jump - NASM (64-bit) ; Copyright (c) 2020 Hall & Slonka SECTION .data wages: DQ 46000 SECTION .bss taxes: RESQ 1 SECTION .text global _main _main: mov rax, 50000 cmp QWORD [wages], rax jae higher mov QWORD [taxes], 2000 jmp done higher: mov QWORD [taxes], 4000 done: mov rax, 60 xor rdi, rdi syscall
; William Barden, Jr. 'TRS-80 Assembly-Language Programming', 1979 pg 189. ; ; Fills a block of memory with a given 8-bit value. ; ; Uses: a, bc, d, hl ; ; Entry: d data to be filled (the 8-bit value) ; hl start addr of the fill area ; bc # of bytes to fill ; Exit: d same ; hl end addr of the fill area + 1 ; bc 0 ; a 0 barden_fill: ld (hl),d ; Actually do fill inc hl ; To next addr dec bc ; Count down byte count ld a,b ; Goto FILL if byte count != 0 or c jr nz,barden_fill ret
; ; Routine to handle menu options ; ; Called from getk() getkey() ; ; We've just read in 0 from os_*in so we need to get the command ; code - this should never occur from BASIC, so the basic crt0 ; file can just be a ret ; ; ; $Id: getcmd.asm,v 1.4 2015/01/19 01:33:22 pauloscustodio Exp $ ; PUBLIC getcmd EXTERN processcmd INCLUDE "stdio.def" .getcmd call_oz(os_in) ld l,a ;hl=0 no key pressed if exit ld h,0 and a ret z cp $B1 ;[]ENTER ret nc ;command code ret with code jp processcmd ; in crt0
.686p .model flat, stdcall option casemap:none .code option prologue:none option epilogue:none get_frdepackersize proc export mov eax, unpacker_end - KKrunchyDepacker ret get_frdepackersize endp get_frdepackerptr proc export mov eax, KKrunchyDepacker ret get_frdepackerptr endp unpacker_start: KKrunchyDepacker: PUSH EBP ; CCADepackerA PUSH ESI PUSH EDI PUSH EBX MOV ESI,DWORD PTR SS:[ESP+018h] SUB ESP,0CA0h MOV EBP,ESP LODS DWORD PTR DS:[ESI] MOV DWORD PTR SS:[EBP],ESI BSWAP EAX MOV DWORD PTR SS:[EBP+4],EAX OR DWORD PTR SS:[EBP+8],0FFFFFFFFh MOV DWORD PTR SS:[EBP+0Ch],5 MOV DWORD PTR SS:[EBP+010h],0 LEA EDI,DWORD PTR SS:[EBP+014h] MOV ECX,0323h XOR EAX,EAX MOV AH,4 REP STOS DWORD PTR ES:[EDI] MOV EDI,DWORD PTR SS:[ESP+0CB4h] @mudff_00401040: XOR ECX,ECX INC ECX DEC DWORD PTR SS:[EBP+0Ch] @mudff_00401046: LEA EBX,DWORD PTR SS:[EBP+ECX*4+0A0h] CALL @mudff_004010F2 ADC CL,CL JNB @mudff_00401046 INC DWORD PTR SS:[EBP+0Ch] XCHG EAX,ECX STOS BYTE PTR ES:[EDI] OR ECX,0FFFFFFFFh @mudff_0040105E: LEA EBX,DWORD PTR SS:[EBP+ECX*4+018h] CALL @mudff_004010F2 JE @mudff_00401040 JECXZ @mudff_00401085 LEA EBX,DWORD PTR SS:[EBP+01Ch] CALL @mudff_004010F2 JE @mudff_00401085 LEA EBX,DWORD PTR SS:[EBP+08A0h] CALL @mudff_00401143 MOV EAX,DWORD PTR SS:[EBP+010h] JMP @mudff_004010CF @mudff_00401085: LEA EBX,DWORD PTR SS:[EBP+04A0h] CALL @mudff_00401143 DEC ECX DEC ECX JS @mudff_004010DC LEA EBX,DWORD PTR SS:[EBP+020h] JE @mudff_0040109C ADD EBX,040h @mudff_0040109C: XOR EDX,EDX INC EDX @mudff_0040109F: PUSH EBX LEA EBX,DWORD PTR DS:[EBX+EDX*4] CALL @mudff_004010F2 POP EBX ADC EDX,EDX LEA ECX,DWORD PTR DS:[EAX+ECX*2] TEST DL,010h JE @mudff_0040109F LEA EAX,DWORD PTR DS:[ECX+1] LEA EBX,DWORD PTR SS:[EBP+08A0h] CALL @mudff_00401143 CMP EAX,0800h SBB ECX,-1 CMP EAX,060h SBB ECX,-1 @mudff_004010CF: MOV DWORD PTR SS:[EBP+010h],EAX PUSH ESI MOV ESI,EDI SUB ESI,EAX REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] POP ESI JMP @mudff_0040105E @mudff_004010DC: MOV EAX,EDI SUB EAX,DWORD PTR SS:[ESP+0CB4h] ADD ESP,0CA0h POP EBX POP EDI POP ESI POP EBP RETN 8 ;<= Procedure End @mudff_004010F2: ;<= Procedure Start PUSH ECX MOV EAX,DWORD PTR SS:[EBP+8] SHR EAX,0Bh IMUL EAX,DWORD PTR DS:[EBX] CMP EAX,DWORD PTR SS:[EBP+4] MOV ECX,DWORD PTR SS:[EBP+0Ch] JBE @mudff_00401116 MOV DWORD PTR SS:[EBP+8],EAX MOV EAX,0800h SUB EAX,DWORD PTR DS:[EBX] SHR EAX,CL ADD DWORD PTR DS:[EBX],EAX XOR EAX,EAX JMP @mudff_00401125 @mudff_00401116: SUB DWORD PTR SS:[EBP+4],EAX SUB DWORD PTR SS:[EBP+8],EAX MOV EAX,DWORD PTR DS:[EBX] SHR EAX,CL SUB DWORD PTR DS:[EBX],EAX OR EAX,0FFFFFFFFh @mudff_00401125: TEST BYTE PTR SS:[EBP+0Bh],0FFh JNZ @mudff_0040113E MOV ECX,DWORD PTR SS:[EBP] INC DWORD PTR SS:[EBP] MOV CL,BYTE PTR DS:[ECX] SHL DWORD PTR SS:[EBP+8],8 SHL DWORD PTR SS:[EBP+4],8 MOV BYTE PTR SS:[EBP+4],CL @mudff_0040113E: SHR EAX,01Fh POP ECX RETN ;<= Procedure End @mudff_00401143: ;<= Procedure Start PUSH EAX XOR ECX,ECX INC ECX MOV EDX,ECX @mudff_00401149: PUSH EBX LEA EBX,DWORD PTR DS:[EBX+EDX*4] CALL @mudff_004010F2 POP EBX ADC DL,DL PUSH EBX LEA EBX,DWORD PTR DS:[EBX+EDX*4] CALL @mudff_004010F2 POP EBX ADC DL,DL LEA ECX,DWORD PTR DS:[EAX+ECX*2] TEST DL,2 JNZ @mudff_00401149 POP EAX RETN ;<= Procedure End unpacker_end: end
; A271743: Number of set partitions of [n] such that 4 is the largest element of the last block. ; 10,15,29,63,149,375,989,2703,7589,21735,63149,185343,547829,1627095,4848509,14479983,43308869,129664455,388469069,1164358623,3490978709,10468741815,31397836829,94176733263,282496645349,847422827175,2542134263789,7626134355903,22877866196789,68632524848535,205895427061949,617681986218543,1853037368721029,5559094926293895 mov $1,2 mov $2,1 lpb $0,1 sub $0,1 mul $2,3 mov $1,$2 add $3,2 mul $3,2 lpe mov $0,1 mul $0,$1 add $0,2 add $0,$3 mov $1,$0 add $1,6
.size 8000 .text@58 jp lstartserial .text@100 jp lbegin .data@143 80 .text@150 lbegin: xor a, a ldff(0f), a ld a, 08 ldff(ff), a ld a, 81 ldff(02), a ei .text@1000 lstartserial: xor a, a ldff(01), a ld a, 81 ldff(02), a .text@1200 ldff(02), a .text@1500 xor a, a ldff(0f), a .text@15f0 ldff a, (0f) jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a ld bc, 7a00 ld hl, 8000 ld d, 00 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles pop af ld b, a srl a srl a srl a srl a ld(9800), a ld a, b and a, 0f ld(9801), a ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f 00 00 08 08 22 22 41 41 7f 7f 41 41 41 41 41 41 00 00 7e 7e 41 41 41 41 7e 7e 41 41 41 41 7e 7e 00 00 3e 3e 41 41 40 40 40 40 40 40 41 41 3e 3e 00 00 7e 7e 41 41 41 41 41 41 41 41 41 41 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 40 40
#include "System.h" #include "Component.h" #include "Application.h" #include "ModuleFileSystem.h" System::System() { stringBuffer = new rapidjson::StringBuffer(); writer = new rapidjson::PrettyWriter<rapidjson::StringBuffer>(*stringBuffer); writer->StartObject(); } System::~System() { delete writer; delete stringBuffer; writer = nullptr; stringBuffer = nullptr; } void System::AddName(const char* name) { writer->String(name); } void System::AddComponentType(const char* name, Type componentType) { writer->String(name); switch (componentType) { case Type::Transform: writer->String("TRANSFORM"); break; case Type::Mesh: writer->String("MESH"); break; case Type::Material: writer->String("MATERIAL"); break; case Type::Camera: writer->String("CAMERA"); break; case Type::Light: writer->String("LIGHT"); break; } } void System::AddInt(const char* name, int value) { writer->String(name); writer->Int(value); } void System::AddUnsigned(const char* name, unsigned value) { writer->String(name); writer->Uint(value); } void System::AddFloat(const char* name, float value) { writer->String(name); writer->Double(value); } void System::AddString(const char* name, const char* value) { writer->String(name); writer->String(value); } void System::AddBool(const char* name, bool value) { writer->String(name); writer->Bool(value); } void System::AddFloat3(const char* name, math::float3 value) { StartObject(name); writer->String("x"); writer->Double(value.x); writer->String("y"); writer->Double(value.y); writer->String("z"); writer->Double(value.z); EndObject(); } void System::AddFloat4(const char* name, math::float4 value) { StartObject(name); writer->String("x"); writer->Double(value.x); writer->String("y"); writer->Double(value.y); writer->String("z"); writer->Double(value.z); writer->String("w"); writer->Double(value.w); EndObject(); } void System::AddQuat(const char* name, math::Quat value) { StartObject(name); writer->String("x"); writer->Double(value.x); writer->String("y"); writer->Double(value.y); writer->String("z"); writer->Double(value.z); writer->String("w"); writer->Double(value.w); EndObject(); } int System::GetComponentType(const char* name, rapidjson::Value& value) { const char* stringComponentType = value[name].GetString(); if (strcmp(stringComponentType, "TRANSFORM") == 0) { return 0; } if (strcmp(stringComponentType, "MESH") == 0) { return 1; } if (strcmp(stringComponentType, "MATERIAL") == 0) { return 2; } if (strcmp(stringComponentType, "CAMERA") == 0) { return 3; } if (strcmp(stringComponentType, "LIGHT") == 0) { return 4; } } int System::GetInt(const char* name, rapidjson::Value& value) { return value[name].GetInt(); } unsigned System::GetUnsigned(const char* name, rapidjson::Value& value) { return value[name].GetUint(); } float System::GetFloat(const char* name, rapidjson::Value& value) { return value[name].GetFloat(); } const char* System::GetString(const char* name, rapidjson::Value& value) { return value[name].GetString(); } bool System::GetBool(const char* name, rapidjson::Value& value) { return value[name].GetBool(); } math::float3 System::GetFloat3(const char* name, rapidjson::Value& value) { math::float3 result = { value[name]["x"].GetFloat(), value[name]["y"].GetFloat(), value[name]["z"].GetFloat() }; return result; } math::float4 System::GetFloat4(const char* name, rapidjson::Value& value) { math::float4 result = { value[name]["x"].GetFloat(), value[name]["y"].GetFloat(), value[name]["z"].GetFloat(), value[name]["w"].GetFloat() }; return result; } math::Quat System::GetQuat(const char* name, rapidjson::Value& value) { math::Quat result = { value[name]["x"].GetFloat(), value[name]["y"].GetFloat(), value[name]["z"].GetFloat(), value[name]["w"].GetFloat() }; return result; } void System::StartObject(const char* name) { writer->String(name); writer->StartObject(); } void System::StartObject() { writer->StartObject(); } void System::EndObject() { writer->EndObject(); } void System::StartArray(const char* name) { writer->String(name); writer->StartArray(); } void System::EndArray() { writer->EndArray(); } void System::WriteToDisk() { writer->EndObject(); App->fileSystem->Save("/Data/Scenes/scene.json", stringBuffer->GetString(), strlen(stringBuffer->GetString()), false); } rapidjson::Document System::LoadFromDisk() { rapidjson::Document result = nullptr; char* fileBuffer; unsigned lenghBuffer = App->fileSystem->Load("/Data/Scenes/scene.json", &fileBuffer); if (fileBuffer) { if (result.Parse<rapidjson::kParseStopWhenDoneFlag>(fileBuffer).HasParseError()) { result = nullptr; } } delete[] fileBuffer; return result; }
// Ceres Solver - A fast non-linear least squares minimizer // Copyright 2015 Google Inc. All rights reserved. // http://ceres-solver.org/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of Google Inc. nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Author: sameeragarwal@google.com (Sameer Agarwal) #include "ceres/parameter_block_ordering.h" #include <memory> #include <unordered_set> #include "ceres/graph.h" #include "ceres/graph_algorithms.h" #include "ceres/map_util.h" #include "ceres/parameter_block.h" #include "ceres/program.h" #include "ceres/residual_block.h" #include "ceres/wall_time.h" #include "glog/logging.h" namespace ceres { namespace internal { using std::map; using std::set; using std::vector; int ComputeStableSchurOrdering(const Program& program, vector<ParameterBlock*>* ordering) { CHECK_NOTNULL(ordering)->clear(); EventLogger event_logger("ComputeStableSchurOrdering"); std::unique_ptr<Graph< ParameterBlock*> > graph(CreateHessianGraph(program)); event_logger.AddEvent("CreateHessianGraph"); const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks(); const std::unordered_set<ParameterBlock*>& vertices = graph->vertices(); for (int i = 0; i < parameter_blocks.size(); ++i) { if (vertices.count(parameter_blocks[i]) > 0) { ordering->push_back(parameter_blocks[i]); } } event_logger.AddEvent("Preordering"); int independent_set_size = StableIndependentSetOrdering(*graph, ordering); event_logger.AddEvent("StableIndependentSet"); // Add the excluded blocks to back of the ordering vector. for (int i = 0; i < parameter_blocks.size(); ++i) { ParameterBlock* parameter_block = parameter_blocks[i]; if (parameter_block->IsConstant()) { ordering->push_back(parameter_block); } } event_logger.AddEvent("ConstantParameterBlocks"); return independent_set_size; } int ComputeSchurOrdering(const Program& program, vector<ParameterBlock*>* ordering) { CHECK_NOTNULL(ordering)->clear(); std::unique_ptr<Graph< ParameterBlock*> > graph(CreateHessianGraph(program)); int independent_set_size = IndependentSetOrdering(*graph, ordering); const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks(); // Add the excluded blocks to back of the ordering vector. for (int i = 0; i < parameter_blocks.size(); ++i) { ParameterBlock* parameter_block = parameter_blocks[i]; if (parameter_block->IsConstant()) { ordering->push_back(parameter_block); } } return independent_set_size; } void ComputeRecursiveIndependentSetOrdering(const Program& program, ParameterBlockOrdering* ordering) { CHECK_NOTNULL(ordering)->Clear(); const vector<ParameterBlock*> parameter_blocks = program.parameter_blocks(); std::unique_ptr<Graph< ParameterBlock*> > graph(CreateHessianGraph(program)); int num_covered = 0; int round = 0; while (num_covered < parameter_blocks.size()) { vector<ParameterBlock*> independent_set_ordering; const int independent_set_size = IndependentSetOrdering(*graph, &independent_set_ordering); for (int i = 0; i < independent_set_size; ++i) { ParameterBlock* parameter_block = independent_set_ordering[i]; ordering->AddElementToGroup(parameter_block->mutable_user_state(), round); graph->RemoveVertex(parameter_block); } num_covered += independent_set_size; ++round; } } Graph<ParameterBlock*>* CreateHessianGraph(const Program& program) { Graph<ParameterBlock*>* graph = CHECK_NOTNULL(new Graph<ParameterBlock*>); const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks(); for (int i = 0; i < parameter_blocks.size(); ++i) { ParameterBlock* parameter_block = parameter_blocks[i]; if (!parameter_block->IsConstant()) { graph->AddVertex(parameter_block); } } const vector<ResidualBlock*>& residual_blocks = program.residual_blocks(); for (int i = 0; i < residual_blocks.size(); ++i) { const ResidualBlock* residual_block = residual_blocks[i]; const int num_parameter_blocks = residual_block->NumParameterBlocks(); ParameterBlock* const* parameter_blocks = residual_block->parameter_blocks(); for (int j = 0; j < num_parameter_blocks; ++j) { if (parameter_blocks[j]->IsConstant()) { continue; } for (int k = j + 1; k < num_parameter_blocks; ++k) { if (parameter_blocks[k]->IsConstant()) { continue; } graph->AddEdge(parameter_blocks[j], parameter_blocks[k]); } } } return graph; } void OrderingToGroupSizes(const ParameterBlockOrdering* ordering, vector<int>* group_sizes) { CHECK_NOTNULL(group_sizes)->clear(); if (ordering == NULL) { return; } const map<int, set<double*>>& group_to_elements = ordering->group_to_elements(); for (const auto& g_t_e : group_to_elements) { group_sizes->push_back(g_t_e.second.size()); } } } // namespace internal } // namespace ceres
; Note - character's animations included first, for anim_invisible address to be as stable as possible (require a server update when it change) #include "game/data/characters/characters-common-animations/characters-common-animations.asm" #include "game/data/characters/characters-index.asm" #include "game/data/characters/characters-common-logic.asm" #include "game/data/stages/stages-index.asm" #include "game/data/rom_constants.asm" #include "game/data/anim_empty.asm"
; A004760: List of numbers whose binary expansion does not begin 10. ; 0,1,3,6,7,12,13,14,15,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,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,127,192,193,194,195,196,197,198,199,200,201,202,203,204,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,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504 mov $2,$0 lpb $0 mov $0,$2 sub $0,$1 trn $0,1 add $1,$2 sub $1,$0 lpe
; A010762: a(n) = floor( n/2 ) * floor( n/3 ). ; 0,0,1,2,2,6,6,8,12,15,15,24,24,28,35,40,40,54,54,60,70,77,77,96,96,104,117,126,126,150,150,160,176,187,187,216,216,228,247,260,260,294,294,308,330,345,345,384,384,400,425,442,442,486,486,504,532,551,551,600,600,620,651,672,672,726,726,748,782,805,805,864,864,888,925,950,950,1014,1014,1040,1080,1107,1107,1176,1176,1204,1247,1276,1276,1350,1350,1380,1426,1457,1457,1536,1536,1568,1617,1650 add $0,1 mov $1,$0 div $0,2 div $1,3 mul $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r15 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0xf0b7, %rsi lea addresses_D_ht+0x74b7, %rdi nop nop nop nop and %r11, %r11 mov $0, %rcx rep movsb nop nop nop add %rbx, %rbx lea addresses_A_ht+0x18b7, %rsi lea addresses_A_ht+0x11cb7, %rdi add %r8, %r8 mov $59, %rcx rep movsq nop nop inc %rsi lea addresses_UC_ht+0xc4b7, %rsi lea addresses_normal_ht+0x1383f, %rdi nop nop nop nop nop sub $43125, %r15 mov $79, %rcx rep movsq nop nop nop inc %r15 lea addresses_normal_ht+0xfb37, %rsi lea addresses_D_ht+0x193f7, %rdi nop nop nop nop nop dec %r14 mov $92, %rcx rep movsw xor %rdi, %rdi lea addresses_A_ht+0x1ee77, %rsi lea addresses_D_ht+0x7cb7, %rdi clflush (%rsi) clflush (%rdi) nop inc %rbx mov $14, %rcx rep movsl nop nop add $14111, %rbx lea addresses_D_ht+0xcf7, %r14 nop nop nop nop lfence mov (%r14), %r15w nop nop mfence pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi // Load mov $0x1b7, %rsi nop nop add %rdx, %rdx movb (%rsi), %r14b and %r14, %r14 // Store lea addresses_PSE+0x1a0b7, %r15 nop nop nop nop nop sub %r12, %r12 movb $0x51, (%r15) nop nop nop nop add $2428, %rax // REPMOV lea addresses_PSE+0xbd3a, %rsi lea addresses_A+0x15037, %rdi nop nop inc %r15 mov $4, %rcx rep movsb nop sub $45278, %r12 // Store lea addresses_WT+0x1deb, %r14 sub %rdx, %rdx mov $0x5152535455565758, %rdi movq %rdi, %xmm2 movups %xmm2, (%r14) nop nop cmp %rcx, %rcx // Faulty Load lea addresses_RW+0xa8b7, %rdx nop add %rdi, %rdi movups (%rdx), %xmm5 vpextrq $0, %xmm5, %rax lea oracles, %rdx and $0xff, %rax shlq $12, %rax mov (%rdx,%rax,1), %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_P', 'congruent': 8}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_PSE', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_PSE'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT', 'congruent': 2}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 3, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 3}} {'32': 16599} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; $Id: bit_fx2.asm $ ; ; Generic platform sound effects module. ; Alternate sound library by Stefano Bodrato ; IF !__CPU_GBZ80__ && !__CPU_INTEL__ SECTION smc_clib PUBLIC bit_fx2 PUBLIC _bit_fx2 INCLUDE "games/games.inc" EXTERN bit_open EXTERN bit_open_di EXTERN bit_close EXTERN bit_close_ei .bit_fx2 ._bit_fx2 pop bc pop de push de push bc IF sndbit_port >= 256 exx ld bc,sndbit_port exx ENDIF ld a,e cp 8 ret nc add a,a ld e,a ld d,0 ld hl,table add hl,de ld a,(hl) inc hl ld h,(hl) ld l,a jp (hl) .table defw DeepSpace ; effect #0 defw SSpace2 defw TSpace defw Clackson2 defw TSpace2 defw TSpace3 ; effect #5 defw Squoink defw explosion ;Space sound .DeepSpace call bit_open_di .DS_LENGHT ld b,100 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .ds_loop dec h jr nz,ds_jump xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,250 .loosetime1 djnz loosetime1 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ds_FR_1 ;ld h,230 ld h,254 .ds_jump dec l jr nz,ds_loop xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,200 .loosetime2 djnz loosetime2 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ds_FR_2 ld l,255 djnz ds_loop call bit_close_ei ret ;Dual note with fuzzy addedd .SSpace2 call bit_open_di .SS_LENGHT ld b,100 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .ss_loop dec h jr nz,ss_jump push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF pop hl xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ss_FR_1 ld h,230 .ss_jump dec l jr nz,ss_loop xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ss_FR_2 ld l,255 djnz ss_loop call bit_close_ei ret ;Dual note with LOT of fuzzy addedd .TSpace call bit_open_di .TS_LENGHT ld b,100 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .ts_loop dec h jr nz,ts_jump push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF pop hl xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ts_FR_1 ld h,130 .ts_jump dec l jr nz,ts_loop push hl push af ld a,sndbit_mask ld l,h ld h,0 and (hl) ld l,a pop af xor l IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF pop hl xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .ts_FR_2 ld l,155 djnz ts_loop call bit_close_ei ret .Clackson2 call bit_open_di .CS_LENGHT ld b,200 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .cs_loop dec h jr nz,cs_jump xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,250 .cswait1 djnz cswait1 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .cs_FR_1 ld h,230 .cs_jump inc l jr nz,cs_loop xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,200 .cswait2 djnz cswait2 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .cs_FR_2 ld l,0 djnz cs_loop call bit_close_ei ret .TSpace2 ld a,230 ld (t2_FR_1+1),a xor a ld (t2_FR_2+1),a call bit_open_di .T2_LENGHT ld b,200 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .t2_loop dec h jr nz,t2_jump xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,250 .wait1 djnz wait1 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .t2_FR_1 ld h,230 .t2_jump inc l jr nz,t2_loop push af ld a,(t2_FR_2+1) inc a ld (t2_FR_2+1),a pop af xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF push bc ld b,200 .wait2 djnz wait2 pop bc xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .t2_FR_2 ld l,0 djnz t2_loop call bit_close_ei ret .TSpace3 ld a,230 ld (u2_FR_1+1),a xor a ld (u2_FR_2+1),a call bit_open_di .U2_LENGHT ld b,200 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .u2_loop dec h jr nz,u2_jump push af ld a,(u2_FR_1+1) inc a ld (u2_FR_1+1),a pop af xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .u2_FR_1 ld h,50 .u2_jump inc l jr nz,u2_loop push af ld a,(u2_FR_2+1) inc a ld (u2_FR_2+1),a pop af xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .u2_FR_2 ld l,0 djnz u2_loop call bit_close_ei ret .Squoink ld a,230 ld (qi_FR_1+1),a xor a ld (qi_FR_2+1),a call bit_open_di .qi_LENGHT ld b,200 IF sndbit_port <= 255 ld c,sndbit_port ENDIF .qi_loop dec h jr nz,qi_jump push af ld a,(qi_FR_1+1) dec a ld (qi_FR_1+1),a pop af xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .qi_FR_1 ld h,50 .qi_jump inc l jr nz,qi_loop push af ld a,(qi_FR_2+1) inc a ld (qi_FR_2+1),a pop af xor sndbit_mask IF sndbit_port >= 256 exx out (c),a ;8 T slower exx ELSE out (c),a ENDIF .qi_FR_2 ld l,0 djnz qi_loop call bit_close_ei ret .explosion call bit_open_di ld hl,1 .expl push hl push af ld a,sndbit_mask ld h,0 and (hl) ld l,a pop af xor l IF sndbit_port >= 256 exx out (c),a ;9 T slower exx ELSE out (sndbit_port),a ENDIF pop hl push af ld b,h ld c,l .dly dec bc ld a,b or c jr nz,dly pop af inc hl bit 1,h jr z,expl call bit_close_ei ret ENDIF
; A132727: a(n) = 3 * 2^(n-1) * a(n-1) with a(0) = 1. ; 1,3,18,216,5184,248832,23887872,4586471424,1761205026816,1352605460594688,2077601987473440768,6382393305518410039296,39213424469105111281434624,481854559876363607426268659712,11842057663521512016107978581082112,582060818277409358615739363217347969024,57218906679942449589361642361718174746935296,11249694804530125128865213781452686900645454675968,4423559992258117682671863902287699732324203105865433088,3478829131831536005418999272403920275891187696951964274262016 mov $1,3 mov $2,3 lpb $0 sub $0,1 mul $1,$2 mul $2,2 lpe div $1,3 mov $0,$1
; A020906: Triangle where n-th row is the first n terms of the sequence in reverse order, starting with a(1) = 1 and a(2) = 2. ; 1,2,1,1,2,1,1,1,2,1,2,1,1,2,1,1,2,1,1,2,1,1,1,2,1,1,2,1,1,1,1,2,1,1,2,1,2,1,1,1,2,1,1,2,1,1,2,1,1,1,2,1,1,2,1,2,1,2,1,1,1,2,1,1,2,1,1,2,1,2,1,1,1,2,1,1,2,1,1,1,2,1,2,1,1,1,2,1,1 lpb $0 seq $0,212012 ; Triangle read by rows in which row n lists the number of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order. div $0,2 sub $0,1 lpe add $0,1
.mode dbg .stack 1 .text cvti2f r6,r2 cvti2f r7,r1 movi2fp f0,r6 movi2fp f1,r7 addf f2,f0,f1 subf f3,f0,f1 cvtf2i f4,f2 cvtf2i f5,f3
;; encoding: utf-8 ; ff3_commands.asm ; ; description: ; replaces command handlers ; ; version: ; 0.9 (2018-12-17) ; ; note: ; 'ff3_executeAction.asm' and 'ff3_command_window.asm' must be included before this file ;====================================================================================================== ff3_commands_begin: INIT_PATCH $35,$a71c,$adaf ;INIT_PATCH $35,$a71c,$a7df DECLARE_COMMAND_VARS .macro .iPlayer = $52 .pBaseParam = $57 .pEquips = $59 .pBattleParam = $5b .pTargetBase = $5d .offset = $5f .endm DECLARE_BATTLE_PTR .macro .pActor = $6e .pTareget = $70 .endm ;====================================================================================================== selectSingleTargetAndSetYto2F: ;out a : targetbit ;out y : #2f .targetMode = $b3 .selectedTarget = $b4 lda #0 ;single sel sta <.targetMode lda #$10 ;select target jsr call_2e_9d53 jsr setYtoOffset2F lda <.selectedTarget rts getPlayerLine: .pEquips = $59 lda #$0f jsr setYtoOffsetOf lda [.pEquips],y lsr a rts ;$35:a7cd initMoveArrowSprite initMoveArrowSprite: .iPlayer = $52 lda #0 sta <$18 jsr clearSprites2x2 ;$8adf lda #$5d ;arrow sta $0221 ;sprite.tileIndex lda <.iPlayer asl a asl a rts ;------------------------------------------------------------------------------------------------------ ;ぜんしん(02) ;$35:a71c commandWindow_OnForwardSelected commandWindow_OnForward: DECLARE_COMMAND_VARS jsr getPlayerLine bcc commandWindow_beepAndCancel .ok: jsr initMoveArrowSprite tax lda #$80 ;rightkey pha ;sta $18 ldy #$43 ;sta $0222 lda #$02 bne commandWindow_setupMove ;$a750: ;command 03 ;$35:a750 commandWindow_OnBack commandWindow_OnBack: DECLARE_COMMAND_VARS jsr getPlayerLine bcs commandWindow_beepAndCancel jsr initMoveArrowSprite clc adc #2 tax lda #$40 ;left pha ldy #$03 ;sta $0222 tya ;fall through commandWindow_setupMove: sta <$19 lda commandWindow_arrowCoords,x sta $0220 ;y lda commandWindow_arrowCoords+1,x sta $0223 ;x ;$35:a784 showArrowAndDecideCommand showArrowAndDecide: ;[in] y : spriteFlag ;[in] sp+0 : cancelKey .beginningFlag = $78ba .cancelKey = $18 .commandId = $19 lda .beginningFlag and #$08 beq .normal ;backattack! tya eor #$40 tay lda commandWindow_arrowCoords_backattack+1,x sta $0223 pla ;cancel key eor #%11000000 ;$80 => 40 / 40 => 80 pha .normal: sty $0222 pla ;cancel key sta <.cancelKey .get_input: ;$a7a4: jsr presentCharacter jsr getPad1Input lda <inputBits beq .get_input tax lsr a bcs .OnA lsr a bcs commandWindow_cancelReturn cpx <.cancelKey bne .get_input beq commandWindow_cancelReturn .OnA: jsr requestSoundEffect05 ldx <.commandId bne commandWindow_decideReturn commandWindow_beepAndCancel: jsr requestSoundEffect06 commandWindow_nop: commandWindow_cancelReturn: lda #1 rts commandWindow_decideToTargetAll: ;x = commandId jsr setYtoOffset2F lda #$c0 ;target flag sta <$b5 lda #$ff ;target bit bne commandWindow_setTargetAndCommand ;------------------------------------------------------------------------------------------------------ ;//04:たたかう ;$35:a843 commandWindow_OnFight ; .org $a843 ;commandWindow_OnFight: ; lda #$04 ; ;fall through commandWindow_OnFight: commandWindow_selectSingleTargetAndNext: ;[in] u8 x : commandId .selectedTarget = $b4 txa pha jsr selectSingleTargetAndSetYto2F bne .ok pla lda #1 rts .ok: pla tax lda <.selectedTarget ;fall through commandWindow_setTargetAndCommand: ;[in] u8 a : targetBit ;[in] u8 x : commandId DECLARE_COMMAND_VARS .targetFlag = $b5 sta [.pBattleParam],y ;2f iny lda <.targetFlag sta [.pBattleParam],y ;30 ;fall through commandWindow_decideReturn: ;[in] u8 X : commandId DECLARE_COMMAND_VARS ;pha ;commandId jsr setYtoOffset2E ;9b9b ;pla txa sta [.pBattleParam],y inc <.iPlayer lda #1 rts ;------------------------------------------------------------------------------------------------------ ;//05:ぼうぎょ ;$35:a877 commandWindow_OnGuard ;commandWindow_OnGuard: ; lda #$05 ; bne commandWindow_decideReturn commandWindow_OnGuard = commandWindow_decideReturn ;------------------------------------------------------------------------------------------------------ ;//06:にげる ;$35:a8ab commandWindow_OnEscapeSelected ; .org $a8ab ;commandWindow_OnEscape: ; lda #$06 ; bne commandWindow_decideReturn ;commandWindow_OnEscape = commandWindow_decideReturn ;------------------------------------------------------------------------------------------------------ ;//07:とんずら ;$35:a8b5 commandWindow_OnSneakAway ;commandWindow_OnSneakAway: ; lda #$07 ; bne commandWindow_decideReturn ;commandWindow_OnSneakAway = commandWindow_decideReturn commandWindow_OnEscape: commandWindow_OnSneakAway: lda battleMode lsr a ;escape flag bcc commandWindow_decideReturn bcs commandWindow_beepAndCancel ;------------------------------------------------------------------------------------------------------ ;//08:ジャンプ ;$35:a9ab commandWindow_OnJump ; .org $a9ab commandWindow_OnJump: .selectedTarget = $b4 .targetFlag = $b5 jsr selectSingleTargetAndSetYto2F beq commandWindow_cancelReturn lda <.targetFlag bpl commandWindow_OnJump ldx #$08 lda <.selectedTarget bne commandWindow_setTargetAndCommand ;------------------------------------------------------------------------------------------------------ ;//0d:みやぶる ;$35:ab07 commandWindow_OnDetect ; .org $ab07 ;commandWindow_OnDetect: ; lda #$0d ; bne commandWindow_selectSingleTargetAndNext commandWindow_OnDetect = commandWindow_selectSingleTargetAndNext ;------------------------------------------------------------------------------------------------------ ;//0c:しらべる ;$35:ab6e commandWindow_OnInspect ; .org $ab6e ;commandWindow_OnInspect: ; lda #$0c ; bne commandWindow_selectSingleTargetAndNext commandWindow_OnInspect = commandWindow_selectSingleTargetAndNext ;------------------------------------------------------------------------------------------------------ ;//0E:ぬすむ ;$35:ab9f commandWindow_OnSteal ; .org $ab9f ;commandWindow_OnSteal: ; lda #$0e ; bne commandWindow_selectSingleTargetAndNext commandWindow_OnSteal = commandWindow_selectSingleTargetAndNext ;------------------------------------------------------------------------------------------------------ ;//0F:ためる ;$35:ac65 commandWindow_OnChargeSelected ; .org $ac65 ;commandWindow_OnCharge: ; lda #$0f ; bne commandWindow_decideReturn commandWindow_OnCharge = commandWindow_decideReturn ;------------------------------------------------------------------------------------------------------ ;//10:うたう ;$35:acd0 commandWindow_OnSing ; .org $acd0 ;commandWindow_OnSing: ; lda #$10 ; bne commandWindow_selectSingleTargetAndNext commandWindow_OnSing = commandWindow_selectSingleTargetAndNext ;------------------------------------------------------------------------------------------------------ ;//11:おどかす ;$35:ad0c commandWindow_OnIntimidate ; .org $ad0c ;commandWindow_OnIntimidate: ; lda #$11 ; bne commandWindow_decideReturn commandWindow_OnIntimidate = commandWindow_decideReturn ;------------------------------------------------------------------------------------------------------ ;//12:おうえん ;$35:ad6b commandWindow_OnCheer ; .org $ad6b ;commandWindow_OnCheer: ; lda #$12 ; bne commandWindow_decideReturn commandWindow_OnCheer = commandWindow_decideReturn ;------------------------------------------------------------------------------------------------------ ;//0b:ちけい ;$35:aa22 commandWindow_0b ; .org $aa22 .ifdef EXTEND_GEOMANCE commandWindow_OnGeomance = commandWindow_decideToTargetAll .else commandWindow_OnGeomance: .geomanceTargetFlag = $7a;$35:ab06 .db $7a //??? jsr getCurrentTerrain tax inx lda #.geomanceTargetFlag .shift_loop: asl a dex bne .shift_loop bcc .target_all jsr dispatchBattleFunction_06 ;802a ldx $7e99 lda #$80 bmi .store .target_all: dex lda #$c0 .store: .targetFlag = $b5 sta <.targetFlag jsr setYtoOffset2F txa ldx #$0b bne commandWindow_setTargetAndCommand .endif ;EXTEND_GEOMANCE ;====================================================================================================== ;a823 commandWindow_arrowCoords: .db $34,$B4,$34,$D4, $50,$B4,$50,$D4, $6C,$B4,$6C,$D4, $88,$B4,$88,$D4 ;a833 commandWindow_arrowCoords_backattack: .db $34,$44,$34,$24, $50,$44,$50,$24, $6C,$44,$6C,$24, $88,$44,$88,$24 ;$a7df: ;====================================================================================================== ;//02:ぜんしん ;$35:a7df command_forward ; .org $a7df command_forward: ; ldx #$39+$02 ; bne command_move command_back: ; ldx #$39+$03 command_move: DECLARE_COMMAND_VARS .pActor = $6e ldy #$33 lda [.pActor],y eor #$01 ;invert line flag sta [.pActor],y jsr getPlayerOffsetFromActor clc adc #$0f tay lda [.pEquips],y eor #$01 sta [.pEquips],y ;fall through setupNullTargetActionType01: ;[in] x : actionId * 2 lda #$ff sta targetName ;78d8 ;fall through setupActionType01: ;[in] x : actionId * 2 lda #1 sta battleProcessType setupActionName: ;[in] x : actionId * 2 txa lsr a clc adc #$39 ;convert actionid to actionNameId sta actionName ;78d7 rts ;$a816: getPlayerOffsetFromActor: DECLARE_COMMAND_VARS jsr getActor2C and #7 sta <.iPlayer jmp getPlayerOffset ;$a881 ;$35:a881 command_guard command_guard: DECLARE_COMMAND_VARS .pActor = $6e jsr setupNullTargetActionType01 jsr setXtoActorIndex ldy #$23 lda [.pActor],y sta $7ce4,x bpl .def_under_80 lda #$ff bne .store .def_under_80: asl a .store: sta [.pActor],y rts ;====================================================================================================== ;$35:a8bf command_escape //06 command_escape: DECLARE_COMMAND_VARS .pActor = $6e .rate = $24 ;ldx #$39+$06 jsr setupNullTargetActionType01 lda #100 jsr getSys1Random pha ;rand jsr getActor2C bmi command_escape_enemy .actor_is_player: .pEnemy = $24 ldx #0 txa tay stx <$18 stx <$19 stx <$1a stx <$1b INIT16 <.pEnemy,$7835 ldx #7 .sum_enemy_lv: lda $7da7,x ;group bmi .next clc lda [.pEnemy],y adc <$18 sta <$18 lda #0 adc <$19 sta <$19 inc <$1a .next: ;SUB16 <.pEnemy,$0040 SUB16by8 <.pEnemy,#$40 dex bpl .sum_enemy_lv jsr div_16 ldy #$2a lda [.pActor],y clc adc #25 sec sbc <$1c ;average lv of enemies bcs .rate_plus lda #0 .rate_plus: .beginningMode = $78ba sta <.rate pla ;rand cmp <.rate bcc command_escape_possible lda .beginningMode lsr a ;party surprise attack bcs command_escape_possible ;.fail: command_escape_fail: lda #$1f ;"にげられない!" ;sta battleMessages ;rts jmp addBattleMessage ;enemy: ;a978 command_escape_enemy: .pActor = $6e pla ;rand ldy #$22 cmp [.pActor],y bcs command_escape_fail lda #$1e sta battleMessages jsr setXtoActorIndex lda #0 jsr flagTargetBit pha ;sta $78d4 txa asl a tax lda <$f0,x ora #$80 sta <$f0,x ;rts pla bne command_escape_succeeded ;//07 ;$35:a93b command_sneakAway //[sneak away] command_sneakAway: ;ldx #$39+$07 jsr setupNullTargetActionType01 command_escape_possible: DECLARE_COMMAND_VARS lda battleMode ;7ed8 lsr a ;escape forbidden flag bcs command_escape_fail ldx #3 .check_confused_member: stx <.iPlayer jsr getPlayerOffset tay iny iny lda [.pBattleParam],y and #$20 bne command_escape_fail dex bpl .check_confused_member ;ok lda #2 sta $78d3 lda #$f0 command_escape_succeeded: sta $78d4 lda #$1e ;"にげだした・・・・" jmp addBattleMessage ;sta battleMessages ;rts ;====================================================================================================== ;$a9d8 ;$35:a9d8 command_jump command_jump: DECLARE_COMMAND_VARS .pActor = $6e ;ldx #$39+$08 jsr setupActionType01 ldy #$01 lda [.pActor],y and #$28 beq .ok ;fail lda #$18 sta effectHandlerIndex jmp command_setNoEffectAndReturn .ok: ;$a9f6: jsr setXtoActorIndex16 inx lda <$f0,x ora #$01 sta <$f0,x iny iny lda #$09 sta [.pActor],y ;2e rts ; ;$35:aa11 command_09 //landing command_land: .pActor = $6e ;; XXX: ;; battle.process_poison will update ;; battle.command_chain_id ($78c5). ;; if a character is to execute 'landing' right after ;; poison damage processed, it never get 'landed' due to ;; uninitialized value. ;; originally this function assumes that variables ;; further passed down to worker functions have correct value. ;; but as mentioned above this is not the case. ;; see also `$34:8213 initBattleVars`. lda #0 ;; this variable ($78d5) won't get initialized by `$34:8212 initBattleVars`. ;; fortunately, other related variables do get initialized by that function. sta battle.command_chain_id ldy #2 lda [.pActor],y and #$fe sta [.pActor],y ldy #$27 lda #CHARGE_COUNT_JUMP sta [.pActor],y jmp dispatchBattleFunction_03 ;801e ;$aa22: ;====================================================================================================== ;$aa5d: ;$35:aa5d command_0b .ifdef EXTEND_GEOMANCE geomance_rates: ; じしん りゅうさ かまいたち そこなしぬま きゅうりゅう うずしお たつまき なだれ .db $f0,$60,$00,$30 .db $0f,$50,$00,$00 .db $00,$f0,$00,$50 .db $00,$0f,$00,$30 .db $00,$50,$f0,$00 .db $00,$00,$5f,$00 .db $00,$50,$00,$f0 .db $20,$00,$00,$08 command_geomance: DECLARE_COMMAND_VARS .pActor = $6e .rates = $18 jsr getActor2C ora #$10 sta [.pActor],y jsr getCurrentTerrain tay iny tya asl a asl a tay dey ldx #7 .cache_rates: lda geomance_rates,y pha and #$0f sta <.rates,x dex pla jsr $fd45 ;a>>=4 sta <.rates,x dey dex bpl .cache_rates ldx #7 lda #0 .sum_rates: .bounds = $7400 clc adc <.rates,x sta .bounds,x dex bpl .sum_rates ;a = sum of rates jsr getSys1Random ldx #7 .find_id: cmp .bounds,x bcc .found dex bpl .find_id .found: .geomanceTargetFlag = $7a .pTarget = $70 ;x = terrain index txa pha lda #.geomanceTargetFlag .shift_loop: asl a dex bpl .shift_loop bcc .target_all ;no more processing jsr dispatchBattleFunction_06 ;802a ldx #1 jsr targetBitToCharIndex ;y = index from $7e99 tya pha INIT16 <.pTarget,$7675 .get_target_ptr: ADD16by8 <.pTarget,#$40 dey bne .get_target_ptr lda #$80 ldy #$30 sta [.pActor],y dey pla sta [.pActor],y .target_all: pla clc adc #$50 .else ;EXTEND_GEOMANCE command_geomance: DECLARE_COMMAND_VARS .pActor = $6e jsr getActor2C ora #$10 sta [.pActor],y jsr getCurrentTerrain ;aac3 clc adc #$50 .endif ;EXTEND_GEOMANCE ldy #$2e sta [.pActor],y sta <$1a .ifdef BOOST_GEOMANCER ldy #$0 lda [.pActor],y pha ldy #$0f clc adc [.pActor],y ldy #0 sta [.pActor],y jsr command_magic pla ldy #$0 sta [.pActor],y .else jsr command_magic .endif ;BOOST_GEOMANCER inc <$cc lda #$14 sta effectHandlerIndex lda play_effectTargetBits ;7e9b bne command_doReturn ;failed. nature bites player lda #3 sta <$54 ;$aac3: damageActorByQuoterHalf: ;[out] x : cacheIndex .maxhp = $18 .pActor = $6e .actorStatusCache = $f0 jsr setXtoActorIndex16 ldy #5 lda [.pActor],y sta $7e5f,x iny lda [.pActor],y lsr a ror $7e5f,x lsr a sta $7e60,x ror $7e5f,x ldy #3 sec lda [.pActor],y sbc $7e5f,x sta [.pActor],y iny lda [.pActor],y sbc $7e60,x sta [.pActor],y dey ora [.pActor],y ;a9d4 beq .result_dead bcs .finish .result_dead: lda #$80 sta <.actorStatusCache,x asl a sta [.pActor],y iny sta [.pActor],y .finish: command_doReturn: rts ;$35:aac3 getCurrentTerrain getCurrentTerrain: lda $7ce3 cmp #$08 bcc .finish ldx #$05 cmp #$12 beq .use_low ;bne .load_param ; ;lda #$55 ; lda #$05 ; rts .load_param: clc lda $74c8 ;field $48 adc #$4e sta <$46 lda #0 adc #$a2 sta <$47 lda #$1a sta <$4a ;current bank lda #1 sta <$4b ;size lda #0 ;src bank jsr copyTo7400 ldx $7400 lda battleMode ;$7ed8 and #8 bne .use_high .use_low: txa and #$0f .finish: rts .use_high: txa jmp $fd45 ;a>>4 ;$35:ab06 .db $7a //??? ;====================================================================================================== ;setEffectHandlerTo18 = $ab66 ;$35:ab0c command_detect command_detect: .pTarget = $70 ;ldx #$39+$0d jsr setupNoMotionType01 ldy #1 lda [.pTarget],y bmi command_setNoEffectAndReturn .ok: ;$ab27: .count = $18 ldy #$12 lda [.pTarget],y ldy #0 ;ldx battleMessageCount sty <.count .queue_weak_points: asl a bcc .next inc <.count pha ;pha ;tya ;;clc (always set) ;adc #$47 ;sta battleMessages,x ;pla ;inx ;stx battleMessageCount tya ;carry always be set adc #$47 jsr addBattleMessage pla .next: iny cpy #7 bne .queue_weak_points lda <.count bne .finish lda #$43 jsr addBattleMessage ;sta battleMessages,x .finish: rts command_setNoEffectAndReturn: ;ldx #$3b ;stx battleMessages ;rts lda #$3b jmp addBattleMessage ;====================================================================================================== ;$35:ab73 command_inspect command_inspect: .pTarget = $70 ;jsr setEffectHandlerTo18 ldy #6 ldx #3 .copy_hp: lda [.pTarget],y sta $78e4,x dey dex bpl .copy_hp ldy #1 ldx #$3f lda [.pTarget],y bpl .ok ldx #$3b .ok: stx battleMessages ldx #$0c*2 ;fall through setupNoMotionType01: ;[in] x : actionId * 2 (initial value on handler entry) jsr setupActionType01 setEffectHandlerTo18 ;18=do nothing lda #$18 sta effectHandlerIndex inc <$cc rts ;====================================================================================================== ;$35:aba4 command_steal command_steal: .pActor = $6e .pTarget = $70 ;ldx #$39+$0E jsr setupNoMotionType01 ldy #$2c lda [.pTarget],y bmi .target_is_enemy .fail: lda #$35 ;"ぬすみそこなった" jmp addBattleMessage ;sta battleMessages ;rts .target_is_enemy: ldy #1 lda [.pTarget],y and #$e8 bne .fail .rate = $24 clc dey lda [.pActor],y ldy #$0f adc [.pActor],y sta <.rate lda #$ff jsr getSys1Random cmp <.rate bcs .fail .dropTableIndex = $18 ldy #$36 lda [.pTarget],y and #$1f sta <.dropTableIndex ; lda #$08 sta <$1a INIT16 <$20,$9b80 lda #$08 ldx #$00 ldy #$1a jsr loadTo7400Ex .dropList = $7400 lda #$ff jsr getSys1Random ldx #3 .get_index: cmp .bounds,x bcs .found_index dex bpl .get_index .found_index: lda .dropList,x tay beq .fail jsr .findItem bmi .put_drop lda #0 jsr .findItem bpl .fail .put_drop: inc backpackItems-$c0+1,x lda backpackItems-$c0+1,x cmp #100 bcc .store_id lda #99 sta backpackItems-$c0+1,x .store_id: tya ;itemid sta backpackItems-$c0,x .finish: sta $78e4 lda #$29 jmp addBattleMessage ;sta battleMessages ;rts .findItem: ;[in] a : itemid to find ldx #$c0 .find_loop: cmp backpackItems-$c0,x beq .found inx inx bne .find_loop .found: txa rts .bounds: .db $00,$30,$60,$90 ;$ac65 ;====================================================================================================== ;$35:ac6f command_charge //0F command_charge: .pActor = $6e ;ldx #$39+$0f jsr setupActionType01 ldx #$3b ;"こうかがなかった" ldy #1 lda [.pActor],y and #$28 bne .fail ldy #$27 lda [.pActor],y clc adc #CHARGE_INCREMENT cmp #CHARGE_MAX bcs .bomb ;ok sta [.pActor],y lda #0 sta $7e93 rts .bomb: ;bomb lda #0 sta [.pActor],y ldy #4 lda [.pActor],y lsr a sta [.pActor],y dey lda [.pActor],y ror a sta [.pActor],y iny ora [.pActor],y bne .bomb_alive ;jsr setXtoActorIndex ;asl a ;tax jsr setXtoActorIndex16 lda <$f0,x ora #$80 sta <$f0,x .bomb_alive: lda #1 sta $7e93 ldx #$2f ;"ためすぎてじばくした!" .fail: stx battleMessages rts ;====================================================================================================== ;$35:acd5 command_sing command_sing: .pActor = $6e ;竪琴チェック オリジナルは装備欄のIDによる ldy #$31 lda [.pActor],y iny ora [.pActor],y and #$08 ;harp beq .fail jmp command_fight .fail: lda #1 sta battleProcessType lda #$42 ;"たてごとがないのでうたえない" sta battleMessages lda #$18 sta effectHandlerIndex rts ;====================================================================================================== ;$35:ad16 command_intimidate command_intimidate: DECLARE_COMMAND_VARS lda battleMode lsr a ;escape forbidden bcc .ok jmp command_setNoEffectAndReturn .ok: ldy #0 .ifdef BOOST_INTIMIDATE ldx #7 .set_lv: lda [.pTargetBase],y lsr a sta [.pTargetBase],y lsr a clc adc [.pTargetBase],y sta [.pTargetBase],y ;ADD16 <.pTargetBase,$0040 ADD16by8 <.pTargetBase,#$40 dex bpl .set_lv .else sec lda [.pTargetBase],y sbc #3 bcs .diff_plus tya ;0 .diff_plus: ldx #7 .set_lv: pha sta [.pTargetBase],y ;ADD16 <.pTargetBase,$0040 ADD16by8 <.pTargetBase,#$40 pla dex bpl .set_lv .endif ;BOOST_INTIMIDATE INIT16 <.pTargetBase,$7675 lda #$32 sta battleMessages lda #$ff sta targetName ;$78d8 ;ldx #$39+$11 ldx #$11*2 jmp setupActionType01 ;$ad6b: ;} ;====================================================================================================== ;$35:ad75 command_cheer command_cheer: DECLARE_COMMAND_VARS ldx #3 .for_each_player: stx <.iPlayer jsr getPlayerOffset clc .ifdef BOOST_CHEER adc #$38 ;bonus atk tay lda [.pBattleParam],y ;clc ;always cleared adc #$20 bcc .next lda #$ff sta targetName .else adc #$19 tay lda [.pBattleParam],y ;clc adc #10 bcc .next lda #$ff sta targetName .endif ;BOOST_CHEER .next: sta [.pBattleParam],y dex bpl .for_each_player ldx #$31 stx battleMessages ;ldx #$39+$12 ldx #$12*2 jmp setupActionType01 ff3_commands_end: ;====================================================================================================== ; RESTORE_PC ff3_commands_begin
// Copyright (c) YugaByte, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software distributed under the License // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations // under the License. #include <set> #include <google/protobuf/util/message_differencer.h> #include "yb/master/catalog_manager.h" #include "yb/master/catalog_manager-internal.h" #include "yb/master/catalog_entity_info.h" #include "yb/master/cdc_rpc_tasks.h" #include "yb/master/cluster_balance.h" #include "yb/cdc/cdc_service.h" #include "yb/client/schema.h" #include "yb/client/session.h" #include "yb/client/table.h" #include "yb/client/table_handle.h" #include "yb/client/table_alterer.h" #include "yb/client/yb_op.h" #include "yb/common/common.pb.h" #include "yb/common/ql_name.h" #include "yb/common/wire_protocol.h" #include "yb/consensus/consensus.h" #include "yb/gutil/bind.h" #include "yb/gutil/strings/join.h" #include "yb/gutil/strings/substitute.h" #include "yb/master/master_defaults.h" #include "yb/master/master_util.h" #include "yb/master/sys_catalog.h" #include "yb/master/sys_catalog-internal.h" #include "yb/master/async_snapshot_tasks.h" #include "yb/master/async_rpc_tasks.h" #include "yb/master/encryption_manager.h" #include "yb/rpc/messenger.h" #include "yb/tablet/operations/snapshot_operation.h" #include "yb/tserver/backup.proxy.h" #include "yb/tserver/service_util.h" #include "yb/util/cast.h" #include "yb/util/flag_tags.h" #include "yb/util/scope_exit.h" #include "yb/util/service_util.h" #include "yb/util/status.h" #include "yb/util/tostring.h" #include "yb/util/string_util.h" #include "yb/util/random_util.h" #include "yb/cdc/cdc_consumer.pb.h" using namespace std::literals; using namespace std::placeholders; using std::string; using std::unique_ptr; using std::vector; using google::protobuf::RepeatedPtrField; using google::protobuf::util::MessageDifferencer; using strings::Substitute; DEFINE_uint64(cdc_state_table_num_tablets, 0, "Number of tablets to use when creating the CDC state table." "0 to use the same default num tablets as for regular tables."); DEFINE_int32(cdc_wal_retention_time_secs, 4 * 3600, "WAL retention time in seconds to be used for tables for which a CDC stream was " "created."); DECLARE_int32(master_rpc_timeout_ms); DEFINE_bool(enable_transaction_snapshots, true, "The flag enables usage of transaction aware snapshots."); TAG_FLAG(enable_transaction_snapshots, hidden); TAG_FLAG(enable_transaction_snapshots, advanced); TAG_FLAG(enable_transaction_snapshots, runtime); namespace yb { using rpc::RpcContext; using pb_util::ParseFromSlice; namespace master { namespace enterprise { //////////////////////////////////////////////////////////// // Snapshot Loader //////////////////////////////////////////////////////////// class SnapshotLoader : public Visitor<PersistentSnapshotInfo> { public: explicit SnapshotLoader(CatalogManager* catalog_manager) : catalog_manager_(catalog_manager) {} CHECKED_STATUS Visit(const SnapshotId& snapshot_id, const SysSnapshotEntryPB& metadata) override { if (TryFullyDecodeTxnSnapshotId(snapshot_id)) { // Transaction aware snapshots should be already loaded. return Status::OK(); } return VisitNonTransactionAwareSnapshot(snapshot_id, metadata); } CHECKED_STATUS VisitNonTransactionAwareSnapshot( const SnapshotId& snapshot_id, const SysSnapshotEntryPB& metadata) { // Setup the snapshot info. auto snapshot_info = make_scoped_refptr<SnapshotInfo>(snapshot_id); auto l = snapshot_info->LockForWrite(); l->mutable_data()->pb.CopyFrom(metadata); // Add the snapshot to the IDs map (if the snapshot is not deleted). auto emplace_result = catalog_manager_->non_txn_snapshot_ids_map_.emplace( snapshot_id, std::move(snapshot_info)); CHECK(emplace_result.second) << "Snapshot already exists: " << snapshot_id; LOG(INFO) << "Loaded metadata for snapshot (id=" << snapshot_id << "): " << emplace_result.first->second->ToString() << ": " << metadata.ShortDebugString(); l->Commit(); return Status::OK(); } private: CatalogManager *catalog_manager_; DISALLOW_COPY_AND_ASSIGN(SnapshotLoader); }; //////////////////////////////////////////////////////////// // CDC Stream Loader //////////////////////////////////////////////////////////// class CDCStreamLoader : public Visitor<PersistentCDCStreamInfo> { public: explicit CDCStreamLoader(CatalogManager* catalog_manager) : catalog_manager_(catalog_manager) {} Status Visit(const CDCStreamId& stream_id, const SysCDCStreamEntryPB& metadata) REQUIRES(catalog_manager_->lock_) { DCHECK(!ContainsKey(catalog_manager_->cdc_stream_map_, stream_id)) << "CDC stream already exists: " << stream_id; scoped_refptr<TableInfo> table = FindPtrOrNull(*catalog_manager_->table_ids_map_, metadata.table_id()); if (!table) { LOG(ERROR) << "Invalid table ID " << metadata.table_id() << " for stream " << stream_id; // TODO (#2059): Potentially signals a race condition that table got deleted while stream was // being created. // Log error and continue without loading the stream. return Status::OK(); } // Setup the CDC stream info. auto stream = make_scoped_refptr<CDCStreamInfo>(stream_id); auto l = stream->LockForWrite(); l->mutable_data()->pb.CopyFrom(metadata); // If the table has been deleted, then mark this stream as DELETING so it can be deleted by the // catalog manager background thread. if (table->LockForRead()->data().is_deleting() && !l->data().is_deleting()) { l->mutable_data()->pb.set_state(SysCDCStreamEntryPB::DELETING); } // Add the CDC stream to the CDC stream map. catalog_manager_->cdc_stream_map_[stream->id()] = stream; l->Commit(); LOG(INFO) << "Loaded metadata for CDC stream " << stream->ToString() << ": " << metadata.ShortDebugString(); return Status::OK(); } private: CatalogManager *catalog_manager_; DISALLOW_COPY_AND_ASSIGN(CDCStreamLoader); }; //////////////////////////////////////////////////////////// // Universe Replication Loader //////////////////////////////////////////////////////////// class UniverseReplicationLoader : public Visitor<PersistentUniverseReplicationInfo> { public: explicit UniverseReplicationLoader(CatalogManager* catalog_manager) : catalog_manager_(catalog_manager) {} Status Visit(const std::string& producer_id, const SysUniverseReplicationEntryPB& metadata) { DCHECK(!ContainsKey(catalog_manager_->universe_replication_map_, producer_id)) << "Producer universe already exists: " << producer_id; // Setup the universe replication info. UniverseReplicationInfo* const ri = new UniverseReplicationInfo(producer_id); auto l = ri->LockForWrite(); l->mutable_data()->pb.CopyFrom(metadata); if (!l->data().is_active() && !l->data().is_deleted_or_failed()) { // Replication was not fully setup. LOG(WARNING) << "Universe replication in transient state: " << producer_id; // TODO: Should we delete all failed universe replication items? } // Add universe replication info to the universe replication map. catalog_manager_->universe_replication_map_[ri->id()] = ri; l->Commit(); LOG(INFO) << "Loaded metadata for universe replication " << ri->ToString(); VLOG(1) << "Metadata for universe replication " << ri->ToString() << ": " << metadata.ShortDebugString(); return Status::OK(); } private: CatalogManager *catalog_manager_; DISALLOW_COPY_AND_ASSIGN(UniverseReplicationLoader); }; //////////////////////////////////////////////////////////// // CatalogManager //////////////////////////////////////////////////////////// CatalogManager::~CatalogManager() { if (StartShutdown()) { CompleteShutdown(); } } void CatalogManager::CompleteShutdown() { snapshot_coordinator_.Shutdown(); // Call shutdown on base class before exiting derived class destructor // because BgTasks is part of base & uses this derived class on Shutdown. super::CompleteShutdown(); } Status CatalogManager::RunLoaders(int64_t term) { RETURN_NOT_OK(super::RunLoaders(term)); // Clear the snapshots. non_txn_snapshot_ids_map_.clear(); // Clear CDC stream map. cdc_stream_map_.clear(); // Clear universe replication map. universe_replication_map_.clear(); LOG(INFO) << __func__ << ": Loading snapshots into memory."; unique_ptr<SnapshotLoader> snapshot_loader(new SnapshotLoader(this)); RETURN_NOT_OK_PREPEND( sys_catalog_->Visit(snapshot_loader.get()), "Failed while visiting snapshots in sys catalog"); LOG(INFO) << __func__ << ": Loading CDC streams into memory."; auto cdc_stream_loader = std::make_unique<CDCStreamLoader>(this); RETURN_NOT_OK_PREPEND( sys_catalog_->Visit(cdc_stream_loader.get()), "Failed while visiting CDC streams in sys catalog"); LOG(INFO) << __func__ << ": Loading universe replication info into memory."; auto universe_replication_loader = std::make_unique<UniverseReplicationLoader>(this); RETURN_NOT_OK_PREPEND( sys_catalog_->Visit(universe_replication_loader.get()), "Failed while visiting universe replication info in sys catalog"); return Status::OK(); } Status CatalogManager::CreateSnapshot(const CreateSnapshotRequestPB* req, CreateSnapshotResponsePB* resp, RpcContext* rpc) { LOG(INFO) << "Servicing CreateSnapshot request: " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); if (FLAGS_enable_transaction_snapshots && req->transaction_aware()) { return CreateTransactionAwareSnapshot(*req, resp, rpc); } return CreateNonTransactionAwareSnapshot(req, resp, rpc); } Status CatalogManager::CreateNonTransactionAwareSnapshot( const CreateSnapshotRequestPB* req, CreateSnapshotResponsePB* resp, RpcContext* rpc) { SnapshotId snapshot_id; { std::lock_guard<LockType> l(lock_); TRACE("Acquired catalog manager lock"); // Verify that the system is not in snapshot creating/restoring state. if (!current_snapshot_id_.empty()) { return STATUS(IllegalState, Format( "Current snapshot id: $0. Parallel snapshot operations are not supported" ": $1", current_snapshot_id_, req), MasterError(MasterErrorPB::PARALLEL_SNAPSHOT_OPERATION)); } // Create a new snapshot UUID. snapshot_id = GenerateIdUnlocked(SysRowEntry::SNAPSHOT); } vector<scoped_refptr<TabletInfo>> all_tablets; // Create in memory snapshot data descriptor. scoped_refptr<SnapshotInfo> snapshot(new SnapshotInfo(snapshot_id)); snapshot->mutable_metadata()->StartMutation(); snapshot->mutable_metadata()->mutable_dirty()->pb.set_state(SysSnapshotEntryPB::CREATING); auto tables = VERIFY_RESULT(CollectTables(req->tables(), req->add_indexes(), true /* include_parent_colocated_table */)); for (const auto& table : tables) { RETURN_NOT_OK(snapshot->AddEntries(table)); all_tablets.insert(all_tablets.end(), table.tablet_infos.begin(), table.tablet_infos.end()); } VLOG(1) << "Snapshot " << snapshot->ToString() << ": PB=" << snapshot->mutable_metadata()->mutable_dirty()->pb.DebugString(); // Write the snapshot data descriptor to the system catalog (in "creating" state). RETURN_NOT_OK(CheckLeaderStatus( sys_catalog_->AddItem(snapshot.get(), leader_ready_term()), "inserting snapshot into sys-catalog")); TRACE("Wrote snapshot to system catalog"); // Commit in memory snapshot data descriptor. snapshot->mutable_metadata()->CommitMutation(); // Put the snapshot data descriptor to the catalog manager. { std::lock_guard<LockType> l(lock_); TRACE("Acquired catalog manager lock"); // Verify that the snapshot does not exist. auto inserted = non_txn_snapshot_ids_map_.emplace(snapshot_id, snapshot).second; RSTATUS_DCHECK(inserted, IllegalState, Format("Snapshot already exists: $0", snapshot_id)); current_snapshot_id_ = snapshot_id; } // Send CreateSnapshot requests to all TServers (one tablet - one request). for (const scoped_refptr<TabletInfo>& tablet : all_tablets) { TRACE("Locking tablet"); auto l = tablet->LockForRead(); LOG(INFO) << "Sending CreateTabletSnapshot to tablet: " << tablet->ToString(); // Send Create Tablet Snapshot request to each tablet leader. SendCreateTabletSnapshotRequest( tablet, snapshot_id, HybridTime::kInvalid, TabletSnapshotOperationCallback()); } resp->set_snapshot_id(snapshot_id); LOG(INFO) << "Successfully started snapshot " << snapshot_id << " creation"; return Status::OK(); } void CatalogManager::Submit(std::unique_ptr<tablet::Operation> operation) { operation->state()->SetTablet(tablet_peer()->tablet()); tablet_peer()->Submit(std::move(operation), leader_ready_term()); } Status CatalogManager::CreateTransactionAwareSnapshot( const CreateSnapshotRequestPB& req, CreateSnapshotResponsePB* resp, rpc::RpcContext* rpc) { SysRowEntries entries; auto tables = VERIFY_RESULT(CollectTables(req.tables(), req.add_indexes(), true /* include_parent_colocated_table */)); for (const auto& table : tables) { // TODO(txn_snapshot) use single lock to resolve all tables to tablets SnapshotInfo::AddEntries(table, entries.mutable_entries(), /* tablet_infos= */ nullptr); } auto snapshot_id = VERIFY_RESULT(snapshot_coordinator_.Create( entries, req.imported(), master_->clock()->MaxGlobalNow(), rpc->GetClientDeadline())); resp->set_snapshot_id(snapshot_id.data(), snapshot_id.size()); return Status::OK(); } Status CatalogManager::ListSnapshots(const ListSnapshotsRequestPB* req, ListSnapshotsResponsePB* resp) { RETURN_NOT_OK(CheckOnline()); auto txn_snapshot_id = TryFullyDecodeTxnSnapshotId(req->snapshot_id()); { std::shared_lock<LockType> l(lock_); TRACE("Acquired catalog manager lock"); if (!current_snapshot_id_.empty()) { resp->set_current_snapshot_id(current_snapshot_id_); } auto setup_snapshot_pb_lambda = [resp](scoped_refptr<SnapshotInfo> snapshot_info) { auto snapshot_lock = snapshot_info->LockForRead(); SnapshotInfoPB* const snapshot = resp->add_snapshots(); snapshot->set_id(snapshot_info->id()); *snapshot->mutable_entry() = snapshot_info->metadata().state().pb; }; if (req->has_snapshot_id()) { if (!txn_snapshot_id) { TRACE("Looking up snapshot"); scoped_refptr<SnapshotInfo> snapshot_info = FindPtrOrNull(non_txn_snapshot_ids_map_, req->snapshot_id()); if (snapshot_info == nullptr) { return STATUS(InvalidArgument, "Could not find snapshot", req->snapshot_id(), MasterError(MasterErrorPB::SNAPSHOT_NOT_FOUND)); } setup_snapshot_pb_lambda(snapshot_info); } } else { for (const SnapshotInfoMap::value_type& entry : non_txn_snapshot_ids_map_) { setup_snapshot_pb_lambda(entry.second); } } } return snapshot_coordinator_.ListSnapshots( txn_snapshot_id, req->list_deleted_snapshots(), resp); } Status CatalogManager::ListSnapshotRestorations(const ListSnapshotRestorationsRequestPB* req, ListSnapshotRestorationsResponsePB* resp) { RETURN_NOT_OK(CheckOnline()); TxnSnapshotRestorationId restoration_id = TxnSnapshotRestorationId::Nil(); if (!req->restoration_id().empty()) { restoration_id = VERIFY_RESULT(FullyDecodeTxnSnapshotRestorationId(req->restoration_id())); } TxnSnapshotId snapshot_id = TxnSnapshotId::Nil(); if (!req->snapshot_id().empty()) { snapshot_id = VERIFY_RESULT(FullyDecodeTxnSnapshotId(req->snapshot_id())); } return snapshot_coordinator_.ListRestorations(restoration_id, snapshot_id, resp); } Status CatalogManager::RestoreSnapshot(const RestoreSnapshotRequestPB* req, RestoreSnapshotResponsePB* resp) { LOG(INFO) << "Servicing RestoreSnapshot request: " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); auto txn_snapshot_id = TryFullyDecodeTxnSnapshotId(req->snapshot_id()); if (txn_snapshot_id) { TxnSnapshotRestorationId id = VERIFY_RESULT(snapshot_coordinator_.Restore(txn_snapshot_id)); resp->set_restoration_id(id.data(), id.size()); return Status::OK(); } return RestoreNonTransactionAwareSnapshot(req->snapshot_id()); } Status CatalogManager::RestoreNonTransactionAwareSnapshot(const string& snapshot_id) { std::lock_guard<LockType> l(lock_); TRACE("Acquired catalog manager lock"); if (!current_snapshot_id_.empty()) { return STATUS( IllegalState, Format( "Current snapshot id: $0. Parallel snapshot operations are not supported: $1", current_snapshot_id_, snapshot_id), MasterError(MasterErrorPB::PARALLEL_SNAPSHOT_OPERATION)); } TRACE("Looking up snapshot"); scoped_refptr<SnapshotInfo> snapshot = FindPtrOrNull(non_txn_snapshot_ids_map_, snapshot_id); if (snapshot == nullptr) { return STATUS(InvalidArgument, "Could not find snapshot", snapshot_id, MasterError(MasterErrorPB::SNAPSHOT_NOT_FOUND)); } auto snapshot_lock = snapshot->LockForWrite(); if (snapshot_lock->data().started_deleting()) { return STATUS(NotFound, "The snapshot was deleted", snapshot_id, MasterError(MasterErrorPB::SNAPSHOT_NOT_FOUND)); } if (!snapshot_lock->data().is_complete()) { return STATUS(IllegalState, "The snapshot state is not complete", snapshot_id, MasterError(MasterErrorPB::SNAPSHOT_IS_NOT_READY)); } TRACE("Updating snapshot metadata on disk"); SysSnapshotEntryPB& snapshot_pb = snapshot_lock->mutable_data()->pb; snapshot_pb.set_state(SysSnapshotEntryPB::RESTORING); // Update tablet states. SetTabletSnapshotsState(SysSnapshotEntryPB::RESTORING, &snapshot_pb); // Update sys-catalog with the updated snapshot state. // The mutation will be aborted when 'l' exits the scope on early return. RETURN_NOT_OK(CheckLeaderStatus( sys_catalog_->UpdateItem(snapshot.get(), leader_ready_term()), "updating snapshot in sys-catalog")); // CataloManager lock 'lock_' is still locked here. current_snapshot_id_ = snapshot_id; // Restore all entries. for (const SysRowEntry& entry : snapshot_pb.entries()) { RETURN_NOT_OK(RestoreEntry(entry, snapshot_id)); } // Commit in memory snapshot data descriptor. TRACE("Committing in-memory snapshot state"); snapshot_lock->Commit(); LOG(INFO) << "Successfully started snapshot " << snapshot->ToString() << " restoring"; return Status::OK(); } Status CatalogManager::RestoreEntry(const SysRowEntry& entry, const SnapshotId& snapshot_id) { switch (entry.type()) { case SysRowEntry::NAMESPACE: { // Restore NAMESPACES. TRACE("Looking up namespace"); scoped_refptr<NamespaceInfo> ns = FindPtrOrNull(namespace_ids_map_, entry.id()); if (ns == nullptr) { // Restore Namespace. // TODO: implement LOG(INFO) << "Restoring: NAMESPACE id = " << entry.id(); return STATUS(NotSupported, Substitute( "Not implemented: restoring namespace: id=$0", entry.type())); } break; } case SysRowEntry::TABLE: { // Restore TABLES. TRACE("Looking up table"); scoped_refptr<TableInfo> table = FindPtrOrNull(*table_ids_map_, entry.id()); if (table == nullptr) { // Restore Table. // TODO: implement LOG(INFO) << "Restoring: TABLE id = " << entry.id(); return STATUS(NotSupported, Substitute( "Not implemented: restoring table: id=$0", entry.type())); } break; } case SysRowEntry::TABLET: { // Restore TABLETS. TRACE("Looking up tablet"); scoped_refptr<TabletInfo> tablet = FindPtrOrNull(*tablet_map_, entry.id()); if (tablet == nullptr) { // Restore Tablet. // TODO: implement LOG(INFO) << "Restoring: TABLET id = " << entry.id(); return STATUS(NotSupported, Substitute( "Not implemented: restoring tablet: id=$0", entry.type())); } else { TRACE("Locking tablet"); auto l = tablet->LockForRead(); LOG(INFO) << "Sending RestoreTabletSnapshot to tablet: " << tablet->ToString(); // Send RestoreSnapshot requests to all TServers (one tablet - one request). SendRestoreTabletSnapshotRequest(tablet, snapshot_id, TabletSnapshotOperationCallback()); } break; } default: return STATUS_FORMAT( InternalError, "Unexpected entry type in the snapshot: $0", entry.type()); } return Status::OK(); } Status CatalogManager::DeleteSnapshot(const DeleteSnapshotRequestPB* req, DeleteSnapshotResponsePB* resp, RpcContext* rpc) { LOG(INFO) << "Servicing DeleteSnapshot request: " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); auto txn_snapshot_id = TryFullyDecodeTxnSnapshotId(req->snapshot_id()); if (txn_snapshot_id) { return snapshot_coordinator_.Delete(txn_snapshot_id, rpc->GetClientDeadline()); } return DeleteNonTransactionAwareSnapshot(req->snapshot_id()); } Status CatalogManager::DeleteNonTransactionAwareSnapshot(const SnapshotId& snapshot_id) { std::lock_guard<LockType> l(lock_); TRACE("Acquired catalog manager lock"); TRACE("Looking up snapshot"); scoped_refptr<SnapshotInfo> snapshot = FindPtrOrNull( non_txn_snapshot_ids_map_, snapshot_id); if (snapshot == nullptr) { return STATUS(InvalidArgument, "Could not find snapshot", snapshot_id, MasterError(MasterErrorPB::SNAPSHOT_NOT_FOUND)); } auto snapshot_lock = snapshot->LockForWrite(); if (snapshot_lock->data().started_deleting()) { return STATUS(NotFound, "The snapshot was deleted", snapshot_id, MasterError(MasterErrorPB::SNAPSHOT_NOT_FOUND)); } if (snapshot_lock->data().is_restoring()) { return STATUS(InvalidArgument, "The snapshot is being restored now", snapshot_id, MasterError(MasterErrorPB::PARALLEL_SNAPSHOT_OPERATION)); } TRACE("Updating snapshot metadata on disk"); SysSnapshotEntryPB& snapshot_pb = snapshot_lock->mutable_data()->pb; snapshot_pb.set_state(SysSnapshotEntryPB::DELETING); // Update tablet states. SetTabletSnapshotsState(SysSnapshotEntryPB::DELETING, &snapshot_pb); // Update sys-catalog with the updated snapshot state. // The mutation will be aborted when 'l' exits the scope on early return. RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(snapshot.get(), leader_ready_term()), "updating snapshot in sys-catalog")); // Send DeleteSnapshot requests to all TServers (one tablet - one request). for (const SysRowEntry& entry : snapshot_pb.entries()) { if (entry.type() == SysRowEntry::TABLET) { TRACE("Looking up tablet"); scoped_refptr<TabletInfo> tablet = FindPtrOrNull(*tablet_map_, entry.id()); if (tablet == nullptr) { LOG(WARNING) << "Deleting tablet not found " << entry.id(); } else { TRACE("Locking tablet"); auto l = tablet->LockForRead(); LOG(INFO) << "Sending DeleteTabletSnapshot to tablet: " << tablet->ToString(); // Send DeleteSnapshot requests to all TServers (one tablet - one request). SendDeleteTabletSnapshotRequest(tablet, snapshot_id, TabletSnapshotOperationCallback()); } } } // Commit in memory snapshot data descriptor. TRACE("Committing in-memory snapshot state"); snapshot_lock->Commit(); LOG(INFO) << "Successfully started snapshot " << snapshot->ToString() << " deletion"; return Status::OK(); } Status CatalogManager::ImportSnapshotPreprocess(const SysSnapshotEntryPB& snapshot_pb, ImportSnapshotMetaResponsePB* resp, NamespaceMap* namespace_map, ExternalTableSnapshotDataMap* tables_data) { for (const SysRowEntry& entry : snapshot_pb.entries()) { switch (entry.type()) { case SysRowEntry::NAMESPACE: // Recreate NAMESPACE. RETURN_NOT_OK(ImportNamespaceEntry(entry, namespace_map)); break; case SysRowEntry::TABLE: { // Create TABLE metadata. LOG_IF(DFATAL, entry.id().empty()) << "Empty entry id"; ExternalTableSnapshotData& data = (*tables_data)[entry.id()]; if (data.old_table_id.empty()) { data.old_table_id = entry.id(); data.table_meta = resp->mutable_tables_meta()->Add(); data.tablet_id_map = data.table_meta->mutable_tablets_ids(); data.table_entry_pb = VERIFY_RESULT(ParseFromSlice<SysTablesEntryPB>(entry.data())); } else { LOG(WARNING) << "Ignoring duplicate table with id " << entry.id(); } LOG_IF(DFATAL, data.old_table_id.empty()) << "Not initialized table id"; } break; case SysRowEntry::TABLET: // Preprocess original tablets. RETURN_NOT_OK(PreprocessTabletEntry(entry, tables_data)); break; case SysRowEntry::UNKNOWN: FALLTHROUGH_INTENDED; case SysRowEntry::CLUSTER_CONFIG: FALLTHROUGH_INTENDED; case SysRowEntry::REDIS_CONFIG: FALLTHROUGH_INTENDED; case SysRowEntry::UDTYPE: FALLTHROUGH_INTENDED; case SysRowEntry::ROLE: FALLTHROUGH_INTENDED; case SysRowEntry::SYS_CONFIG: FALLTHROUGH_INTENDED; case SysRowEntry::CDC_STREAM: FALLTHROUGH_INTENDED; case SysRowEntry::UNIVERSE_REPLICATION: FALLTHROUGH_INTENDED; case SysRowEntry::SNAPSHOT: FATAL_INVALID_ENUM_VALUE(SysRowEntry::Type, entry.type()); } } return Status::OK(); } Status CatalogManager::ImportSnapshotCreateObject(const SysSnapshotEntryPB& snapshot_pb, ImportSnapshotMetaResponsePB* resp, NamespaceMap* namespace_map, ExternalTableSnapshotDataMap* tables_data, CreateObjects create_objects) { // Create ONLY TABLES or ONLY INDEXES in accordance to the argument. for (const SysRowEntry& entry : snapshot_pb.entries()) { if (entry.type() == SysRowEntry::TABLE) { ExternalTableSnapshotData& data = (*tables_data)[entry.id()]; if ((create_objects == CreateObjects::kOnlyIndexes) == data.is_index()) { RETURN_NOT_OK(ImportTableEntry(*namespace_map, *tables_data, &data)); } } } return Status::OK(); } Status CatalogManager::ImportSnapshotWaitForTables(const SysSnapshotEntryPB& snapshot_pb, ImportSnapshotMetaResponsePB* resp, ExternalTableSnapshotDataMap* tables_data) { for (const SysRowEntry& entry : snapshot_pb.entries()) { if (entry.type() == SysRowEntry::TABLE) { ExternalTableSnapshotData& data = (*tables_data)[entry.id()]; if (!data.is_index()) { RETURN_NOT_OK(WaitForCreateTableToFinish(data.new_table_id)); } } } return Status::OK(); } Status CatalogManager::ImportSnapshotProcessTablets(const SysSnapshotEntryPB& snapshot_pb, ImportSnapshotMetaResponsePB* resp, ExternalTableSnapshotDataMap* tables_data) { for (const SysRowEntry& entry : snapshot_pb.entries()) { if (entry.type() == SysRowEntry::TABLET) { // Create tablets IDs map. RETURN_NOT_OK(ImportTabletEntry(entry, tables_data)); } } return Status::OK(); } template <class RespClass> void ProcessDeleteObjectStatus(const string& obj_name, const string& id, const RespClass& resp, const Status& s) { Status result = s; if (result.ok() && resp.has_error()) { result = StatusFromPB(resp.error().status()); LOG_IF(DFATAL, result.ok()) << "Expecting error status"; } if (!result.ok()) { LOG(WARNING) << "Failed to delete new " << obj_name << " with id=" << id << ": " << result; } } void CatalogManager::DeleteNewSnapshotObjects(const NamespaceMap& namespace_map, const ExternalTableSnapshotDataMap& tables_data) { for (const ExternalTableSnapshotDataMap::value_type& entry : tables_data) { const TableId& old_id = entry.first; const TableId& new_id = entry.second.new_table_id; const TableType type = entry.second.table_entry_pb.table_type(); // Do not delete YSQL objects - it must be deleted via PG API. if (new_id.empty() || new_id == old_id || type == TableType::PGSQL_TABLE_TYPE) { continue; } LOG(INFO) << "Deleting new table with id=" << new_id << " old id=" << old_id; DeleteTableRequestPB req; DeleteTableResponsePB resp; req.mutable_table()->set_table_id(new_id); req.set_is_index_table(entry.second.is_index()); ProcessDeleteObjectStatus("table", new_id, resp, DeleteTable(&req, &resp, nullptr)); } for (const NamespaceMap::value_type& entry : namespace_map) { const NamespaceId& old_id = entry.first; const NamespaceId& new_id = entry.second.first; const YQLDatabase& db_type = entry.second.second; // Do not delete YSQL objects - it must be deleted via PG API. if (new_id.empty() || new_id == old_id || db_type == YQL_DATABASE_PGSQL) { continue; } LOG(INFO) << "Deleting new namespace with id=" << new_id << " old id=" << old_id; DeleteNamespaceRequestPB req; DeleteNamespaceResponsePB resp; req.mutable_namespace_()->set_id(new_id); ProcessDeleteObjectStatus( "namespace", new_id, resp, DeleteNamespace(&req, &resp, nullptr)); } } Status CatalogManager::ImportSnapshotMeta(const ImportSnapshotMetaRequestPB* req, ImportSnapshotMetaResponsePB* resp) { LOG(INFO) << "Servicing ImportSnapshotMeta request: " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); NamespaceMap namespace_map; ExternalTableSnapshotDataMap tables_data; bool successful_exit = false; auto se = ScopeExit([this, &namespace_map, &tables_data, &successful_exit] { if (!successful_exit) { DeleteNewSnapshotObjects(namespace_map, tables_data); } }); const SysSnapshotEntryPB& snapshot_pb = req->snapshot().entry(); // PHASE 1: Recreate namespaces, create table's meta data. RETURN_NOT_OK(ImportSnapshotPreprocess(snapshot_pb, resp, &namespace_map, &tables_data)); // PHASE 2: Recreate ONLY tables. RETURN_NOT_OK(ImportSnapshotCreateObject( snapshot_pb, resp, &namespace_map, &tables_data, CreateObjects::kOnlyTables)); // PHASE 3: Wait for all tables creation complete. RETURN_NOT_OK(ImportSnapshotWaitForTables(snapshot_pb, resp, &tables_data)); // PHASE 4: Recreate ONLY indexes. RETURN_NOT_OK(ImportSnapshotCreateObject( snapshot_pb, resp, &namespace_map, &tables_data, CreateObjects::kOnlyIndexes)); // PHASE 5: Restore tablets. RETURN_NOT_OK(ImportSnapshotProcessTablets(snapshot_pb, resp, &tables_data)); successful_exit = true; return Status::OK(); } Status CatalogManager::ChangeEncryptionInfo(const ChangeEncryptionInfoRequestPB* req, ChangeEncryptionInfoResponsePB* resp) { auto l = cluster_config_->LockForWrite(); auto encryption_info = l->mutable_data()->pb.mutable_encryption_info(); RETURN_NOT_OK(encryption_manager_->ChangeEncryptionInfo(req, encryption_info)); l->mutable_data()->pb.set_version(l->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); l->Commit(); std::lock_guard<simple_spinlock> lock(should_send_universe_key_registry_mutex_); for (auto& entry : should_send_universe_key_registry_) { entry.second = true; } return Status::OK(); } Status CatalogManager::IsEncryptionEnabled(const IsEncryptionEnabledRequestPB* req, IsEncryptionEnabledResponsePB* resp) { auto l = cluster_config_->LockForRead(); const auto& encryption_info = l->data().pb.encryption_info(); return encryption_manager_->IsEncryptionEnabled(encryption_info, resp); } Status CatalogManager::ImportNamespaceEntry(const SysRowEntry& entry, NamespaceMap* namespace_map) { LOG_IF(DFATAL, entry.type() != SysRowEntry::NAMESPACE) << "Unexpected entry type: " << entry.type(); SysNamespaceEntryPB meta = VERIFY_RESULT(ParseFromSlice<SysNamespaceEntryPB>(entry.data())); const YQLDatabase db_type = GetDatabaseType(meta); NamespaceData& ns_data = (*namespace_map)[entry.id()]; ns_data.second = db_type; TRACE("Looking up namespace"); // First of all try to find the namespace by ID. It will work if we are restoring the backup // on the original cluster where the backup was created. scoped_refptr<NamespaceInfo> ns; { SharedLock<LockType> l(lock_); ns = FindPtrOrNull(namespace_ids_map_, entry.id()); } if (ns != nullptr && ns->name() == meta.name() && ns->state() == SysNamespaceEntryPB::RUNNING) { ns_data.first = entry.id(); return Status::OK(); } // If the namespace was not found by ID, it's ok on a new cluster OR if the namespace was // deleted and created again. In both cases the namespace can be found by NAME. if (db_type == YQL_DATABASE_PGSQL) { // YSQL database must be created via external call. Find it by name. { SharedLock<LockType> l(lock_); ns = FindPtrOrNull(namespace_names_mapper_[db_type], meta.name()); } if (ns == nullptr) { return STATUS(InvalidArgument, "YSQL database must exist", meta.name(), MasterError(MasterErrorPB::NAMESPACE_NOT_FOUND)); } if (ns->state() != SysNamespaceEntryPB::RUNNING) { return STATUS(InvalidArgument, "Found YSQL database must be running", meta.name(), MasterError(MasterErrorPB::NAMESPACE_NOT_FOUND)); } auto ns_lock = ns->LockForRead(); ns_data.first = ns->id(); } else { CreateNamespaceRequestPB req; CreateNamespaceResponsePB resp; req.set_name(meta.name()); const Status s = CreateNamespace(&req, &resp, nullptr); if (!s.ok() && !s.IsAlreadyPresent()) { return s.CloneAndAppend("Failed to create namespace"); } if (s.IsAlreadyPresent()) { LOG(INFO) << "Using existing namespace " << meta.name() << ": " << resp.id(); } ns_data.first = resp.id(); } return Status::OK(); } Status CatalogManager::RecreateTable(const NamespaceId& new_namespace_id, const ExternalTableSnapshotDataMap& table_map, ExternalTableSnapshotData* table_data) { const SysTablesEntryPB& meta = DCHECK_NOTNULL(table_data)->table_entry_pb; CreateTableRequestPB req; CreateTableResponsePB resp; req.set_name(meta.name()); req.set_table_type(meta.table_type()); req.set_num_tablets(table_data->num_tablets); req.mutable_namespace_()->set_id(new_namespace_id); *req.mutable_partition_schema() = meta.partition_schema(); *req.mutable_replication_info() = meta.replication_info(); SchemaPB* const schema = req.mutable_schema(); *schema = meta.schema(); schema->mutable_table_properties()->set_num_tablets(table_data->num_tablets); // Setup Index info. if (table_data->is_index()) { TRACE("Looking up indexed table"); // First of all try to attach to the new copy of the referenced table, // because the table restored from the snapshot is preferred. // For that try to map old indexed table ID into new table ID. ExternalTableSnapshotDataMap::const_iterator it = table_map.find(meta.indexed_table_id()); const bool using_existing_table = (it == table_map.end()); if (using_existing_table) { LOG(INFO) << "Try to use old indexed table ID " << meta.indexed_table_id(); req.set_indexed_table_id(meta.indexed_table_id()); } else { LOG(INFO) << "Found new table ID " << it->second.new_table_id << " for old table ID " << meta.indexed_table_id() << " from the snapshot."; req.set_indexed_table_id(it->second.new_table_id); } scoped_refptr<TableInfo> indexed_table; { SharedLock<LockType> l(lock_); // Try to find the specified indexed table by id. indexed_table = FindPtrOrNull(*table_ids_map_, req.indexed_table_id()); } if (indexed_table == nullptr) { return STATUS( InvalidArgument, Format("Indexed table not found by id: $0", req.indexed_table_id()), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } LOG(INFO) << "Found indexed table by ID " << req.indexed_table_id(); // Ensure the main table schema (including column ids) was not changed. if (!using_existing_table) { Schema new_indexed_schema, src_indexed_schema; RETURN_NOT_OK(indexed_table->GetSchema(&new_indexed_schema)); RETURN_NOT_OK(SchemaFromPB(it->second.table_entry_pb.schema(), &src_indexed_schema)); if (!new_indexed_schema.Equals(src_indexed_schema)) { return STATUS( InternalError, Format("Recreated table has changes in schema: new schema: {$0}, source schema: {$1}", new_indexed_schema.ToString(), src_indexed_schema.ToString()), MasterError(MasterErrorPB::SNAPSHOT_FAILED)); } } req.set_is_local_index(meta.is_local_index()); req.set_is_unique_index(meta.is_unique_index()); req.set_skip_index_backfill(true); // Setup IndexInfoPB - self descriptor. IndexInfoPB* const index_info_pb = req.mutable_index_info(); *index_info_pb = meta.index_info(); index_info_pb->clear_table_id(); index_info_pb->set_indexed_table_id(req.indexed_table_id()); // Reset column ids. for (int i = 0; i < index_info_pb->columns_size(); ++i) { index_info_pb->mutable_columns(i)->clear_column_id(); } } RETURN_NOT_OK(CreateTable(&req, &resp, /* RpcContext */nullptr)); table_data->new_table_id = resp.table_id(); return Status::OK(); } Status CatalogManager::ImportTableEntry(const NamespaceMap& namespace_map, const ExternalTableSnapshotDataMap& table_map, ExternalTableSnapshotData* table_data) { const SysTablesEntryPB& meta = DCHECK_NOTNULL(table_data)->table_entry_pb; bool is_parent_colocated_table = false; table_data->old_namespace_id = meta.namespace_id(); LOG_IF(DFATAL, table_data->old_namespace_id.empty()) << "No namespace id"; LOG_IF(DFATAL, namespace_map.find(table_data->old_namespace_id) == namespace_map.end()) << "Namespace not found: " << table_data->old_namespace_id; const NamespaceId new_namespace_id = namespace_map.find(table_data->old_namespace_id)->second.first; LOG_IF(DFATAL, new_namespace_id.empty()) << "No namespace id"; Schema schema; RETURN_NOT_OK(SchemaFromPB(meta.schema(), &schema)); const vector<ColumnId>& column_ids = schema.column_ids(); scoped_refptr<TableInfo> table; // Create new table if namespace was changed. if (new_namespace_id == table_data->old_namespace_id) { TRACE("Looking up table"); { SharedLock<LockType> l(lock_); table = FindPtrOrNull(*table_ids_map_, table_data->old_table_id); } // Check table is active, table name and table schema are equal to backed up ones. if (table != nullptr) { auto table_lock = table->LockForRead(); if (table->is_running() && table->name() == meta.name()) { // Check the found table schema. Schema persisted_schema; RETURN_NOT_OK(table->GetSchema(&persisted_schema)); // Schema::Equals() compares only column names & types. Check the column ids separately. if (!persisted_schema.Equals(schema) || persisted_schema.column_ids() != column_ids) { const string msg = Format("Found by id $0 $1 table $2 in namespace $3 has " "schema={$4}, expected={$5}", table_data->old_table_id, TableType_Name(meta.table_type()), meta.name(), new_namespace_id, persisted_schema, schema); LOG(WARNING) << msg; return STATUS(InvalidArgument, msg, MasterError(MasterErrorPB::SNAPSHOT_FAILED)); } } else { table.reset(); } } } if (table == nullptr) { if (meta.table_type() == TableType::PGSQL_TABLE_TYPE) { // YSQL table must be created via external call. Find it by name. // Expecting the table name is unique in the YSQL database. if (meta.colocated() && IsColocatedParentTableId(table_data->old_table_id)) { // For the parent colocated table we need to generate the new_table_id ourselves // since the names will not match. // For normal colocated tables, we are still able to follow the normal table flow, so no // need to generate the new_table_id ourselves. table_data->new_table_id = new_namespace_id + kColocatedParentTableIdSuffix; is_parent_colocated_table = true; } else { DCHECK(table_data->new_table_id.empty()); SharedLock<LockType> l(lock_); for (const auto& entry : *table_ids_map_) { table = entry.second; auto ltm = table->LockForRead(); if (table->is_running() && new_namespace_id == table->namespace_id() && meta.name() == ltm->data().name() && ((table_data->is_index() && IsUserIndexUnlocked(*table)) || (!table_data->is_index() && IsUserTableUnlocked(*table)))) { // Found the new YSQL table by name. if (table_data->new_table_id.empty()) { table_data->new_table_id = entry.first; } else if (table_data->new_table_id != entry.first) { return STATUS(InvalidArgument, Format("Found 2 YSQL tables with the same name: $0 - $1, $2", meta.name(), table_data->new_table_id, entry.first), MasterError(MasterErrorPB::SNAPSHOT_FAILED)); } } } if (table_data->new_table_id.empty()) { return STATUS(InvalidArgument, Format("YSQL table not found: $0", meta.name()), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } } else { RETURN_NOT_OK(RecreateTable(new_namespace_id, table_map, table_data)); } TRACE("Looking up new table"); { SharedLock<LockType> l(lock_); table = FindPtrOrNull(*table_ids_map_, table_data->new_table_id); } if (table == nullptr) { return STATUS(InternalError, Format("Created table not found: $0", table_data->new_table_id), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } // Don't do schema validation/column updates on the parent colocated table. // However, still do the validation for regular colocated tables. if (!is_parent_colocated_table) { Schema persisted_schema; { TRACE("Locking table"); auto table_lock = table->LockForRead(); RETURN_NOT_OK(table->GetSchema(&persisted_schema)); } // Schema::Equals() compares only column names & types. It does not compare the column ids. if (!persisted_schema.Equals(schema) || persisted_schema.column_ids().size() != column_ids.size()) { return STATUS(InternalError, Format("Invalid created table schema={$0}, expected={$1}", persisted_schema, schema), MasterError(MasterErrorPB::SNAPSHOT_FAILED)); } // Update the table column ids if it's not equal to the stored ids. if (persisted_schema.column_ids() != column_ids) { if (meta.table_type() != TableType::PGSQL_TABLE_TYPE) { LOG(WARNING) << "Unexpected wrong column ids in " << TableType_Name(meta.table_type()) << " table " << meta.name() << " in namespace id " << new_namespace_id; } LOG(INFO) << "Restoring column ids in " << TableType_Name(meta.table_type()) << " table " << meta.name() << " in namespace id " << new_namespace_id; auto l = table->LockForWrite(); size_t col_idx = 0; for (auto& column : *l->mutable_data()->pb.mutable_schema()->mutable_columns()) { // Expecting here correct schema (columns - order, names, types), but with only wrong // column ids. Checking correct column order and column names below. if (column.name() != schema.column(col_idx).name()) { return STATUS(InternalError, Format("Unexpected column name for index=$0: name=$1, expected name=$2", col_idx, schema.column(col_idx).name(), column.name()), MasterError(MasterErrorPB::SNAPSHOT_FAILED)); } // Copy the column id from imported (original) schema. column.set_id(column_ids[col_idx++]); } l->mutable_data()->pb.set_next_column_id(schema.max_col_id() + 1); l->mutable_data()->pb.set_version(l->data().pb.version() + 1); // Update sys-catalog with the new table schema. RETURN_NOT_OK(sys_catalog_->UpdateItem(table.get(), leader_ready_term())); l->Commit(); // Update the new table schema in tablets. SendAlterTableRequest(table); } } } else { table_data->new_table_id = table_data->old_table_id; } // Set the type of the table in the response pb (default is TABLE so only set if colocated). if (meta.colocated()) { if (is_parent_colocated_table) { table_data->table_meta->set_table_type( ImportSnapshotMetaResponsePB_TableType_PARENT_COLOCATED_TABLE); } else { table_data->table_meta->set_table_type( ImportSnapshotMetaResponsePB_TableType_COLOCATED_TABLE); } } vector<scoped_refptr<TabletInfo>> new_tablets; { TRACE("Locking table"); auto table_lock = table->LockForRead(); table->GetAllTablets(&new_tablets); } for (const scoped_refptr<TabletInfo>& tablet : new_tablets) { auto tablet_lock = tablet->LockForRead(); const PartitionPB& partition_pb = tablet->metadata().state().pb.partition(); const ExternalTableSnapshotData::PartitionKeys key( partition_pb.partition_key_start(), partition_pb.partition_key_end()); table_data->new_tablets_map[key] = tablet->id(); } IdPairPB* const namespace_ids = table_data->table_meta->mutable_namespace_ids(); namespace_ids->set_new_id(new_namespace_id); namespace_ids->set_old_id(table_data->old_namespace_id); IdPairPB* const table_ids = table_data->table_meta->mutable_table_ids(); table_ids->set_new_id(table_data->new_table_id); table_ids->set_old_id(table_data->old_table_id); return Status::OK(); } Status CatalogManager::PreprocessTabletEntry(const SysRowEntry& entry, ExternalTableSnapshotDataMap* table_map) { LOG_IF(DFATAL, entry.type() != SysRowEntry::TABLET) << "Unexpected entry type: " << entry.type(); SysTabletsEntryPB meta = VERIFY_RESULT(ParseFromSlice<SysTabletsEntryPB>(entry.data())); ExternalTableSnapshotData& table_data = (*table_map)[meta.table_id()]; ++table_data.num_tablets; return Status::OK(); } Status CatalogManager::ImportTabletEntry(const SysRowEntry& entry, ExternalTableSnapshotDataMap* table_map) { LOG_IF(DFATAL, entry.type() != SysRowEntry::TABLET) << "Unexpected entry type: " << entry.type(); SysTabletsEntryPB meta = VERIFY_RESULT(ParseFromSlice<SysTabletsEntryPB>(entry.data())); LOG_IF(DFATAL, table_map->find(meta.table_id()) == table_map->end()) << "Table not found: " << meta.table_id(); ExternalTableSnapshotData& table_data = (*table_map)[meta.table_id()]; if (meta.colocated() && table_data.tablet_id_map->size() >= 1) { LOG(INFO) << "Already processed this colocated tablet: " << entry.id(); return Status::OK(); } // Update tablets IDs map. if (table_data.new_table_id == table_data.old_table_id) { TRACE("Looking up tablet"); SharedLock<LockType> l(lock_); scoped_refptr<TabletInfo> tablet = FindPtrOrNull(*tablet_map_, entry.id()); if (tablet != nullptr) { IdPairPB* const pair = table_data.tablet_id_map->Add(); pair->set_old_id(entry.id()); pair->set_new_id(entry.id()); return Status::OK(); } } const PartitionPB& partition_pb = meta.partition(); const ExternalTableSnapshotData::PartitionKeys key( partition_pb.partition_key_start(), partition_pb.partition_key_end()); const ExternalTableSnapshotData::PartitionToIdMap::const_iterator it = table_data.new_tablets_map.find(key); if (it == table_data.new_tablets_map.end()) { return STATUS(NotFound, Format("Not found new tablet with expected partition keys: $0 - $1", partition_pb.partition_key_start(), partition_pb.partition_key_end()), MasterError(MasterErrorPB::INTERNAL_ERROR)); } IdPairPB* const pair = table_data.tablet_id_map->Add(); pair->set_old_id(entry.id()); pair->set_new_id(it->second); return Status::OK(); } const Schema& CatalogManager::schema() { return sys_catalog()->schema(); } TabletInfos CatalogManager::GetTabletInfos(const std::vector<TabletId>& ids) { TabletInfos result; result.reserve(ids.size()); SharedLock<LockType> l(lock_); for (const auto& id : ids) { auto it = tablet_map_->find(id); result.push_back(it != tablet_map_->end() ? it->second : nullptr); } return result; } void CatalogManager::SendCreateTabletSnapshotRequest( const scoped_refptr<TabletInfo>& tablet, const std::string& snapshot_id, HybridTime snapshot_hybrid_time, TabletSnapshotOperationCallback callback) { auto call = std::make_shared<AsyncTabletSnapshotOp>( master_, AsyncTaskPool(), tablet, snapshot_id, tserver::TabletSnapshotOpRequestPB::CREATE_ON_TABLET); call->SetSnapshotHybridTime(snapshot_hybrid_time); call->SetCallback(std::move(callback)); tablet->table()->AddTask(call); WARN_NOT_OK(ScheduleTask(call), "Failed to send create snapshot request"); } void CatalogManager::SendRestoreTabletSnapshotRequest( const scoped_refptr<TabletInfo>& tablet, const string& snapshot_id, TabletSnapshotOperationCallback callback) { auto call = std::make_shared<AsyncTabletSnapshotOp>( master_, AsyncTaskPool(), tablet, snapshot_id, tserver::TabletSnapshotOpRequestPB::RESTORE); call->SetCallback(std::move(callback)); tablet->table()->AddTask(call); WARN_NOT_OK(ScheduleTask(call), "Failed to send restore snapshot request"); } void CatalogManager::SendDeleteTabletSnapshotRequest(const scoped_refptr<TabletInfo>& tablet, const string& snapshot_id, TabletSnapshotOperationCallback callback) { auto call = std::make_shared<AsyncTabletSnapshotOp>( master_, AsyncTaskPool(), tablet, snapshot_id, tserver::TabletSnapshotOpRequestPB::DELETE_ON_TABLET); call->SetCallback(std::move(callback)); tablet->table()->AddTask(call); WARN_NOT_OK(ScheduleTask(call), "Failed to send delete snapshot request"); } rpc::Scheduler& CatalogManager::Scheduler() { return master_->messenger()->scheduler(); } bool CatalogManager::IsLeader() { auto peer = tablet_peer(); if (!peer) { return false; } auto consensus = peer->shared_consensus(); if (!consensus) { return false; } auto leader_status = consensus->GetLeaderStatus(/* allow_stale= */ true); return leader_status == consensus::LeaderStatus::LEADER_AND_READY; } void CatalogManager::HandleCreateTabletSnapshotResponse(TabletInfo *tablet, bool error) { LOG(INFO) << "Handling Create Tablet Snapshot Response for tablet " << DCHECK_NOTNULL(tablet)->ToString() << (error ? " ERROR" : " OK"); // Get the snapshot data descriptor from the catalog manager. scoped_refptr<SnapshotInfo> snapshot; { std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); if (current_snapshot_id_.empty()) { LOG(WARNING) << "No active snapshot: " << current_snapshot_id_; return; } snapshot = FindPtrOrNull(non_txn_snapshot_ids_map_, current_snapshot_id_); if (!snapshot) { LOG(WARNING) << "Snapshot not found: " << current_snapshot_id_; return; } } if (!snapshot->IsCreateInProgress()) { LOG(WARNING) << "Snapshot is not in creating state: " << snapshot->id(); return; } auto tablet_l = tablet->LockForRead(); auto l = snapshot->LockForWrite(); RepeatedPtrField<SysSnapshotEntryPB_TabletSnapshotPB>* tablet_snapshots = l->mutable_data()->pb.mutable_tablet_snapshots(); int num_tablets_complete = 0; for (int i = 0; i < tablet_snapshots->size(); ++i) { SysSnapshotEntryPB_TabletSnapshotPB* tablet_info = tablet_snapshots->Mutable(i); if (tablet_info->id() == tablet->id()) { tablet_info->set_state(error ? SysSnapshotEntryPB::FAILED : SysSnapshotEntryPB::COMPLETE); } if (tablet_info->state() == SysSnapshotEntryPB::COMPLETE) { ++num_tablets_complete; } } // Finish the snapshot. bool finished = true; if (error) { l->mutable_data()->pb.set_state(SysSnapshotEntryPB::FAILED); LOG(WARNING) << "Failed snapshot " << snapshot->id() << " on tablet " << tablet->id(); } else if (num_tablets_complete == tablet_snapshots->size()) { l->mutable_data()->pb.set_state(SysSnapshotEntryPB::COMPLETE); LOG(INFO) << "Completed snapshot " << snapshot->id(); } else { finished = false; } if (finished) { std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); current_snapshot_id_ = ""; } VLOG(1) << "Snapshot: " << snapshot->id() << " PB: " << l->mutable_data()->pb.DebugString() << " Complete " << num_tablets_complete << " tablets from " << tablet_snapshots->size(); const Status s = sys_catalog_->UpdateItem(snapshot.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating snapshot in sys-catalog"); } l->Commit(); } void CatalogManager::HandleRestoreTabletSnapshotResponse(TabletInfo *tablet, bool error) { LOG(INFO) << "Handling Restore Tablet Snapshot Response for tablet " << DCHECK_NOTNULL(tablet)->ToString() << (error ? " ERROR" : " OK"); // Get the snapshot data descriptor from the catalog manager. scoped_refptr<SnapshotInfo> snapshot; { std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); if (current_snapshot_id_.empty()) { LOG(WARNING) << "No restoring snapshot: " << current_snapshot_id_; return; } snapshot = FindPtrOrNull(non_txn_snapshot_ids_map_, current_snapshot_id_); if (!snapshot) { LOG(WARNING) << "Restoring snapshot not found: " << current_snapshot_id_; return; } } if (!snapshot->IsRestoreInProgress()) { LOG(WARNING) << "Snapshot is not in restoring state: " << snapshot->id(); return; } auto tablet_l = tablet->LockForRead(); auto l = snapshot->LockForWrite(); RepeatedPtrField<SysSnapshotEntryPB_TabletSnapshotPB>* tablet_snapshots = l->mutable_data()->pb.mutable_tablet_snapshots(); int num_tablets_complete = 0; for (int i = 0; i < tablet_snapshots->size(); ++i) { SysSnapshotEntryPB_TabletSnapshotPB* tablet_info = tablet_snapshots->Mutable(i); if (tablet_info->id() == tablet->id()) { tablet_info->set_state(error ? SysSnapshotEntryPB::FAILED : SysSnapshotEntryPB::COMPLETE); } if (tablet_info->state() == SysSnapshotEntryPB::COMPLETE) { ++num_tablets_complete; } } // Finish the snapshot. if (error || num_tablets_complete == tablet_snapshots->size()) { if (error) { l->mutable_data()->pb.set_state(SysSnapshotEntryPB::FAILED); LOG(WARNING) << "Failed restoring snapshot " << snapshot->id() << " on tablet " << tablet->id(); } else { LOG_IF(DFATAL, num_tablets_complete != tablet_snapshots->size()) << "Wrong number of tablets"; l->mutable_data()->pb.set_state(SysSnapshotEntryPB::COMPLETE); LOG(INFO) << "Restored snapshot " << snapshot->id(); } std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); current_snapshot_id_ = ""; } VLOG(1) << "Snapshot: " << snapshot->id() << " PB: " << l->mutable_data()->pb.DebugString() << " Complete " << num_tablets_complete << " tablets from " << tablet_snapshots->size(); const Status s = sys_catalog_->UpdateItem(snapshot.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating snapshot in sys-catalog"); } l->Commit(); } void CatalogManager::HandleDeleteTabletSnapshotResponse( SnapshotId snapshot_id, TabletInfo *tablet, bool error) { LOG(INFO) << "Handling Delete Tablet Snapshot Response for tablet " << DCHECK_NOTNULL(tablet)->ToString() << (error ? " ERROR" : " OK"); // Get the snapshot data descriptor from the catalog manager. scoped_refptr<SnapshotInfo> snapshot; { std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); snapshot = FindPtrOrNull(non_txn_snapshot_ids_map_, snapshot_id); if (!snapshot) { LOG(WARNING) << "Snapshot not found: " << snapshot_id; return; } } if (!snapshot->IsDeleteInProgress()) { LOG(WARNING) << "Snapshot is not in deleting state: " << snapshot->id(); return; } auto tablet_l = tablet->LockForRead(); auto l = snapshot->LockForWrite(); RepeatedPtrField<SysSnapshotEntryPB_TabletSnapshotPB>* tablet_snapshots = l->mutable_data()->pb.mutable_tablet_snapshots(); int num_tablets_complete = 0; for (int i = 0; i < tablet_snapshots->size(); ++i) { SysSnapshotEntryPB_TabletSnapshotPB* tablet_info = tablet_snapshots->Mutable(i); if (tablet_info->id() == tablet->id()) { tablet_info->set_state(error ? SysSnapshotEntryPB::FAILED : SysSnapshotEntryPB::DELETED); } if (tablet_info->state() != SysSnapshotEntryPB::DELETING) { ++num_tablets_complete; } } if (num_tablets_complete == tablet_snapshots->size()) { // Delete the snapshot. l->mutable_data()->pb.set_state(SysSnapshotEntryPB::DELETED); LOG(INFO) << "Deleted snapshot " << snapshot->id(); const Status s = sys_catalog_->DeleteItem(snapshot.get(), leader_ready_term()); std::lock_guard<LockType> manager_l(lock_); TRACE("Acquired catalog manager lock"); if (current_snapshot_id_ == snapshot_id) { current_snapshot_id_ = ""; } // Remove it from the maps. TRACE("Removing from maps"); if (non_txn_snapshot_ids_map_.erase(snapshot_id) < 1) { LOG(WARNING) << "Could not remove snapshot " << snapshot_id << " from map"; } if (!s.ok()) { return (void)CheckStatus(s, "deleting snapshot from sys-catalog"); } } else if (error) { l->mutable_data()->pb.set_state(SysSnapshotEntryPB::FAILED); LOG(WARNING) << "Failed snapshot " << snapshot->id() << " deletion on tablet " << tablet->id(); const Status s = sys_catalog_->UpdateItem(snapshot.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating snapshot in sys-catalog"); } } l->Commit(); VLOG(1) << "Deleting snapshot: " << snapshot->id() << " PB: " << l->mutable_data()->pb.DebugString() << " Complete " << num_tablets_complete << " tablets from " << tablet_snapshots->size(); } void CatalogManager::DumpState(std::ostream* out, bool on_disk_dump) const { super::DumpState(out, on_disk_dump); // TODO: dump snapshots } Status CatalogManager::CheckValidReplicationInfo(const ReplicationInfoPB& replication_info, const TSDescriptorVector& all_ts_descs, const vector<Partition>& partitions, CreateTableResponsePB* resp) { TSDescriptorVector ts_descs; GetTsDescsFromPlacementInfo(replication_info.live_replicas(), all_ts_descs, &ts_descs); RETURN_NOT_OK(super::CheckValidPlacementInfo(replication_info.live_replicas(), ts_descs, partitions, resp)); for (int i = 0; i < replication_info.read_replicas_size(); i++) { GetTsDescsFromPlacementInfo(replication_info.read_replicas(i), all_ts_descs, &ts_descs); RETURN_NOT_OK(super::CheckValidPlacementInfo(replication_info.read_replicas(i), ts_descs, partitions, resp)); } return Status::OK(); } Status CatalogManager::HandlePlacementUsingReplicationInfo( const ReplicationInfoPB& replication_info, const TSDescriptorVector& all_ts_descs, consensus::RaftConfigPB* config) { TSDescriptorVector ts_descs; GetTsDescsFromPlacementInfo(replication_info.live_replicas(), all_ts_descs, &ts_descs); RETURN_NOT_OK(super::HandlePlacementUsingPlacementInfo(replication_info.live_replicas(), ts_descs, consensus::RaftPeerPB::VOTER, config)); for (int i = 0; i < replication_info.read_replicas_size(); i++) { GetTsDescsFromPlacementInfo(replication_info.read_replicas(i), all_ts_descs, &ts_descs); RETURN_NOT_OK(super::HandlePlacementUsingPlacementInfo(replication_info.read_replicas(i), ts_descs, consensus::RaftPeerPB::OBSERVER, config)); } return Status::OK(); } void CatalogManager::GetTsDescsFromPlacementInfo(const PlacementInfoPB& placement_info, const TSDescriptorVector& all_ts_descs, TSDescriptorVector* ts_descs) { ts_descs->clear(); for (const auto& ts_desc : all_ts_descs) { TSDescriptor* ts_desc_ent = down_cast<TSDescriptor*>(ts_desc.get()); if (placement_info.has_placement_uuid()) { string placement_uuid = placement_info.placement_uuid(); if (ts_desc_ent->placement_uuid() == placement_uuid) { ts_descs->push_back(ts_desc); } } else if (ts_desc_ent->placement_uuid() == "") { // Since the placement info has no placement id, we know it is live, so we add this ts. ts_descs->push_back(ts_desc); } } } template <typename Registry, typename Mutex> bool ShouldResendRegistry( const std::string& ts_uuid, bool has_registration, Registry* registry, Mutex* mutex) { bool should_resend_registry; { std::lock_guard<Mutex> lock(*mutex); auto it = registry->find(ts_uuid); should_resend_registry = (it == registry->end() || it->second || has_registration); if (it == registry->end()) { registry->emplace(ts_uuid, false); } else { it->second = false; } } return should_resend_registry; } Status CatalogManager::FillHeartbeatResponse(const TSHeartbeatRequestPB* req, TSHeartbeatResponsePB* resp) { SysClusterConfigEntryPB cluster_config; RETURN_NOT_OK(GetClusterConfig(&cluster_config)); RETURN_NOT_OK(FillHeartbeatResponseEncryption(cluster_config, req, resp)); return FillHeartbeatResponseCDC(cluster_config, req, resp); } Status CatalogManager::FillHeartbeatResponseCDC(const SysClusterConfigEntryPB& cluster_config, const TSHeartbeatRequestPB* req, TSHeartbeatResponsePB* resp) { resp->set_cluster_config_version(cluster_config.version()); if (!cluster_config.has_consumer_registry() || req->cluster_config_version() >= cluster_config.version()) { return Status::OK(); } *resp->mutable_consumer_registry() = cluster_config.consumer_registry(); return Status::OK(); } Status CatalogManager::FillHeartbeatResponseEncryption( const SysClusterConfigEntryPB& cluster_config, const TSHeartbeatRequestPB* req, TSHeartbeatResponsePB* resp) { const auto& ts_uuid = req->common().ts_instance().permanent_uuid(); if (!cluster_config.has_encryption_info() || !ShouldResendRegistry(ts_uuid, req->has_registration(), &should_send_universe_key_registry_, &should_send_universe_key_registry_mutex_)) { return Status::OK(); } const auto& encryption_info = cluster_config.encryption_info(); RETURN_NOT_OK(encryption_manager_->FillHeartbeatResponseEncryption(encryption_info, resp)); return Status::OK(); } void CatalogManager::SetTabletSnapshotsState(SysSnapshotEntryPB::State state, SysSnapshotEntryPB* snapshot_pb) { RepeatedPtrField<SysSnapshotEntryPB_TabletSnapshotPB>* tablet_snapshots = snapshot_pb->mutable_tablet_snapshots(); for (int i = 0; i < tablet_snapshots->size(); ++i) { SysSnapshotEntryPB_TabletSnapshotPB* tablet_info = tablet_snapshots->Mutable(i); tablet_info->set_state(state); } } Status CatalogManager::CreateCdcStateTableIfNeeded(rpc::RpcContext *rpc) { TableIdentifierPB table_identifier; table_identifier.set_table_name(kCdcStateTableName); table_identifier.mutable_namespace_()->set_name(kSystemNamespaceName); // Check that the namespace exists. scoped_refptr<NamespaceInfo> ns_info; RETURN_NOT_OK(FindNamespace(table_identifier.namespace_(), &ns_info)); if (!ns_info) { return STATUS(NotFound, "Namespace does not exist", kSystemNamespaceName); } // If CDC state table exists do nothing, otherwise create it. scoped_refptr<TableInfo> table_info; RETURN_NOT_OK(FindTable(table_identifier, &table_info)); if (!table_info) { // Set up a CreateTable request internally. CreateTableRequestPB req; CreateTableResponsePB resp; req.set_name(kCdcStateTableName); req.mutable_namespace_()->CopyFrom(table_identifier.namespace_()); req.set_table_type(TableType::YQL_TABLE_TYPE); client::YBSchemaBuilder schema_builder; schema_builder.AddColumn(master::kCdcTabletId)->HashPrimaryKey()->Type(DataType::STRING); schema_builder.AddColumn(master::kCdcStreamId)->PrimaryKey()->Type(DataType::STRING); schema_builder.AddColumn(master::kCdcCheckpoint)->Type(DataType::STRING); schema_builder.AddColumn(master::kCdcData)->Type(QLType::CreateTypeMap( DataType::STRING, DataType::STRING)); schema_builder.AddColumn(master::kCdcLastReplicationTime)->Type(DataType::TIMESTAMP); client::YBSchema yb_schema; CHECK_OK(schema_builder.Build(&yb_schema)); auto schema = yb::client::internal::GetSchema(yb_schema); SchemaToPB(schema, req.mutable_schema()); // Explicitly set the number tablets if the corresponding flag is set, otherwise CreateTable // will use the same defaults as for regular tables. if (FLAGS_cdc_state_table_num_tablets > 0) { req.mutable_schema()->mutable_table_properties()->set_num_tablets( FLAGS_cdc_state_table_num_tablets); } Status s = CreateTable(&req, &resp, rpc); // We do not lock here so it is technically possible that the table was already created. // If so, there is nothing to do so we just ignore the "AlreadyPresent" error. if (!s.ok() && !s.IsAlreadyPresent()) { return s; } } return Status::OK(); } Status CatalogManager::IsCdcStateTableCreated(IsCreateTableDoneResponsePB* resp) { IsCreateTableDoneRequestPB req; req.mutable_table()->set_table_name(kCdcStateTableName); req.mutable_table()->mutable_namespace_()->set_name(kSystemNamespaceName); return IsCreateTableDone(&req, resp); } // Helper class to print a vector of CDCStreamInfo pointers. namespace { template<class CDCStreamInfoPointer> std::string JoinStreamsCSVLine(std::vector<CDCStreamInfoPointer> cdc_streams) { std::vector<CDCStreamId> cdc_stream_ids; for (const auto& cdc_stream : cdc_streams) { cdc_stream_ids.push_back(cdc_stream->id()); } return JoinCSVLine(cdc_stream_ids); } } // namespace Status CatalogManager::DeleteCDCStreamsForTable(const TableId& table_id) { return DeleteCDCStreamsForTables({table_id}); } Status CatalogManager::DeleteCDCStreamsForTables(const vector<TableId>& table_ids) { std::ostringstream tid_stream; for (const auto& tid : table_ids) { tid_stream << " " << tid; } LOG(INFO) << "Deleting CDC streams for tables:" << tid_stream.str(); std::vector<scoped_refptr<CDCStreamInfo>> streams; for (const auto& tid : table_ids) { auto newstreams = FindCDCStreamsForTable(tid); streams.insert(streams.end(), newstreams.begin(), newstreams.end()); } if (streams.empty()) { return Status::OK(); } // Do not delete them here, just mark them as DELETING and the catalog manager background thread // will handle the deletion. return MarkCDCStreamsAsDeleting(streams); } std::vector<scoped_refptr<CDCStreamInfo>> CatalogManager::FindCDCStreamsForTable( const TableId& table_id) { std::vector<scoped_refptr<CDCStreamInfo>> streams; std::shared_lock<LockType> l(lock_); for (const auto& entry : cdc_stream_map_) { auto ltm = entry.second->LockForRead(); if (ltm->data().table_id() == table_id && !ltm->data().started_deleting()) { streams.push_back(entry.second); } } return streams; } void CatalogManager::GetAllCDCStreams(std::vector<scoped_refptr<CDCStreamInfo>>* streams) { streams->clear(); streams->reserve(cdc_stream_map_.size()); std::shared_lock<LockType> l(lock_); for (const CDCStreamInfoMap::value_type& e : cdc_stream_map_) { if (!e.second->LockForRead()->data().is_deleting()) { streams->push_back(e.second); } } } Status CatalogManager::CreateCDCStream(const CreateCDCStreamRequestPB* req, CreateCDCStreamResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "CreateCDCStream from " << RequestorString(rpc) << ": " << req->DebugString(); RETURN_NOT_OK(CheckOnline()); TableIdentifierPB table_identifier; table_identifier.set_table_id(req->table_id()); scoped_refptr<TableInfo> table; RETURN_NOT_OK(FindTable(table_identifier, &table)); if (table == nullptr) { return STATUS(NotFound, "Table not found", req->table_id(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } { auto l = table->LockForRead(); if (l->data().started_deleting()) { return STATUS(NotFound, "Table does not exist", req->table_id(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } AlterTableRequestPB alter_table_req; alter_table_req.mutable_table()->set_table_id(req->table_id()); alter_table_req.set_wal_retention_secs(FLAGS_cdc_wal_retention_time_secs); AlterTableResponsePB alter_table_resp; Status s = this->AlterTable(&alter_table_req, &alter_table_resp, rpc); if (!s.ok()) { return STATUS(InternalError, "Unable to change the WAL retention time for table", req->table_id(), MasterError(MasterErrorPB::INTERNAL_ERROR)); } scoped_refptr<CDCStreamInfo> stream; { TRACE("Acquired catalog manager lock"); std::lock_guard<LockType> l(lock_); // Construct the CDC stream if the producer wasn't bootstrapped. CDCStreamId stream_id; stream_id = GenerateIdUnlocked(SysRowEntry::CDC_STREAM); stream = make_scoped_refptr<CDCStreamInfo>(stream_id); stream->mutable_metadata()->StartMutation(); SysCDCStreamEntryPB *metadata = &stream->mutable_metadata()->mutable_dirty()->pb; metadata->set_table_id(table->id()); metadata->mutable_options()->CopyFrom(req->options()); // Add the stream to the in-memory map. cdc_stream_map_[stream->id()] = stream; resp->set_stream_id(stream->id()); } TRACE("Inserted new CDC stream into CatalogManager maps"); // Update the on-disk system catalog. RETURN_NOT_OK(CheckLeaderStatusAndSetupError( sys_catalog_->AddItem(stream.get(), leader_ready_term()), "inserting CDC stream into sys-catalog", resp)); TRACE("Wrote CDC stream to sys-catalog"); // Commit the in-memory state. stream->mutable_metadata()->CommitMutation(); LOG(INFO) << "Created CDC stream " << stream->ToString(); RETURN_NOT_OK(CreateCdcStateTableIfNeeded(rpc)); return Status::OK(); } Status CatalogManager::DeleteCDCStream(const DeleteCDCStreamRequestPB* req, DeleteCDCStreamResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "Servicing DeleteCDCStream request from " << RequestorString(rpc) << ": " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); if (req->stream_id_size() < 1) { return STATUS(InvalidArgument, "No CDC Stream ID given", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } std::vector<scoped_refptr<CDCStreamInfo>> streams; { std::shared_lock<LockType> l(lock_); for (const auto& stream_id : req->stream_id()) { auto stream = FindPtrOrNull(cdc_stream_map_, stream_id); if (stream == nullptr || stream->LockForRead()->data().is_deleting()) { return STATUS(NotFound, "CDC stream does not exist", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } streams.push_back(stream); } } // Do not delete them here, just mark them as DELETING and the catalog manager background thread // will handle the deletion. Status s = MarkCDCStreamsAsDeleting(streams); if (!s.ok()) { if (s.IsIllegalState()) { PANIC_RPC(rpc, s.message().ToString()); } return CheckIfNoLongerLeaderAndSetupError(s, resp); } LOG(INFO) << "Successfully deleted CDC streams " << JoinStreamsCSVLine(streams) << " per request from " << RequestorString(rpc); return Status::OK(); } Status CatalogManager::MarkCDCStreamsAsDeleting( const std::vector<scoped_refptr<CDCStreamInfo>>& streams) { std::vector<std::unique_ptr<CDCStreamInfo::lock_type>> locks; std::vector<CDCStreamInfo*> streams_to_mark; locks.reserve(streams.size()); for (auto& stream : streams) { auto l = stream->LockForWrite(); l->mutable_data()->pb.set_state(SysCDCStreamEntryPB::DELETING); locks.push_back(std::move(l)); streams_to_mark.push_back(stream.get()); } // The mutation will be aborted when 'l' exits the scope on early return. RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItems(streams_to_mark, leader_ready_term()), "updating CDC streams in sys-catalog")); LOG(INFO) << "Successfully marked streams " << JoinStreamsCSVLine(streams_to_mark) << " as DELETING in sys catalog"; for (auto& lock : locks) { lock->Commit(); } return Status::OK(); } Status CatalogManager::FindCDCStreamsMarkedAsDeleting( std::vector<scoped_refptr<CDCStreamInfo>>* streams) { TRACE("Acquired catalog manager lock"); std::shared_lock<LockType> l(lock_); for (const CDCStreamInfoMap::value_type& entry : cdc_stream_map_) { auto ltm = entry.second->LockForRead(); if (ltm->data().is_deleting()) { LOG(INFO) << "Stream " << entry.second->id() << " was marked as DELETING"; streams->push_back(entry.second); } } return Status::OK(); } Status CatalogManager::CleanUpDeletedCDCStreams( const std::vector<scoped_refptr<CDCStreamInfo>>& streams) { RETURN_NOT_OK(CheckOnline()); auto ybclient = master_->async_client_initializer().client(); // First. For each deleted stream, delete the cdc state rows. // Delete all the entries in cdc_state table that contain all the deleted cdc streams. client::TableHandle cdc_table; const client::YBTableName cdc_state_table_name( YQL_DATABASE_CQL, master::kSystemNamespaceName, master::kCdcStateTableName); Status s = cdc_table.Open(cdc_state_table_name, ybclient); if (!s.ok()) { LOG(WARNING) << "Unable to open table " << master::kCdcStateTableName << " to delete stream ids entries: " << s; return s.CloneAndPrepend("Unable to open cdc_state table"); } std::shared_ptr<client::YBSession> session = ybclient->NewSession(); std::vector<std::pair<CDCStreamId, std::shared_ptr<client::YBqlWriteOp>>> stream_ops; std::set<CDCStreamId> failed_streams; for (const auto& stream : streams) { LOG(INFO) << "Deleting rows for stream " << stream->id(); vector<scoped_refptr<TabletInfo>> tablets; scoped_refptr<TableInfo> table; { TRACE("Acquired catalog manager lock"); SharedLock<LockType> l(lock_); table = FindPtrOrNull(*table_ids_map_, stream->table_id()); } // GetAllTablets locks lock_ in shared mode. if (table) { table->GetAllTablets(&tablets); } for (const auto& tablet : tablets) { const auto delete_op = cdc_table.NewDeleteOp(); auto* delete_req = delete_op->mutable_request(); QLAddStringHashValue(delete_req, tablet->tablet_id()); QLAddStringRangeValue(delete_req, stream->id()); s = session->Apply(delete_op); stream_ops.push_back(std::make_pair(stream->id(), delete_op)); LOG(INFO) << "Deleting stream " << stream->id() << " for tablet " << tablet->tablet_id() << " with request " << delete_req->ShortDebugString(); if (!s.ok()) { LOG(WARNING) << "Unable to delete stream with id " << stream->id() << " from table " << master::kCdcStateTableName << " for tablet " << tablet->tablet_id() << ". Status: " << s << ", Response: " << delete_op->response().ShortDebugString(); } } } // Flush all the delete operations. s = session->Flush(); if (!s.ok()) { LOG(ERROR) << "Unable to flush operations to delete cdc streams: " << s; return s.CloneAndPrepend("Error deleting cdc stream rows from cdc_state table"); } for (const auto& e : stream_ops) { if (!e.second->succeeded()) { LOG(WARNING) << "Error deleting cdc_state row with tablet id " << e.second->request().hashed_column_values(0).value().string_value() << " and stream id " << e.second->request().range_column_values(0).value().string_value() << ": " << e.second->response().status(); failed_streams.insert(e.first); } } // TODO: Read cdc_state table and verify that there are not rows with the specified cdc stream // and keep those in the map in the DELETED state to retry later. std::vector<std::unique_ptr<CDCStreamInfo::lock_type>> locks; locks.reserve(streams.size() - failed_streams.size()); std::vector<CDCStreamInfo*> streams_to_delete; streams_to_delete.reserve(streams.size() - failed_streams.size()); // Delete from sys catalog only those streams that were successfully delete from cdc_state. for (auto& stream : streams) { if (failed_streams.find(stream->id()) == failed_streams.end()) { locks.push_back(stream->LockForWrite()); streams_to_delete.push_back(stream.get()); } } // The mutation will be aborted when 'l' exits the scope on early return. RETURN_NOT_OK(CheckStatus( sys_catalog_->DeleteItems(streams_to_delete, leader_ready_term()), "deleting CDC streams from sys-catalog")); LOG(INFO) << "Successfully deleted streams " << JoinStreamsCSVLine(streams_to_delete) << " from sys catalog"; // Remove it from the map. TRACE("Removing from CDC stream maps"); { std::lock_guard<LockType> l(lock_); for (const auto& stream : streams_to_delete) { if (cdc_stream_map_.erase(stream->id()) < 1) { return STATUS(IllegalState, "Could not remove CDC stream from map", stream->id()); } } } LOG(INFO) << "Successfully deleted streams " << JoinStreamsCSVLine(streams_to_delete) << " from stream map"; for (auto& lock : locks) { lock->Commit(); } return Status::OK(); } Status CatalogManager::GetCDCStream(const GetCDCStreamRequestPB* req, GetCDCStreamResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "GetCDCStream from " << RequestorString(rpc) << ": " << req->DebugString(); RETURN_NOT_OK(CheckOnline()); if (!req->has_stream_id()) { return STATUS(InvalidArgument, "CDC Stream ID must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } scoped_refptr<CDCStreamInfo> stream; { std::shared_lock<LockType> l(lock_); stream = FindPtrOrNull(cdc_stream_map_, req->stream_id()); } if (stream == nullptr || stream->LockForRead()->data().is_deleting()) { return STATUS(NotFound, "Could not find CDC stream", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } auto stream_lock = stream->LockForRead(); CDCStreamInfoPB* stream_info = resp->mutable_stream(); stream_info->set_stream_id(stream->id()); stream_info->set_table_id(stream_lock->data().table_id()); stream_info->mutable_options()->CopyFrom(stream_lock->data().options()); return Status::OK(); } Status CatalogManager::ListCDCStreams(const ListCDCStreamsRequestPB* req, ListCDCStreamsResponsePB* resp) { RETURN_NOT_OK(CheckOnline()); scoped_refptr<TableInfo> table; bool filter_table = req->has_table_id(); if (filter_table) { // Lookup the table and verify that it exists. TableIdentifierPB table_identifier; table_identifier.set_table_id(req->table_id()); RETURN_NOT_OK(FindTable(table_identifier, &table)); if (table == nullptr) { return STATUS(NotFound, "Table not found", req->table_id(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } std::shared_lock<LockType> l(lock_); for (const CDCStreamInfoMap::value_type& entry : cdc_stream_map_) { auto ltm = entry.second->LockForRead(); if ((filter_table && table->id() != ltm->data().table_id()) || ltm->data().is_deleting()) { continue; // Skip deleting/deleted streams and streams from other tables. } CDCStreamInfoPB* stream = resp->add_streams(); stream->set_stream_id(entry.second->id()); stream->set_table_id(ltm->data().table_id()); stream->mutable_options()->CopyFrom(ltm->data().options()); } return Status::OK(); } bool CatalogManager::CDCStreamExistsUnlocked(const CDCStreamId& stream_id) { LOG_IF(DFATAL, !lock_.is_locked()) << "CatalogManager lock must be taken"; scoped_refptr<CDCStreamInfo> stream = FindPtrOrNull(cdc_stream_map_, stream_id); if (stream == nullptr || stream->LockForRead()->data().is_deleting()) { return false; } return true; } /* * UniverseReplication is setup in 4 stages within the Catalog Manager * 1. SetupUniverseReplication: Validates user input & requests Producer schema. * 2. GetTableSchemaCallback: Validates Schema compatibility & requests Producer CDC init. * 3. AddCDCStreamToUniverseAndInitConsumer: Setup RPC connections for CDC Streaming * 4. InitCDCConsumer: Initializes the Consumer settings to begin tailing data */ Status CatalogManager::SetupUniverseReplication(const SetupUniverseReplicationRequestPB* req, SetupUniverseReplicationResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "SetupUniverseReplication from " << RequestorString(rpc) << ": " << req->DebugString(); // Sanity checking section. RETURN_NOT_OK(CheckOnline()); if (!req->has_producer_id()) { return STATUS(InvalidArgument, "Producer universe ID must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } if (req->producer_master_addresses_size() <= 0) { return STATUS(InvalidArgument, "Producer master address must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } if (req->producer_bootstrap_ids().size() > 0 && req->producer_bootstrap_ids().size() != req->producer_table_ids().size()) { return STATUS(InvalidArgument, "Number of bootstrap ids must be equal to number of tables", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } std::unordered_map<TableId, std::string> table_id_to_bootstrap_id; if (req->producer_bootstrap_ids_size() > 0) { for (int i = 0; i < req->producer_table_ids().size(); i++) { table_id_to_bootstrap_id[req->producer_table_ids(i)] = req->producer_bootstrap_ids(i); } } // We assume that the list of table ids is unique. if (req->producer_bootstrap_ids().size() > 0 && req->producer_table_ids().size() != table_id_to_bootstrap_id.size()) { return STATUS(InvalidArgument, "When providing bootstrap ids, " "the list of tables must be unique", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } scoped_refptr<UniverseReplicationInfo> ri; { TRACE("Acquired catalog manager lock"); std::shared_lock<LockType> l(lock_); if (FindPtrOrNull(universe_replication_map_, req->producer_id()) != nullptr) { return STATUS(InvalidArgument, "Producer already present", req->producer_id(), MasterError(MasterErrorPB::INVALID_REQUEST)); } } // Create an entry in the system catalog DocDB for this new universe replication. ri = new UniverseReplicationInfo(req->producer_id()); ri->mutable_metadata()->StartMutation(); SysUniverseReplicationEntryPB *metadata = &ri->mutable_metadata()->mutable_dirty()->pb; metadata->set_producer_id(req->producer_id()); metadata->mutable_producer_master_addresses()->CopyFrom(req->producer_master_addresses()); metadata->mutable_tables()->CopyFrom(req->producer_table_ids()); metadata->set_state(SysUniverseReplicationEntryPB::INITIALIZING); RETURN_NOT_OK(CheckLeaderStatusAndSetupError( sys_catalog_->AddItem(ri.get(), leader_ready_term()), "inserting universe replication info into sys-catalog", resp)); TRACE("Wrote universe replication info to sys-catalog"); // Commit the in-memory state now that it's added to the persistent catalog. ri->mutable_metadata()->CommitMutation(); LOG(INFO) << "Setup universe replication from producer " << ri->ToString(); { std::lock_guard<LockType> l(lock_); universe_replication_map_[ri->id()] = ri; } // Initialize the CDC Stream by querying the Producer server for RPC sanity checks. auto result = ri->GetOrCreateCDCRpcTasks(req->producer_master_addresses()); if (!result.ok()) { MarkUniverseReplicationFailed(ri); return result.status().CloneAndAddErrorCode(MasterError(MasterErrorPB::INVALID_REQUEST)); } std::shared_ptr<CDCRpcTasks> cdc_rpc = *result; // For each table, run an async RPC task to verify a sufficient Producer:Consumer schema match. for (int i = 0; i < req->producer_table_ids_size(); i++) { auto table_info = std::make_shared<client::YBTableInfo>(); // SETUP CONTINUES after this async call. const Status s = cdc_rpc->client()->GetTableSchemaById( req->producer_table_ids(i), table_info, Bind(&enterprise::CatalogManager::GetTableSchemaCallback, Unretained(this), ri->id(), table_info, table_id_to_bootstrap_id)); if (!s.ok()) { MarkUniverseReplicationFailed(ri); return SetupError(resp->mutable_error(), MasterErrorPB::INVALID_REQUEST, s); } } LOG(INFO) << "Started schema validation for universe replication " << ri->ToString(); return Status::OK(); } void CatalogManager::MarkUniverseReplicationFailed( scoped_refptr<UniverseReplicationInfo> universe) { auto l = universe->LockForWrite(); if (l->data().pb.state() == SysUniverseReplicationEntryPB::DELETED) { l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::DELETED_ERROR); } else { l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::FAILED); } // Update sys_catalog. const Status s = sys_catalog_->UpdateItem(universe.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating universe replication info in sys-catalog"); } l->Commit(); } void CatalogManager::GetTableSchemaCallback( const std::string& universe_id, const std::shared_ptr<client::YBTableInfo>& info, const std::unordered_map<TableId, std::string>& table_bootstrap_ids, const Status& s) { scoped_refptr<UniverseReplicationInfo> universe; { std::shared_lock<LockType> catalog_lock(lock_); TRACE("Acquired catalog manager lock"); universe = FindPtrOrNull(universe_replication_map_, universe_id); if (universe == nullptr) { LOG(ERROR) << "Universe not found: " << universe_id; return; } } if (!s.ok()) { MarkUniverseReplicationFailed(universe); LOG(ERROR) << "Error getting schema for table " << info->table_id << ": " << s; return; } // Get corresponding table schema on local universe. GetTableSchemaRequestPB req; GetTableSchemaResponsePB resp; auto* table = req.mutable_table(); table->set_table_name(info->table_name.table_name()); table->mutable_namespace_()->set_name(info->table_name.namespace_name()); table->mutable_namespace_()->set_database_type( GetDatabaseTypeForTable(client::YBTable::ClientToPBTableType(info->table_type))); // Since YSQL tables are not present in table map, we first need to list tables to get the table // ID and then get table schema. // Remove this once table maps are fixed for YSQL. ListTablesRequestPB list_req; ListTablesResponsePB list_resp; list_req.set_name_filter(info->table_name.table_name()); Status status = ListTables(&list_req, &list_resp); if (!status.ok() || list_resp.has_error()) { LOG(ERROR) << "Error while listing table: " << status; MarkUniverseReplicationFailed(universe); return; } // TODO: This does not work for situation where tables in different YSQL schemas have the same // name. This will be fixed as part of #1476. for (const auto& t : list_resp.tables()) { if (t.name() == info->table_name.table_name() && t.namespace_().name() == info->table_name.namespace_name()) { table->set_table_id(t.id()); break; } } if (!table->has_table_id()) { LOG(ERROR) << "Could not find matching table for " << info->table_name.ToString(); MarkUniverseReplicationFailed(universe); return; } // We have a table match. Now get the table schema and validate status = GetTableSchema(&req, &resp); if (!status.ok() || resp.has_error()) { LOG(ERROR) << "Error while getting table schema: " << status; MarkUniverseReplicationFailed(universe); return; } auto result = info->schema.EquivalentForDataCopy(resp.schema()); if (!result.ok() || !*result) { LOG(ERROR) << "Source and target schemas don't match: Source: " << info->table_id << ", Target: " << resp.identifier().table_id() << ", Source schema: " << info->schema.ToString() << ", Target schema: " << resp.schema().DebugString(); MarkUniverseReplicationFailed(universe); return; } auto l = universe->LockForWrite(); auto master_addresses = l->data().pb.producer_master_addresses(); auto res = universe->GetOrCreateCDCRpcTasks(master_addresses); if (!res.ok()) { LOG(ERROR) << "Error while setting up client for producer " << universe->id(); l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::FAILED); const Status s = sys_catalog_->UpdateItem(universe.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating universe replication info in sys-catalog"); } l->Commit(); return; } std::shared_ptr<CDCRpcTasks> cdc_rpc = *res; vector<TableId> validated_tables; if (l->data().is_deleted_or_failed()) { // Nothing to do since universe is being deleted. return; } auto map = l->mutable_data()->pb.mutable_validated_tables(); (*map)[info->table_id] = resp.identifier().table_id(); // Now, all tables are validated. if (l->mutable_data()->pb.validated_tables_size() == l->mutable_data()->pb.tables_size()) { l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::VALIDATED); auto tbl_iter = l->data().pb.tables(); validated_tables.insert(validated_tables.begin(), tbl_iter.begin(), tbl_iter.end()); } // TODO: end of config validation should be where SetupUniverseReplication exits back to user LOG(INFO) << "UpdateItem in GetTableSchemaCallback"; // Update sys_catalog. status = sys_catalog_->UpdateItem(universe.get(), leader_ready_term()); if (!status.ok()) { return (void)CheckStatus(status, "updating universe replication info in sys-catalog"); } l->Commit(); // Create CDC stream for each validated table, after persisting the replication state change. if (!validated_tables.empty()) { std::unordered_map<std::string, std::string> options; options.reserve(2); options.emplace(cdc::kRecordType, CDCRecordType_Name(cdc::CDCRecordType::CHANGE)); options.emplace(cdc::kRecordFormat, CDCRecordFormat_Name(cdc::CDCRecordFormat::WAL)); for (const auto& table : validated_tables) { string producer_bootstrap_id; auto it = table_bootstrap_ids.find(table); if (it != table_bootstrap_ids.end()) { producer_bootstrap_id = it->second; } if (!producer_bootstrap_id.empty()) { auto table_id = std::make_shared<TableId>(); auto stream_options = std::make_shared<std::unordered_map<std::string, std::string>>(); cdc_rpc->client()->GetCDCStream(producer_bootstrap_id, table_id, stream_options, std::bind(&enterprise::CatalogManager::GetCDCStreamCallback, this, producer_bootstrap_id, table_id, stream_options, universe->id(), table, std::placeholders::_1)); } else { cdc_rpc->client()->CreateCDCStream( table, options, std::bind(&enterprise::CatalogManager::AddCDCStreamToUniverseAndInitConsumer, this, universe->id(), table, std::placeholders::_1)); } } } } void CatalogManager::GetCDCStreamCallback( const CDCStreamId& bootstrap_id, std::shared_ptr<TableId> table_id, std::shared_ptr<std::unordered_map<std::string, std::string>> options, const std::string& universe_id, const TableId& table, const Status& s) { if (!s.ok()) { LOG(ERROR) << "Unable to find bootstrap id " << bootstrap_id; AddCDCStreamToUniverseAndInitConsumer(universe_id, table, s); } else { if (*table_id != table) { const Status invalid_bootstrap_id_status = STATUS_FORMAT( InvalidArgument, "Invalid bootstrap id for table $0. Bootstrap id $1 belongs to table $2", table, bootstrap_id, *table_id); LOG(ERROR) << invalid_bootstrap_id_status; AddCDCStreamToUniverseAndInitConsumer(universe_id, table, invalid_bootstrap_id_status); } // todo check options AddCDCStreamToUniverseAndInitConsumer(universe_id, table, bootstrap_id); } } void CatalogManager::AddCDCStreamToUniverseAndInitConsumer( const std::string& universe_id, const TableId& table_id, const Result<CDCStreamId>& stream_id) { scoped_refptr<UniverseReplicationInfo> universe; { std::shared_lock<LockType> catalog_lock(lock_); TRACE("Acquired catalog manager lock"); universe = FindPtrOrNull(universe_replication_map_, universe_id); if (universe == nullptr) { LOG(ERROR) << "Universe not found: " << universe_id; return; } } if (!stream_id.ok()) { LOG(ERROR) << "Error setting up CDC stream for table " << table_id; MarkUniverseReplicationFailed(universe); return; } bool merge_alter = false; { auto l = universe->LockForWrite(); if (l->data().is_deleted_or_failed()) { // Nothing to do if universe is being deleted. return; } auto map = l->mutable_data()->pb.mutable_table_streams(); (*map)[table_id] = *stream_id; // This functions as a barrier: waiting for the last RPC call from GetTableSchemaCallback. if (l->mutable_data()->pb.table_streams_size() == l->data().pb.tables_size()) { // All tables successfully validated! Register CDC consumers & start replication. LOG(INFO) << "Registering CDC consumers for universe " << universe->id(); auto validated_tables = l->data().pb.validated_tables(); std::vector<CDCConsumerStreamInfo> consumer_info; consumer_info.reserve(l->data().pb.tables_size()); for (const auto& table : validated_tables) { CDCConsumerStreamInfo info; info.producer_table_id = table.first; info.consumer_table_id = table.second; info.stream_id = (*map)[info.producer_table_id]; consumer_info.push_back(info); } std::vector<HostPort> hp; HostPortsFromPBs(l->data().pb.producer_master_addresses(), &hp); Status s = InitCDCConsumer(consumer_info, HostPort::ToCommaSeparatedString(hp), l->data().pb.producer_id()); if (!s.ok()) { LOG(ERROR) << "Error registering subscriber: " << s; l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::FAILED); } else { GStringPiece original_producer_id(universe->id()); if (original_producer_id.ends_with(".ALTER")) { // Don't enable ALTER universes, merge them into the main universe instead. merge_alter = true; } else { l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::ACTIVE); } } } // Update sys_catalog with new producer table id info. Status status = sys_catalog_->UpdateItem(universe.get(), leader_ready_term()); if (!status.ok()) { return (void)CheckStatus(status, "updating universe replication info in sys-catalog"); } l->Commit(); } // If this is an 'alter', merge back into primary command now that setup is a success. if (merge_alter) { MergeUniverseReplication(universe); } } Status CatalogManager::InitCDCConsumer( const std::vector<CDCConsumerStreamInfo>& consumer_info, const std::string& master_addrs, const std::string& producer_universe_uuid) { std::unordered_set<HostPort, HostPortHash> tserver_addrs; // Get the tablets in the consumer table. cdc::ProducerEntryPB producer_entry; for (const auto& stream_info : consumer_info) { GetTableLocationsRequestPB consumer_table_req; consumer_table_req.set_max_returned_locations(std::numeric_limits<int32_t>::max()); GetTableLocationsResponsePB consumer_table_resp; TableIdentifierPB table_identifer; table_identifer.set_table_id(stream_info.consumer_table_id); *(consumer_table_req.mutable_table()) = table_identifer; RETURN_NOT_OK(GetTableLocations(&consumer_table_req, &consumer_table_resp)); cdc::StreamEntryPB stream_entry; // Get producer tablets and map them to the consumer tablets RETURN_NOT_OK(CreateTabletMapping( stream_info.producer_table_id, stream_info.consumer_table_id, producer_universe_uuid, master_addrs, consumer_table_resp, &tserver_addrs, &stream_entry)); (*producer_entry.mutable_stream_map())[stream_info.stream_id] = std::move(stream_entry); } // Log the Network topology of the Producer Cluster auto master_addrs_list = StringSplit(master_addrs, ','); producer_entry.mutable_master_addrs()->Reserve(master_addrs_list.size()); for (const auto& addr : master_addrs_list) { auto hp = VERIFY_RESULT(HostPort::FromString(addr, 0)); HostPortToPB(hp, producer_entry.add_master_addrs()); } producer_entry.mutable_tserver_addrs()->Reserve(tserver_addrs.size()); for (const auto& addr : tserver_addrs) { HostPortToPB(addr, producer_entry.add_tserver_addrs()); } auto l = cluster_config_->LockForWrite(); auto producer_map = l->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto it = producer_map->find(producer_universe_uuid); if (it != producer_map->end()) { return STATUS(InvalidArgument, "Already created a consumer for this universe"); } // TServers will use the ClusterConfig to create CDC Consumers for applicable local tablets. (*producer_map)[producer_universe_uuid] = std::move(producer_entry); l->mutable_data()->pb.set_version(l->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); l->Commit(); return Status::OK(); } void CatalogManager::MergeUniverseReplication(scoped_refptr<UniverseReplicationInfo> universe) { // Merge back into primary command now that setup is a success. GStringPiece original_producer_id(universe->id()); if (!original_producer_id.ends_with(".ALTER")) { return; } original_producer_id.remove_suffix(sizeof(".ALTER")-1 /* exclude \0 ending */); LOG(INFO) << "Merging CDC universe: " << universe->id() << " into " << original_producer_id.ToString(); scoped_refptr<UniverseReplicationInfo> original_universe; { std::shared_lock<LockType> catalog_lock(lock_); TRACE("Acquired catalog manager lock"); original_universe = FindPtrOrNull(universe_replication_map_, original_producer_id.ToString()); if (original_universe == nullptr) { LOG(ERROR) << "Universe not found: " << original_producer_id.ToString(); return; } } // Merge Cluster Config for TServers. { auto cl = cluster_config_->LockForWrite(); auto pm = cl->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto original_producer_entry = pm->find(original_universe->id()); auto alter_producer_entry = pm->find(universe->id()); if (original_producer_entry != pm->end() && alter_producer_entry != pm->end()) { // Merge the Tables from the Alter into the original. auto as = alter_producer_entry->second.stream_map(); original_producer_entry->second.mutable_stream_map()->insert(as.begin(), as.end()); // Delete the Alter pm->erase(alter_producer_entry); } else { LOG(WARNING) << "Could not find both universes in Cluster Config: " << universe->id(); } cl->mutable_data()->pb.set_version(cl->mutable_data()->pb.version() + 1); const Status s = sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating cluster config in sys-catalog"); } cl->Commit(); } // Merge Master Config on Consumer. (no need for Producer changes, since it uses stream_id) { auto original_lock = original_universe->LockForWrite(); auto alter_lock = universe->LockForWrite(); // Merge Table->StreamID mapping. auto at = alter_lock->mutable_data()->pb.mutable_tables(); original_lock->mutable_data()->pb.mutable_tables()->MergeFrom(*at); at->Clear(); auto as = alter_lock->mutable_data()->pb.mutable_table_streams(); original_lock->mutable_data()->pb.mutable_table_streams()->insert(as->begin(), as->end()); as->clear(); auto av = alter_lock->mutable_data()->pb.mutable_validated_tables(); original_lock->mutable_data()->pb.mutable_validated_tables()->insert(av->begin(), av->end()); av->clear(); alter_lock->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::DELETED); vector<UniverseReplicationInfo*> universes{original_universe.get(), universe.get()}; const Status s = sys_catalog_->UpdateItems(universes, leader_ready_term()); if (!s.ok()) { return (void)CheckStatus(s, "updating universe replication entries in sys-catalog"); } alter_lock->Commit(); original_lock->Commit(); } // TODO: universe_replication_map_.erase(universe->id()) at a later time. // TwoDCTest.AlterUniverseReplicationTables crashes due to undiagnosed race right now. LOG(INFO) << "Done with Merging " << universe->id() << " into " << original_universe->id(); } Status CatalogManager::DeleteUniverseReplication(const DeleteUniverseReplicationRequestPB* req, DeleteUniverseReplicationResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "Servicing DeleteUniverseReplication request from " << RequestorString(rpc) << ": " << req->ShortDebugString(); RETURN_NOT_OK(CheckOnline()); if (!req->has_producer_id()) { return STATUS(InvalidArgument, "Producer universe ID required", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } scoped_refptr<UniverseReplicationInfo> ri; { std::shared_lock<LockType> catalog_lock(lock_); TRACE("Acquired catalog manager lock"); ri = FindPtrOrNull(universe_replication_map_, req->producer_id()); if (ri == nullptr) { return STATUS(NotFound, "Universe replication info does not exist", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } auto l = ri->LockForWrite(); l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::DELETED); // Delete subscribers on the Consumer Registry (removes from TServers). LOG(INFO) << "Deleting subscribers for producer " << req->producer_id(); { auto cl = cluster_config_->LockForWrite(); auto producer_map = cl->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto it = producer_map->find(req->producer_id()); if (it != producer_map->end()) { producer_map->erase(it); cl->mutable_data()->pb.set_version(cl->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); cl->Commit(); } } // Delete CDC stream config on the Producer. if (!l->data().pb.table_streams().empty()) { auto result = ri->GetOrCreateCDCRpcTasks(l->data().pb.producer_master_addresses()); if (!result.ok()) { LOG(WARNING) << "Unable to create cdc rpc task. CDC streams won't be deleted: " << result; } else { auto cdc_rpc = *result; vector<CDCStreamId> streams; for (const auto& table : l->data().pb.table_streams()) { streams.push_back(table.second); } auto s = cdc_rpc->client()->DeleteCDCStream(streams); if (!s.ok()) { LOG(WARNING) << "Unable to delete CDC stream " << s; } } } // Delete universe in the Universe Config. DeleteUniverseReplicationUnlocked(ri); l->Commit(); LOG(INFO) << "Processed delete universe replication " << ri->ToString() << " per request from " << RequestorString(rpc); return Status::OK(); } void CatalogManager::DeleteUniverseReplicationUnlocked( scoped_refptr<UniverseReplicationInfo> universe) { // Assumes that caller has locked universe. Status s = sys_catalog_->DeleteItem(universe.get(), leader_ready_term()); if (!s.ok()) { LOG(ERROR) << "An error occured while updating sys-catalog: " << s << ": universe_id: " << universe->id(); return; } // Remove it from the map. std::lock_guard<LockType> catalog_lock(lock_); if (universe_replication_map_.erase(universe->id()) < 1) { LOG(ERROR) << "An error occured while removing replication info from map: " << s << ": universe_id: " << universe->id(); } } Status CatalogManager::SetUniverseReplicationEnabled( const SetUniverseReplicationEnabledRequestPB* req, SetUniverseReplicationEnabledResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "Servicing SetUniverseReplicationEnabled request from " << RequestorString(rpc) << ": " << req->ShortDebugString(); // Sanity Checking Cluster State and Input. RETURN_NOT_OK(CheckOnline()); if (!req->has_producer_id()) { return STATUS(InvalidArgument, "Producer universe ID must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } if (!req->has_is_enabled()) { return STATUS(InvalidArgument, "Must explicitly set whether to enable", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } scoped_refptr<UniverseReplicationInfo> universe; { std::shared_lock<LockType> l(lock_); universe = FindPtrOrNull(universe_replication_map_, req->producer_id()); if (universe == nullptr) { return STATUS(NotFound, "Could not find CDC producer universe", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } // Update the Master's Universe Config with the new state. { auto l = universe->LockForWrite(); if (l->data().pb.state() != SysUniverseReplicationEntryPB::DISABLED && l->data().pb.state() != SysUniverseReplicationEntryPB::ACTIVE) { return STATUS( InvalidArgument, Format("Universe Replication in invalid state: $0. Retry or Delete.", SysUniverseReplicationEntryPB::State_Name(l->data().pb.state())), req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } if (req->is_enabled()) { l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::ACTIVE); } else { // DISABLE. l->mutable_data()->pb.set_state(SysUniverseReplicationEntryPB::DISABLED); } RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(universe.get(), leader_ready_term()), "updating universe replication info in sys-catalog")); l->Commit(); } // Modify the Consumer Registry, which will fan out this info to all TServers on heartbeat. { auto l = cluster_config_->LockForWrite(); auto producer_map = l->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto it = producer_map->find(req->producer_id()); if (it == producer_map->end()) { LOG(WARNING) << "Valid Producer Universe not in Consumer Registry: " << req->producer_id(); return STATUS(NotFound, "Could not find CDC producer universe", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } (*it).second.set_disable_stream(!req->is_enabled()); l->mutable_data()->pb.set_version(l->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); l->Commit(); } return Status::OK(); } Status CatalogManager::AlterUniverseReplication(const AlterUniverseReplicationRequestPB* req, AlterUniverseReplicationResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "Servicing AlterUniverseReplication request from " << RequestorString(rpc) << ": " << req->ShortDebugString(); // Sanity Checking Cluster State and Input. RETURN_NOT_OK(CheckOnline()); if (!req->has_producer_id()) { return STATUS(InvalidArgument, "Producer universe ID must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } // Verify that there is an existing Universe config scoped_refptr<UniverseReplicationInfo> original_ri; { std::shared_lock<LockType> l(lock_); original_ri = FindPtrOrNull(universe_replication_map_, req->producer_id()); if (original_ri == nullptr) { return STATUS(NotFound, "Could not find CDC producer universe", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } // Currently, config options are mutually exclusive to simplify transactionality. int config_count = (req->producer_master_addresses_size() > 0 ? 1 : 0) + (req->producer_table_ids_to_remove_size() > 0 ? 1 : 0) + (req->producer_table_ids_to_add_size() > 0 ? 1 : 0); if (config_count != 1) { return STATUS(InvalidArgument, "Only 1 Alter operation per request currently supported", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } // Config logic... if (req->producer_master_addresses_size() > 0) { // 'set_master_addresses' // TODO: Verify the input. Setup an RPC Task, ListTables, ensure same. // 1a. Persistent Config: Update the Universe Config for Master. { auto l = original_ri->LockForWrite(); l->mutable_data()->pb.mutable_producer_master_addresses()->CopyFrom( req->producer_master_addresses()); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(original_ri.get(), leader_ready_term()), "updating universe replication info in sys-catalog")); l->Commit(); } // 1b. Persistent Config: Update the Consumer Registry (updates TServers) { auto l = cluster_config_->LockForWrite(); auto producer_map = l->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto it = producer_map->find(req->producer_id()); if (it == producer_map->end()) { LOG(WARNING) << "Valid Producer Universe not in Consumer Registry: " << req->producer_id(); return STATUS(NotFound, "Could not find CDC producer universe", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } (*it).second.mutable_master_addrs()->CopyFrom(req->producer_master_addresses()); l->mutable_data()->pb.set_version(l->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); l->Commit(); } // 2. Memory Update: Change cdc_rpc_tasks (Master cache) { auto result = original_ri->GetOrCreateCDCRpcTasks(req->producer_master_addresses()); if (!result.ok()) { return result.status().CloneAndAddErrorCode(MasterError(MasterErrorPB::INTERNAL_ERROR)); } } } else if (req->producer_table_ids_to_remove_size() > 0) { // 'remove_table' auto it = req->producer_table_ids_to_remove(); std::set<string> table_ids_to_remove(it.begin(), it.end()); // Filter out any tables that aren't in the existing replication config. { auto l = original_ri->LockForRead(); auto tbl_iter = l->data().pb.tables(); std::set<string> existing_tables(tbl_iter.begin(), tbl_iter.end()), filtered_list; set_intersection(table_ids_to_remove.begin(), table_ids_to_remove.end(), existing_tables.begin(), existing_tables.end(), std::inserter(filtered_list, filtered_list.begin())); filtered_list.swap(table_ids_to_remove); } vector<CDCStreamId> streams_to_remove; // 1. Update the Consumer Registry (removes from TServers). { auto cl = cluster_config_->LockForWrite(); auto pm = cl->mutable_data()->pb.mutable_consumer_registry()->mutable_producer_map(); auto producer_entry = pm->find(req->producer_id()); if (producer_entry != pm->end()) { // Remove the Tables Specified (not part of the key). auto stream_map = producer_entry->second.mutable_stream_map(); for (auto& p : *stream_map) { if (table_ids_to_remove.count(p.second.producer_table_id()) > 0) { streams_to_remove.push_back(p.first); } } if (streams_to_remove.size() == stream_map->size()) { // If this ends with an empty Map, disallow and force user to delete. LOG(WARNING) << "CDC 'remove_table' tried to remove all tables." << req->producer_id(); return STATUS( InvalidArgument, "Cannot remove all tables with alter. Use delete_universe_replication instead.", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } else if (streams_to_remove.empty()) { // If this doesn't delete anything, notify the user. return STATUS(InvalidArgument, "Removal matched no entries.", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } for (auto& key : streams_to_remove) { stream_map->erase(stream_map->find(key)); } } cl->mutable_data()->pb.set_version(cl->mutable_data()->pb.version() + 1); RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(cluster_config_.get(), leader_ready_term()), "updating cluster config in sys-catalog")); cl->Commit(); } // 2. Remove from Master Configs on Producer and Consumer. { auto l = original_ri->LockForWrite(); if (!l->data().pb.table_streams().empty()) { // Delete Relevant Table->StreamID mappings on Consumer. auto table_streams = l->mutable_data()->pb.mutable_table_streams(); auto validated_tables = l->mutable_data()->pb.mutable_validated_tables(); for (auto& key : table_ids_to_remove) { table_streams->erase(table_streams->find(key)); validated_tables->erase(validated_tables->find(key)); } for (int i = 0; i < l->mutable_data()->pb.tables_size(); i++) { if (table_ids_to_remove.count(l->mutable_data()->pb.tables(i)) > 0) { l->mutable_data()->pb.mutable_tables()->DeleteSubrange(i, 1); --i; } } // Delete CDC stream config on the Producer. auto result = original_ri->GetOrCreateCDCRpcTasks(l->data().pb.producer_master_addresses()); if (!result.ok()) { LOG(WARNING) << "Unable to create cdc rpc task. CDC streams won't be deleted: " << result; } else { auto s = (*result)->client()->DeleteCDCStream(streams_to_remove); if (!s.ok()) { std::stringstream os; std::copy(streams_to_remove.begin(), streams_to_remove.end(), std::ostream_iterator<CDCStreamId>(os, ", ")); LOG(WARNING) << "Unable to delete CDC streams: " << os.str() << s; } } } RETURN_NOT_OK(CheckStatus( sys_catalog_->UpdateItem(original_ri.get(), leader_ready_term()), "updating universe replication info in sys-catalog")); l->Commit(); } } else if (req->producer_table_ids_to_add_size() > 0) { // 'add_table' string alter_producer_id = req->producer_id() + ".ALTER"; // Verify no 'alter' command running. scoped_refptr<UniverseReplicationInfo> alter_ri; { std::shared_lock<LockType> l(lock_); alter_ri = FindPtrOrNull(universe_replication_map_, alter_producer_id); } { if (alter_ri != nullptr) { LOG(INFO) << "Found " << alter_producer_id << "... Removing"; if (alter_ri->LockForRead()->data().is_deleted_or_failed()) { // Delete previous Alter if it's completed but failed. master::DeleteUniverseReplicationRequestPB delete_req; delete_req.set_producer_id(alter_ri->id()); master::DeleteUniverseReplicationResponsePB delete_resp; Status s = DeleteUniverseReplication(&delete_req, &delete_resp, rpc); if (!s.ok()) { resp->mutable_error()->Swap(delete_resp.mutable_error()); return s; } } else { return STATUS(InvalidArgument, "Alter for CDC producer currently running", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } } } // Only add new tables. Ignore tables that are currently being replicated. auto tid_iter = req->producer_table_ids_to_add(); unordered_set<string> new_tables(tid_iter.begin(), tid_iter.end()); { auto l = original_ri->LockForRead(); for(auto t : l->data().pb.tables()) { auto pos = new_tables.find(t); if (pos != new_tables.end()) { new_tables.erase(pos); } } } if (new_tables.empty()) { return STATUS(InvalidArgument, "CDC producer already contains all requested tables", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } // 1. create an ALTER table request that mirrors the original 'setup_replication'. master::SetupUniverseReplicationRequestPB setup_req; master::SetupUniverseReplicationResponsePB setup_resp; setup_req.set_producer_id(alter_producer_id); setup_req.mutable_producer_master_addresses()->CopyFrom( original_ri->LockForRead()->data().pb.producer_master_addresses()); for (auto t : new_tables) { setup_req.add_producer_table_ids(t); } // 2. run the 'setup_replication' pipeline on the ALTER Table Status s = SetupUniverseReplication(&setup_req, &setup_resp, rpc); if (!s.ok()) { resp->mutable_error()->Swap(setup_resp.mutable_error()); return s; } // NOTE: ALTER merges back into original after completion. } return Status::OK(); } Status CatalogManager::GetUniverseReplication(const GetUniverseReplicationRequestPB* req, GetUniverseReplicationResponsePB* resp, rpc::RpcContext* rpc) { LOG(INFO) << "GetUniverseReplication from " << RequestorString(rpc) << ": " << req->DebugString(); RETURN_NOT_OK(CheckOnline()); if (!req->has_producer_id()) { return STATUS(InvalidArgument, "Producer universe ID must be provided", req->ShortDebugString(), MasterError(MasterErrorPB::INVALID_REQUEST)); } scoped_refptr<UniverseReplicationInfo> universe; { std::shared_lock<LockType> l(lock_); universe = FindPtrOrNull(universe_replication_map_, req->producer_id()); if (universe == nullptr) { return STATUS(NotFound, "Could not find CDC producer universe", req->ShortDebugString(), MasterError(MasterErrorPB::OBJECT_NOT_FOUND)); } } auto l = universe->LockForRead(); resp->mutable_entry()->CopyFrom(l->data().pb); return Status::OK(); } void CatalogManager::Started() { snapshot_coordinator_.Start(); } } // namespace enterprise } // namespace master } // namespace yb
#include "Vector2DI.h" #include "Vector2DF.h" namespace altseed { Vector2DI::Vector2DI() : X(0), Y(0) {} Vector2DI::Vector2DI(int32_t x, int32_t y) : X(x), Y(y) {} bool Vector2DI::operator==(const Vector2DI& right) { return X == right.X && Y == right.Y; } bool Vector2DI::operator!=(const Vector2DI& right) { return X != right.X || Y != right.Y; } Vector2DI Vector2DI::operator-() { return Vector2DI(-X, -Y); } Vector2DI Vector2DI::operator+(const Vector2DI& right) { return Vector2DI(X + right.X, Y + right.Y); } Vector2DI Vector2DI::operator-(const Vector2DI& right) { return Vector2DI(X - right.X, Y - right.Y); } Vector2DI Vector2DI::operator*(const Vector2DI& right) { return Vector2DI(X * right.X, Y * right.Y); } Vector2DI Vector2DI::operator/(const Vector2DI& right) { return Vector2DI(X / right.X, Y / right.Y); } Vector2DI Vector2DI::operator*(int32_t right) { return Vector2DI(X * right, Y * right); } Vector2DI Vector2DI::operator/(int32_t right) { return Vector2DI(X / right, Y / right); } Vector2DI& Vector2DI::operator+=(const Vector2DI& right) { X += right.X; Y += right.Y; return *this; } Vector2DI& Vector2DI::operator-=(const Vector2DI& right) { X -= right.X; Y -= right.Y; return *this; } Vector2DI& Vector2DI::operator*=(const Vector2DI& right) { X *= right.X; Y *= right.Y; return *this; } Vector2DI& Vector2DI::operator/=(const Vector2DI& right) { X /= right.X; Y /= right.Y; return *this; } Vector2DI& Vector2DI::operator*=(int32_t right) { X *= right; Y *= right; return *this; } Vector2DI& Vector2DI::operator/=(int32_t right) { X /= right; Y /= right; return *this; } Vector2DF Vector2DI::To2DF() const { return Vector2DF(X, Y); } Vector2DI Vector2DI::DivideByScalar(const Vector2DI& v1, float v2) { return Vector2DI(v1.X / v2, v1.Y / v2); } } // namespace altseed
INCLUDE "hardware.inc" SECTION "Helper Functions",HOME ;-------------------------------------------------------------------------- ;- wait_ly() b = ly to wait for - ;-------------------------------------------------------------------------- wait_ly:: ld c,rLY & $FF .no_same_ly: ld a,[$FF00+c] cp a,b jr nz,.no_same_ly ret ;-------------------------------------------------------------------------- ;- memset() d = value hl = start address bc = size - ;-------------------------------------------------------------------------- memset:: ld a,d ld [hl+],a dec bc ld a,b or a,c jr nz,memset ret ;-------------------------------------------------------------------------- ;- CARTRIDGE HEADER - ;-------------------------------------------------------------------------- SECTION "Cartridge Header",HOME[$0100] nop nop jr Main NINTENDO_LOGO ; 0123456789ABC DB "LCD TIMINGS.." DW $0000 DB $00 ;GBC flag DB 0,0,0 ;SuperGameboy DB $1B ;CARTTYPE (MBC5+RAM+BATTERY) DB 0 ;ROMSIZE DB 4 ;RAMSIZE (16*8KB) DB $01,$00 ;Destination (0 = Japan, 1 = Non Japan) | Manufacturer DB 0,0,0,0 ;Version | Complement check | Checksum ;-------------------------------------------------------------------------- ;- Main() - ;-------------------------------------------------------------------------- Main: di ld a,$0A ld [$0000],a ; enable SRAM ; Clear SRAM ld a,$00 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$01 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$02 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$03 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$04 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$05 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$06 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ld a,$07 ld [$4000],a ld d,0 ld hl,$A000 ld bc,$2000 call memset ;-------------------- ld a,IEF_VBLANK ld [rIE],a ;-------------------- ld a,1 ld [rLYC],a ;-------------------- ld a,$00 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_0 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$01 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_1 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$02 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_2 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$03 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_3 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,143 ld [rLYC],a ;-------------------- ld a,$04 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_0 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$05 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_1 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$06 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_2 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$07 ld [$4000],a ld b,140 call wait_ly xor a,a ld [rIF],a ld c,rSTAT & $FF ld hl,$A000 halt call stat_read_test_delay_dmg_3 ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 ;-------------------- ld a,$00 ld [$0000],a ; disable SRAM ;-------------------- ld a,$80 ld [rNR52],a ld a,$FF ld [rNR51],a ld a,$77 ld [rNR50],a ld a,$C0 ld [rNR11],a ld a,$E0 ld [rNR12],a ld a,$00 ld [rNR13],a ld a,$87 ld [rNR14],a .end: halt jr .end ;-------------------------------------------------------------------------- stat_read_test_delay_dmg_3: nop stat_read_test_delay_dmg_2: nop stat_read_test_delay_dmg_1: nop stat_read_test_delay_dmg_0: REPT ( ((70224+456*12)/4) / 4 ) ld a,[$FF00+c] ld [hl+],a ENDR ret ;--------------------------------------------------------------------------
; intmax_t strtoimax(const char *nptr, char **endptr, int base) SECTION code_clib SECTION code_inttypes PUBLIC asm_strtoimax EXTERN asm_strtol defc asm_strtoimax = asm_strtol
; A080335: Diagonal in square spiral or maze arrangement of natural numbers. ; 1,5,9,17,25,37,49,65,81,101,121,145,169,197,225,257,289,325,361,401,441,485,529,577,625,677,729,785,841,901,961,1025,1089,1157,1225,1297,1369,1445,1521,1601,1681,1765,1849,1937,2025,2117,2209,2305,2401,2501,2601,2705,2809,2917,3025,3137,3249,3365,3481,3601,3721,3845,3969,4097,4225,4357,4489,4625,4761,4901,5041,5185,5329,5477,5625,5777,5929,6085,6241,6401,6561,6725,6889,7057,7225,7397,7569,7745,7921,8101,8281,8465,8649,8837,9025,9217,9409,9605,9801,10001 mov $1,$0 add $0,1 pow $0,2 mod $1,2 add $0,$1
db 0 ; species ID placeholder db 55, 40, 85, 40, 80, 105 ; hp atk def spd sat sdf db NORMAL, FLYING ; type db 75 ; catch rate db 114 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F12_5 ; gender ratio db 100 ; unknown 1 db 10 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/togetic/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_FAST ; growth rate dn EGG_FLYING, EGG_FAIRY ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, ROCK_SMASH, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, FIRE_BLAST, SWIFT, DEFENSE_CURL, DREAM_EATER, DETECT, REST, ATTRACT, STEEL_WING, WIND_RIDE, FLAMETHROWER ; end
; A229803: Domination number for rook graph HR(n) on a triangular board of hexagonal cells. The rook can move along any row of adjacent cells, in any of the three directions. ; 1,1,2,2,3,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9 mul $0,6 add $0,15 div $0,13
// // Created by limenghua on 18-3-12. // #include <iostream> #include <boost/config.hpp> #include "modulepp/module.h" #include "modulepp/plugin/plugin_config.h" #include "modulepp/plugin/plugin_module.h" #include "core/service.h" namespace my_namespace { using namespace modulepp; using modulepp::plugin::plugin_module; using modulepp::plugin::plugin_config; class demo_module:public plugin_module { public: demo_module(): plugin_module("demo_module"){ add_dependencies("core"); std::cout<<"demo module construct"<<std::endl; } ~demo_module(){ std::cout<<"demo module disstruct"<<std::endl; } virtual void start()override { auto service = get_service<core::service>("core.service"); std::string dec = service->describe(); module::start(); std::cout<<"demo module start..."<<std::endl; std::cout << "get describe from core is:"<< dec << std::endl; register_service<int>("age",std::make_shared<int>(100)); } virtual void stop()override { module::stop(); std::cout<<"demo module stop..."<<std::endl; } }; // Exporting `my_namespace::plugin` variable with alias name `plugin` // (Has the same effect as `BOOST_DLL_ALIAS(my_namespace::plugin, plugin)`) extern "C" BOOST_SYMBOL_EXPORT demo_module plugin_module; demo_module plugin_module; } // namespace my_namespace
; A003893: a(n) = Fibonacci(n) mod 10. ; Coded manually 2021-03-31 by Simon Strandgaard, https://github.com/neoneye ; 0,1,1,2,3,5,8,3,1,4,5,9,4,3,7,0,7,7,4,1,5,6,1,7,8,5,3,8,1,9,0,9,9,8,7,5,2,7,9,6,5,1,6,7,3,0,3,3,6,9,5,4,9,3,2,5,7,2,9,1,0,1,1,2,3,5,8,3,1,4,5,9,4,3,7,0,7,7,4,1,5,6,1,7,8,5,3,8,1,9,0,9,9,8,7,5,2,7,9,6,5,1,6,7,3 mov $3,1 lpb $0 sub $0,1 mov $2,$1 add $1,$3 mod $1,10 mov $3,$2 lpe mov $0,$1
; A007844: Least positive integer k for which 3^n divides k!. ; 1,3,6,9,9,12,15,18,18,21,24,27,27,27,30,33,36,36,39,42,45,45,48,51,54,54,54,57,60,63,63,66,69,72,72,75,78,81,81,81,81,84,87,90,90,93,96,99,99,102,105,108,108,108,111,114,117,117,120,123,126,126,129,132,135,135,135,138,141,144,144,147,150,153,153,156,159,162,162,162,162,165,168,171,171,174,177,180,180,183,186,189,189,189,192,195,198,198,201,204 mov $2,$0 lpb $2 mov $1,$0 trn $1,1 seq $1,96346 ; Complement of A004128. sub $2,1 lpe sub $1,$0 mov $0,$1 add $0,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 "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "base/time/time.h" #include "chrome/browser/chromeos/login/screens/error_screen.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/login/localized_values_builder.h" #include "ui/chromeos/devicetype_utils.h" #include "ui/strings/grit/ui_strings.h" namespace { const char kJsScreenPath[] = "login.ErrorMessageScreen"; } // namespace namespace chromeos { ErrorScreenHandler::ErrorScreenHandler() : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { set_call_js_prefix(kJsScreenPath); } ErrorScreenHandler::~ErrorScreenHandler() { if (screen_) screen_->OnViewDestroyed(this); } void ErrorScreenHandler::Show() { if (!page_is_ready()) { show_on_init_ = true; return; } BaseScreenHandler::ShowScreen(kScreenId); if (screen_) screen_->OnShow(); showing_ = true; } void ErrorScreenHandler::Hide() { showing_ = false; if (screen_) screen_->OnHide(); } void ErrorScreenHandler::Bind(ErrorScreen* screen) { screen_ = screen; BaseScreenHandler::SetBaseScreen(screen_); } void ErrorScreenHandler::Unbind() { screen_ = nullptr; BaseScreenHandler::SetBaseScreen(nullptr); } void ErrorScreenHandler::ShowOobeScreen(OobeScreen screen) { ShowScreen(screen); } void ErrorScreenHandler::RegisterMessages() { AddCallback("hideCaptivePortal", &ErrorScreenHandler::HandleHideCaptivePortal); BaseScreenHandler::RegisterMessages(); } void ErrorScreenHandler::DeclareLocalizedValues( ::login::LocalizedValuesBuilder* builder) { builder->Add("deviceType", ui::GetChromeOSDeviceName()); builder->Add("loginErrorTitle", IDS_LOGIN_ERROR_TITLE); builder->Add("rollbackErrorTitle", IDS_RESET_SCREEN_REVERT_ERROR); builder->Add("signinOfflineMessageBody", ui::SubstituteChromeOSDeviceType(IDS_LOGIN_OFFLINE_MESSAGE)); builder->Add("kioskOfflineMessageBody", IDS_KIOSK_OFFLINE_MESSAGE); builder->Add("kioskOnlineTitle", IDS_LOGIN_NETWORK_RESTORED_TITLE); builder->Add("kioskOnlineMessageBody", IDS_KIOSK_ONLINE_MESSAGE); builder->Add("autoEnrollmentOfflineMessageBody", IDS_LOGIN_AUTO_ENROLLMENT_OFFLINE_MESSAGE); builder->AddF("rollbackErrorMessageBody", IDS_RESET_SCREEN_REVERT_ERROR_EXPLANATION, IDS_SHORT_PRODUCT_NAME); builder->Add("captivePortalTitle", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_TITLE); builder->Add("captivePortalMessage", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL); builder->Add("captivePortalProxyMessage", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_PROXY); builder->Add("captivePortalNetworkSelect", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_NETWORK_SELECT); builder->Add("signinProxyMessageText", IDS_LOGIN_PROXY_ERROR_MESSAGE); builder->Add("updateOfflineMessageBody", ui::SubstituteChromeOSDeviceType(IDS_UPDATE_OFFLINE_MESSAGE)); builder->Add("updateProxyMessageText", IDS_UPDATE_PROXY_ERROR_MESSAGE); builder->AddF("localStateErrorText0", IDS_LOCAL_STATE_ERROR_TEXT_0, IDS_SHORT_PRODUCT_NAME); builder->Add("localStateErrorText1", IDS_LOCAL_STATE_ERROR_TEXT_1); builder->Add("localStateErrorPowerwashButton", IDS_LOCAL_STATE_ERROR_POWERWASH_BUTTON); builder->Add("connectingIndicatorText", IDS_LOGIN_CONNECTING_INDICATOR_TEXT); builder->Add("guestSigninFixNetwork", IDS_LOGIN_GUEST_SIGNIN_FIX_NETWORK); builder->Add("rebootButton", IDS_RELAUNCH_BUTTON); builder->Add("diagnoseButton", IDS_DIAGNOSE_BUTTON); builder->Add("configureCertsButton", IDS_MANAGE_CERTIFICATES); builder->Add("continueButton", IDS_NETWORK_SELECTION_CONTINUE_BUTTON); builder->Add("okButton", IDS_APP_OK); } void ErrorScreenHandler::Initialize() { if (!page_is_ready()) return; if (show_on_init_) { // TODO(nkostylev): Check that context initial state is properly passed. Show(); show_on_init_ = false; } } void ErrorScreenHandler::OnConnectToNetworkRequested() { if (showing_ && screen_) screen_->OnUserAction(ErrorScreen::kUserActionConnectRequested); } void ErrorScreenHandler::HandleHideCaptivePortal() { if (screen_) screen_->HideCaptivePortal(); } } // namespace chromeos
.MODEL SMALL .DATA .CODE MAIN PROC MOV AX,@DATA MOV DX,AX MOV AX, 0 MOV BX, 1 MOV CX, 8 MOV DX , AX MOV DX, BX FIBO: MOV DX,AX ADD DX,BX MOV AX,BX MOV BX,DX MOV AH, 2 MOV DL,BL INT 21H MOV AX,4C00H INT 21H MAIN ENDP END MAIN
; A017395: a(n) = (11*n)^7. ; 0,19487171,2494357888,42618442977,319277809664,1522435234375,5455160701056,16048523266853,40867559636992,93206534790699,194871710000000,379749833583241,698260569735168,1222791080775407,2054210978157184,3329565857578125,5231047633534976,7996339888664083,11930436453209472,17419031429960369,24943578880000000,35098120384607511,48607978698654848,66350415710840437,89377352926101504,118940252685546875,156517258339252096,203842691587258713,262939005204119552,336151289362331839,426184429770000000 pow $0,7 mul $0,19487171
; A049386: Binary order of 2^n-th prime. ; 1,2,3,5,6,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72 mov $2,$0 mul $0,3 lpb $0 sub $0,1 div $0,2 add $1,$2 mov $2,1 lpe mov $3,$1 cmp $3,0 add $1,$3 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r8 push %r9 push %rcx push %rdi push %rsi lea addresses_UC_ht+0x1bf52, %r9 nop nop nop nop nop add $9864, %r13 mov $0x6162636465666768, %rsi movq %rsi, (%r9) nop nop nop nop nop inc %rcx lea addresses_D_ht+0x16466, %rsi lea addresses_D_ht+0xd158, %rdi clflush (%rdi) nop nop xor %r13, %r13 mov $125, %rcx rep movsw nop nop nop nop nop and %rdi, %rdi lea addresses_UC_ht+0x10c86, %rsi lea addresses_A_ht+0x10dca, %rdi cmp %r8, %r8 mov $127, %rcx rep movsb sub %r8, %r8 lea addresses_normal_ht+0x101d6, %rdi nop nop and %rsi, %rsi mov $0x6162636465666768, %r9 movq %r9, %xmm4 vmovups %ymm4, (%rdi) nop nop nop sub $44185, %r8 lea addresses_normal_ht+0x137d6, %rsi lea addresses_WC_ht+0x1d4d6, %rdi nop and $11756, %r11 mov $119, %rcx rep movsw nop nop nop sub $59877, %r9 lea addresses_A_ht+0x32d6, %r8 nop nop nop nop and $36583, %rdi mov (%r8), %esi nop inc %r11 lea addresses_WC_ht+0x8fd6, %rsi lea addresses_A_ht+0x6f6, %rdi clflush (%rdi) nop add %r10, %r10 mov $62, %rcx rep movsl nop nop add $6290, %r11 lea addresses_A_ht+0x596e, %r10 nop nop nop nop nop and $12361, %rdi movl $0x61626364, (%r10) add $54530, %r8 lea addresses_A_ht+0x1ad56, %rcx nop dec %r9 mov $0x6162636465666768, %r13 movq %r13, %xmm7 movups %xmm7, (%rcx) nop and $23482, %r9 lea addresses_A_ht+0x129d6, %rsi lea addresses_WT_ht+0x1de32, %rdi nop nop nop nop nop sub $60671, %r11 mov $97, %rcx rep movsl nop nop nop and $55958, %rsi lea addresses_normal_ht+0x9fd6, %rcx nop nop add $7141, %rsi mov (%rcx), %rdi nop nop nop nop cmp %r10, %r10 lea addresses_A_ht+0x8df6, %rsi lea addresses_WC_ht+0x1ac56, %rdi clflush (%rsi) nop nop nop nop nop sub %r13, %r13 mov $115, %rcx rep movsb nop add %r9, %r9 lea addresses_A_ht+0xbb56, %r11 nop nop nop nop dec %r8 mov (%r11), %edi nop nop nop nop nop cmp %r13, %r13 lea addresses_normal_ht+0x125b6, %r9 nop nop nop nop xor $1618, %r8 mov (%r9), %r10d nop nop nop sub $37466, %rcx lea addresses_D_ht+0x19c6e, %rsi lea addresses_normal_ht+0xc592, %rdi xor $34846, %r11 mov $5, %rcx rep movsq nop nop nop nop inc %rsi pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi // Store lea addresses_PSE+0x15e06, %rax nop nop nop nop nop add $55042, %r8 mov $0x5152535455565758, %r13 movq %r13, %xmm4 vmovups %ymm4, (%rax) nop nop nop nop nop dec %r13 // Store lea addresses_WC+0x169d6, %rbx nop nop nop nop nop sub $56659, %r15 mov $0x5152535455565758, %r8 movq %r8, %xmm1 movups %xmm1, (%rbx) nop nop nop nop xor $36491, %r8 // Store mov $0x9ca, %rbx nop nop cmp %r13, %r13 mov $0x5152535455565758, %r15 movq %r15, (%rbx) nop nop nop nop nop add %rbx, %rbx // REPMOV lea addresses_US+0x1c9d6, %rsi lea addresses_RW+0x10936, %rdi clflush (%rdi) xor %r15, %r15 mov $88, %rcx rep movsl nop nop nop dec %rdi // Store lea addresses_WT+0x1dbd6, %rsi nop nop dec %rbx mov $0x5152535455565758, %r10 movq %r10, (%rsi) nop nop nop nop nop cmp $5692, %r13 // Store lea addresses_RW+0x1b8df, %r10 nop nop nop nop and %rax, %rax movl $0x51525354, (%r10) nop nop nop nop nop xor %r15, %r15 // Store lea addresses_D+0xbe36, %r13 nop nop nop inc %rcx mov $0x5152535455565758, %r11 movq %r11, %xmm2 vmovaps %ymm2, (%r13) inc %r15 // Store lea addresses_A+0xffd6, %r8 nop nop nop sub $47236, %r13 mov $0x5152535455565758, %rsi movq %rsi, %xmm1 movntdq %xmm1, (%r8) nop xor %rax, %rax // Store lea addresses_US+0x16b9f, %r15 nop nop nop and $54105, %rsi mov $0x5152535455565758, %rcx movq %rcx, (%r15) nop cmp %rcx, %rcx // Load lea addresses_UC+0xefd6, %r10 nop dec %rdi mov (%r10), %r8 xor $59709, %rcx // REPMOV lea addresses_normal+0xabd6, %rsi lea addresses_normal+0x1a7d6, %rdi nop nop nop sub $42166, %r11 mov $61, %rcx rep movsl nop add %r11, %r11 // REPMOV lea addresses_normal+0x1ef56, %rsi lea addresses_RW+0x67d6, %rdi nop nop nop xor %rbx, %rbx mov $120, %rcx rep movsl inc %r15 // REPMOV lea addresses_UC+0x33d6, %rsi lea addresses_WT+0x13bd6, %rdi nop nop cmp %rbx, %rbx mov $110, %rcx rep movsq nop nop nop and $8154, %r11 // Store lea addresses_WT+0x108d6, %rsi nop nop and %rax, %rax movw $0x5152, (%rsi) nop nop nop nop and %r13, %r13 // Store lea addresses_WT+0xb366, %rax sub $54077, %r8 movb $0x51, (%rax) and %rax, %rax // Faulty Load lea addresses_RW+0x67d6, %r15 nop add $28387, %r13 mov (%r15), %ecx lea oracles, %r8 and $0xff, %rcx shlq $12, %rcx mov (%r8,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_US', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_RW', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': True, 'same': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 8, 'same': False}} {'src': {'type': 'addresses_normal', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_RW', 'congruent': 0, 'same': True}} {'src': {'type': 'addresses_UC', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT', 'congruent': 4, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 4}} [Faulty Load] {'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}} {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}} {'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}} {'a0': 1} a0 */
;************************************************************************** ;* ;* FILE playerdata.asm ;* Copyright (c) 1994, 2003 Daniel Kahlin <daniel@kahlin.net> ;* Written by Daniel Kahlin <daniel@kahlin.net> ;* $Id: playerdata.asm,v 1.14 2003/08/09 19:12:23 tlr Exp $ ;* ;* DESCRIPTION ;* The actual music data in T0 or T1 format. ;* ;* ;****** seg.u bss org $3300 PLAYER_T1 EQU 1 TuneStart: ;************************************************************************** ;* ;* TuneSpecific Data ;* ;****** pl_ID: ds.b 2 pl_Version: ds.b 1 pl_Revision: ds.b 1 ;0 if interrupt speed shall be LEGACY (victracker 1.0) ;1 if interrupt speed shall be PAL... ;2 if interrupt speed shall be PAL.2X ;3 if interrupt speed shall be PAL.3X ;4 if interrupt speed shall be PAL.4X ;5 if interrupt speed shall be NTSC.. ;6 if interrupt speed shall be NTSC2X ;7 if interrupt speed shall be NTSC3X ;8 if interrupt speed shall be NTSC4X ;9 if interrupt speed shall be SYNC24 (trigged by external device) ;A if interrupt speed shall be SYNC48 (trigged by external device) pl_PlayMode: ds.b 1 ;0 if scale shall be LEGACY (victracker 1.0) pl_Scale: ds.b 1 pl_Reserved0: ds.b 1 ;pad pl_SongNum: ds.b 1 ;Start and end positions and Speeds for 16 songs pl_StartStep: ds.b 1 pl_EndStep: ds.b 1 pl_RepeatStep: ds.b 1 pl_StartSpeed: ds.b 1 ;the remaining 13 ds.b 4*13 pl_Arpeggios: ds.b 256 IFCONST PLAYER_T1 pl_ExtraT1Start: pl_ArpeggioConf: ds.b 32 pl_Reserved2: ds.b 60 ;pad pl_Title: ds.b 16 ;null terminated _or_ exactly 16 chars pl_Author: ds.b 16 ;null terminated _or_ exactly 16 chars pl_Year: ds.b 4 ;year written as 4 ascii digits pl_Sounds: ds.b 256 pl_LengthTab: ds.b 256 pl_ExtraT1End: ENDIF ;PLAYER_T1 pl_PattLists: pl_Tab1: ds.b 256 pl_Tab2: ds.b 256 pl_Tab3: ds.b 256 pl_Tab4: ds.b 256 pl_Tab5: ds.b 256 pl_PatternData: ds.b $40*128 TuneEnd: ; eof
namespace menu { seek(codeCursor) //Bahamut Lagoon shares a lot of code routines between each screen, //which interferes greatly with tile allocation strategies. //the dispatcher attempts to record when screens are entered into, //in order to disambiguate shared routines, and call handlers for //specific screens instead. namespace dispatcher { enqueue pc seek($ee7b64); jsl hookCampaignMenu seek($ee7947); jsl hookPartyMenu; nop seek($ee6f83); jsl party seek($eea74d); string.hook(party.other) seek($eea512); string.hook(party.other) seek($ee6f6c); string.skip() //"Party" static text (used by several screens) //unit and status screens seek($ee6fe4); string.hook(mp.setType) //"MP" seek($ee6ff1); string.hook(mp.setType) //"SP" seek($ee705a); jsl mp.setCurrent seek($ee707f); jsl mp.setMaximum seek($ee701c); jsl mp.setCurrentUnavailable seek($ee7039); jsl mp.setMaximumUnavailable //formations and dragons screens seek($ee99f8); jsl technique.name seek($eea5cd); jsl technique.blank seek($ee9a05); jsl technique.level seek($ee9a1e); jsl technique.multiplier; nop #5 seek($ee9a2c); jsl technique.count //formations, equipments, information, shop screens seek($eef02b); jsl page.index seek($eef01b); jsl page.total seek($eee6b6); string.hook(page.noItems) //"No Items" text (shop screen) seek($eeefa8); string.hook(page.noItems) //"No Items" text (information screen) //shared positions seek($ee700f); adc #$0000 //"MP"- position (magic, item, unit screens) seek($ee702c); adc #$0000 //"MP"/ position (magic, item, unit screens) seek($ee7044); adc #$0000 //"SP"# position (magic, item, unit screens) dequeue pc namespace screen { variable(2, id) constant unknown = 0 constant formations = 1 constant dragons = 2 constant information = 3 constant equipments = 4 constant magicItem = 5 constant equipment = 6 constant status = 7 constant unit = 8 } constant menuIndex = $4c function hookCampaignMenu { lda.b menuIndex enter cmp #$0000; bne +; lda.w #screen.formations; sta screen.id; jmp return; + cmp #$0001; bne +; lda.w #screen.dragons; sta screen.id; jmp return; + cmp #$0002; bne +; lda.w #screen.information; sta screen.id; jmp return; + cmp #$0003; bne +; lda.w #screen.equipments; sta screen.id; jmp return; + lda.w #screen.unknown; sta screen.id return: leave asl; tax; rtl } function hookPartyMenu { lda.b menuIndex enter cmp #$0000; bne +; lda.w #screen.magicItem; sta screen.id; jmp return; + //Magic cmp #$0001; bne +; lda.w #screen.magicItem; sta screen.id; jmp return; + //Item cmp #$0002; bne +; lda.w #screen.equipment; sta screen.id; jmp return; + cmp #$0003; bne +; lda.w #screen.information; sta screen.id; jmp return; + lda.w #screen.unknown; sta screen.id return: leave cmp #$0003; rtl } //A => party# function party { enter dec; and #$0007 pha; lda $0f,s; tax; pla //X => caller cpx #$8052; bne +; jsl party.party; leave; rtl; + //Party and Campaign cpx #$a570; bne +; jsl formations.party; leave; rtl; + //Formations (selected) cpx #$a75e; bne +; jsl overviews.party; leave; rtl; + //Formations and Equipments (list) cpx #$cb3e; bne +; jsl dragons.party; leave; rtl; + //Dragon Formation leave; rtl //other party function other { php; rep #$20; pha lda $04,s //A => caller cmp #$a515; bne +; lda #$0006; jsl formations.party; pla; plp; rtl; + //Formations (selected) cmp #$a750; bne +; lda #$0006; jsl overviews.party; pla; plp; rtl; + //Formations and Equipments (list) pla; plp; rtl } } namespace mp { variable(2, screen) variable(2, type) //A => type ($00 = MP, $80 = SP) function setType { php; rep #$20; pha and #$0080; sta type lda $0c,s //A => caller cmp #$8fb5; bne +; lda.w #screen.magicItem; sta screen; lda type; jsl magicItem.mp.setType; pla; plp; rtl; + cmp #$9679; bne +; lda.w #screen.status; sta screen; lda type; jsl status.mp.setType; pla; plp; rtl; + cmp #$ae65; bne +; lda.w #screen.unit; sta screen; lda type; jsl unit.mp.setType; pla; plp; rtl; + cmp #$b7bf; bne +; lda.w #screen.equipment; sta screen; lda type; jsl equipment.mp.setType; pla; plp; rtl; + lda.w #screen.unknown; sta screen; pla; plp; rtl } //A => current value function setCurrent { php; rep #$20; pha lda screen cmp.w #screen.magicItem; bne +; pla; jsl magicItem.mp.setCurrent; plp; rtl; + cmp.w #screen.status; bne +; pla; jsl status.mp.setCurrent; plp; rtl; + cmp.w #screen.unit; bne +; pla; jsl unit.mp.setCurrent; plp; rtl; + cmp.w #screen.equipment; bne +; pla; jsl equipment.mp.setCurrent; plp; rtl; + pla; plp; rtl } //A => maximum value function setMaximum { php; rep #$20; pha lda screen cmp.w #screen.magicItem; bne +; pla; jsl magicItem.mp.setMaximum; plp; rtl; + cmp.w #screen.status; bne +; pla; jsl status.mp.setMaximum; plp; rtl; + cmp.w #screen.unit; bne +; pla; jsl unit.mp.setMaximum; plp; rtl; + cmp.w #screen.equipment; bne +; pla; jsl equipment.mp.setMaximum; plp; rtl; + pla; plp; rtl } function setCurrentUnavailable { php; rep #$20; pha lda #$ffff; jsl setCurrent pla; plp; rtl } function setMaximumUnavailable { php; rep #$20; pha lda #$ffff; jsl setMaximum pla; plp; rtl } } namespace technique { //A => technique name function name { php; rep #$20; pha lda screen.id cmp.w #screen.formations; bne +; pla; jsl formations.technique.name; plp; rtl; + cmp.w #screen.dragons; bne +; pla; jsl dragons.technique.name; plp; rtl; + pla; plp; rtl } function blank { php; rep #$20; pha lda #$00ff //position of "---------" in technique list jsl name pla; plp; rtl } //A => technique level function level { php; rep #$20; pha lda screen.id cmp.w #screen.formations; bne +; pla; jsl formations.technique.level; plp; rtl; + cmp.w #screen.dragons; bne +; pla; jsl dragons.technique.level; plp; rtl; + pla; plp; rtl } //------ //ee9a1e lda #$00e7 //ee9a21 ora $1862 //ee9a24 sta $c400,x //------ function multiplier { enter tilemap.decrementAddress(2) tilemap.setColorIvory() tilemap.write(glyph.multiplier) leave; rtl } //A => technique count function count { enter tilemap.setColorIvory() and #$00ff; add.w #glyph.numbers; pha lda tilemap.address; tax; pla ora tilemap.attributes; sta tilemap.location,x leave; rtl } } namespace page { variable(2, pageIndex) variable(2, pageTotal) variable(2, counter) //A => current page function index { enter and #$00ff; sta pageIndex leave; rtl } //A => total number of pages function total { enter tilemap.setColorWhite() and #$00ff; sta pageTotal ldx #$0000 append.styleTiny() append.alignSkip(2) append.literal("Page") lda pageTotal; cmp.w #10; jcs total_2 total_1: { tilemap.write($a0fc) append.alignLeft() append.alignSkip(24) lda pageIndex; append.integer1(); append.literal("/") lda pageTotal; append.integer1() lda #$0005; render.small.bpp2() getTileIndex(counter, 2); mul(6); add #$03f4; tax lda #$0005; write.bpp2() leave; rtl } total_2: { append.alignLeft() append.alignSkip(23) lda pageIndex; append.integer_2(); append.literal("/") append.alignLeft() append.alignSkip(37) lda pageTotal; append.integer_2() lda #$0006; render.small.bpp2() getTileIndex(counter, 2); mul(6); add #$03f4; tax lda #$0006; write.bpp2() leave; rtl } } function noItems { enter tilemap.setColorWhite() tilemap.write($a0fc) ldx #$0000; append.styleTiny() append.alignSkip(2); append.literal("No Items!") lda #$0005; render.small.bpp2() getTileIndex(counter, 2); mul(6); add #$03f4; tax lda #$0005; write.bpp2() leave; rtl } } } codeCursor = pc() }
/** * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "LiveEffectEngine.h" #include <assert.h> #include <logging_macros.h> #include <climits> /** * Duplex is not very stable right after starting up: * the callbacks may not be happening at the right times * The time to get it stable varies on different systems. Half second * is used for this sample, during the time this sample plays silence. */ const float kSystemWarmupTime = 0.5f; LiveEffectEngine::LiveEffectEngine() { assert(mOutputChannelCount == mInputChannelCount); } LiveEffectEngine::~LiveEffectEngine() { stopStream(mPlayStream); stopStream(mRecordingStream); closeStream(mPlayStream); closeStream(mRecordingStream); } void LiveEffectEngine::setRecordingDeviceId(int32_t deviceId) { mRecordingDeviceId = deviceId; } void LiveEffectEngine::setPlaybackDeviceId(int32_t deviceId) { mPlaybackDeviceId = deviceId; } bool LiveEffectEngine::isAAudioSupported() { oboe::AudioStreamBuilder builder; return builder.isAAudioSupported(); } bool LiveEffectEngine::setAudioApi(oboe::AudioApi api) { if (mIsEffectOn) return false; mAudioApi = api; return true; } void LiveEffectEngine::setEffectOn(bool isOn) { if (isOn != mIsEffectOn) { mIsEffectOn = isOn; if (isOn) { openAllStreams(); } else { closeAllStreams(); } } } void LiveEffectEngine::openAllStreams() { // Note: The order of stream creation is important. We create the playback // stream first, then use properties from the playback stream // (e.g. sample rate) to create the recording stream. By matching the // properties we should get the lowest latency path openPlaybackStream(); openRecordingStream(); // Now start the recording stream first so that we can read from it during // the playback stream's dataCallback if (mRecordingStream && mPlayStream) { startStream(mRecordingStream); startStream(mPlayStream); } else { LOGE("Failed to create recording (%p) and/or playback (%p) stream", mRecordingStream, mPlayStream); closeAllStreams(); } } /** * Stops and closes the playback and recording streams. */ void LiveEffectEngine::closeAllStreams() { /** * Note: The order of events is important here. * The playback stream must be closed before the recording stream. If the * recording stream were to be closed first the playback stream's * callback may attempt to read from the recording stream * which would cause the app to crash since the recording stream would be * null. */ if (mPlayStream != nullptr) { closeStream(mPlayStream); // Calling close will also stop the stream mPlayStream = nullptr; } if (mRecordingStream != nullptr) { closeStream(mRecordingStream); mRecordingStream = nullptr; } } /** * Creates an audio stream for recording. The audio device used will depend on * mRecordingDeviceId. * If the value is set to oboe::Unspecified then the default recording device * will be used. */ void LiveEffectEngine::openRecordingStream() { // To create a stream we use a stream builder. This allows us to specify all // the parameters for the stream prior to opening it oboe::AudioStreamBuilder builder; setupRecordingStreamParameters(&builder); // Now that the parameters are set up we can open the stream oboe::Result result = builder.openStream(&mRecordingStream); if (result == oboe::Result::OK && mRecordingStream) { assert(mRecordingStream->getChannelCount() == mInputChannelCount); assert(mRecordingStream->getSampleRate() == mSampleRate); assert(mRecordingStream->getFormat() == oboe::AudioFormat::I16); warnIfNotLowLatency(mRecordingStream); } else { LOGE("Failed to create recording stream. Error: %s", oboe::convertToText(result)); } } /** * Creates an audio stream for playback. The audio device used will depend on * mPlaybackDeviceId. * If the value is set to oboe::Unspecified then the default playback device * will be used. */ void LiveEffectEngine::openPlaybackStream() { oboe::AudioStreamBuilder builder; setupPlaybackStreamParameters(&builder); oboe::Result result = builder.openStream(&mPlayStream); if (result == oboe::Result::OK && mPlayStream) { mSampleRate = mPlayStream->getSampleRate(); assert(mPlayStream->getFormat() == oboe::AudioFormat::I16); assert(mOutputChannelCount == mPlayStream->getChannelCount()); mSystemStartupFrames = static_cast<uint64_t>(mSampleRate * kSystemWarmupTime); mProcessedFrameCount = 0; warnIfNotLowLatency(mPlayStream); } else { LOGE("Failed to create playback stream. Error: %s", oboe::convertToText(result)); } } /** * Sets the stream parameters which are specific to recording, * including the sample rate which is determined from the * playback stream. * * @param builder The recording stream builder */ oboe::AudioStreamBuilder *LiveEffectEngine::setupRecordingStreamParameters( oboe::AudioStreamBuilder *builder) { // This sample uses blocking read() by setting callback to null builder->setCallback(nullptr) ->setDeviceId(mRecordingDeviceId) ->setDirection(oboe::Direction::Input) ->setSampleRate(mSampleRate) ->setChannelCount(mInputChannelCount); return setupCommonStreamParameters(builder); } /** * Sets the stream parameters which are specific to playback, including device * id and the dataCallback function, which must be set for low latency * playback. * @param builder The playback stream builder */ oboe::AudioStreamBuilder *LiveEffectEngine::setupPlaybackStreamParameters( oboe::AudioStreamBuilder *builder) { builder->setCallback(this) ->setDeviceId(mPlaybackDeviceId) ->setDirection(oboe::Direction::Output) ->setChannelCount(mOutputChannelCount); return setupCommonStreamParameters(builder); } /** * Set the stream parameters which are common to both recording and playback * streams. * @param builder The playback or recording stream builder */ oboe::AudioStreamBuilder *LiveEffectEngine::setupCommonStreamParameters( oboe::AudioStreamBuilder *builder) { // We request EXCLUSIVE mode since this will give us the lowest possible // latency. // If EXCLUSIVE mode isn't available the builder will fall back to SHARED // mode. builder->setAudioApi(mAudioApi) ->setFormat(mFormat) ->setSharingMode(oboe::SharingMode::Shared) ->setPerformanceMode(oboe::PerformanceMode::LowLatency); return builder; } void LiveEffectEngine::startStream(oboe::AudioStream *stream) { assert(stream); if (stream) { oboe::Result result = stream->requestStart(); if (result != oboe::Result::OK) { LOGE("Error starting stream. %s", oboe::convertToText(result)); } } } void LiveEffectEngine::stopStream(oboe::AudioStream *stream) { if (stream) { oboe::Result result = stream->stop(0L); if (result != oboe::Result::OK) { LOGE("Error stopping stream. %s", oboe::convertToText(result)); } } } /** * Close the stream. AudioStream::close() is a blocking call so * the application does not need to add synchronization between * onAudioReady() function and the thread calling close(). * [the closing thread is the UI thread in this sample]. * @param stream the stream to close */ void LiveEffectEngine::closeStream(oboe::AudioStream *stream) { if (stream) { oboe::Result result = stream->close(); if (result != oboe::Result::OK) { LOGE("Error closing stream. %s", oboe::convertToText(result)); } } } /** * Restart the streams. During the restart operation subsequent calls to this * method will output a warning. */ void LiveEffectEngine::restartStreams() { LOGI("Restarting streams"); if (mRestartingLock.try_lock()) { closeAllStreams(); openAllStreams(); mRestartingLock.unlock(); } else { LOGW( "Restart stream operation already in progress - ignoring this " "request"); // We were unable to obtain the restarting lock which means the restart // operation is currently // active. This is probably because we received successive "stream // disconnected" events. // Internal issue b/63087953 } } /** * Warn in logcat if non-low latency stream is created * @param stream: newly created stream * */ void LiveEffectEngine::warnIfNotLowLatency(oboe::AudioStream *stream) { if (stream->getPerformanceMode() != oboe::PerformanceMode::LowLatency) { LOGW( "Stream is NOT low latency." "Check your requested format, sample rate and channel count"); } } /** * Handles playback stream's audio request. In this sample, we simply block-read * from the record stream for the required samples. * * @param oboeStream: the playback stream that requesting additional samples * @param audioData: the buffer to load audio samples for playback stream * @param numFrames: number of frames to load to audioData buffer * @return: DataCallbackResult::Continue. */ oboe::DataCallbackResult LiveEffectEngine::onAudioReady( oboe::AudioStream *oboeStream, void *audioData, int32_t numFrames) { assert(oboeStream == mPlayStream); int32_t prevFrameRead = 0, framesRead = 0; if (mProcessedFrameCount < mSystemStartupFrames) { do { // Drain the audio for the starting up period, half second for // this sample. prevFrameRead = framesRead; oboe::ResultWithValue<int32_t> status = mRecordingStream->read(audioData, numFrames, 0); framesRead = (!status) ? 0 : status.value(); if (framesRead == 0) break; } while (framesRead); framesRead = prevFrameRead; } else { oboe::ResultWithValue<int32_t> status = mRecordingStream->read(audioData, numFrames, 0); if (!status) { LOGE("input stream read error: %s", oboe::convertToText(status.error())); return oboe::DataCallbackResult ::Stop; } framesRead = status.value(); } if (framesRead < numFrames) { int32_t bytesPerFrame = mRecordingStream->getChannelCount() * oboeStream->getBytesPerSample(); uint8_t *padPos = static_cast<uint8_t *>(audioData) + framesRead * bytesPerFrame; memset(padPos, 0, static_cast<size_t>((numFrames - framesRead) * bytesPerFrame)); } // add your audio processing here mProcessedFrameCount += numFrames; return oboe::DataCallbackResult::Continue; } /** * Oboe notifies the application for "about to close the stream". * * @param oboeStream: the stream to close * @param error: oboe's reason for closing the stream */ void LiveEffectEngine::onErrorBeforeClose(oboe::AudioStream *oboeStream, oboe::Result error) { LOGE("%s stream Error before close: %s", oboe::convertToText(oboeStream->getDirection()), oboe::convertToText(error)); } /** * Oboe notifies application that "the stream is closed" * * @param oboeStream * @param error */ void LiveEffectEngine::onErrorAfterClose(oboe::AudioStream *oboeStream, oboe::Result error) { LOGE("%s stream Error after close: %s", oboe::convertToText(oboeStream->getDirection()), oboe::convertToText(error)); }
// Copyright (c) 2011 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 "components/webdata/common/web_database_table.h" WebDatabaseTable::WebDatabaseTable() : db_(nullptr), meta_table_(nullptr) {} WebDatabaseTable::~WebDatabaseTable() {} void WebDatabaseTable::Init(sql::Connection* db, sql::MetaTable* meta_table) { db_ = db; meta_table_ = meta_table; }
; A120892: a(n)=3*a(n-1)+3*a(n-2)-a(n-3);a(0)=1,a(1)=0,a(2)=3. a(n)=4*{a(n-1)+(-1)^n}-a(n-2);a(0)=1,a(1)=0. ; 1,0,3,8,33,120,451,1680,6273,23408,87363,326040,1216801,4541160,16947843,63250208,236052993,880961760,3287794051,12270214440,45793063713,170902040408,637815097923,2380358351280,8883618307201,33154114877520,123732841202883,461777249934008,1723376158533153,6431727384198600,24003533378261251,89582406128846400,334326091137124353,1247721958419651008,4656561742541479683,17378525011746267720,64857538304443591201,242051628206028097080,903348974519668797123,3371344269872647091408,12582028104970919568513,46956768150011031182640,175245044495073205162051,654023409830281789465560,2440848594826053952700193,9109370969473934021335208,33996635283069682132640643,126877170162804794509227360,473512045368149495904268801,1767171011309793189107847840,6595171999871023260527122563,24613516988174299853000642408,91858895952826176151475447073,342822066823130404752901145880,1279429371339695442860129136451,4774895418535651366687615399920,17820152302802910023890332463233,66505713792675988728873714453008,248202702867901044891604525348803,926305097678928190837544386942200,3457017687847811718458573022420001,12901765653712318682996747702737800,48150044927001463013528417788531203,179698414054293533371116923451387008,670643611290172670470939276017016833 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 trn $0,1 seq $0,1571 ; a(0) = 0, a(1) = 2, a(n) = 4*a(n-1) - a(n-2) + 1. add $0,3 div $0,3 mov $2,$3 mul $2,$0 add $1,$2 mov $4,$0 lpe min $5,1 mul $5,$4 sub $1,$5 mov $0,$1