From 138637d8f367bd066a4ad5f3c592299c5cab35e4 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 11:06:13 -0500 Subject: [PATCH 01/21] move vba tools into vba/ --- vba.py => vba/vba.py | 0 vba_autoplayer.py => vba/vba_autoplayer.py | 0 vba_config.py => vba/vba_config.py | 0 vba_keyboard.py => vba/vba_keyboard.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename vba.py => vba/vba.py (100%) rename vba_autoplayer.py => vba/vba_autoplayer.py (100%) rename vba_config.py => vba/vba_config.py (100%) rename vba_keyboard.py => vba/vba_keyboard.py (100%) diff --git a/vba.py b/vba/vba.py similarity index 100% rename from vba.py rename to vba/vba.py diff --git a/vba_autoplayer.py b/vba/vba_autoplayer.py similarity index 100% rename from vba_autoplayer.py rename to vba/vba_autoplayer.py diff --git a/vba_config.py b/vba/vba_config.py similarity index 100% rename from vba_config.py rename to vba/vba_config.py diff --git a/vba_keyboard.py b/vba/vba_keyboard.py similarity index 100% rename from vba_keyboard.py rename to vba/vba_keyboard.py From 5ce5342833f8170390c0112ed6047243e67465a9 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 22:49:39 -0500 Subject: [PATCH 02/21] require vba_wrapper from pypi --- requirements.txt | 3 +++ setup.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/requirements.txt b/requirements.txt index 2ddc543..ab6f202 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ # testing mock + +# emulation +vba_wrapper==0.0.2 diff --git a/setup.py b/setup.py index b85fc20..f2c277e 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,8 @@ if sys.argv[-1] == 'publish': # dependencies. requires = [ "mock", + "nose", + "vba_wrapper==0.0.2", ] setup( From 72cdd7ba645e02c928fd56def4465e38e4c03709 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 22:52:50 -0500 Subject: [PATCH 03/21] move vba/ -> pokemontools/vba/ --- pokemontools/vba/__init__.py | 7 +++++++ {vba => pokemontools/vba}/vba.py | 0 {vba => pokemontools/vba}/vba_autoplayer.py | 0 {vba => pokemontools/vba}/vba_config.py | 0 {vba => pokemontools/vba}/vba_keyboard.py | 0 5 files changed, 7 insertions(+) create mode 100644 pokemontools/vba/__init__.py rename {vba => pokemontools/vba}/vba.py (100%) rename {vba => pokemontools/vba}/vba_autoplayer.py (100%) rename {vba => pokemontools/vba}/vba_config.py (100%) rename {vba => pokemontools/vba}/vba_keyboard.py (100%) diff --git a/pokemontools/vba/__init__.py b/pokemontools/vba/__init__.py new file mode 100644 index 0000000..ea883a7 --- /dev/null +++ b/pokemontools/vba/__init__.py @@ -0,0 +1,7 @@ +""" +pokecrystal/pokered VBA automation module + +dependencies: + python-vba-wrapper (vba_wrapper) + vba-linux +""" diff --git a/vba/vba.py b/pokemontools/vba/vba.py similarity index 100% rename from vba/vba.py rename to pokemontools/vba/vba.py diff --git a/vba/vba_autoplayer.py b/pokemontools/vba/vba_autoplayer.py similarity index 100% rename from vba/vba_autoplayer.py rename to pokemontools/vba/vba_autoplayer.py diff --git a/vba/vba_config.py b/pokemontools/vba/vba_config.py similarity index 100% rename from vba/vba_config.py rename to pokemontools/vba/vba_config.py diff --git a/vba/vba_keyboard.py b/pokemontools/vba/vba_keyboard.py similarity index 100% rename from vba/vba_keyboard.py rename to pokemontools/vba/vba_keyboard.py From bde8f7670a6f81ab7de98c75745d7d4b74dc2b44 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 22:53:16 -0500 Subject: [PATCH 04/21] vba_tests.py -> test_vba.py This matches the other filenames in the tests/ directory. --- tests/{vba_tests.py => test_vba.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{vba_tests.py => test_vba.py} (100%) diff --git a/tests/vba_tests.py b/tests/test_vba.py similarity index 100% rename from tests/vba_tests.py rename to tests/test_vba.py From 37b9c79b4ce7564fe09a48df61b01d97c55bf18c Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 22:54:39 -0500 Subject: [PATCH 05/21] fix some imports in test_vba.py --- tests/test_vba.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_vba.py b/tests/test_vba.py index a257f20..56a71e3 100644 --- a/tests/test_vba.py +++ b/tests/test_vba.py @@ -4,12 +4,12 @@ Tests for VBA automation tools import unittest -import vba +import pokemontools.vba.vba as vba try: - import vba_autoplayer + import pokemontools.vba.vba_autoplayer except ImportError: - import autoplayer as vba_autoplayer + import pokemontools.vba.autoplayer as vba_autoplayer vba_autoplayer.vba = vba From 0eb5468d220606ad4c2cc93df96faf7a338c958c Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 22:55:25 -0500 Subject: [PATCH 06/21] fix some imports in pokemontools/vba/vba.py This file is meant to be run while under jython, so it's not completely fair to run it through python2.7 when testing. But whatever. --- pokemontools/vba/vba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index ea7bb2e..3e0b7dd 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -87,9 +87,9 @@ from copy import copy import unittest # for converting bytes to readable text -from chars import chars +from pokemontools.chars import chars -from map_names import map_names +from pokemontools.map_names import map_names # for _check_java_library_path from java.lang import System From c6ee12ed1d2b3e937733d3a12205b0b689660957 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 23:03:44 -0500 Subject: [PATCH 07/21] split keyboard graph data from the python file The keyboard.data file has the information necessary to reconstruct the graph of the keyboard that appears in pokecrystal. --- pokemontools/vba/keyboard.data | 501 ++++++++++++++++++++++++++++++ pokemontools/vba/vba_keyboard.py | 504 +------------------------------ 2 files changed, 503 insertions(+), 502 deletions(-) create mode 100644 pokemontools/vba/keyboard.data diff --git a/pokemontools/vba/keyboard.data b/pokemontools/vba/keyboard.data new file mode 100644 index 0000000..2e9a669 --- /dev/null +++ b/pokemontools/vba/keyboard.data @@ -0,0 +1,501 @@ +A a select +A B r +A I l +A lower-upper-column-1 u +A J d + +B b select +B A l +B C r +B lower-upper-column-2 u +B K d + +C c select +C D r +C B l +C lower-upper-column-3 u +C L d + +D d select +D E r +D C l +D del-upper-column-1 u +D M d + +E e select +E del-upper-column-2 u +E N d +E D l +E F r + +F f select +F del-upper-column-3 u +F O d +F E l +F G r + +G g select +G end-upper-column-1 u +G P d +G F l +G H r + +H h select +H end-upper-column-2 u +H Q d +H G l +H I r + +I i select +I end-upper-column-3 u +I R d +I H l +I A r + +J j select +J A u +J S d +J R l +J K r + +K k select +K B u +K T d +K J l +K L r + +L l select +L C u +L U d +L K l +L M r + +M m select +M D u +M V d +M L l +M N r + +N n select +N E u +N W d +N M l +N O r + +O o select +O F u +O X d +O N l +O P r + +P p select +P G u +P Y d +P O l +P Q r + +Q q select +Q H u +Q Z d +Q P l +Q R r + +R r select +R I u +R space-upper-x8-y2 d +R Q l +R J r + +S s select +S J u +S - d +S space-upper-x8-y2 l + +T t select +T K u +T ? d +T S l +T U r + +U u select +U L u +U ! d +U T l +U V r + +V v select +V M u +V / d +V U l +V W r + +W w select +W N u +W . d +W V l +W X r + +X x select +X O u +X , d +X W l +X Y r + +Y y select +Y P u +Y space-upper-x6-y3 d +Y X l +Y Z r + +Z z select +Z Q u +Z space-upper-x7-y3 d +Z Y l +Z space-upper-x8-y2 r + +end-upper-column-1 lower-upper-column-1 r +end-upper-column-2 lower-upper-column-1 r +end-upper-column-3 lower-upper-column-1 r +end-upper-column-1 del-upper-column-1 l +end-upper-column-2 del-upper-column-1 l +end-upper-column-3 del-upper-column-1 l +lower-upper-column-1 end-upper-column-1 l +lower-upper-column-2 end-upper-column-1 l +lower-upper-column-3 end-upper-column-1 l +lower-upper-column-1 del-upper-column-1 r +lower-upper-column-2 del-upper-column-1 r +lower-upper-column-3 del-upper-column-1 r +del-upper-column-1 lower-upper-column-1 l +del-upper-column-2 lower-upper-column-1 l +del-upper-column-3 lower-upper-column-1 l +del-upper-column-1 end-upper-column-1 r +del-upper-column-2 end-upper-column-1 r +del-upper-column-3 end-upper-column-1 r + +lower-upper-column-1 A d +lower-upper-column-2 B d +lower-upper-column-3 C d +lower-upper-column-1 - u +lower-upper-column-2 ? u +lower-upper-column-3 ! u + +del-upper-column-1 D d +del-upper-column-2 E d +del-upper-column-3 F d +del-upper-column-1 / u +del-upper-column-2 . u +del-upper-column-3 , u + +end-upper-column-1 G d +end-upper-column-2 H d +end-upper-column-3 I d +end-upper-column-1 space-upper-x6-y3 u +end-upper-column-2 space-upper-x7-y3 u +end-upper-column-3 space-upper-x8-y3 u + +space-upper-x8-y2 space-lower-x8-y2 select +space-upper-x8-y2 R u +space-upper-x8-y2 space-upper-x8-y3 d +space-upper-x8-y2 Z l +space-upper-x8-y2 S r + +space-upper-x8-y3 MN select +space-upper-x8-y3 space-upper-x8-y2 u +space-upper-x8-y3 end-upper-column-3 d +space-upper-x8-y3 space-upper-x7-y3 l +space-upper-x8-y3 - r + +space-upper-x7-y3 PK select +space-upper-x7-y3 Z u +space-upper-x7-y3 end-upper-column-2 d +space-upper-x7-y3 space-upper-x6-y3 l +space-upper-x7-y3 space-upper-x8-y3 r + +space-upper-x6-y3 ] select +space-upper-x6-y3 Y u +space-upper-x6-y3 end-upper-column-1 d +space-upper-x6-y3 , l +space-upper-x6-y3 space-upper-x7-y3 r + +end-upper-column-1 end-lower-column-1 select +end-upper-column-2 end-lower-column-2 select +end-upper-column-3 end-lower-column-3 select +lower-upper-column-1 lower-lower-column-1 select +lower-upper-column-2 lower-lower-column-2 select +lower-upper-column-3 lower-lower-column-3 select +del-upper-column-1 del-lower-column-1 select +del-upper-column-2 del-lower-column-2 select +del-upper-column-3 del-lower-column-3 select + +lower-lower-column-1 × u +lower-lower-column-2 ( u +lower-lower-column-3 ) u +lower-lower-column-1 a d +lower-lower-column-2 b d +lower-lower-column-3 c d + +end-lower-column-1 ] u +end-lower-column-2 PK u +end-lower-column-3 MN u +end-lower-column-1 g d +end-lower-column-2 h d +end-lower-column-3 i d + +del-lower-column-1 : u +del-lower-column-2 ; u +del-lower-column-3 [ u +del-lower-column-1 d d +del-lower-column-2 e d +del-lower-column-3 f d + +- × select +- S u +- lower-upper-column-1 d +- space-upper-x8-y3 l +- ? r + +? ( select +? T u +? lower-upper-column-2 d +? - l +? ! r + +! ) select +! U u +! lower-upper-column-3 d +! ? l +! / r + +/ : select +/ V u +/ del-upper-column-1 d +/ ! l +/ . r + +. ; select +. W u +. del-upper-column-2 d +. / l +. , r + +, [ select +, X u +, del-upper-column-3 d +, . l +, space-upper-x6-y3 r + +× - select +× s u +× upper-lower-column-1 d +× MN l +× ( r + +( ? select +( t u +( upper-lower-column-2 d +( × l +( ) r + +) ! select +) u u +) upper-lower-column-3 d +) ( l +) : r + +: / select +: v u +: del-lower-column-1 d +: ) l +: ; r + +; . select +; w u +; del-lower-column-2 d +; : l +; [ r + +[ , select +[ x u +[ del-lower-column-3 d +[ ; l +[ ] r + +] space-upper-x6-y3 select +] y u +] end-lower-column-1 d +] [ l +] PK r + +PK space-upper-x7-y3 select +PK z u +PK end-lower-column-2 d +PK ] l +PK MN r + +MN space-upper-x8-y3 select +MN space-lower-x8-y2 u +MN end-lower-column-3 d +MN PK l +MN × r + +space-lower-x8-y2 space-upper-x8-y2 select +space-lower-x8-y2 r u +space-lower-x8-y2 MN d +space-lower-x8-y2 z l +space-lower-x8-y2 s r + +a A select +a upper-lower-column-1 u +a j d +a i l +a b r + +b B select +b upper-lower-column-2 u +b k d +b a l +b c r + +c C select +c upper-lower-column-3 u +c l d +c b l +c d r + +d D select +d del-lower-column-1 u +d m d +d c l +d e r + +e E select +e del-lower-column-2 u +e n d +e d l +e f r + +f F select +f del-lower-column-3 u +f o d +f e l +f g r + +g G select +g end-lower-column-1 u +g p d +g f l +g h r + +h H select +h end-lower-column-2 u +h q d +h g l +h i r + +i I select +i end-lower-column-3 u +i r d +i h l +i a r + +j J select +j a u +j s d +j r l +j k r + +k K select +k b u +k t d +k j l +k l r + +l L select +l c u +l u d +l k l +l m r + +m M select +m d u +m v d +m l l +m n r + +n N select +n e u +n w d +n m l +n o r + +o O select +o f u +o x d +o n l +o p r + +p P select +p g u +p y d +p o l +p q r + +q Q select +q h u +q z d +q p l +q r r + +r R select +r i u +r space-lower-x8-y2 d +r q l +r j r + +s S select +s j u +s × d +s space-lower-x8-y2 l +s t r + +t T select +t k u +t ( d +t s l +t u r + +u U select +u l u +u ) d +u t l +u v r + +v V select +v m u +v : d +v u l +v w r + +w W select +w n u +w ; d +w v l +w x r + +x X select +x o u +x [ d +x w l +x y r + +y Y select +y p u +y ] d +y x l +y z r + +z Z select +z q u +z PK d +z y l +z space-lower-x8-y2 r diff --git a/pokemontools/vba/vba_keyboard.py b/pokemontools/vba/vba_keyboard.py index 7d57953..c83da65 100644 --- a/pokemontools/vba/vba_keyboard.py +++ b/pokemontools/vba/vba_keyboard.py @@ -9,508 +9,8 @@ import networkx graph = networkx.DiGraph() -graph_data = """ -A a select -A B r -A I l -A lower-upper-column-1 u -A J d - -B b select -B A l -B C r -B lower-upper-column-2 u -B K d - -C c select -C D r -C B l -C lower-upper-column-3 u -C L d - -D d select -D E r -D C l -D del-upper-column-1 u -D M d - -E e select -E del-upper-column-2 u -E N d -E D l -E F r - -F f select -F del-upper-column-3 u -F O d -F E l -F G r - -G g select -G end-upper-column-1 u -G P d -G F l -G H r - -H h select -H end-upper-column-2 u -H Q d -H G l -H I r - -I i select -I end-upper-column-3 u -I R d -I H l -I A r - -J j select -J A u -J S d -J R l -J K r - -K k select -K B u -K T d -K J l -K L r - -L l select -L C u -L U d -L K l -L M r - -M m select -M D u -M V d -M L l -M N r - -N n select -N E u -N W d -N M l -N O r - -O o select -O F u -O X d -O N l -O P r - -P p select -P G u -P Y d -P O l -P Q r - -Q q select -Q H u -Q Z d -Q P l -Q R r - -R r select -R I u -R space-upper-x8-y2 d -R Q l -R J r - -S s select -S J u -S - d -S space-upper-x8-y2 l - -T t select -T K u -T ? d -T S l -T U r - -U u select -U L u -U ! d -U T l -U V r - -V v select -V M u -V / d -V U l -V W r - -W w select -W N u -W . d -W V l -W X r - -X x select -X O u -X , d -X W l -X Y r - -Y y select -Y P u -Y space-upper-x6-y3 d -Y X l -Y Z r - -Z z select -Z Q u -Z space-upper-x7-y3 d -Z Y l -Z space-upper-x8-y2 r - -end-upper-column-1 lower-upper-column-1 r -end-upper-column-2 lower-upper-column-1 r -end-upper-column-3 lower-upper-column-1 r -end-upper-column-1 del-upper-column-1 l -end-upper-column-2 del-upper-column-1 l -end-upper-column-3 del-upper-column-1 l -lower-upper-column-1 end-upper-column-1 l -lower-upper-column-2 end-upper-column-1 l -lower-upper-column-3 end-upper-column-1 l -lower-upper-column-1 del-upper-column-1 r -lower-upper-column-2 del-upper-column-1 r -lower-upper-column-3 del-upper-column-1 r -del-upper-column-1 lower-upper-column-1 l -del-upper-column-2 lower-upper-column-1 l -del-upper-column-3 lower-upper-column-1 l -del-upper-column-1 end-upper-column-1 r -del-upper-column-2 end-upper-column-1 r -del-upper-column-3 end-upper-column-1 r - -lower-upper-column-1 A d -lower-upper-column-2 B d -lower-upper-column-3 C d -lower-upper-column-1 - u -lower-upper-column-2 ? u -lower-upper-column-3 ! u - -del-upper-column-1 D d -del-upper-column-2 E d -del-upper-column-3 F d -del-upper-column-1 / u -del-upper-column-2 . u -del-upper-column-3 , u - -end-upper-column-1 G d -end-upper-column-2 H d -end-upper-column-3 I d -end-upper-column-1 space-upper-x6-y3 u -end-upper-column-2 space-upper-x7-y3 u -end-upper-column-3 space-upper-x8-y3 u - -space-upper-x8-y2 space-lower-x8-y2 select -space-upper-x8-y2 R u -space-upper-x8-y2 space-upper-x8-y3 d -space-upper-x8-y2 Z l -space-upper-x8-y2 S r - -space-upper-x8-y3 MN select -space-upper-x8-y3 space-upper-x8-y2 u -space-upper-x8-y3 end-upper-column-3 d -space-upper-x8-y3 space-upper-x7-y3 l -space-upper-x8-y3 - r - -space-upper-x7-y3 PK select -space-upper-x7-y3 Z u -space-upper-x7-y3 end-upper-column-2 d -space-upper-x7-y3 space-upper-x6-y3 l -space-upper-x7-y3 space-upper-x8-y3 r - -space-upper-x6-y3 ] select -space-upper-x6-y3 Y u -space-upper-x6-y3 end-upper-column-1 d -space-upper-x6-y3 , l -space-upper-x6-y3 space-upper-x7-y3 r - -end-upper-column-1 end-lower-column-1 select -end-upper-column-2 end-lower-column-2 select -end-upper-column-3 end-lower-column-3 select -lower-upper-column-1 lower-lower-column-1 select -lower-upper-column-2 lower-lower-column-2 select -lower-upper-column-3 lower-lower-column-3 select -del-upper-column-1 del-lower-column-1 select -del-upper-column-2 del-lower-column-2 select -del-upper-column-3 del-lower-column-3 select - -lower-lower-column-1 × u -lower-lower-column-2 ( u -lower-lower-column-3 ) u -lower-lower-column-1 a d -lower-lower-column-2 b d -lower-lower-column-3 c d - -end-lower-column-1 ] u -end-lower-column-2 PK u -end-lower-column-3 MN u -end-lower-column-1 g d -end-lower-column-2 h d -end-lower-column-3 i d - -del-lower-column-1 : u -del-lower-column-2 ; u -del-lower-column-3 [ u -del-lower-column-1 d d -del-lower-column-2 e d -del-lower-column-3 f d - -- × select -- S u -- lower-upper-column-1 d -- space-upper-x8-y3 l -- ? r - -? ( select -? T u -? lower-upper-column-2 d -? - l -? ! r - -! ) select -! U u -! lower-upper-column-3 d -! ? l -! / r - -/ : select -/ V u -/ del-upper-column-1 d -/ ! l -/ . r - -. ; select -. W u -. del-upper-column-2 d -. / l -. , r - -, [ select -, X u -, del-upper-column-3 d -, . l -, space-upper-x6-y3 r - -× - select -× s u -× upper-lower-column-1 d -× MN l -× ( r - -( ? select -( t u -( upper-lower-column-2 d -( × l -( ) r - -) ! select -) u u -) upper-lower-column-3 d -) ( l -) : r - -: / select -: v u -: del-lower-column-1 d -: ) l -: ; r - -; . select -; w u -; del-lower-column-2 d -; : l -; [ r - -[ , select -[ x u -[ del-lower-column-3 d -[ ; l -[ ] r - -] space-upper-x6-y3 select -] y u -] end-lower-column-1 d -] [ l -] PK r - -PK space-upper-x7-y3 select -PK z u -PK end-lower-column-2 d -PK ] l -PK MN r - -MN space-upper-x8-y3 select -MN space-lower-x8-y2 u -MN end-lower-column-3 d -MN PK l -MN × r - -space-lower-x8-y2 space-upper-x8-y2 select -space-lower-x8-y2 r u -space-lower-x8-y2 MN d -space-lower-x8-y2 z l -space-lower-x8-y2 s r - -a A select -a upper-lower-column-1 u -a j d -a i l -a b r - -b B select -b upper-lower-column-2 u -b k d -b a l -b c r - -c C select -c upper-lower-column-3 u -c l d -c b l -c d r - -d D select -d del-lower-column-1 u -d m d -d c l -d e r - -e E select -e del-lower-column-2 u -e n d -e d l -e f r - -f F select -f del-lower-column-3 u -f o d -f e l -f g r - -g G select -g end-lower-column-1 u -g p d -g f l -g h r - -h H select -h end-lower-column-2 u -h q d -h g l -h i r - -i I select -i end-lower-column-3 u -i r d -i h l -i a r - -j J select -j a u -j s d -j r l -j k r - -k K select -k b u -k t d -k j l -k l r - -l L select -l c u -l u d -l k l -l m r - -m M select -m d u -m v d -m l l -m n r - -n N select -n e u -n w d -n m l -n o r - -o O select -o f u -o x d -o n l -o p r - -p P select -p g u -p y d -p o l -p q r - -q Q select -q h u -q z d -q p l -q r r - -r R select -r i u -r space-lower-x8-y2 d -r q l -r j r - -s S select -s j u -s × d -s space-lower-x8-y2 l -s t r - -t T select -t k u -t ( d -t s l -t u r - -u U select -u l u -u ) d -u t l -u v r - -v V select -v m u -v : d -v u l -v w r - -w W select -w n u -w ; d -w v l -w x r - -x X select -x o u -x [ d -x w l -x y r - -y Y select -y p u -y ] d -y x l -y z r - -z Z select -z q u -z PK d -z y l -z space-lower-x8-y2 r""" +# load graph data from file +graph_data = open("keyboard.data", "r").read() for line in graph_data.split("\n"): if line == "": From e593f680c2fc7356c3afebe9c1a5cd8490274406 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 8 Sep 2013 23:05:19 -0500 Subject: [PATCH 08/21] encoding -> coding in header --- pokemontools/vba/vba_keyboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemontools/vba/vba_keyboard.py b/pokemontools/vba/vba_keyboard.py index c83da65..65d481d 100644 --- a/pokemontools/vba/vba_keyboard.py +++ b/pokemontools/vba/vba_keyboard.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- """ This file constructs a networkx.DiGraph object called graph, which can be used to find the shortest path of keypresses on the keyboard to type a word. From 815266f03fb5de060939a271136caf520921654c Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:11:54 -0500 Subject: [PATCH 09/21] fix path in vba_keyboard.py --- pokemontools/vba/vba_keyboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pokemontools/vba/vba_keyboard.py b/pokemontools/vba/vba_keyboard.py index 65d481d..f25fd06 100644 --- a/pokemontools/vba/vba_keyboard.py +++ b/pokemontools/vba/vba_keyboard.py @@ -10,7 +10,8 @@ import networkx graph = networkx.DiGraph() # load graph data from file -graph_data = open("keyboard.data", "r").read() +data_path = os.path.join(os.path.abspath(__file__), "keyboard.data") +graph_data = open(data_path, "r").read() for line in graph_data.split("\n"): if line == "": From 5d41f8a91dc47e41f45ecaeec4ad1640196be37e Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:12:34 -0500 Subject: [PATCH 10/21] move vba_keyboard.py -> keyboard.py --- pokemontools/vba/{vba_keyboard.py => keyboard.py} | 0 pokemontools/vba/vba.py | 5 +---- 2 files changed, 1 insertion(+), 4 deletions(-) rename pokemontools/vba/{vba_keyboard.py => keyboard.py} (100%) diff --git a/pokemontools/vba/vba_keyboard.py b/pokemontools/vba/keyboard.py similarity index 100% rename from pokemontools/vba/vba_keyboard.py rename to pokemontools/vba/keyboard.py diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 3e0b7dd..b7c3768 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -109,10 +109,7 @@ Gb.loadVBA() from vba_config import * -try: - import vba_keyboard as keyboard -except ImportError: - print "Not loading the keyboard module (which uses networkx)." +import keyboard if not os.path.exists(rom_path): raise Exception("rom_path is not configured properly; edit vba_config.py? " + str(rom_path)) From 8b307f116a568831f708740661924932a7bb1bd6 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:17:40 -0500 Subject: [PATCH 11/21] remove jython shebangs --- pokemontools/vba/vba.py | 1 - pokemontools/vba/vba_config.py | 1 - 2 files changed, 2 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index b7c3768..b242536 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -1,4 +1,3 @@ -#!/usr/bin/jython # -*- encoding: utf-8 -*- """ vba-clojure (but really it's jython/python/jvm) diff --git a/pokemontools/vba/vba_config.py b/pokemontools/vba/vba_config.py index 4433f16..a59e625 100644 --- a/pokemontools/vba/vba_config.py +++ b/pokemontools/vba/vba_config.py @@ -1,4 +1,3 @@ -#!/usr/bin/jython # -*- encoding: utf-8 -*- import os From fab1b4ce20a2d71ad8c53376938a27bbc7efc8c9 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:18:27 -0500 Subject: [PATCH 12/21] encoding -> coding in python headers --- pokemontools/vba/vba.py | 2 +- pokemontools/vba/vba_config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index b242536..b715ca8 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- """ vba-clojure (but really it's jython/python/jvm) diff --git a/pokemontools/vba/vba_config.py b/pokemontools/vba/vba_config.py index a59e625..3eb5983 100644 --- a/pokemontools/vba/vba_config.py +++ b/pokemontools/vba/vba_config.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- import os # by default we assume the user has vba in pokecrystal/extras From 55af0392e132f874921efe362251455df701d81b Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:20:37 -0500 Subject: [PATCH 13/21] remove vba_config and just use pokemontools.config --- pokemontools/vba/vba.py | 9 +++++++-- pokemontools/vba/vba_config.py | 11 ----------- 2 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 pokemontools/vba/vba_config.py diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index b715ca8..76df8ce 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -106,10 +106,15 @@ import com.aurellem.gb.Gb as Gb # load the vba-clojure library Gb.loadVBA() -from vba_config import * - import keyboard +# just use a default config for now until the globals are removed completely +import pokemontools.config as conf +config = conf.Config() +project_path = config.path +save_state_path = config.save_state_path +rom_path = config.rom_path + if not os.path.exists(rom_path): raise Exception("rom_path is not configured properly; edit vba_config.py? " + str(rom_path)) diff --git a/pokemontools/vba/vba_config.py b/pokemontools/vba/vba_config.py deleted file mode 100644 index 3eb5983..0000000 --- a/pokemontools/vba/vba_config.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -import os - -# by default we assume the user has vba in pokecrystal/extras -project_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..')) - -# save states are in pokecrystal/save-states/ -save_state_path = os.path.join(project_path, "save-states") - -# where is your rom? -rom_path = os.path.join(project_path, "baserom.gbc") From fa966f7a3ff7daafeb78a71adc795aa7bcccb992 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:21:54 -0500 Subject: [PATCH 14/21] remove some TODOs --- pokemontools/vba/vba.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 76df8ce..e2d1168 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -66,15 +66,6 @@ Usage (in jython, not python): vba.get_memory_at(0xDCDA) vba.set_memory_at(0xDCDB, 0xFF) vba.get_memory_range(0xDCDA, 10) - -TOOD: - [ ] set a specific register - [ ] get a specific register - [ ] breakpoints - [ ] vgm stuff - [ ] gbz80disasm integration - [ ] pokecrystal.extras integration - """ import os From e88a4767e97796c2b78fda3ecd2c43b187aac059 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 00:27:26 -0500 Subject: [PATCH 15/21] some config defaults taken from vba stuff --- pokemontools/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pokemontools/config.py b/pokemontools/config.py index 656fab0..cbf230c 100644 --- a/pokemontools/config.py +++ b/pokemontools/config.py @@ -31,6 +31,14 @@ class Config(object): if "path" not in self._config: self._config["path"] = os.getcwd() + # vba save states go into ./save-states/ + if "save_state_path" not in self._config: + self._config["save_state_path"] = os.path.join(self._config["path"], "save-states/") + + # assume rom is at ./baserom.gbc + if "rom" not in self._config: + self._config["rom_path"] = os.path.join(self._config["path"], "baserom.gbc") + def __getattr__(self, key): """ Grab the value from the class properties, then check the configuration, From cdf1b82fad704ca31ffc607b8954aef94d207317 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 01:59:58 -0500 Subject: [PATCH 16/21] keyboard needs os --- pokemontools/vba/keyboard.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pokemontools/vba/keyboard.py b/pokemontools/vba/keyboard.py index f25fd06..b954800 100644 --- a/pokemontools/vba/keyboard.py +++ b/pokemontools/vba/keyboard.py @@ -4,6 +4,7 @@ This file constructs a networkx.DiGraph object called graph, which can be used to find the shortest path of keypresses on the keyboard to type a word. """ +import os import itertools import networkx From 709850fff5ee7c8f6bff61a2b0f3b23d4954dcac Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 02:02:45 -0500 Subject: [PATCH 17/21] fix keyboard.data path in keyboard.py --- pokemontools/vba/keyboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemontools/vba/keyboard.py b/pokemontools/vba/keyboard.py index b954800..4a07e57 100644 --- a/pokemontools/vba/keyboard.py +++ b/pokemontools/vba/keyboard.py @@ -11,7 +11,7 @@ import networkx graph = networkx.DiGraph() # load graph data from file -data_path = os.path.join(os.path.abspath(__file__), "keyboard.data") +data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "keyboard.data") graph_data = open(data_path, "r").read() for line in graph_data.split("\n"): From 54057bc762b955a4c8924fa951ebf2faadca16a9 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 02:04:47 -0500 Subject: [PATCH 18/21] strip out jython garbage from vba.py --- pokemontools/vba/vba.py | 609 +--------------------------------------- 1 file changed, 8 insertions(+), 601 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index e2d1168..00bde25 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -1,79 +1,14 @@ # -*- coding: utf-8 -*- """ -vba-clojure (but really it's jython/python/jvm) - -This is jython, not python. Use jython to run this file. Before running this -file, some of the dependencies need to be constructed. These can be obtained -from the vba-clojure project. - sudo apt-get install g++ libtool openjdk-6-jre openjdk-6-jdk libsdl1.2-dev mercurial ant autoconf jython - - export JAVA_INCLUDE_PATH=/usr/lib/jvm/java-6-openjdk-amd64/include/ - export JAVA_INCLUDE_PATH2=/usr/lib/jvm/java-6-openjdk-amd64/include/ - - hg clone http://hg.bortreb.com/vba-clojure - cd vba-clojure/ - ./dl-libs.sh - cd java/ - ant all - cd .. - autoreconf -i - ./configure - make - sudo make install - -Make sure vba-clojure bindings are in $CLASSPATH: - export CLASSPATH=$CLASSPATH:java/dist/gb-bindings.jar - -Make sure vba-clojure is available within "java.library.path": - sudo ln -s \ - $HOME/local/vba-clojure/vba-clojure/src/clojure/.libs/libvba.so.0.0.0 \ - /usr/lib/jni/libvba.so - -(In the above command, substitute the first path with the path of the vba-clojure -directory you made, if it is different.) - -Also make sure VisualBoyAdvance.cfg is somewhere in the $PATH for VBA to find. -A default configuration is provided in vba-clojure under src/. - -Usage (in jython, not python): - import vba - - # activate the laser beam - vba.load_rom("/path/to/baserom.gbc") - - # make the emulator eat some instructions - vba.nstep(300) - - # save the state because we're paranoid - copyrights = vba.get_state() - # or ... - vba.save_state("copyrights") - # >>> vba.load_state("copyrights") == copyrights - # True - - # play for a while, then press F12 - vba.run() - - # let's save the game again - vba.save_state("unknown-delete-me") - - # and let's go back to the other state - vba.set_state(copyrights) - - # or why not the other way around? - vba.set_state(vba.load_state("unknown-delete-me")) - - vba.get_memory_at(0xDCDA) - vba.set_memory_at(0xDCDB, 0xFF) - vba.get_memory_range(0xDCDA, 10) +VBA automation """ import os import sys import re -from array import array import string from copy import copy + import unittest # for converting bytes to readable text @@ -81,22 +16,6 @@ from pokemontools.chars import chars from pokemontools.map_names import map_names -# for _check_java_library_path -from java.lang import System - -# for passing states to the emulator -from java.nio import ByteBuffer - -# For getRegisters and other times we have to pass a java int array to a -# function. -import jarray - -# load in the vba-clojure bindings -import com.aurellem.gb.Gb as Gb - -# load the vba-clojure library -Gb.loadVBA() - import keyboard # just use a default config for now until the globals are removed completely @@ -109,131 +28,13 @@ rom_path = config.rom_path if not os.path.exists(rom_path): raise Exception("rom_path is not configured properly; edit vba_config.py? " + str(rom_path)) -def _check_java_library_path(): - """ - Returns the value of java.library.path. +import vba_wrapper - The vba-clojure library must be compiled - and linked from this location. - """ - return System.getProperty("java.library.path") +vba = vba_wrapper.VBA(rom_path) +registers = vba_wrapper.core.registers.Registers(vba) -class RomList(list): - - """ - Simple wrapper to prevent a giant rom from being shown on screen. - """ - - def __init__(self, *args, **kwargs): - list.__init__(self, *args, **kwargs) - - def __repr__(self): - """ - Simplifies this object so that the output doesn't overflow stdout. - """ - return "RomList(too long)" - -button_masks = { - "a": 0x0001, - "b": 0x0002, - "r": 0x0010, - "l": 0x0020, - "u": 0x0040, - "d": 0x0080, - "select": 0x0004, - "start": 0x0008, - "restart": 0x0800, - "listen": -1, # what? -} - -# useful for directly stating what to press -a, b, r, l, u, d, select, start, restart = "a", "b", "r", "l", "u", "d", "select", "start", "restart" - -def button_combiner(buttons): - """ - Combines multiple button presses into an integer. - - This is used when sending a keypress to the emulator. - """ - result = 0 - - # String inputs need to be cleaned up so that "start" doesn't get - # recognized as "s" and "t" etc.. - if isinstance(buttons, str): - if "restart" in buttons: - buttons = buttons.replace("restart", "") - result |= button_masks["restart"] - if "start" in buttons: - buttons = buttons.replace("start", "") - result |= button_masks["start"] - if "select" in buttons: - buttons = buttons.replace("select", "") - result |= button_masks["select"] - - # allow for the "a, b" and "a b" formats - if ", " in buttons: - buttons = buttons.split(", ") - elif " " in buttons: - buttons = buttons.split(" ") - - if isinstance(buttons, list): - if len(buttons) > 9: - raise Exception("can't combine more than 9 buttons at a time") - - for each in buttons: - result |= button_masks[each] - - #print "button: " + str(result) - return result - -def load_rom(path=None): - """ - Starts the emulator with a certain ROM. - - Defaults to rom_path if no parameters are given. - """ - if path == None: - path = rom_path - try: - root = load_state("root") - except: - # "root.sav" is required because if you create it in the future, you - # will have to shutdown the emulator and possibly lose your state. Some - # functions require there to be at least one root state available to do - # computations between two states. - sys.stderr.write("ERROR: unable to read \"root.sav\", please run" - " generate_root() or get_root() to make an initial save.\n") - Gb.startEmulator(path) - -def shutdown(): - """ - Stops the emulator. Closes the window. - - The "opposite" of this is the load_rom function. - """ - Gb.shutdown() - -def step(): - """ - Advances the emulator forward by one step. - """ - Gb.step() - -def nstep(steplimit): - """ - Step the game forward by a certain number of instructions. - """ - for counter in range(0, steplimit): - Gb.step() - -def step_until_capture(): - """ - Loop step() until SDLK_F12 is detected. - """ - Gb.stepUntilCapture() - -# just some aliases for step_until_capture -run = go = step_until_capture +button_masks = vba_wrapper.core.VBA.button_masks +button_combiner = vba_wrapper.core.VBA.button_combine def translate_chars(charz): result = "" @@ -241,217 +42,6 @@ def translate_chars(charz): result += chars[each] return result -def _create_byte_buffer(data): - """ - Converts data into a ByteBuffer. - - This is useful for interfacing with the Gb class. - """ - buf = ByteBuffer.allocateDirect(len(data)) - if isinstance(data[0], int): - for byte in data: - buf.put(byte) - else: - for byte in data: - buf.put(ord(byte)) - return buf - -def set_state(state, do_step=False): - """ - Injects the given state into the emulator. - - Use do_step if you want to call step(), which also allows - SDL to render the latest frame. Note that the default is to - not step, and that the screen (if it is enabled) will appear - as if it still has the last state loaded. This is normal. - """ - Gb.loadState(_create_byte_buffer(state)) - if do_step: - step() - -def get_state(): - """ - Retrieves the current state of the emulator. - """ - buf = Gb.saveState() - state = [buf.get(x) for x in range(0, buf.capacity())] - arr = array("b") - arr.extend(state) - return arr.tostring() # instead of state - -def save_state(name, state=None, override=False): - """ - Saves the given state to save_state_path. - - The file format must be ".sav" - (and this will be appended to your string if necessary). - """ - if state == None: - state = get_state() - if len(name) < 4 or name[-4:] != ".sav": - name += ".sav" - save_path = os.path.join(save_state_path, name) - if not override and os.path.exists(save_path): - raise Exception("oops, save state path already exists: " + str(save_path)) - else: - # convert the state into a reasonable output - data = array('b') - data.extend(state) - output = data.tostring() - - file_handler = open(save_path, "wb") - file_handler.write(output) - file_handler.close() - -def load_state(name): - """ - Reads a state from file based on name. - - Looks in save_state_path for a file - with this name (".sav" is optional). - """ - save_path = os.path.join(save_state_path, name) - if not os.path.exists(save_path): - if len(name) < 4 or name[-4:] != ".sav": - name += ".sav" - save_path = os.path.join(save_state_path, name) - file_handler = open(save_path, "rb") - state = file_handler.read() - file_handler.close() - return state - -def generate_root(): - """ - Restarts the emulator and saves the initial state to "root.sav". - """ - shutdown() - load_rom() - root = get_state() - save_state("root", state=root, override=True) - return root - -def get_root(): - """ - Loads the root state. - - (Or restarts the emulator and creates a new root state.) - """ - try: - root = load_state("root") - except: - root = generate_root() - -def get_registers(): - """ - Returns a list of current register values. - """ - register_array = jarray.zeros(Gb.NUM_REGISTERS, "i") - Gb.getRegisters(register_array) - return list(register_array) - -def set_registers(registers): - """ - Applies the set of registers to the CPU. - """ - Gb.writeRegisters(registers) -write_registers = set_registers - -def get_rom(): - """ - Returns the ROM in bytes. - """ - rom_array = jarray.zeros(Gb.ROM_SIZE, "i") - Gb.getROM(rom_array) - return RomList(rom_array) - -def get_ram(): - """ - Returns the RAM in bytes. - """ - ram_array = jarray.zeros(Gb.RAM_SIZE, "i") - Gb.getRAM(ram_array) - return RomList(ram_array) - -def say_hello(): - """ - Test that the VBA/GB bindings are working. - """ - Gb.sayHello() - -def get_memory(): - """ - Returns memory in bytes. - """ - memory_size = 0x10000 - memory = jarray.zeros(memory_size, "i") - Gb.getMemory(memory) - return RomList(memory) - -def set_memory(memory): - """ - Sets memory in the emulator. - - Use get_memory() to retrieve the current state. - """ - Gb.writeMemory(memory) - -def get_pixels(): - """ - Returns a list of pixels on the screen display. - - Broken, probably. Use screenshot() instead. - """ - sys.stderr.write("ERROR: seems to be broken on VBA's end? Good luck. Use" - " screenshot() instead.\n") - size = Gb.DISPLAY_WIDTH * Gb.DISPLAY_HEIGHT - pixels = jarray.zeros(size, "i") - Gb.getPixels(pixels) - return RomList(pixels) - -def screenshot(filename, literal=False): - """ - Saves a PNG screenshot to the file at filename. - - Use literal if you want to store it in the current directory. - Default is to save it to screenshots/ under the project. - """ - screenshots_path = os.path.join(project_path, "screenshots/") - filename = os.path.join(screenshots_path, filename) - if len(filename) < 4 or filename[-4:] != ".png": - filename += ".png" - Gb.nwritePNG(filename) - print "Screenshot saved to: " + str(filename) -save_png = screenshot - -def read_memory(address): - """ - Read an integer at an address. - """ - return Gb.readMemory(address) -get_memory_at = read_memory - -def get_memory_range(start_address, byte_count): - """ - Returns a list of bytes. - - start_address - address to start reading at - byte_count - how many bytes (0 returns just 1 byte) - """ - bytez = [] - for counter in range(0, byte_count): - byte = get_memory_at(start_address + counter) - bytez.append(byte) - return bytez - -def set_memory_at(address, value): - """ - Sets a byte at a certain address in memory. - - This directly sets the memory instead of copying - the memory from the emulator. - """ - Gb.setMemoryAt(address, value) - def press(buttons, holdsteps=1, aftersteps=1): """ Press a button. @@ -473,18 +63,6 @@ def press(buttons, holdsteps=1, aftersteps=1): for step_counter in range(0, aftersteps): Gb.step(0) -def get_buttons(): - """ - Returns the currentButtons[0] value - - (an integer with bits set for which - buttons are currently pressed). - """ - return Gb.getCurrentButtons() - -class State(RomList): - name = None - class Recording: def __init__(self): self.frames = [] @@ -499,7 +77,7 @@ class Recording: """ Saves the current state. """ - state = State(get_state()) + state = bytearray(get_state()) state.name = name self.states[self.frame_count] = state @@ -538,104 +116,6 @@ class Recording: frame_id = self.states.index(thing) self.step(first_frame=frame_id, replay=True) -class Registers: - order = [ - "pc", - "sp", - "af", - "bc", - "de", - "hl", - "iff", - "div", - "tima", - "tma", - "tac", - "if", - "lcdc", - "stat", - "scy", - "scx", - "ly", - "lyc", - "dma", - "wy", - "wx", - "vbk", - "hdma1", - "hdma2", - "hdma3", - "hdma4", - "hdma5", - "svbk", - "ie", - ] - - def __setitem__(self, key, value): - current_registers = get_registers() - current_registers[Registers.order.index(key)] = value - set_registers(current_registers) - - def __getitem__(self, key): - current_registers = get_registers() - return current_registers[Registers.order.index(key)] - - def __list__(self): - return get_registers() - - def _get_register(id): - def constructed_func(self, id=copy(id)): - return get_registers()[id] - return constructed_func - - def _set_register(id): - def constructed_func(self, value, id=copy(id)): - current_registers = get_registers() - current_registers[id] = value - set_registers(current_registers) - return constructed_func - - pc = property(fget=_get_register(0), fset=_set_register(0)) - sp = property(fget=_get_register(1), fset=_set_register(1)) - af = property(fget=_get_register(2), fset=_set_register(2)) - bc = property(fget=_get_register(3), fset=_set_register(3)) - de = property(fget=_get_register(4), fset=_set_register(4)) - hl = property(fget=_get_register(5), fset=_set_register(5)) - iff = property(fget=_get_register(6), fset=_set_register(6)) - div = property(fget=_get_register(7), fset=_set_register(7)) - tima = property(fget=_get_register(8), fset=_set_register(8)) - tma = property(fget=_get_register(9), fset=_set_register(9)) - tac = property(fget=_get_register(10), fset=_set_register(10)) - _if = property(fget=_get_register(11), fset=_set_register(11)) - lcdc = property(fget=_get_register(12), fset=_set_register(12)) - stat = property(fget=_get_register(13), fset=_set_register(13)) - scy = property(fget=_get_register(14), fset=_set_register(14)) - scx = property(fget=_get_register(15), fset=_set_register(15)) - ly = property(fget=_get_register(16), fset=_set_register(16)) - lyc = property(fget=_get_register(17), fset=_set_register(17)) - dma = property(fget=_get_register(18), fset=_set_register(18)) - wy = property(fget=_get_register(19), fset=_set_register(19)) - wx = property(fget=_get_register(20), fset=_set_register(20)) - vbk = property(fget=_get_register(21), fset=_set_register(21)) - hdma1 = property(fget=_get_register(22), fset=_set_register(22)) - hdma2 = property(fget=_get_register(23), fset=_set_register(23)) - hdma3 = property(fget=_get_register(24), fset=_set_register(24)) - hdma4 = property(fget=_get_register(25), fset=_set_register(25)) - hdma5 = property(fget=_get_register(26), fset=_set_register(26)) - svbk = property(fget=_get_register(27), fset=_set_register(27)) - ie = property(fget=_get_register(28), fset=_set_register(28)) - - def __repr__(self): - spacing = "\t" - output = "Registers:\n" - for (id, each) in enumerate(self.order): - output += spacing + each + " = " + hex(get_registers()[id]) - #hex(self[each]) - output += "\n" - return output - -registers = Registers() - def call(bank, address): """ Jumps into a function at a certain address. @@ -668,66 +148,6 @@ def call(bank, address): else: registers["pc"] = address -class cheats: - """ - Helpers to manage the cheating infrastructure. - - import vba; vba.load_rom(); vba.cheats.add_gameshark("0100CFCF", "text speedup 1"); vba.cheats.add_gameshark("0101CCCF", "text speedup 2"); vba.go() - """ - - @staticmethod - def enable(id): - """ - void gbCheatEnable(int i) - """ - Gb.cheatEnable(id) - - @staticmethod - def disable(id): - """ - void gbCheatDisable(int i) - """ - Gb.cheatDisable(id) - - @staticmethod - def load_file(filename): - """ - Loads a .clt file. By default each cheat is disabled. - """ - Gb.loadCheatsFromFile(filename) - - @staticmethod - def remove_all(): - """ - Removes all cheats from memory. - - void gbCheatRemoveAll() - """ - Gb.cheatRemoveAll() - - @staticmethod - def remove_cheat(id): - """ - Removes a specific cheat from memory by id. - - void gbCheatRemove(int i) - """ - Gb.cheatRemove(id) - - @staticmethod - def add_gamegenie(code, description=""): - """ - void gbAddGgCheat(const char *code, const char *desc) - """ - Gb.cheatAddGamegenie(code, description) - - @staticmethod - def add_gameshark(code, description=""): - """ - gbAddGsCheat(const char *code, const char *desc) - """ - Gb.cheatAddGameshark(code, description) - def get_stack(): """ Return a list of functions on the stack. @@ -1133,19 +553,6 @@ class crystal: memory = get_memory() class TestEmulator(unittest.TestCase): - try: - state = load_state("cheating-12") - except: - if "__name__" == "__main__": - raise Exception("failed to setup unit tests because no save state found") - - def setUp(self): - load_rom() - set_state(self.state) - - def tearDown(self): - shutdown() - def test_PlaceString(self): call(0, 0x1078) From 1caffffa3893d3fe2bef25cd4d860bda43cbbe08 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 02:06:30 -0500 Subject: [PATCH 19/21] vba_autoplayer.py -> autoplayer.py --- pokemontools/vba/{vba_autoplayer.py => autoplayer.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pokemontools/vba/{vba_autoplayer.py => autoplayer.py} (100%) diff --git a/pokemontools/vba/vba_autoplayer.py b/pokemontools/vba/autoplayer.py similarity index 100% rename from pokemontools/vba/vba_autoplayer.py rename to pokemontools/vba/autoplayer.py From 98defaf9f2500db39166fd13e098d837b2da23a3 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 02:10:01 -0500 Subject: [PATCH 20/21] remove the Recording junk That should go into vba_wrapper if it turns out to be important. --- pokemontools/vba/vba.py | 53 ----------------------------------------- 1 file changed, 53 deletions(-) diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 00bde25..d7fdf1d 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -63,59 +63,6 @@ def press(buttons, holdsteps=1, aftersteps=1): for step_counter in range(0, aftersteps): Gb.step(0) -class Recording: - def __init__(self): - self.frames = [] - self.states = {} - - def _get_frame_count(self): - return len(self.frames) - - frame_count = property(fget=_get_frame_count) - - def save(self, name=None): - """ - Saves the current state. - """ - state = bytearray(get_state()) - state.name = name - self.states[self.frame_count] = state - - def load(self, name): - """ - Loads a state by name in the state list. - """ - for state in self.states.items(): - if state.name == name: - set_state(state) - return state - return False - - def step(self, stepcount=1, first_frame=0, replay=False): - """ - Records button presses for each frame. - """ - if replay: - stepcount = len(self.frames[first_name:]) - - for counter in range(first_frame, stepcount): - if replay: - press(self.frames[counter], steplimit=0) - else: - self.frames.append(get_buttons()) - nstep(1) - - def replay_from(self, thing): - """ - Replays based on a State or the name of a saved state. - """ - if isinstance(thing, State): - set_state(thing) - else: - thing = self.load(thing) - frame_id = self.states.index(thing) - self.step(first_frame=frame_id, replay=True) - def call(bank, address): """ Jumps into a function at a certain address. From 052fde28ca5a0839f49af702bbc1a5ffbf410858 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 9 Sep 2013 02:18:01 -0500 Subject: [PATCH 21/21] remove the old vba filenames from MANIFEST.in --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 62317d9..d750b85 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include README.md -include vba_autoplayer.py vba_config.py vba_keyboard.py vba.py global-exclude *.pyc global-exclude .gitignore