def test_joypad1_with_up_event(self): game = Game() joypad_1 = Joypad(1, game) game._asm_chunks['joypad1_up'] = ' LDA $0200\n' self.assertTrue(joypad_1.is_used) asm = joypad_1.to_asm() self.assertTrue('LDA $0200' in asm) self.assertTrue('JoyPad1A:' in asm) self.assertTrue('JoyPad1B:' in asm) self.assertTrue('JoyPad1Select:' in asm) self.assertTrue('JoyPad1Start:' in asm) self.assertTrue('JoyPad1Up:' in asm) self.assertTrue('JoyPad1Down:' in asm) self.assertTrue('JoyPad1Left:' in asm) self.assertTrue('JoyPad1Right:' in asm) self.assertTrue('JoyPad2' not in asm)
def compose(code, game_program=game): global game if game_program == None: game = game_program = Game() python_land = ast.parse(code) turist = PyNesVisitor() turist.visit(python_land) game = None return game_program
def compose(code, game_program=game): global game if game_program == None: game = game_program = Game() python_land = ast.parse(code) builder = PyNesTransformer() builder.visit(python_land) turist = PyNesVisitor() turist.visit(python_land) python_land = ast.fix_missing_locations(python_land) #exec compile(python_land, '<string>', 'exec') game = None return game_program
def test_ppusprite_with_1(self): s = PPUSprite(1, Game()) self.assertEquals(0x0204, s.y) self.assertEquals(0x0207, s.x)
def test_ppusprite_with_0(self): s = PPUSprite(0, Game()) self.assertEquals(0x0200, s.y) self.assertEquals(0x0203, s.x)
def test_joypad2(self): joypad_2 = Joypad(2, Game()) self.assertFalse(joypad_2.is_used) self.assertEquals('', joypad_2.to_asm())
def test_joypad1(self): joypad_1 = Joypad(1, Game()) self.assertFalse(joypad_1.is_used) self.assertEquals('', joypad_1.to_asm())
import pynes from pynes.game import Game from pynes.bitbag import * from pynes.nes_types import * game = Game() palette = game.assign( 'palette', NesArray([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0x0F, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 ])) sprite = game.assign('sprite', game.call('define_sprite', [128, 128, 0, 3])) game.assign('chr_asset', NesChrFile('player.chr')) game.asmFunction("reset") game.call('wait_vblank') game.call('clearmem') game.call('wait_vblank') game.call('load_palette', [palette]) game.call('load_sprite', [sprite, 0]) game.asmFunction("joypad1_up") game.minusAssign(game.call('get_sprite', [0]).y, 1)
import pynes from pynes.game import Game from pynes.bitbag import * from pynes.nes_types import * game = Game() palette = game.assign('palette', NesArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,15, 0x0F, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) ) sprite = game.assign('sprite', game.call('define_sprite', [128, 128, 0, 3])) game.assign('chr_asset', NesChrFile('player.chr')) game.asmFunction("reset") game.call('wait_vblank') game.call('clearmem') game.call('wait_vblank') game.call('load_palette', [palette]) game.call('load_sprite', [sprite, 0]) game.asmFunction("joypad1_up") game.minusAssign(game.call('get_sprite', [0]).y, 1) #game.asmFunction("joypad1_up")