text stringlengths 1 1.05M |
|---|
; A081423: Subdiagonal of array of n-gonal numbers A081422.
; 1,3,12,34,75,141,238,372,549,775,1056,1398,1807,2289,2850,3496,4233,5067,6004,7050,8211,9493,10902,12444,14125,15951,17928,20062,22359,24825,27466,30288,33297,36499,39900,43506,47323,51357,55614,60100,64821,69783,74992,80454,86175,92161,98418,104952,111769,118875,126276,133978,141987,150309,158950,167916,177213,186847,196824,207150,217831,228873,240282,252064,264225,276771,289708,303042,316779,330925,345486,360468,375877,391719,408000,424726,441903,459537,477634,496200,515241,534763,554772,575274,596275,617781,639798,662332,685389,708975,733096,757758,782967,808729,835050,861936,889393,917427,946044,975250
mul $0,2
mov $2,$0
pow $0,2
add $0,2
add $2,1
mul $0,$2
div $0,8
add $0,1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x6a91, %rsi
nop
nop
nop
nop
sub %rdx, %rdx
mov (%rsi), %r10d
nop
sub $62855, %rdi
lea addresses_normal_ht+0x1d2f1, %r11
nop
nop
nop
nop
add %rdx, %rdx
mov $0x6162636465666768, %rcx
movq %rcx, (%r11)
nop
nop
nop
nop
inc %rsi
lea addresses_WC_ht+0x6c51, %r10
nop
xor %rcx, %rcx
vmovups (%r10), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rsi
nop
nop
dec %r10
lea addresses_normal_ht+0x66a1, %rdi
clflush (%rdi)
nop
nop
nop
lfence
movb (%rdi), %r10b
nop
nop
nop
nop
nop
add $25324, %rdx
lea addresses_D_ht+0x17691, %rcx
nop
nop
nop
nop
nop
add $22040, %rax
movups (%rcx), %xmm2
vpextrq $1, %xmm2, %rdx
nop
nop
cmp $32967, %r11
lea addresses_UC_ht+0x1e919, %rcx
nop
inc %r11
mov $0x6162636465666768, %rsi
movq %rsi, (%rcx)
nop
dec %r10
lea addresses_WT_ht+0x1ea11, %rsi
nop
nop
cmp $43321, %rdi
movb (%rsi), %dl
nop
nop
nop
nop
mfence
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %rax
push %rbp
push %rbx
// Load
lea addresses_UC+0x1a0d5, %rbp
nop
nop
nop
and $43930, %rbx
mov (%rbp), %r10w
nop
dec %rbp
// Faulty Load
lea addresses_PSE+0x8691, %rbp
nop
sub %rax, %rax
mov (%rbp), %r12w
lea oracles, %r10
and $0xff, %r12
shlq $12, %r12
mov (%r10,%r12,1), %r12
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_UC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}}
{'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}}
{'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
/*
* Qt4 bitcoin GUI.
*
* W.J. van der Laan 2011-2012
* The Bitcoin Developers 2011-2012
*/
#include "bitcoingui.h"
#include "transactiontablemodel.h"
#include "addressbookpage.h"
#include "sendcoinsdialog.h"
#include "signverifymessagedialog.h"
#include "secondauthdialog.h"
#include "multisigdialog.h"
#include "optionsdialog.h"
#include "aboutdialog.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "editaddressdialog.h"
#include "optionsmodel.h"
#include "transactiondescdialog.h"
#include "addresstablemodel.h"
#include "transactionview.h"
#include "overviewpage.h"
#include "bitcoinunits.h"
#include "guiconstants.h"
#include "askpassphrasedialog.h"
#include "notificator.h"
#include "guiutil.h"
#include "ui_interface.h"
#include "rpcconsole.h"
#include "mintingview.h"
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#include <QApplication>
#if QT_VERSION < 0x050000
#include <QMainWindow>
#endif
#include <QMenuBar>
#include <QMenu>
#include <QIcon>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QToolBar>
#include <QStatusBar>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QLocale>
#include <QMessageBox>
#include <QProgressBar>
#include <QStackedWidget>
#include <QDateTime>
#include <QMovie>
#include <QFileDialog>
#if QT_VERSION < 0x050000
#include <QDesktopServices>
#else
#include <QStandardPaths>
#endif
#include <QTimer>
#include <QDragEnterEvent>
#if QT_VERSION < 0x050000
#include <QUrl>
#endif
#include <QStyle>
#include <QMimeData>
#include <iostream>
extern bool fWalletUnlockMintOnly;
extern uint64_t nStakeInputsMapSize;
BitcoinGUI::BitcoinGUI(QWidget *parent):
QMainWindow(parent),
clientModel(0),
walletModel(0),
signVerifyMessageDialog(0),
secondAuthDialog(0),
multisigPage(0),
encryptWalletAction(0),
lockWalletAction(0),
unlockWalletAction(0),
unlockWalletMiningAction(0),
changePassphraseAction(0),
trayIcon(0),
notificator(0),
rpcConsole(0),
aboutDialog(0),
optionsDialog(0)
{
resize(850, 550);
setWindowTitle(tr("42") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin"));
setWindowIcon(QIcon(":icons/bitcoin"));
#else
//setUnifiedTitleAndToolBarOnMac(true);
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
createActions();
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create the tray icon (or setup the dock icon)
createTrayIcon();
// Create tabs
overviewPage = new OverviewPage();
transactionsPage = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout();
transactionView = new TransactionView(this);
vbox->addWidget(transactionView);
transactionsPage->setLayout(vbox);
mintingPage = new QWidget(this);
QVBoxLayout *vboxMinting = new QVBoxLayout();
mintingView = new MintingView(this);
vboxMinting->addWidget(mintingView);
mintingPage->setLayout(vboxMinting);
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
sendCoinsPage = new SendCoinsDialog(this);
signVerifyMessageDialog = new SignVerifyMessageDialog(0);
secondAuthDialog = new SecondAuthDialog(0);
multisigPage = new MultisigDialog(0);
centralWidget = new QStackedWidget(this);
centralWidget->addWidget(overviewPage);
centralWidget->addWidget(transactionsPage);
centralWidget->addWidget(mintingPage);
centralWidget->addWidget(addressBookPage);
centralWidget->addWidget(receiveCoinsPage);
centralWidget->addWidget(sendCoinsPage);
setCentralWidget(centralWidget);
// Create status bar
statusBar();
statusBar()->setSizeGripEnabled(false);
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setMinimumWidth(72);
frameBlocks->setMaximumWidth(72);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
labelEncryptionIcon = new QLabel();
labelMiningIcon = new QLabel();
labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel();
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelEncryptionIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelMiningIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
progressBarLabel->setVisible(false);
progressBar = new QProgressBar();
progressBar->setAlignment(Qt::AlignCenter);
progressBar->setVisible(false);
if (!fUseBlackTheme)
{
// Override style sheet for progress bar for styles that have a segmented progress bar,
// as they make the text unreadable (workaround for issue #1071)
// See https://qt-project.org/doc/qt-4.8/gallery.html
QString curStyle = qApp->style()->metaObject()->className();
if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
{
progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
}
}
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->addPermanentWidget(frameBlocks);
syncIconMovie = new QMovie(fUseBlackTheme ? ":/movies/update_spinner_black" : ":/movies/update_spinner", "mng", this);
// Clicking on a transaction on the overview page simply sends you to transaction history page
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
// Double-clicking on a transaction on the transaction history page shows details
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
rpcConsole = new RPCConsole(0);
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(raise()));
aboutDialog = new AboutDialog(0);
optionsDialog = new OptionsDialog(0);
// Clicking on "Verify Message" in the address book sends you to the verify message tab
connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
// Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
gotoOverviewPage();
}
BitcoinGUI::~BitcoinGUI()
{
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
delete appMenuBar;
#endif
delete rpcConsole;
delete aboutDialog;
delete optionsDialog;
delete multisigPage;
delete secondAuthDialog;
delete signVerifyMessageDialog;
}
void BitcoinGUI::createActions()
{
QActionGroup *tabGroup = new QActionGroup(this);
overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setToolTip(tr("Show general overview of wallet"));
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
sendCoinsAction->setToolTip(tr("Send coins to a 42 address"));
sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
tabGroup->addAction(sendCoinsAction);
receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
tabGroup->addAction(receiveCoinsAction);
historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setToolTip(tr("Browse transaction history"));
historyAction->setCheckable(true);
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);
mintingAction = new QAction(QIcon(":/icons/history"), tr("&Minting"), this);
mintingAction->setToolTip(tr("Show your minting capacity"));
mintingAction->setCheckable(true);
mintingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
tabGroup->addAction(mintingAction);
addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
addressBookAction->setCheckable(true);
addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
tabGroup->addAction(addressBookAction);
multisigAction = new QAction(QIcon(":/icons/send"), tr("Multisig"), this);
multisigAction->setStatusTip(tr("Open window for working with multisig addresses"));
tabGroup->addAction(multisigAction);
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(mintingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(mintingAction, SIGNAL(triggered()), this, SLOT(gotoMintingPage()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
connect(multisigAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(multisigAction, SIGNAL(triggered()), this, SLOT(gotoMultisigPage()));
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About 42"), this);
aboutAction->setStatusTip(tr("Show information about 42"));
aboutAction->setMenuRole(QAction::AboutRole);
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for 42"));
optionsAction->setMenuRole(QAction::PreferencesRole);
toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt or decrypt wallet"));
encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
dumpWalletAction = new QAction(QIcon(":/icons/dump"), tr("&Dump Wallet..."), this);
dumpWalletAction->setStatusTip(tr("Dump keys to a text file"));
importWalletAction = new QAction(QIcon(":/icons/import"), tr("&Import Wallet..."), this);
importWalletAction->setStatusTip(tr("Import keys into a wallet"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your 42 addresses to prove you own them"));
verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified 42 addresses"));
secondAuthAction = new QAction(QIcon(":/icons/key"), tr("Second &auth..."), this);
secondAuthAction->setStatusTip(tr("Second auth with your 42 addresses"));
lockWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Lock wallet"), this);
lockWalletAction->setStatusTip(tr("Lock wallet"));
lockWalletAction->setCheckable(true);
unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("Unlo&ck wallet"), this);
unlockWalletAction->setStatusTip(tr("Unlock wallet"));
unlockWalletAction->setCheckable(true);
unlockWalletMiningAction = new QAction(QIcon(":/icons/mining_active"), tr("Unlo&ck wallet for mining"), this);
unlockWalletMiningAction->setStatusTip(tr("Unlock wallet for mining"));
unlockWalletMiningAction->setCheckable(true);
exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
exportAction->setStatusTip(tr("Export the data in the current tab to a file"));
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
connect(lockWalletAction, SIGNAL(triggered(bool)), this, SLOT(lockWallet()));
connect(unlockWalletAction, SIGNAL(triggered(bool)), this, SLOT(unlockWallet()));
connect(unlockWalletMiningAction, SIGNAL(triggered(bool)), this, SLOT(unlockWalletMining(bool)));
connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(dumpWalletAction, SIGNAL(triggered()), this, SLOT(dumpWallet()));
connect(importWalletAction, SIGNAL(triggered()), this, SLOT(importWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(secondAuthAction, SIGNAL(triggered()), this, SLOT(gotoSecondAuthPage()));
}
void BitcoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
// Get the main window's menu bar on other platforms
appMenuBar = menuBar();
#endif
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
file->addAction(backupWalletAction);
file->addSeparator();
file->addAction(dumpWalletAction);
file->addAction(importWalletAction);
file->addAction(exportAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addAction(secondAuthAction);
file->addAction(multisigAction);
file->addSeparator();
file->addAction(quitAction);
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
QMenu *securityMenu = settings->addMenu(QIcon(":/icons/key"), tr("&Wallet security"));
securityMenu->addAction(encryptWalletAction);
securityMenu->addAction(changePassphraseAction);
securityMenu->addAction(unlockWalletAction);
securityMenu->addAction(unlockWalletMiningAction);
securityMenu->addAction(lockWalletAction);
settings->addAction(optionsAction);
QMenu *help = appMenuBar->addMenu(tr("&Help"));
help->addAction(openRPCConsoleAction);
help->addAction(aboutAction);
}
void BitcoinGUI::createToolBars()
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(mintingAction);
toolbar->addAction(addressBookAction);
toolbar->setMovable(false);
toolbar->setIconSize(QSize(32, 32));
}
void BitcoinGUI::setClientModel(ClientModel *clientModel)
{
this->clientModel = clientModel;
if(clientModel)
{
// Replace some strings and icons, when using the testnet
if(clientModel->isTestNet())
{
setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]"));
#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin_testnet"));
setWindowIcon(QIcon(":icons/bitcoin_testnet"));
#else
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
#endif
if(trayIcon)
{
trayIcon->setToolTip(tr("42 client") + QString(" ") + tr("[testnet]"));
trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet"));
}
aboutAction->setIcon(QIcon(":/icons/toolbar_testnet"));
}
// Keep up to date with client
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(clientModel->getNumBlocks(), clientModel->getNumBlocksOfPeers());
connect(clientModel, SIGNAL(numBlocksChanged(int,int)), this, SLOT(setNumBlocks(int,int)));
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateMining()));
timer->start(10*1000); //10 seconds
// Report errors from network/worker thread
connect(clientModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool)));
rpcConsole->setClientModel(clientModel);
addressBookPage->setOptionsModel(clientModel->getOptionsModel());
receiveCoinsPage->setOptionsModel(clientModel->getOptionsModel());
}
}
void BitcoinGUI::setWalletModel(WalletModel *walletModel)
{
this->walletModel = walletModel;
if(walletModel)
{
// Report errors from wallet thread
connect(walletModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool)));
// Put transaction list in tabs
transactionView->setModel(walletModel);
mintingView->setModel(walletModel);
overviewPage->setModel(walletModel);
addressBookPage->setModel(walletModel->getAddressTableModel());
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
sendCoinsPage->setModel(walletModel);
signVerifyMessageDialog->setModel(walletModel);
secondAuthDialog->setModel(walletModel);
multisigPage->setModel(walletModel);
setEncryptionStatus(walletModel->getEncryptionStatus());
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int)));
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(updateMining()));
// Balloon pop-up for new transaction
connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(incomingTransaction(QModelIndex,int,int)));
// Ask for passphrase if needed
connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet()));
}
}
void BitcoinGUI::createTrayIcon()
{
QMenu *trayIconMenu;
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setToolTip(tr("42 client"));
trayIcon->setIcon(QIcon(":/icons/toolbar"));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->show();
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsAction);
trayIconMenu->addAction(multisigAction);
trayIconMenu->addAction(receiveCoinsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addAction(secondAuthAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
#ifndef Q_OS_MAC
// This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
}
#ifndef Q_OS_MAC
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger)
{
// Click on system tray icon triggers show/hide of the main window
toggleHideAction->trigger();
}
}
#endif
void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
return;
optionsDialog->setModel(clientModel->getOptionsModel());
optionsDialog->setWindowModality(Qt::ApplicationModal);
optionsDialog->show();
}
void BitcoinGUI::aboutClicked()
{
aboutDialog->setModel(clientModel);
aboutDialog->setWindowModality(Qt::ApplicationModal);
aboutDialog->show();
}
void BitcoinGUI::setNumConnections(int count)
{
QString icon;
switch(count)
{
case 0: icon = ":/icons/connect_0"; break;
case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
default: icon = ":/icons/connect_4"; break;
}
labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to 42 network", "", count));
}
void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
{
// don't show / hide progress bar and its label if we have no connection to the network
if (!clientModel || clientModel->getNumConnections() == 0)
{
statusBar()->setVisible(false);
return;
}
bool fShowStatusBar = false;
QString strStatusBarWarnings = clientModel->getStatusBarWarnings();
QString tooltip;
if(count < nTotalBlocks)
{
int nRemainingBlocks = nTotalBlocks - count;
float nPercentageDone = count / (nTotalBlocks * 0.01f);
if (strStatusBarWarnings.isEmpty())
{
progressBarLabel->setText(tr("Synchronizing with network..."));
progressBarLabel->setVisible(true);
progressBar->setFormat(tr("~%n block(s) remaining", "", nRemainingBlocks));
progressBar->setMaximum(nTotalBlocks);
progressBar->setValue(count);
progressBar->setVisible(true);
fShowStatusBar = true;
}
tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2);
}
else
{
if (strStatusBarWarnings.isEmpty())
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
fShowStatusBar = true;
tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
}
// Override progressBarLabel text and hide progress bar, when we have warnings to display
if (!strStatusBarWarnings.isEmpty())
{
progressBarLabel->setText(strStatusBarWarnings);
progressBarLabel->setVisible(true);
progressBar->setVisible(false);
}
tooltip = tr("Current PoW difficulty is %1.").arg(clientModel->getDifficulty(false)) + QString("<br>") + tooltip;
tooltip = tr("Current PoS difficulty is %1.").arg(clientModel->getDifficulty(true)) + QString("<br>") + tooltip;
QDateTime lastBlockDate = clientModel->getLastBlockDate();
int secs = lastBlockDate.secsTo(QDateTime::currentDateTime());
QString text;
// Represent time from last generated block in human readable text
if(secs <= 0)
{
// Fully up to date. Leave text empty.
}
else if(secs < 60)
{
text = tr("%n second(s) ago","",secs);
}
else if(secs < 60*60)
{
text = tr("%n minute(s) ago","",secs/60);
}
else if(secs < 24*60*60)
{
text = tr("%n hour(s) ago","",secs/(60*60));
}
else
{
text = tr("%n day(s) ago","",secs/(60*60*24));
}
// Set icon state: spinning if catching up, tick otherwise
if(secs < 90*60 && count >= nTotalBlocks)
{
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
overviewPage->showOutOfSyncWarning(false);
}
else
{
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
labelBlocksIcon->setMovie(syncIconMovie);
syncIconMovie->start();
overviewPage->showOutOfSyncWarning(true);
}
if(!text.isEmpty())
{
tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1.").arg(text);
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
statusBar()->setVisible(fShowStatusBar);
}
void BitcoinGUI::updateMining()
{
if(!walletModel)
return;
labelMiningIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
if (!clientModel->getNumConnections())
{
labelMiningIcon->setToolTip(tr("Wallet is offline"));
return;
}
if (walletModel->getEncryptionStatus() == WalletModel::Locked)
{
labelMiningIcon->setToolTip(tr("Wallet is locked"));
return;
}
if (clientModel->inInitialBlockDownload() || clientModel->getNumBlocksOfPeers() > clientModel->getNumBlocks())
{
labelMiningIcon->setToolTip(tr("Blockchain download is in progress"));
return;
}
if (nStakeInputsMapSize > 0)
{
labelMiningIcon->setPixmap(QIcon(":/icons/mining_active").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
uint64_t nNetworkWeight = clientModel->getPoSKernelPS();
labelMiningIcon->setToolTip(QString("<nobr>")+tr("Stake miner is active<br>%1 inputs being used for mining<br>Network weight is %3").arg(nStakeInputsMapSize).arg(nNetworkWeight)+QString("<\nobr>"));
}
else
labelMiningIcon->setToolTip(tr("No suitable inputs were found"));
}
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, const QString &detail)
{
QString strTitle = tr("42") + " - ";
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
// Check for usage of predefined title
switch (style) {
case CClientUIInterface::MSG_ERROR:
strTitle += tr("Error");
break;
case CClientUIInterface::MSG_WARNING:
strTitle += tr("Warning");
break;
case CClientUIInterface::MSG_INFORMATION:
strTitle += tr("Information");
break;
default:
strTitle += title; // Use supplied title
}
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
}
else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
buttons = QMessageBox::Ok;
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons);
if(!detail.isEmpty()) { mBox.setDetailedText(detail); }
mBox.exec();
}
else
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
}
void BitcoinGUI::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
{
QTimer::singleShot(0, this, SLOT(hide()));
e->ignore();
}
}
}
#endif
}
void BitcoinGUI::closeEvent(QCloseEvent *event)
{
if(clientModel)
{
#ifndef Q_OS_MAC // Ignored on Mac
if(!clientModel->getOptionsModel()->getMinimizeOnClose())
{
qApp->quit();
}
#endif
}
// close rpcConsole in case it was open to make some space for the shutdown window
rpcConsole->close();
QMainWindow::closeEvent(event);
}
void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
{
QString strMessage =
tr("This transaction is over the size limit. You can still send it for a fee of %1, "
"which goes to the nodes that process your transaction and helps to support the network. "
"Do you want to pay the fee?").arg(
BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
QMessageBox::StandardButton retval = QMessageBox::question(
this, tr("Confirm transaction fee"), strMessage,
QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
*payFee = (retval == QMessageBox::Yes);
}
void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
{
if(!walletModel || !clientModel)
return;
TransactionTableModel *ttm = walletModel->getTransactionTableModel();
qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
.data(Qt::EditRole).toULongLong();
if(!clientModel->inInitialBlockDownload())
{
// On new transaction, make an info balloon
// Unless the initial block download is in progress, to prevent balloon-spam
QString date = ttm->index(start, TransactionTableModel::Date, parent)
.data().toString();
QString type = ttm->index(start, TransactionTableModel::Type, parent)
.data().toString();
QString address = ttm->index(start, TransactionTableModel::ToAddress, parent)
.data().toString();
QIcon icon = qvariant_cast<QIcon>(ttm->index(start,
TransactionTableModel::ToAddress, parent)
.data(Qt::DecorationRole));
notificator->notify(Notificator::Information,
(amount)<0 ? tr("Sent transaction") :
tr("Incoming transaction"),
tr("Date: %1\n"
"Amount: %2\n"
"Type: %3\n"
"Address: %4\n")
.arg(date)
.arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true))
.arg(type)
.arg(address), icon);
}
}
void BitcoinGUI::gotoOverviewPage()
{
overviewAction->setChecked(true);
centralWidget->setCurrentWidget(overviewPage);
exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
}
void BitcoinGUI::gotoHistoryPage()
{
historyAction->setChecked(true);
centralWidget->setCurrentWidget(transactionsPage);
exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
}
void BitcoinGUI::gotoMintingPage()
{
mintingAction->setChecked(true);
centralWidget->setCurrentWidget(mintingPage);
exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
connect(exportAction, SIGNAL(triggered()), mintingView, SLOT(exportClicked()));
}
void BitcoinGUI::gotoAddressBookPage()
{
addressBookAction->setChecked(true);
centralWidget->setCurrentWidget(addressBookPage);
exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked()));
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
centralWidget->setCurrentWidget(receiveCoinsPage);
exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
}
void BitcoinGUI::gotoSendCoinsPage()
{
sendCoinsAction->setChecked(true);
centralWidget->setCurrentWidget(sendCoinsPage);
exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
}
void BitcoinGUI::gotoSignMessageTab(QString addr)
{
// call show() in showTab_SM()
signVerifyMessageDialog->showTab_SM(true);
if(!addr.isEmpty())
signVerifyMessageDialog->setAddress_SM(addr);
}
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
// call show() in showTab_VM()
signVerifyMessageDialog->showTab_VM(true);
if(!addr.isEmpty())
signVerifyMessageDialog->setAddress_VM(addr);
}
void BitcoinGUI::gotoSecondAuthPage(QString addr)
{
secondAuthDialog->show();
secondAuthDialog->raise();
secondAuthDialog->activateWindow();
}
void BitcoinGUI::gotoMultisigPage()
{
multisigPage->show();
multisigPage->raise();
multisigPage->activateWindow();
}
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
if(event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void BitcoinGUI::dropEvent(QDropEvent *event)
{
if(event->mimeData()->hasUrls())
{
int nValidUrisFound = 0;
QList<QUrl> uris = event->mimeData()->urls();
foreach(const QUrl &uri, uris)
{
if (sendCoinsPage->handleURI(uri.toString()))
nValidUrisFound++;
}
// if valid URIs were found
if (nValidUrisFound)
gotoSendCoinsPage();
else
notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid 42 address or malformed URI parameters."));
}
event->acceptProposedAction();
}
void BitcoinGUI::handleURI(QString strURI)
{
// URI has to be valid
if (sendCoinsPage->handleURI(strURI))
{
showNormalIfMinimized();
gotoSendCoinsPage();
}
else
notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid 42 address or malformed URI parameters."));
}
void BitcoinGUI::setEncryptionStatus(int status)
{
switch(status)
{
case WalletModel::Unencrypted:
labelEncryptionIcon->hide();
encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false);
lockWalletAction->setEnabled(false);
unlockWalletAction->setEnabled(false);
unlockWalletMiningAction->setEnabled(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(true);
lockWalletAction->setEnabled(true);
lockWalletAction->setChecked(false);
unlockWalletAction->setEnabled(false);
unlockWalletMiningAction->setEnabled(false);
if (fWalletUnlockMintOnly)
unlockWalletMiningAction->setChecked(true);
else
unlockWalletAction->setChecked(true);
break;
case WalletModel::Locked:
labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(true);
lockWalletAction->setChecked(true);
unlockWalletAction->setChecked(false);
unlockWalletMiningAction->setChecked(false);
lockWalletAction->setEnabled(false);
unlockWalletAction->setEnabled(true);
unlockWalletMiningAction->setEnabled(true);
break;
}
}
void BitcoinGUI::encryptWallet(bool status)
{
if(!walletModel)
return;
AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt:
AskPassphraseDialog::Decrypt, this);
dlg.setModel(walletModel);
dlg.exec();
setEncryptionStatus(walletModel->getEncryptionStatus());
}
void BitcoinGUI::unlockWalletMining(bool status)
{
if(!walletModel)
return;
// Unlock wallet when requested by wallet model
if(walletModel->getEncryptionStatus() == WalletModel::Locked)
{
AskPassphraseDialog dlg(AskPassphraseDialog::UnlockMining, this);
dlg.setModel(walletModel);
dlg.exec();
}
}
void BitcoinGUI::backupWallet()
{
#if QT_VERSION < 0x050000
QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif
QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)"));
if(!filename.isEmpty()) {
if(!walletModel->backupWallet(filename)) {
QMessageBox::warning(this, tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location."));
}
}
}
void BitcoinGUI::dumpWallet()
{
if(!walletModel)
return;
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet failed or was cancelled
return;
}
#if QT_VERSION < 0x050000
QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif
QString filename = QFileDialog::getSaveFileName(this, tr("Dump Wallet"), saveDir, tr("Wallet dump (*.txt)"));
if(!filename.isEmpty()) {
if(!walletModel->dumpWallet(filename)) {
message(tr("Dump failed"),
tr("An error happened while trying to save the keys to your location.\n"
"Keys were not saved.")
,CClientUIInterface::MSG_ERROR);
}
else
message(tr("Dump successful"),
tr("Keys were saved to this file:\n%2")
.arg(filename)
,CClientUIInterface::MSG_INFORMATION);
}
}
void BitcoinGUI::importWallet()
{
if(!walletModel)
return;
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet failed or was cancelled
return;
}
#if QT_VERSION < 0x050000
QString openDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString openDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif
QString filename = QFileDialog::getOpenFileName(this, tr("Import Wallet"), openDir, tr("Wallet dump (*.txt)"));
if(!filename.isEmpty()) {
if(!walletModel->importWallet(filename)) {
message(tr("Import Failed"),
tr("An error happened while trying to import the keys.\n"
"Some or all keys from:\n %1,\n were not imported into your wallet.")
.arg(filename)
,CClientUIInterface::MSG_ERROR);
}
else
message(tr("Import Successful"),
tr("All keys from:\n %1,\n were imported into your wallet.")
.arg(filename)
,CClientUIInterface::MSG_INFORMATION);
}
}
void BitcoinGUI::changePassphrase()
{
AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
dlg.setModel(walletModel);
dlg.exec();
}
void BitcoinGUI::unlockWallet()
{
if(!walletModel)
return;
// Unlock wallet when requested by wallet model
if(walletModel->getEncryptionStatus() == WalletModel::Locked)
{
AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this);
dlg.setModel(walletModel);
dlg.exec();
}
}
void BitcoinGUI::lockWallet()
{
if(!walletModel)
return;
walletModel->setWalletLocked(true);
}
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (isHidden())
{
// Make sure the window is not minimized
setWindowState(windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
// Then show it
show();
raise();
activateWindow();
}
else if (isMinimized())
{
showNormal();
raise();
activateWindow();
}
else if (GUIUtil::isObscured(this))
{
raise();
activateWindow();
if(fToggleHidden)
{
Sleep(1);
if (GUIUtil::isObscured(this))
hide();
}
}
else if(fToggleHidden)
hide();
}
void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
void BitcoinGUI::error(const QString &title, const QString &message, bool modal)
{
// Report errors from network/worker thread
if(modal)
{
QMessageBox::critical(this, title, message, QMessageBox::Ok, QMessageBox::Ok);
} else {
notificator->notify(Notificator::Critical, title, message);
}
}
|
; A008732: Molien series for 3-dimensional group [2,n] = *22n.
; 1,2,3,4,5,7,9,11,13,15,18,21,24,27,30,34,38,42,46,50,55,60,65,70,75,81,87,93,99,105,112,119,126,133,140,148,156,164,172,180,189,198,207,216,225,235,245,255,265,275,286,297,308,319,330,342,354,366,378,390,403,416,429,442,455,469,483,497,511,525,540,555,570,585,600,616,632,648,664,680,697,714,731,748,765,783,801,819,837,855,874,893,912,931,950,970,990,1010,1030,1050
add $0,4
bin $0,2
div $0,5
|
/*=========================================================================
Program: ParaView
Module: ParaViewMainWindow.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
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 AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "vtkPVConfig.h"
#ifdef PARAVIEW_ENABLE_PYTHON
extern "C" {
void vtkPVInitializePythonModules();
}
#endif
#include "ParaViewMainWindow.h"
#include "ui_ParaViewMainWindow.h"
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqHelpReaction.h"
#include "pqObjectInspectorWidget.h"
#include "pqOptions.h"
#include "pqParaViewBehaviors.h"
#include "pqParaViewMenuBuilders.h"
#include "pqPropertiesPanel.h"
#include "vtkProcessModule.h"
#include "vtkPVPlugin.h"
#ifndef BUILD_SHARED_LIBS
# include "pvStaticPluginsInit.h"
#endif
#include "ParaViewDocumentationInitializer.h"
#ifdef PARAVIEW_ENABLE_PYTHON
# include "pqPythonDebugLeaksView.h"
typedef pqPythonDebugLeaksView DebugLeaksViewType;
#else
# include "vtkQtDebugLeaksView.h"
typedef vtkQtDebugLeaksView DebugLeaksViewType;
#endif
class ParaViewMainWindow::pqInternals : public Ui::pqClientMainWindow
{
};
//-----------------------------------------------------------------------------
ParaViewMainWindow::ParaViewMainWindow()
{
// the debug leaks view should be constructed as early as possible
// so that it can monitor vtk objects created at application startup.
if (getenv("PV_DEBUG_LEAKS_VIEW"))
{
vtkQtDebugLeaksView* leaksView = new DebugLeaksViewType(this);
leaksView->setWindowFlags(Qt::Window);
leaksView->show();
}
#ifdef PARAVIEW_ENABLE_PYTHON
vtkPVInitializePythonModules();
#endif
// init the ParaView embedded documentation.
PARAVIEW_DOCUMENTATION_INIT();
this->Internals = new pqInternals();
this->Internals->setupUi(this);
// Setup default GUI layout.
this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
// Set up the dock window corners to give the vertical docks more room.
this->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
this->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
this->tabifyDockWidget(
this->Internals->colorMapEditorDock,
this->Internals->memoryInspectorDock);
this->tabifyDockWidget(
this->Internals->colorMapEditorDock,
this->Internals->comparativePanelDock);
this->tabifyDockWidget(
this->Internals->colorMapEditorDock,
this->Internals->collaborationPanelDock);
this->Internals->animationViewDock->hide();
this->Internals->statisticsDock->hide();
this->Internals->comparativePanelDock->hide();
this->Internals->collaborationPanelDock->hide();
this->Internals->memoryInspectorDock->hide();
this->Internals->multiBlockInspectorDock->hide();
this->Internals->colorMapEditorDock->hide();
this->tabifyDockWidget(this->Internals->animationViewDock,
this->Internals->statisticsDock);
pqOptions* options = pqOptions::SafeDownCast(
vtkProcessModule::GetProcessModule()->GetOptions());
if(!options->GetUseOldPanels())
{
this->removeDockWidget(this->Internals->objectInspectorDock);
this->removeDockWidget(this->Internals->displayDock);
delete this->Internals->objectInspectorDock;
delete this->Internals->displayDock;
this->Internals->objectInspectorDock = 0;
this->Internals->displayDock = 0;
this->tabifyDockWidget(this->Internals->propertiesDock, this->Internals->informationDock);
this->Internals->propertiesDock->show();
this->Internals->propertiesDock->raise();
// Enable help from the properties panel.
QObject::connect(this->Internals->propertiesPanel,
SIGNAL(helpRequested(const QString&, const QString&)),
this, SLOT(showHelpForProxy(const QString&, const QString&)));
}
else
{
this->removeDockWidget(this->Internals->propertiesDock);
delete this->Internals->propertiesDock;
this->Internals->propertiesDock = 0;
this->tabifyDockWidget(this->Internals->objectInspectorDock, this->Internals->displayDock);
this->tabifyDockWidget(this->Internals->objectInspectorDock, this->Internals->informationDock);
this->Internals->objectInspectorDock->raise();
// Enable help from the object inspector.
QObject::connect(this->Internals->objectInspector,
SIGNAL(helpRequested(const QString&, const QString&)),
this, SLOT(showHelpForProxy(const QString&, const QString&)));
}
/// Provide access to the color-editor panel for the application.
pqApplicationCore::instance()->registerManager(
"COLOR_EDITOR_PANEL", this->Internals->colorMapEditorDock);
// Populate application menus with actions.
pqParaViewMenuBuilders::buildFileMenu(*this->Internals->menu_File);
pqParaViewMenuBuilders::buildEditMenu(*this->Internals->menu_Edit);
// Populate sources menu.
pqParaViewMenuBuilders::buildSourcesMenu(*this->Internals->menuSources, this);
// Populate filters menu.
pqParaViewMenuBuilders::buildFiltersMenu(*this->Internals->menuFilters, this);
// Populate Tools menu.
pqParaViewMenuBuilders::buildToolsMenu(*this->Internals->menuTools);
// setup the context menu for the pipeline browser.
pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(
*this->Internals->pipelineBrowser);
pqParaViewMenuBuilders::buildToolbars(*this);
// Setup the View menu. This must be setup after all toolbars and dockwidgets
// have been created.
pqParaViewMenuBuilders::buildViewMenu(*this->Internals->menu_View, *this);
// Setup the menu to show macros.
pqParaViewMenuBuilders::buildMacrosMenu(*this->Internals->menu_Macros);
// Setup the help menu.
pqParaViewMenuBuilders::buildHelpMenu(*this->Internals->menu_Help);
// Final step, define application behaviors. Since we want all ParaView
// behaviors, we use this convenience method.
new pqParaViewBehaviors(this, this);
// load static plugins
#ifndef BUILD_SHARED_LIBS
paraview_static_plugins_init();
#endif
}
//-----------------------------------------------------------------------------
ParaViewMainWindow::~ParaViewMainWindow()
{
delete this->Internals;
}
//-----------------------------------------------------------------------------
void ParaViewMainWindow::showHelpForProxy(const QString& groupname, const
QString& proxyname)
{
pqHelpReaction::showProxyHelp(groupname, proxyname);
}
|
; A008936: Expansion of (1 - 2*x -x^4)/(1 - 2*x)^2 in powers of x.
; 1,2,4,8,15,28,52,96,176,320,576,1024,1792,3072,5120,8192,12288,16384,16384,0,-65536,-262144,-786432,-2097152,-5242880,-12582912,-29360128,-67108864,-150994944,-335544320,-738197504,-1610612736,-3489660928,-7516192768,-16106127360,-34359738368,-73014444032,-154618822656,-326417514496,-687194767360,-1443109011456,-3023656976384,-6322191859712,-13194139533312,-27487790694400,-57174604644352,-118747255799808,-246290604621824,-510173395288064,-1055531162664960,-2181431069507584,-4503599627370496,-9288674231451648,-19140298416324608,-39406496739491840,-81064793292668928,-166633186212708352,-342273571680157696,-702561541869797376,-1441151880758558720,-2954361355555045376,-6052837899185946624,-12393906174523604992,-25364273101350633472,-51881467707308113920,-106068778423829921792,-216749242866087231488,-442721857769029238784,-903890459611768029184,-1844674407370955161600,-3763135791036748529664,-7673845534663173472256,-15642838974505699770368,-31875973759370105192448,-64932539139457621688320,-132226261520350065983488,-269174889523569777180672,-547794512012878844788736,-1114478489957236270432256,-2266735911777429702574080,-4609029687280773728567296,-9369175102013376103972864,-19040581658930409501622272,-38685626227668133590597632,-78580178274950896355901440,-159578208189131051061215232,-323992119656720618821255168,-657655645870358271040159744,-1334654104854550608875618304,-2707993835936769351341834240,-5493358924328874969864863744,-11141460353568422474092118016,-22592405716958190016909017088,-45803781453559070171267596288,-92845502946403520617434316800,-188166885971377801784666882048,-381285532099897124668930260992,-772474584514077291537053515776,-1564756209656720667472493019136,-3169126500570573503741758013440
add $0,1
mov $2,$0
lpb $0
sub $0,1
sub $2,10
mul $2,2
cmp $3,0
sub $3,$2
lpe
mov $0,$3
sub $0,12
div $0,32
add $0,1
|
; ---------------------------------------------------------------------------
; Sprite mappings - SLZ platforms
; ---------------------------------------------------------------------------
dc.w byte_819C-Map_obj18b
byte_819C: dc.b 2
dc.b $F8, $F, 0, $21, $E0
dc.b $F8, $F, 0, $21, 0
even |
; Stub for the SHARP MZ family
;
; Stefano Bodrato - 5/5/2000
;
; $Id: mz_crt0.asm,v 1.24 2016/07/15 21:03:25 dom Exp $
;
MODULE mz_crt0
;--------
; Include zcc_opt.def to find out some info
;--------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;--------
; Some scope definitions
;--------
EXTERN _main ;main() is always external to crt0 code
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
; Now, getting to the real stuff now!
IF !DEFINED_CRT_ORG_CODE
defc CRT_ORG_CODE = $1300
ENDIF
org CRT_ORG_CODE
start:
ld (start1+1),sp ;Save entry stack
ld hl,-64
add hl,sp
ld sp,hl
call crt0_init_bss
ld (exitsp),sp
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
; the compiled program and the stack pointer
IF DEFINED_USING_amalloc
INCLUDE "amalloc.def"
ENDIF
call _main
cleanup:
;
; Deallocate memory which has been allocated here!
;
IF !DEFINED_nostreams
EXTERN closeall
call closeall
ENDIF
start1:
ld sp,0
jp $AD ; Go back to monitor
l_dcal: jp (hl) ;Used for function pointer calls
defm "Small C+ SHARP MZ"
defb 0
INCLUDE "crt0_runtime_selection.asm"
INCLUDE "crt0_section.asm"
SECTION code_crt_init
ld hl,$D000
ld (base_graphics),hl
|
; A212294: Sums of (zero or more) distinct twin primes.
; 0,3,5,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74
sub $1,$0
add $0,11
add $1,2
lpb $0
sub $2,2
add $2,$1
sub $0,$2
div $0,2
lpe
|
start:
set r2 2
set r3 3500
set r4 1000
mul r2 r2 r4
add r4 r2 r3
set r2 'e'
set r3 1000
mul r2 r2 r3
add r5 r4 r2
writenumber r5
stop
|
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 <aws/rds/model/ModifyDBSnapshotAttributeResult.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <utility>
using namespace Aws::RDS::Model;
using namespace Aws::Utils::Xml;
using namespace Aws::Utils::Logging;
using namespace Aws::Utils;
using namespace Aws;
ModifyDBSnapshotAttributeResult::ModifyDBSnapshotAttributeResult()
{
}
ModifyDBSnapshotAttributeResult::ModifyDBSnapshotAttributeResult(const AmazonWebServiceResult<XmlDocument>& result)
{
*this = result;
}
ModifyDBSnapshotAttributeResult& ModifyDBSnapshotAttributeResult::operator =(const AmazonWebServiceResult<XmlDocument>& result)
{
const XmlDocument& xmlDocument = result.GetPayload();
XmlNode rootNode = xmlDocument.GetRootElement();
XmlNode resultNode = rootNode;
if (rootNode.GetName() != "ModifyDBSnapshotAttributeResult")
{
resultNode = rootNode.FirstChild("ModifyDBSnapshotAttributeResult");
}
if(!resultNode.IsNull())
{
XmlNode dBSnapshotAttributesResultNode = resultNode.FirstChild("DBSnapshotAttributesResult");
if(!dBSnapshotAttributesResultNode.IsNull())
{
m_dBSnapshotAttributesResult = dBSnapshotAttributesResultNode;
}
}
XmlNode responseMetadataNode = rootNode.FirstChild("ResponseMetadata");
m_responseMetadata = responseMetadataNode;
AWS_LOGSTREAM_DEBUG("Aws::RDS::Model::ModifyDBSnapshotAttributeResult", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() );
return *this;
}
|
; A227721: Floor(1/s(n)), where s(n) = (2n+1)/(2n+2) - n*log((n+1)/n).
; 17,44,83,134,197,272,359,458,569,692,827,974,1133,1304,1487,1682,1889,2108,2339,2582,2837,3104,3383,3674,3977,4292,4619,4958,5309,5672,6047,6434,6833,7244,7667,8102,8549,9008,9479,9962,10457,10964,11483,12014,12557,13112,13679,14258,14849,15452,16067,16694,17333,17984,18647,19322,20009,20708,21419,22142,22877,23624,24383,25154,25937,26732,27539,28358,29189,30032,30887,31754,32633,33524,34427,35342,36269,37208,38159,39122,40097,41084,42083,43094,44117,45152,46199,47258,48329,49412,50507,51614
mov $1,6
mul $1,$0
add $1,21
mul $1,$0
add $1,17
mov $0,$1
|
cpy {m1}
bcc {la1}
|
; Endless loop
move r00 #1
.org @x10
.nam hello
addi r00 #1
jump hello
halt
|
; A284675: Positions of 0 in A284674; complement of A284676.
; Submitted by Christian Krause
; 1,6,10,14,19,23,27,32,36,40,45,49,53,57,62,66,70,75,79,83,88,92,96,100,105,109,113,118,122,126,131,135,139,143,148,152,156,161,165,169,174,178,182,187,191,195,199,204,208,212,217,221,225,230,234,238,242,247,251,255,260,264,268,273,277,281,285,290,294,298,303,307,311,316,320,324,329,333,337,341,346,350,354,359,363,367,372,376,380,384,389,393,397,402,406,410,415,419,423,427
lpb $0
mov $2,$0
div $0,72436
seq $2,284678 ; Positions of 0 in A284677; complement of A284679.
sub $2,1
lpe
mov $0,$2
add $0,1
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkSVGDevice.h"
#include "SkBase64.h"
#include "SkBitmap.h"
#include "SkChecksum.h"
#include "SkClipStack.h"
#include "SkData.h"
#include "SkDraw.h"
#include "SkImageEncoder.h"
#include "SkPaint.h"
#include "SkParsePath.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTHash.h"
#include "SkTypeface.h"
#include "SkUtils.h"
#include "SkXMLWriter.h"
namespace {
static SkString svg_color(SkColor color) {
return SkStringPrintf("rgb(%u,%u,%u)",
SkColorGetR(color),
SkColorGetG(color),
SkColorGetB(color));
}
static SkScalar svg_opacity(SkColor color) {
return SkIntToScalar(SkColorGetA(color)) / SK_AlphaOPAQUE;
}
// Keep in sync with SkPaint::Cap
static const char* cap_map[] = {
nullptr, // kButt_Cap (default)
"round", // kRound_Cap
"square" // kSquare_Cap
};
static_assert(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, "missing_cap_map_entry");
static const char* svg_cap(SkPaint::Cap cap) {
SkASSERT(cap < SK_ARRAY_COUNT(cap_map));
return cap_map[cap];
}
// Keep in sync with SkPaint::Join
static const char* join_map[] = {
nullptr, // kMiter_Join (default)
"round", // kRound_Join
"bevel" // kBevel_Join
};
static_assert(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, "missing_join_map_entry");
static const char* svg_join(SkPaint::Join join) {
SkASSERT(join < SK_ARRAY_COUNT(join_map));
return join_map[join];
}
// Keep in sync with SkPaint::Align
static const char* text_align_map[] = {
nullptr, // kLeft_Align (default)
"middle", // kCenter_Align
"end" // kRight_Align
};
static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
"missing_text_align_map_entry");
static const char* svg_text_align(SkPaint::Align align) {
SkASSERT(align < SK_ARRAY_COUNT(text_align_map));
return text_align_map[align];
}
static SkString svg_transform(const SkMatrix& t) {
SkASSERT(!t.isIdentity());
SkString tstr;
switch (t.getType()) {
case SkMatrix::kPerspective_Mask:
SkDebugf("Can't handle perspective matrices.");
break;
case SkMatrix::kTranslate_Mask:
tstr.printf("translate(%g %g)", t.getTranslateX(), t.getTranslateY());
break;
case SkMatrix::kScale_Mask:
tstr.printf("scale(%g %g)", t.getScaleX(), t.getScaleY());
break;
default:
// http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined
// | a c e |
// | b d f |
// | 0 0 1 |
tstr.printf("matrix(%g %g %g %g %g %g)",
t.getScaleX(), t.getSkewY(),
t.getSkewX(), t.getScaleY(),
t.getTranslateX(), t.getTranslateY());
break;
}
return tstr;
}
struct Resources {
Resources(const SkPaint& paint)
: fPaintServer(svg_color(paint.getColor())) {}
SkString fPaintServer;
SkString fClip;
};
class SVGTextBuilder : SkNoncopyable {
public:
SVGTextBuilder(const void* text, size_t byteLen, const SkPaint& paint, const SkPoint& offset,
unsigned scalarsPerPos, const SkScalar pos[] = nullptr)
: fOffset(offset)
, fScalarsPerPos(scalarsPerPos)
, fPos(pos)
, fLastCharWasWhitespace(true) // start off in whitespace mode to strip all leading space
{
SkASSERT(scalarsPerPos <= 2);
SkASSERT(scalarsPerPos == 0 || SkToBool(pos));
int count = paint.countText(text, byteLen);
switch(paint.getTextEncoding()) {
case SkPaint::kGlyphID_TextEncoding: {
SkASSERT(count * sizeof(uint16_t) == byteLen);
SkAutoSTArray<64, SkUnichar> unichars(count);
paint.glyphsToUnichars((const uint16_t*)text, count, unichars.get());
for (int i = 0; i < count; ++i) {
this->appendUnichar(unichars[i]);
}
} break;
case SkPaint::kUTF8_TextEncoding: {
const char* c8 = reinterpret_cast<const char*>(text);
for (int i = 0; i < count; ++i) {
this->appendUnichar(SkUTF8_NextUnichar(&c8));
}
SkASSERT(reinterpret_cast<const char*>(text) + byteLen == c8);
} break;
case SkPaint::kUTF16_TextEncoding: {
const uint16_t* c16 = reinterpret_cast<const uint16_t*>(text);
for (int i = 0; i < count; ++i) {
this->appendUnichar(SkUTF16_NextUnichar(&c16));
}
SkASSERT(SkIsAlign2(byteLen));
SkASSERT(reinterpret_cast<const uint16_t*>(text) + (byteLen / 2) == c16);
} break;
case SkPaint::kUTF32_TextEncoding: {
SkASSERT(count * sizeof(uint32_t) == byteLen);
const uint32_t* c32 = reinterpret_cast<const uint32_t*>(text);
for (int i = 0; i < count; ++i) {
this->appendUnichar(c32[i]);
}
} break;
default:
SkFAIL("unknown text encoding");
}
if (scalarsPerPos < 2) {
SkASSERT(fPosY.isEmpty());
fPosY.appendScalar(offset.y()); // DrawText or DrawPosTextH (fixed Y).
}
if (scalarsPerPos < 1) {
SkASSERT(fPosX.isEmpty());
fPosX.appendScalar(offset.x()); // DrawText (X also fixed).
}
}
const SkString& text() const { return fText; }
const SkString& posX() const { return fPosX; }
const SkString& posY() const { return fPosY; }
private:
void appendUnichar(SkUnichar c) {
bool discardPos = false;
bool isWhitespace = false;
switch(c) {
case ' ':
case '\t':
// consolidate whitespace to match SVG's xml:space=default munging
// (http://www.w3.org/TR/SVG/text.html#WhiteSpace)
if (fLastCharWasWhitespace) {
discardPos = true;
} else {
fText.appendUnichar(c);
}
isWhitespace = true;
break;
case '\0':
// SkPaint::glyphsToUnichars() returns \0 for inconvertible glyphs, but these
// are not legal XML characters (http://www.w3.org/TR/REC-xml/#charsets)
discardPos = true;
isWhitespace = fLastCharWasWhitespace; // preserve whitespace consolidation
break;
case '&':
fText.append("&");
break;
case '"':
fText.append(""");
break;
case '\'':
fText.append("'");
break;
case '<':
fText.append("<");
break;
case '>':
fText.append(">");
break;
default:
fText.appendUnichar(c);
break;
}
this->advancePos(discardPos);
fLastCharWasWhitespace = isWhitespace;
}
void advancePos(bool discard) {
if (!discard && fScalarsPerPos > 0) {
fPosX.appendf("%.8g, ", fOffset.x() + fPos[0]);
if (fScalarsPerPos > 1) {
SkASSERT(fScalarsPerPos == 2);
fPosY.appendf("%.8g, ", fOffset.y() + fPos[1]);
}
}
fPos += fScalarsPerPos;
}
const SkPoint& fOffset;
const unsigned fScalarsPerPos;
const SkScalar* fPos;
SkString fText, fPosX, fPosY;
bool fLastCharWasWhitespace;
};
}
// For now all this does is serve unique serial IDs, but it will eventually evolve to track
// and deduplicate resources.
class SkSVGDevice::ResourceBucket : ::SkNoncopyable {
public:
ResourceBucket() : fGradientCount(0), fClipCount(0), fPathCount(0), fImageCount(0) {}
SkString addLinearGradient() {
return SkStringPrintf("gradient_%d", fGradientCount++);
}
SkString addClip() {
return SkStringPrintf("clip_%d", fClipCount++);
}
SkString addPath() {
return SkStringPrintf("path_%d", fPathCount++);
}
SkString addImage() {
return SkStringPrintf("img_%d", fImageCount++);
}
private:
uint32_t fGradientCount;
uint32_t fClipCount;
uint32_t fPathCount;
uint32_t fImageCount;
};
class SkSVGDevice::AutoElement : ::SkNoncopyable {
public:
AutoElement(const char name[], SkXMLWriter* writer)
: fWriter(writer)
, fResourceBucket(nullptr) {
fWriter->startElement(name);
}
AutoElement(const char name[], SkXMLWriter* writer, ResourceBucket* bucket,
const SkDraw& draw, const SkPaint& paint)
: fWriter(writer)
, fResourceBucket(bucket) {
Resources res = this->addResources(draw, paint);
if (!res.fClip.isEmpty()) {
// The clip is in device space. Apply it via a <g> wrapper to avoid local transform
// interference.
fClipGroup.reset(new AutoElement("g", fWriter));
fClipGroup->addAttribute("clip-path",res.fClip);
}
fWriter->startElement(name);
this->addPaint(paint, res);
if (!draw.fMatrix->isIdentity()) {
this->addAttribute("transform", svg_transform(*draw.fMatrix));
}
}
~AutoElement() {
fWriter->endElement();
}
void addAttribute(const char name[], const char val[]) {
fWriter->addAttribute(name, val);
}
void addAttribute(const char name[], const SkString& val) {
fWriter->addAttribute(name, val.c_str());
}
void addAttribute(const char name[], int32_t val) {
fWriter->addS32Attribute(name, val);
}
void addAttribute(const char name[], SkScalar val) {
fWriter->addScalarAttribute(name, val);
}
void addText(const SkString& text) {
fWriter->addText(text.c_str(), text.size());
}
void addRectAttributes(const SkRect&);
void addPathAttributes(const SkPath&);
void addTextAttributes(const SkPaint&);
private:
Resources addResources(const SkDraw& draw, const SkPaint& paint);
void addClipResources(const SkDraw& draw, Resources* resources);
void addShaderResources(const SkPaint& paint, Resources* resources);
void addPaint(const SkPaint& paint, const Resources& resources);
SkString addLinearGradientDef(const SkShader::GradientInfo& info, const SkShader* shader);
SkXMLWriter* fWriter;
ResourceBucket* fResourceBucket;
std::unique_ptr<AutoElement> fClipGroup;
};
void SkSVGDevice::AutoElement::addPaint(const SkPaint& paint, const Resources& resources) {
SkPaint::Style style = paint.getStyle();
if (style == SkPaint::kFill_Style || style == SkPaint::kStrokeAndFill_Style) {
this->addAttribute("fill", resources.fPaintServer);
if (SK_AlphaOPAQUE != SkColorGetA(paint.getColor())) {
this->addAttribute("fill-opacity", svg_opacity(paint.getColor()));
}
} else {
SkASSERT(style == SkPaint::kStroke_Style);
this->addAttribute("fill", "none");
}
if (style == SkPaint::kStroke_Style || style == SkPaint::kStrokeAndFill_Style) {
this->addAttribute("stroke", resources.fPaintServer);
SkScalar strokeWidth = paint.getStrokeWidth();
if (strokeWidth == 0) {
// Hairline stroke
strokeWidth = 1;
this->addAttribute("vector-effect", "non-scaling-stroke");
}
this->addAttribute("stroke-width", strokeWidth);
if (const char* cap = svg_cap(paint.getStrokeCap())) {
this->addAttribute("stroke-linecap", cap);
}
if (const char* join = svg_join(paint.getStrokeJoin())) {
this->addAttribute("stroke-linejoin", join);
}
if (paint.getStrokeJoin() == SkPaint::kMiter_Join) {
this->addAttribute("stroke-miterlimit", paint.getStrokeMiter());
}
if (SK_AlphaOPAQUE != SkColorGetA(paint.getColor())) {
this->addAttribute("stroke-opacity", svg_opacity(paint.getColor()));
}
} else {
SkASSERT(style == SkPaint::kFill_Style);
this->addAttribute("stroke", "none");
}
}
Resources SkSVGDevice::AutoElement::addResources(const SkDraw& draw, const SkPaint& paint) {
Resources resources(paint);
// FIXME: this is a weak heuristic and we end up with LOTS of redundant clips.
bool hasClip = !draw.fClipStack->isWideOpen();
bool hasShader = SkToBool(paint.getShader());
if (hasClip || hasShader) {
AutoElement defs("defs", fWriter);
if (hasClip) {
this->addClipResources(draw, &resources);
}
if (hasShader) {
this->addShaderResources(paint, &resources);
}
}
return resources;
}
void SkSVGDevice::AutoElement::addShaderResources(const SkPaint& paint, Resources* resources) {
const SkShader* shader = paint.getShader();
SkASSERT(SkToBool(shader));
SkShader::GradientInfo grInfo;
grInfo.fColorCount = 0;
if (SkShader::kLinear_GradientType != shader->asAGradient(&grInfo)) {
// TODO: non-linear gradient support
SkDebugf("unsupported shader type\n");
return;
}
SkAutoSTArray<16, SkColor> grColors(grInfo.fColorCount);
SkAutoSTArray<16, SkScalar> grOffsets(grInfo.fColorCount);
grInfo.fColors = grColors.get();
grInfo.fColorOffsets = grOffsets.get();
// One more call to get the actual colors/offsets.
shader->asAGradient(&grInfo);
SkASSERT(grInfo.fColorCount <= grColors.count());
SkASSERT(grInfo.fColorCount <= grOffsets.count());
resources->fPaintServer.printf("url(#%s)", addLinearGradientDef(grInfo, shader).c_str());
}
void SkSVGDevice::AutoElement::addClipResources(const SkDraw& draw, Resources* resources) {
SkASSERT(!draw.fClipStack->isWideOpen());
SkPath clipPath;
(void) draw.fClipStack->asPath(&clipPath);
SkString clipID = fResourceBucket->addClip();
const char* clipRule = clipPath.getFillType() == SkPath::kEvenOdd_FillType ?
"evenodd" : "nonzero";
{
// clipPath is in device space, but since we're only pushing transform attributes
// to the leaf nodes, so are all our elements => SVG userSpaceOnUse == device space.
AutoElement clipPathElement("clipPath", fWriter);
clipPathElement.addAttribute("id", clipID);
SkRect clipRect = SkRect::MakeEmpty();
if (clipPath.isEmpty() || clipPath.isRect(&clipRect)) {
AutoElement rectElement("rect", fWriter);
rectElement.addRectAttributes(clipRect);
rectElement.addAttribute("clip-rule", clipRule);
} else {
AutoElement pathElement("path", fWriter);
pathElement.addPathAttributes(clipPath);
pathElement.addAttribute("clip-rule", clipRule);
}
}
resources->fClip.printf("url(#%s)", clipID.c_str());
}
SkString SkSVGDevice::AutoElement::addLinearGradientDef(const SkShader::GradientInfo& info,
const SkShader* shader) {
SkASSERT(fResourceBucket);
SkString id = fResourceBucket->addLinearGradient();
{
AutoElement gradient("linearGradient", fWriter);
gradient.addAttribute("id", id);
gradient.addAttribute("gradientUnits", "userSpaceOnUse");
gradient.addAttribute("x1", info.fPoint[0].x());
gradient.addAttribute("y1", info.fPoint[0].y());
gradient.addAttribute("x2", info.fPoint[1].x());
gradient.addAttribute("y2", info.fPoint[1].y());
if (!shader->getLocalMatrix().isIdentity()) {
this->addAttribute("gradientTransform", svg_transform(shader->getLocalMatrix()));
}
SkASSERT(info.fColorCount >= 2);
for (int i = 0; i < info.fColorCount; ++i) {
SkColor color = info.fColors[i];
SkString colorStr(svg_color(color));
{
AutoElement stop("stop", fWriter);
stop.addAttribute("offset", info.fColorOffsets[i]);
stop.addAttribute("stop-color", colorStr.c_str());
if (SK_AlphaOPAQUE != SkColorGetA(color)) {
stop.addAttribute("stop-opacity", svg_opacity(color));
}
}
}
}
return id;
}
void SkSVGDevice::AutoElement::addRectAttributes(const SkRect& rect) {
// x, y default to 0
if (rect.x() != 0) {
this->addAttribute("x", rect.x());
}
if (rect.y() != 0) {
this->addAttribute("y", rect.y());
}
this->addAttribute("width", rect.width());
this->addAttribute("height", rect.height());
}
void SkSVGDevice::AutoElement::addPathAttributes(const SkPath& path) {
SkString pathData;
SkParsePath::ToSVGString(path, &pathData);
this->addAttribute("d", pathData);
}
void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
this->addAttribute("font-size", paint.getTextSize());
if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
this->addAttribute("text-anchor", textAlign);
}
SkString familyName;
SkTHashSet<SkString> familySet;
sk_sp<const SkTypeface> tface(paint.getTypeface() ?
sk_ref_sp(paint.getTypeface()) : SkTypeface::MakeDefault());
SkASSERT(tface);
SkTypeface::Style style = tface->style();
if (style & SkTypeface::kItalic) {
this->addAttribute("font-style", "italic");
}
if (style & SkTypeface::kBold) {
this->addAttribute("font-weight", "bold");
}
sk_sp<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamilyNameIterator());
SkTypeface::LocalizedString familyString;
while (familyNameIter->next(&familyString)) {
if (familySet.contains(familyString.fString)) {
continue;
}
familySet.add(familyString.fString);
familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString.fString.c_str());
}
if (!familyName.isEmpty()) {
this->addAttribute("font-family", familyName);
}
}
SkBaseDevice* SkSVGDevice::Create(const SkISize& size, SkXMLWriter* writer) {
if (!writer) {
return nullptr;
}
return new SkSVGDevice(size, writer);
}
SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer)
: INHERITED(SkImageInfo::MakeUnknown(size.fWidth, size.fHeight),
SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fWriter(writer)
, fResourceBucket(new ResourceBucket)
{
SkASSERT(writer);
fWriter->writeHeader();
// The root <svg> tag gets closed by the destructor.
fRootElement.reset(new AutoElement("svg", fWriter));
fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg");
fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
fRootElement->addAttribute("width", size.width());
fRootElement->addAttribute("height", size.height());
}
SkSVGDevice::~SkSVGDevice() {
}
void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
AutoElement rect("rect", fWriter, fResourceBucket.get(), draw, paint);
rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()),
SkIntToScalar(this->height())));
}
void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) {
SkPath path;
switch (mode) {
// todo
case SkCanvas::kPoints_PointMode:
SkDebugf("unsupported operation: drawPoints(kPoints_PointMode)\n");
break;
case SkCanvas::kLines_PointMode:
count -= 1;
for (size_t i = 0; i < count; i += 2) {
path.rewind();
path.moveTo(pts[i]);
path.lineTo(pts[i+1]);
AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
elem.addPathAttributes(path);
}
break;
case SkCanvas::kPolygon_PointMode:
if (count > 1) {
path.addPoly(pts, SkToInt(count), false);
path.moveTo(pts[0]);
AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
elem.addPathAttributes(path);
}
break;
}
}
void SkSVGDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) {
AutoElement rect("rect", fWriter, fResourceBucket.get(), draw, paint);
rect.addRectAttributes(r);
}
void SkSVGDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
AutoElement ellipse("ellipse", fWriter, fResourceBucket.get(), draw, paint);
ellipse.addAttribute("cx", oval.centerX());
ellipse.addAttribute("cy", oval.centerY());
ellipse.addAttribute("rx", oval.width() / 2);
ellipse.addAttribute("ry", oval.height() / 2);
}
void SkSVGDevice::drawRRect(const SkDraw& draw, const SkRRect& rr, const SkPaint& paint) {
SkPath path;
path.addRRect(rr);
AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
elem.addPathAttributes(path);
}
void SkSVGDevice::drawPath(const SkDraw& draw, const SkPath& path, const SkPaint& paint,
const SkMatrix* prePathMatrix, bool pathIsMutable) {
AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
elem.addPathAttributes(path);
// TODO: inverse fill types?
if (path.getFillType() == SkPath::kEvenOdd_FillType) {
elem.addAttribute("fill-rule", "evenodd");
}
}
void SkSVGDevice::drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm,
const SkPaint& paint) {
sk_sp<const SkData> pngData(
SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality));
if (!pngData) {
return;
}
size_t b64Size = SkBase64::Encode(pngData->data(), pngData->size(), nullptr);
SkAutoTMalloc<char> b64Data(b64Size);
SkBase64::Encode(pngData->data(), pngData->size(), b64Data.get());
SkString svgImageData("data:image/png;base64,");
svgImageData.append(b64Data.get(), b64Size);
SkString imageID = fResourceBucket->addImage();
{
AutoElement defs("defs", fWriter);
{
AutoElement image("image", fWriter);
image.addAttribute("id", imageID);
image.addAttribute("width", bm.width());
image.addAttribute("height", bm.height());
image.addAttribute("xlink:href", svgImageData);
}
}
{
AutoElement imageUse("use", fWriter, fResourceBucket.get(), draw, paint);
imageUse.addAttribute("xlink:href", SkStringPrintf("#%s", imageID.c_str()));
}
}
void SkSVGDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) {
SkMatrix adjustedMatrix = *draw.fMatrix;
adjustedMatrix.preConcat(matrix);
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
drawBitmapCommon(adjustedDraw, bitmap, paint);
}
void SkSVGDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) {
SkMatrix adjustedMatrix = *draw.fMatrix;
adjustedMatrix.preTranslate(SkIntToScalar(x), SkIntToScalar(y));
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
drawBitmapCommon(adjustedDraw, bitmap, paint);
}
void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const SkRect* srcOrNull,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint) {
SkMatrix adjustedMatrix;
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
dst,
SkMatrix::kFill_ScaleToFit);
adjustedMatrix.postConcat(*draw.fMatrix);
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
SkClipStack adjustedClipStack;
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
adjustedClipStack = *draw.fClipStack;
adjustedClipStack.clipRect(dst, *draw.fMatrix, SkCanvas::kIntersect_Op,
paint.isAntiAlias());
adjustedDraw.fClipStack = &adjustedClipStack;
}
drawBitmapCommon(adjustedDraw, bm, paint);
}
void SkSVGDevice::drawText(const SkDraw& draw, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) {
AutoElement elem("text", fWriter, fResourceBucket.get(), draw, paint);
elem.addTextAttributes(paint);
SVGTextBuilder builder(text, len, paint, SkPoint::Make(x, y), 0);
elem.addAttribute("x", builder.posX());
elem.addAttribute("y", builder.posY());
elem.addText(builder.text());
}
void SkSVGDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
const SkScalar pos[], int scalarsPerPos, const SkPoint& offset,
const SkPaint& paint) {
SkASSERT(scalarsPerPos == 1 || scalarsPerPos == 2);
AutoElement elem("text", fWriter, fResourceBucket.get(), draw, paint);
elem.addTextAttributes(paint);
SVGTextBuilder builder(text, len, paint, offset, scalarsPerPos, pos);
elem.addAttribute("x", builder.posX());
elem.addAttribute("y", builder.posY());
elem.addText(builder.text());
}
void SkSVGDevice::drawTextOnPath(const SkDraw&, const void* text, size_t len, const SkPath& path,
const SkMatrix* matrix, const SkPaint& paint) {
SkString pathID = fResourceBucket->addPath();
{
AutoElement defs("defs", fWriter);
AutoElement pathElement("path", fWriter);
pathElement.addAttribute("id", pathID);
pathElement.addPathAttributes(path);
}
{
AutoElement textElement("text", fWriter);
textElement.addTextAttributes(paint);
if (matrix && !matrix->isIdentity()) {
textElement.addAttribute("transform", svg_transform(*matrix));
}
{
AutoElement textPathElement("textPath", fWriter);
textPathElement.addAttribute("xlink:href", SkStringPrintf("#%s", pathID.c_str()));
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
SkASSERT(paint.getTextAlign() == SkPaint::kCenter_Align ||
paint.getTextAlign() == SkPaint::kRight_Align);
textPathElement.addAttribute("startOffset",
paint.getTextAlign() == SkPaint::kCenter_Align ? "50%" : "100%");
}
SVGTextBuilder builder(text, len, paint, SkPoint::Make(0, 0), 0);
textPathElement.addText(builder.text());
}
}
}
void SkSVGDevice::drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkBlendMode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) {
// todo
SkDebugf("unsupported operation: drawVertices()\n");
}
void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
const SkPaint&) {
// todo
SkDebugf("unsupported operation: drawDevice()\n");
}
|
; A071735: Expansion of (1+x^3*C^3)*C^2, where C = (1-(1-4*x)^(1/2))/(2*x) is g.f. for Catalan numbers, A000108.
; 1,2,5,15,47,152,504,1705,5863,20436,72046,256462,920550,3328192,12109270,44305245,162911415,601700700,2231255070,8304089970,31007435970,116130446640,436137803400,1642112017338,6197239974582
mov $2,$0
mov $4,2
lpb $4
mov $0,$2
sub $4,1
add $0,$4
trn $0,1
seq $0,782 ; a(n) = 2*Catalan(n) - Catalan(n-1).
mov $3,$0
mov $5,$4
mul $5,$0
add $1,$5
lpe
min $2,1
mul $2,$3
sub $1,$2
mov $0,$1
|
; A170476: Number of reduced words of length n in Coxeter group on 35 generators S_i with relations (S_i)^2 = (S_i S_j)^45 = I.
; 1,35,1190,40460,1375640,46771760,1590239840,54068154560,1838317255040,62502786671360,2125094746826240,72253221392092160,2456609527331133440,83524723929258536960,2839840613594790256640,96554580862222868725760
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,34
lpe
mov $0,$2
div $0,34
|
db 0 ; species ID placeholder
db 75, 90, 50, 95, 110, 80
; hp atk def spd sat sdf
db DARK, FIRE ; type
db 45 ; catch rate
db 204 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/houndoom/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROAR, TOXIC, ROCK_SMASH, DARK_PULSE, SUNNY_DAY, STONE_EDGE, SNORE, HYPER_BEAM, PROTECT, POISON_FANG, SOLARBEAM, IRON_HEAD, RETURN, SHADOW_BALL, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, FIRE_BLAST, SWIFT, PURSUIT, REST, ATTRACT, THIEF, STRENGTH, FLAMETHROWER
; end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r9
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x1ed0c, %rdi
xor %r9, %r9
vmovups (%rdi), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbx
nop
nop
nop
nop
cmp %rdx, %rdx
lea addresses_UC_ht+0x15cde, %rsi
lea addresses_UC_ht+0x7a0c, %rdi
nop
add $27736, %r9
mov $50, %rcx
rep movsw
nop
nop
nop
nop
nop
and $38677, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r9
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r8
push %rax
push %rcx
// Store
mov $0xd2c, %r10
nop
nop
nop
nop
xor %r14, %r14
movw $0x5152, (%r10)
nop
nop
nop
nop
sub $37805, %r10
// Faulty Load
lea addresses_PSE+0xfd0c, %r8
nop
nop
nop
and $7978, %r14
mov (%r8), %rcx
lea oracles, %r14
and $0xff, %rcx
shlq $12, %rcx
mov (%r14,%rcx,1), %rcx
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': True}}
{'33': 21}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; A080251: Paired decomposition of tetrahedral numbers A000292 arranged as number triangle.
; Submitted by Christian Krause
; 1,2,2,3,3,4,4,4,6,6,5,5,8,8,9,6,6,10,10,12,12,7,7,12,12,15,15,16,8,8,14,14,18,18,20,20,9,9,16,16,21,21,24,24,25,10,10,18,18,24,24,28,28,30,30,11,11,20,20,27,27,32,32,35,35,36
lpb $0
add $1,1
sub $0,$1
lpe
add $0,2
div $0,2
add $1,2
sub $1,$0
mul $1,$0
mov $0,$1
|
#include <bg2e/base/matrix_state.hpp>
namespace bg2e {
namespace base {
MatrixState::MatrixState()
{
}
MatrixState::~MatrixState() {
}
void MatrixState::beginFrame() {
_projectionMatrixStack.beginFrame();
_viewMatrixStack.beginFrame();
_modelMatrixStack.beginFrame();
}
}
}
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: RasterMod
FILE: nimbusChars.asm
AUTHOR: Gene Anderson
REVISION HISTORY:
Name Date Description
---- ---- -----------
Gene 11/3/89 Initial revision
DESCRIPTION:
This file contains routines for generating individual characters.
$Id: nimbusChars.asm,v 1.1 97/04/18 11:45:31 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusGenChar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Generate one character for a font.
CALLED BY: VidBuildChar (via NimbusStrategy)
PASS: dx - character to build (Chars)
es - seg addr of font (locked)
bp - seg addr of gstate (locked)
GS_fontHandle - handle of font
GS_fontAttr - font attributes
ds - seg addr of font info block
RETURN: es - seg addr of font (locked) (may have changed)
carry - clear
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 11/ 7/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusGenChar proc far
uses ax, bx, cx, dx, ds, si, di, bp
.enter
mov di, 400
call ThreadBorrowStackSpace
push di
EC < tst dh ;>
EC < ERROR_NZ CANNOT_USE_DOUBLE_BYTE_CHARS_IN_THIS_VERSION ;>
call CharSetup ;setup routines, vars
push dx ;save character to build
push di ;save ptr to CharGenData
call FindCharPtr ;find ptr to character
call ds:GenRouts.CGR_make_rout ;call MakeChar() routine
pop di ;di <- ptr to CharGenData
pop dx ;dl <- character built
call ds:GenRouts.CGR_resize_rout ;call routine to resize font
mov ax, segment udata
mov ds, ax ;ax <- seg addr of idata
mov bx, ds:bitmapHandle ;bx <- handle of bitmap
call MemUnlock ;unlock bitmap block
mov bx, ds:variableHandle ;bx <- handle of vars
call MemUnlock ;unlock variable block
pop di
call ThreadReturnStackSpace
.leave
clc ;indicate no error
ret
NimbusGenChar endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FindCharPtr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Find ptr to individual character data
CALLED BY: INTERNAL: NimbusGenChar
PASS: dl - character (Chars)
ds - seg addr of NimbusVars
gstateSegment - seg addr of GState
infoSegment - seg addr of font info block
firstChar - first character in font
RETURN: es:di - ptr to character data
cx - handle of outline data
DESTROYED: none
PSEUDO CODE/STRATEGY:
Calls LoadOutlineData which finds the outline data
with the largest subset of styles built in. The
styles to implement that are returned is the set of
styles that is not implied by the outline data.
(eg. italic returned when making bold-italic from bold data)
KNOWN BUGS/SIDE EFFECTS/IDEAS:
ASSUMES the cutoff point for characters is 0x80
(as does nim2pc)
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 11/13/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FindCharPtr proc near
uses ax, bx, dx, ds
.enter
mov al, dl
EC < call ECCheckFirstChar ;>
sub al, ds:firstChar ;al <- char index, 1st half
SBCS < mov bx, ODF_PART1 ;bx <- flag: first half >
DBCS < mov bx, offset NOED_part1 ;bx <- flag: first half >
cmp dl, NIMBUS_CHAR_MIDPOINT ;see if in second half
jb firstHalf ;branch if in first half
sub dl, NIMBUS_CHAR_MIDPOINT
mov al, dl ;al <- char index, 2nd half
SBCS < mov bx, ODF_PART2 ;bx <- flag: second half>
DBCS < mov bx, offset NOED_part2 ;bx <- flag: second half>
firstHalf:
clr ah
mov di, ax ;di <- char index
push ds
EC < call ECCheckGStateSegment ;>
mov ds, ds:gstateSegment ;ds <- seg addr of gstate
mov cx, ds:GS_fontAttr.FCA_fontID ;cx <- font ID
mov al, ds:GS_fontAttr.FCA_textStyle
pop ds
mov ds, ds:infoSegment ;ds <- seg addr of info block
EC < call ECCheckInfoSegment ;>
call LoadOutlineData ;es == seg addr of odata
shl di, 1 ;*2 for words
mov di, es:[di] ;di <- ptr to char data
.leave
ret
FindCharPtr endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CharSetup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Setup routines, data for calling makechar()
CALLED BY: NimbusGenChar
PASS: es - seg addr of font
ds - seg addr of info block
bp - seg addr of GState
RETURN: ds - seg addr of vars
fontSegment - seg addr of font
fontHandle - handle of font
gstateSegment - seg addr of GState
infoSegment - seg addr of font info block
es:di - ptr to CharGenData for font
DESTROYED: ax, bx, cx, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/ 7/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CharSetup proc near
uses es
.enter
push ds ;save seg addr of info block
push es ;save seg addr of font
SBCS < mov ah, es:FB_firstChar >
DBCS < mov ah, {byte}es:FB_firstChar >
SBCS < mov al, es:FB_lastChar >
DBCS < mov al, {byte}es:FB_lastChar >
push ax
sub al, ah
clr ah ;ax <- # of chars - 1
if DBCS_PCGEOS
.assert (size CharTableEntry eq 6)
shl ax, 1 ;*2
mov si, ax
shl ax, 1 ;*4
add ax, si ;*6
else
.assert (size CharTableEntry eq 8)
shl ax, 1
shl ax, 1
shl ax, 1 ;*8 for each CharTableEntry
endif
add ax, size FontBuf ;skip font header
mov si, ax
push ax ;store offset to GenData
segmov ds, es ;ds <- seg addr of font
call LockNimbusVars ;ax <- seg addr, bx <- handle
mov es, ax ;es <- NimbusVars seg
mov cx, size CharGenData ;cx <- # of bytes to mov
mov di, offset GenData ;es:di <- ptr to dest
rep movsb ;copy me jesus
mov cx, size CharGenRouts / 2
segmov ds, cs
mov si, es:GenData.CGD_routs ;ds:si <- ptr to routine table
mov di, offset GenRouts ;es:di <- ptr to dest
rep movsw ;copy me jesus
pop di ;di <- offset of CharGenData
mov ds, ax ;ds <- seg addr of vars
pop ax ;ah <- first char, al <- last
mov ds:firstChar, ah ;store first char
pop ds:fontSegment ;store seg addr of font
pop ds:infoSegment ;store seg addr of info block
mov ds:gstateSegment, bp ;store gstate segment
mov es, bp
mov bx, es:GS_fontHandle ;bx <- handle of font
mov ds:fontHandle, bx ;store font handle
EC < call ECCheckFontHandle ;>
EC < call ECCheckFontSegment ;>
EC < call ECCheckGStateSegment ;>
EC < call ECCheckInfoSegment ;>
EC < call ECCheckFirstChar ;>
.leave
ret
CharSetup endp
NimbusBitmapRouts CharGenRouts <
offset BMapBits,
offset SetBit,
offset BitmapAlloc,
offset MakeChar,
offset CopyCharResize
>
NimbusRegionRouts CharGenRouts <
offset SetPointInRegion,
offset SetBitInRegion,
offset RegionAlloc,
offset MakeChar,
offset CopyRegionResize
>
UnhintedRouts CharGenRouts <
offset SetPointInRegion,
offset SetBitInRegion,
offset RegionAlloc,
offset MakeBigChar,
offset CopyRegionResize
>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LockNimbusVars
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Lock the NimbusVars block
CALLED BY: CharSetup(), NimbusGenInRegion()
PASS: nothing
RETURN: ax - NimbusVars segment
bx - NimbusVars handle
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/ 7/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LockNimbusVarsFar proc far
call LockNimbusVars
ret
LockNimbusVarsFar endp
LockNimbusVars proc near
uses ds
.enter
mov ax, segment udata
mov ds, ax ;ds <- seg addr of idata
mov bx, ds:variableHandle ;bx <- handle of vars
call MemLock
jnc done ;branch if still in memory
push cx
mov ax, size NimbusVars ;ax <- size of block
mov ch, mask HAF_NO_ERR or mask HAF_LOCK ;ch <- HeapAllocFlags
call MemReAlloc ;reallocate variable block
EC < call ECNukeVariableBlock ;>
pop cx
done:
.leave
ret
LockNimbusVars endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CopyCharResize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Resize the font as necessary and add the char to it.
CALLED BY: INTERNAL: NimbusGenChar
PASS: ds - seg addr of vars
fontSegment - seg addr of font
fontHandle - handle of font
gstateSegment - seg addr of GState
infoSegment - seg addr of font info block
ds:guano - bitmap (NimbusBitmap)
dl - character index (not number)
di - offset of CharGenData
RETURN: es - seg addr of font (may have changed)
DESTROYED: ax, cx, dx, si, di, ds
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should scan the bitmap to see where the data
actually starts and ends, at least for rotated characters,
because rotated characters can have a fair amount of white
space left. Draw a 'P' and its bounding box rotated
-45 degrees to see what I mean.
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 11/14/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CopyCharResize proc near
.enter
EC < call ECCheckFontSegment ;>
mov es, ds:fontSegment ;es <- seg addr of font
SBCS < sub dl, es:FB_firstChar ;dl <- char index >
DBCS < sub dl, {byte}es:FB_firstChar ;dl <- char index >
clr dh
mov si, dx ;si <- char index
if DBCS_PCGEOS
.assert (size CharTableEntry eq 6)
shl si, 1 ;*2
shl si, 1 ;*4
add si, dx ;*5
add si, dx ;*6
else
.assert (size CharTableEntry eq 8)
shl si, 1 ;*8 for each CTE
shl si, 1
shl si, 1 ;si <- offset of CharTableEntry
endif
EC < cmp es:FB_charTable[si].CTE_dataOffset, CHAR_NOT_BUILT >
EC < ERROR_NZ FONT_BAD_CHAR_FLAG >
push ds:guano.NB_lox ;save left edge
push ds:guano.NB_hiy ;save baseline offset
push ds:guano.NB_width ;save width
mov ax, ds:guano.NB_height ;ax <- height of bitmap
push ax ;save height
mov cx, ds:guano.NB_bytesperline ;cx <- width of bitmap (bytes)
EC < tst ch ;>
EC < ERROR_NZ FONT_CHAR_TOO_BIG ;>
EC < tst ah ;>
EC < ERROR_NZ FONT_CHAR_TOO_BIG ;>
mul cl ;ax <- width * height
push ax ;save size of bitmap
add ax, SIZE_CHAR_HEADER ;add space for header
call ResizeFont ;resize me jesus
pop cx ;cx <- size of bitmap (bytes)
pop ax ;ax <- height of bitmap
mov es:[si].CD_numRows, al
pop ax ;ax <- width of bitmap
mov es:[si].CD_pictureWidth, al
pop bx ;bx <- baseline offset
mov ax, es:[di].CGD_heightY ;ax <- scaled baseline for font
add ax, es:[di].CGD_scriptY ;add any offset for super/sub
sub ax, bx ;ax <- offset to top of bitmap
mov es:[si].CD_yoff, al
pop ax ;ax <- offset to left edge
mov bx, es:[di].CGD_heightX
add bx, es:[di].CGD_scriptX
add ax, bx
mov es:[si].CD_xoff, al
mov ds, ds:guano.NB_segment ;ds <- seg addr of bitmap
mov di, si
clr si ;ds:si <- ptr to bitmap
add di, CD_data ;es:di <- ptr to our data
rep movsb
EC < cmp di, es:FB_dataSize ;>
EC < ERROR_NZ OVERDOSE ;>
.leave
ret
CopyCharResize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResizeFont
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Resize a font, deleting characters if necessary.
CALLED BY: CopyCharResize, CopyRegionResize
PASS: es - seg addr of font
ax - size of character to add (including header)
di - offset of CharTableEntry for character
ds - seg addr of NimbusVars
ds:fontHandle - handle of font block
RETURN: es - seg addr of font (may have changed)
es:FB_dataSize - updated
es:si - ptr to space for character
DESTROYED: cx, dx, ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 3/ 9/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResizeFont proc near
uses ds
.enter
EC < call ECCheckFontHandle ;>
mov bx, ds:fontHandle ;bx <- handle of font
segmov ds, es, cx
mov cx, ds:FB_dataSize ;cx <- current size of font
mov dx, cx
add dx, ax ;add char size to current
cmp dx, MAX_FONT_SIZE ;see if font too big
jbe sizeOK ;branch if OK
call FontDrDeleteLRUChar ;shrink me jesus
mov cx, ds:FB_dataSize ;cx <- new size of font
sizeOK:
mov ds:FB_charTable[si].CTE_dataOffset, cx
mov si, cx ;si <- offset of new char
add ax, cx ;ax <- new size of font
mov ds:FB_dataSize, ax ;store new size
mov ch, HAF_STANDARD_NO_ERR ;ch <- HeapAllocFlags
call MemReAlloc ;add space for new char
mov es, ax ;es <- seg addr of font
.leave
ret
ResizeFont endp
|
;*
;* COW : Character Oriented Windows
;*
;* gwinterf.asm : Global memory allocator - Windows interface procs
.xlist
include kernel.inc
include galloc.inc
.list
IFDEF DEBUG
CheckHeap MACRO n
local ok
cmp fCheckCwHeap,0
je ok
cCall CheckGlobalHeap
or ax,ax
jz ok
push ax
push dx
cCall <far ptr PrintGlobalHeap> ;*!! look at heap on exit
pop dx
pop ax ;* restore ax to see why we died
cCall CowAssertFailed
DB "&n"
DB ":invalid global heap$"
ok:
ENDM
ELSE
CheckHeap MACRO n
ENDM
ENDIF
sBegin DATA
externW <hGlobalHeap,pGlobalHeap>
IFNDEF NOPCODE
externW <$q_mpsnq> ;* HandleTable - 2
ENDIF ;!NOPCODE
IFDEF DEBUG
staticB szThunkFormat, <"Thunk %x: sf=%x, ow=%x, sz=%x, nx=%x",0dh,0ah,0>
globalB fCheckCwHeap,1
ENDIF ;DEBUG
IFDEF WINDOWS_OLD_APP
externW <fWoaPresent>
ENDIF ; WINDOWS_OLD_APP
IFDEF DUAL
IFDEF DEBUG
externW fProtectMode
ENDIF ;DEBUG
ENDIF ;DUAL
sEnd DATA
IFDEF WINDOWS_OLD_APP
externFP <WoaRelease> ;* User supplied
ENDIF ; WINDOWS_OLD_APP
IFDEF DEBUG
externFPublic <_dprintf> ;* in assertsw.c
ENDIF ;DEBUG
sBegin KERNEL
assumes CS,KERNEL
assumes DS,NOTHING ;* DS usually points to MOB
assumes SS,DATA ;* get variables from here
externNP <PatchStackMoved, PatchStackDiscarded>
externNP <PatchThunkMoved, PatchThunkDiscarded> ;* ldthunk.asm
IFDEF DEBUG
externNP <CheckGlobalHeap> ;* lddebug.asm
ENDIF ;DEBUG
IFDEF KEEP_SYMDEB_CODE
externNP <DebugMovedSegment, DebugFreeSegment> ;* lddebug.asm
ENDIF ; KEEP_SYMDEB_CODE
;* * low level subroutines
externNP <galloc,grealloc> ; GMEM.ASM
externNP <gfree> ; GMEM.ASM
externNP <gdref,ghandle,galign> ; GMEM.ASM
externNP <gfindfree> ; GALLOC.ASM
externNP <gcompact> ; GCOMPACT.ASM
externNP <halloc,hthread> ; HANDLE.ASM
PUBLIC genter
PUBLIC gnotify
PUBLIC ghexpand
PUBLIC xhandle
IFDEF DEBPUB
PUBLIC gavail, gbtop
PUBLIC gmemfail, gmemcheck
ENDIF ;DEBPUB
SUBRS PROC NEAR
; Subroutine to enter a critical region for the global heap.
;
; Output: DS:DI = address of GlobalInfo for global heap
;* * NOTE : gi_lrulock is not needed due to simplified LRU
;* * and accordingly gleave is not needed !
;
genter:
mov ds,pGlobalHeap
xor di,di
ret
; Subroutine to convert a 32-bit byte count to a 16-bit paragraph count.
;
; Inputs: AX = allocation flags or -1 if called from GlobalCompact
; BX = stack address of 32-bit unsigned integer
; DX = handle being reallocated or zero
; DS:DI = address of GlobalInfo for global heap
;
; Outputs: AX = updated allocation flags
; BX = #paragraphs needed to contain that many bytes
; CX = owner value to use
; DX = handle being reallocated or zero
;
gbtop:
push dx
mov dx,ss:[bx+2]
mov bx,ss:[bx]
mov cx,4
add bx,15
adc dx,0
jnc gbtop1
dec dx
dec bx
gbtop1:
shr dx,1
rcr bx,1
loop gbtop1
pop dx
inc ax
jz gbtopx ; All done if called from GlobalCompact
dec ax
mov [di].gi_cmpflags,al ; Save flags for gcompact
test dl,GA_FIXED ; Are we reallocating a fixed handle?
jnz gbtop4 ; Yes, then go allocate low
or dx,dx ; Reallocating a moveable handle?
jnz gbtop3a ; Yes, allocate high
test al,GA_MOVEABLE ; Is this a moveable request?
jz gbtop4 ; No, then go allocate low
gbtop3a:
or al,GA_ALLOCHIGH ; Yes, allocate high
cmp [di].gi_reserve,di ; Reserve area for code?
je gbtop4 ; No, all moveable allocated high
test al,GA_DISCCODE ; Yes, is this discardable code?
jnz gbtop4 ; Yes, then allocate high
xor al,GA_ALLOCHIGH ; No, then allocate low
gbtop4:
test ah,HE_DISCARDABLE ; Discard level?
jz gbtop4a
and ah,not HE_DISCARDABLE ; Yes, convert to boolean value
or ah,GA_DISCARDABLE
gbtop4a:
mov cl,GA_SEGTYPE ; Copy segment type bits to handle
and cl,al
or ah,cl ; table flags
;* * Figure out the owner field
or dx,dx ;* reallocating ?
mov cx,ownerData ;* owner for all global data
jz gbtopx ;* new block => global data
;* * use the old owner field
xchg dx,si
mov cx,[si].he_address ;* owner or ps
test [si].he_flags,HE_DISCARDED
jnz owner_discarded ;* owner in cx
;* * we must get ga_owner field from resident block
mov es,cx
mov cx,es:[di].ga_owner ;* old owner field
owner_discarded:
xchg dx,si ;* restore si/dx
gbtopx:
ret
; Subroutine to get the available memory.
;
gavail:
mov byte ptr [di].gi_cmpflags,0
call gcompact
or dx,dx
jz gavail1
jmp gcsize
gavail1:
push dx ; No max yet
mov es,[di].hi_first
gcstat:
cmp es:[di].ga_sig,GA_ENDSIG ; Last block?
je gcstat3 ; Yes all done
mov es,es:[di].ga_next ; Next block
cmp es:[di].ga_owner,di ; Free?
je gcstat0 ; Yes
mov si,es:[di].ga_handle
or si,si ; Fixed?
jz gcstat ; Yes, next block
cmp [si].he_count,0 ; Locked?
jne gcstat ; Yes, next block
test [si].he_flags,GA_DISCARDABLE ; Discardable?
jz gcstat ; No, next block
test es:[di].ga_flags,GA_DISCCODE; No, discardable code?
jnz gcstat ; Yes, next block
gcstat0:
push es ; Save starting point
mov ax,es:[di].ga_size ; Use this size
mov cx,[di].hi_count
gcstat0a:
mov es,es:[di].ga_next ; Next block
cmp es:[di].ga_owner,di ; Free?
je gcstat1 ; Yes, include size
cmp es:[di].ga_sig,GA_ENDSIG ; End of arena?
je gcstat0b ; Yes, handle reserve area
mov si,es:[di].ga_handle
or si,si ; Fixed?
jz gcstat2 ; Yes, stop looking
cmp [si].he_count,0 ; Locked?
jne gcstat2 ; Yes, stop looking
test [si].he_flags,GA_DISCARDABLE ; Discardable?
jz gcstat1a ; No, dont include in count then
test es:[di].ga_flags,GA_DISCCODE; Yes, discardable code?
jz gcstat1 ; No, include in count then
gcstat0b:
mov si,es ; Yes, see if we are trying
sub si,[di].hi_last ; to steal some of the reserve area
neg si
sub si,[di].gi_reserve
inc ax ; add in one arena header
add ax,si ; Adjust amount by reserve area
jz gcstat2
dec ax ; remove one arena header
jmp short gcstat2
gcstat1: ; Free or Discardable
add ax,es:[di].ga_size ; Increase availabe space
inc ax ; by size of this block
gcstat1a: ; Moveable
loop gcstat0a
gcstat2:
pop es ; Back to starting point
cmp ax,dx ; Did we find a bigger block?
jbe gcstat ; No, then look again
mov dx,ax ; Yes, remember size
pop ax
push es ; ...and block
jmp gcstat
gcstat3:
pop es
mov ax,dx
gcsize:
or ax,ax ; zero mem available?
jz gcfinal ; yes, return 0
dec ax ; Dont be too exact
jz gcfinal
dec ax
gcfinal:
and al,GA_MASK ; round down to nearest alignment
xor dx,dx
ret
;********** gnotify **********
; Subroutine to update all info if a global object moved / discarded
;
; Inputs: AL = message code (GN_MOVE, GN_DISCARD)
; BX = handle
; CX = optional argument (new ps, discard flags)
;* DX = original owner field
;* DS = pGlobalHeap
;
; Outputs: n/a
;
; Destroys: AX,BX,CX,DX,ES
;
gnotify:
IFDEF DEBUG
;* * Test for valid owner
or dh,dh
jz ok_notify_owner ;* code segment
cmp dx,ownerData
jz ok_notify_owner ;* data segment
cmp dx,-1
jz ok_notify_owner ;* master object
bad_notify_owner:
cCall CowAssertFailed
DB "gnotify : bad owner$"
ok_notify_owner:
ENDIF ;DEBUG
xor ah,ah
push si
push di
IFNDEF NOPCODE
Save <ax,bx,cx,dx>
cCall FixHandleTable
ENDIF ;NOPCODE
mov di,cx ;* di = new ps / discard flags
mov cx,dx ;* cx = owner
AssertReset bl,GA_FIXED ;* MUST BE MOVEABLE
;* never discard FIXED objects
mov si,[bx].he_address
AssertNe si,0 ;* the old block must exist
Assert <GN_MOVE EQ 1>
dec ax
jnz notify_discard
;* * MOVING :
AssertNe di,0 ;* di = new destination ps
mov [bx].he_address,di ;* update handle address
IFDEF KEEP_SYMDEB_CODE
Save <cx>
cCall DebugMovedSegment,<si,di>
ENDIF ; KEEP_SYMDEB_CODE
;* * Test to see if we moved a code segment
or ch,ch ;* upper byte zero for CODE
jnz notify_move_data
;* * moving code
Save <cx>
cCall PatchThunkMoved,<cx,di>
cCall PatchStackMoved,<cx,si,di>
jmp short notify_exit
notify_move_data:
;* * Test to see if MOB moved
mov ax,ds
cmp ax,si ; Did we move DS?
jne notify_exit ; No, continue
;* * We have moved the Master Object
push di ; update DS pointer.
pop ds
mov pGlobalHeap,ds ;* and the master object pointer
jmp short notify_exit
notify_discard:
Assert <GN_DISCARD EQ 2>
AssertEq ax,1
;* * DISCARDING :
mov [bx].he_address,0 ;* discarded
IFDEF KEEP_SYMDEB_CODE
Save <cx>
cCall DebugFreeSegment,<si>
ENDIF ; KEEP_SYMDEB_CODE
or ch,ch ;* upper byte zero for CODE
jnz notify_exit ;* discarding data
;* * Discarding code
Save <cx>
cCall PatchThunkDiscarded,<cx>
cCall PatchStackDiscarded,<cx,si>
notify_exit:
pop di
pop si
ret
; Procedure to expand a global handle table
;
; Inputs: CX = #handle table entries to expand the table by
; DS:DI global info structure
;
; Outputs: AX = address of handle table block of requested size
;
; Destroys: ES,BX,CX,DX
;
ghexpand:
mov ax,ds
push cx
call ghandle
pop cx
jz ghfail
mov dx,ax
xor ax,ax
mov bx,DS:[di].hi_htable
mov bx,DS:[bx].ht_count
inc bx
add bx,cx
shl bx,1
shl bx,1
add bx,DS:[di].hi_htable
jc ghfail
add bx,15
jc ghfail
mov cl,4
shr bx,cl
; Dont allow master object into reserve swap area
and byte ptr [di].gi_cmpflags,not GA_DISCCODE
call grealloc
jcxz ghfail
mov dx,ax
call gdref
jz ghfail
mov bx,ES:[di].ga_size
mov cl,4
shl bx,cl
sub bx,HE_ALIGN
and bl,HE_MASK
sub bx,DS:[di].hi_htable
mov cl,2
shr bx,cl
mov ax,bx
mov bx,DS:[di].hi_htable
mov cx,ax
xchg DS:[bx].ht_count,ax
sub cx,ax
inc bx
inc bx
shl ax,1
shl ax,1
add bx,ax
xchg bx,di
call hthread
mov DS:[di],cx
mov di,bx
mov cx,ax
ret
ghfail:
xor cx,cx
ret
gmemcheck:
or ax,ax
jz gmemfail
ret
gmemfail:
ret
SUBRS ENDP
IFNDEF NOPCODE
;********** FixHandleTable **********
; Inputs: AL = message code (GN_MOVE, GN_DISCARD)
; BX = handle
; CX = optional argument (new ps, discard flags)
;* DS = pGlobalHeap
;* * Fix Handle Table
;* exit : n/a - Trashes AX,BX,CX,DX,DI,ES
cProc FixHandleTable,<NEAR,ATOMIC>
cBegin FixHandleTable
;* * find new address
cmp al,GN_MOVE
je move_in_handle_table
xor cx,cx ;* new ps is 0
move_in_handle_table:
mov ax,ss
mov es,ax ;* set ES to DDS
;* * find old address
mov ax,ds:[bx].he_address
;* * set up for test : ax = old ps, cx = new ps
mov dx,cx ;* dx = psNew
mov di,dataOffset $q_mpsnq
mov cx,DGROUP:[DI-4] ;* count of entries
;* * scan till old value matched
cld
fix_ht_loop:
jcxz fix_ht_end
repne scasw
jne fix_ht_end
mov es:[di-2],dx
jmp fix_ht_loop
fix_ht_end:
cEnd FixHandleTable
ENDIF ;!NOPCODE
;*****************************************************************************
; The remainder of this file implements the exported interface to the
; global memory manager.
;
; DWORD far PASCAL GlobalSize( HANDLE );
; HANDLE far PASCAL GlobalAlloc( WORD, DWORD );
; HANDLE far PASCAL GlobalReAlloc( HANDLE, DWORD, WORD );
; HANDLE far PASCAL GlobalFree( HANDLE );
; DWORD far PASCAL GlobalCompact( DWORD );
; #define GlobalDiscard( h ) GlobalReAlloc( h, 0L, GMEM_MOVEABLE )
; HANDLE far PASCAL GlobalHandle( WORD );
;
;
; Procedure return the handle for a global segment.
;
; Inputs: Stack = sp -> near return return address of ghandle
; sp+2 -> far return return address of caller
; sp+6 -> segment address parameter
;
; Outputs: AX = handle or zero if invalid segment address
; Old DS,DI have been pushed on the stack
; Z flag set if invalid or fixed segment. O.W. Z flag
; reset and BX = pointer to handle table entry
; CX = flags and count word from handle table
; DX = segment address
; ES:DI = arena header of object
; DS:DI = master object segment address
;
;
;
xhandle PROC NEAR
pop dx ; Get near return address
mov bx,sp ; Get seg parameter from stack
mov ax,SS:[bx+4]
inc ax ; Is it -1?
jz xh2 ; Yes, handle special
dec ax ; No, restore AX
xh1:
push ds ; Save DS:DI
push di
mov ds,pGlobalHeap ; Point to master object
xor di,di
inc ds:[di].gi_lrulock
push dx ; Call ghandle and return
jmp ghandle ; to our caller directly
xh2:
mov ax,ds ; If passed -1 use callers DS
jmp xh1
xhandle ENDP
cPublic GlobalHandle
; parmW seg
cBegin nogen
gh0:
call xhandle
xhandlex:
dec ds:[di].gi_lrulock
pop di
pop ds
ret 2
cEnd nogen ;GlobalHandle
cPublic GlobalSize
; parmW h
cBegin nogen
call xhandle ; Call ghandle with handle in DX
or dx,dx ; Did we get a segment address?
jz xhandlex ; No, all done then
mov ax,ES:[di].ga_size ; Yes, get size in paragraphs
push ax
xor dx,dx ; Returning a long result
mov cx,4
gs2:
shl ax,1
rcl dx,1
loop gs2
pop cx ; Return number paragraphs in CX
jmp short xhandlex
cEnd nogen ;GlobalSize
cPublic GlobalAlloc,<>,<ds,si,di>
parmW flags
parmD nbytes
cBegin
CheckHeap GlobalAlloc
IFDEF WINDOWS_OLD_APP
cmp fWoaPresent,0
jz GA10
xor ax,ax
cCall WoaRelease,<nbytes,ax>
GA10:
ENDIF ; WINDOWS_OLD_APP
; EnterCrit
call genter ; About to modify memory arena
xor dx,dx ; No handle
mov ax,flags ; Allocate space for object
lea bx,nbytes ; Convert requested bytes to paragraphs
call gbtop ; ... into BX
call galloc
call gmemcheck
cEnd GlobalAlloc
cPublic GlobalReAlloc,<>,<ds,si,di>
parmW h
parmD nbytes
parmW rflags
cBegin
CheckHeap GlobalReAlloc
IFDEF WINDOWS_OLD_APP
cmp fWoaPresent,0
jz GR10
cCall GlobalSize,<h>
sub ax, WORD PTR (nbytes)
sbb dx, WORD PTR (nbytes+2)
jnc GR10
xor ax,ax
cCall WoaRelease,<nbytes,ax>
GR10:
ENDIF ; WINDOWS_OLD_APP
; EnterCrit
call genter ; About to modify memory arena
mov dx,h
mov ax,rflags
lea bx,nbytes ; Convert requested bytes to paragraphs
call gbtop ; ... into BX
call grealloc ; Reallocate global object
call gmemcheck
cEnd GlobalReAlloc
cPublic GlobalFree,<>,<ds,si,di>
parmW h
cBegin
CheckHeap GlobalFree
; EnterCrit
call genter ; About to modify memory arena
IFDEF DEBUG
mov dx,h
call gdref
or si,si
jz free_ok
cmp ch,00h ; Debugging check for count underflow
je free_ok
cCall CowAssertFailed
DB "GlobalFree: freeing locked object$"
free_ok:
ENDIF ;DEBUG
mov dx,h ; Free handle
xor cx,cx ; Dont check owner field
call gfree
cEnd GlobalFree
cPublic GlobalCompact,<>,<ds,si,di>
parmD minBytes
cBegin
IFDEF DUAL
IFDEF DEBUG
mov cx,fProtectMode ; real mode only!
jcxz @F
BREAKPOINT ; m3 would call cowassertfaileddos3
@@:
ENDIF
ENDIF
CheckHeap GlobalCompact
; EnterCrit
call genter ; About to modify memory arena
mov ax,-1
lea bx,minBytes
call gbtop
clc ; galign should be called with carry clear
call galign
call gavail ; Returns paragraphs in DX:AX
mov cx,4 ; Convert paragraphs to bytes
push ax
gcsize1:
shl ax,1
rcl dx,1
loop gcsize1
pop cx ; let caller to jcxz to test failure
cEnd GlobalCompact
;*****************************************************************************
;* Debug support
IFDEF DEBUG
;********** PrintGlobalHeap **********
;* entry : n/a
;* * print the contents of the global heap
;* exit : n/a
;* * NOTE : this code must be fixed since it throws everything out.
cProc PrintGlobalHeap, <FAR, PUBLIC, ATOMIC>, <DS,ES,SI,DI,AX,BX,CX,DX>
cBegin PrintGlobalHeap
mov ax,DGROUP
mov ds,ax
assumes DS,DGROUP
;* * compact the heap (removing any free gaps) -- throw out code as well
mov es,pGlobalHeap
xor di,di
mov es,es:[di].hi_first ;* es => first block.
;* * scan from end till finding free block
Print_next_thunk:
xor ah,ah ;get all pieces to print.
mov al,es:[di].ga_sig ; Put sig with flags
mov ah,es:[di].ga_flags
mov bx,es:[di].ga_owner
mov cx,es:[di].ga_size
mov dx,es:[di].ga_next ;
mov si,offset dgroup:szThunkFormat
push es
?PLM = 0
cCall dprintf, <si,es,ax,bx,cx,dx>
?PLM = 1
pop es
mov ax,es
cmp ax,dx ;see if at end of list
jz end_print ; yes lets get out
mov es,dx ; no move to segment
jmp Print_next_thunk
end_print:
cEnd PrintGlobalHeap
ENDIF ;DEBUG
;*****************************************************************************
sEnd KERNEL
END
|
object_const_def ; object_event constants
const ECRUTEAKCITY_GRAMPS1
const ECRUTEAKCITY_GRAMPS2
const ECRUTEAKCITY_LASS1
const ECRUTEAKCITY_LASS2
const ECRUTEAKCITY_FISHER
const ECRUTEAKCITY_YOUNGSTER
const ECRUTEAKCITY_GRAMPS3
EcruteakCity_MapScripts:
db 0 ; scene scripts
db 1 ; callbacks
callback MAPCALLBACK_NEWMAP, .FlyPoint
.FlyPoint:
setflag ENGINE_FLYPOINT_ECRUTEAK
return
EcruteakCityGramps1Script:
jumptextfaceplayer EcruteakCityGramps1Text
EcruteakCityGramps2Script:
jumptextfaceplayer EcruteakCityGramps2Text
EcruteakCityGramps3Script:
jumptextfaceplayer EcruteakCityGramps3Text
EcruteakCityLass1Script:
jumptextfaceplayer EcruteakCityLass1Text
EcruteakCityLass2Script:
faceplayer
opentext
checkevent EVENT_RELEASED_THE_BEASTS
iftrue .ReleasedBeasts
writetext EcruteakCityLass2Text
waitbutton
closetext
end
.ReleasedBeasts:
writetext EcruteakCityLass2Text_ReleasedBeasts
waitbutton
closetext
end
EcruteakCityFisherScript:
faceplayer
opentext
checkevent EVENT_JASMINE_RETURNED_TO_GYM
iftrue .JasmineReturned
writetext EcruteakCityFisherText
waitbutton
closetext
end
.JasmineReturned:
writetext EcruteakCityFisherText_JasmineReturned
waitbutton
closetext
end
EcruteakCityYoungsterScript:
jumptextfaceplayer EcruteakCityYoungsterText
EcruteakCitySign:
jumptext EcruteakCitySignText
TinTowerSign:
jumptext TinTowerSignText
EcruteakGymSign:
jumptext EcruteakGymSignText
EcruteakDanceTheaterSign:
jumptext EcruteakDanceTheaterSignText
BurnedTowerSign:
jumptext BurnedTowerSignText
EcruteakCityPokecenterSign:
jumpstd pokecentersign
EcruteakCityMartSign:
jumpstd martsign
EcruteakCityHiddenHyperPotion:
hiddenitem HYPER_POTION, EVENT_ECRUTEAK_CITY_HIDDEN_HYPER_POTION
UnusedMissingDaughterText:
; unused
text "Oh, no. Oh, no…"
para "My daughter is"
line "missing."
para "No… She couldn't"
line "have gone to the"
cont "BURNED TOWER."
para "I told her not to"
line "go near it…"
para "People seem to"
line "disappear there…"
para "Oh, what should I"
line "do…?"
done
EcruteakCityGramps1Text:
text "ECRUTEAK used to"
line "have two towers:"
para "one each in the"
line "east and west."
done
EcruteakCityGramps2Text:
text "Ah, child."
line "Have you learned"
para "to dance like the"
line "KIMONO GIRLS?"
para "If you go to their"
line "DANCE THEATER, an"
para "odd old man will"
line "give you something"
cont "nice, I hear."
done
EcruteakCityLass1Text:
text "I'm going to prac-"
line "tice at the DANCE"
para "THEATER. Care to"
line "join me?"
done
EcruteakCityLass2Text:
text "The tower that"
line "used to be here…"
para "My grandma told me"
line "it used to be much"
cont "taller."
done
EcruteakCityLass2Text_ReleasedBeasts:
text "Three big #MON"
line "ran off in differ-"
cont "ent directions."
cont "What were they?"
done
EcruteakCityFisherText:
text "I heard a rumor"
line "about OLIVINE"
cont "LIGHTHOUSE."
para "The #MON that"
line "serves as the"
para "beacon fell ill."
line "Sounds like they"
cont "are in trouble."
done
EcruteakCityFisherText_JasmineReturned:
text "The #MON at"
line "OLIVINE LIGHTHOUSE"
cont "has been cured."
para "Boats can safely"
line "sail out to sea at"
cont "night again."
done
EcruteakCityYoungsterText:
text "I hear #MON are"
line "rampaging at the"
para "LAKE OF RAGE. I'd"
line "like to see that."
done
EcruteakCityGramps3Text:
text "In the distant"
line "past…"
para "This tower burned"
line "in a fire. Three"
para "nameless #MON"
line "perished in it."
para "A rainbow-colored"
line "#MON descended"
para "from the sky and"
line "resurrected them…"
para "It's a legend that"
line "has been passed"
para "down by ECRUTEAK"
line "GYM LEADERS."
para "Me?"
para "I was a trainer"
line "way back when."
cont "Hohoho!"
done
EcruteakCitySignText:
text "ECRUTEAK CITY"
line "A Historical City"
para "Where the Past"
line "Meets the Present"
done
TinTowerSignText:
text "TIN TOWER"
para "A legendary #-"
line "MON is said to"
cont "roost here."
done
EcruteakGymSignText:
text "ECRUTEAK CITY"
line "#MON GYM"
cont "LEADER: MORTY"
para "The Mystic Seer of"
line "the Future"
done
EcruteakDanceTheaterSignText:
text "ECRUTEAK DANCE"
line "THEATER"
done
BurnedTowerSignText:
text "BURNED TOWER"
para "It was destroyed"
line "by a mysterious"
cont "fire."
para "Please stay away,"
line "as it is unsafe."
done
EcruteakCity_MapEvents:
db 0, 0 ; filler
db 15 ; warp events
warp_event 35, 26, ROUTE_42_ECRUTEAK_GATE, 1
warp_event 35, 27, ROUTE_42_ECRUTEAK_GATE, 2
warp_event 18, 11, ECRUTEAK_TIN_TOWER_ENTRANCE, 1
warp_event 20, 2, WISE_TRIOS_ROOM, 1
warp_event 20, 3, WISE_TRIOS_ROOM, 2
warp_event 23, 27, ECRUTEAK_POKECENTER_1F, 1
warp_event 5, 21, ECRUTEAK_LUGIA_SPEECH_HOUSE, 1
warp_event 23, 21, DANCE_THEATRE, 1
warp_event 29, 21, ECRUTEAK_MART, 2
warp_event 6, 27, ECRUTEAK_GYM, 1
warp_event 13, 27, ECRUTEAK_ITEMFINDER_HOUSE, 1
warp_event 37, 7, TIN_TOWER_1F, 1
warp_event 5, 5, BURNED_TOWER_1F, 1
warp_event 0, 18, ROUTE_38_ECRUTEAK_GATE, 3
warp_event 0, 19, ROUTE_38_ECRUTEAK_GATE, 4
db 0 ; coord events
db 8 ; bg events
bg_event 15, 21, BGEVENT_READ, EcruteakCitySign
bg_event 38, 10, BGEVENT_READ, TinTowerSign
bg_event 8, 28, BGEVENT_READ, EcruteakGymSign
bg_event 21, 21, BGEVENT_READ, EcruteakDanceTheaterSign
bg_event 2, 10, BGEVENT_READ, BurnedTowerSign
bg_event 24, 27, BGEVENT_READ, EcruteakCityPokecenterSign
bg_event 30, 21, BGEVENT_READ, EcruteakCityMartSign
bg_event 23, 14, BGEVENT_ITEM, EcruteakCityHiddenHyperPotion
db 7 ; object events
object_event 18, 15, SPRITE_GRAMPS, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakCityGramps1Script, -1
object_event 20, 21, SPRITE_GRAMPS, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakCityGramps2Script, -1
object_event 21, 29, SPRITE_LASS, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 2, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, EcruteakCityLass1Script, -1
object_event 3, 9, SPRITE_LASS, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakCityLass2Script, -1
object_event 9, 22, SPRITE_FISHER, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, EcruteakCityFisherScript, -1
object_event 10, 14, SPRITE_YOUNGSTER, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, EcruteakCityYoungsterScript, -1
object_event 3, 7, SPRITE_GRAMPS, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, EcruteakCityGramps3Script, EVENT_ECRUTEAK_CITY_GRAMPS
|
; **************************************
; *** ZoomTen's GameBoy Music Player ***
; *** Version 2.0 ***
; *** ***
; *** 2017-01-14 ***
; **************************************
; **************************************
; **** now with ARPEGGIOS! ***
; **** DUTY CYCLES! ***
; **** FANCY EFFECTS! ***
; **** MORE POSSIBILITIES! ***
; **** PRECISE TEMPO CONTROL! ***
; **************************************
; **************************************
; -----------------------------------------------------------
; Sound system
; -----------------------------------------------------------
UpdateMusic:
; Check if song started
ld a, [w_song_enabled]
and a
ret z ; Skip everything if SE stopped
; Increment timer
; A factor of $FF means original speed
ld a, [w_song_speed]
ld c, a
ld a, [w_song_timer]
add a, c
ld [w_song_timer], a
; If timer doesn't overflow do sound FX (arps, duty cycling) instead
; ret nc ; if slow down fx too
jr nc, .do_FX
.do_notes
; Parse notes
call Music_A_ParseNotes
call Music_B_ParseNotes
call Music_C_ParseNotes
call Music_D_ParseNotes
.do_FX
call Music_A_ApplyFX ; Then do instrument playback
call Music_B_ApplyFX
call Music_C_ApplyFX
call Music_D_Drums
.return
ret
; -----------------------------------------------------------
; The BULK™ wh
; -----------------------------------------------------------
include "src/sound/engine/engine.a.asm"
include "src/sound/engine/engine.b.asm"
include "src/sound/engine/engine.c.asm"
include "src/sound/engine/engine.d.asm"
; -----------------------------------------------------------
; Sound engine data
; -----------------------------------------------------------
; lookup tables
include "src/sound/tables/pitches.asm"
include "src/sound/tables/instruments.asm"
include "src/sound/tables/vibrato.asm"
include "src/sound/tables/waves.asm"
include "src/sound/tables/drums.asm"
|
; A135517: a(n) = 2^(A091090(n)-1).
; 1,1,1,2,1,2,1,4,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,16,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,16,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,32,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,16,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,32,1,2,1,4
mov $1,1
lpb $0
mul $1,2
add $2,1
add $0,$2
dif $0,2
lpe
mov $0,$1
|
.data
message: .asciiz "The numbers are equal."
message2: .asciiz "Nothing happened."
.text
main:
addi $t0, $zero, 20
addi $t1, $zero, 20
beq $t0, $t1, numbersEqual
# Syscall
li $v0, 10
syscall
numbersEqual:
li $v0, 4
la $a0, message
syscall |
###############################################################################
# File : jr.asm
# Project : MIPS32 MUX
# Author: : Grant Ayers (ayers@cs.stanford.edu)
#
# Standards/Formatting:
# MIPS gas, soft tab, 80 column
#
# Description:
# Test the functionality of the 'jr' instruction.
#
###############################################################################
.section .test, "x"
.balign 4
.set noreorder
.global test
.ent test
test:
lui $s0, 0xbfff # Load the base address 0xbffffff0
ori $s0, 0xfff0
ori $s1, $0, 1 # Prepare the 'done' status
#### Test code start ####
la $t0, $target
jr $t0
ori $v0, $0, 0 # The test result starts as a failure
$finish:
sw $v0, 8($s0)
sw $s1, 4($s0)
jr $ra
nop
j $finish # Early-by-1 detection
$target:
nop
ori $v0, $0, 1 # Set the result to pass
j $finish
nop
#### Test code end ####
.end test
|
/**
* Copyright (C) 2017 MongoDB 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 "mongo/util/net/cidr.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/platform/basic.h"
#ifdef _WIN32
#include <Ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#endif
using std::begin;
using std::find;
using std::end;
namespace mongo {
namespace {
constexpr std::uint8_t kIPv4Bits = 32;
constexpr std::uint8_t kIPv6Bits = 128;
#ifdef _WIN32
/**
* Windows doesn't declare the second arg as const, but it is.
* Also, it should blindly downcast to void*, but it doesn't.
*/
const char* inet_ntop(INT af, const std::uint8_t* addr, PSTR buf, std::size_t bufsz) {
return ::inet_ntop(af, const_cast<void*>(reinterpret_cast<const void*>(addr)), buf, bufsz);
}
#endif
/**
* `std::stoi()` naturally throws `std::invalid_argument` if str
* isn't numeric at all or `std::out_of_range` if str won't fit in an int.
*
* Extend that to include a check that the string is entirely numeric and throw
* `std::invalid_argument` for that as well
*/
int strict_stoi(const std::string& str, int base = 10) {
std::size_t pos;
auto len = std::stoi(str, &pos, base);
if (pos != str.size()) {
throw std::invalid_argument("Invalid characters encountered parsing: " + str + " at " +
str.substr(pos));
}
return len;
}
template <class T>
T& append(T& s, int family, const std::array<uint8_t, 16> ip, int len) {
char buffer[INET6_ADDRSTRLEN + 1] = {};
if (inet_ntop(family, ip.data(), buffer, sizeof(buffer) - 1)) {
s << buffer << '/' << (int)len;
}
return s;
}
} // namespace
StatusWith<CIDR> CIDR::parse(BSONElement from) noexcept {
if (from.type() != String) {
return {ErrorCodes::UnsupportedFormat, "CIDR range must be a string"};
}
return parse(from.valueStringData());
}
StatusWith<CIDR> CIDR::parse(StringData s) noexcept try {
return CIDR(s);
} catch (const DBException& e) {
return e.toStatus();
}
CIDR::CIDR(StringData s) try {
auto slash = find(begin(s), end(s), '/');
auto ip = (slash == end(s)) ? s.toString() : s.substr(0, slash - begin(s)).toString();
if (inet_pton(AF_INET, ip.c_str(), _ip.data())) {
_family = AF_INET;
_len = kIPv4Bits;
} else if (inet_pton(AF_INET6, ip.c_str(), _ip.data())) {
_family = AF_INET6;
_len = kIPv6Bits;
} else {
uasserted(ErrorCodes::UnsupportedFormat, "Invalid IP address in CIDR string");
}
if (slash == end(s)) {
return;
}
auto len = strict_stoi(std::string(slash + 1, end(s)), 10);
uassert(ErrorCodes::UnsupportedFormat,
"Invalid length in CIDR string",
(len >= 0) && (len <= _len));
_len = len;
} catch (const std::invalid_argument&) {
uasserted(ErrorCodes::UnsupportedFormat, "Non-numeric length in CIDR string");
} catch (const std::out_of_range&) {
uasserted(ErrorCodes::UnsupportedFormat, "Invalid length in CIDR string");
}
template <>
BSONObjBuilder& BSONObjBuilderValueStream::operator<<<CIDR>(CIDR value) {
_builder->append(_fieldName, value.toString());
_fieldName = StringData();
return *_builder;
}
} // namespace
std::ostream& mongo::operator<<(std::ostream& s, const CIDR& cidr) {
return append(s, cidr._family, cidr._ip, cidr._len);
}
mongo::StringBuilder& mongo::operator<<(StringBuilder& s, const CIDR& cidr) {
return append(s, cidr._family, cidr._ip, cidr._len);
}
|
; A168193: a(n) = a(n-1) + a(n-2) + 4, with a(0)=0, a(1)=2.
; 0,2,6,12,22,38,64,106,174,284,462,750,1216,1970,3190,5164,8358,13526,21888,35418,57310,92732,150046,242782,392832,635618,1028454,1664076,2692534,4356614,7049152,11405770,18454926,29860700,48315630,78176334,126491968,204668306,331160278,535828588,866988870,1402817462,2269806336,3672623802,5942430142,9615053948,15557484094,25172538046,40730022144,65902560194,106632582342,172535142540,279167724886,451702867430,730870592320,1182573459754,1913444052078,3096017511836,5009461563918,8105479075758
mov $1,4
mov $3,6
lpb $0
sub $0,1
mov $2,$1
mov $1,$3
add $3,$2
lpe
sub $1,4
mov $0,$1
|
; Generic I/O
level_data: dw 0, 10848 ; level 1
dw 10848, 12123 ; level 2
dw 22971, 12159 ; level 3
dw 35130, 12685 ; level 4
dw 47815, 14356 ; level 5
dw 62171, 13925 ; level 6
dw 0, 11783 ; level 7 (file 2)
dw 11783, 12116 ; level 8 (file 2)
dw 23899, 3926 ; level 0 (attract mode, file 2)
dw 27825, 8662 ; level 9 (easter egg)
sprite_data: dw 0, 2193 ; skeleton
dw 2193, 2023 ; orc
dw 4216, 2225 ; mummy
dw 6441, 2312 ; troll
dw 8753, 499 ; rock
dw 9252, 2455 ; knight
dw 11707, 2620 ; dal gurak
dw 14327, 2486 ; golem
dw 16813, 2186 ; ogre
dw 18999, 2186 ; minotaur
dw 21185, 2124 ; demon
dw 23309, 1281 ; golem - sup
dw 24590, 1315 ; ogre - sup
dw 25905, 1766 ; minotaur - sup
dw 27671, 1091 ; demon - sup
intro_data: dw 0, 1498 ; intro - frame
dw 1498, 4131 ; intro - screens
dw 5629, 3082 ; end - screens
dw 8711, 1814; end - credits
dw 10525, 2630 ; music - intro
dw 13155, 2052 ; music - end
dw 15207, 462 ; music - credits
; Load level from disk
; Will *always* place stuff in RAM Page 1, at $c000
; INPUT:
; - A: level to load
IO_LoadLevel:
call IO_loading
cp 6
jr c, IO_LoadLevel_file1
ld ix, filename_2
jr IO_LoadLevel_common
IO_LoadLevel_file1:
ld ix, filename
IO_LoadLevel_common:
ld hl, level_data
call IO_getdata
ld hl, $C000 ; load at $C000
ld a, 1 ; and store in RAMBank1
; call IO_Load
; ret
jp IO_Load
IO_getdata:
add a, a
add a, a
ld e, a
ld d, 0
add hl, de ; hl points to the offset
ld c, (hl)
inc hl
ld b, (hl) ; BC holds the offset to load
inc hl
ld e, (hl)
inc hl
ld d, (hl) ; DE holds the size
ret
; Print a string on screen, not controlling line breaks
; INPUT:
; IY: pointer to string
; B: X in chars
; C: Y in chars
print_string_3dos:
ld a, (iy+0)
and a
ret z ; return on NULL
push iy
push bc
call print_char
pop bc
pop iy
inc iy
inc b
jr nz, print_string_3dos
ret
; Load sprite from disk
; Will *always* place stuff in RAM page 4
; INPUT:
; - A: sprite to load
; - (current_spraddr): where to load
;
; RETURNS:
; - BC: number of bytes loaded
IO_LoadSprite:
ld hl, sprite_data
call IO_getdata
ld hl, (current_spraddr) ; load address
ld a, 4 ; and store in RAMBank4
ld ix, filename_spr
push de
call IO_Load
pop bc
ret
; Load intro screen pack from from disk
; Will *always* place stuff in RAM page 0, address $AC80
; INPUT:
; - A: screen pack to load
IO_LoadIntro:
call IO_loading
ld hl, intro_data
call IO_getdata
xor a ; Page 0
ld hl, $AC80 ; buffer
ld ix, filename_intro
jp IO_Load
; call IO_Load
; ret
; Load intro music
; Will *always* place stuff in RAM page 3, address $CC00
; INPUT:
; - A: music to load (for now, just 4)
IO_LoadIntroMusic:
call IO_loading
ld hl, intro_data
call IO_getdata
ld a, 3 ; Page 3
ld hl, $CB72 ; buffer
ld ix, filename_intro
jp IO_Load
loading_string_en: db "LOADING...",0
loading_string: db "CARGANDO...",0
IO_loading:
push af
ld a, (language)
and a
jr z, IO_loading_spanish
ld iy, loading_string_en
jr IO_loading_common
IO_loading_spanish:
ld iy, loading_string
IO_loading_common:
ld bc, $0B0C
call print_string_3dos
ld a, 7
ld hl, 16384+6144+12*32+11
ld de, 16384+6144+12*32+11+1
ld (hl), a
ld bc, 10
ldir
pop af
ret
; Input/output functions for +3DOS, using plain files
; +3DOS constants
DOS_EST_1346 equ $13F
DOS_OPEN equ $106
DOS_READ equ $112
DOS_CLOSE equ $109
DOS_MOTOR_OFF equ $19c
DOS_EST_POS equ $136
; Set the proper environment for +3DOS
; This means: IM1, RAM7, save previous RAM bank
previous_rambank: db 0
filename: db "IANNA.DAT",$ff
filename_2: db "IANNA2.DAT",$ff
filename_spr: db "IANNA.SPR",$ff
filename_intro: db "INTRO.BIN",$ff
DOS_Setenv:
ld A, ($5B5C)
ld (previous_rambank), a
di
ld b, 7
call setrambank_p3
im 1
LD IY, 5C3Ah ; re-establish the IY pointer (must be done!)
ei
ret
; Restore the previous environment
; This means: IM2, previous RAM bank and screen
DOS_RestoreEnv:
di
ld a, (previous_rambank)
ld b, a
call setrambank_p3
ei
ld a, 0xbf
ld hl, 0x8000
ld de, ISR
; call SetIM2
; ret
jp SetIM2
; Load from +3 file
; INPUT:
; - HL: destination
; - A: page for destination
; - DE: number of bytes to load
; - BC: offset in file
; - IX: filename
IO_Load:
push hl
push de
push af
push bc
call DOS_Setenv
ld hl, $0000
ld de, $0000
call DOS_EST_1346
JP NC, 0 ; reset if failed
push ix
pop hl ; file name
ld bc, $0001 ; File handle 0, exclusive read
ld de, $0002 ; Open, place pointer after header
call DOS_OPEN ; open file
jp nc, 0 ; reset if open failed (change into something better!!!)
; go to offset
pop bc
ld h, b
ld l, c
ld e, 0 ; WARNING: this is only allowing up to 64K file offsets. If we need more than that, redesign it!
ld b, 0 ; file descriptor 0
call DOS_EST_POS
JP NC, 0 ; reset if failed
pop af
ld c, a ; load to RAM BANK specified in A
ld b, $00 ; b=file descriptor 0
pop de ; DE = number of bytes to load
pop hl ; destination
call DOS_READ ; read bytes
ld b, 0
call DOS_CLOSE ; close file
call DOS_MOTOR_OFF ; disconnect drive motor
jp DOS_RestoreEnv
; call DOS_RestoreEnv
; ret
|
; A087656: Let f be defined on the rationals by f(p/q) =(p+1)/(q+1)=p_{1}/q_{1} where (p_{1},q_{1})=1. Let f^k(p/q)=p_{k}/q_{k} where (p_{k},q_{k})=1. Sequence gives least k such that p_{k}-q_{k} = 1 starting at n.
; 1,2,2,4,3,6,3,4,5,10,4,12,7,6,4,16,5,18,6,8,11,22,5,8,13,6,8,28,7,30,5,12,17,10,6,36,19,14,7,40,9,42,12,8,23,46,6,12,9,18,14,52,7,14,9,20,29,58,8,60,31,10,6,16,13,66,18,24,11,70,7,72,37,10,20,16,15,78,8,8,41,82
mov $6,$0
mov $7,$0
lpb $6,1
sub $6,$7
sub $6,1
mul $6,2
sub $0,$6
mov $2,$0
cmp $8,0
add $5,$8
sub $0,$5
mov $1,$0
sub $1,1
add $6,2
lpb $2,1
lpb $1,1
mov $3,$2
gcd $3,$1
sub $1,$3
add $4,3
lpe
mov $1,$4
mov $2,1
lpe
lpe
div $1,3
add $1,1
|
; A318369: Number of non-isomorphic set multipartitions (multisets of sets) of the multiset of prime indices of n.
; Submitted by Christian Krause
; 1,1,1,1,1,2,1,1,1,2,1,2,1,2,2,1,1,2,1,2,2,2,1,2,1,2,1,2,1,3,1,1,2,2,2,3,1,2,2,2,1,3,1,2,2,2,1,2,1,2,2,2,1,2,2,2,2,2,1,5,1,2,2,1,2,3,1,2,2,3,1,3,1,2,2,2,2,3,1,2,1,2,1,5,2,2,2
seq $0,343943 ; Number of distinct possible alternating sums of permutations of the multiset of prime factors of n.
add $0,1
seq $0,3132 ; Sum of squares of digits of n.
sub $0,4
div $0,5
add $0,1
|
#include "pch.h"
#include "VisualTreeHelper2.h"
#include <queue>
using namespace Platform;
using namespace Platform::Collections;
using namespace std;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Media;
using namespace Mntone::Xamcc::Controls;
#define VTH2_RETURN return ref new VectorView<DependencyObject^>( move( data ) );
VisualTreeHelper2::VisualTreeHelper2()
{ }
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetDescendantsOfType( DependencyObject^ reference, TypeName typeName )
{
vector<DependencyObject^> data = GetDescendantsInternal( reference );
OfType( data, typeName );
VTH2_RETURN
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetDescendants( DependencyObject^ reference )
{
vector<DependencyObject^> data = GetDescendantsInternal( reference );
VTH2_RETURN
}
vector<DependencyObject^> VisualTreeHelper2::GetDescendantsInternal( DependencyObject^ reference )
{
vector<DependencyObject^> data;
if( reference == nullptr )
{
return move( data );
}
queue<DependencyObject^> queue;
auto popup = dynamic_cast<Popup^>( reference );
if( popup != nullptr && popup->Child != nullptr )
{
queue.push( popup->Child );
data.emplace_back( popup->Child );
}
else
{
const auto count = VisualTreeHelper::GetChildrenCount( reference );
for( int32 i = 0; i < count; ++i )
{
auto child = VisualTreeHelper::GetChild( reference, i );
queue.push( child );
data.emplace_back( child );
}
}
while( !queue.empty() )
{
reference = queue.front();
queue.pop();
popup = dynamic_cast<Popup^>( reference );
if( popup != nullptr && popup->Child != nullptr )
{
queue.push( popup->Child );
data.emplace_back( popup->Child );
continue;
}
const auto count = VisualTreeHelper::GetChildrenCount( reference );
for( int32 i = 0; i < count; ++i )
{
auto child = VisualTreeHelper::GetChild( reference, i );
queue.push( child );
data.emplace_back( child );
}
}
return move( data );
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetAncestors( DependencyObject^ reference )
{
vector<DependencyObject^> data;
if( reference == nullptr )
{
VTH2_RETURN
}
auto parent = VisualTreeHelper::GetParent( reference );
while( parent != nullptr )
{
data.emplace_back( parent );
parent = VisualTreeHelper::GetParent( parent );
}
VTH2_RETURN
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetChildrenOfType( DependencyObject^ reference, TypeName typeName )
{
vector<DependencyObject^> data = GetChildrenInternal( reference );
OfType( data, typeName );
VTH2_RETURN
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetChildren( DependencyObject^ reference )
{
vector<DependencyObject^> data = GetChildrenInternal( reference );
VTH2_RETURN
}
vector<DependencyObject^> VisualTreeHelper2::GetChildrenInternal( DependencyObject^ reference )
{
vector<DependencyObject^> data;
if( reference == nullptr )
{
return move( data );
}
auto popup = dynamic_cast<Popup^>( reference );
if( popup != nullptr && popup->Child != nullptr )
{
data.emplace_back( popup->Child );
return move( data );
}
const auto count = VisualTreeHelper::GetChildrenCount( reference );
for( int32 i = 0; i < count; ++i )
{
auto child = VisualTreeHelper::GetChild( reference, i );
data.emplace_back( child );
}
return move( data );
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetSiblingsOfType( DependencyObject^ reference, TypeName typeName )
{
vector<DependencyObject^> data = GetSiblingsInternal( reference );
OfType( data, typeName );
VTH2_RETURN
}
IVectorView<DependencyObject^>^ VisualTreeHelper2::GetSiblings( DependencyObject^ reference )
{
vector<DependencyObject^> data = GetSiblingsInternal( reference );
VTH2_RETURN
}
vector<DependencyObject^> VisualTreeHelper2::GetSiblingsInternal( DependencyObject^ reference )
{
vector<DependencyObject^> data;
if( reference == nullptr )
{
return move( data );
}
auto parent = VisualTreeHelper::GetParent( reference );
if( parent == nullptr )
{
data.emplace_back( reference );
return move( data );
}
auto popup = dynamic_cast<Popup^>( parent );
if( popup != nullptr && popup->Child != nullptr )
{
data.emplace_back( popup->Child );
return move( data );
}
const auto count = VisualTreeHelper::GetChildrenCount( parent );
for( int32 i = 0; i < count; ++i )
{
auto child = VisualTreeHelper::GetChild( reference, i );
data.emplace_back( child );
}
return move( data );
}
void VisualTreeHelper2::OfType( vector<DependencyObject^>& data, TypeName typeName )
{
data.erase(
remove_if(
begin( data ),
end( data ),
[typeName]( DependencyObject^ d ) { return TypeName( d->GetType() ).Name != typeName.Name; } ),
end( data ) );
} |
; A317298: a(n) = (1/2)*(1 + (-1)^n + 2*n + 4*n^2).
; 1,3,11,21,37,55,79,105,137,171,211,253,301,351,407,465,529,595,667,741,821,903,991,1081,1177,1275,1379,1485,1597,1711,1831,1953,2081,2211,2347,2485,2629,2775,2927,3081,3241,3403,3571,3741,3917,4095,4279,4465,4657,4851,5051,5253,5461,5671,5887,6105,6329,6555,6787,7021,7261,7503,7751,8001,8257,8515,8779,9045,9317,9591,9871,10153,10441,10731,11027,11325,11629,11935,12247,12561,12881,13203,13531,13861,14197,14535,14879,15225,15577,15931,16291,16653,17021,17391,17767,18145,18529,18915,19307,19701,20101,20503,20911,21321,21737,22155,22579,23005,23437,23871,24311,24753,25201,25651,26107,26565,27029,27495,27967,28441,28921,29403,29891,30381,30877,31375,31879,32385,32897,33411,33931,34453,34981,35511,36047,36585,37129,37675,38227,38781,39341,39903,40471,41041,41617,42195,42779,43365,43957,44551,45151,45753,46361,46971,47587,48205,48829,49455,50087,50721,51361,52003,52651,53301,53957,54615,55279,55945,56617,57291,57971,58653,59341,60031,60727,61425,62129,62835,63547,64261,64981,65703,66431,67161,67897,68635,69379,70125,70877,71631,72391,73153,73921,74691,75467,76245,77029,77815,78607,79401,80201,81003,81811,82621,83437,84255,85079,85905,86737,87571,88411,89253,90101,90951,91807,92665,93529,94395,95267,96141,97021,97903,98791,99681,100577,101475,102379,103285,104197,105111,106031,106953,107881,108811,109747,110685,111629,112575,113527,114481,115441,116403,117371,118341,119317,120295,121279,122265,123257,124251
mov $1,$0
pow $0,2
div $1,2
add $1,$0
mul $1,2
add $1,1
|
; A100154: Structured truncated icosahedral numbers.
; 1,60,282,772,1635,2976,4900,7512,10917,15220,20526,26940,34567,43512,53880,65776,79305,94572,111682,130740,151851,175120,200652,228552,258925,291876,327510,365932,407247,451560,498976,549600,603537,660892,721770,786276,854515,926592,1002612,1082680,1166901,1255380,1348222,1445532,1547415,1653976,1765320,1881552,2002777,2129100,2260626,2397460,2539707,2687472,2840860,2999976,3164925,3335812,3512742,3695820,3885151,4080840,4282992,4491712,4707105,4929276,5158330,5394372,5637507,5887840,6145476,6410520,6683077,6963252,7251150,7546876,7850535,8162232,8482072,8810160,9146601,9491500,9844962,10207092,10577995,10957776,11346540,11744392,12151437,12567780,12993526,13428780,13873647,14328232,14792640,15266976,15751345,16245852,16750602,17265700,17791251,18327360,18874132,19431672,20000085,20579476,21169950,21771612,22384567,23008920,23644776,24292240,24951417,25622412,26305330,27000276,27707355,28426672,29158332,29902440,30659101,31428420,32210502,33005452,33813375,34634376,35468560,36316032,37176897,38051260,38939226,39840900,40756387,41685792,42629220,43586776,44558565,45544692,46545262,47560380,48590151,49634680,50694072,51768432,52857865,53962476,55082370,56217652,57368427,58534800,59716876,60914760,62128557,63358372,64604310,65866476,67144975,68439912,69751392,71079520,72424401,73786140,75164842,76560612,77973555,79403776,80851380,82316472,83799157,85299540,86817726,88353820,89907927,91480152,93070600,94679376,96306585,97952332,99616722,101299860,103001851,104722800,106462812,108221992,110000445,111798276,113615590,115452492,117309087,119185480,121081776,122998080,124934497,126891132,128868090,130865476,132883395,134921952,136981252,139061400,141162501,143284660,145427982,147592572,149778535,151985976,154215000,156465712,158738217,161032620,163349026,165687540,168048267,170431312,172836780,175264776,177715405,180188772,182684982,185204140,187746351,190311720,192900352,195512352,198147825,200806876,203489610,206196132,208926547,211680960,214459476,217262200,220089237,222940692,225816670,228717276,231642615,234592792,237567912,240568080,243593401,246643980,249719922,252821332,255948315,259100976,262279420,265483752,268714077,271970500
mov $1,$0
add $1,4
add $1,$0
mov $3,$0
add $3,3
mov $6,$0
add $0,$1
sub $0,1
mov $4,2
lpb $0,1
sub $0,1
add $1,$4
sub $1,2
sub $4,1
add $4,$3
sub $4,1
lpe
sub $1,6
mov $5,$6
mov $7,$6
lpb $5,1
sub $5,1
add $8,$7
lpe
mov $2,17
mov $7,$8
lpb $2,1
add $1,$7
sub $2,1
lpe
mov $5,$6
mov $8,0
lpb $5,1
sub $5,1
add $8,$7
lpe
mov $2,13
mov $7,$8
lpb $2,1
add $1,$7
sub $2,1
lpe
|
Name: z00_msge0.asm
Type: file
Size: 50408
Last-Modified: '2016-05-13T04:36:32Z'
SHA-1: ABB26E752EBC9662786E4FEA7F479B844D0B6838
Description: null
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r8
push %rbp
push %rbx
push %rcx
push %rdx
lea addresses_normal_ht+0x18ced, %r8
nop
nop
nop
nop
nop
xor %rdx, %rdx
movb (%r8), %bl
nop
nop
nop
nop
nop
dec %rbp
lea addresses_UC_ht+0x52ed, %rcx
clflush (%rcx)
nop
nop
nop
nop
sub %r10, %r10
mov $0x6162636465666768, %r11
movq %r11, (%rcx)
nop
nop
nop
nop
nop
add %r10, %r10
pop %rdx
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r9
push %rcx
push %rdi
push %rdx
// Store
lea addresses_A+0xc2ed, %rdi
nop
nop
and $36451, %r9
mov $0x5152535455565758, %r12
movq %r12, %xmm3
vmovups %ymm3, (%rdi)
nop
nop
nop
nop
dec %rcx
// Store
lea addresses_normal+0x1336d, %rdx
nop
nop
nop
nop
nop
xor %r11, %r11
movb $0x51, (%rdx)
nop
nop
nop
cmp %rdx, %rdx
// Store
lea addresses_A+0x1e37d, %rdi
nop
nop
nop
nop
nop
sub $1097, %r10
movl $0x51525354, (%rdi)
nop
add $21935, %r11
// Faulty Load
lea addresses_A+0xc2ed, %rdi
clflush (%rdi)
nop
add %r12, %r12
mov (%rdi), %r11
lea oracles, %r12
and $0xff, %r11
shlq $12, %r11
mov (%r12,%r11,1), %r11
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A', 'congruent': 0}}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal', 'congruent': 6}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_A', 'congruent': 4}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 11}, 'OP': 'STOR'}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
[BotwMasterModeTweaksV208]
moduleMatches = 0x6267BFD0
# Constants
merge0x129 = $bit0 + $bit1 + $bit3 + $bit5 + $bit8
;Combines bits set by the user in rules.txt to a bitmask. Split between 2 patches because vanilla compiled it to 2 hex values instead of 1 for some
;reason. There's no overlap in vanilla between the 2 hex values, so I made sure each bit was set by the same instruction as in vanilla.
;(Variable names are the hex values that were in that location in vanilla)
merge0xd0 = $bit4 + $bit6 + $bit7
;Bit 2 is excluded from the logic because it does absolutely nothing. Bits 0 and 1 are connected to other parts of the game code, but don't actually
;do anything in-game.
# Patches
0x031696B8 = ori r9, r0, merge0x129
0x031696C4 = ori r0, r9, merge0xd0
|
;
; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright 2009 D. R. Commander
;
; Based on
; x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
; the IJG's original jidctflt.c; see the jidctflt.c for more details.
;
; [TAB8]
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1,%2,0x44
%endmacro
%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1,%2,0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
alignz 16
global EXTN(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
PD_1_414 times 4 dd 1.414213562373095048801689
PD_1_847 times 4 dd 1.847759065022573512256366
PD_1_082 times 4 dd 1.082392200292393968799446
PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
alignz 16
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 64
;
; Perform dequantization and inverse DCT on one block of coefficients.
;
; GLOBAL(void)
; jsimd_idct_float_sse2 (void * dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
; r10 = void * dct_table
; r11 = JCOEFPTR coef_block
; r12 = JSAMPARRAY output_buf
; r13 = JDIMENSION output_col
%define original_rbp rbp+0
%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT
; FAST_FLOAT workspace[DCTSIZE2]
align 16
global EXTN(jsimd_idct_float_sse2)
EXTN(jsimd_idct_float_sse2):
push rbp
mov rax,rsp ; rax = original rbp
sub rsp, byte 4
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [rsp],rax
mov rbp,rsp ; rbp = aligned rbp
lea rsp, [workspace]
collect_args
push rbx
; ---- Pass 1: process columns from input, store into work array.
mov rdx, r10 ; quantptr
mov rsi, r11 ; inptr
lea rdi, [workspace] ; FAST_FLOAT * wsptr
mov rcx, DCTSIZE/4 ; ctr
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
jnz near .columnDCT
movq xmm1, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm4, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm6, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
movq xmm7, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
por xmm1,xmm2
por xmm3,xmm4
por xmm5,xmm6
por xmm1,xmm3
por xmm5,xmm7
por xmm1,xmm5
packsswb xmm1,xmm1
movd eax,xmm1
test rax,rax
jnz short .columnDCT
; -- AC terms all zero
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm1,xmm0
movaps xmm2,xmm0
movaps xmm3,xmm0
shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00)
shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01)
shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02)
shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
%endif
.columnDCT:
; -- Even part
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
punpcklwd xmm1,xmm1 ; xmm1=(20 20 21 21 22 22 23 23)
psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23)
cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm1,xmm1 ; xmm1=in2=(20 21 22 23)
punpcklwd xmm2,xmm2 ; xmm2=(40 40 41 41 42 42 43 43)
punpcklwd xmm3,xmm3 ; xmm3=(60 60 61 61 62 62 63 63)
psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43)
psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63)
cvtdq2ps xmm2,xmm2 ; xmm2=in4=(40 41 42 43)
cvtdq2ps xmm3,xmm3 ; xmm3=in6=(60 61 62 63)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4,xmm0
movaps xmm5,xmm1
subps xmm0,xmm2 ; xmm0=tmp11
subps xmm1,xmm3
addps xmm4,xmm2 ; xmm4=tmp10
addps xmm5,xmm3 ; xmm5=tmp13
mulps xmm1,[rel PD_1_414]
subps xmm1,xmm5 ; xmm1=tmp12
movaps xmm6,xmm4
movaps xmm7,xmm0
subps xmm4,xmm5 ; xmm4=tmp3
subps xmm0,xmm1 ; xmm0=tmp2
addps xmm6,xmm5 ; xmm6=tmp0
addps xmm7,xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movq xmm2, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm2,xmm2 ; xmm2=(10 10 11 11 12 12 13 13)
punpcklwd xmm3,xmm3 ; xmm3=(30 30 31 31 32 32 33 33)
psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13)
psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33)
cvtdq2ps xmm2,xmm2 ; xmm2=in1=(10 11 12 13)
cvtdq2ps xmm3,xmm3 ; xmm3=in3=(30 31 32 33)
punpcklwd xmm5,xmm5 ; xmm5=(50 50 51 51 52 52 53 53)
punpcklwd xmm1,xmm1 ; xmm1=(70 70 71 71 72 72 73 73)
psrad xmm5,(DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53)
psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73)
cvtdq2ps xmm5,xmm5 ; xmm5=in5=(50 51 52 53)
cvtdq2ps xmm1,xmm1 ; xmm1=in7=(70 71 72 73)
mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4,xmm2
movaps xmm0,xmm5
addps xmm2,xmm1 ; xmm2=z11
addps xmm5,xmm3 ; xmm5=z13
subps xmm4,xmm1 ; xmm4=z12
subps xmm0,xmm3 ; xmm0=z10
movaps xmm1,xmm2
subps xmm2,xmm5
addps xmm1,xmm5 ; xmm1=tmp7
mulps xmm2,[rel PD_1_414] ; xmm2=tmp11
movaps xmm3,xmm0
addps xmm0,xmm4
mulps xmm0,[rel PD_1_847] ; xmm0=z5
mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3,xmm0 ; xmm3=tmp12
subps xmm4,xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3,xmm1 ; xmm3=tmp6
movaps xmm5,xmm6
movaps xmm0,xmm7
addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03)
addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13)
subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73)
subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63)
subps xmm2,xmm3 ; xmm2=tmp5
movaps xmm1,xmm6 ; transpose coefficients(phase 1)
unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11)
unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13)
movaps xmm3,xmm0 ; transpose coefficients(phase 1)
unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71)
unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
addps xmm4,xmm2 ; xmm4=tmp4
movaps xmm0,xmm7
movaps xmm3,xmm5
addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23)
addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43)
subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53)
subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33)
movaps xmm2,xmm7 ; transpose coefficients(phase 1)
unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31)
unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33)
movaps xmm4,xmm5 ; transpose coefficients(phase 1)
unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51)
unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53)
movaps xmm3,xmm6 ; transpose coefficients(phase 2)
unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30)
unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31)
movaps xmm0,xmm1 ; transpose coefficients(phase 2)
unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32)
unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6,xmm5 ; transpose coefficients(phase 2)
unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70)
unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71)
movaps xmm3,xmm4 ; transpose coefficients(phase 2)
unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72)
unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm4
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
.nextcolumn:
add rsi, byte 4*SIZEOF_JCOEF ; coef_block
add rdx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
add rdi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
dec rcx ; ctr
jnz near .columnloop
; -- Prefetch the next coefficient block
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
; ---- Pass 2: process rows from work array, store into output array.
mov rax, [original_rbp]
lea rsi, [workspace] ; FAST_FLOAT * wsptr
mov rdi, r12 ; (JSAMPROW *)
mov rax, r13
mov rcx, DCTSIZE/4 ; ctr
.rowloop:
; -- Even part
movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4,xmm0
movaps xmm5,xmm1
subps xmm0,xmm2 ; xmm0=tmp11
subps xmm1,xmm3
addps xmm4,xmm2 ; xmm4=tmp10
addps xmm5,xmm3 ; xmm5=tmp13
mulps xmm1,[rel PD_1_414]
subps xmm1,xmm5 ; xmm1=tmp12
movaps xmm6,xmm4
movaps xmm7,xmm0
subps xmm4,xmm5 ; xmm4=tmp3
subps xmm0,xmm1 ; xmm0=tmp2
addps xmm6,xmm5 ; xmm6=tmp0
addps xmm7,xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4,xmm2
movaps xmm0,xmm5
addps xmm2,xmm1 ; xmm2=z11
addps xmm5,xmm3 ; xmm5=z13
subps xmm4,xmm1 ; xmm4=z12
subps xmm0,xmm3 ; xmm0=z10
movaps xmm1,xmm2
subps xmm2,xmm5
addps xmm1,xmm5 ; xmm1=tmp7
mulps xmm2,[rel PD_1_414] ; xmm2=tmp11
movaps xmm3,xmm0
addps xmm0,xmm4
mulps xmm0,[rel PD_1_847] ; xmm0=z5
mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3,xmm0 ; xmm3=tmp12
subps xmm4,xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3,xmm1 ; xmm3=tmp6
movaps xmm5,xmm6
movaps xmm0,xmm7
addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30)
addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31)
subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37)
subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36)
subps xmm2,xmm3 ; xmm2=tmp5
movaps xmm1,[rel PD_RNDINT_MAGIC] ; xmm1=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm3,xmm3
psrld xmm3,WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm6,xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **)
addps xmm7,xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **)
addps xmm0,xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **)
addps xmm5,xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **)
pand xmm6,xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --)
pslld xmm7,WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31)
pand xmm0,xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --)
pslld xmm5,WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37)
por xmm6,xmm7 ; xmm6=(00 01 10 11 20 21 30 31)
por xmm0,xmm5 ; xmm0=(06 07 16 17 26 27 36 37)
movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2
movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3
addps xmm4,xmm2 ; xmm4=tmp4
movaps xmm7,xmm1
movaps xmm5,xmm3
addps xmm1,xmm2 ; xmm1=data2=(02 12 22 32)
addps xmm3,xmm4 ; xmm3=data4=(04 14 24 34)
subps xmm7,xmm2 ; xmm7=data5=(05 15 25 35)
subps xmm5,xmm4 ; xmm5=data3=(03 13 23 33)
movaps xmm2,[rel PD_RNDINT_MAGIC] ; xmm2=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm4,xmm4
psrld xmm4,WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm3,xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **)
addps xmm7,xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **)
addps xmm1,xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **)
addps xmm5,xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **)
pand xmm3,xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --)
pslld xmm7,WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35)
pand xmm1,xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --)
pslld xmm5,WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33)
por xmm3,xmm7 ; xmm3=(04 05 14 15 24 25 34 35)
por xmm1,xmm5 ; xmm1=(02 03 12 13 22 23 32 33)
movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
packsswb xmm6,xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35)
packsswb xmm1,xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37)
paddb xmm6,xmm2
paddb xmm1,xmm2
movdqa xmm4,xmm6 ; transpose coefficients(phase 2)
punpcklwd xmm6,xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
punpckhwd xmm4,xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
movdqa xmm7,xmm6 ; transpose coefficients(phase 3)
punpckldq xmm6,xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
punpckhdq xmm7,xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
pshufd xmm5,xmm6,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm3,xmm7,0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm7
mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm3
add rsi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add rdi, byte 4*SIZEOF_JSAMPROW
dec rcx ; ctr
jnz near .rowloop
pop rbx
uncollect_args
mov rsp,rbp ; rsp <- aligned rbp
pop rsp ; rsp <- original rbp
pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#include "LinterContentBrowserExtensions.h"
#include "Modules/ModuleManager.h"
#include "LevelEditor.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "LinterStyle.h"
#include "LauncherPlatformModule.h"
#include "UnrealEdMisc.h"
#include "ContentBrowserModule.h"
#include "EditorStyleSet.h"
#include "Linter.h"
#include "Framework/MultiBox/MultiBoxExtender.h"
#include "Framework/Commands/UIAction.h"
#include "Delegates/IDelegateInstance.h"
#include "TooltipEditor/TooltipTool.h"
#define LOCTEXT_NAMESPACE "Linter"
DEFINE_LOG_CATEGORY_STATIC(LinterContentBrowserExtensions, Log, All);
void FLinterContentBrowserExtensions::InstallHooks(FLinterModule* LinterModule, FDelegateHandle* pContentBrowserExtenderDelegateHandle, class FDelegateHandle* pAssetExtenderDelegateHandle)
{
struct Local
{
// Path extensions
static TSharedRef<FExtender> OnExtendContentBrowserAssetSelectionMenu(const TArray<FString>& SelectedPaths)
{
TSharedRef<FExtender> Extender = MakeShared<FExtender>();
Extender->AddMenuExtension(
"PathContextSourceControl",
EExtensionHook::After,
TSharedPtr<FUICommandList>(),
FMenuExtensionDelegate::CreateStatic(&Local::ContentBrowserExtenderFunc, SelectedPaths)
);
return Extender;
}
static void ContentBrowserExtenderFunc(FMenuBuilder& MenuBuilder, const TArray<FString> SelectedPaths)
{
MenuBuilder.BeginSection("LinterContentBrowserContext", LOCTEXT("CB_LinterHeader", "Linter"));
{
MenuBuilder.AddMenuEntry(
LOCTEXT("CB_ScanProjectWithLinter", "Scan with Linter"),
LOCTEXT("CB_ScanProjectWithLinter_Tooltip", "Scan project content with Linter"),
FSlateIcon(FLinterStyle::GetStyleSetName(), "Linter.Toolbar.Icon"),
FUIAction(FExecuteAction::CreateLambda([SelectedPaths]()
{
if (FLinterModule* lm = FModuleManager::GetModulePtr<FLinterModule>("Linter"))
{
if (lm != nullptr)
{
lm->SetDesiredLintPaths(SelectedPaths);
}
FGlobalTabmanager::Get()->TryInvokeTab(FName("LinterTab"));
}
})),
NAME_None,
EUserInterfaceActionType::Button);
}
MenuBuilder.EndSection();
}
// Asset extensions
static TSharedRef<FExtender> OnExtendAssetSelectionMenu(const TArray<FAssetData>& SelectedAssets)
{
TSharedRef<FExtender> Extender = MakeShared<FExtender>();
Extender->AddMenuExtension(
"CommonAssetActions",
EExtensionHook::After,
nullptr,
FMenuExtensionDelegate::CreateStatic(&Local::AssetExtenderFunc, SelectedAssets)
);
return Extender;
}
static void AssetExtenderFunc(FMenuBuilder& MenuBuilder, const TArray<FAssetData> SelectedAssets)
{
MenuBuilder.BeginSection("LinterAssetContext", LOCTEXT("CB_LinterHeader", "Linter"));
{
// Run through the assets to determine if any are blueprints
bool bAnyBlueprintsSelected = false;
for (auto AssetIt = SelectedAssets.CreateConstIterator(); AssetIt; ++AssetIt)
{
const FAssetData& Asset = *AssetIt;
// Cannot rename redirectors or classes or cooked packages
if (!Asset.IsRedirector() && Asset.AssetClass != NAME_Class && !(Asset.PackageFlags & PKG_FilterEditorOnly))
{
if (Asset.GetClass()->IsChildOf(UBlueprint::StaticClass()))
{
bAnyBlueprintsSelected = true;
break;
}
}
}
// If we have blueprints selected, enable blueprint tools
if (bAnyBlueprintsSelected)
{
// Add Tooltip Editor
MenuBuilder.AddMenuEntry(
LOCTEXT("CB_EditBlueprintTooltips", "Edit Blueprint Tooltips (Experimental)"),
LOCTEXT("CB_EditBlueprintTooltips_Tooltip", "Edit selected blueprints' templates definitions"),
FSlateIcon(FLinterStyle::GetStyleSetName(), "Linter.Toolbar.Icon"),
FUIAction(FExecuteAction::CreateLambda([SelectedAssets]()
{
UE_LOG(LinterContentBrowserExtensions, Display, TEXT("Opening Tooltip Tool window."));
FTooltipTool AssetDlg(SelectedAssets);
if (AssetDlg.ShowModal() == FTooltipTool::Confirm)
{
UE_LOG(LinterContentBrowserExtensions, Display, TEXT("Tooltip Tool did the thing."));
}
})),
NAME_None,
EUserInterfaceActionType::Button);
}
// Run through the assets to see if any can be renamed
bool bAnyAssetCanBeRenamed = false;
for (auto AssetIt = SelectedAssets.CreateConstIterator(); AssetIt; ++AssetIt)
{
const FAssetData& Asset = *AssetIt;
// Cannot rename redirectors or classes or cooked packages
if (!Asset.IsRedirector() && Asset.AssetClass != NAME_Class && !(Asset.PackageFlags & PKG_FilterEditorOnly))
{
bAnyAssetCanBeRenamed = true;
break;
}
}
if (bAnyAssetCanBeRenamed)
{
// Add Tooltip Editor
MenuBuilder.AddMenuEntry(
LOCTEXT("CB_BatchRenameAssets", "Batch Rename Assets (Experimental)"),
LOCTEXT("CB_BatchRenameAssets_Tooltip", "Perform a bulk rename operation on all of the selected assets"),
FSlateIcon(FLinterStyle::GetStyleSetName(), "Linter.Toolbar.Icon"),
FUIAction(FExecuteAction::CreateLambda([SelectedAssets]()
{
UE_LOG(LinterContentBrowserExtensions, Display, TEXT("Starting batch rename."));
FDlgBatchRenameTool AssetDlg(SelectedAssets);
AssetDlg.ShowModal();
})),
NAME_None,
EUserInterfaceActionType::Button);
}
}
MenuBuilder.EndSection();
}
};
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));
// Path view extenders
TArray<FContentBrowserMenuExtender_SelectedPaths>& CBMenuPathExtenderDelegates = ContentBrowserModule.GetAllPathViewContextMenuExtenders();
CBMenuPathExtenderDelegates.Add(FContentBrowserMenuExtender_SelectedPaths::CreateStatic(&Local::OnExtendContentBrowserAssetSelectionMenu));
*pContentBrowserExtenderDelegateHandle = CBMenuPathExtenderDelegates.Last().GetHandle();
// Asset extenders
TArray<FContentBrowserMenuExtender_SelectedAssets>& CBMenuAssetExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders();
CBMenuAssetExtenderDelegates.Add(FContentBrowserMenuExtender_SelectedAssets::CreateStatic(&Local::OnExtendAssetSelectionMenu));
*pAssetExtenderDelegateHandle = CBMenuAssetExtenderDelegates.Last().GetHandle();
}
void FLinterContentBrowserExtensions::RemoveHooks(FLinterModule* LinterModule, FDelegateHandle* pContentBrowserExtenderDelegateHandle, FDelegateHandle* pAssetExtenderDelegateHandle)
{
if (FModuleManager::Get().IsModuleLoaded("ContentBrowser"))
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));
// Path view extenders
TArray<FContentBrowserMenuExtender_SelectedPaths>& CBMenuExtenderDelegates = ContentBrowserModule.GetAllAssetContextMenuExtenders();
CBMenuExtenderDelegates.RemoveAll([pContentBrowserExtenderDelegateHandle](const FContentBrowserMenuExtender_SelectedPaths & Delegate) { return Delegate.GetHandle() == *pContentBrowserExtenderDelegateHandle; });
// Asset extenders
TArray<FContentBrowserMenuExtender_SelectedAssets>& CBMenuAssetExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders();
CBMenuAssetExtenderDelegates.RemoveAll([pAssetExtenderDelegateHandle](const FContentBrowserMenuExtender_SelectedAssets & Delegate) { return Delegate.GetHandle() == *pAssetExtenderDelegateHandle; });
}
}
#undef LOCTEXT_NAMESPACE |
Name: ys_w64.asm
Type: file
Size: 22163
Last-Modified: '2016-05-13T04:51:45Z'
SHA-1: 04C07AC97215B3A22B7017E9160FEFDDE82AA27A
Description: null
|
; A267580: Binary representation of the middle column of the "Rule 167" elementary cellular automaton starting with a single ON (black) cell.
; Submitted by Simon Strandgaard
; 1,11,110,1101,11010,110101,1101011,11010111,110101110,1101011101,11010111011,110101110111,1101011101111,11010111011111,110101110111111,1101011101111111,11010111011111110,110101110111111101,1101011101111111011,11010111011111110111,110101110111111101111,1101011101111111011111,11010111011111110111111,110101110111111101111111,1101011101111111011111111,11010111011111110111111111,110101110111111101111111111,1101011101111111011111111111,11010111011111110111111111111,110101110111111101111111111111
mov $2,$0
mov $4,$0
add $4,1
lpb $4
mov $0,$2
add $3,2
sub $4,1
sub $0,$4
add $0,1
mov $5,$0
mov $0,4
mul $1,10
mod $3,$5
trn $0,$3
mov $5,$0
div $5,4
pow $5,$0
add $1,$5
lpe
mov $0,$1
|
SECTION "INTRO_CUTSCENE_1_MAP", ROMX, ALIGN[8], BANK[12]
;;; Generated by cutscene.py
r12_cutscene_test_map_data::
.test_0
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_1
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $81, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $83, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $84, $85, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $86, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $87, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $88, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_2
DB $80, $81, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $83, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $84, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $85, $86, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $87, $88, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $89, $8A, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $8B, $80, $80, $8C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $8D, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $8E, $8F, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $90, $91, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $92, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $93, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $82, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_3
DB $80, $80, $80, $80, $80, $81, $82, $83, $83, $83, $83, $83, $84, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $85, $83, $83, $83, $83, $83, $83, $86, $87, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $88, $89, $83, $83, $83, $83, $83, $83, $83, $8A, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8B, $83, $83, $83, $83, $83, $83, $83, $83, $8C, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8D, $8E, $83, $83, $83, $83, $83, $83, $83, $8F, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $90, $83, $83, $83, $83, $83, $83, $91, $92, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $93, $83, $83, $83, $83, $83, $83, $94, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $95, $96, $83, $83, $83, $83, $83, $83, $83, $97, $98, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $99, $9A, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $9B, $9C, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $9D, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $9E, $87, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9F, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A0, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A1, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A2, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A3, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A4, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $9E, $A5, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A6, $A7, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A8, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $83, $A9, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_4
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $86, $87, $88, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $89, $8A, $86, $86, $86, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8C, $86, $86, $86, $86, $86, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8E, $86, $86, $86, $86, $86, $86, $8F, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $90, $86, $86, $86, $86, $86, $91, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $92, $86, $86, $86, $86, $93, $94, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $95, $96, $86, $86, $86, $86, $97, $98, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $99, $9A, $86, $86, $86, $86, $86, $86, $9B, $9C, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $9D, $9E, $86, $86, $86, $86, $86, $86, $86, $86, $9F, $A0, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A1, $A2, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $A3, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A4, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $A5, $A6, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A7, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $A8, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A9, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $AA, $AB, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $AC, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $AD, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $AE, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $86, $AF, $84, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_5
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $83, $84, $85, $86, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $87, $88, $88, $89, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8A, $88, $88, $88, $8B, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8D, $88, $88, $88, $88, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8F, $88, $88, $88, $90, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $92, $88, $88, $88, $88, $93, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $94, $88, $88, $88, $88, $88, $88, $95, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $96, $88, $88, $88, $88, $88, $88, $88, $97, $98, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $99, $9A, $88, $88, $88, $88, $88, $88, $88, $88, $9B, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $9C, $88, $88, $88, $88, $88, $88, $88, $88, $88, $9D, $9E, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $9F, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $A0, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A1, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $A2, $A3, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A4, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $A5, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A6, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $A7, $A8, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $A9, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $88, $AA, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $AB, $AC, $AD, $88, $88, $88, $88, $88, $88, $88, $88, $AE, $AF, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_6
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $83, $84, $85, $86, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $87, $88, $88, $89, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8A, $88, $88, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8C, $88, $88, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8E, $8F, $88, $88, $88, $90, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $91, $88, $88, $88, $88, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $93, $88, $88, $88, $88, $88, $94, $95, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $96, $88, $88, $88, $88, $88, $88, $97, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $98, $88, $88, $88, $88, $88, $88, $99, $9A, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $9B, $88, $88, $88, $88, $88, $88, $88, $9C, $9D, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $9E, $88, $88, $88, $88, $88, $88, $88, $88, $9F, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $A0, $88, $88, $88, $88, $88, $88, $88, $88, $A1, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $A2, $A3, $88, $88, $A4, $A5, $A6, $A7, $A8, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $A9, $AA, $AB, $AC, $AD, $AE, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $AF, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_7
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $83, $84, $85, $86, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $87, $88, $88, $89, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8A, $8B, $8C, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8E, $88, $88, $8F, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $90, $88, $88, $88, $88, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $92, $88, $88, $88, $88, $93, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $94, $88, $88, $88, $88, $95, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $96, $88, $88, $88, $88, $88, $97, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $98, $99, $88, $88, $88, $88, $9A, $9B, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $9C, $9D, $9E, $9F, $A0, $A1, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $A2, $A3, $A4, $A5, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_8
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $83, $84, $85, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $86, $87, $88, $89, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8A, $8B, $8B, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8D, $8B, $8B, $8B, $8E, $8F, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $90, $8B, $8B, $8B, $8B, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $92, $8B, $8B, $8B, $8B, $93, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $94, $8B, $8B, $8B, $8B, $95, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $96, $97, $98, $99, $9A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $9B, $9C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $9D, $9E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_9
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $85, $86, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $87, $88, $89, $8A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8B, $88, $88, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8D, $88, $88, $88, $88, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8F, $88, $88, $88, $88, $90, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $91, $92, $93, $94, $95, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $96, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $98, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_10
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $8C, $8D, $8E, $8E, $8F, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $90, $8E, $8E, $8E, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $92, $93, $8E, $94, $95, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $96, $97, $98, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $99, $9A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_11
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8B, $89, $89, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8D, $8E, $8F, $90, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $91, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_12
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $89, $8A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8B, $89, $8C, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8E, $8F, $90, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_13
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $8B, $89, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8D, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_14
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $88, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $89, $87, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8C, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_15
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $85, $86, $87, $88, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $89, $87, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8C, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_16
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $88, $89, $8A, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8B, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $8D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $8E, $8F, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $90, $91, $92, $93, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $94, $95, $96, $97, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $9A, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9B, $9C, $9D, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_17
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8C, $8D, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $8F, $90, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $91, $92, $93, $94, $95, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $96, $97, $98, $99, $9A, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9B, $9C, $9D, $9E, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9F, $A0, $A1, $9E, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A2, $A3, $A4, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_18
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $81, $82, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $81, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8C, $8D, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $8F, $90, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $91, $92, $93, $94, $95, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $96, $80, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $9A, $9B, $9C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9D, $9E, $9F, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A0, $A1, $A2, $A3, $A3, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A3, $A4, $A5, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A6, $A7, $A8, $A3, $A3, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A9, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $AA, $AB, $AC, $A3, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_19
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $84, $85, $86, $87, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $8C, $8D, $8E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $8F, $90, $80, $91, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $92, $93, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $94, $95, $96, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $9A, $9B, $9C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9D, $9E, $9F, $A0, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A1, $A2, $A3, $A4, $A5, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9E, $9E, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A7, $A8, $A9, $9E, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9E, $AA, $AB, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $AC, $AD, $AE, $9E, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9E, $AF, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $B0, $B1, $B2, $9E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_20
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $84, $85, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $86, $87, $88, $89, $8A, $8B, $8C, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8D, $8E, $8F, $90, $91, $92, $93, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $94, $95, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $96, $97, $80, $98, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $99, $9A, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9B, $9C, $9D, $9E, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9F, $A0, $A1, $A2, $A3, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $A5, $A6, $A7, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A8, $A9, $AA, $AB, $AC, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A5, $A5, $AD, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $AE, $AF, $B0, $A5, $A5, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A5, $B1, $B2, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $B3, $B4, $B5, $A5, $A5, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A5, $B6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $B7, $B8, $B9, $A5, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_21
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $85, $86, $87, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8C, $8D, $8E, $8F, $90, $91, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $93, $94, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $95, $96, $80, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9A, $9B, $9C, $9D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9E, $9F, $A0, $A1, $A2, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A3, $A4, $A5, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A7, $A8, $A9, $AA, $AB, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $A4, $AC, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $AD, $AE, $AF, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B0, $B1, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $B2, $B3, $B4, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B5, $80, $80, $80, $80, $80, $B6, $B7, $80, $80, $B8, $B9, $80, $80, $80, $BA, $BB, $BC, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_22
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $85, $86, $87, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8C, $8D, $8E, $8F, $90, $91, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $93, $94, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $95, $96, $80, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9A, $9B, $9C, $9D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9E, $9F, $A0, $A1, $A2, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A3, $A4, $A5, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A7, $A8, $A9, $AA, $AB, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $A4, $AC, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $AD, $AE, $AF, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B0, $B1, $80, $80, $80, $80, $AD, $B2, $80, $80, $B3, $B4, $80, $80, $B5, $B6, $B7, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B8, $80, $80, $80, $80, $80, $B9, $BA, $BB, $BC, $BD, $BE, $80, $80, $80, $BF, $C0, $C1, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_23
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $85, $86, $87, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8C, $8D, $8E, $8F, $90, $91, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $93, $94, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $95, $96, $80, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9A, $9B, $9C, $9D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9E, $9F, $A0, $A1, $A2, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A3, $A4, $A5, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A7, $A8, $A9, $AA, $AB, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $A4, $AC, $80, $80, $80, $80, $80, $AD, $80, $80, $AE, $AF, $80, $80, $B0, $B1, $B2, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B3, $B4, $80, $80, $80, $80, $B5, $B6, $80, $B7, $B8, $B9, $80, $80, $BA, $BB, $BC, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $BD, $80, $80, $80, $80, $80, $BE, $BF, $C0, $C1, $C2, $C3, $80, $80, $80, $C4, $C5, $C6, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
.test_24
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $81, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $82, $83, $84, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $85, $86, $87, $88, $89, $8A, $8B, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $8C, $8D, $8E, $8F, $90, $91, $92, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $93, $94, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $95, $96, $80, $97, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $98, $99, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $9A, $9B, $9C, $9D, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $9E, $9F, $A0, $A1, $A2, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A3, $A4, $A5, $A6, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $80, $A7, $A8, $A9, $AA, $AB, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $A4, $AC, $80, $80, $80, $80, $80, $AD, $80, $80, $AE, $AF, $80, $80, $B0, $B1, $B2, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $B3, $B4, $80, $80, $80, $80, $B5, $B6, $80, $B7, $B8, $B9, $80, $80, $BA, $BB, $BC, $A4, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
DB $A4, $BD, $80, $80, $80, $80, $80, $BE, $BF, $C0, $C1, $C2, $C3, $80, $80, $80, $C4, $C5, $C6, $A4, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
|
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
/*
$Log$
Revision 1.2 2007/10/12 13:36:27 cvetan
Coding convention fixes from Stefan
Revision 1.1 2007/09/17 10:23:31 cvetan
New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
*/
////////////////////////////////////////////////////////////////////////
////
//// AliTPCMonitorMappingHandler class
////
//// Class for handling mapping information TPC
////
//// The mapping information for the TPC front end electornics (pads, front end cards)
//// are handled by this class.
//// The information from the design mapping and from the hardware address can be
//// cross checked in the TPCMonitor.C.
//// Malfunctioning front end cards can be identified by looking at single channels
//// displayed with the TPCMonitor.
////
////
//// Authors: Roland Bramm,
//// Stefan Kniege, IKF, Frankfurt
////
/////////////////////////////////////////////////////////////////////////
#include <cstdlib>
#include "AliTPCMonitorMappingHandler.h"
#include "TH1.h"
#include "TLegend.h"
#include <TMath.h>
#include "AliLog.h"
#include <Riostream.h>
#include <string>
#include <TString.h>
using std::ifstream;
using std::ios;
ClassImp(AliTPCMonitorMappingHandler)
//_____________________________________________________________________________________________
AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const Char_t* name, const Char_t* title):
TNamed(name,title),
fnumofChannels(0),
fmaxHWAdress(0),
fsizeofArray(0)
{
// Constructor : Initialize mapping arrays
for(Int_t in = 0; in<159; ++in)
for(Int_t jn = 0; jn<150; ++jn)
fmappingChannelinRow[in][jn] = 0;
for(Int_t i = 0; i<7000; ++i){
for(Int_t j = 0; j<8; ++j)
fu2ftestmapping[i][j] = 0;
for(Int_t j = 0; j<128; ++j)
fecGainMap[i][j] = 0.;
}
for(Int_t i = 0; i<24000; ++i){
for(Int_t j = 0; j<2; ++j)
fMapHwFECglobal[i][j]=0;
for (Int_t j=0; j<11; ++j)
fmapping[i][j]=0;
fmapping[i][1]=-1;
}
}
//____________________________________________________________________________
AliTPCMonitorMappingHandler::AliTPCMonitorMappingHandler(const AliTPCMonitorMappingHandler &maphand) :
TNamed(maphand.GetName(),maphand.GetTitle()),
fnumofChannels(maphand.fnumofChannels),
fmaxHWAdress(maphand.fmaxHWAdress),
fsizeofArray(maphand.fsizeofArray)
{
// copy constructor
for(Int_t in = 0; in<159; ++in)
for(Int_t jn = 0; jn<150; ++jn)
fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
for(Int_t i = 0; i<7000; ++i){
for(Int_t j = 0; j<8; ++j)
fu2ftestmapping[i][j] = maphand.fu2ftestmapping[i][j];
for(Int_t j = 0; j<128; ++j)
fecGainMap[i][j] = maphand.fecGainMap[i][j];
}
for(Int_t i = 0; i<24000; ++i){
for (Int_t j = 0; j<2; ++j)
fMapHwFECglobal[i][j]=maphand.fMapHwFECglobal[i][j];
for (Int_t j=0; j<11; ++j)
fmapping[i][j] = maphand.fmapping[i][j];
}
}
//____________________________________________________________________________
AliTPCMonitorMappingHandler &AliTPCMonitorMappingHandler:: operator= (const AliTPCMonitorMappingHandler& maphand)
{
// assignment operator
if (this == &maphand) return *this;
fnumofChannels=maphand.fnumofChannels;
fmaxHWAdress=maphand.fmaxHWAdress;
fsizeofArray=maphand.fsizeofArray;
for(Int_t in = 0; in<159; ++in)
for(Int_t jn = 0; jn<150; ++jn)
fmappingChannelinRow[in][jn] = maphand.fmappingChannelinRow[in][jn];
for(Int_t i = 0; i<7000; ++i){
for(Int_t j = 0; j<8; ++j)
fu2ftestmapping[i][j]=maphand.fu2ftestmapping[i][j];
for(Int_t j = 0; j<128; ++j)
fecGainMap[i][j] = maphand.fecGainMap[i][j];
}
for(Int_t i = 0; i<24000; ++i){
for(Int_t j = 0; j<2; ++j)
fMapHwFECglobal[i][j] = maphand.fMapHwFECglobal[i][j];
for (Int_t j=0; j<11; ++j)
fmapping[i][j] = maphand.fmapping[i][j];
}
return *this;
}
//_____________________________________________________________________________________________
AliTPCMonitorMappingHandler::~AliTPCMonitorMappingHandler()
{
// Destructor
}
//_____________________________________________________________________________________________
void AliTPCMonitorMappingHandler::ReadMapping(const char* mapfile)
{
// Read global Mapping file
// Format of data in mapping file:
// column 0: hadrware address
// column 1: readout index in IROC/OROC
// column 2: global pad row number (0-158)
// column 3 pad number in row
// column 4: connector
// column 5: pin
// column 6: fec number in IROC/OROC
// column 7: fec channel
// column 8: fec connector
// column 9: altro channel
// column 10: altro chip
// Mapping data for a given hardware address are placed at the
// index corresponding to the value of the hardware address in
// the fmapping array..
// The mapping information for the hardware address 'hwaddr'
// can hence be found in fmapping[hwaddr]
Int_t version = -1;
Int_t actPos = 0;
ifstream infile(mapfile,ios::in);
// printf("file1: %s\n",mapfile);
if (!infile.is_open()) return;
// int numLines = 0;
// std::string line;
// while ( std::getline(infile, line) )
// ++numLines;
// infile.seekg(0,ios::beg);
// infile.clear();
// printf("file: %s - %d\n",mapfile,numLines);
infile >> version;
// --numLines;
infile >> fnumofChannels;
// --numLines;
infile >> fmaxHWAdress;
fsizeofArray = fmaxHWAdress;
// --numLines;
//consistency check
fnumofChannels=TMath::Abs(fnumofChannels);
// fnumofChannels=TMath::Min(fnumofChannels,numLines);
Int_t val=0;
for(Int_t i = 0; i < fnumofChannels ; i++) {
//get hw address
infile >> actPos;
//set first value of hw address to channel number
if (actPos>0 && actPos<24000)
fmapping[actPos][0] = (Short_t)i;
//loop over channel parameters
for(Int_t j = 1 ; j < 11 ; j++) {
infile >> val;
if (actPos>0 && actPos<24000)
fmapping[actPos][j] = (Short_t)val;
}
}
infile.close();
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::ReadFECMapping(const char* u2ftestfile)
{
// Read in Mapping of global FEC numbers to branches, rcu patches etc.
// Format in Mapping file
// column 0: global card number (set to 0 if card number does not exist)
// column 1: side of the TPC
// column 2: sector on the side (0-17)
// column 3: rcu in the sector (0-5)
// column 4: fec number in rcu (0-24)
// column 5: fec number in branch (0-12)
// column 6: branch number (0,1)
// column 7: local hardware address of first channel (not used)
// Order of data is kept in fu2ftestmapping
ifstream datin(u2ftestfile);
Int_t carry = 0;
Int_t ncards = 0;
for(Int_t ind = 0; ind<7000; ind++) {
for(Int_t entr = 0; entr<8; entr++) {
datin >> carry ;
fu2ftestmapping[ind][entr] = carry ;
if(entr==0 && carry!=0) ncards++;
}
}
return ncards ;
}
//_____________________________________________________________________________________________
void AliTPCMonitorMappingHandler::ReadfecHwMap(Int_t sector)
{
// Create mapping of global FEC numbers to hardware addresses for a given sector
Int_t fside =0;
Int_t fsector = 0;
Int_t fec = 0;
Int_t branch = 0;
Int_t rcupatch = 0;
Int_t altrchann = 0;
Int_t altrchip = 0;
Int_t nextHwAddress = 0;
Int_t nfecs = 0;
if(sector/18==0) fside =65;
else fside =67;
if(sector>18) fsector= sector-18;
else fsector= sector ;
for(Int_t ind = 0; ind<7000; ind++) {
if((Int_t)U2fGetSide(ind)==fside && U2fGetSector(ind)==fsector) {
nfecs++;
fec = U2fGetFECinBranch(ind);
branch = U2fGetBranch(ind);
rcupatch = U2fGetRCU(ind);
for(Int_t ch = 0; ch<128; ch++) {
altrchann = ch%16;
altrchip = ch/16;
nextHwAddress = ( ((branch&1)<<11) + (fec<<7) + (altrchip<<4) + (altrchann) + ((rcupatch-1)<<12) );
if (nextHwAddress<0 || nextHwAddress>=24000) continue;
fMapHwFECglobal[nextHwAddress][0] = ind;
fMapHwFECglobal[nextHwAddress][1] = ch ;
}
}
}
}
//_____________________________________________________________________________________________
void AliTPCMonitorMappingHandler::ReadfecGainMap(const char* fecgainmap)
{
// Read global gain calibration pap
// Format in file :
// colummn 0 : FEC number
// colums 1-128 : gain calibration factors
ifstream datin(fecgainmap);
Int_t fecnr = 0;
Float_t val = 0.0 ;
while(!datin.eof())
{
datin >> fecnr ;
for(Int_t in = 0; in<128; in++)
{
datin >> val ;
if (fecnr<0 || fecnr>=7000) continue;
fecGainMap[fecnr][in] = val;
}
}
}
//_____________________________________________________________________________________________
void AliTPCMonitorMappingHandler::ReadRowMappingGlob(const char* fpathtoMappingRowfile)
{
// Read mapping of hardware addresses in rows
// Format of file:
// column 0: global row number (0-158)
// column 1: number of pads in this row (npads)
// column 2-npads: hardware addresses for these pads
TString readcarry;
TString readcarry2;
ifstream in(fpathtoMappingRowfile,ios::in);
for(Int_t i = 0; i < 159 ; i++) {
in >> readcarry; // row number
in >> readcarry2; // numof pads
fmappingChannelinRow[i][0] = readcarry2.Atoi();
fmappingChannelinRow[i][1] = TMath::Min(TMath::Abs(readcarry.Atoi()),140); //maximum number of pads is 140
for(Int_t j = 2 ; j < fmappingChannelinRow[i][0]+2 ; j++) {
in >> readcarry;
fmappingChannelinRow[i][j] = readcarry.Atoi();
}
}
in.close();
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetNumOfChannels() const
{
// Return number of channels
return fnumofChannels;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetSizeofArray() const
{
// Return sise of global mapping fmapping array.
// Value orresponds to max value of hardware addresses
return fsizeofArray;
}
//_____________________________________________________________________________________________
const Short_t* AliTPCMonitorMappingHandler::GetLine(Int_t hwaddr) const
{
// Return pointer to mapping array for the hardware address hwaddr
const Short_t* retval=0x0;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetIndex(Int_t hwaddr) const
{
// Return readout index for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][1];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetPadRow(Int_t hwaddr) const
{
// Return global pad row for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][2];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetPad(Int_t hwaddr) const
{
// Return pad number in row for the hardware address hwaddr
Int_t retval;
if(hwaddr < fsizeofArray)
retval = fmapping[hwaddr][3];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetConnector(Int_t hwaddr) const
{
// Return connector for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][4];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetPin(Int_t hwaddr) const
{
// Return pin for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][5];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetFEC(Int_t hwaddr) const
{
// Return fec number in IROC/OROC for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][6];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetFECchannel(Int_t hwaddr) const
{
// Return FEC channel for the hardware address hwaddr
Int_t retval;
if(hwaddr < fsizeofArray)
retval = fmapping[hwaddr][7];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetFECconnector(Int_t hwaddr) const
{
// Return FEC connector for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][8];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetAltroChannel(Int_t hwaddr) const
{
// Return Altro channel for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][9];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetAltro(Int_t hwaddr) const
{
// Return Altro chip number in FEC for the hardware address hwaddr
Int_t retval;
if(hwaddr <= fsizeofArray)
retval = fmapping[hwaddr][10];
else
retval = 0;
return retval;
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetNumofPads(Int_t row)
{
// Return number of pads in row
if(row>=0&&row<159)
return fmappingChannelinRow[row][0];
else {
AliError("Wrong row number");
return 0;
}
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::GetPadAddInRow(Int_t row,Int_t pad )
{
// Return hardware address for given pad in row
if(row>=0&&row<159)
return fmappingChannelinRow[row][pad+2];
else {
AliError("Wrong row number");
return 0;
}
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetFECnr(Int_t index) const
{
// Return FEC number for index (FEC number should be equal to index)
return fu2ftestmapping[index][0];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetSide(Int_t fecnr) const
{
// Return side on which FEC is installed
return fu2ftestmapping[fecnr][1];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetSector(Int_t fecnr) const
{
// Return sector in which FEC is installed
return fu2ftestmapping[fecnr][2];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetRCU(Int_t fecnr) const
{
// Rerurn rcu patch in which FEC is installed
return fu2ftestmapping[fecnr][3];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetFECinRCU(Int_t fecnr) const
{
// Return index of FEC in RCU (0-25)
return fu2ftestmapping[fecnr][4];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetFECinBranch(Int_t fecnr) const
{
// Return index of FEC in branch (0-12)
return fu2ftestmapping[fecnr][5];
}
//_____________________________________________________________________________________________
Int_t AliTPCMonitorMappingHandler::U2fGetBranch(Int_t fecnr) const
{
// Return branch in which FEC is installed (0,1)
return fu2ftestmapping[fecnr][6];
}
|
; *******************************************************************************************
; *******************************************************************************************
;
; Name : tokenise.asm
; Purpose : Tokenise ASCII string
; Date : 2nd September 2019
; Author : Paul Robson (paul@robsons.org.uk)
;
; *******************************************************************************************
; *******************************************************************************************
; *******************************************************************************************
;
; Tokenise ASCIIZ string at (zGenPtr). Return length in A
;
; *******************************************************************************************
TokeniseString:
sta zGenPtr ; save source
stx zGenPtr+1
ldy #0 ; source
ldx #3 ; target
;
sty TokeniseBuffer+0 ; write three NULLs. So it looks like
sty TokeniseBuffer+1 ; there's a line number zero.
sty TokeniseBuffer+2
;
; Main tokenising loop
;
_TSMainLoop:
;
_TSSkipSpaces:
lda (zGenPtr),y ; skip over spaces.
iny
cmp #" "
beq _TSSkipSpaces
;
cmp #"0" ; is it a constant
bcc _TSNotConstant
cmp #"9"+1
bcs _TSNotConstant
;
dey ; point back to start
jsr TokeniseConstant ; tokenise a constant
bra _TSMainLoop ; and loop back.
;
; Check end and string/decimal sequences.
;
_TSNotConstant:
;
cmp #32 ; end of line.
bcc _TSExit
cmp #'"' ; quoted string
beq _TSQuotedString
cmp #'.' ; decimal.
beq _TSDecimal
jsr TOKCapitalise ; make U/C
cmp #"R" ; is it R, if so check for REM ?
bne _TSNoRemCheck
jsr TOKCheckREM
bcs _TSMainLoop ; and if REM okay, go back.
_TSNoRemCheck:
;
dey ; point to character
;
jsr TokeniseKeyword ; try to tokenise a keyword.
bcs _TSMainLoop ; true if tokenised okay.
;
lda (zGenPtr),y ; get character
jsr TOKCapitalise
cmp #"A" ; is it A-Z, if so it's an alphanumeric sequence.
bcc _TSSingle
cmp #"Z"+1
bcc _TSAlphaNumeric
;
_TSSingle:
iny ; skip over output
and #63 ; make 6 bit ASCII
ora #128
beq _TSMainLoop ; ignore @, which doesn't tokenise.
sta TokeniseBuffer,x
inx
bra _TSMainLoop
;
; Copy an alphanumeric sequence that follows.
;
_TSAlphaNumeric:
lda (zGenPtr),y ; get
jsr TOKCapitalise
cmp #"0" ; check 0-9
bcc _TSMainLoop
cmp #"9"+1
bcc _TSANOkay
cmp #"A" ; check A-Z
bcc _TSMainLoop
cmp #"Z"+1
bcs _TSMainLoop
and #63 ; write it out
_TSANOkay:
sta TokeniseBuffer,x
inx
iny
bra _TSAlphaNumeric
;
; Add NULL and exit.
;
_TSExit:lda #0 ; mark end of line.
sta TokeniseBuffer,x
txa ; return length of tokenised line in bytes.
rts
;
; Quoted string, ended by either another " or a control.
;
_TSQuotedString:
jsr TokeniseQuotedString
bra _TSMainLoop
;
; Decimal sequence.
;
_TSDecimal:
jsr TokeniseDecimalString
bra _TSMainLoop
;
; Check for REM, if so do it and return CS. (R) already checked.
;
TOKCheckREM:
lda (zGenPtr),y ; check E
jsr TOKCapitalise
cmp #"E"
bne _TCRFail
iny
lda (zGenPtr),y ; check M
dey
jsr TOKCapitalise
cmp #"M"
bne _TCRFail
;
iny ; point to first character
iny
jsr TokeniseREMString ; tokenise REM
sec
rts
;
_TCRFail:
clc
rts
;
; Token capitaliser.
;
TOKCapitalise:
cmp #"a"
bcc _TOKCExit
cmp #"z"+1
bcs _TOKCExit
eor #$20
_TOKCExit:
rts
|
_shutdown: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "user.h"
#include "stat.h"
int main()
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
printf(1, "Shutting Down:\n");
11: 83 ec 08 sub $0x8,%esp
14: 68 d1 07 00 00 push $0x7d1
19: 6a 01 push $0x1
1b: e8 fb 03 00 00 call 41b <printf>
20: 83 c4 10 add $0x10,%esp
shutdown();
23: e8 fc 02 00 00 call 324 <shutdown>
exit();
28: e8 57 02 00 00 call 284 <exit>
0000002d <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
2d: 55 push %ebp
2e: 89 e5 mov %esp,%ebp
30: 57 push %edi
31: 53 push %ebx
asm volatile("cld; rep stosb" :
32: 8b 4d 08 mov 0x8(%ebp),%ecx
35: 8b 55 10 mov 0x10(%ebp),%edx
38: 8b 45 0c mov 0xc(%ebp),%eax
3b: 89 cb mov %ecx,%ebx
3d: 89 df mov %ebx,%edi
3f: 89 d1 mov %edx,%ecx
41: fc cld
42: f3 aa rep stos %al,%es:(%edi)
44: 89 ca mov %ecx,%edx
46: 89 fb mov %edi,%ebx
48: 89 5d 08 mov %ebx,0x8(%ebp)
4b: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
4e: 90 nop
4f: 5b pop %ebx
50: 5f pop %edi
51: 5d pop %ebp
52: c3 ret
00000053 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
53: 55 push %ebp
54: 89 e5 mov %esp,%ebp
56: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
59: 8b 45 08 mov 0x8(%ebp),%eax
5c: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
5f: 90 nop
60: 8b 45 08 mov 0x8(%ebp),%eax
63: 8d 50 01 lea 0x1(%eax),%edx
66: 89 55 08 mov %edx,0x8(%ebp)
69: 8b 55 0c mov 0xc(%ebp),%edx
6c: 8d 4a 01 lea 0x1(%edx),%ecx
6f: 89 4d 0c mov %ecx,0xc(%ebp)
72: 0f b6 12 movzbl (%edx),%edx
75: 88 10 mov %dl,(%eax)
77: 0f b6 00 movzbl (%eax),%eax
7a: 84 c0 test %al,%al
7c: 75 e2 jne 60 <strcpy+0xd>
;
return os;
7e: 8b 45 fc mov -0x4(%ebp),%eax
}
81: c9 leave
82: c3 ret
00000083 <strcmp>:
int
strcmp(const char *p, const char *q)
{
83: 55 push %ebp
84: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
86: eb 08 jmp 90 <strcmp+0xd>
p++, q++;
88: 83 45 08 01 addl $0x1,0x8(%ebp)
8c: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
90: 8b 45 08 mov 0x8(%ebp),%eax
93: 0f b6 00 movzbl (%eax),%eax
96: 84 c0 test %al,%al
98: 74 10 je aa <strcmp+0x27>
9a: 8b 45 08 mov 0x8(%ebp),%eax
9d: 0f b6 10 movzbl (%eax),%edx
a0: 8b 45 0c mov 0xc(%ebp),%eax
a3: 0f b6 00 movzbl (%eax),%eax
a6: 38 c2 cmp %al,%dl
a8: 74 de je 88 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
aa: 8b 45 08 mov 0x8(%ebp),%eax
ad: 0f b6 00 movzbl (%eax),%eax
b0: 0f b6 d0 movzbl %al,%edx
b3: 8b 45 0c mov 0xc(%ebp),%eax
b6: 0f b6 00 movzbl (%eax),%eax
b9: 0f b6 c0 movzbl %al,%eax
bc: 29 c2 sub %eax,%edx
be: 89 d0 mov %edx,%eax
}
c0: 5d pop %ebp
c1: c3 ret
000000c2 <strlen>:
uint
strlen(char *s)
{
c2: 55 push %ebp
c3: 89 e5 mov %esp,%ebp
c5: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
c8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
cf: eb 04 jmp d5 <strlen+0x13>
d1: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d5: 8b 55 fc mov -0x4(%ebp),%edx
d8: 8b 45 08 mov 0x8(%ebp),%eax
db: 01 d0 add %edx,%eax
dd: 0f b6 00 movzbl (%eax),%eax
e0: 84 c0 test %al,%al
e2: 75 ed jne d1 <strlen+0xf>
;
return n;
e4: 8b 45 fc mov -0x4(%ebp),%eax
}
e7: c9 leave
e8: c3 ret
000000e9 <memset>:
void*
memset(void *dst, int c, uint n)
{
e9: 55 push %ebp
ea: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
ec: 8b 45 10 mov 0x10(%ebp),%eax
ef: 50 push %eax
f0: ff 75 0c pushl 0xc(%ebp)
f3: ff 75 08 pushl 0x8(%ebp)
f6: e8 32 ff ff ff call 2d <stosb>
fb: 83 c4 0c add $0xc,%esp
return dst;
fe: 8b 45 08 mov 0x8(%ebp),%eax
}
101: c9 leave
102: c3 ret
00000103 <strchr>:
char*
strchr(const char *s, char c)
{
103: 55 push %ebp
104: 89 e5 mov %esp,%ebp
106: 83 ec 04 sub $0x4,%esp
109: 8b 45 0c mov 0xc(%ebp),%eax
10c: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
10f: eb 14 jmp 125 <strchr+0x22>
if(*s == c)
111: 8b 45 08 mov 0x8(%ebp),%eax
114: 0f b6 00 movzbl (%eax),%eax
117: 3a 45 fc cmp -0x4(%ebp),%al
11a: 75 05 jne 121 <strchr+0x1e>
return (char*)s;
11c: 8b 45 08 mov 0x8(%ebp),%eax
11f: eb 13 jmp 134 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
121: 83 45 08 01 addl $0x1,0x8(%ebp)
125: 8b 45 08 mov 0x8(%ebp),%eax
128: 0f b6 00 movzbl (%eax),%eax
12b: 84 c0 test %al,%al
12d: 75 e2 jne 111 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
12f: b8 00 00 00 00 mov $0x0,%eax
}
134: c9 leave
135: c3 ret
00000136 <gets>:
char*
gets(char *buf, int max)
{
136: 55 push %ebp
137: 89 e5 mov %esp,%ebp
139: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
13c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
143: eb 42 jmp 187 <gets+0x51>
cc = read(0, &c, 1);
145: 83 ec 04 sub $0x4,%esp
148: 6a 01 push $0x1
14a: 8d 45 ef lea -0x11(%ebp),%eax
14d: 50 push %eax
14e: 6a 00 push $0x0
150: e8 47 01 00 00 call 29c <read>
155: 83 c4 10 add $0x10,%esp
158: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
15b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
15f: 7e 33 jle 194 <gets+0x5e>
break;
buf[i++] = c;
161: 8b 45 f4 mov -0xc(%ebp),%eax
164: 8d 50 01 lea 0x1(%eax),%edx
167: 89 55 f4 mov %edx,-0xc(%ebp)
16a: 89 c2 mov %eax,%edx
16c: 8b 45 08 mov 0x8(%ebp),%eax
16f: 01 c2 add %eax,%edx
171: 0f b6 45 ef movzbl -0x11(%ebp),%eax
175: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
177: 0f b6 45 ef movzbl -0x11(%ebp),%eax
17b: 3c 0a cmp $0xa,%al
17d: 74 16 je 195 <gets+0x5f>
17f: 0f b6 45 ef movzbl -0x11(%ebp),%eax
183: 3c 0d cmp $0xd,%al
185: 74 0e je 195 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
187: 8b 45 f4 mov -0xc(%ebp),%eax
18a: 83 c0 01 add $0x1,%eax
18d: 3b 45 0c cmp 0xc(%ebp),%eax
190: 7c b3 jl 145 <gets+0xf>
192: eb 01 jmp 195 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
194: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
195: 8b 55 f4 mov -0xc(%ebp),%edx
198: 8b 45 08 mov 0x8(%ebp),%eax
19b: 01 d0 add %edx,%eax
19d: c6 00 00 movb $0x0,(%eax)
return buf;
1a0: 8b 45 08 mov 0x8(%ebp),%eax
}
1a3: c9 leave
1a4: c3 ret
000001a5 <stat>:
int
stat(char *n, struct stat *st)
{
1a5: 55 push %ebp
1a6: 89 e5 mov %esp,%ebp
1a8: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1ab: 83 ec 08 sub $0x8,%esp
1ae: 6a 00 push $0x0
1b0: ff 75 08 pushl 0x8(%ebp)
1b3: e8 0c 01 00 00 call 2c4 <open>
1b8: 83 c4 10 add $0x10,%esp
1bb: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
1be: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1c2: 79 07 jns 1cb <stat+0x26>
return -1;
1c4: b8 ff ff ff ff mov $0xffffffff,%eax
1c9: eb 25 jmp 1f0 <stat+0x4b>
r = fstat(fd, st);
1cb: 83 ec 08 sub $0x8,%esp
1ce: ff 75 0c pushl 0xc(%ebp)
1d1: ff 75 f4 pushl -0xc(%ebp)
1d4: e8 03 01 00 00 call 2dc <fstat>
1d9: 83 c4 10 add $0x10,%esp
1dc: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
1df: 83 ec 0c sub $0xc,%esp
1e2: ff 75 f4 pushl -0xc(%ebp)
1e5: e8 c2 00 00 00 call 2ac <close>
1ea: 83 c4 10 add $0x10,%esp
return r;
1ed: 8b 45 f0 mov -0x10(%ebp),%eax
}
1f0: c9 leave
1f1: c3 ret
000001f2 <atoi>:
int
atoi(const char *s)
{
1f2: 55 push %ebp
1f3: 89 e5 mov %esp,%ebp
1f5: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
1f8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
1ff: eb 25 jmp 226 <atoi+0x34>
n = n*10 + *s++ - '0';
201: 8b 55 fc mov -0x4(%ebp),%edx
204: 89 d0 mov %edx,%eax
206: c1 e0 02 shl $0x2,%eax
209: 01 d0 add %edx,%eax
20b: 01 c0 add %eax,%eax
20d: 89 c1 mov %eax,%ecx
20f: 8b 45 08 mov 0x8(%ebp),%eax
212: 8d 50 01 lea 0x1(%eax),%edx
215: 89 55 08 mov %edx,0x8(%ebp)
218: 0f b6 00 movzbl (%eax),%eax
21b: 0f be c0 movsbl %al,%eax
21e: 01 c8 add %ecx,%eax
220: 83 e8 30 sub $0x30,%eax
223: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
226: 8b 45 08 mov 0x8(%ebp),%eax
229: 0f b6 00 movzbl (%eax),%eax
22c: 3c 2f cmp $0x2f,%al
22e: 7e 0a jle 23a <atoi+0x48>
230: 8b 45 08 mov 0x8(%ebp),%eax
233: 0f b6 00 movzbl (%eax),%eax
236: 3c 39 cmp $0x39,%al
238: 7e c7 jle 201 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
23a: 8b 45 fc mov -0x4(%ebp),%eax
}
23d: c9 leave
23e: c3 ret
0000023f <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
23f: 55 push %ebp
240: 89 e5 mov %esp,%ebp
242: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
245: 8b 45 08 mov 0x8(%ebp),%eax
248: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
24b: 8b 45 0c mov 0xc(%ebp),%eax
24e: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
251: eb 17 jmp 26a <memmove+0x2b>
*dst++ = *src++;
253: 8b 45 fc mov -0x4(%ebp),%eax
256: 8d 50 01 lea 0x1(%eax),%edx
259: 89 55 fc mov %edx,-0x4(%ebp)
25c: 8b 55 f8 mov -0x8(%ebp),%edx
25f: 8d 4a 01 lea 0x1(%edx),%ecx
262: 89 4d f8 mov %ecx,-0x8(%ebp)
265: 0f b6 12 movzbl (%edx),%edx
268: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
26a: 8b 45 10 mov 0x10(%ebp),%eax
26d: 8d 50 ff lea -0x1(%eax),%edx
270: 89 55 10 mov %edx,0x10(%ebp)
273: 85 c0 test %eax,%eax
275: 7f dc jg 253 <memmove+0x14>
*dst++ = *src++;
return vdst;
277: 8b 45 08 mov 0x8(%ebp),%eax
}
27a: c9 leave
27b: c3 ret
0000027c <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
27c: b8 01 00 00 00 mov $0x1,%eax
281: cd 40 int $0x40
283: c3 ret
00000284 <exit>:
SYSCALL(exit)
284: b8 02 00 00 00 mov $0x2,%eax
289: cd 40 int $0x40
28b: c3 ret
0000028c <wait>:
SYSCALL(wait)
28c: b8 03 00 00 00 mov $0x3,%eax
291: cd 40 int $0x40
293: c3 ret
00000294 <pipe>:
SYSCALL(pipe)
294: b8 04 00 00 00 mov $0x4,%eax
299: cd 40 int $0x40
29b: c3 ret
0000029c <read>:
SYSCALL(read)
29c: b8 05 00 00 00 mov $0x5,%eax
2a1: cd 40 int $0x40
2a3: c3 ret
000002a4 <write>:
SYSCALL(write)
2a4: b8 10 00 00 00 mov $0x10,%eax
2a9: cd 40 int $0x40
2ab: c3 ret
000002ac <close>:
SYSCALL(close)
2ac: b8 15 00 00 00 mov $0x15,%eax
2b1: cd 40 int $0x40
2b3: c3 ret
000002b4 <kill>:
SYSCALL(kill)
2b4: b8 06 00 00 00 mov $0x6,%eax
2b9: cd 40 int $0x40
2bb: c3 ret
000002bc <exec>:
SYSCALL(exec)
2bc: b8 07 00 00 00 mov $0x7,%eax
2c1: cd 40 int $0x40
2c3: c3 ret
000002c4 <open>:
SYSCALL(open)
2c4: b8 0f 00 00 00 mov $0xf,%eax
2c9: cd 40 int $0x40
2cb: c3 ret
000002cc <mknod>:
SYSCALL(mknod)
2cc: b8 11 00 00 00 mov $0x11,%eax
2d1: cd 40 int $0x40
2d3: c3 ret
000002d4 <unlink>:
SYSCALL(unlink)
2d4: b8 12 00 00 00 mov $0x12,%eax
2d9: cd 40 int $0x40
2db: c3 ret
000002dc <fstat>:
SYSCALL(fstat)
2dc: b8 08 00 00 00 mov $0x8,%eax
2e1: cd 40 int $0x40
2e3: c3 ret
000002e4 <link>:
SYSCALL(link)
2e4: b8 13 00 00 00 mov $0x13,%eax
2e9: cd 40 int $0x40
2eb: c3 ret
000002ec <mkdir>:
SYSCALL(mkdir)
2ec: b8 14 00 00 00 mov $0x14,%eax
2f1: cd 40 int $0x40
2f3: c3 ret
000002f4 <chdir>:
SYSCALL(chdir)
2f4: b8 09 00 00 00 mov $0x9,%eax
2f9: cd 40 int $0x40
2fb: c3 ret
000002fc <dup>:
SYSCALL(dup)
2fc: b8 0a 00 00 00 mov $0xa,%eax
301: cd 40 int $0x40
303: c3 ret
00000304 <getpid>:
SYSCALL(getpid)
304: b8 0b 00 00 00 mov $0xb,%eax
309: cd 40 int $0x40
30b: c3 ret
0000030c <getppid>:
SYSCALL(getppid)
30c: b8 18 00 00 00 mov $0x18,%eax
311: cd 40 int $0x40
313: c3 ret
00000314 <getsyscallinfo>:
SYSCALL(getsyscallinfo)
314: b8 19 00 00 00 mov $0x19,%eax
319: cd 40 int $0x40
31b: c3 ret
0000031c <getAllPids>:
SYSCALL(getAllPids)
31c: b8 16 00 00 00 mov $0x16,%eax
321: cd 40 int $0x40
323: c3 ret
00000324 <shutdown>:
SYSCALL(shutdown)
324: b8 17 00 00 00 mov $0x17,%eax
329: cd 40 int $0x40
32b: c3 ret
0000032c <sbrk>:
SYSCALL(sbrk)
32c: b8 0c 00 00 00 mov $0xc,%eax
331: cd 40 int $0x40
333: c3 ret
00000334 <sleep>:
SYSCALL(sleep)
334: b8 0d 00 00 00 mov $0xd,%eax
339: cd 40 int $0x40
33b: c3 ret
0000033c <uptime>:
SYSCALL(uptime)
33c: b8 0e 00 00 00 mov $0xe,%eax
341: cd 40 int $0x40
343: c3 ret
00000344 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
344: 55 push %ebp
345: 89 e5 mov %esp,%ebp
347: 83 ec 18 sub $0x18,%esp
34a: 8b 45 0c mov 0xc(%ebp),%eax
34d: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
350: 83 ec 04 sub $0x4,%esp
353: 6a 01 push $0x1
355: 8d 45 f4 lea -0xc(%ebp),%eax
358: 50 push %eax
359: ff 75 08 pushl 0x8(%ebp)
35c: e8 43 ff ff ff call 2a4 <write>
361: 83 c4 10 add $0x10,%esp
}
364: 90 nop
365: c9 leave
366: c3 ret
00000367 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
367: 55 push %ebp
368: 89 e5 mov %esp,%ebp
36a: 53 push %ebx
36b: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
36e: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
375: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
379: 74 17 je 392 <printint+0x2b>
37b: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
37f: 79 11 jns 392 <printint+0x2b>
neg = 1;
381: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
388: 8b 45 0c mov 0xc(%ebp),%eax
38b: f7 d8 neg %eax
38d: 89 45 ec mov %eax,-0x14(%ebp)
390: eb 06 jmp 398 <printint+0x31>
} else {
x = xx;
392: 8b 45 0c mov 0xc(%ebp),%eax
395: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
398: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
39f: 8b 4d f4 mov -0xc(%ebp),%ecx
3a2: 8d 41 01 lea 0x1(%ecx),%eax
3a5: 89 45 f4 mov %eax,-0xc(%ebp)
3a8: 8b 5d 10 mov 0x10(%ebp),%ebx
3ab: 8b 45 ec mov -0x14(%ebp),%eax
3ae: ba 00 00 00 00 mov $0x0,%edx
3b3: f7 f3 div %ebx
3b5: 89 d0 mov %edx,%eax
3b7: 0f b6 80 30 0a 00 00 movzbl 0xa30(%eax),%eax
3be: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
3c2: 8b 5d 10 mov 0x10(%ebp),%ebx
3c5: 8b 45 ec mov -0x14(%ebp),%eax
3c8: ba 00 00 00 00 mov $0x0,%edx
3cd: f7 f3 div %ebx
3cf: 89 45 ec mov %eax,-0x14(%ebp)
3d2: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
3d6: 75 c7 jne 39f <printint+0x38>
if(neg)
3d8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3dc: 74 2d je 40b <printint+0xa4>
buf[i++] = '-';
3de: 8b 45 f4 mov -0xc(%ebp),%eax
3e1: 8d 50 01 lea 0x1(%eax),%edx
3e4: 89 55 f4 mov %edx,-0xc(%ebp)
3e7: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
3ec: eb 1d jmp 40b <printint+0xa4>
putc(fd, buf[i]);
3ee: 8d 55 dc lea -0x24(%ebp),%edx
3f1: 8b 45 f4 mov -0xc(%ebp),%eax
3f4: 01 d0 add %edx,%eax
3f6: 0f b6 00 movzbl (%eax),%eax
3f9: 0f be c0 movsbl %al,%eax
3fc: 83 ec 08 sub $0x8,%esp
3ff: 50 push %eax
400: ff 75 08 pushl 0x8(%ebp)
403: e8 3c ff ff ff call 344 <putc>
408: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
40b: 83 6d f4 01 subl $0x1,-0xc(%ebp)
40f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
413: 79 d9 jns 3ee <printint+0x87>
putc(fd, buf[i]);
}
415: 90 nop
416: 8b 5d fc mov -0x4(%ebp),%ebx
419: c9 leave
41a: c3 ret
0000041b <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
41b: 55 push %ebp
41c: 89 e5 mov %esp,%ebp
41e: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
421: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
428: 8d 45 0c lea 0xc(%ebp),%eax
42b: 83 c0 04 add $0x4,%eax
42e: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
431: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
438: e9 59 01 00 00 jmp 596 <printf+0x17b>
c = fmt[i] & 0xff;
43d: 8b 55 0c mov 0xc(%ebp),%edx
440: 8b 45 f0 mov -0x10(%ebp),%eax
443: 01 d0 add %edx,%eax
445: 0f b6 00 movzbl (%eax),%eax
448: 0f be c0 movsbl %al,%eax
44b: 25 ff 00 00 00 and $0xff,%eax
450: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
453: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
457: 75 2c jne 485 <printf+0x6a>
if(c == '%'){
459: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
45d: 75 0c jne 46b <printf+0x50>
state = '%';
45f: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
466: e9 27 01 00 00 jmp 592 <printf+0x177>
} else {
putc(fd, c);
46b: 8b 45 e4 mov -0x1c(%ebp),%eax
46e: 0f be c0 movsbl %al,%eax
471: 83 ec 08 sub $0x8,%esp
474: 50 push %eax
475: ff 75 08 pushl 0x8(%ebp)
478: e8 c7 fe ff ff call 344 <putc>
47d: 83 c4 10 add $0x10,%esp
480: e9 0d 01 00 00 jmp 592 <printf+0x177>
}
} else if(state == '%'){
485: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
489: 0f 85 03 01 00 00 jne 592 <printf+0x177>
if(c == 'd'){
48f: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
493: 75 1e jne 4b3 <printf+0x98>
printint(fd, *ap, 10, 1);
495: 8b 45 e8 mov -0x18(%ebp),%eax
498: 8b 00 mov (%eax),%eax
49a: 6a 01 push $0x1
49c: 6a 0a push $0xa
49e: 50 push %eax
49f: ff 75 08 pushl 0x8(%ebp)
4a2: e8 c0 fe ff ff call 367 <printint>
4a7: 83 c4 10 add $0x10,%esp
ap++;
4aa: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4ae: e9 d8 00 00 00 jmp 58b <printf+0x170>
} else if(c == 'x' || c == 'p'){
4b3: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
4b7: 74 06 je 4bf <printf+0xa4>
4b9: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
4bd: 75 1e jne 4dd <printf+0xc2>
printint(fd, *ap, 16, 0);
4bf: 8b 45 e8 mov -0x18(%ebp),%eax
4c2: 8b 00 mov (%eax),%eax
4c4: 6a 00 push $0x0
4c6: 6a 10 push $0x10
4c8: 50 push %eax
4c9: ff 75 08 pushl 0x8(%ebp)
4cc: e8 96 fe ff ff call 367 <printint>
4d1: 83 c4 10 add $0x10,%esp
ap++;
4d4: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4d8: e9 ae 00 00 00 jmp 58b <printf+0x170>
} else if(c == 's'){
4dd: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
4e1: 75 43 jne 526 <printf+0x10b>
s = (char*)*ap;
4e3: 8b 45 e8 mov -0x18(%ebp),%eax
4e6: 8b 00 mov (%eax),%eax
4e8: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
4eb: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
4ef: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4f3: 75 25 jne 51a <printf+0xff>
s = "(null)";
4f5: c7 45 f4 e1 07 00 00 movl $0x7e1,-0xc(%ebp)
while(*s != 0){
4fc: eb 1c jmp 51a <printf+0xff>
putc(fd, *s);
4fe: 8b 45 f4 mov -0xc(%ebp),%eax
501: 0f b6 00 movzbl (%eax),%eax
504: 0f be c0 movsbl %al,%eax
507: 83 ec 08 sub $0x8,%esp
50a: 50 push %eax
50b: ff 75 08 pushl 0x8(%ebp)
50e: e8 31 fe ff ff call 344 <putc>
513: 83 c4 10 add $0x10,%esp
s++;
516: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
51a: 8b 45 f4 mov -0xc(%ebp),%eax
51d: 0f b6 00 movzbl (%eax),%eax
520: 84 c0 test %al,%al
522: 75 da jne 4fe <printf+0xe3>
524: eb 65 jmp 58b <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
526: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
52a: 75 1d jne 549 <printf+0x12e>
putc(fd, *ap);
52c: 8b 45 e8 mov -0x18(%ebp),%eax
52f: 8b 00 mov (%eax),%eax
531: 0f be c0 movsbl %al,%eax
534: 83 ec 08 sub $0x8,%esp
537: 50 push %eax
538: ff 75 08 pushl 0x8(%ebp)
53b: e8 04 fe ff ff call 344 <putc>
540: 83 c4 10 add $0x10,%esp
ap++;
543: 83 45 e8 04 addl $0x4,-0x18(%ebp)
547: eb 42 jmp 58b <printf+0x170>
} else if(c == '%'){
549: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
54d: 75 17 jne 566 <printf+0x14b>
putc(fd, c);
54f: 8b 45 e4 mov -0x1c(%ebp),%eax
552: 0f be c0 movsbl %al,%eax
555: 83 ec 08 sub $0x8,%esp
558: 50 push %eax
559: ff 75 08 pushl 0x8(%ebp)
55c: e8 e3 fd ff ff call 344 <putc>
561: 83 c4 10 add $0x10,%esp
564: eb 25 jmp 58b <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
566: 83 ec 08 sub $0x8,%esp
569: 6a 25 push $0x25
56b: ff 75 08 pushl 0x8(%ebp)
56e: e8 d1 fd ff ff call 344 <putc>
573: 83 c4 10 add $0x10,%esp
putc(fd, c);
576: 8b 45 e4 mov -0x1c(%ebp),%eax
579: 0f be c0 movsbl %al,%eax
57c: 83 ec 08 sub $0x8,%esp
57f: 50 push %eax
580: ff 75 08 pushl 0x8(%ebp)
583: e8 bc fd ff ff call 344 <putc>
588: 83 c4 10 add $0x10,%esp
}
state = 0;
58b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
592: 83 45 f0 01 addl $0x1,-0x10(%ebp)
596: 8b 55 0c mov 0xc(%ebp),%edx
599: 8b 45 f0 mov -0x10(%ebp),%eax
59c: 01 d0 add %edx,%eax
59e: 0f b6 00 movzbl (%eax),%eax
5a1: 84 c0 test %al,%al
5a3: 0f 85 94 fe ff ff jne 43d <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
5a9: 90 nop
5aa: c9 leave
5ab: c3 ret
000005ac <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5ac: 55 push %ebp
5ad: 89 e5 mov %esp,%ebp
5af: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
5b2: 8b 45 08 mov 0x8(%ebp),%eax
5b5: 83 e8 08 sub $0x8,%eax
5b8: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5bb: a1 4c 0a 00 00 mov 0xa4c,%eax
5c0: 89 45 fc mov %eax,-0x4(%ebp)
5c3: eb 24 jmp 5e9 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5c5: 8b 45 fc mov -0x4(%ebp),%eax
5c8: 8b 00 mov (%eax),%eax
5ca: 3b 45 fc cmp -0x4(%ebp),%eax
5cd: 77 12 ja 5e1 <free+0x35>
5cf: 8b 45 f8 mov -0x8(%ebp),%eax
5d2: 3b 45 fc cmp -0x4(%ebp),%eax
5d5: 77 24 ja 5fb <free+0x4f>
5d7: 8b 45 fc mov -0x4(%ebp),%eax
5da: 8b 00 mov (%eax),%eax
5dc: 3b 45 f8 cmp -0x8(%ebp),%eax
5df: 77 1a ja 5fb <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5e1: 8b 45 fc mov -0x4(%ebp),%eax
5e4: 8b 00 mov (%eax),%eax
5e6: 89 45 fc mov %eax,-0x4(%ebp)
5e9: 8b 45 f8 mov -0x8(%ebp),%eax
5ec: 3b 45 fc cmp -0x4(%ebp),%eax
5ef: 76 d4 jbe 5c5 <free+0x19>
5f1: 8b 45 fc mov -0x4(%ebp),%eax
5f4: 8b 00 mov (%eax),%eax
5f6: 3b 45 f8 cmp -0x8(%ebp),%eax
5f9: 76 ca jbe 5c5 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
5fb: 8b 45 f8 mov -0x8(%ebp),%eax
5fe: 8b 40 04 mov 0x4(%eax),%eax
601: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
608: 8b 45 f8 mov -0x8(%ebp),%eax
60b: 01 c2 add %eax,%edx
60d: 8b 45 fc mov -0x4(%ebp),%eax
610: 8b 00 mov (%eax),%eax
612: 39 c2 cmp %eax,%edx
614: 75 24 jne 63a <free+0x8e>
bp->s.size += p->s.ptr->s.size;
616: 8b 45 f8 mov -0x8(%ebp),%eax
619: 8b 50 04 mov 0x4(%eax),%edx
61c: 8b 45 fc mov -0x4(%ebp),%eax
61f: 8b 00 mov (%eax),%eax
621: 8b 40 04 mov 0x4(%eax),%eax
624: 01 c2 add %eax,%edx
626: 8b 45 f8 mov -0x8(%ebp),%eax
629: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
62c: 8b 45 fc mov -0x4(%ebp),%eax
62f: 8b 00 mov (%eax),%eax
631: 8b 10 mov (%eax),%edx
633: 8b 45 f8 mov -0x8(%ebp),%eax
636: 89 10 mov %edx,(%eax)
638: eb 0a jmp 644 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
63a: 8b 45 fc mov -0x4(%ebp),%eax
63d: 8b 10 mov (%eax),%edx
63f: 8b 45 f8 mov -0x8(%ebp),%eax
642: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
644: 8b 45 fc mov -0x4(%ebp),%eax
647: 8b 40 04 mov 0x4(%eax),%eax
64a: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
651: 8b 45 fc mov -0x4(%ebp),%eax
654: 01 d0 add %edx,%eax
656: 3b 45 f8 cmp -0x8(%ebp),%eax
659: 75 20 jne 67b <free+0xcf>
p->s.size += bp->s.size;
65b: 8b 45 fc mov -0x4(%ebp),%eax
65e: 8b 50 04 mov 0x4(%eax),%edx
661: 8b 45 f8 mov -0x8(%ebp),%eax
664: 8b 40 04 mov 0x4(%eax),%eax
667: 01 c2 add %eax,%edx
669: 8b 45 fc mov -0x4(%ebp),%eax
66c: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
66f: 8b 45 f8 mov -0x8(%ebp),%eax
672: 8b 10 mov (%eax),%edx
674: 8b 45 fc mov -0x4(%ebp),%eax
677: 89 10 mov %edx,(%eax)
679: eb 08 jmp 683 <free+0xd7>
} else
p->s.ptr = bp;
67b: 8b 45 fc mov -0x4(%ebp),%eax
67e: 8b 55 f8 mov -0x8(%ebp),%edx
681: 89 10 mov %edx,(%eax)
freep = p;
683: 8b 45 fc mov -0x4(%ebp),%eax
686: a3 4c 0a 00 00 mov %eax,0xa4c
}
68b: 90 nop
68c: c9 leave
68d: c3 ret
0000068e <morecore>:
static Header*
morecore(uint nu)
{
68e: 55 push %ebp
68f: 89 e5 mov %esp,%ebp
691: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
694: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
69b: 77 07 ja 6a4 <morecore+0x16>
nu = 4096;
69d: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6a4: 8b 45 08 mov 0x8(%ebp),%eax
6a7: c1 e0 03 shl $0x3,%eax
6aa: 83 ec 0c sub $0xc,%esp
6ad: 50 push %eax
6ae: e8 79 fc ff ff call 32c <sbrk>
6b3: 83 c4 10 add $0x10,%esp
6b6: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
6b9: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
6bd: 75 07 jne 6c6 <morecore+0x38>
return 0;
6bf: b8 00 00 00 00 mov $0x0,%eax
6c4: eb 26 jmp 6ec <morecore+0x5e>
hp = (Header*)p;
6c6: 8b 45 f4 mov -0xc(%ebp),%eax
6c9: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
6cc: 8b 45 f0 mov -0x10(%ebp),%eax
6cf: 8b 55 08 mov 0x8(%ebp),%edx
6d2: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
6d5: 8b 45 f0 mov -0x10(%ebp),%eax
6d8: 83 c0 08 add $0x8,%eax
6db: 83 ec 0c sub $0xc,%esp
6de: 50 push %eax
6df: e8 c8 fe ff ff call 5ac <free>
6e4: 83 c4 10 add $0x10,%esp
return freep;
6e7: a1 4c 0a 00 00 mov 0xa4c,%eax
}
6ec: c9 leave
6ed: c3 ret
000006ee <malloc>:
void*
malloc(uint nbytes)
{
6ee: 55 push %ebp
6ef: 89 e5 mov %esp,%ebp
6f1: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6f4: 8b 45 08 mov 0x8(%ebp),%eax
6f7: 83 c0 07 add $0x7,%eax
6fa: c1 e8 03 shr $0x3,%eax
6fd: 83 c0 01 add $0x1,%eax
700: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
703: a1 4c 0a 00 00 mov 0xa4c,%eax
708: 89 45 f0 mov %eax,-0x10(%ebp)
70b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
70f: 75 23 jne 734 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
711: c7 45 f0 44 0a 00 00 movl $0xa44,-0x10(%ebp)
718: 8b 45 f0 mov -0x10(%ebp),%eax
71b: a3 4c 0a 00 00 mov %eax,0xa4c
720: a1 4c 0a 00 00 mov 0xa4c,%eax
725: a3 44 0a 00 00 mov %eax,0xa44
base.s.size = 0;
72a: c7 05 48 0a 00 00 00 movl $0x0,0xa48
731: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
734: 8b 45 f0 mov -0x10(%ebp),%eax
737: 8b 00 mov (%eax),%eax
739: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
73c: 8b 45 f4 mov -0xc(%ebp),%eax
73f: 8b 40 04 mov 0x4(%eax),%eax
742: 3b 45 ec cmp -0x14(%ebp),%eax
745: 72 4d jb 794 <malloc+0xa6>
if(p->s.size == nunits)
747: 8b 45 f4 mov -0xc(%ebp),%eax
74a: 8b 40 04 mov 0x4(%eax),%eax
74d: 3b 45 ec cmp -0x14(%ebp),%eax
750: 75 0c jne 75e <malloc+0x70>
prevp->s.ptr = p->s.ptr;
752: 8b 45 f4 mov -0xc(%ebp),%eax
755: 8b 10 mov (%eax),%edx
757: 8b 45 f0 mov -0x10(%ebp),%eax
75a: 89 10 mov %edx,(%eax)
75c: eb 26 jmp 784 <malloc+0x96>
else {
p->s.size -= nunits;
75e: 8b 45 f4 mov -0xc(%ebp),%eax
761: 8b 40 04 mov 0x4(%eax),%eax
764: 2b 45 ec sub -0x14(%ebp),%eax
767: 89 c2 mov %eax,%edx
769: 8b 45 f4 mov -0xc(%ebp),%eax
76c: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
76f: 8b 45 f4 mov -0xc(%ebp),%eax
772: 8b 40 04 mov 0x4(%eax),%eax
775: c1 e0 03 shl $0x3,%eax
778: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
77b: 8b 45 f4 mov -0xc(%ebp),%eax
77e: 8b 55 ec mov -0x14(%ebp),%edx
781: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
784: 8b 45 f0 mov -0x10(%ebp),%eax
787: a3 4c 0a 00 00 mov %eax,0xa4c
return (void*)(p + 1);
78c: 8b 45 f4 mov -0xc(%ebp),%eax
78f: 83 c0 08 add $0x8,%eax
792: eb 3b jmp 7cf <malloc+0xe1>
}
if(p == freep)
794: a1 4c 0a 00 00 mov 0xa4c,%eax
799: 39 45 f4 cmp %eax,-0xc(%ebp)
79c: 75 1e jne 7bc <malloc+0xce>
if((p = morecore(nunits)) == 0)
79e: 83 ec 0c sub $0xc,%esp
7a1: ff 75 ec pushl -0x14(%ebp)
7a4: e8 e5 fe ff ff call 68e <morecore>
7a9: 83 c4 10 add $0x10,%esp
7ac: 89 45 f4 mov %eax,-0xc(%ebp)
7af: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
7b3: 75 07 jne 7bc <malloc+0xce>
return 0;
7b5: b8 00 00 00 00 mov $0x0,%eax
7ba: eb 13 jmp 7cf <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7bc: 8b 45 f4 mov -0xc(%ebp),%eax
7bf: 89 45 f0 mov %eax,-0x10(%ebp)
7c2: 8b 45 f4 mov -0xc(%ebp),%eax
7c5: 8b 00 mov (%eax),%eax
7c7: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
7ca: e9 6d ff ff ff jmp 73c <malloc+0x4e>
}
7cf: c9 leave
7d0: c3 ret
|
; A119476: a(1)=1, a(n)=a((n+1)/2)+1 if n is odd, a(n)=a(n/2)+2 if n is even.
; 1,3,4,5,5,6,6,7,6,7,7,8,7,8,8,9,7,8,8,9,8,9,9,10,8,9,9,10,9,10,10,11,8,9,9,10,9,10,10,11,9,10,10,11,10,11,11,12,9,10,10,11,10,11,11,12,10,11,11,12,11,12,12,13,9,10,10,11,10,11,11,12,10,11,11,12,11,12,12,13,10,11
mov $1,$0
lpb $0,1
div $0,2
add $1,1
sub $1,$0
lpe
add $1,1
|
; A099603: Row sums of triangle A099602, in which row n equals the inverse binomial transform of column n of the triangle of trinomial coefficients (A027907).
; Submitted by Jamie Morken(s1)
; 1,2,4,12,20,64,104,336,544,1760,2848,9216,14912,48256,78080,252672,408832,1323008,2140672,6927360,11208704,36272128,58689536,189923328,307302400,994451456,1609056256,5207015424,8425127936,27264286720
add $0,1
mov $2,$0
seq $2,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
lpb $0
sub $0,2
mul $2,2
lpe
mov $0,$2
|
; -------------------------------------------------------------------------------------------------
; TITLE: p001-Basic-Neuron-3-inputs
; PROCESSOR: Attiny85
;
; DESCRIPTION: I know this is insane, but also a great learning experience :D
;
; I use integer math
; This will however reduce the maximum value to 255
; With the introduction of negative numbers I am further limited to +/- 127
; Let's see how this goes...
;
; Negative numbers are handled as twos complement (standard for most binay systems)
;
; For the first example, we can keep everything in registers for ultra fast access
; Later on we have to fall back to the internal SRAM
;
; CONNECTIONS: For this example no pins have to be connected.
; -------------------------------------------------------------------------------------------------
.DEVICE attiny44 ; device to check memory
.INCLUDE "AVR_Assembly/attiny44.asm" ; register map made by me
; warning: the register map is not finished yet!
; Interrupt vector routines | Nr | Source | Description
Begin:
rjmp Init ; 1 | RESET | Pin, Power on, Reset, Brown-out, Watchdog Reset
reti ; 2 | INT0 | External Interrupt Request 0
reti ; 3 | PCINT0 | Pin Change Interrupt Request 0
reti ; 4 | TIM1_COMPA | Timer Counter 1 Compare Match A
reti ; 5 | TIM1_OVF | Timer Counter 1 Overflow
reti ; 6 | TIM0_OVF | Timer Counter 0 Overflow
reti ; 7 | EE_RDY | EEPROM Ready
reti ; 8 | ANA_COMP | Analog Comparator
reti ; 9 | ADC | ADC Conversion Complete
reti ; 10 | TIM1_COMPB | Timer Counter 1 Compare Match B
reti ; 11 | TIM0_COMPA | Timer Counter 0 Compare Match A
reti ; 12 | TIM0_COMPB | Timer Counter 0 Compare Match B
reti ; 13 | WDT | Watchdog Time-out
reti ; 14 | USI_START | USI Start
reti ; 15 | USI_OVF | USI Overflow
;;
; @brief Initialization, runs once
;
; This function runs once at the start of the program
Init:
ldi r16, high(RAMEND) ; load high part of adress
out SPH, r16 ; set stack pointer to top of RAM
ldi r16, low(RAMEND) ; load low part of adress
out SPL, r16 ; set stack pointer to top of RAM
;sei ; enable interrupts
; im just gonna put stuff here since it has to run only once at the moment
; i had to change the inputs because it would overflow otherwise
; inputs
ldi r18, 1 ;2
ldi r19, 5 ;1
ldi r20, 2 ;1
; weights
ldi r21, 3 ;1
ldi r22, 2 ;1
ldi r23, 8 ;7
; bias
ldi r24, 3 ;0
ldi r25, 0x00 ; reset sum
; first input
mov r16, r18 ; the first input
mov r17, r21 ; the first weight
; an icall is used since this is more universal
; a normal rcall can only reach a limited jumping distance
ldi r30, low(Multiply) ; the low address byte of the target address
ldi r31, high(Multiply) ; the high address byte of the target address
icall ; call the multiplication function
mov r17, r25 ; the sum is the second number for the addition
ldi r30, low(AddAndCap) ; the low address byte of the target address
ldi r31, high(AddAndCap) ; the high address byte of the target address
icall ; call the addition function
mov r25, r16 ; store the result in the sum
; second input
mov r16, r19 ; the first input
mov r17, r22 ; the first weight
ldi r30, low(Multiply) ; the low address byte of the target address
ldi r31, high(Multiply) ; the high address byte of the target address
icall ; call the multiplication function
mov r17, r25 ; the sum is the second number for the addition
ldi r30, low(AddAndCap) ; the low address byte of the target address
ldi r31, high(AddAndCap) ; the high address byte of the target address
icall ; call the addition function
mov r25, r16 ; store the result in the sum
; third input
mov r16, r20 ; the first input
mov r17, r23 ; the first weight
ldi r30, low(Multiply) ; the low address byte of the target address
ldi r31, high(Multiply) ; the high address byte of the target address
icall ; call the multiplication function
mov r17, r25 ; the sum is the second number for the addition
ldi r30, low(AddAndCap) ; the low address byte of the target address
ldi r31, high(AddAndCap) ; the high address byte of the target address
icall ; call the addition function
; bias
mov r17, r24 ; the bias is the second number for the addition
ldi r30, low(AddAndCap) ; the low address byte of the target address
ldi r31, high(AddAndCap) ; the high address byte of the target address
icall ; call the addition function
; the result is in r16 since thats the way the addition returns its result
;;
; @brief Main loop function
;
; This function loops (wow)
Main:
;wdr ; watchdog reset
ldi r17, 0xFF ; bitmask for all pins in the register
out DDRA, r17 ; define port as output
out PORTA, r16 ; put the result on the pins
; now, using a logic analyser, I can probe the result
rjmp Main
;;
; @brief Multiplis two values
;
; @param r16 - first input
; @param r17 - second input
;
; @return r16 - the result of the multiplication
;
; Multiplies the values from registers r16 and r17
; The limit for the result is +/- 127
; In the first step, the signs of both values are investigated
; This way we know, if the result has to be negative or positive
; Then it's basically the same as multiplication by hand
; The first number is shifted and added for every bit set in the other number
; At the end the sign is put back if necessary
Multiply:
push r18 ; adder holder lower byte
push r19 ; adder holder upper byte
push r20 ; product holder lower byte
push r21 ; product holder upper byte
push r22 ; bitmask
push r23 ; used to keep a copy of the second value
push r24 ; stores sign during multiplication
mov r24, r16 ; copy first number into r24
eor r24, r17 ; if either is negative, the sign bit will be set. if none or both are, its cleared (- * - = +)
sbrc r16, 7 ; if the first number is negative
neg r16 ; make it positive
sbrc r17, 7 ; if the second number is negative
neg r17 ; make it positive
mov r18, r16 ; copy first number into r18
clr r19 ; clear r19
clr r20 ; clear r20
clr r21 ; clear r21
ldi r22, 0x01 ; set bitmask to the first bit
Multiply_Outerloop:
cpi r22, 0x80 ; when the bitmask reached the sign bit
breq Multiply_LoopExit ; multiplication is done
mov r23, r17 ; copy second number into r23
and r23, r22 ; compare second number with bitmask
breq Multiply_BitNotSet ; when the bit is not set, dont add anything
add r20, r18 ; add the lower byte without carry
adc r21, r19 ; add the upper byte and the carry from the lower byte
Multiply_BitNotSet:
lsl r18 ; shift r18 left, lowest bit is 0, highest bit goes to carry
rol r19 ; rotate r19 left, lowest bit is carry from r18
lsl r22 ; shift bitmask left
rjmp Multiply_Outerloop
Multiply_LoopExit:
andi r21, 0xFF ; any bit in the upper byte is too much
brne Multiply_SomeUpperBits
mov r23, r20
andi r23, 0x80 ; highest bit in lower byte is sign bit, it cannot be set
breq Multiply_NoUpperBits
Multiply_SomeUpperBits:
ldi r20, 0x7F ; highest possible number
Multiply_NoUpperBits:
mov r16, r20
sbrc r24, 7 ; if the sign bit is set
neg r16 ; make the result negative
pop r24
pop r23
pop r22
pop r21
pop r20
pop r19
pop r18
ret
;;
; @brief Adds two values
;
; @param r16 - first input
; @param r17 - second input
;
; @return r16 - the result of the multiplication
;
; Adds the values in r16 and r17
; If the result would overflow 7 bits it is capped
; If the result would underflow (7 bits with sign set) it is capped negative
; This is overcomplicated but saver than making assumptions about the math unit
;
; the maximum output of an addition in binary is one bit more
; since the inputs HAVE to be 7 bits (if they are 8 bit it's your fault and treated as negative)
; we are allowed to add them
; now if it would overflow (it's converted to positive, no underflow possible)
; we can catch that by looking at most significant bit
AddAndCap:
add r16, r17 ; add the numbers
brvc AddAndCap_NoOverflow
brpl AddAndCap_NegativeOverflow
; positive overflow
ldi r16, 0x7F ; cap positive
rjmp AddAndCap_NoOverflow
AddAndCap_NegativeOverflow:
ldi r16, 0x80 ; cap negative
AddAndCap_NoOverflow:
ret |
UART_BUSY BIT 00h
PROG EQU 0000h
ORG PROG+0000h
SJMP START
;Interrupt Vector Table
ORG PROG+0023h
LCALL UART_ISR
RETI
ORG PROG+0030h
START:
CLR UART_BUSY
MOV TMOD,#00100001b ; Timer1 in Mode 2, Timer0 in Mode 1
MOV TH1, #0F3h ; Baud Rate = 2400 bps at 12.000MHz
MOV SCON,#01010000b ; UART in Mode 1
SETB ES ; Enable UART Interrupt
SETB EA ; Enable Interrupt
SETB TR1 ; Start Timer 1
MOV A,#'H'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#'l'
CALL UART_PUTC
MOV A,#'l'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#','
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'W'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'a'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'N'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'.'
CALL UART_PUTC
MOV A,#'1'
CALL UART_PUTC
MOV A,#'2'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV P1,#255
GoodMoring: MOV P1,#255
CJNE A,#01H,AfterNoon
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'M'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'i'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'g'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
JMP GoodMoring
AfterNoon: CJNE A,#02H,GoodNight
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'A'
CALL UART_PUTC
MOV A,#'f'
CALL UART_PUTC
MOV A,#'t'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
JMP GoodMoring
GoodNight: CJNE A,#03H,Finish
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'N'
CALL UART_PUTC
MOV A,#'i'
CALL UART_PUTC
MOV A,#'g'
CALL UART_PUTC
MOV A,#'h'
CALL UART_PUTC
MOV A,#'t'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
Finish: JMP GoodMoring
UART_ISR:
JB RI,RECEIVED
TRANSMITTED:
CLR UART_BUSY
CLR TI
RET
RECEIVED:
MOV A,SBUF
CLR RI
RET
UART_PUTC:
JB UART_BUSY,UART_PUTC
SETB UART_BUSY
MOV SBUF,A
RET
END
|
db "WICKED@" ; species name
db "It lives quietly"
next "in deep forests."
next "It is said to"
page "create chilly"
next "winter winds with"
next "the fan it holds.@"
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xb8c8, %rcx
nop
nop
nop
and %r8, %r8
mov $0x6162636465666768, %r15
movq %r15, (%rcx)
nop
add %r11, %r11
lea addresses_normal_ht+0xcac8, %rsi
lea addresses_WT_ht+0x9648, %rdi
nop
dec %r11
mov $49, %rcx
rep movsq
nop
and %r15, %r15
lea addresses_WT_ht+0x10e88, %rsi
lea addresses_D_ht+0x1d168, %rdi
nop
nop
nop
nop
nop
add $31286, %r8
mov $7, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp %r15, %r15
lea addresses_normal_ht+0xa6c8, %rdi
nop
nop
nop
nop
xor $38625, %r12
mov $0x6162636465666768, %r15
movq %r15, (%rdi)
nop
nop
cmp $16088, %r11
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_PSE+0x19028, %rsi
mov $0x588, %rdi
clflush (%rsi)
nop
nop
nop
xor $58997, %r11
mov $35, %rcx
rep movsq
add $2541, %rbp
// Faulty Load
lea addresses_US+0x46c8, %rdi
nop
nop
nop
nop
cmp %r14, %r14
vmovups (%rdi), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rcx
lea oracles, %rbp
and $0xff, %rcx
shlq $12, %rcx
mov (%rbp,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_PSE', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_P', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'00': 38}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A133883: a(n) = binomial(n+3,n) mod 3^2.
; 1,4,1,2,8,2,3,3,3,4,7,4,5,2,5,6,6,6,7,1,7,8,5,8,0,0,0,1,4,1,2,8,2,3,3,3,4,7,4,5,2,5,6,6,6,7,1,7,8,5,8,0,0,0,1,4,1,2,8,2,3,3,3,4,7,4,5,2,5,6,6,6,7,1,7,8,5,8,0,0,0,1,4,1,2,8,2,3,3,3,4,7,4,5,2,5,6,6,6,7
add $0,3
bin $0,3
mod $0,9
|
dd len
extern show
global _start
global io_hlt
global io_cli
global io_sti
global io_stihlt
global io_in8
global io_in16
global io_in32
global io_out8
global io_out16
global io_out32
global io_load_eflags
global io_store_eflags
_start:
[bits 32]
call show
io_hlt: ; void io_hlt(void);
hlt
ret
io_cli: ; void io_cli(void);
cli
ret
io_sti: ; void io_sti(void);
sti
ret
io_stihlt: ; void io_stihlt(void);
sti
hlt
ret
io_in8: ; int io_in8(int port);
mov edx,[esp+4] ; port
mov eax,0
in al,dx
ret
io_in16: ; int io_in16(int port);
mov edx,[esp+4] ; port
mov eax,0
in ax,dx
ret
io_in32: ; int io_in32(int port);
mov edx,[esp+4] ; port
in eax,dx
ret
io_out8: ; void io_out8(int port, int data);
mov edx,[esp+4] ; port
mov al,[esp+8] ; data
out dx,al
ret
io_out16: ; void io_out16(int port, int data);
mov edx,[esp+4] ; port
mov eax,[esp+8] ; data
out dx,ax
ret
io_out32: ; void io_out32(int port, int data);
mov edx,[esp+4] ; port
mov eax,[esp+8] ; data
out dx,eax
ret
io_load_eflags: ; int io_load_eflags(void);
pushfd ; push eflags 傛偄偆報枴
pop eax
ret
io_store_eflags: ; void io_store_eflags(int eflags);
mov eax,[esp+4]
push eax
popfd ; pop eflags 傛偄偆報枴
ret
len:
|
; A131355: Partial sums of A065423 plus one.
; 1,1,1,3,4,8,10,16,19,27,31,41,46,58,64,78,85,101,109,127,136,156,166,188,199,223,235,261,274,302,316,346,361,393,409,443,460,496,514,552,571,611,631,673,694,738,760,806,829,877,901,951,976,1028,1054,1108
mov $1,$0
div $0,2
add $0,$1
sub $1,1
div $1,2
mul $1,$0
mov $0,$1
div $0,2
add $0,1
|
; A131712: Period 4: repeat [1, 3, 7, 9].
; 1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1,3,7,9,1
mod $0,4
mul $0,8
div $0,5
mov $1,$0
mul $1,2
add $1,1
|
; unsigned char esx_m_setcaps(unsigned char caps)
INCLUDE "config_private.inc"
SECTION code_esxdos
PUBLIC asm_esx_m_setcaps
EXTERN __esxdos_error_mc
asm_esx_m_setcaps:
; enter : l = new capabilities
;
; exit : success
;
; hl = old capabilities
; carry reset
;
; fail
;
; hl = -1
; carry set, errno set
;
; uses : af, bc, de, hl
ld a,l
rst __ESX_RST_SYS
defb __ESX_M_SETCAPS
jp c, __esxdos_error_mc
ld l,e
ld h,0
ret
; ***************************************************************************
; * M_SETCAPS ($91) *
; ***************************************************************************
; Entry: A=capabilities to set:
; bit 7=1, do not erase new file data in f_truncate/f_ftruncate
; (increases performance of these calls)
; bits 0..6: reserved, must be zero
; Exit: Fc=0, success
; E=previous capabilities
;
; NOTE: This call is only available from NextOS v1.98M+.
; Earlier versions will return with Fc=1 (error) and A=esx_enocmd
; NOTE: You should save the original value of the capabilities which is
; returned in E. After completing the calls you need with your altered
; capabilities, restore the original value by calling M_SETCAPS again
; with the value that was previously returned in E.
; This will ensure that other programs running after you have exited
; will continue to see the original expected behaviour.
|
/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Kristian Lauszus, TKJ Electronics
Web : http://www.tkjelectronics.com
e-mail : kristianl@tkjelectronics.com
*/
#include "PS3USB.h"
// To enable serial debugging see "settings.h"
//#define EXTRADEBUG // Uncomment to get even more debugging data
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
PS3USB::PS3USB(USB *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) :
pUsb(p), // pointer to USB class instance - mandatory
bAddress(0), // device address - mandatory
bPollEnable(false) // don't start polling before dongle is connected
{
for(uint8_t i = 0; i < PS3_MAX_ENDPOINTS; i++) {
epInfo[i].epAddr = 0;
epInfo[i].maxPktSize = (i) ? 0 : 8;
epInfo[i].bmSndToggle = 0;
epInfo[i].bmRcvToggle = 0;
epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
}
if(pUsb) // register in USB subsystem
pUsb->RegisterDeviceClass(this); //set devConfig[] entry
my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead
my_bdaddr[4] = btadr4;
my_bdaddr[3] = btadr3;
my_bdaddr[2] = btadr2;
my_bdaddr[1] = btadr1;
my_bdaddr[0] = btadr0;
}
uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode;
UsbDevice *p = NULL;
EpInfo *oldep_ptr = NULL;
uint16_t PID;
uint16_t VID;
// get memory address of USB device address pool
AddressPool &addrPool = pUsb->GetAddressPool();
#ifdef EXTRADEBUG
Notify(PSTR("\r\nPS3USB Init"), 0x80);
#endif
// check if address has already been assigned to an instance
if(bAddress) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nAddress in use"), 0x80);
#endif
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
}
// Get pointer to pseudo device with address 0 assigned
p = addrPool.GetUsbDevicePtr(0);
if(!p) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nAddress not found"), 0x80);
#endif
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
}
if(!p->epinfo) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nepinfo is null"), 0x80);
#endif
return USB_ERROR_EPINFO_IS_NULL;
}
// Save old pointer to EP_RECORD of address 0
oldep_ptr = p->epinfo;
// Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
p->epinfo = epInfo;
p->lowspeed = lowspeed;
// Get device descriptor
rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data
// Restore p->epinfo
p->epinfo = oldep_ptr;
if(rcode)
goto FailGetDevDescr;
VID = udd->idVendor;
PID = udd->idProduct;
if(VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID))
goto FailUnknownDevice;
// Allocate new address according to device class
bAddress = addrPool.AllocAddress(parent, false, port);
if(!bAddress)
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
// Extract Max Packet Size from device descriptor
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
// Assign new address to the device
rcode = pUsb->setAddr(0, 0, bAddress);
if(rcode) {
p->lowspeed = false;
addrPool.FreeAddress(bAddress);
bAddress = 0;
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nsetAddr: "), 0x80);
D_PrintHex<uint8_t > (rcode, 0x80);
#endif
return rcode;
}
#ifdef EXTRADEBUG
Notify(PSTR("\r\nAddr: "), 0x80);
D_PrintHex<uint8_t > (bAddress, 0x80);
#endif
//delay(300); // Spec says you should wait at least 200ms
p->lowspeed = false;
//get pointer to assigned address record
p = addrPool.GetUsbDevicePtr(bAddress);
if(!p)
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
p->lowspeed = lowspeed;
// Assign epInfo to epinfo pointer - only EP0 is known
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
if(rcode)
goto FailSetDevTblEntry;
/* The application will work in reduced host mode, so we can save program and data
memory space. After verifying the PID and VID we will use known values for the
configuration values for device, interface, endpoints and HID for the PS3 Controllers */
/* Initialize data structures for endpoints of device */
epInfo[ PS3_OUTPUT_PIPE ].epAddr = 0x02; // PS3 output endpoint
epInfo[ PS3_OUTPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT;
epInfo[ PS3_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
epInfo[ PS3_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = 0;
epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = 0;
epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint
epInfo[ PS3_INPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT;
epInfo[ PS3_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
epInfo[ PS3_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
epInfo[ PS3_INPUT_PIPE ].bmSndToggle = 0;
epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = 0;
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
if(rcode)
goto FailSetDevTblEntry;
delay(200); //Give time for address change
rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1);
if(rcode)
goto FailSetConfDescr;
if(PID == PS3_PID || PID == PS3NAVIGATION_PID) {
if(PID == PS3_PID) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
#endif
PS3Connected = true;
} else { // must be a navigation controller
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
#endif
PS3NavigationConnected = true;
}
enable_sixaxis(); // The PS3 controller needs a special command before it starts sending data
// Needed for PS3 Dualshock and Navigation commands to work
for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]);
for(uint8_t i = 6; i < 10; i++)
readBuf[i] = 0x7F; // Set the analog joystick values to center position
} else { // must be a Motion controller
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
#endif
PS3MoveConnected = true;
writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work
}
if(my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) {
if(PS3MoveConnected)
setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address
else
setBdaddr(my_bdaddr); // Set internal Bluetooth address
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
for(int8_t i = 5; i > 0; i--) {
D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
Notify(PSTR(":"), 0x80);
}
D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
#endif
}
onInit();
bPollEnable = true;
Notify(PSTR("\r\n"), 0x80);
timer = (uint32_t)millis();
return 0; // Successful configuration
/* Diagnostic messages */
FailGetDevDescr:
#ifdef DEBUG_USB_HOST
NotifyFailGetDevDescr();
goto Fail;
#endif
FailSetDevTblEntry:
#ifdef DEBUG_USB_HOST
NotifyFailSetDevTblEntry();
goto Fail;
#endif
FailSetConfDescr:
#ifdef DEBUG_USB_HOST
NotifyFailSetConfDescr();
#endif
goto Fail;
FailUnknownDevice:
#ifdef DEBUG_USB_HOST
NotifyFailUnknownDevice(VID, PID);
#endif
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
Fail:
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
NotifyFail(rcode);
#endif
Release();
return rcode;
}
/* Performs a cleanup after failed Init() attempt */
uint8_t PS3USB::Release() {
PS3Connected = false;
PS3MoveConnected = false;
PS3NavigationConnected = false;
pUsb->GetAddressPool().FreeAddress(bAddress);
bAddress = 0;
bPollEnable = false;
return 0;
}
uint8_t PS3USB::Poll() {
if(!bPollEnable)
return 0;
if(PS3Connected || PS3NavigationConnected) {
uint16_t BUFFER_SIZE = EP_MAXPKTSIZE;
pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1
if((int32_t)((uint32_t)millis() - timer) > 100) { // Loop 100ms before processing data
readReport();
#ifdef PRINTREPORT
printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
#endif
}
} else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB
if((int32_t)((uint32_t)millis() - timer) > 4000) { // Send at least every 4th second
Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
timer = (uint32_t)millis();
}
}
return 0;
}
void PS3USB::readReport() {
ButtonState = (uint32_t)(readBuf[2] | ((uint16_t)readBuf[3] << 8) | ((uint32_t)readBuf[4] << 16));
//Notify(PSTR("\r\nButtonState", 0x80);
//PrintHex<uint32_t>(ButtonState, 0x80);
if(ButtonState != OldButtonState) {
ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
OldButtonState = ButtonState;
}
}
void PS3USB::printReport() { // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
#ifdef PRINTREPORT
for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
D_PrintHex<uint8_t > (readBuf[i], 0x80);
Notify(PSTR(" "), 0x80);
}
Notify(PSTR("\r\n"), 0x80);
#endif
}
bool PS3USB::getButtonPress(ButtonEnum b) {
return (ButtonState & pgm_read_dword(&PS3_BUTTONS[(uint8_t)b]));
}
bool PS3USB::getButtonClick(ButtonEnum b) {
uint32_t button = pgm_read_dword(&PS3_BUTTONS[(uint8_t)b]);
bool click = (ButtonClickState & button);
ButtonClickState &= ~button; // Clear "click" event
return click;
}
uint8_t PS3USB::getAnalogButton(ButtonEnum a) {
return (uint8_t)(readBuf[(pgm_read_byte(&PS3_ANALOG_BUTTONS[(uint8_t)a])) - 9]);
}
uint8_t PS3USB::getAnalogHat(AnalogHatEnum a) {
return (uint8_t)(readBuf[((uint8_t)a + 6)]);
}
uint16_t PS3USB::getSensor(SensorEnum a) {
return ((readBuf[((uint16_t)a) - 9] << 8) | readBuf[((uint16_t)a + 1) - 9]);
}
float PS3USB::getAngle(AngleEnum a) {
if(PS3Connected) {
float accXval, accYval, accZval;
// Data for the Kionix KXPC4 used in the DualShock 3
const float zeroG = 511.5f; // 1.65/3.3*1023 (1,65V)
accXval = -((float)getSensor(aX) - zeroG);
accYval = -((float)getSensor(aY) - zeroG);
accZval = -((float)getSensor(aZ) - zeroG);
// Convert to 360 degrees resolution
// atan2 outputs the value of -π to π (radians)
// We are then converting it to 0 to 2π and then to degrees
if(a == Pitch)
return (atan2f(accYval, accZval) + PI) * RAD_TO_DEG;
else
return (atan2f(accXval, accZval) + PI) * RAD_TO_DEG;
} else
return 0;
}
bool PS3USB::getStatus(StatusEnum c) {
return (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff));
}
void PS3USB::printStatusString() {
char statusOutput[102]; // Max string length plus null character
if(PS3Connected || PS3NavigationConnected) {
strcpy_P(statusOutput, PSTR("\r\nConnectionStatus: "));
if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
else strcat_P(statusOutput, PSTR("Error"));
strcat_P(statusOutput, PSTR(" - PowerRating: "));
if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging"));
else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging"));
else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown"));
else if(getStatus(Dying)) strcat_P(statusOutput, PSTR("Dying"));
else if(getStatus(Low)) strcat_P(statusOutput, PSTR("Low"));
else if(getStatus(High)) strcat_P(statusOutput, PSTR("High"));
else if(getStatus(Full)) strcat_P(statusOutput, PSTR("Full"));
else strcat_P(statusOutput, PSTR("Error"));
strcat_P(statusOutput, PSTR(" - WirelessStatus: "));
if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on"));
else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off"));
else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on"));
else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off"));
else strcat_P(statusOutput, PSTR("Error"));
} else
strcpy_P(statusOutput, PSTR("\r\nError"));
USB_HOST_SERIAL.write(statusOutput);
}
/* Playstation Sixaxis Dualshock and Navigation Controller commands */
void PS3USB::PS3_Command(uint8_t *data, uint16_t nbytes) {
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x01), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL);
}
void PS3USB::setAllOff() {
for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]); // Reset buffer
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setRumbleOff() {
uint8_t rumbleBuf[EP_MAXPKTSIZE];
memcpy(rumbleBuf, writeBuf, EP_MAXPKTSIZE);
rumbleBuf[1] = 0x00;
rumbleBuf[2] = 0x00; // Low mode off
rumbleBuf[3] = 0x00;
rumbleBuf[4] = 0x00; // High mode off
PS3_Command(rumbleBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setRumbleOn(RumbleEnum mode) {
if((mode & 0x30) > 0x00) {
uint8_t power[2] = {0xff, 0x00}; // Defaults to RumbleLow
if(mode == RumbleHigh) {
power[0] = 0x00;
power[1] = 0xff;
}
setRumbleOn(0xfe, power[0], 0xfe, power[1]);
}
}
void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
uint8_t rumbleBuf[EP_MAXPKTSIZE];
memcpy(rumbleBuf, writeBuf, EP_MAXPKTSIZE);
rumbleBuf[1] = rightDuration;
rumbleBuf[2] = rightPower;
rumbleBuf[3] = leftDuration;
rumbleBuf[4] = leftPower;
PS3_Command(rumbleBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setLedRaw(uint8_t value) {
writeBuf[9] = value << 1;
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setLedOff(LEDEnum a) {
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1));
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setLedOn(LEDEnum a) {
if(a == OFF)
setLedRaw(0);
else {
writeBuf[9] |= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1);
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
}
void PS3USB::setLedToggle(LEDEnum a) {
writeBuf[9] ^= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1);
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
}
void PS3USB::setBdaddr(uint8_t *bdaddr) {
/* Set the internal Bluetooth address */
uint8_t buf[8];
buf[0] = 0x01;
buf[1] = 0x00;
for(uint8_t i = 0; i < 6; i++)
buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
}
void PS3USB::getBdaddr(uint8_t *bdaddr) {
uint8_t buf[8];
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
for(uint8_t i = 0; i < 6; i++)
bdaddr[5 - i] = buf[i + 2]; // Copy into buffer reversed, so it is LSB first
}
void PS3USB::enable_sixaxis() { // Command used to enable the Dualshock 3 and Navigation controller to send data via USB
uint8_t cmd_buf[4];
cmd_buf[0] = 0x42; // Special PS3 Controller enable commands
cmd_buf[1] = 0x0c;
cmd_buf[2] = 0x00;
cmd_buf[3] = 0x00;
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF4), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL);
}
/* Playstation Move Controller commands */
void PS3USB::Move_Command(uint8_t *data, uint16_t nbytes) {
pUsb->outTransfer(bAddress, epInfo[ PS3_OUTPUT_PIPE ].epAddr, nbytes, data);
}
void PS3USB::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { // Use this to set the Color using RGB values
// Set the Bulb's values into the write buffer
writeBuf[2] = r;
writeBuf[3] = g;
writeBuf[4] = b;
Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE);
}
void PS3USB::moveSetBulb(ColorsEnum color) { // Use this to set the Color using the predefined colors in "enums.h"
moveSetBulb((uint8_t)(color >> 16), (uint8_t)(color >> 8), (uint8_t)(color));
}
void PS3USB::moveSetRumble(uint8_t rumble) {
#ifdef DEBUG_USB_HOST
if(rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
#endif
writeBuf[6] = rumble; // Set the rumble value into the write buffer
Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE);
}
void PS3USB::setMoveBdaddr(uint8_t *bdaddr) {
/* Set the internal Bluetooth address */
uint8_t buf[11];
buf[0] = 0x05;
buf[7] = 0x10;
buf[8] = 0x01;
buf[9] = 0x02;
buf[10] = 0x12;
for(uint8_t i = 0; i < 6; i++)
buf[i + 1] = bdaddr[i];
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
}
void PS3USB::getMoveBdaddr(uint8_t *bdaddr) {
uint8_t buf[16];
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x04), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x04, 0x03, 0x00, 16, 16, buf, NULL);
for(uint8_t i = 0; i < 6; i++)
bdaddr[i] = buf[10 + i];
}
void PS3USB::getMoveCalibration(uint8_t *data) {
uint8_t buf[49];
for(uint8_t i = 0; i < 3; i++) {
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x10), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x10, 0x03, 0x00, 49, 49, buf, NULL);
for(uint8_t j = 0; j < 49; j++)
data[49 * i + j] = buf[j];
}
}
void PS3USB::onInit() {
if(pFuncOnInit)
pFuncOnInit(); // Call the user function
else {
if(PS3MoveConnected)
moveSetBulb(Red);
else // Dualshock 3 or Navigation controller
setLedOn(static_cast<LEDEnum>(LED1));
}
}
|
; A025748: 3rd order Patalan numbers (generalization of Catalan numbers).
; Submitted by Christian Krause
; 1,1,3,15,90,594,4158,30294,227205,1741905,13586859,107459703,859677624,6943550040,56540336040,463630755528,3824953733106,31724616256938,264371802141150,2212374554760150,18583946259985260,156636118477018620,1324287183487521060,11227652207828982900,95435043766546354650,813106572890974941618,6942679199299862963046,59398477594009938683838,509129807948656617290040,4371493868248810265697240,37594847266939768284996264,323800781299126391357871048,2792781738704965125461637789
trn $0,1
seq $0,97188 ; G.f. A(x) satisfies A057083(x*A(x)) = A(x) and so equals the ratio of the g.f.s of any two adjacent diagonals of triangle A097186.
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
default rel
[bits 64]
%include "reg_sizes.asm"
extern crc32_iscsi_00
extern crc32_iscsi_01
extern crc32_iscsi_base
extern crc32_ieee_01
extern crc32_ieee_by4 ;; Optimized for SLM
extern crc32_ieee_02
extern crc32_ieee_base
extern crc16_t10dif_01
extern crc16_t10dif_by4 ;; Optimized for SLM
extern crc16_t10dif_02
extern crc16_t10dif_base
extern crc32_gzip_refl_by8
extern crc32_gzip_refl_by8_02
extern crc32_gzip_refl_base
extern crc16_t10dif_copy_by4
extern crc16_t10dif_copy_by4_02
extern crc16_t10dif_copy_base
%if (AS_FEATURE_LEVEL) >= 10
extern crc32_gzip_refl_by16_10
extern crc32_ieee_by16_10
extern crc32_iscsi_by16_10
extern crc16_t10dif_by16_10
%endif
%include "multibinary.asm"
section .data
;;; *_mbinit are initial values for *_dispatched; is updated on first call.
;;; Therefore, *_dispatch_init is only executed on first call.
crc32_iscsi_dispatched:
dq crc32_iscsi_mbinit
crc32_ieee_dispatched:
dq crc32_ieee_mbinit
crc16_t10dif_dispatched:
dq crc16_t10dif_mbinit
section .text
;;;;
; crc32_iscsi multibinary function
;;;;
mk_global crc32_iscsi, function
crc32_iscsi_mbinit:
endbranch
call crc32_iscsi_dispatch_init
crc32_iscsi:
endbranch
jmp qword [crc32_iscsi_dispatched]
crc32_iscsi_dispatch_init:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
lea rsi, [crc32_iscsi_base WRT_OPT] ; Default
mov eax, 1
cpuid
mov ebx, ecx ; save cpuid1.ecx
test ecx, FLAG_CPUID1_ECX_SSE4_2
jz .crc_iscsi_init_done ; use iscsi_base
lea rsi, [crc32_iscsi_00 WRT_OPT]
test ecx, FLAG_CPUID1_ECX_CLMUL
jz .crc_iscsi_init_done ; use ieee_base
lea rsi, [crc32_iscsi_01 WRT_OPT]
;; Test for XMM_YMM support/AVX
test ecx, FLAG_CPUID1_ECX_OSXSAVE
je .crc_iscsi_init_done
xor ecx, ecx
xgetbv ; xcr -> edx:eax
mov edi, eax ; save xgetvb.eax
and eax, FLAG_XGETBV_EAX_XMM_YMM
cmp eax, FLAG_XGETBV_EAX_XMM_YMM
jne .crc_iscsi_init_done
test ebx, FLAG_CPUID1_ECX_AVX
je .crc_iscsi_init_done
;; AVX/02 opt if available
%if AS_FEATURE_LEVEL >= 10
;; Test for AVX2
xor ecx, ecx
mov eax, 7
cpuid
test ebx, FLAG_CPUID7_EBX_AVX2
je .crc_iscsi_init_done ; No AVX2 possible
;; Test for AVX512
and edi, FLAG_XGETBV_EAX_ZMM_OPM
cmp edi, FLAG_XGETBV_EAX_ZMM_OPM
jne .crc_iscsi_init_done ; No AVX512 possible
and ebx, FLAGS_CPUID7_EBX_AVX512_G1
cmp ebx, FLAGS_CPUID7_EBX_AVX512_G1
jne .crc_iscsi_init_done
and ecx, FLAGS_CPUID7_ECX_AVX512_G2
cmp ecx, FLAGS_CPUID7_ECX_AVX512_G2
lea rbx, [crc32_iscsi_by16_10 WRT_OPT] ; AVX512/10 opt
cmove rsi, rbx
%endif
.crc_iscsi_init_done:
mov [crc32_iscsi_dispatched], rsi
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
ret
;;;;
; crc32_ieee multibinary function
;;;;
mk_global crc32_ieee, function
crc32_ieee_mbinit:
endbranch
call crc32_ieee_dispatch_init
crc32_ieee:
endbranch
jmp qword [crc32_ieee_dispatched]
crc32_ieee_dispatch_init:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
lea rsi, [crc32_ieee_base WRT_OPT] ; Default
mov eax, 1
cpuid
mov ebx, ecx ; save cpuid1.ecx
test ecx, FLAG_CPUID1_ECX_SSE3
jz .crc_ieee_init_done ; use ieee_base
test ecx, FLAG_CPUID1_ECX_CLMUL
jz .crc_ieee_init_done ; use ieee_base
lea rsi, [crc32_ieee_01 WRT_OPT]
;; Extra Avoton test
lea rdx, [crc32_ieee_by4 WRT_OPT]
and eax, FLAG_CPUID1_EAX_STEP_MASK
cmp eax, FLAG_CPUID1_EAX_AVOTON
cmove rsi, rdx
;; Test for XMM_YMM support/AVX
test ecx, FLAG_CPUID1_ECX_OSXSAVE
je .crc_ieee_init_done
xor ecx, ecx
xgetbv ; xcr -> edx:eax
mov edi, eax ; save xgetvb.eax
and eax, FLAG_XGETBV_EAX_XMM_YMM
cmp eax, FLAG_XGETBV_EAX_XMM_YMM
jne .crc_ieee_init_done
test ebx, FLAG_CPUID1_ECX_AVX
je .crc_ieee_init_done
lea rsi, [crc32_ieee_02 WRT_OPT] ; AVX/02 opt
%if AS_FEATURE_LEVEL >= 10
;; Test for AVX2
xor ecx, ecx
mov eax, 7
cpuid
test ebx, FLAG_CPUID7_EBX_AVX2
je .crc_ieee_init_done ; No AVX2 possible
;; Test for AVX512
and edi, FLAG_XGETBV_EAX_ZMM_OPM
cmp edi, FLAG_XGETBV_EAX_ZMM_OPM
jne .crc_ieee_init_done ; No AVX512 possible
and ebx, FLAGS_CPUID7_EBX_AVX512_G1
cmp ebx, FLAGS_CPUID7_EBX_AVX512_G1
jne .crc_ieee_init_done
and ecx, FLAGS_CPUID7_ECX_AVX512_G2
cmp ecx, FLAGS_CPUID7_ECX_AVX512_G2
lea rbx, [crc32_ieee_by16_10 WRT_OPT] ; AVX512/10 opt
cmove rsi, rbx
%endif
.crc_ieee_init_done:
mov [crc32_ieee_dispatched], rsi
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
ret
;;;;
; crc16_t10dif multibinary function
;;;;
mk_global crc16_t10dif, function
crc16_t10dif_mbinit:
endbranch
call crc16_t10dif_dispatch_init
crc16_t10dif:
endbranch
jmp qword [crc16_t10dif_dispatched]
crc16_t10dif_dispatch_init:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
lea rsi, [crc16_t10dif_base WRT_OPT] ; Default
mov eax, 1
cpuid
mov ebx, ecx ; save cpuid1.ecx
test ecx, FLAG_CPUID1_ECX_SSE3
jz .t10dif_init_done ; use t10dif_base
test ecx, FLAG_CPUID1_ECX_CLMUL
jz .t10dif_init_done ; use t10dif_base
lea rsi, [crc16_t10dif_01 WRT_OPT]
;; Extra Avoton test
lea rdx, [crc16_t10dif_by4 WRT_OPT]
and eax, FLAG_CPUID1_EAX_STEP_MASK
cmp eax, FLAG_CPUID1_EAX_AVOTON
cmove rsi, rdx
;; Test for XMM_YMM support/AVX
test ecx, FLAG_CPUID1_ECX_OSXSAVE
je .t10dif_init_done
xor ecx, ecx
xgetbv ; xcr -> edx:eax
mov edi, eax ; save xgetvb.eax
and eax, FLAG_XGETBV_EAX_XMM_YMM
cmp eax, FLAG_XGETBV_EAX_XMM_YMM
jne .t10dif_init_done
test ebx, FLAG_CPUID1_ECX_AVX
je .t10dif_init_done
lea rsi, [crc16_t10dif_02 WRT_OPT] ; AVX/02 opt
%if AS_FEATURE_LEVEL >= 10
;; Test for AVX2
xor ecx, ecx
mov eax, 7
cpuid
test ebx, FLAG_CPUID7_EBX_AVX2
je .t10dif_init_done ; No AVX2 possible
;; Test for AVX512
and edi, FLAG_XGETBV_EAX_ZMM_OPM
cmp edi, FLAG_XGETBV_EAX_ZMM_OPM
jne .t10dif_init_done ; No AVX512 possible
and ebx, FLAGS_CPUID7_EBX_AVX512_G1
cmp ebx, FLAGS_CPUID7_EBX_AVX512_G1
jne .t10dif_init_done
and ecx, FLAGS_CPUID7_ECX_AVX512_G2
cmp ecx, FLAGS_CPUID7_ECX_AVX512_G2
lea rbx, [crc16_t10dif_by16_10 WRT_OPT] ; AVX512/10 opt
cmove rsi, rbx
%endif
.t10dif_init_done:
mov [crc16_t10dif_dispatched], rsi
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
ret
mbin_interface crc32_gzip_refl
mbin_dispatch_init_clmul crc32_gzip_refl, crc32_gzip_refl_base, crc32_gzip_refl_by8, crc32_gzip_refl_by8_02, crc32_gzip_refl_by16_10
mbin_interface crc16_t10dif_copy
mbin_dispatch_init_clmul crc16_t10dif_copy, crc16_t10dif_copy_base, crc16_t10dif_copy_by4, crc16_t10dif_copy_by4_02, crc16_t10dif_copy_by4_02
;;; func core, ver, snum
slversion crc16_t10dif, 00, 03, 011a
slversion crc32_ieee, 00, 03, 011b
slversion crc32_iscsi, 00, 03, 011c
slversion crc32_gzip_refl, 00, 00, 002a
|
; example from page 54
.data
sum DWORD 0 ; this is the data area
.code ; this is the code area
main proc
mov eax,5 ; move 5 to the eax register
add eax,6 ; add 6 to the eax register
move sum, eax
invoke ExitProcess,0 ; end the program
main endp
end main |
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/cwp/v20180228/model/DescribeBaselineStrategyListResponse.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Cwp::V20180228::Model;
using namespace std;
DescribeBaselineStrategyListResponse::DescribeBaselineStrategyListResponse() :
m_totalCountHasBeenSet(false),
m_strategyListHasBeenSet(false)
{
}
CoreInternalOutcome DescribeBaselineStrategyListResponse::Deserialize(const string &payload)
{
rapidjson::Document d;
d.Parse(payload.c_str());
if (d.HasParseError() || !d.IsObject())
{
return CoreInternalOutcome(Core::Error("response not json format"));
}
if (!d.HasMember("Response") || !d["Response"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `Response` is null or not object"));
}
rapidjson::Value &rsp = d["Response"];
if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.RequestId` is null or not string"));
}
string requestId(rsp["RequestId"].GetString());
SetRequestId(requestId);
if (rsp.HasMember("Error"))
{
if (!rsp["Error"].IsObject() ||
!rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() ||
!rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.Error` format error").SetRequestId(requestId));
}
string errorCode(rsp["Error"]["Code"].GetString());
string errorMsg(rsp["Error"]["Message"].GetString());
return CoreInternalOutcome(Core::Error(errorCode, errorMsg).SetRequestId(requestId));
}
if (rsp.HasMember("TotalCount") && !rsp["TotalCount"].IsNull())
{
if (!rsp["TotalCount"].IsUint64())
{
return CoreInternalOutcome(Core::Error("response `TotalCount` IsUint64=false incorrectly").SetRequestId(requestId));
}
m_totalCount = rsp["TotalCount"].GetUint64();
m_totalCountHasBeenSet = true;
}
if (rsp.HasMember("StrategyList") && !rsp["StrategyList"].IsNull())
{
if (!rsp["StrategyList"].IsArray())
return CoreInternalOutcome(Core::Error("response `StrategyList` is not array type"));
const rapidjson::Value &tmpValue = rsp["StrategyList"];
for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr)
{
Strategy item;
CoreInternalOutcome outcome = item.Deserialize(*itr);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_strategyList.push_back(item);
}
m_strategyListHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
string DescribeBaselineStrategyListResponse::ToJsonString() const
{
rapidjson::Document value;
value.SetObject();
rapidjson::Document::AllocatorType& allocator = value.GetAllocator();
if (m_totalCountHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "TotalCount";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_totalCount, allocator);
}
if (m_strategyListHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "StrategyList";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator);
int i=0;
for (auto itr = m_strategyList.begin(); itr != m_strategyList.end(); ++itr, ++i)
{
value[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
(*itr).ToJsonObject(value[key.c_str()][i], allocator);
}
}
rapidjson::Value iKey(rapidjson::kStringType);
string key = "RequestId";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value().SetString(GetRequestId().c_str(), allocator), allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
return buffer.GetString();
}
uint64_t DescribeBaselineStrategyListResponse::GetTotalCount() const
{
return m_totalCount;
}
bool DescribeBaselineStrategyListResponse::TotalCountHasBeenSet() const
{
return m_totalCountHasBeenSet;
}
vector<Strategy> DescribeBaselineStrategyListResponse::GetStrategyList() const
{
return m_strategyList;
}
bool DescribeBaselineStrategyListResponse::StrategyListHasBeenSet() const
{
return m_strategyListHasBeenSet;
}
|
GLOBAL readRtcRaw
section .text
readRtcRaw:
push rbp
mov rbp,rsp
mov rax,rdi
out 70h,al
mov rax,0
in al,71h
mov rsp,rbp
pop rbp
ret
|
@256
D=A
@SP
M=D
@300
D=A
@LCL
M=D
@400
D=A
@ARG
M=D
@3000
D=A
@THIS
M=D
@3010
D=A
@THAT
M=D
@Sys.init$ret.0
D=A
@SP
A=M
M=D
@SP
M=M+1
@LCL
D=M
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@SP
A=M
M=D
@SP
M=M+1
@5
D=A
@0
D=D+A
@SP
D=M-D
@ARG
M=D
@SP
D=M
@LCL
M=D
@Sys.init
0;JMP
(Sys.init$ret.0)
// // This file is part of www.nand2tetris.org
// // and the book "The Elements of Computing Systems"
// // by Nisan and Schocken, MIT Press.
// // File name: projects/08/FunctionCalls/FibonacciElement/Main.vm
//
// // Computes the n'th element of the Fibonacci series, recursively.
// // n is given in argument[0]. Called by the Sys.init function
// // (part of the Sys.vm file), which also pushes the argument[0]
// // parameter before this code starts running.
//
// function Main.fibonacci 0
(Main.fibonacci)
@R13
M=0
D=0
(PUSH_ZEROS.0)
@0
D=A-D
@END_PUSH_ZEROS.0
D;JLE
@SP
A=M
M=0
@SP
M=M+1
@R13
M=M+1
D=M
@PUSH_ZEROS.0
0;JMP
(END_PUSH_ZEROS.0)
// push argument 0
@0
D=A
@ARG
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
// push constant 2
@2
D=A
@SP
A=M
M=D
@SP
M=M+1
// lt // checks if n<2
@SP
M=M-1
A=M
D=M
@SP
M=M-1
A=M
D=M-D
@SET_0
D;JLT
D=0
@DEST_0
0;JMP
(SET_0)
D=-1
@DEST_0
0;JMP
(DEST_0)
@SP
A=M
M=D
@SP
M=M+1
// if-goto IF_TRUE
@SP
M=M-1
A=M
D=M
@IF_TRUE
D;JNE
// goto IF_FALSE
@IF_FALSE
0;JMP
// label IF_TRUE // if n<2, return n
(IF_TRUE)
// push argument 0
@0
D=A
@ARG
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
// return
@LCL
D=M
@endFrame
M=D
@5
D=A
@endFrame
D=M-D
A=D
D=M
@retAddr
M=D
@SP
M=M-1
A=M
D=M
@ARG
A=M
M=D
@ARG
D=M
@SP
M=D+1
@1
D=A
@endFrame
D=M-D
A=D
D=M
@THAT
M=D
@2
D=A
@endFrame
D=M-D
A=D
D=M
@THIS
M=D
@3
D=A
@endFrame
D=M-D
A=D
D=M
@ARG
M=D
@4
D=A
@endFrame
D=M-D
A=D
D=M
@LCL
M=D
@retAddr
A=M
0;JMP
// label IF_FALSE // if n>=2, returns fib(n-2)+fib(n-1)
(IF_FALSE)
// push argument 0
@0
D=A
@ARG
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
// push constant 2
@2
D=A
@SP
A=M
M=D
@SP
M=M+1
// sub
@SP
M=M-1
A=M
D=M
@SP
M=M-1
A=M
M=M-D
@SP
M=M+1
// call Main.fibonacci 1 // computes fib(n-2)
@Main.fibonacci$ret.1
D=A
@SP
A=M
M=D
@SP
M=M+1
@LCL
D=M
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@SP
A=M
M=D
@SP
M=M+1
@5
D=A
@1
D=D+A
@SP
D=M-D
@ARG
M=D
@SP
D=M
@LCL
M=D
@Main.fibonacci
0;JMP
(Main.fibonacci$ret.1)
// push argument 0
@0
D=A
@ARG
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
// push constant 1
@1
D=A
@SP
A=M
M=D
@SP
M=M+1
// sub
@SP
M=M-1
A=M
D=M
@SP
M=M-1
A=M
M=M-D
@SP
M=M+1
// call Main.fibonacci 1 // computes fib(n-1)
@Main.fibonacci$ret.2
D=A
@SP
A=M
M=D
@SP
M=M+1
@LCL
D=M
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@SP
A=M
M=D
@SP
M=M+1
@5
D=A
@1
D=D+A
@SP
D=M-D
@ARG
M=D
@SP
D=M
@LCL
M=D
@Main.fibonacci
0;JMP
(Main.fibonacci$ret.2)
// add // returns fib(n-1) + fib(n-2)
@SP
M=M-1
A=M
D=M
@SP
M=M-1
A=M
M=M+D
@SP
M=M+1
// return
@LCL
D=M
@endFrame
M=D
@5
D=A
@endFrame
D=M-D
A=D
D=M
@retAddr
M=D
@SP
M=M-1
A=M
D=M
@ARG
A=M
M=D
@ARG
D=M
@SP
M=D+1
@1
D=A
@endFrame
D=M-D
A=D
D=M
@THAT
M=D
@2
D=A
@endFrame
D=M-D
A=D
D=M
@THIS
M=D
@3
D=A
@endFrame
D=M-D
A=D
D=M
@ARG
M=D
@4
D=A
@endFrame
D=M-D
A=D
D=M
@LCL
M=D
@retAddr
A=M
0;JMP
// // This file is part of www.nand2tetris.org
// // and the book "The Elements of Computing Systems"
// // by Nisan and Schocken, MIT Press.
// // File name: projects/08/FunctionCalls/FibonacciElement/Sys.vm
//
// // Pushes a constant, say n, onto the stack, and calls the Main.fibonacii
// // function, which computes the n'th element of the Fibonacci series.
// // Note that by convention, the Sys.init function is called "automatically"
// // by the bootstrap code.
//
// function Sys.init 0
(Sys.init)
@R13
M=0
D=0
(PUSH_ZEROS.1)
@0
D=A-D
@END_PUSH_ZEROS.1
D;JLE
@SP
A=M
M=0
@SP
M=M+1
@R13
M=M+1
D=M
@PUSH_ZEROS.1
0;JMP
(END_PUSH_ZEROS.1)
// push constant 4
@4
D=A
@SP
A=M
M=D
@SP
M=M+1
// call Main.fibonacci 1 // computes the 4'th fibonacci element
@Main.fibonacci$ret.3
D=A
@SP
A=M
M=D
@SP
M=M+1
@LCL
D=M
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@SP
A=M
M=D
@SP
M=M+1
@5
D=A
@1
D=D+A
@SP
D=M-D
@ARG
M=D
@SP
D=M
@LCL
M=D
@Main.fibonacci
0;JMP
(Main.fibonacci$ret.3)
// label WHILE
(WHILE)
// goto WHILE // loops infinitely
@WHILE
0;JMP
|
C arm/ecc-384-modp.asm
ifelse(<
Copyright (C) 2013 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
>)
.file "ecc-384-modp.asm"
.arm
define(<RP>, <r1>)
define(<T0>, <r0>)
define(<T1>, <r2>)
define(<T2>, <r3>)
define(<T3>, <r4>)
define(<F0>, <r5>)
define(<F1>, <r6>)
define(<F2>, <r7>)
define(<F3>, <r8>)
define(<F4>, <r10>)
define(<N>, <r12>)
define(<H>, <lr>)
C ecc_384_modp (const struct ecc_modulo *m, mp_limb_t *rp)
.text
.align 2
PROLOGUE(nettle_ecc_384_modp)
push {r4,r5,r6,r7,r8,r10,lr}
add RP, RP, #80
ldm RP, {T0, T1, T2, T3} C 20-23
C First get top 4 limbs, which need folding twice, as
C
C T3 T2 T1 T0
C T3 T2 T1
C -T3
C ----------------
C F4 F3 F2 F1 F0
C
C Start with
C
C T3 T1 T0
C T1
C -T3
C -----------
C F2 F1 F0 Always fits
adds F0, T0, T1
adcs F1, T1, #0
adcs F2, T3, #0
subs F0, F0, T3
sbcs F1, F1, #0
sbcs F2, F2, #0
C T3 T2 T2 0
C F2 F1 F0
C ----------------
C F4 F3 F2 F1 F0
mov F4, #0
adds F1, F1, T2
adcs F2, F2, T2
adcs F3, T3, #0
adcs F4, F4, #0
C Add in to high part
sub RP, RP, #32
ldm RP, {T0, T1, T2, T3} C 12-15
mov H, #0
adds F0, T0, F0
adcs F1, T1, F1
adcs F2, T2, F2
adcs F3, T3, F3
adcs F4, F4, #0 C Do F4 later
C Add to low part, keeping carry (positive or negative) in H
sub RP, RP, #48
ldm RP, {T0, T1, T2, T3} C 0-3
mov H, #0
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
adc H, H, #0
subs T1, T1, F0
sbcs T2, T2, F1
sbcs T3, T3, F2
sbc H, H, #0
adds T3, T3, F0
adc H, H, #0
stm RP!, {T0,T1,T2,T3} C 0-3
mov N, #2
.Loop:
ldm RP, {T0,T1,T2,T3} C 4-7
C First, propagate carry
adds T0, T0, H
asr H, #31 C Sign extend
adcs T1, T1, H
adcs T2, T2, H
adcs T3, T3, H
adc H, H, #0
C +B^4 term
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
adc H, H, #0
C +B^3 terms
ldr F0, [RP, #+48] C 16
adds T0, T0, F1
adcs T1, T1, F2
adcs T2, T2, F3
adcs T3, T3, F0
adc H, H, #0
C -B
ldr F1, [RP, #+52] C 17-18
ldr F2, [RP, #+56]
subs T0, T0, F3
sbcs T1, T1, F0
sbcs T2, T2, F1
sbcs T3, T3, F2
sbcs H, H, #0
C +1
ldr F3, [RP, #+60] C 19
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
adc H, H, #0
subs N, N, #1
stm RP!, {T0,T1,T2,T3}
bne .Loop
C Fold high limbs, we need to add in
C
C F4 F4 0 -F4 F4 H H 0 -H H
C
C We always have F4 >= 0, but we can have H < 0.
C Sign extension gets tricky when F4 = 0 and H < 0.
sub RP, RP, #48
ldm RP, {T0,T1,T2,T3} C 0-3
C H H 0 -H H
C ----------------
C S H F3 F2 F1 F0
C
C Define S = H >> 31 (asr), we then have
C
C F0 = H
C F1 = S - H
C F2 = - [H > 0]
C F3 = H - [H > 0]
C H = H + S
C
C And we get underflow in S - H iff H > 0
C H = 0 H > 0 H = -1
mov F0, H C 0 H -1
asr H, #31
subs F1, H, F0 C 0,C=1 -H,C=0 0,C=1
sbc F2, F2, F2 C 0 -1 0
sbc F3, F0, #0 C 0 H-1 -1
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
adc H, H, F0 C 0+cy H+cy -2+cy
stm RP!, {T0,T1,T2,T3} C 0-3
ldm RP, {T0,T1,T2,T3} C 4-7
C F4 0 -F4
C ---------
C F3 F2 F1
rsbs F1, F4, #0
sbc F2, F2, F2
sbc F3, F4, #0
C Sign extend H
adds F0, F4, H
asr H, H, #31
adcs F1, F1, H
adcs F2, F2, H
adcs F3, F3, H
adcs F4, F4, H
adc H, H, #0
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
stm RP!, {T0,T1,T2,T3} C 4-7
ldm RP, {T0,T1,T2,T3} C 8-11
adcs T0, T0, F4
adcs T1, T1, H
adcs T2, T2, H
adcs T3, T3, H
adc H, H, #0
stm RP, {T0,T1,T2,T3} C 8-11
C Final (unlikely) carry
sub RP, RP, #32
ldm RP, {T0,T1,T2,T3} C 0-3
C Fold H into F0-F4
mov F0, H
asr H, #31
subs F1, H, F0
sbc F2, F2, F2
sbc F3, F0, #0
add F4, F0, H
adds T0, T0, F0
adcs T1, T1, F1
adcs T2, T2, F2
adcs T3, T3, F3
stm RP!, {T0,T1,T2,T3} C 0-3
ldm RP, {T0,T1,T2,T3} C 4-7
adcs T0, T0, F4
adcs T1, T1, H
adcs T2, T2, H
adcs T3, T3, H
stm RP!, {T0,T1,T2,T3} C 4-7
ldm RP, {T0,T1,T2,T3} C 8-11
adcs T0, T0, H
adcs T1, T1, H
adcs T2, T2, H
adcs T3, T3, H
stm RP!, {T0,T1,T2,T3} C 8-11
pop {r4,r5,r6,r7,r8,r10,pc}
EPILOGUE(nettle_ecc_384_modp)
|
; *******************************************************************************************
; *******************************************************************************************
;
; Name : multiply.asm
; Purpose : 32 bit Multiply
; Date : 3rd June 2019
; Author : paul@robsons.org.uk
;
; *******************************************************************************************
; *******************************************************************************************
; *******************************************************************************************
;
; 32 bit multiply
;
; *******************************************************************************************
Binary_Multiply: ;; *
lda EXSValueL+0,x ; multiplier to DTemp1, multiplicand in Value+2
sta DTemp1
lda EXSValueH+0,x
sta DTemp1+2
stz EXSValueL+0,x ; zero result
stz EXSValueH+0,x
_BinaryMultiply_Loop:
lda DTemp1 ; multiplier zero then exit
ora DTemp1+2
beq _BinaryMultiply_Exit
lda DTemp1 ; check bit 0 of multiplier
and #1
beq _BinaryMultiply_NoAdd
clc ; add multiplicand to result.
lda EXSValueL+0,x
adc EXSValueL+2,x
sta EXSValueL+0,x
lda EXSValueH+0,x
adc EXSValueH+2,x
sta EXSValueH+0,x
_BinaryMultiply_NoAdd:
lsr DTemp1+2 ; halve multiplier
ror DTemp1
asl EXSValueL+2,x ; double multiplicand
rol EXSValueH+2,x
bra _BinaryMultiply_Loop ; go round again.
_BinaryMultiply_Exit:
rts
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 4, 0x90
.globl cpAESCMAC_Update_AES_NI
.type cpAESCMAC_Update_AES_NI, @function
cpAESCMAC_Update_AES_NI:
movslq %edx, %rdx
movdqu (%rdi), %xmm0
.p2align 4, 0x90
.Lblks_loopgas_1:
movdqu (%rsi), %xmm1
movdqa (%r8), %xmm4
mov %r8, %r9
pxor %xmm1, %xmm0
pxor %xmm4, %xmm0
movdqa (16)(%r9), %xmm4
add $(16), %r9
mov %rcx, %r10
sub $(1), %r10
.p2align 4, 0x90
.Lcipher_loopgas_1:
aesenc %xmm4, %xmm0
movdqa (16)(%r9), %xmm4
add $(16), %r9
dec %r10
jnz .Lcipher_loopgas_1
aesenclast %xmm4, %xmm0
add $(16), %rsi
sub $(16), %rdx
jnz .Lblks_loopgas_1
pxor %xmm4, %xmm4
movdqu %xmm0, (%rdi)
ret
.Lfe1:
.size cpAESCMAC_Update_AES_NI, .Lfe1-(cpAESCMAC_Update_AES_NI)
|
; A193767: The number of dominoes in a largest saturated domino covering of the 4 by n board.
; 2,5,8,12,14,17,21,24,26,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177
mov $3,$0
lpb $0
mod $0,3
mul $0,4
pow $1,$4
lpe
add $1,2
mov $2,$3
mul $2,3
add $1,$2
mov $0,$1
|
#include "canvas.h"
Canvas *CanvasInstance;
int state = 0;
/* Surface to store current scribbles */
static cairo_surface_t *surface = NULL;
GtkWidget *da2;
static void clear_surface(void)
{
cairo_t *cr;
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_paint(cr);
cairo_destroy(cr);
}
static gboolean configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
if (surface)
{
cairo_surface_destroy(surface);
}
surface = gdk_window_create_similar_surface(gtk_widget_get_window(widget),
CAIRO_CONTENT_COLOR, gtk_widget_get_allocated_width(widget),
gtk_widget_get_allocated_height(widget));
clear_surface();
return TRUE;
}
static void draw_brush(GtkWidget *widget)
{
cairo_t *cr;
cr = cairo_create(surface);
cairo_set_line_width(cr, 0.9);
cairo_move_to(cr, 10, 10);
cairo_line_to(cr, (int) (CanvasInstance->viewportX - 10), 10);
cairo_line_to(cr, (int) (CanvasInstance->viewportX - 10), CanvasInstance->viewportY - 10);
cairo_line_to(cr, (int) (10), CanvasInstance->viewportY - 10);
cairo_line_to(cr, (int) (10), 10);
cairo_set_source_rgb(cr, 1, 0, 0);
std::list<GeometricObject *>::iterator i;
int j = 0;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->Draw(cr);
j++;
}
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_stroke(cr);
cairo_destroy(cr);
}
bool hasPoint = false;
Point *firstLinePoint;
std::vector<Point *> _mousePoints;
static gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event,
gpointer data)
{
if (surface == NULL)
{
return false;
}
if (event->button == GDK_BUTTON_PRIMARY)
{
if (state == 0)
{
CanvasInstance->AddPoint(event->x, event->y);
}
if (state == 1)
{
if (!hasPoint)
{
hasPoint = true;
firstLinePoint = new Point(event->x, event->y, 0);
}
else
{
hasPoint = false;
CanvasInstance->AddLine(firstLinePoint->position[0],
firstLinePoint->position[1], event->x, event->y);
}
}
if (state == 2)
{
CanvasInstance->AddPoint(event->x, event->y);
_mousePoints.push_back(new Point(event->x, event->y, 0));
}
if (state == 3)
{
CanvasInstance->AddPoint(event->x, event->y);
_mousePoints.push_back(new Point(event->x, event->y, 0));
if (_mousePoints.size() >= 4)
{
CanvasInstance->AddCurve(_mousePoints);
_mousePoints.erase(_mousePoints.begin());
}
}
}
else if (event->button == GDK_BUTTON_SECONDARY)
{
if (state == 2)
{
CanvasInstance->AddPolygon(_mousePoints);
_mousePoints.clear();
}
}
return true;
}
static gboolean draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
{
cairo_set_source_surface(cr, surface, 0, 0);
cairo_paint(cr);
draw_brush(widget);
//g_print("drawSignal\n");
return FALSE;
}
static void close_window(void)
{
if (surface)
{
cairo_surface_destroy(surface);
}
gtk_main_quit();
}
Canvas::Canvas()
{
// g_print("CAnvas init\n");
//if(!CanvasInstance){
//g_print("CAnvas init\n");
CanvasInstance = this;
//}
inPerpective = false;
//(Point *initialPos, float rot, float _scale,int _minX,int _minY,int _maxX,int _maxY)
win = new Window(new Point(0, 0, 0), 0, 0, 1, 600, 600);
//worldCoordinates = new Point(win->p0->position[0],win->p0->position[1],win->p0->position[2]+1);
scale = 1;
viewportX = 600;
viewportY = 600;
windowMinX = -200;
windowMaxX = 400;
windowMinY = -300;
windowMaxY = 300;
Point *GPoints[4][4]; //pontos para bezier
GPoints[0][0] = new Point(100, 300, 1);
GPoints[1][0] = new Point(100, 300, 2);
GPoints[2][0] = new Point(100, 300, 3);
GPoints[3][0] = new Point(100, 300, 4);
GPoints[0][1] = new Point(200, 300, 1);
GPoints[1][1] = new Point(200, -200, 2);
GPoints[2][1] = new Point(200, -200, 3);
GPoints[3][1] = new Point(200, 300, 4);
GPoints[0][2] = new Point(300, 300, 1);
GPoints[1][2] = new Point(300, -200, 2);
GPoints[2][2] = new Point(300, -200, 3);
GPoints[3][2] = new Point(300, 300, 4);
GPoints[0][3] = new Point(400, 300, 1);
GPoints[1][3] = new Point(400, 300, 2);
GPoints[2][3] = new Point(400, 300, 3);
GPoints[3][3] = new Point(400, 300, 4);
Point *GP[4][4]; //pontos para spline
GP[0][0] = new Point(-1, 3, -1);
GP[1][0] = new Point(-1, 3, -2);
GP[2][0] = new Point(-1, 3, -3);
GP[3][0] = new Point(-1, 3, -4);
GP[0][1] = new Point(0, 3, 1);
GP[1][1] = new Point(0, -2, 2);
GP[2][1] = new Point(0, -2, 3);
GP[3][1] = new Point(0, 3, 4);
GP[0][2] = new Point(1, 3, -1);
GP[1][2] = new Point(1, -2, -2);
GP[2][2] = new Point(1, -2, -3);
GP[3][2] = new Point(1, 3, -4);
GP[0][3] = new Point(2, 3, 1);
GP[1][3] = new Point(2, 3, 2);
GP[2][3] = new Point(2, 3, 3);
GP[3][3] = new Point(2, 3, 4);
superSpline *sSpline = new superSpline(GP);
sSpline->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
sSpline->SetViewPort(viewportX, viewportY);
//lg.push_back(sSpline);
superBezier *sB = new superBezier(GPoints);
sB->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
sB->SetViewPort(viewportX, viewportY);
//lg.push_back(sB);
std::vector < Point * > cPoints(4);
cPoints[0] = new Point(-300, -100, 2);
cPoints[1] = new Point(-300, 200, 2);
cPoints[2] = new Point(-100, 200, 2);
cPoints[3] = new Point(-100, 600, 2);
Curve *curve = new Curve(cPoints);
curve->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
curve->SetViewPort(viewportX, viewportY);
Spline *spline = new Spline(cPoints);
spline->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
spline->SetViewPort(viewportX, viewportY);
// curve->Translate(50,-100);
// curve->Scale(1);
// curve->Rotate(90);
// lg.push_back(spline);
cPoints[0] = cPoints[1];
cPoints[1] = cPoints[2];
cPoints[2] = cPoints[3];
cPoints[3] = new Point(0, 800, 2);
spline = new Spline(cPoints);
spline->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
spline->SetViewPort(viewportX, viewportY);
//lg.push_back(spline);
//lg.push_back(curve);
//
axisX = new Line(new Point(-1000, 0, 1), new Point(1000, 0, 1));
axisX->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
axisX->SetViewPort(viewportX, viewportY);
// lg.push_back(axisX);
axisY = new Line(new Point(0, -1000, 1), new Point(0, 1000, 1));
axisY->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
axisY->SetViewPort(viewportX, viewportY);
// lg.push_back(axisY);
// /**/
Point *p = new Point(-150, 100, 1);
p->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
p->SetViewPort(viewportX, viewportY);
// lg.push_back(p);
//
// for(int i = 0; i < 360; i+=30){
// p = new Point(-100,0);
// p->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
// p->SetViewPort(viewportX,viewportY);
// p->Rotate(i);
// lg.push_back(p);
// }
//
// for(int i = 0; i < 360; i+=30){
// p = new Point(50,100);
// p->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
// p->SetViewPort(viewportX,viewportY);
// p->RotateAroundPoint(i,100,150);
// lg.push_back(p);
// }
//
// for(int i = 0; i < 360; i+=30){
// l = new Line(new Point(-100,0),new Point(-100,100));
// l->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
// l->SetViewPort(viewportX,viewportY);
// l->Rotate(i);
// l->Scale(i/100);
// lg.push_back(l);
// }
//
// for(int i = 0; i < 360; i+=30){
// l = new Line(new Point(-100,0),new Point(-100,100));
// l->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
// l->SetViewPort(viewportX,viewportY);
// l->RotateAroundWorld(i);
// l->Scale(0.5);
// lg.push_back(l);
// }
//
//
// // l->Translate(-100,0);
// // l->ApplyTransform();
// lg.push_back(l);
//
//obj.GetPoints();
Line *l = new Line(new Point(-100, 100, 1), new Point(700, -100, 1));
l->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
l->SetViewPort(viewportX, viewportY);
//lg.push_back(l);
l = new Line(new Point(10, 10, 1), new Point(100, 10, 1));
l->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
l->SetViewPort(viewportX, viewportY);
//lg.push_back(l);
l = new Line(new Point(-700, -400, 1), new Point(700, 400, 1));
l->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
l->SetViewPort(viewportX, viewportY);
// lg.push_back(l);
//+++++++++++++++++Criando poligono em 3D
std::vector < Point * > points(4);
points[0] = new Point(-70, 70, 1);
points[0] = new Point(-400, 130, 1);
points[1] = new Point(-400, 400, 1);
points[2] = new Point(30, 400, 1);
points[3] = new Point(30, 130, 1);
Polygon *pol = new Polygon(points);
pol->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
pol->SetViewPort(viewportX, viewportY);
lg.push_back(pol);
std::vector < Point * > points2(4);
points2[0] = new Point(-70, 70, 4);
points2[0] = new Point(-400, 130, 4);
points2[1] = new Point(-400, 400, 4);
points2[2] = new Point(30, 400, 4);
points2[3] = new Point(30, 130, 4);
Polygon *pol2 = new Polygon(points2);
pol2->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
pol2->SetViewPort(viewportX, viewportY);
lg.push_back(pol2);
for (int i = 0; i < points.size(); i++)
{
Line *l = new Line(
new Point(points[i]->position[0], points[i]->position[1],
points[i]->position[2]),
new Point(points2[i]->position[0], points2[i]->position[1],
points2[i]->position[2]));
l->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
l->SetViewPort(viewportX, viewportY);
lg.push_back(l);
}
//+++++++++++++++++FIM poligono em 3D
Polygon *polOBJ = new Polygon(obj.GetPoints());
polOBJ->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
polOBJ->SetViewPort(viewportX, viewportY);
//lg.push_back(polOBJ);
//Pegando a distancia do centro de projeção a origem
float diffX = win->cop->position[0];
float diffY = win->cop->position[1];
float diffZ = win->cop->position[2];
//Transalado a window
win->Translate(-diffX, -diffY, -diffZ);
//Atualizo Objetos
UpdateObjects();
//Tranlado o Mundo
TranslateWorld(-diffX, -diffY, -diffZ);
RotateWorldInX(-win->angX);
RotateWorldInY(-win->angY);
win->Scale();
ScaleWorld(win->scale);
// Polygon *polOBJ = new Polygon(obj.GetPoints());
// polOBJ->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
// polOBJ->SetViewPort(viewportX, viewportY);
//
// lg.push_back(polOBJ);
//ProjectObjects();
UpdateObjects();
ClipObjects();
}
void Canvas::AddPoint(float mouseX, float mouseY)
{
//g_print("x %i y %i \%i",);
// Point *p = new Point(
// win->p0->position[0] + mouseX * (win->scale)
// - (viewportX / 2) * (win->scale),
// win->p0->position[1] - mouseY * (win->scale)
// + (viewportY / 2) * (win->scale), win->p0->position[2]-1);
// p->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
// p->SetViewPort(viewportX, viewportY);
// //p->Scale()
// lg.push_back(p);
Point *p = new Point(win->p0->position[0] + mouseX - (viewportX / 2),
win->p0->position[1] - mouseY + (viewportY / 2),
win->p0->position[2] + 1);
p->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
p->SetViewPort(viewportX, viewportY);
p->ScaleWorld(win->scale);
//p->Scale()
lg.push_back(p);
Redraw();
}
void Canvas::AddLine(float x1, float y1, float x2, float y2)
{
Line *line = new Line(
new Point(win->p0->position[0] + x1 - (viewportX / 2),
win->p0->position[1] - y1 + (viewportY / 2),
win->p0->position[2] + 1),
new Point(win->p0->position[0] + x2 - (viewportX / 2),
win->p0->position[1] - y2 + (viewportY / 2),
win->p0->position[2] + 1));
line->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
line->SetViewPort(viewportX, viewportY);
line->ScaleWorld(win->scale);
lg.push_back(line);
Redraw();
}
void Canvas::AddPolygon(std::vector<Point *> mousePoints)
{
std::vector < Point * > polyPoints;
for (int i = 0; i < mousePoints.size(); i++)
{
polyPoints.push_back(
new Point(
win->p0->position[0] + mousePoints[i]->position[0]
- (viewportX / 2),
win->p0->position[1] - mousePoints[i]->position[1]
+ (viewportY / 2), win->p0->position[2] + 1));
}
Polygon *pol = new Polygon(polyPoints);
pol->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
pol->SetViewPort(viewportX, viewportY);
pol->ScaleWorld(win->scale);
lg.push_back(pol);
Redraw();
}
void Canvas::AddCurve(std::vector<Point *> mousePoints)
{
std::vector < Point * > polyPoints;
for (int i = 0; i < mousePoints.size(); i++)
{
polyPoints.push_back(
new Point(
win->p0->position[0] + mousePoints[i]->position[0]
- (viewportX / 2),
win->p0->position[1] - mousePoints[i]->position[1]
+ (viewportY / 2), win->p0->position[2] + 1));
}
Spline *spline = new Spline(polyPoints);
spline->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
spline->SetViewPort(viewportX, viewportY);
spline->ScaleWorld(win->scale);
Curve *curve = new Curve(polyPoints);
curve->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
curve->SetViewPort(viewportX, viewportY);
curve->ScaleWorld(win->scale);
//lg.push_back(curve);
lg.push_back(spline);
Redraw();
}
void Canvas::CreatePoint()
{
state = 0;
_mousePoints.clear();
}
void Canvas::CreateLine()
{
state = 1;
_mousePoints.clear();
}
void Canvas::CreatePolygon()
{
state = 2;
_mousePoints.clear();
}
void Canvas::CreateCurve()
{
state = 3;
_mousePoints.clear();
}
void Canvas::ChangeViewType()
{
inPerpective = !inPerpective;
if (inPerpective)
{
g_print("\n\n Project \n\n");
ProjectObjects();
}
else
{
UnprojectObjects();
}
Redraw();
}
void Canvas::ProjectObjects()
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->Project();
}
}
void Canvas::UnprojectObjects()
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->Unproject();
}
}
void Canvas::ClipObjects()
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->Clip();
}
}
void Canvas::ScaleWorld(float scale)
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->ScaleWorld(scale);
(*i)->ApplyTransform();
}
ClipObjects();
}
void Canvas::RotateWorldInX(float ang)
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->SetVUp(ang);
(*i)->RotateAroundWorldInX(ang);
(*i)->ApplyTransform();
}
ClipObjects();
}
void Canvas::RotateWorldInY(float ang)
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->SetVUp(ang);
(*i)->RotateAroundWorldInY(ang);
(*i)->ApplyTransform();
}
ClipObjects();
}
void Canvas::RotateWorldInZ(float ang)
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->SetVUp(ang);
(*i)->RotateAroundWorldInZ(ang);
(*i)->ApplyTransform();
}
ClipObjects();
}
void Canvas::TranslateWorld(float x, float y, float z)
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
(*i)->Translate(x, y, z);
(*i)->ApplyTransform();
}
}
void Canvas::UpdateObjects()
{
std::list<GeometricObject *>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i)
{
//g_print("Min x %f max x %f", win->minX, win->maxX);
(*i)->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
// (*i)->SetWindow(-1,-1,1,1);
}
//ClipObjects();
}
void Canvas::SetCanvas(GtkWidget *movementGrid)
{
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_grid_attach(GTK_GRID(movementGrid), frame, 1, 3, 14, 14);
CanvasInstance->da = gtk_drawing_area_new();
gtk_widget_set_size_request(CanvasInstance->da, viewportX, viewportY);
gtk_container_add(GTK_CONTAINER(frame), CanvasInstance->da);
g_signal_connect(CanvasInstance->da, "draw", G_CALLBACK(draw_cb), NULL);
g_signal_connect(CanvasInstance->da, "button-press-event",
G_CALLBACK(button_press_event_cb), NULL);
g_signal_connect(CanvasInstance->da, "configure-event",
G_CALLBACK(configure_event_cb), NULL);
gtk_widget_set_events(CanvasInstance->da,
gtk_widget_get_events(CanvasInstance->da) | GDK_BUTTON_PRESS_MASK);
gtk_widget_show(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::Redraw()
{
clear_surface();
ClipObjects();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::DrawLine(int xi, int yi, int xf, int yf)
{
// CanvasInstance->lg.push_back(new Line(new Point(100,300),new Point(800,200)));
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::GoDown()
{
/*win->Translate(0, -0.5f, 0);
clear_surface();
std::list<GeometricObject*>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i) {
(*i)->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
}
*/
clear_surface();
UnprojectObjects();
TranslateWorld(0, -1, 0);
ProjectObjects();
UpdateObjects();
ClipObjects();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::GoUp()
{
/*win->Translate(0, 0.5f, 0);
clear_surface();
std::list<GeometricObject*>::iterator i;
for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i) {
(*i)->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
}*/
//ProjectObjects();
clear_surface();
UnprojectObjects();
TranslateWorld(0, 1, 0);
ProjectObjects();
UpdateObjects();
ClipObjects();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::GoLeft()
{
// win->minX-=10;
// win->maxX-=10;
// win->Translate(-0.5f, 0, 0);
// clear_surface();
//
// std::list<GeometricObject*>::iterator i;
// for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i) {
// (*i)->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
// }
// //ProjectObjects();
// ClipObjects();
clear_surface();
UnprojectObjects();
TranslateWorld(-1, 0, 0);
ProjectObjects();
UpdateObjects();
ClipObjects();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::GoRight()
{
/*
win->minX+=10;
win->maxX+=10*/
//
// win->Translate(0.5f, 0, 0);
//
// clear_surface();
//
// std::list<GeometricObject*>::iterator i;
// for (i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i) {
// (*i)->SetWindow(win->minX, win->minY, win->maxX, win->maxY, win->dop);
// }
// //ProjectObjects();
// ClipObjects();
clear_surface();
UnprojectObjects();
TranslateWorld(1, 0, 0);
ProjectObjects();
UpdateObjects();
ClipObjects();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::RotateZ()
{
float diffX = win->p0->position[0];
float diffY = win->p0->position[1];
float diffZ = win->p0->position[2];
win->Translate(-win->p0->position[0], -win->p0->position[1],
-win->p0->position[2]);
UpdateObjects();
TranslateWorld(-diffX, -diffY, -diffZ);
RotateWorldInY(-90);
UpdateObjects();
clear_surface();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::ZoomIn()
{
// g_print("Translate in x %f \n",win->p0->position[0]);
/*
win->minX+=1;
win->maxX-=1;
win->minY+=1;
win->maxY-=1;
clear_surface();
std::list<GeometricObject*>::iterator i;
for(i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i){
(*i)->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
}
*/
float diffX = win->p0->position[0];
float diffY = win->p0->position[1];
float diffZ = win->p0->position[2];
win->Translate(-win->p0->position[0], -win->p0->position[1],
-win->p0->position[2]);
UpdateObjects();
TranslateWorld(-diffX, -diffY, -diffZ);
RotateWorldInZ(-90);
//win->Scale();
//ScaleWorld(win->scale);
UpdateObjects();
clear_surface();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::ZoomOut()
{
/*win->minX-=1;
win->maxX+=1;
win->minY-=1;
win->maxY+=1;
clear_surface();
std::list<GeometricObject*>::iterator i;
for(i = CanvasInstance->lg.begin(); i != CanvasInstance->lg.end(); ++i){
(*i)->SetWindow(win->minX,win->minY,win->maxX,win->maxY);
}*/
float diffX = win->p0->position[0];
float diffY = win->p0->position[1];
float diffZ = win->p0->position[2];
win->Translate(-win->p0->position[0], -win->p0->position[1],
-win->p0->position[2]);
UpdateObjects();
TranslateWorld(-diffX, -diffY, -diffZ);
RotateWorldInZ(90);
//win->Scale();
//ScaleWorld(win->scale);
UpdateObjects();
clear_surface();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::ZoomPlus()
{
ScaleWorld(1.5f);
UpdateObjects();
clear_surface();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
}
void Canvas::ZoomMinus()
{
ScaleWorld(0.5f);
UpdateObjects();
clear_surface();
draw_brush(CanvasInstance->da);
gtk_widget_queue_draw(CanvasInstance->da);
} |
#include <Common/CurrentMetrics.h>
/// Available metrics. Add something here as you wish.
#define APPLY_FOR_METRICS(M) \
M(Query, "Number of executing queries") \
M(Merge, "Number of executing background merges") \
M(PartMutation, "Number of mutations (ALTER DELETE/UPDATE)") \
M(ReplicatedFetch, "Number of data parts being fetched from replica") \
M(ReplicatedSend, "Number of data parts being sent to replicas") \
M(ReplicatedChecks, "Number of data parts checking for consistency") \
M(BackgroundPoolTask, "Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping)") \
M(BackgroundMovePoolTask, "Number of active tasks in BackgroundProcessingPool for moves") \
M(BackgroundSchedulePoolTask, "Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc.") \
M(DiskSpaceReservedForMerge, "Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts.") \
M(DistributedSend, "Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode.") \
M(QueryPreempted, "Number of queries that are stopped and waiting due to 'priority' setting.") \
M(TCPConnection, "Number of connections to TCP server (clients with native interface)") \
M(HTTPConnection, "Number of connections to HTTP server") \
M(InterserverConnection, "Number of connections from other replicas to fetch parts") \
M(OpenFileForRead, "Number of files open for reading") \
M(OpenFileForWrite, "Number of files open for writing") \
M(Read, "Number of read (read, pread, io_getevents, etc.) syscalls in fly") \
M(Write, "Number of write (write, pwrite, io_getevents, etc.) syscalls in fly") \
M(SendScalars, "Number of connections that are sending data for scalars to remote servers.") \
M(SendExternalTables, "Number of connections that are sending data for external tables to remote servers. External tables are used to implement GLOBAL IN and GLOBAL JOIN operators with distributed subqueries.") \
M(QueryThread, "Number of query processing threads") \
M(ReadonlyReplica, "Number of Replicated tables that are currently in readonly state due to re-initialization after ZooKeeper session loss or due to startup without ZooKeeper configured.") \
M(LeaderReplica, "Number of Replicated tables that are leaders. Leader replica is responsible for assigning merges, cleaning old blocks for deduplications and a few more bookkeeping tasks. There may be no more than one leader across all replicas at one moment of time. If there is no leader it will be elected soon or it indicate an issue.") \
M(MemoryTracking, "Total amount of memory (bytes) allocated in currently executing queries. Note that some memory allocations may not be accounted.") \
M(MemoryTrackingInBackgroundProcessingPool, "Total amount of memory (bytes) allocated in background processing pool (that is dedicated for backround merges, mutations and fetches). Note that this value may include a drift when the memory was allocated in a context of background processing pool and freed in other context or vice-versa. This happens naturally due to caches for tables indexes and doesn't indicate memory leaks.") \
M(MemoryTrackingInBackgroundMoveProcessingPool, "Total amount of memory (bytes) allocated in background processing pool (that is dedicated for backround moves). Note that this value may include a drift when the memory was allocated in a context of background processing pool and freed in other context or vice-versa. This happens naturally due to caches for tables indexes and doesn't indicate memory leaks.") \
M(MemoryTrackingInBackgroundSchedulePool, "Total amount of memory (bytes) allocated in background schedule pool (that is dedicated for bookkeeping tasks of Replicated tables).") \
M(MemoryTrackingForMerges, "Total amount of memory (bytes) allocated for background merges. Included in MemoryTrackingInBackgroundProcessingPool. Note that this value may include a drift when the memory was allocated in a context of background processing pool and freed in other context or vice-versa. This happens naturally due to caches for tables indexes and doesn't indicate memory leaks.") \
M(LeaderElection, "Number of Replicas participating in leader election. Equals to total number of replicas in usual cases.") \
M(EphemeralNode, "Number of ephemeral nodes hold in ZooKeeper.") \
M(ZooKeeperSession, "Number of sessions (connections) to ZooKeeper. Should be no more than one, because using more than one connection to ZooKeeper may lead to bugs due to lack of linearizability (stale reads) that ZooKeeper consistency model allows.") \
M(ZooKeeperWatch, "Number of watches (event subscriptions) in ZooKeeper.") \
M(ZooKeeperRequest, "Number of requests to ZooKeeper in fly.") \
M(DelayedInserts, "Number of INSERT queries that are throttled due to high number of active data parts for partition in a MergeTree table.") \
M(ContextLockWait, "Number of threads waiting for lock in Context. This is global lock.") \
M(StorageBufferRows, "Number of rows in buffers of Buffer tables") \
M(StorageBufferBytes, "Number of bytes in buffers of Buffer tables") \
M(DictCacheRequests, "Number of requests in fly to data sources of dictionaries of cache type.") \
M(Revision, "Revision of the server. It is a number incremented for every release or release candidate except patch releases.") \
M(VersionInteger, "Version of the server in a single integer number in base-1000. For example, version 11.22.33 is translated to 11022033.") \
M(RWLockWaitingReaders, "Number of threads waiting for read on a table RWLock.") \
M(RWLockWaitingWriters, "Number of threads waiting for write on a table RWLock.") \
M(RWLockActiveReaders, "Number of threads holding read lock in a table RWLock.") \
M(RWLockActiveWriters, "Number of threads holding write lock in a table RWLock.") \
M(GlobalThread, "Number of threads in global thread pool.") \
M(GlobalThreadActive, "Number of threads in global thread pool running a task.") \
M(LocalThread, "Number of threads in local thread pools. Should be similar to GlobalThreadActive.") \
M(LocalThreadActive, "Number of threads in local thread pools running a task.") \
M(DistributedFilesToInsert, "Number of pending files to process for asynchronous insertion into Distributed tables. Number of files for every shard is summed.") \
namespace CurrentMetrics
{
#define M(NAME, DOCUMENTATION) extern const Metric NAME = __COUNTER__;
APPLY_FOR_METRICS(M)
#undef M
constexpr Metric END = __COUNTER__;
std::atomic<Value> values[END] {}; /// Global variable, initialized by zeros.
const char * getName(Metric event)
{
static const char * strings[] =
{
#define M(NAME, DOCUMENTATION) #NAME,
APPLY_FOR_METRICS(M)
#undef M
};
return strings[event];
}
const char * getDocumentation(Metric event)
{
static const char * strings[] =
{
#define M(NAME, DOCUMENTATION) DOCUMENTATION,
APPLY_FOR_METRICS(M)
#undef M
};
return strings[event];
}
Metric end() { return END; }
}
#undef APPLY_FOR_METRICS
|
/*
Copyright 2014, The University of Texas at Austin
All rights reserved.
THIS FILE IS PART OF THE CONTAINMENT DOMAINS RUNTIME LIBRARY
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "cd_event.h"
#include <unistd.h>
using namespace cd;
CDEvent::CDEvent() : event_(0) , current_pos_(0)
{
InitEvent();
}
CDEvent::~CDEvent()
{
DestroyEvent();
}
void CDEvent::InitEvent()
{
if( event_ == 0 )
{
event_ = new uint32_t[SIZE_EVENT_ARRAY];
}
}
void CDEvent::DestroyEvent()
{
if( event_ != 0)
{
delete [] event_;
}
}
uint32_t CDEvent::AddEvent()
{
uint32_t ret_prepare_pos = current_pos_;
uint32_t converted_pos = current_pos_ / sizeof(uint32_t);
if( len_event_ < converted_pos)
{
//FIXME need to allocate additional memory and then probably memcpy ? the original one? let's check this out.
}
SetEvent(current_pos_);
current_pos_++;
return ret_prepare_pos;
}
void CDEvent::ResetEvent(uint32_t pos)
{
//x& = ~(1u <<3);
// check if we need larger array.
uint32_t converted_pos = pos / sizeof(uint32_t);
uint32_t offset = pos % sizeof(uint32_t);
event_[converted_pos] &= ~(1u << offset);
}
void CDEvent::SetEvent(uint32_t pos)
{
// x|= (1u << 3); // 4th bit set
uint32_t converted_pos = pos / sizeof(uint32_t);
uint32_t offset = pos % sizeof(uint32_t);
event_[converted_pos] |= (1u << offset);
}
bool CDEvent::Test()
{
if( current_pos_ == 0 ) return false;
uint32_t end= current_pos_/ sizeof(uint32_t);
for( uint32_t i = 0 ; i < end ; i++ )
{
if( event_[i] != 0 )
{
return false;
}
}
return true;
}
CDErrT CDEvent::Wait()
{
while(!Test())
{
usleep(0);
}
return kOK;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r14
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x19956, %rsi
lea addresses_WC_ht+0x9556, %rdi
clflush (%rsi)
nop
nop
nop
nop
xor $62424, %r12
mov $54, %rcx
rep movsq
xor %rdi, %rdi
lea addresses_A_ht+0xb312, %rsi
lea addresses_WT_ht+0xa056, %rdi
and $51029, %rax
mov $108, %rcx
rep movsl
nop
nop
cmp %rax, %rax
lea addresses_A_ht+0x35da, %r10
nop
nop
nop
xor $30343, %rbp
mov $0x6162636465666768, %rcx
movq %rcx, (%r10)
sub $16760, %r12
lea addresses_WT_ht+0x40f6, %rsi
clflush (%rsi)
nop
nop
nop
sub %rdi, %rdi
movl $0x61626364, (%rsi)
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0xf956, %rcx
nop
nop
xor $60934, %rbp
movb (%rcx), %r10b
nop
nop
dec %rsi
lea addresses_WC_ht+0xe5e2, %r10
nop
nop
nop
dec %rax
mov (%r10), %rcx
nop
nop
xor $26217, %rcx
lea addresses_A_ht+0xf356, %rdi
nop
nop
nop
nop
dec %rsi
mov (%rdi), %r10
nop
nop
nop
add $22450, %rdi
lea addresses_A_ht+0xc856, %rbp
and %rax, %rax
mov $0x6162636465666768, %rcx
movq %rcx, (%rbp)
nop
nop
dec %rbp
lea addresses_A_ht+0x1da6, %rsi
lea addresses_D_ht+0x2756, %rdi
nop
nop
nop
nop
nop
dec %r10
mov $86, %rcx
rep movsw
nop
nop
sub $13990, %rsi
lea addresses_UC_ht+0x2d6, %rax
nop
nop
nop
nop
sub $64270, %r10
movw $0x6162, (%rax)
nop
nop
nop
xor $9414, %rcx
lea addresses_D_ht+0xa4b6, %rsi
lea addresses_WT_ht+0x15356, %rdi
nop
nop
nop
nop
nop
xor $31772, %r14
mov $24, %rcx
rep movsl
nop
nop
nop
nop
cmp %r12, %r12
lea addresses_WC_ht+0xba5e, %rsi
lea addresses_UC_ht+0x18396, %rdi
clflush (%rsi)
xor %rax, %rax
mov $120, %rcx
rep movsw
nop
nop
nop
nop
add $47877, %r12
lea addresses_D_ht+0x1d1e6, %r14
nop
nop
nop
nop
inc %rbp
movb (%r14), %r12b
nop
add %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r14
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r14
push %r8
push %rcx
push %rdi
push %rsi
// Store
lea addresses_UC+0x1a679, %r12
nop
nop
nop
nop
cmp %r8, %r8
movl $0x51525354, (%r12)
nop
nop
dec %r12
// Store
lea addresses_D+0x1b8d6, %r13
nop
nop
nop
nop
and $13578, %r12
movb $0x51, (%r13)
nop
nop
inc %r12
// REPMOV
lea addresses_WT+0x14c56, %rsi
lea addresses_normal+0x1ed56, %rdi
nop
nop
nop
nop
nop
add %r11, %r11
mov $124, %rcx
rep movsw
nop
nop
nop
and %r14, %r14
// Store
lea addresses_PSE+0x19d56, %r11
nop
xor $20955, %r13
movb $0x51, (%r11)
nop
nop
nop
nop
nop
xor %rsi, %rsi
// Store
lea addresses_WC+0x1e36, %r14
nop
xor $41749, %r8
movb $0x51, (%r14)
nop
nop
nop
nop
nop
and %r13, %r13
// Faulty Load
lea addresses_normal+0x1ed56, %rcx
nop
nop
nop
sub %r14, %r14
mov (%rcx), %r11
lea oracles, %r13
and $0xff, %r11
shlq $12, %r11
mov (%r13,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 4, 'AVXalign': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WT', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_PSE', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WC', 'size': 1, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': True}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'src': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
/*
*
* Copyright (C) 2002-2020, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmdata
*
* Author: Marco Eichelberg
*
* Purpose: decoder codec class for RLE
*
*/
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dcrleccd.h"
// dcmdata includes
#include "dcmtk/dcmdata/dcrlecp.h" /* for class DcmRLECodecParameter */
#include "dcmtk/dcmdata/dcrledec.h" /* for class DcmRLEDecoder */
#include "dcmtk/dcmdata/dcdatset.h" /* for class DcmDataset */
#include "dcmtk/dcmdata/dcdeftag.h" /* for tag constants */
#include "dcmtk/dcmdata/dcpixseq.h" /* for class DcmPixelSequence */
#include "dcmtk/dcmdata/dcpxitem.h" /* for class DcmPixelItem */
#include "dcmtk/dcmdata/dcvrpobw.h" /* for class DcmPolymorphOBOW */
#include "dcmtk/dcmdata/dcswap.h" /* for swapIfNecessary() */
#include "dcmtk/dcmdata/dcuid.h" /* for dcmGenerateUniqueIdentifer()*/
DcmRLECodecDecoder::DcmRLECodecDecoder()
: DcmCodec()
{
}
DcmRLECodecDecoder::~DcmRLECodecDecoder()
{
}
OFBool DcmRLECodecDecoder::canChangeCoding(
const E_TransferSyntax oldRepType,
const E_TransferSyntax newRepType) const
{
E_TransferSyntax myXfer = EXS_RLELossless;
DcmXfer newRep(newRepType);
if (newRep.isNotEncapsulated() && (oldRepType == myXfer)) return OFTrue; // decompress requested
// we don't support re-coding for now.
return OFFalse;
}
OFCondition DcmRLECodecDecoder::decode(
const DcmRepresentationParameter * /* fromRepParam */,
DcmPixelSequence * pixSeq,
DcmPolymorphOBOW& uncompressedPixelData,
const DcmCodecParameter * cp,
const DcmStack& objStack,
OFBool& /* removeOldRep */) const
{
OFCondition result = EC_Normal;
// assume we can cast the codec parameter to what we need
const DcmRLECodecParameter *djcp = OFstatic_cast(const DcmRLECodecParameter *, cp);
OFBool enableReverseByteOrder = djcp->getReverseDecompressionByteOrder();
DcmStack localStack(objStack);
(void)localStack.pop(); // pop pixel data element from stack
DcmObject *dataset = localStack.pop(); // this is the item in which the pixel data is located
if ((!dataset)||((dataset->ident()!= EVR_dataset) && (dataset->ident()!= EVR_item))) result = EC_InvalidTag;
else
{
Uint16 imageSamplesPerPixel = 0;
Uint16 imageRows = 0;
Uint16 imageColumns = 0;
Sint32 imageFrames = 1;
Uint16 imageBitsAllocated = 0;
Uint16 imageBytesAllocated = 0;
Uint16 imagePlanarConfiguration = 0;
Uint32 rleHeader[16];
DcmItem *ditem = OFstatic_cast(DcmItem *, dataset);
OFBool numberOfFramesPresent = OFFalse;
if (result.good()) result = ditem->findAndGetUint16(DCM_SamplesPerPixel, imageSamplesPerPixel);
if (result.good()) result = ditem->findAndGetUint16(DCM_Rows, imageRows);
if (result.good()) result = ditem->findAndGetUint16(DCM_Columns, imageColumns);
if (result.good()) result = ditem->findAndGetUint16(DCM_BitsAllocated, imageBitsAllocated);
if (result.good())
{
imageBytesAllocated = OFstatic_cast(Uint16, imageBitsAllocated / 8);
if ((imageBitsAllocated < 8)||(imageBitsAllocated % 8 != 0))
{
DCMDATA_ERROR("The RLE decoder only supports images where BitsAllocated is a multiple of 8.");
result = EC_CannotChangeRepresentation;
}
}
if (result.good() && (imageSamplesPerPixel > 1))
{
result = ditem->findAndGetUint16(DCM_PlanarConfiguration, imagePlanarConfiguration);
}
// number of frames is an optional attribute - we don't mind if it isn't present.
if (result.good())
{
if (ditem->findAndGetSint32(DCM_NumberOfFrames, imageFrames).good()) numberOfFramesPresent = OFTrue;
}
if (imageFrames >= OFstatic_cast(Sint32, pixSeq->card()))
imageFrames = OFstatic_cast(Sint32, pixSeq->card()) - 1; // limit number of frames to number of pixel items - 1
if (imageFrames < 1)
imageFrames = 1; // default in case the number of frames attribute is absent or contains garbage
if (result.good())
{
DcmPixelItem *pixItem = NULL;
Uint8 * rleData = NULL;
const size_t bytesPerStripe = OFstatic_cast(size_t, imageColumns) * OFstatic_cast(size_t, imageRows);
DcmRLEDecoder rledecoder(bytesPerStripe);
if (rledecoder.fail()) result = EC_MemoryExhausted; // RLE decoder failed to initialize
else
{
const size_t frameSize = OFstatic_cast(size_t, imageBytesAllocated) * OFstatic_cast(size_t, imageRows)
* OFstatic_cast(size_t, imageColumns) * OFstatic_cast(size_t, imageSamplesPerPixel);
size_t totalSize = frameSize * imageFrames;
if (totalSize & 1) totalSize++; // align on 16-bit word boundary
Uint16 *imageData16 = NULL;
Sint32 currentFrame = 0;
Uint32 currentItem = 1; // ignore offset table
Uint32 numberOfStripes = 0;
Uint32 fragmentLength = 0;
result = uncompressedPixelData.createUint16Array(OFstatic_cast(Uint32, totalSize/sizeof(Uint16)), imageData16);
if (result.good())
{
Uint8 *imageData8 = OFreinterpret_cast(Uint8 *, imageData16);
while ((currentFrame < imageFrames) && result.good())
{
DCMDATA_DEBUG("RLE decoder processes frame " << currentFrame);
DCMDATA_DEBUG("RLE decoder processes pixel item " << currentItem);
// get first pixel item of this frame
result = pixSeq->getItem(pixItem, currentItem++);
if (result.good())
{
fragmentLength = pixItem->getLength();
result = pixItem->getUint8Array(rleData);
if (result.good())
{
// we require that the RLE header must be completely
// contained in the first fragment; otherwise bail out
if (fragmentLength < 64)
{
DCMDATA_ERROR("Pixel item shorter than 64 bytes, RLE header incomplete.");
result = EC_CannotChangeRepresentation;
}
}
}
if (result.good())
{
// copy RLE header to buffer and adjust byte order
memcpy(rleHeader, rleData, 64);
swapIfNecessary(gLocalByteOrder, EBO_LittleEndian, rleHeader, 16*OFstatic_cast(Uint32, sizeof(Uint32)), sizeof(Uint32));
// determine number of stripes.
numberOfStripes = rleHeader[0];
// check that number of stripes in RLE header matches our expectation
if ((numberOfStripes < 1) || (numberOfStripes > 15) ||
(numberOfStripes != OFstatic_cast(Uint32, imageBytesAllocated) * imageSamplesPerPixel))
{
DCMDATA_ERROR("Number of stripes in RLE header incorrect: found " << numberOfStripes << ", expected " << (OFstatic_cast(Uint32, imageBytesAllocated) * imageSamplesPerPixel));
result = EC_CannotChangeRepresentation;
}
}
if (result.good())
{
// this variable keeps the number of bytes we have processed
// for the current frame in earlier pixel fragments
Uint32 fragmentOffset = 0;
// this variable keeps the current position within the current fragment
Uint32 byteOffset = 0;
OFBool lastStripe = OFFalse;
OFBool lastStripeOfColor = OFFalse;
Uint32 inputBytes = 0;
// pointers for buffer copy operations
Uint8 *outputBuffer = NULL;
Uint8 *pixelPointer = NULL;
// byte offset for first sample in frame
Uint32 sampleOffset = 0;
// byte offset between samples
Uint32 offsetBetweenSamples = 0;
// temporary variables
Uint32 sample = 0;
Uint32 byte = 0;
Uint32 pixel = 0;
// for each stripe in stripe set
for (Uint32 stripeIndex = 0; (stripeIndex < numberOfStripes) && result.good(); ++stripeIndex)
{
// reset RLE codec
rledecoder.clear();
// adjust start point for RLE stripe, ignoring trailing garbage from the last run
byteOffset = rleHeader[stripeIndex + 1];
if (byteOffset < fragmentOffset)
{
DCMDATA_ERROR("Byte offset in RLE header is wrong.");
result = EC_CannotChangeRepresentation;
}
else
{
byteOffset -= fragmentOffset; // now byteOffset is correct but may point to next fragment
while ((byteOffset > fragmentLength) && result.good())
{
DCMDATA_DEBUG("RLE decoder processes pixel item " << currentItem);
result = pixSeq->getItem(pixItem, currentItem++);
if (result.good())
{
byteOffset -= fragmentLength;
fragmentOffset += fragmentLength;
fragmentLength = pixItem->getLength();
result = pixItem->getUint8Array(rleData);
if (result.bad())
{
DCMDATA_ERROR("Cannot access pixel fragment.");
}
}
else
{
DCMDATA_ERROR("Cannot access pixel fragment.");
}
}
}
// something went wrong; most likely the byte offset in the RLE header is incorrect.
if (result.bad()) return EC_CannotChangeRepresentation;
// byteOffset now points to the first byte of the new RLE stripe
// check if the current stripe is the last one for this frame
if (stripeIndex + 1 == numberOfStripes) lastStripe = OFTrue; else lastStripe = OFFalse;
if (lastStripe)
{
// the last stripe needs special handling because we cannot use the
// offset table to determine the number of bytes to feed to the codec
// if the RLE data is split in multiple fragments. We need to feed
// data fragment by fragment until the RLE codec has produced
// sufficient output.
while ((rledecoder.size() < bytesPerStripe) && result.good())
{
// feed complete remaining content of fragment to RLE codec and
// switch to next fragment
result = rledecoder.decompress(rleData + byteOffset, OFstatic_cast(size_t, fragmentLength - byteOffset));
// special handling for zero pad byte at the end of the RLE stream
// which results in an EC_StreamNotifyClient return code
// or trailing garbage data which results in EC_CorruptedData
if (rledecoder.size() == bytesPerStripe) result = EC_Normal;
// Check if we're already done. If yes, don't change fragment
if (result.good() || result == EC_StreamNotifyClient)
{
if (rledecoder.size() < bytesPerStripe)
{
DCMDATA_WARN("RLE decoder is finished but has produced insufficient data for this stripe, will continue with next pixel item");
DCMDATA_DEBUG("RLE decoder processes pixel item " << currentItem);
result = pixSeq->getItem(pixItem, currentItem++);
if (result.good())
{
byteOffset = 0;
fragmentOffset += fragmentLength;
fragmentLength = pixItem->getLength();
result = pixItem->getUint8Array(rleData);
}
}
else byteOffset = fragmentLength;
}
} /* while */
}
else
{
// not the last stripe. We can use the offset table to determine
// the number of bytes to feed to the RLE codec.
inputBytes = rleHeader[stripeIndex+2];
if (inputBytes < rleHeader[stripeIndex + 1])
{
DCMDATA_ERROR("Byte offset in RLE header is wrong.");
result = EC_CannotChangeRepresentation;
}
else
{
inputBytes -= rleHeader[stripeIndex + 1]; // number of bytes to feed to codec
while ((inputBytes > (fragmentLength - byteOffset)) && result.good())
{
// feed complete remaining content of fragment to RLE codec and
// switch to next fragment
result = rledecoder.decompress(rleData + byteOffset, OFstatic_cast(size_t, fragmentLength - byteOffset));
if (result.good() || result == EC_StreamNotifyClient)
{
DCMDATA_DEBUG("RLE decoder processes pixel item " << currentItem);
result = pixSeq->getItem(pixItem, currentItem++);
}
if (result.good())
{
inputBytes -= fragmentLength - byteOffset;
byteOffset = 0;
fragmentOffset += fragmentLength;
fragmentLength = pixItem->getLength();
result = pixItem->getUint8Array(rleData);
}
} /* while */
// last fragment for this RLE stripe
result = rledecoder.decompress(rleData + byteOffset, OFstatic_cast(size_t, inputBytes));
// special handling for zero pad byte at the end of the RLE stream
// which results in an EC_StreamNotifyClient return code
// or trailing garbage data which results in EC_CorruptedData
if (rledecoder.size() == bytesPerStripe) result = EC_Normal;
byteOffset += inputBytes;
}
}
// copy the decoded stuff over to the buffer here...
// make sure the RLE decoder has produced the right amount of data
lastStripeOfColor = lastStripe || ((imagePlanarConfiguration == 1) && ((stripeIndex + 1) % imageBytesAllocated == 0));
if (lastStripeOfColor && (rledecoder.size() < bytesPerStripe))
{
// stripe ended prematurely? report a warning and continue
DCMDATA_WARN("RLE decoder is finished but has produced insufficient data for this stripe, filling remaining pixels");
result = EC_Normal;
}
else if (rledecoder.size() != bytesPerStripe)
{
DCMDATA_ERROR("RLE decoder is finished but has produced insufficient data for this stripe");
result = EC_CannotChangeRepresentation;
}
// distribute decompressed bytes into output image array
if (result.good())
{
// which sample and byte are we currently compressing?
sample = stripeIndex / imageBytesAllocated;
byte = stripeIndex % imageBytesAllocated;
// raw buffer containing bytesPerStripe bytes of uncompressed data
outputBuffer = OFstatic_cast(Uint8 *, rledecoder.getOutputBuffer());
// compute byte offsets
if (imagePlanarConfiguration == 0)
{
sampleOffset = sample * imageBytesAllocated;
offsetBetweenSamples = imageSamplesPerPixel * imageBytesAllocated;
}
else
{
sampleOffset = sample * imageBytesAllocated * imageColumns * imageRows;
offsetBetweenSamples = imageBytesAllocated;
}
// initialize pointer to output data
if (enableReverseByteOrder)
{
// assume incorrect LSB to MSB order of RLE segments as produced by some tools
pixelPointer = imageData8 + sampleOffset + byte;
}
else
{
pixelPointer = imageData8 + sampleOffset + imageBytesAllocated - byte - 1;
}
// loop through all pixels of the frame
for (pixel = 0; pixel < bytesPerStripe; ++pixel)
{
*pixelPointer = *outputBuffer++;
pixelPointer += offsetBetweenSamples;
}
}
} /* for */
}
// advance by one frame
if (result.good())
{
currentFrame++;
imageData8 += frameSize;
}
} /* while still frames to process */
// adjust byte order for uncompressed image to little endian
swapIfNecessary(EBO_LittleEndian, gLocalByteOrder, imageData16, OFstatic_cast(Uint32, totalSize), sizeof(Uint16));
// Number of Frames might have changed in case the previous value was wrong
if (result.good() && (numberOfFramesPresent || (imageFrames > 1)))
{
char numBuf[20];
sprintf(numBuf, "%ld", OFstatic_cast(long, imageFrames));
result = OFstatic_cast(DcmItem *, dataset)->putAndInsertString(DCM_NumberOfFrames, numBuf);
}
}
}
}
// the following operations do not affect the Image Pixel Module
// but other modules such as SOP Common. We only perform these
// changes if we're on the main level of the dataset,
// which should always identify itself as dataset, not as item.
if (dataset->ident() == EVR_dataset)
{
// create new SOP instance UID if codec parameters require so
if (result.good() && djcp->getUIDCreation()) result =
DcmCodec::newInstance(OFstatic_cast(DcmItem *, dataset), NULL, NULL, NULL);
}
}
return result;
}
OFCondition DcmRLECodecDecoder::decodeFrame(
const DcmRepresentationParameter * /* fromParam */,
DcmPixelSequence * fromPixSeq,
const DcmCodecParameter * cp,
DcmItem *dataset,
Uint32 frameNo,
Uint32& startFragment,
void *buffer,
Uint32 bufSize,
OFString& decompressedColorModel) const
{
OFCondition result = EC_Normal;
// assume we can cast the codec parameter to what we need
const DcmRLECodecParameter *djcp = OFstatic_cast(const DcmRLECodecParameter *, cp);
OFBool enableReverseByteOrder = djcp->getReverseDecompressionByteOrder();
if ((!dataset)||((dataset->ident()!= EVR_dataset) && (dataset->ident()!= EVR_item))) return EC_InvalidTag;
Uint16 imageSamplesPerPixel = 0;
Uint16 imageRows = 0;
Uint16 imageColumns = 0;
Sint32 imageFrames = 1;
Uint16 imageBitsAllocated = 0;
Uint16 imageBytesAllocated = 0;
Uint16 imagePlanarConfiguration = 0;
Uint32 rleHeader[16];
OFString photometricInterpretation;
DcmItem *ditem = OFstatic_cast(DcmItem *, dataset);
if (result.good()) result = ditem->findAndGetUint16(DCM_SamplesPerPixel, imageSamplesPerPixel);
if (result.good()) result = ditem->findAndGetUint16(DCM_Rows, imageRows);
if (result.good()) result = ditem->findAndGetUint16(DCM_Columns, imageColumns);
if (result.good()) result = ditem->findAndGetUint16(DCM_BitsAllocated, imageBitsAllocated);
if (result.good()) result = dataset->findAndGetOFString(DCM_PhotometricInterpretation, photometricInterpretation);
if (result.good())
{
imageBytesAllocated = OFstatic_cast(Uint16, imageBitsAllocated / 8);
if ((imageBitsAllocated < 8)||(imageBitsAllocated % 8 != 0))
{
DCMDATA_ERROR("The RLE decoder only supports images where BitsAllocated is a multiple of 8.");
return EC_CannotChangeRepresentation;
}
}
if (result.good() && (imageSamplesPerPixel > 1))
{
result = ditem->findAndGetUint16(DCM_PlanarConfiguration, imagePlanarConfiguration);
}
// number of frames is an optional attribute - we don't mind if it isn't present.
if (result.good()) (void) ditem->findAndGetSint32(DCM_NumberOfFrames, imageFrames);
if (imageFrames < 1) imageFrames = 1; // default in case this attribute contains garbage
if (result.bad())
return result;
DcmPixelItem *pixItem = NULL;
Uint8 * rleData = NULL;
const size_t bytesPerStripe = OFstatic_cast(size_t, imageColumns) * OFstatic_cast(size_t, imageRows);
Uint32 numberOfStripes = 0;
Uint32 fragmentLength = 0;
Uint32 frameSize = OFstatic_cast(Uint32, imageBytesAllocated) * OFstatic_cast(Uint32, imageRows)
* OFstatic_cast(Uint32, imageColumns) * OFstatic_cast(Uint32, imageSamplesPerPixel);
if (frameSize > bufSize) return EC_IllegalCall;
DcmRLEDecoder rledecoder(bytesPerStripe);
if (rledecoder.fail()) return EC_MemoryExhausted; // RLE decoder failed to initialize
DCMDATA_DEBUG("RLE decoder processes frame " << frameNo);
// determine the corresponding item (first fragment) for this frame
Uint32 currentItem = startFragment;
// if the user has provided this information, we trust him.
// If the user has passed a zero, try to find out ourselves.
if (currentItem == 0 && result.good())
{
result = determineStartFragment(frameNo, imageFrames, fromPixSeq, currentItem);
if (result.bad())
return result;
}
DCMDATA_DEBUG("RLE decoder processes pixel item " << currentItem);
// now access and decompress the frame starting at the item we have identified
result = fromPixSeq->getItem(pixItem, currentItem);
if (result.bad())
return result;
fragmentLength = pixItem->getLength();
result = pixItem->getUint8Array(rleData);
if (result.bad())
return result;
// copy RLE header to buffer and adjust byte order
memcpy(rleHeader, rleData, 64);
swapIfNecessary(gLocalByteOrder, EBO_LittleEndian, rleHeader, OFstatic_cast(Uint32, 16*sizeof(Uint32)), sizeof(Uint32));
// determine number of stripes.
numberOfStripes = rleHeader[0];
// check that number of stripes in RLE header matches our expectation
if ((numberOfStripes < 1) || (numberOfStripes > 15) || (numberOfStripes != OFstatic_cast(Uint32, imageBytesAllocated) * imageSamplesPerPixel))
{
DCMDATA_ERROR("Number of stripes in RLE header incorrect: found " << numberOfStripes << ", expected " << (OFstatic_cast(Uint32, imageBytesAllocated) * imageSamplesPerPixel));
return EC_CannotChangeRepresentation;
}
// this variable keeps the current position within the current fragment
Uint32 byteOffset = 0;
OFBool lastStripe = OFFalse;
OFBool lastStripeOfColor = OFFalse;
Uint32 inputBytes = 0;
// pointers for buffer copy operations
Uint8 *outputBuffer = NULL;
Uint8 *pixelPointer = NULL;
Uint16 *imageData16 = OFreinterpret_cast(Uint16 *, buffer);
Uint8 *imageData8 = OFreinterpret_cast(Uint8 *, buffer);
// byte offset for first sample in frame
Uint32 sampleOffset = 0;
// byte offset between samples
Uint32 offsetBetweenSamples = 0;
// temporary variables
Uint32 sample = 0;
Uint32 byte = 0;
Uint32 pixel = 0;
size_t bytesToDecode;
// for each stripe in stripe set
for (Uint32 stripeIndex = 0; stripeIndex < numberOfStripes; ++stripeIndex)
{
// reset RLE codec
rledecoder.clear();
// adjust start point for RLE stripe
byteOffset = rleHeader[stripeIndex + 1];
// byteOffset now points to the first byte of the new RLE stripe
// check if the current stripe is the last one for this frame
if (stripeIndex + 1 == numberOfStripes) lastStripe = OFTrue; else lastStripe = OFFalse;
if (lastStripe)
{
// the last stripe needs special handling because we cannot use the
// offset table to determine the number of bytes to feed to the codec
// if the RLE data is split in multiple fragments. We need to feed
// data fragment by fragment until the RLE codec has produced
// sufficient output.
bytesToDecode = OFstatic_cast(size_t, fragmentLength - byteOffset);
}
else
{
// not the last stripe. We can use the offset table to determine
// the number of bytes to feed to the RLE codec.
inputBytes = rleHeader[stripeIndex+2];
if (inputBytes < rleHeader[stripeIndex + 1])
{
DCMDATA_ERROR("Byte offset in RLE header is wrong.");
return EC_CannotChangeRepresentation;
}
inputBytes -= rleHeader[stripeIndex + 1]; // number of bytes to feed to codec
bytesToDecode = OFstatic_cast(size_t, inputBytes);
}
// last fragment for this RLE stripe
result = rledecoder.decompress(rleData + byteOffset, bytesToDecode);
// special handling for zero pad byte at the end of the RLE stream
// which results in an EC_StreamNotifyClient return code
// or trailing garbage data which results in EC_CorruptedData
if (rledecoder.size() == bytesPerStripe) result = EC_Normal;
byteOffset += inputBytes;
// copy the decoded stuff over to the buffer here...
// make sure the RLE decoder has produced the right amount of data
lastStripeOfColor = lastStripe || ((imagePlanarConfiguration == 1) && ((stripeIndex + 1) % imageBytesAllocated == 0));
if (lastStripeOfColor && (rledecoder.size() < bytesPerStripe))
{
// stripe ended prematurely? report a warning and continue
DCMDATA_WARN("RLE decoder is finished but has produced insufficient data for this stripe, filling remaining pixels");
result = EC_Normal;
}
else if (rledecoder.size() != bytesPerStripe)
{
DCMDATA_ERROR("RLE decoder is finished but has produced insufficient data for this stripe");
return EC_CannotChangeRepresentation;
}
// distribute decompressed bytes into output image array
// which sample and byte are we currently decompressing?
sample = stripeIndex / imageBytesAllocated;
byte = stripeIndex % imageBytesAllocated;
// raw buffer containing bytesPerStripe bytes of uncompressed data
outputBuffer = OFstatic_cast(Uint8 *, rledecoder.getOutputBuffer());
// compute byte offsets
if (imagePlanarConfiguration == 0)
{
sampleOffset = sample * imageBytesAllocated;
offsetBetweenSamples = imageSamplesPerPixel * imageBytesAllocated;
}
else
{
sampleOffset = sample * imageBytesAllocated * imageColumns * imageRows;
offsetBetweenSamples = imageBytesAllocated;
}
// initialize pointer to output data
if (enableReverseByteOrder)
{
// assume incorrect LSB to MSB order of RLE segments as produced by some tools
pixelPointer = imageData8 + sampleOffset + byte;
}
else
{
pixelPointer = imageData8 + sampleOffset + imageBytesAllocated - byte - 1;
}
// copy the pixel data that was decoded
const size_t decoderSize = rledecoder.size();
for (pixel = 0; pixel < decoderSize; ++pixel)
{
*pixelPointer = *outputBuffer++;
pixelPointer += offsetBetweenSamples;
}
// and fill the remainder of the image with copies of the last decoded pixel
const Uint8 lastPixelValue = *(outputBuffer - 1);
for (pixel = OFstatic_cast(Uint32, decoderSize); pixel < bytesPerStripe; ++pixel)
{
*pixelPointer = lastPixelValue;
pixelPointer += offsetBetweenSamples;
}
}
/* remove used fragment from memory */
pixItem->compact(); // there should only be one...
if (result.good())
{
// compression was successful. Now update output parameters
startFragment = currentItem + 1;
decompressedColorModel = photometricInterpretation;
}
// adjust byte order for uncompressed image to little endian
swapIfNecessary(EBO_LittleEndian, gLocalByteOrder, imageData16, frameSize, sizeof(Uint16));
return result;
}
OFCondition DcmRLECodecDecoder::encode(
const Uint16 * /* pixelData */,
const Uint32 /* length */,
const DcmRepresentationParameter * /* toRepParam */,
DcmPixelSequence * & /* pixSeq */,
const DcmCodecParameter * /* cp */,
DcmStack & /* objStack */,
OFBool& /* removeOldRep */) const
{
// we are a decoder only
return EC_IllegalCall;
}
OFCondition DcmRLECodecDecoder::encode(
const E_TransferSyntax /* fromRepType */,
const DcmRepresentationParameter * /* fromRepParam */,
DcmPixelSequence * /* fromPixSeq */,
const DcmRepresentationParameter * /* toRepParam */,
DcmPixelSequence * & /* toPixSeq */,
const DcmCodecParameter * /* cp */,
DcmStack & /* objStack */,
OFBool& /* removeOldRep */) const
{
// we don't support re-coding for now.
return EC_IllegalCall;
}
OFCondition DcmRLECodecDecoder::determineDecompressedColorModel(
const DcmRepresentationParameter * /* fromParam */,
DcmPixelSequence * /* fromPixSeq */,
const DcmCodecParameter * /* cp */,
DcmItem *dataset,
OFString &decompressedColorModel) const
{
OFCondition result = EC_IllegalParameter;
if (dataset != NULL )
{
if ((dataset->ident() == EVR_dataset) || (dataset->ident() == EVR_item))
{
// retrieve color model from given dataset
result = dataset->findAndGetOFString(DCM_PhotometricInterpretation, decompressedColorModel);
if (result == EC_TagNotFound)
{
DCMDATA_WARN("DcmRLECodecDecoder: Mandatory element PhotometricInterpretation " << DCM_PhotometricInterpretation << " is missing");
result = EC_MissingAttribute;
}
else if (result.bad())
{
DCMDATA_WARN("DcmRLECodecDecoder: Cannot retrieve value of element PhotometricInterpretation " << DCM_PhotometricInterpretation << ": " << result.text());
}
else if (decompressedColorModel.empty())
{
DCMDATA_WARN("DcmRLECodecDecoder: No value for mandatory element PhotometricInterpretation " << DCM_PhotometricInterpretation);
result = EC_MissingValue;
}
} else
result = EC_CorruptedData;
}
return result;
}
|
SECTION code_ctype
PUBLIC asm_islower
asm_islower:
; determine if char is in [a-z]
; enter : a = char
; exit : carry if not lower
; uses : f
cp 'a'
ret c
cp 'z'+1
ccf
ret
|
; A210100: Number of (n+1) X 2 0..2 arrays with every 2 X 2 subblock having one or three distinct values, and new values 0..2 introduced in row major order.
; 7,30,135,614,2799,12766,58231,265622,1211647,5526990,25211655,115004294,524598159,2392982206,10915714711,49792609142,227131616287,1036072863150,4726101083175,21558359689574,98339596281519,448581262028446,2046227117579191
add $0,1
mov $1,2
mov $2,2
lpb $0,1
sub $0,1
mul $2,2
add $1,$2
add $1,1
add $2,$1
lpe
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x17a3e, %r12
nop
nop
nop
xor %rbp, %rbp
and $0xffffffffffffffc0, %r12
movntdqa (%r12), %xmm3
vpextrq $0, %xmm3, %rsi
nop
cmp %rcx, %rcx
lea addresses_D_ht+0xefde, %rsi
lea addresses_normal_ht+0x1a596, %rdi
dec %rdx
mov $46, %rcx
rep movsw
sub %rdi, %rdi
lea addresses_normal_ht+0x1b9d9, %rsi
lea addresses_normal_ht+0x12a0a, %rdi
nop
nop
nop
nop
nop
sub %r12, %r12
mov $34, %rcx
rep movsw
inc %r12
lea addresses_UC_ht+0x1274a, %rsi
nop
nop
nop
nop
and $36903, %r15
mov $0x6162636465666768, %rdx
movq %rdx, %xmm1
movups %xmm1, (%rsi)
nop
nop
cmp %r12, %r12
lea addresses_UC_ht+0x1913e, %rdi
nop
nop
sub %rbp, %rbp
mov $0x6162636465666768, %r12
movq %r12, %xmm1
vmovups %ymm1, (%rdi)
nop
nop
nop
inc %r15
lea addresses_UC_ht+0xb6ea, %r12
nop
nop
nop
xor $34765, %rbp
mov $0x6162636465666768, %r15
movq %r15, %xmm3
vmovups %ymm3, (%r12)
nop
nop
nop
xor %rsi, %rsi
lea addresses_UC_ht+0x1010a, %rbp
nop
nop
sub %rcx, %rcx
vmovups (%rbp), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %r15
nop
nop
nop
nop
dec %r12
lea addresses_WC_ht+0x8bca, %r15
nop
add $13970, %rcx
movb (%r15), %dl
dec %rcx
lea addresses_normal_ht+0x8aa2, %rcx
nop
nop
and %r15, %r15
mov $0x6162636465666768, %r12
movq %r12, %xmm2
movups %xmm2, (%rcx)
nop
nop
nop
nop
nop
cmp %rbp, %rbp
lea addresses_UC_ht+0x468a, %rsi
lea addresses_WC_ht+0xd69a, %rdi
nop
nop
nop
cmp $62767, %rdx
mov $41, %rcx
rep movsq
nop
dec %rsi
lea addresses_UC_ht+0xcfea, %rdx
dec %rsi
mov (%rdx), %ecx
nop
nop
nop
xor $37215, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %rbx
push %rcx
// Faulty Load
lea addresses_RW+0x4e8a, %r14
nop
nop
nop
sub $22739, %rcx
mov (%r14), %r15
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
#include "car.hpp"
#include <glm/gtx/fast_trigonometry.hpp>
#include <glm/gtx/rotate_vector.hpp>
void Car::initializeGL(GLuint program) {
terminateGL();
me_program = program;
m_rotationLoc = abcg::glGetUniformLocation(me_program, "rotation");
m_scaleLoc = abcg::glGetUniformLocation(me_program, "scale");
m_translationLoc = abcg::glGetUniformLocation(me_program, "translation");
m_rotation = 0.0f;
m_translation = glm::vec2(0, -0.5);
m_velocity = glm::vec2(0);
std::array<glm::vec2, 26> positions{
glm::vec2{-02.5f, +12.5f}, glm::vec2{-15.5f, +02.5f},
glm::vec2{-15.5f, -12.5f}, glm::vec2{-09.5f, -07.5f},
glm::vec2{-03.5f, -12.5f}, glm::vec2{+03.5f, -12.5f},
glm::vec2{+09.5f, -07.5f}, glm::vec2{+15.5f, -12.5f},
glm::vec2{+15.5f, +02.5f}, glm::vec2{+02.5f, +12.5f},
glm::vec2{-12.5f, +10.5f}, glm::vec2{-12.5f, +04.0f},
glm::vec2{-09.5f, +04.0f}, glm::vec2{-09.5f, +10.5f},
glm::vec2{+09.5f, +10.5f}, glm::vec2{+09.5f, +04.0f},
glm::vec2{+12.5f, +04.0f}, glm::vec2{+12.5f, +10.5f},
glm::vec2{-12.0f, -10.5f}, glm::vec2{-12.0f, -04.0f},
glm::vec2{-09.5f, -04.0f}, glm::vec2{-09.5f, -10.5f},
glm::vec2{+09.5f, -10.5f}, glm::vec2{+09.5f, -04.0f},
glm::vec2{+12.5f, -04.0f}, glm::vec2{+12.5f, -10.5f},
};
std::array<glm::vec4, 26> colors{
glm::vec4{0,1,0,0}, glm::vec4{0,1,0,0},
glm::vec4{0,1,0,0}, glm::vec4{0,1,0,0},
glm::vec4{0,1,0,0}, glm::vec4{0,1,0,0},
glm::vec4{0,1,0,0}, glm::vec4{0,1,0,0},
glm::vec4{0,1,0,0}, glm::vec4{0,1,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
glm::vec4{0,0,0,0}, glm::vec4{0,0,0,0},
};
for (auto &position : positions) {
position /= glm::vec2{15.5f, 15.5f};
}
const std::array indices{0, 3, 4,
0, 4, 5,
9, 0, 5,
9, 5, 6,
10, 11, 12,
10, 12, 13,
14, 15, 16,
14, 16, 17,
18, 19, 20,
18, 20, 21,
22, 23, 24,
22, 24, 25
};
abcg::glGenBuffers(1, &m_vbo);
abcg::glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
abcg::glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions.data(),
GL_STATIC_DRAW);
abcg::glBindBuffer(GL_ARRAY_BUFFER, 0);
abcg::glGenBuffers(1, &m_vbo_color);
abcg::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_color);
abcg::glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors.data(),
GL_STATIC_DRAW);
abcg::glBindBuffer(GL_ARRAY_BUFFER, 0);
abcg::glGenBuffers(1, &m_ebo);
abcg::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
abcg::glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices.data(),
GL_STATIC_DRAW);
abcg::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
GLint positionAttribute{abcg::glGetAttribLocation(me_program, "inPosition")};
GLint colorAttribute{abcg::glGetAttribLocation(me_program, "inColor")};
abcg::glGenVertexArrays(1, &m_vao);
abcg::glBindVertexArray(m_vao);
abcg::glEnableVertexAttribArray(positionAttribute);
abcg::glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
abcg::glVertexAttribPointer(positionAttribute, 2, GL_FLOAT, GL_FALSE, 0,
nullptr);
abcg::glBindBuffer(GL_ARRAY_BUFFER, 0);
abcg::glEnableVertexAttribArray(colorAttribute);
abcg::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_color);
abcg::glVertexAttribPointer(colorAttribute, 4, GL_FLOAT, GL_FALSE, 0,
nullptr);
abcg::glBindBuffer(GL_ARRAY_BUFFER, 0);
abcg::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
abcg::glBindVertexArray(0);
}
void Car::paintGL(const GameData &gameData) {
if (gameData.m_state != State::Playing) return;
abcg::glUseProgram(me_program);
abcg::glBindVertexArray(m_vao);
abcg::glUniform1f(m_scaleLoc, m_scale);
abcg::glUniform1f(m_rotationLoc, m_rotation);
abcg::glUniform2fv(m_translationLoc, 1, &m_translation.x);
if (m_trailBlinkTimer.elapsed() > 100.0 / 1000.0) m_trailBlinkTimer.restart();
if (gameData.m_input[static_cast<size_t>(Input::Up)]) {
if (m_trailBlinkTimer.elapsed() < 50.0 / 1000.0) {
abcg::glEnable(GL_BLEND);
abcg::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
abcg::glDrawElements(GL_TRIANGLES, 14 * 3, GL_UNSIGNED_INT, nullptr);
abcg::glDisable(GL_BLEND);
}
}
abcg::glDrawElements(GL_TRIANGLES, 12 * 3, GL_UNSIGNED_INT, nullptr);
abcg::glBindVertexArray(0);
abcg::glUseProgram(0);
}
void Car::terminateGL() {
abcg::glDeleteBuffers(1, &m_vbo);
abcg::glDeleteBuffers(1, &m_ebo);
abcg::glDeleteVertexArrays(1, &m_vbo_color);
abcg::glDeleteVertexArrays(1, &m_vao);
}
void Car::update(const GameData &gameData, float deltaTime) {
if (gameData.m_input[static_cast<size_t>(Input::Left)]) {
m_rotation = glm::wrapAngle(m_rotation + 4.0f * deltaTime);
m_translation.x = m_translation.x - 0.5f * deltaTime;
}
if (gameData.m_input[static_cast<size_t>(Input::Right)]) {
m_rotation = glm::wrapAngle(m_rotation - 4.0f * deltaTime);
m_translation.x = m_translation.x + 0.5f * deltaTime;
}
if (gameData.m_input[static_cast<size_t>(Input::Up)] &&
gameData.m_state == State::Playing) {
glm::vec2 forward = glm::rotate(glm::vec2{0.0f, 1.0f}, m_rotation);
m_velocity += forward * deltaTime;
}
} |
;***************************************************************************
; DEFINE SECTION
;***************************************************************************
include "VECTREX.I"
; start of vectrex memory with cartridge name...
org 0
;***************************************************************************
; HEADER SECTION
;***************************************************************************
db "g GCE 1998", $80 ; 'g' is copyright sign
dw music1 ; music from the rom
db $F8, $50, $20, -$45 ; height, width, rel y, rel x
; (from 0,0)
db "SINGLE LINE",$80 ; some game information,
; ending with $80
db 0 ; end of game header
;***************************************************************************
; CODE SECTION
;***************************************************************************
; here the cartridge program starts off
main:
jsr Wait_Recal ; Vectrex BIOS recalibration
lda #$80 ; scaling factor of $80 to A
sta VIA_t1_cnt_lo ; move to time 1 lo, this
; means scaling
lda #0 ; to 0 (y)
ldb #0 ; to 0 (x)
jsr Moveto_d ; move the vector beam the
; relative position
jsr Intensity_5F ; Sets the intensity of the
; vector beam to $5f
clr Vec_Misc_Count ; in order for drawing only 1
; vector, this must be set to
; 0
lda #100 ; to 100 (y)
ldb #50 ; to 50 (x)
jsr Draw_Line_d ; draw the line now
bra main ; and repeat forever
;***************************************************************************
end main
;***************************************************************************
|
; ; ; ; ; ; ; ; ; ; ; ;
;
; A generator that gives Mario a coin per second when ON is set, takes away a coin when
; OFF is set, changes ON to OFF after a few seconds, and kills Mario when he has 0 coins
;
; Insert as a generator
; Does not use extra bit
; Will kill Mario instantly if he enters the level with 0 coins
; Thus the best placement is in a level after the entrance level, providing some coins
; Limits max coins to 98
; Credit much preferred
; Done at request
;
; ; ; ; ; ; ; ; ; ; ; ;
dcb "INIT"
dcb "MAIN"
LDA $0DBF ; Coins
CMP #99 ; If 99 coins...
BNE Bleh
DEC $0DBF ; Decrease by one to prevent 1-up via coins, and A0 graphic from displaying in coin counter
Bleh:
LDA $0DBF
BEQ Death ; Kill if 0 coins
LDA $14AF ; ON/OFF status
CMP #$01
BEQ Continue ; Continue if 01-FF (OFF)
LDA $13 ; Frame count
BEQ ONOFFSwitch ; Set OFF after maximum of 4.25 seconds
Continue:
LDA $13 ; Frame count
AND #$3F ; Continue only once per second
BNE Return
LDA $14AF ; ON/OFF
BEQ ON ; If 00 (ON), branch
;OFF:
DEC $0DBF ; Take coin
LDA #$2A ; Incorrect SFX
STA $1DFC
BRA Return
ON:
INC $0DBF ; Give coin
LDA #$01 ; Coin SFX
STA $1DFC
BRA Return
Death:
LDA $188A ; Prevents death from running every frame
BNE Return
JSL $F606 ; Die Mario, die!
INC $188A ; Sets flag in free RAM to prevent death from running every frame (cleared on overworld)
BRA Return
ONOFFSwitch:
LDA #$01
STA $14AF ; Switch OFF
LDA #$1C ; SFX
STA $1DFC
Return:
RTL
|
nop
|
; A115269: Row sums of correlation triangle for floor((n+4)/4).
; 1,2,4,6,11,16,24,32,46,60,80,100,130,160,200,240,295,350,420,490,581,672,784,896,1036,1176,1344,1512,1716,1920,2160,2400,2685,2970,3300,3630,4015,4400,4840,5280,5786,6292,6864,7436,8086,8736,9464,10192,11011,11830,12740,13650,14665,15680,16800,17920,19160,20400,21760,23120,24616,26112,27744,29376,31161,32946,34884,36822,38931,41040,43320,45600,48070,50540,53200,55860,58730,61600,64680,67760,71071,74382,77924,81466,85261,89056,93104,97152,101476,105800,110400,115000,119900,124800,130000,135200,140725,146250,152100,157950,164151,170352,176904,183456,190386,197316,204624,211932,219646,227360,235480,243600,252155,260710,269700,278690,288145,297600,307520,317440,327856,338272,349184,360096,371536,382976,394944,406912,419441,431970,445060,458150,471835,485520,499800,514080,528990,543900,559440,574980,591186,607392,624264,641136,658711,676286,694564,712842,731861,750880,770640,790400,810940,831480,852800,874120,896260,918400,941360,964320,988141,1011962,1036644,1061326,1086911,1112496,1138984,1165472,1192906,1220340,1248720,1277100,1306470,1335840,1366200,1396560,1427955,1459350,1491780,1524210,1557721,1591232,1625824,1660416,1696136,1731856,1768704,1805552,1843576,1881600,1920800,1960000,2000425,2040850,2082500,2124150,2167075,2210000,2254200,2298400,2343926,2389452,2436304,2483156,2531386,2579616,2629224,2678832,2729871,2780910,2833380,2885850,2939805,2993760,3049200,3104640,3161620,3218600,3277120,3335640,3395756,3455872,3517584,3579296,3642661,3706026,3771044,3836062,3902791,3969520,4037960,4106400,4176610,4246820,4318800,4390780,4464590,4538400,4614040,4689680,4767211,4844742,4924164,5003586,5084961,5166336,5249664,5332992,5418336,5503680
mov $17,$0
mov $19,$0
add $19,1
lpb $19
clr $0,17
mov $0,$17
sub $19,1
sub $0,$19
mov $14,$0
mov $16,$0
add $16,1
lpb $16
clr $0,14
mov $0,$14
sub $16,1
sub $0,$16
add $0,3
add $6,$0
add $0,1
gcd $0,2
bin $0,2
lpb $6
add $2,$0
add $4,$2
sub $6,4
lpe
add $15,$4
lpe
add $18,$15
lpe
mov $1,$18
|
; A140162: a(1)=1, a(n) = a(n-1) + n^5 if n odd, a(n) = a(n-1) + n^0 if n is even.
; 1,2,245,246,3371,3372,20179,20180,79229,79230,240281,240282,611575,611576,1370951,1370952,2790809,2790810,5266909,5266910,9351011,9351012,15787355,15787356,25552981,25552982,39901889,39901890,60413039,60413040,89042191,89042192,128177585,128177586,180699461,180699462,250043419,250043420,340267619,340267620,456123821,456123822,603132265,603132266,787660391,787660392,1017005399,1017005400,1299480649,1299480650,1644505901,1644505902,2062701395,2062701396,2565985771,2565985772,3167677829,3167677830,3882602129,3882602130,4727198431,4727198432,5719634975,5719634976,6879925601,6879925602,8230050709,8230050710,9794082059,9794082060,11598311411,11598311412,13671383005,13671383006,16044429881,16044429882,18751214039,18751214040,21828270439,21828270440,25315054841,25315054842,29254095485,29254095486,33691148611,33691148612,38675357819,38675357820,44259417269,44259417270,50499738721,50499738722,57456622415,57456622416,65194431791,65194431792,73781772049,73781772050,83291672549,83291672550,93801773051,93801773052,105394513795,105394513796,118157329421,118157329422,132182846729,132182846730,147569086279,147569086280,164419667831,164419667832,182844019625,182844019626,202957591501,202957591502,224882071859,224882071860,248745608459,248745608460,274683033061,274683033062,302836089905,302836089906,333353668031,333353668032,366392037439,366392037440,402115089089,402115089090,440694578741,440694578742,482310374635,482310374636,527150709011,527150709012,575412433469,575412433470,627301278169,627301278170,683032114871,683032114872,742829223815,742829223816,806926564441,806926564442,875568049949,875568049950,949007825699,949007825700,1027510551451,1027510551452,1111351687445,1111351687446,1200817784321,1200817784322,1296206776879,1296206776880,1397828281679,1397828281680,1506003898481,1506003898482,1621067515525,1621067515526,1743365618651,1743365618652,1873257604259,1873257604260,2011116096109,2011116096110,2157327265961,2157327265962,2312291158055,2312291158056,2476422017431,2476422017432,2650148622089,2650148622090,2833914618989,2833914618990,3028178863891,3028178863892,3233415765035,3233415765036,3450115630661,3450115630662,3678785020369,3678785020370,3919947100319,3919947100320,4174142002271,4174142002272,4441927186465,4441927186466,4723877808341,4723877808342,5020587089099,5020587089100,5332666690099,5332666690100,5660747091101,5660747091102,6005477972345,6005477972346,6367528600471,6367528600472,6747588218279,6747588218280,7146366438329,7146366438330,7564593640381,7564593640382,8003021372675,8003021372676,8462422757051,8462422757052,8943592897909,8943592897910,9447349295009,9447349295010,9974532260111,9974532260112,10526005337455,10526005337456,11102655728081,11102655728082,11705394717989,11705394717990,12335158110139,12335158110140,12992906660291,12992906660292,13679626516685,13679626516686,14396329663561,14396329663562,15144054368519,15144054368520,15923865633719,15923865633720,16736855650921,16736855650922,17584144260365,17584144260366,18466879413491,18466879413492,19386237639499,19386237639500,20343424515749,20343424515750
mov $2,$0
add $2,1
mov $5,$0
lpb $2
mov $0,$5
sub $2,1
sub $0,$2
mov $4,$0
gcd $0,2
mov $3,5
gcd $6,1
add $4,$6
lpb $0
gcd $4,$0
pow $0,7
sub $0,1
lpe
pow $4,$3
add $1,$4
lpe
|
; A314209: Coordination sequence Gal.5.293.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,5,11,17,22,27,32,37,43,49,54,59,65,71,76,81,86,91,97,103,108,113,119,125,130,135,140,145,151,157,162,167,173,179,184,189,194,199,205,211,216,221,227,233,238,243,248,253,259,265
mov $5,$0
mov $7,$0
add $7,1
mov $8,$0
lpb $7
mov $0,$5
mov $4,0
sub $7,1
sub $0,$7
mov $2,2
lpb $0
div $0,$2
mov $6,8
add $6,$0
mov $0,1
mov $3,$6
mul $3,2
add $4,5
mod $3,$4
add $2,$3
div $2,$4
mov $6,1
add $6,$2
add $2,2
lpe
mov $3,$0
add $0,$6
add $3,1
add $0,$3
add $1,$0
lpe
add $1,$8
mov $0,$1
|
; A070652: n^6 mod 29.
; 0,1,6,4,7,23,24,25,13,16,22,9,28,20,5,5,20,28,9,22,16,13,25,24,23,7,4,6,1,0,1,6,4,7,23,24,25,13,16,22,9,28,20,5,5,20,28,9,22,16,13,25,24,23,7,4,6,1,0,1,6,4,7,23,24,25,13,16,22,9,28,20,5,5,20,28,9,22,16,13,25
pow $0,6
mod $0,29
|
/*
* Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
*
* The contents of this file constitute Original Code as defined in and are
* subject to the Apple Public Source License Version 1.2 (the 'License').
* You may not use this file except in compliance with the License. Please
* obtain a copy of the License at http://www.apple.com/publicsource and
* read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*/
/*
* p12pbe.h - PKCS12 PBE routine. App space reference version.
*
* Created 2/28/03 by Doug Mitchell.
*/
#include "p12pbe.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <Security/cssm.h>
#include <openssl/bn.h>
/*
* For development outside the CSP, malloc using stdlib.
* Inside the CSP we'll use CssmAllocator.
*/
#define PBE_MALLOC malloc
#define PBE_FREE free
/*
* implementation dependent hash object
* for now just a Digest context handle
*/
typedef CSSM_CC_HANDLE HashHand;
static HashHand hashCreate(CSSM_CSP_HANDLE cspHand,
CSSM_ALGORITHMS alg)
{
CSSM_CC_HANDLE hashHand;
CSSM_RETURN crtn = CSSM_CSP_CreateDigestContext(cspHand,
alg,
&hashHand);
if(crtn) {
printf("CSSM_CSP_CreateDigestContext error\n");
return 0;
}
return hashHand;
}
static CSSM_RETURN hashInit(HashHand hand)
{
return CSSM_DigestDataInit(hand);
}
static CSSM_RETURN hashUpdate(HashHand hand,
const unsigned char *buf,
unsigned bufLen)
{
const CSSM_DATA cdata = {bufLen, (uint8 *)buf};
return CSSM_DigestDataUpdate(hand, &cdata, 1);
}
static CSSM_RETURN hashFinal(HashHand hand,
unsigned char *digest, // mallocd by caller
unsigned *digestLen) // IN/OUT
{
CSSM_DATA cdata = {(uint32)digestLen, digest};
return CSSM_DigestDataFinal(hand, &cdata);
}
static CSSM_RETURN hashDone(HashHand hand)
{
return CSSM_DeleteContext(hand);
}
/*
* Create a "string" (in the loose p12 notation) of specified length
* from the concatention of copies of the specified input string.
*/
static unsigned char *p12StrCat(
const unsigned char *inStr,
unsigned inStrLen,
unsigned outLen,
unsigned char *outStr = NULL) // if not present, we malloc
{
if(outStr == NULL) {
outStr = (unsigned char *)PBE_MALLOC(outLen);
}
unsigned toMove = outLen;
unsigned char *outp = outStr;
while(toMove) {
unsigned thisMove = inStrLen;
if(thisMove > toMove) {
thisMove = toMove;
}
memmove(outp, inStr, thisMove);
toMove -= thisMove;
outp += thisMove;
}
return outStr;
}
/*
* PBE generator per PKCS12 v.1 section B.2.
*/
CSSM_RETURN p12PbeGen_app(
const CSSM_DATA &pwd, // unicode, double null terminated
const unsigned char *salt,
unsigned saltLen,
unsigned iterCount,
P12_PBE_ID pbeId,
CSSM_ALGORITHMS hashAlg, // MS5 or SHA1 only
CSSM_CSP_HANDLE cspHand,
/* result goes here, mallocd by caller */
unsigned char *outbuf,
unsigned outbufLen)
{
CSSM_RETURN ourRtn;
unsigned unipassLen = pwd.Length;
unsigned char *unipass = pwd.Data;
/*
* all variables of the form p12_<XXX> represent <XXX> from the
* PKCS12 spec. E.g., p12_u is u, the length of the digest output.
* Only difference here is: all of our sizes are in BYTES, not
* bits.
*/
unsigned p12_r = iterCount;
unsigned p12_n = outbufLen;
unsigned p12_u; // hash output size
unsigned p12_v; // hash block size
unsigned char *p12_P = NULL; // catted passwords
unsigned char *p12_S = NULL; // catted salts
switch(hashAlg) {
case CSSM_ALGID_MD5:
p12_u = 16;
p12_v = 64;
break;
case CSSM_ALGID_SHA1:
p12_u = 20;
p12_v = 64;
break;
default:
return CSSMERR_CSP_INVALID_ALGORITHM;
}
/*
* 1. Construct a string, D (the “diversifier”), by
* concatenating v/8 copies of ID.
*/
unsigned char *p12_D = NULL; // diversifier
p12_D = (unsigned char *)PBE_MALLOC(p12_v);
/* subsequent errors to errOut: */
for(unsigned dex=0; dex<p12_v; dex++) {
p12_D[dex] = (unsigned char)pbeId;
}
/*
* 2. Concatenate copies of the salt together to create
* a string S of length v * ceil(s/v) bits (the final copy
* of the salt may be truncated to create S). Note that if
* the salt is the empty string, then so is S.
*/
unsigned p12_Slen = p12_v * ((saltLen + p12_v - 1) / p12_v);
if(p12_Slen) {
p12_S = p12StrCat(salt, saltLen, p12_Slen);
}
/*
* 3. Concatenate copies of the password together to create
* a string P of length v * ceil(p/v) bits (the final copy of
* the password may be truncated to create P). Note that
* if the password is the empty string, then so is P.
*/
unsigned p12_Plen = p12_v * ((unipassLen + p12_v - 1) / p12_v);
if(p12_Plen) {
p12_P = p12StrCat(unipass, unipassLen, p12_Plen);
}
/*
* 4. Set I= S||P to be the concatenation of S and P.
*/
unsigned char *p12_I =
(unsigned char *)PBE_MALLOC(p12_Slen + p12_Plen);
memmove(p12_I, p12_S, p12_Slen);
if(p12_Plen) {
memmove(p12_I + p12_Slen, p12_P, p12_Plen);
}
/*
* 5. Set c = ceil(n/u).
*/
unsigned p12_c = (p12_n + p12_u - 1) / p12_u;
/* allocate c hash-output-size bufs */
unsigned char *p12_A = (unsigned char *)PBE_MALLOC(p12_c * p12_u);
/* one reusable hash object */
HashHand hashHand = hashCreate(cspHand, hashAlg);
if(!hashHand) {
return CSSMERR_CSP_INVALID_CONTEXT_HANDLE; // XXX
}
/* reused inside the loop */
unsigned char *p12_B = (unsigned char *)PBE_MALLOC(p12_v + sizeof(int));
BIGNUM *Ij = BN_new();
BIGNUM *Bpl1 = BN_new();
/*
* 6. For i=1, 2, ..., p12_c, do the following:
*/
for(unsigned p12_i=0; p12_i<p12_c; p12_i++) {
unsigned char *p12_AsubI = p12_A + (p12_i * p12_u);
/*
* a) Set A[i] = H**r(D||I). (i.e. the rth hash of D||I,
* H(H(H(...H(D||I))))
*/
ourRtn = hashInit(hashHand);
if(ourRtn) break;
ourRtn = hashUpdate(hashHand, p12_D, p12_v);
if(ourRtn) break;
ourRtn = hashUpdate(hashHand, p12_I, p12_Slen + p12_Plen);
if(ourRtn) break;
unsigned outLen = p12_u;
ourRtn = hashFinal(hashHand, p12_AsubI, &outLen);
if(ourRtn) break;
for(unsigned iter=1; iter<p12_r; iter++) {
ourRtn = hashInit(hashHand);
if(ourRtn) break;
ourRtn = hashUpdate(hashHand, p12_AsubI, p12_u);
if(ourRtn) break;
ourRtn = hashFinal(hashHand, p12_AsubI, &outLen);
if(ourRtn) break;
}
/*
* b) Concatenate copies of A[i] to create a string B of
* length v bits (the final copy of A[i]i may be truncated
* to create B).
*/
p12StrCat(p12_AsubI, p12_u, p12_v, p12_B);
/*
* c) Treating I as a concatenation I[0], I[1], ...,
* I[k-1] of v-bit blocks, where k = ceil(s/v) + ceil(p/v),
* modify I by setting I[j]=(I[j]+B+1) mod (2 ** v)
* for each j.
*
* Copied from PKCS12_key_gen_uni() from openssl...
*/
/* Work out B + 1 first then can use B as tmp space */
BN_bin2bn (p12_B, p12_v, Bpl1);
BN_add_word (Bpl1, 1);
unsigned Ilen = p12_Slen + p12_Plen;
for (unsigned j = 0; j < Ilen; j+=p12_v) {
BN_bin2bn (p12_I + j, p12_v, Ij);
BN_add (Ij, Ij, Bpl1);
BN_bn2bin (Ij, p12_B);
unsigned Ijlen = BN_num_bytes (Ij);
/* If more than 2^(v*8) - 1 cut off MSB */
if (Ijlen > p12_v) {
BN_bn2bin (Ij, p12_B);
memcpy (p12_I + j, p12_B + 1, p12_v);
/* If less than v bytes pad with zeroes */
} else if (Ijlen < p12_v) {
memset(p12_I + j, 0, p12_v - Ijlen);
BN_bn2bin(Ij, p12_I + j + p12_v - Ijlen);
} else BN_bn2bin (Ij, p12_I + j);
}
}
if(ourRtn) {
goto errOut;
}
/*
* 7. Concatenate A[1], A[2], ..., A[c] together to form a
* pseudo-random bit string, A.
*
* 8. Use the first n bits of A as the output of this entire
* process.
*/
memmove(outbuf, p12_A, outbufLen);
ourRtn = CSSM_OK;
errOut:
/* FIXME clear all these strings */
if(p12_D) {
PBE_FREE(p12_D);
}
if(p12_S) {
PBE_FREE(p12_S);
}
if(p12_P) {
PBE_FREE(p12_P);
}
if(p12_I) {
PBE_FREE(p12_I);
}
if(p12_A) {
PBE_FREE(p12_A);
}
if(p12_B) {
PBE_FREE(p12_B);
}
if(hashHand) {
hashDone(hashHand);
}
BN_free(Bpl1);
BN_free(Ij);
return ourRtn;
}
|
; A117596: Start with x=6/5; repeatedly apply the map x -> x*ceiling(x); sequence gives numerators of the resulting sequence of fractions.
; Submitted by Christian Krause
; 6,12,36,288,16704,55808064,622908012647232,77602878444025201997703040704,1204441348559630271252918141028336694332989128001036771264,290135792424028156178425357986052529062710984863337179470336908191924417208517059859206222048920739921330978585792
mov $1,1
lpb $0
sub $0,1
div $2,5
add $2,$1
add $2,1
mul $1,$2
mov $2,$1
lpe
mov $0,$1
mul $0,6
|
; A058748: a(n) = round(n*exp(n)).
; 0,3,15,60,218,742,2421,7676,23848,72928,220265,658616,1953057,5751374,16836460,49035261,142177768,410634197,1181879444,3391163718,9703303908,27695130424,78868082615,224130479264,635738931116,1800122483435,5088969845150,14365302496249,40495197800161,114008694617177,320594237445734,900514339622670,2526814725845782,7083238132935230,19837699245933466,55510470830970075,155204335696147028,433608267793696618,1210525406770322736,3377142616535756131,9415410673480799416,26233583234732252918,73049547543861043991,203297097133861902143,565470405031809564136,1572042197586829290662,4368214933477126482276,12132170565093316762294,33680332378068632345543,93459982052259884835730,259235276429353623204373,718768032037738786189099,1992124160372619961637856,5519292499505416532507241,15286067837683347062387143,42321318958281094260005101,117132931776727784618795985,324086039962148136690499883,896412582642260279604784481,2478714138236403410424390124,6852044338894105701977743099,18936217407781711443114787061,52317811346197017832254642778,144508339046585422383259228937,399049541171943480506191277371,1101678008866716914192159347434,3040743178658652418167030172252,8390833244642832329440597136987,23149077139535835545362968871630,63851093906555734441672545625143,176080706964341690438604682197648,485474657313154814539668390694117,1338243656604572145845066530503270,3688247350101556062026637982495608,10163034048597303789602995120583188,27999314975992512301911812379485251,77124829496655543315267095594010490,212405535998284105884058176132504970,584876525765229393904699186115476715
mul $0,2
mov $2,-8
mov $3,$0
mul $3,5
lpb $3
mul $1,$0
mul $2,$3
add $1,$2
cmp $4,0
add $5,$4
div $1,$5
div $2,$5
sub $3,2
lpe
mul $1,$0
div $1,$2
add $1,1
div $1,2
mov $0,$1
|
// Copyright 2019 The MWC Developers
//
// 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 "e_outputs.h"
#include "../core/appcontext.h"
#include "../core/Config.h"
#include "../state/statemachine.h"
#include "../util/crypto.h"
#include "../util/Log.h"
#include <QDebug>
#include "../core/global.h"
#include "../core/WndManager.h"
#include "../bridge/BridgeManager.h"
#include "../bridge/wnd/e_outputs_b.h"
namespace state {
Outputs::Outputs(StateContext * context) :
State(context, STATE::OUTPUTS)
{
}
Outputs::~Outputs() {}
NextStateRespond Outputs::execute() {
if (context->appContext->getActiveWndState() != STATE::OUTPUTS)
return NextStateRespond(NextStateRespond::RESULT::DONE);
core::getWndManager()->pageOutputs();
return NextStateRespond( NextStateRespond::RESULT::WAIT_FOR_ACTION );
}
}
|
; float __fsadd_callee(float a1, float a2)
SECTION code_fp_math48
PUBLIC cm48_sdccixp_dsadd_callee
EXTERN cm48_sdccixp_dcallee2, am48_dadd, cm48_sdccixp_m482d
cm48_sdccixp_dsadd_callee:
; add two sdcc floats
;
; enter : stack = sdcc_float a2, sdcc_float a1, ret
;
; exit : dehl = sdcc_float(a1+a2)
;
; uses : af, bc, de, hl, af', bc', de', hl'
call cm48_sdccixp_dcallee2
; AC = a1
; AC'= a2
call am48_dadd
jp cm48_sdccixp_m482d
|
; A040563: Continued fraction for sqrt(588).
; 24,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48,4,48
sub $0,1
mod $0,2
mul $0,11
add $0,2
pow $0,2
mov $1,$0
div $1,15
mul $1,4
add $1,4
|
.386p
Kernel Segment public para use32
assume cs:Kernel
__k8259SlaveEntry proc
pushad
mov ebp,esp
add ebp,32
push dword ptr ICW2_MASTER_INT_NO + 2
push dword ptr 0
push dword ptr [ebp]
push dword ptr [ebp + 4]
push dword ptr [ebp + 8]
test dword ptr [ebp+4],3
jz _kSlaveFriverKernelModeInt
push dword ptr [ebp + 12]
push dword ptr [ebp + 16]
jmp _kSlaveFriverShowExpInfo
_kSlaveFriverKernelModeInt:
push dword ptr 0
push dword ptr 0
_kSlaveFriverShowExpInfo:
call __exceptionInfo
add esp,28
mov al,20h
out 20h,al
out 0a0h,al
popad
iretd
__k8259SlaveEntry endp
Kernel ends |
; A173625: Decimal expansion of -3(1 - Pi)
; Submitted by Christian Krause
; 6,4,2,4,7,7,7,9,6,0,7,6,9,3,7,9,7,1,5,3,8,7,9,3,0,1,4,9,8,3,8,5,0,8,6,5,2,5,9,1,5,0,8,1,9,8,1,2,5,3,1,7,4,6,2,9,2,4,8,3,3,7,7,6,9,2,3,4,4,9,2,1,8,8,5,8,6,2,6,9,9,5,8,8,4,1,0,4,4,7,6,0,2,6,3,5,1,2,0,3
mov $1,1
mov $2,1
mov $3,$0
mul $3,5
lpb $3
mul $1,$3
mov $5,$3
mul $5,2
add $5,3
mul $2,$5
add $1,$2
cmp $4,0
mov $5,$0
add $5,$4
div $1,$5
div $2,$5
sub $3,1
lpe
mul $1,2
mov $6,10
pow $6,$0
div $2,$6
div $1,$2
add $1,$6
mov $0,$1
mul $0,286909
sub $0,1
mod $0,10
|
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)rraiy"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta yb
lda #<da
sta 172
lda #>da
sta 173
next lda pb
pha
plp
lda db
sta da
ror a
sta dr
adc ab
sta ar
php
pla
sta pr
lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $73
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc 172
bne noinc
inc 173
noinc lda yb
bne nodec
dec 173
nodec dec yb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "dcmz"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend
|
_stressfs: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "fs.h"
#include "fcntl.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
int fd, i;
char path[] = "stressfs0";
7: b8 30 00 00 00 mov $0x30,%eax
{
c: ff 71 fc pushl -0x4(%ecx)
f: 55 push %ebp
10: 89 e5 mov %esp,%ebp
12: 57 push %edi
13: 56 push %esi
14: 53 push %ebx
15: 51 push %ecx
char data[512];
printf(1, "stressfs starting\n");
memset(data, 'a', sizeof(data));
16: 8d b5 e8 fd ff ff lea -0x218(%ebp),%esi
for(i = 0; i < 4; i++)
1c: 31 db xor %ebx,%ebx
{
1e: 81 ec 20 02 00 00 sub $0x220,%esp
char path[] = "stressfs0";
24: 66 89 85 e6 fd ff ff mov %ax,-0x21a(%ebp)
2b: c7 85 de fd ff ff 73 movl $0x65727473,-0x222(%ebp)
32: 74 72 65
printf(1, "stressfs starting\n");
35: 68 58 08 00 00 push $0x858
3a: 6a 01 push $0x1
char path[] = "stressfs0";
3c: c7 85 e2 fd ff ff 73 movl $0x73667373,-0x21e(%ebp)
43: 73 66 73
printf(1, "stressfs starting\n");
46: e8 b5 04 00 00 call 500 <printf>
memset(data, 'a', sizeof(data));
4b: 83 c4 0c add $0xc,%esp
4e: 68 00 02 00 00 push $0x200
53: 6a 61 push $0x61
55: 56 push %esi
56: e8 95 01 00 00 call 1f0 <memset>
5b: 83 c4 10 add $0x10,%esp
if(fork() > 0)
5e: e8 27 03 00 00 call 38a <fork>
63: 85 c0 test %eax,%eax
65: 0f 8f bf 00 00 00 jg 12a <main+0x12a>
for(i = 0; i < 4; i++)
6b: 83 c3 01 add $0x1,%ebx
6e: 83 fb 04 cmp $0x4,%ebx
71: 75 eb jne 5e <main+0x5e>
73: bf 04 00 00 00 mov $0x4,%edi
break;
printf(1, "write %d\n", i);
78: 83 ec 04 sub $0x4,%esp
7b: 53 push %ebx
7c: 68 6b 08 00 00 push $0x86b
path[8] += i;
fd = open(path, O_CREATE | O_RDWR);
81: bb 14 00 00 00 mov $0x14,%ebx
printf(1, "write %d\n", i);
86: 6a 01 push $0x1
88: e8 73 04 00 00 call 500 <printf>
path[8] += i;
8d: 89 f8 mov %edi,%eax
8f: 00 85 e6 fd ff ff add %al,-0x21a(%ebp)
fd = open(path, O_CREATE | O_RDWR);
95: 5f pop %edi
96: 58 pop %eax
97: 8d 85 de fd ff ff lea -0x222(%ebp),%eax
9d: 68 02 02 00 00 push $0x202
a2: 50 push %eax
a3: e8 2a 03 00 00 call 3d2 <open>
a8: 83 c4 10 add $0x10,%esp
ab: 89 c7 mov %eax,%edi
ad: 8d 76 00 lea 0x0(%esi),%esi
for(i = 0; i < 20; i++)
// printf(fd, "%d\n", i);
write(fd, data, sizeof(data));
b0: 83 ec 04 sub $0x4,%esp
b3: 68 00 02 00 00 push $0x200
b8: 56 push %esi
b9: 57 push %edi
ba: e8 f3 02 00 00 call 3b2 <write>
for(i = 0; i < 20; i++)
bf: 83 c4 10 add $0x10,%esp
c2: 83 eb 01 sub $0x1,%ebx
c5: 75 e9 jne b0 <main+0xb0>
close(fd);
c7: 83 ec 0c sub $0xc,%esp
ca: 57 push %edi
cb: e8 ea 02 00 00 call 3ba <close>
printf(1, "read\n");
d0: 58 pop %eax
d1: 5a pop %edx
d2: 68 75 08 00 00 push $0x875
d7: 6a 01 push $0x1
d9: e8 22 04 00 00 call 500 <printf>
fd = open(path, O_RDONLY);
de: 59 pop %ecx
df: 8d 85 de fd ff ff lea -0x222(%ebp),%eax
e5: 5b pop %ebx
e6: 6a 00 push $0x0
e8: 50 push %eax
e9: bb 14 00 00 00 mov $0x14,%ebx
ee: e8 df 02 00 00 call 3d2 <open>
f3: 83 c4 10 add $0x10,%esp
f6: 89 c7 mov %eax,%edi
f8: 90 nop
f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for (i = 0; i < 20; i++)
read(fd, data, sizeof(data));
100: 83 ec 04 sub $0x4,%esp
103: 68 00 02 00 00 push $0x200
108: 56 push %esi
109: 57 push %edi
10a: e8 9b 02 00 00 call 3aa <read>
for (i = 0; i < 20; i++)
10f: 83 c4 10 add $0x10,%esp
112: 83 eb 01 sub $0x1,%ebx
115: 75 e9 jne 100 <main+0x100>
close(fd);
117: 83 ec 0c sub $0xc,%esp
11a: 57 push %edi
11b: e8 9a 02 00 00 call 3ba <close>
wait();
120: e8 75 02 00 00 call 39a <wait>
exit();
125: e8 68 02 00 00 call 392 <exit>
12a: 89 df mov %ebx,%edi
12c: e9 47 ff ff ff jmp 78 <main+0x78>
131: 66 90 xchg %ax,%ax
133: 66 90 xchg %ax,%ax
135: 66 90 xchg %ax,%ax
137: 66 90 xchg %ax,%ax
139: 66 90 xchg %ax,%ax
13b: 66 90 xchg %ax,%ax
13d: 66 90 xchg %ax,%ax
13f: 90 nop
00000140 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 53 push %ebx
144: 8b 45 08 mov 0x8(%ebp),%eax
147: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
14a: 89 c2 mov %eax,%edx
14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
150: 83 c1 01 add $0x1,%ecx
153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
157: 83 c2 01 add $0x1,%edx
15a: 84 db test %bl,%bl
15c: 88 5a ff mov %bl,-0x1(%edx)
15f: 75 ef jne 150 <strcpy+0x10>
;
return os;
}
161: 5b pop %ebx
162: 5d pop %ebp
163: c3 ret
164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
16a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000170 <strcmp>:
int
strcmp(const char *p, const char *q)
{
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 53 push %ebx
174: 8b 55 08 mov 0x8(%ebp),%edx
177: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
17a: 0f b6 02 movzbl (%edx),%eax
17d: 0f b6 19 movzbl (%ecx),%ebx
180: 84 c0 test %al,%al
182: 75 1c jne 1a0 <strcmp+0x30>
184: eb 2a jmp 1b0 <strcmp+0x40>
186: 8d 76 00 lea 0x0(%esi),%esi
189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
190: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
193: 0f b6 02 movzbl (%edx),%eax
p++, q++;
196: 83 c1 01 add $0x1,%ecx
199: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
19c: 84 c0 test %al,%al
19e: 74 10 je 1b0 <strcmp+0x40>
1a0: 38 d8 cmp %bl,%al
1a2: 74 ec je 190 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
1a4: 29 d8 sub %ebx,%eax
}
1a6: 5b pop %ebx
1a7: 5d pop %ebp
1a8: c3 ret
1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1b0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1b2: 29 d8 sub %ebx,%eax
}
1b4: 5b pop %ebx
1b5: 5d pop %ebp
1b6: c3 ret
1b7: 89 f6 mov %esi,%esi
1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001c0 <strlen>:
uint
strlen(const char *s)
{
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1c6: 80 39 00 cmpb $0x0,(%ecx)
1c9: 74 15 je 1e0 <strlen+0x20>
1cb: 31 d2 xor %edx,%edx
1cd: 8d 76 00 lea 0x0(%esi),%esi
1d0: 83 c2 01 add $0x1,%edx
1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1d7: 89 d0 mov %edx,%eax
1d9: 75 f5 jne 1d0 <strlen+0x10>
;
return n;
}
1db: 5d pop %ebp
1dc: c3 ret
1dd: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
1e0: 31 c0 xor %eax,%eax
}
1e2: 5d pop %ebp
1e3: c3 ret
1e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001f0 <memset>:
void*
memset(void *dst, int c, uint n)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 57 push %edi
1f4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
1f7: 8b 4d 10 mov 0x10(%ebp),%ecx
1fa: 8b 45 0c mov 0xc(%ebp),%eax
1fd: 89 d7 mov %edx,%edi
1ff: fc cld
200: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
202: 89 d0 mov %edx,%eax
204: 5f pop %edi
205: 5d pop %ebp
206: c3 ret
207: 89 f6 mov %esi,%esi
209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000210 <strchr>:
char*
strchr(const char *s, char c)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 53 push %ebx
214: 8b 45 08 mov 0x8(%ebp),%eax
217: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
21a: 0f b6 10 movzbl (%eax),%edx
21d: 84 d2 test %dl,%dl
21f: 74 1d je 23e <strchr+0x2e>
if(*s == c)
221: 38 d3 cmp %dl,%bl
223: 89 d9 mov %ebx,%ecx
225: 75 0d jne 234 <strchr+0x24>
227: eb 17 jmp 240 <strchr+0x30>
229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
230: 38 ca cmp %cl,%dl
232: 74 0c je 240 <strchr+0x30>
for(; *s; s++)
234: 83 c0 01 add $0x1,%eax
237: 0f b6 10 movzbl (%eax),%edx
23a: 84 d2 test %dl,%dl
23c: 75 f2 jne 230 <strchr+0x20>
return (char*)s;
return 0;
23e: 31 c0 xor %eax,%eax
}
240: 5b pop %ebx
241: 5d pop %ebp
242: c3 ret
243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000250 <gets>:
char*
gets(char *buf, int max)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 57 push %edi
254: 56 push %esi
255: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
256: 31 f6 xor %esi,%esi
258: 89 f3 mov %esi,%ebx
{
25a: 83 ec 1c sub $0x1c,%esp
25d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
260: eb 2f jmp 291 <gets+0x41>
262: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
268: 8d 45 e7 lea -0x19(%ebp),%eax
26b: 83 ec 04 sub $0x4,%esp
26e: 6a 01 push $0x1
270: 50 push %eax
271: 6a 00 push $0x0
273: e8 32 01 00 00 call 3aa <read>
if(cc < 1)
278: 83 c4 10 add $0x10,%esp
27b: 85 c0 test %eax,%eax
27d: 7e 1c jle 29b <gets+0x4b>
break;
buf[i++] = c;
27f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
283: 83 c7 01 add $0x1,%edi
286: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
289: 3c 0a cmp $0xa,%al
28b: 74 23 je 2b0 <gets+0x60>
28d: 3c 0d cmp $0xd,%al
28f: 74 1f je 2b0 <gets+0x60>
for(i=0; i+1 < max; ){
291: 83 c3 01 add $0x1,%ebx
294: 3b 5d 0c cmp 0xc(%ebp),%ebx
297: 89 fe mov %edi,%esi
299: 7c cd jl 268 <gets+0x18>
29b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
29d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2a0: c6 03 00 movb $0x0,(%ebx)
}
2a3: 8d 65 f4 lea -0xc(%ebp),%esp
2a6: 5b pop %ebx
2a7: 5e pop %esi
2a8: 5f pop %edi
2a9: 5d pop %ebp
2aa: c3 ret
2ab: 90 nop
2ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2b0: 8b 75 08 mov 0x8(%ebp),%esi
2b3: 8b 45 08 mov 0x8(%ebp),%eax
2b6: 01 de add %ebx,%esi
2b8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2ba: c6 03 00 movb $0x0,(%ebx)
}
2bd: 8d 65 f4 lea -0xc(%ebp),%esp
2c0: 5b pop %ebx
2c1: 5e pop %esi
2c2: 5f pop %edi
2c3: 5d pop %ebp
2c4: c3 ret
2c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002d0 <stat>:
int
stat(const char *n, struct stat *st)
{
2d0: 55 push %ebp
2d1: 89 e5 mov %esp,%ebp
2d3: 56 push %esi
2d4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
2d5: 83 ec 08 sub $0x8,%esp
2d8: 6a 00 push $0x0
2da: ff 75 08 pushl 0x8(%ebp)
2dd: e8 f0 00 00 00 call 3d2 <open>
if(fd < 0)
2e2: 83 c4 10 add $0x10,%esp
2e5: 85 c0 test %eax,%eax
2e7: 78 27 js 310 <stat+0x40>
return -1;
r = fstat(fd, st);
2e9: 83 ec 08 sub $0x8,%esp
2ec: ff 75 0c pushl 0xc(%ebp)
2ef: 89 c3 mov %eax,%ebx
2f1: 50 push %eax
2f2: e8 f3 00 00 00 call 3ea <fstat>
close(fd);
2f7: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
2fa: 89 c6 mov %eax,%esi
close(fd);
2fc: e8 b9 00 00 00 call 3ba <close>
return r;
301: 83 c4 10 add $0x10,%esp
}
304: 8d 65 f8 lea -0x8(%ebp),%esp
307: 89 f0 mov %esi,%eax
309: 5b pop %ebx
30a: 5e pop %esi
30b: 5d pop %ebp
30c: c3 ret
30d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
310: be ff ff ff ff mov $0xffffffff,%esi
315: eb ed jmp 304 <stat+0x34>
317: 89 f6 mov %esi,%esi
319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000320 <atoi>:
int
atoi(const char *s)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 53 push %ebx
324: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
327: 0f be 11 movsbl (%ecx),%edx
32a: 8d 42 d0 lea -0x30(%edx),%eax
32d: 3c 09 cmp $0x9,%al
n = 0;
32f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
334: 77 1f ja 355 <atoi+0x35>
336: 8d 76 00 lea 0x0(%esi),%esi
339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
340: 8d 04 80 lea (%eax,%eax,4),%eax
343: 83 c1 01 add $0x1,%ecx
346: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
34a: 0f be 11 movsbl (%ecx),%edx
34d: 8d 5a d0 lea -0x30(%edx),%ebx
350: 80 fb 09 cmp $0x9,%bl
353: 76 eb jbe 340 <atoi+0x20>
return n;
}
355: 5b pop %ebx
356: 5d pop %ebp
357: c3 ret
358: 90 nop
359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000360 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 56 push %esi
364: 53 push %ebx
365: 8b 5d 10 mov 0x10(%ebp),%ebx
368: 8b 45 08 mov 0x8(%ebp),%eax
36b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
36e: 85 db test %ebx,%ebx
370: 7e 14 jle 386 <memmove+0x26>
372: 31 d2 xor %edx,%edx
374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
378: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
37c: 88 0c 10 mov %cl,(%eax,%edx,1)
37f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
382: 39 d3 cmp %edx,%ebx
384: 75 f2 jne 378 <memmove+0x18>
return vdst;
}
386: 5b pop %ebx
387: 5e pop %esi
388: 5d pop %ebp
389: c3 ret
0000038a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
38a: b8 01 00 00 00 mov $0x1,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <exit>:
SYSCALL(exit)
392: b8 02 00 00 00 mov $0x2,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <wait>:
SYSCALL(wait)
39a: b8 03 00 00 00 mov $0x3,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <pipe>:
SYSCALL(pipe)
3a2: b8 04 00 00 00 mov $0x4,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <read>:
SYSCALL(read)
3aa: b8 05 00 00 00 mov $0x5,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <write>:
SYSCALL(write)
3b2: b8 10 00 00 00 mov $0x10,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <close>:
SYSCALL(close)
3ba: b8 15 00 00 00 mov $0x15,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <kill>:
SYSCALL(kill)
3c2: b8 06 00 00 00 mov $0x6,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <exec>:
SYSCALL(exec)
3ca: b8 07 00 00 00 mov $0x7,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <open>:
SYSCALL(open)
3d2: b8 0f 00 00 00 mov $0xf,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <mknod>:
SYSCALL(mknod)
3da: b8 11 00 00 00 mov $0x11,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <unlink>:
SYSCALL(unlink)
3e2: b8 12 00 00 00 mov $0x12,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <fstat>:
SYSCALL(fstat)
3ea: b8 08 00 00 00 mov $0x8,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <link>:
SYSCALL(link)
3f2: b8 13 00 00 00 mov $0x13,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <mkdir>:
SYSCALL(mkdir)
3fa: b8 14 00 00 00 mov $0x14,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <chdir>:
SYSCALL(chdir)
402: b8 09 00 00 00 mov $0x9,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <dup>:
SYSCALL(dup)
40a: b8 0a 00 00 00 mov $0xa,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <getpid>:
SYSCALL(getpid)
412: b8 0b 00 00 00 mov $0xb,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <sbrk>:
SYSCALL(sbrk)
41a: b8 0c 00 00 00 mov $0xc,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <sleep>:
SYSCALL(sleep)
422: b8 0d 00 00 00 mov $0xd,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <uptime>:
SYSCALL(uptime)
42a: b8 0e 00 00 00 mov $0xe,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <cps>:
SYSCALL(cps)
432: b8 16 00 00 00 mov $0x16,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <chpr>:
SYSCALL(chpr)
43a: b8 17 00 00 00 mov $0x17,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <waitx>:
SYSCALL(waitx)
442: b8 18 00 00 00 mov $0x18,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <getpinfo>:
SYSCALL(getpinfo)
44a: b8 19 00 00 00 mov $0x19,%eax
44f: cd 40 int $0x40
451: c3 ret
452: 66 90 xchg %ax,%ax
454: 66 90 xchg %ax,%ax
456: 66 90 xchg %ax,%ax
458: 66 90 xchg %ax,%ax
45a: 66 90 xchg %ax,%ax
45c: 66 90 xchg %ax,%ax
45e: 66 90 xchg %ax,%ax
00000460 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
460: 55 push %ebp
461: 89 e5 mov %esp,%ebp
463: 57 push %edi
464: 56 push %esi
465: 53 push %ebx
466: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
469: 85 d2 test %edx,%edx
{
46b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
46e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
470: 79 76 jns 4e8 <printint+0x88>
472: f6 45 08 01 testb $0x1,0x8(%ebp)
476: 74 70 je 4e8 <printint+0x88>
x = -xx;
478: f7 d8 neg %eax
neg = 1;
47a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
481: 31 f6 xor %esi,%esi
483: 8d 5d d7 lea -0x29(%ebp),%ebx
486: eb 0a jmp 492 <printint+0x32>
488: 90 nop
489: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
490: 89 fe mov %edi,%esi
492: 31 d2 xor %edx,%edx
494: 8d 7e 01 lea 0x1(%esi),%edi
497: f7 f1 div %ecx
499: 0f b6 92 84 08 00 00 movzbl 0x884(%edx),%edx
}while((x /= base) != 0);
4a0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
4a2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
4a5: 75 e9 jne 490 <printint+0x30>
if(neg)
4a7: 8b 45 c4 mov -0x3c(%ebp),%eax
4aa: 85 c0 test %eax,%eax
4ac: 74 08 je 4b6 <printint+0x56>
buf[i++] = '-';
4ae: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
4b3: 8d 7e 02 lea 0x2(%esi),%edi
4b6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
4ba: 8b 7d c0 mov -0x40(%ebp),%edi
4bd: 8d 76 00 lea 0x0(%esi),%esi
4c0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
4c3: 83 ec 04 sub $0x4,%esp
4c6: 83 ee 01 sub $0x1,%esi
4c9: 6a 01 push $0x1
4cb: 53 push %ebx
4cc: 57 push %edi
4cd: 88 45 d7 mov %al,-0x29(%ebp)
4d0: e8 dd fe ff ff call 3b2 <write>
while(--i >= 0)
4d5: 83 c4 10 add $0x10,%esp
4d8: 39 de cmp %ebx,%esi
4da: 75 e4 jne 4c0 <printint+0x60>
putc(fd, buf[i]);
}
4dc: 8d 65 f4 lea -0xc(%ebp),%esp
4df: 5b pop %ebx
4e0: 5e pop %esi
4e1: 5f pop %edi
4e2: 5d pop %ebp
4e3: c3 ret
4e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
4e8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
4ef: eb 90 jmp 481 <printint+0x21>
4f1: eb 0d jmp 500 <printf>
4f3: 90 nop
4f4: 90 nop
4f5: 90 nop
4f6: 90 nop
4f7: 90 nop
4f8: 90 nop
4f9: 90 nop
4fa: 90 nop
4fb: 90 nop
4fc: 90 nop
4fd: 90 nop
4fe: 90 nop
4ff: 90 nop
00000500 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
500: 55 push %ebp
501: 89 e5 mov %esp,%ebp
503: 57 push %edi
504: 56 push %esi
505: 53 push %ebx
506: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
509: 8b 75 0c mov 0xc(%ebp),%esi
50c: 0f b6 1e movzbl (%esi),%ebx
50f: 84 db test %bl,%bl
511: 0f 84 b3 00 00 00 je 5ca <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
517: 8d 45 10 lea 0x10(%ebp),%eax
51a: 83 c6 01 add $0x1,%esi
state = 0;
51d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
51f: 89 45 d4 mov %eax,-0x2c(%ebp)
522: eb 2f jmp 553 <printf+0x53>
524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
528: 83 f8 25 cmp $0x25,%eax
52b: 0f 84 a7 00 00 00 je 5d8 <printf+0xd8>
write(fd, &c, 1);
531: 8d 45 e2 lea -0x1e(%ebp),%eax
534: 83 ec 04 sub $0x4,%esp
537: 88 5d e2 mov %bl,-0x1e(%ebp)
53a: 6a 01 push $0x1
53c: 50 push %eax
53d: ff 75 08 pushl 0x8(%ebp)
540: e8 6d fe ff ff call 3b2 <write>
545: 83 c4 10 add $0x10,%esp
548: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
54b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
54f: 84 db test %bl,%bl
551: 74 77 je 5ca <printf+0xca>
if(state == 0){
553: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
555: 0f be cb movsbl %bl,%ecx
558: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
55b: 74 cb je 528 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
55d: 83 ff 25 cmp $0x25,%edi
560: 75 e6 jne 548 <printf+0x48>
if(c == 'd'){
562: 83 f8 64 cmp $0x64,%eax
565: 0f 84 05 01 00 00 je 670 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
56b: 81 e1 f7 00 00 00 and $0xf7,%ecx
571: 83 f9 70 cmp $0x70,%ecx
574: 74 72 je 5e8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
576: 83 f8 73 cmp $0x73,%eax
579: 0f 84 99 00 00 00 je 618 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
57f: 83 f8 63 cmp $0x63,%eax
582: 0f 84 08 01 00 00 je 690 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
588: 83 f8 25 cmp $0x25,%eax
58b: 0f 84 ef 00 00 00 je 680 <printf+0x180>
write(fd, &c, 1);
591: 8d 45 e7 lea -0x19(%ebp),%eax
594: 83 ec 04 sub $0x4,%esp
597: c6 45 e7 25 movb $0x25,-0x19(%ebp)
59b: 6a 01 push $0x1
59d: 50 push %eax
59e: ff 75 08 pushl 0x8(%ebp)
5a1: e8 0c fe ff ff call 3b2 <write>
5a6: 83 c4 0c add $0xc,%esp
5a9: 8d 45 e6 lea -0x1a(%ebp),%eax
5ac: 88 5d e6 mov %bl,-0x1a(%ebp)
5af: 6a 01 push $0x1
5b1: 50 push %eax
5b2: ff 75 08 pushl 0x8(%ebp)
5b5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
5b8: 31 ff xor %edi,%edi
write(fd, &c, 1);
5ba: e8 f3 fd ff ff call 3b2 <write>
for(i = 0; fmt[i]; i++){
5bf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
5c3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
5c6: 84 db test %bl,%bl
5c8: 75 89 jne 553 <printf+0x53>
}
}
}
5ca: 8d 65 f4 lea -0xc(%ebp),%esp
5cd: 5b pop %ebx
5ce: 5e pop %esi
5cf: 5f pop %edi
5d0: 5d pop %ebp
5d1: c3 ret
5d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
5d8: bf 25 00 00 00 mov $0x25,%edi
5dd: e9 66 ff ff ff jmp 548 <printf+0x48>
5e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
5e8: 83 ec 0c sub $0xc,%esp
5eb: b9 10 00 00 00 mov $0x10,%ecx
5f0: 6a 00 push $0x0
5f2: 8b 7d d4 mov -0x2c(%ebp),%edi
5f5: 8b 45 08 mov 0x8(%ebp),%eax
5f8: 8b 17 mov (%edi),%edx
5fa: e8 61 fe ff ff call 460 <printint>
ap++;
5ff: 89 f8 mov %edi,%eax
601: 83 c4 10 add $0x10,%esp
state = 0;
604: 31 ff xor %edi,%edi
ap++;
606: 83 c0 04 add $0x4,%eax
609: 89 45 d4 mov %eax,-0x2c(%ebp)
60c: e9 37 ff ff ff jmp 548 <printf+0x48>
611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
618: 8b 45 d4 mov -0x2c(%ebp),%eax
61b: 8b 08 mov (%eax),%ecx
ap++;
61d: 83 c0 04 add $0x4,%eax
620: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
623: 85 c9 test %ecx,%ecx
625: 0f 84 8e 00 00 00 je 6b9 <printf+0x1b9>
while(*s != 0){
62b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
62e: 31 ff xor %edi,%edi
s = (char*)*ap;
630: 89 cb mov %ecx,%ebx
while(*s != 0){
632: 84 c0 test %al,%al
634: 0f 84 0e ff ff ff je 548 <printf+0x48>
63a: 89 75 d0 mov %esi,-0x30(%ebp)
63d: 89 de mov %ebx,%esi
63f: 8b 5d 08 mov 0x8(%ebp),%ebx
642: 8d 7d e3 lea -0x1d(%ebp),%edi
645: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
648: 83 ec 04 sub $0x4,%esp
s++;
64b: 83 c6 01 add $0x1,%esi
64e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
651: 6a 01 push $0x1
653: 57 push %edi
654: 53 push %ebx
655: e8 58 fd ff ff call 3b2 <write>
while(*s != 0){
65a: 0f b6 06 movzbl (%esi),%eax
65d: 83 c4 10 add $0x10,%esp
660: 84 c0 test %al,%al
662: 75 e4 jne 648 <printf+0x148>
664: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
667: 31 ff xor %edi,%edi
669: e9 da fe ff ff jmp 548 <printf+0x48>
66e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
670: 83 ec 0c sub $0xc,%esp
673: b9 0a 00 00 00 mov $0xa,%ecx
678: 6a 01 push $0x1
67a: e9 73 ff ff ff jmp 5f2 <printf+0xf2>
67f: 90 nop
write(fd, &c, 1);
680: 83 ec 04 sub $0x4,%esp
683: 88 5d e5 mov %bl,-0x1b(%ebp)
686: 8d 45 e5 lea -0x1b(%ebp),%eax
689: 6a 01 push $0x1
68b: e9 21 ff ff ff jmp 5b1 <printf+0xb1>
putc(fd, *ap);
690: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
693: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
696: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
698: 6a 01 push $0x1
ap++;
69a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
69d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
6a0: 8d 45 e4 lea -0x1c(%ebp),%eax
6a3: 50 push %eax
6a4: ff 75 08 pushl 0x8(%ebp)
6a7: e8 06 fd ff ff call 3b2 <write>
ap++;
6ac: 89 7d d4 mov %edi,-0x2c(%ebp)
6af: 83 c4 10 add $0x10,%esp
state = 0;
6b2: 31 ff xor %edi,%edi
6b4: e9 8f fe ff ff jmp 548 <printf+0x48>
s = "(null)";
6b9: bb 7b 08 00 00 mov $0x87b,%ebx
while(*s != 0){
6be: b8 28 00 00 00 mov $0x28,%eax
6c3: e9 72 ff ff ff jmp 63a <printf+0x13a>
6c8: 66 90 xchg %ax,%ax
6ca: 66 90 xchg %ax,%ax
6cc: 66 90 xchg %ax,%ax
6ce: 66 90 xchg %ax,%ax
000006d0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
6d0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6d1: a1 34 0b 00 00 mov 0xb34,%eax
{
6d6: 89 e5 mov %esp,%ebp
6d8: 57 push %edi
6d9: 56 push %esi
6da: 53 push %ebx
6db: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
6de: 8d 4b f8 lea -0x8(%ebx),%ecx
6e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6e8: 39 c8 cmp %ecx,%eax
6ea: 8b 10 mov (%eax),%edx
6ec: 73 32 jae 720 <free+0x50>
6ee: 39 d1 cmp %edx,%ecx
6f0: 72 04 jb 6f6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6f2: 39 d0 cmp %edx,%eax
6f4: 72 32 jb 728 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
6f6: 8b 73 fc mov -0x4(%ebx),%esi
6f9: 8d 3c f1 lea (%ecx,%esi,8),%edi
6fc: 39 fa cmp %edi,%edx
6fe: 74 30 je 730 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
700: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
703: 8b 50 04 mov 0x4(%eax),%edx
706: 8d 34 d0 lea (%eax,%edx,8),%esi
709: 39 f1 cmp %esi,%ecx
70b: 74 3a je 747 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
70d: 89 08 mov %ecx,(%eax)
freep = p;
70f: a3 34 0b 00 00 mov %eax,0xb34
}
714: 5b pop %ebx
715: 5e pop %esi
716: 5f pop %edi
717: 5d pop %ebp
718: c3 ret
719: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
720: 39 d0 cmp %edx,%eax
722: 72 04 jb 728 <free+0x58>
724: 39 d1 cmp %edx,%ecx
726: 72 ce jb 6f6 <free+0x26>
{
728: 89 d0 mov %edx,%eax
72a: eb bc jmp 6e8 <free+0x18>
72c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
730: 03 72 04 add 0x4(%edx),%esi
733: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
736: 8b 10 mov (%eax),%edx
738: 8b 12 mov (%edx),%edx
73a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
73d: 8b 50 04 mov 0x4(%eax),%edx
740: 8d 34 d0 lea (%eax,%edx,8),%esi
743: 39 f1 cmp %esi,%ecx
745: 75 c6 jne 70d <free+0x3d>
p->s.size += bp->s.size;
747: 03 53 fc add -0x4(%ebx),%edx
freep = p;
74a: a3 34 0b 00 00 mov %eax,0xb34
p->s.size += bp->s.size;
74f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
752: 8b 53 f8 mov -0x8(%ebx),%edx
755: 89 10 mov %edx,(%eax)
}
757: 5b pop %ebx
758: 5e pop %esi
759: 5f pop %edi
75a: 5d pop %ebp
75b: c3 ret
75c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000760 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
760: 55 push %ebp
761: 89 e5 mov %esp,%ebp
763: 57 push %edi
764: 56 push %esi
765: 53 push %ebx
766: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
769: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
76c: 8b 15 34 0b 00 00 mov 0xb34,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
772: 8d 78 07 lea 0x7(%eax),%edi
775: c1 ef 03 shr $0x3,%edi
778: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
77b: 85 d2 test %edx,%edx
77d: 0f 84 9d 00 00 00 je 820 <malloc+0xc0>
783: 8b 02 mov (%edx),%eax
785: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
788: 39 cf cmp %ecx,%edi
78a: 76 6c jbe 7f8 <malloc+0x98>
78c: 81 ff 00 10 00 00 cmp $0x1000,%edi
792: bb 00 10 00 00 mov $0x1000,%ebx
797: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
79a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
7a1: eb 0e jmp 7b1 <malloc+0x51>
7a3: 90 nop
7a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7a8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
7aa: 8b 48 04 mov 0x4(%eax),%ecx
7ad: 39 f9 cmp %edi,%ecx
7af: 73 47 jae 7f8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
7b1: 39 05 34 0b 00 00 cmp %eax,0xb34
7b7: 89 c2 mov %eax,%edx
7b9: 75 ed jne 7a8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
7bb: 83 ec 0c sub $0xc,%esp
7be: 56 push %esi
7bf: e8 56 fc ff ff call 41a <sbrk>
if(p == (char*)-1)
7c4: 83 c4 10 add $0x10,%esp
7c7: 83 f8 ff cmp $0xffffffff,%eax
7ca: 74 1c je 7e8 <malloc+0x88>
hp->s.size = nu;
7cc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
7cf: 83 ec 0c sub $0xc,%esp
7d2: 83 c0 08 add $0x8,%eax
7d5: 50 push %eax
7d6: e8 f5 fe ff ff call 6d0 <free>
return freep;
7db: 8b 15 34 0b 00 00 mov 0xb34,%edx
if((p = morecore(nunits)) == 0)
7e1: 83 c4 10 add $0x10,%esp
7e4: 85 d2 test %edx,%edx
7e6: 75 c0 jne 7a8 <malloc+0x48>
return 0;
}
}
7e8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
7eb: 31 c0 xor %eax,%eax
}
7ed: 5b pop %ebx
7ee: 5e pop %esi
7ef: 5f pop %edi
7f0: 5d pop %ebp
7f1: c3 ret
7f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
7f8: 39 cf cmp %ecx,%edi
7fa: 74 54 je 850 <malloc+0xf0>
p->s.size -= nunits;
7fc: 29 f9 sub %edi,%ecx
7fe: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
801: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
804: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
807: 89 15 34 0b 00 00 mov %edx,0xb34
}
80d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
810: 83 c0 08 add $0x8,%eax
}
813: 5b pop %ebx
814: 5e pop %esi
815: 5f pop %edi
816: 5d pop %ebp
817: c3 ret
818: 90 nop
819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
820: c7 05 34 0b 00 00 38 movl $0xb38,0xb34
827: 0b 00 00
82a: c7 05 38 0b 00 00 38 movl $0xb38,0xb38
831: 0b 00 00
base.s.size = 0;
834: b8 38 0b 00 00 mov $0xb38,%eax
839: c7 05 3c 0b 00 00 00 movl $0x0,0xb3c
840: 00 00 00
843: e9 44 ff ff ff jmp 78c <malloc+0x2c>
848: 90 nop
849: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
850: 8b 08 mov (%eax),%ecx
852: 89 0a mov %ecx,(%edx)
854: eb b1 jmp 807 <malloc+0xa7>
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// enum class align_val_t : size_t {}
// UNSUPPORTED: c++98, c++03, c++11, c++14
#include <new>
#include "test_macros.h"
int main() {
{
static_assert(std::is_enum<std::align_val_t>::value, "");
static_assert(std::is_same<std::underlying_type<std::align_val_t>::type, std::size_t>::value, "");
static_assert(!std::is_constructible<std::align_val_t, std::size_t>::value, "");
static_assert(!std::is_constructible<std::size_t, std::align_val_t>::value, "");
}
{
constexpr auto a = std::align_val_t(0);
constexpr auto b = std::align_val_t(32);
constexpr auto c = std::align_val_t(-1);
static_assert(a != b, "");
static_assert(a == std::align_val_t(0), "");
static_assert(b == std::align_val_t(32), "");
static_assert(static_cast<std::size_t>(c) == (std::size_t)-1, "");
}
}
|
; A214992: Power ceiling-floor sequence of (golden ratio)^4.
; Submitted by Christian Krause
; 7,47,323,2213,15169,103969,712615,4884335,33477731,229459781,1572740737,10779725377,73885336903,506417632943,3471038093699,23790849022949,163064905066945,1117663486445665,7660579500052711,52506393013923311,359884171597410467,2466682808167949957,16906895485578239233,115881585590879724673,794264203650579833479,5443967839963179109679,37313510676091673934275,255750606892678538430245,1752940737572658095077441,12014834556115928127111841,82350901155238838794705447,564441473530555943435826287
add $0,1
mul $0,2
mov $1,4
mov $2,1
lpb $0
sub $0,1
add $2,1
add $2,$1
add $1,$2
add $1,1
lpe
div $1,3
mov $0,$1
sub $0,10
div $0,3
mul $0,2
add $0,7
|
; ********************************************************************************************
; ********************************************************************************************
;
; Name : data.asm
; Purpose : ..
; Created : 15th Nov 1991
; Updated : 4th Jan 2021
; Authors : Fred Bowen
;
; ********************************************************************************************
; ********************************************************************************************
data
jsr datan ; skip to end of statement- offset in .y
addon tya
clc
adc txtptr ; add offset to end to txtptr
sta txtptr
bcc remrts
inc txtptr+1
remrts rts ; NEWSTT rts addr is still there
rem jsr remn ; skip rest of statement
bra addon ; will always branch
datan ldx #':' ; DATA terminates on ":" and null
!text $2c
remn ldx #0 ; REM terminates on null only
stx charac ; preserve terminator
ldy #0 ; this makes charac=0 after swap
sty endchr
l43_1 lda endchr
ldx charac
sta charac
stx endchr
l43_2 jsr indtxt
beq remrts ; null always terminates
cmp endchr ; is it some another terminator?
beq remrts ; yes, it's finished
iny ; progress to next character
cmp #'"' ; is it a quote?
bne l43_2 ; no, just continue
beq l43_1 ; yes, time to change
;.end
; ********************************************************************************************
;
; Date Changes
; ==== =======
;
; ********************************************************************************************
|
; A089946: Secondary diagonal of array A089944, in which the n-th row is the n-th binomial transform of the natural numbers.
; Submitted by Jon Maiga
; 1,4,24,200,2160,28812,458752,8503056,180000000,4287177620,113515167744,3308603804376,105288694411264,3632897460937500,135107988821114880,5388090449900829728,229385780960233586688,10383890888434362036516,498073600000000000000000,25235231695868621191582440,1346729042946771357124263936,75510856578721799088651388844,4438067544496026455776746799104,272848410531878471374511718750000,17512857249110028763076565454028800,1171476776336837069415687689488177332,81535087833258119651007986774858268672
mov $2,$0
add $0,2
sub $2,1
pow $0,$2
add $2,2
mul $0,$2
mul $0,2
trn $0,1
add $0,1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.