comparison clojure/com/aurellem/assembly.clj @ 135:eb6ba88088d3

Wrote a more efficient input-number-assembly program; 91 oc -> 60 oc.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 18 Mar 2012 05:13:19 -0500
parents 7f7cc8858d2e
children ffeeabae7dcd
comparison
equal deleted inserted replaced
134:718abf3bec8a 135:eb6ba88088d3
388 388
389 0xFA ;D353 ; load (D350) into A 389 0xFA ;D353 ; load (D350) into A
390 0x50 ;D354 --> 390 0x50 ;D354 -->
391 0xD3 ;D355 --> D31F 391 0xD3 ;D355 --> D31F
392 392
393 0xEA ;D356 ; load (A), which is 393 0xEA ;D356 ; load A, which is
394 0x00 ;D357 --> ; 00010000, into FF00 394 0x00 ;D357 --> ; 00010000, into FF00
395 0xFF ;D358 --> FF00 395 0xFF ;D358 --> FF00
396 396
397 0x06 ;D359 397 0x06 ;D359
398 ;D35A 398 ;D35A
465 (dotimes [_ 90000] (step (view-memory @current-state 0xD352)))) 465 (dotimes [_ 90000] (step (view-memory @current-state 0xD352))))
466 466
467 467
468 468
469 469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
470 (defn write-memory-assembly* [] 495 (defn write-memory-assembly* []
471 [ 496 [
497 ;; --------- FRAME METRONOME
498
472 0x18 ;; D31D 499 0x18 ;; D31D
473 0x02 500 0x01
474 0x00 ;; frame-count D31F 501 0x00 ;; v-blank-prev D31F
475 0x00 ;; v-blank-prev D320
476 502
477 0xFA ;; load modes into A 503 0xFA ;; load modes into A
478 0x41 504 0x41
479 0xFF 505 0xFF
480 506
481 0x47 507 0x47 ;; A -> B
482 508 0xCB ;; rotate A
483 0xCB
484 0x2F 509 0x2F
485 0x2F 510 0x2F ;; invert A
486 511
487 0xA0 512 0xA0
488 0xE6 513 0x47 ;; now B_0 contains (VB==1)
489 0x01
490 0x47 ;; now B contains (VB==1)
491 514
492 0xFA ;; load v-blank-prev 515 0xFA ;; load v-blank-prev
493 0x20
494 0xD3
495
496 0x2F
497
498 0xA0
499 0x4F ;; now C contains increment?
500
501 0xFA ;; load frame count
502 0x1F 516 0x1F
503 0xD3 517 0xD3
504 518
505 0x81 ;; add A+C->A 519 0x2F ;; complement v-blank-prev
506 0xEA ;; spit A --> fc 520
521 0xA0 ;; A & B --> A
522 0x4F ;; now C_0 contains increment?
523
524
525 0x78 ;; B->A
526
527 0xEA ;; spit A --> vbprev
507 0x1F 528 0x1F
508 0xD3 529 0xD3
509 530
510 0x78 ;; B->A 531 0x41 ;test C_0
511 532 0x20 ; nonzero jump
512 0xEA ;; spit A --> vbprev 533 0x04
534
535 0xC3 ; ; go back to beginning
536 0x1D ;
537 0xD3 ;
538
539 ;; -------- GET BUTTON INPUT
540 0x00 ;; var: which-input D339
541 ;; prepare to select bits
542
543 0x01 ;; load 0x0000 into BC
544 0x00
545 0x00
546
547 0x3E ;; load 0x20 into A
513 0x20 548 0x20
549
550
551 0xEA ;; load A into [FF00] ;; D33F (not D33C)
552 0x00
553 0xFF
554
555 0xFA ;; load A from [FF00]
556 0x00
557 0xFF
558
559 0xE6 ;; bitmask 00001111
560 0x0F
561
562 0xB0 ;; A or B --> A
563
564 0xCB
565 0x41 ;; test bit 0 of C
566 0x20 ;; jump forward if 1
567 0x08
568
569 0x47 ;; A -> B
570 0xCB ;; swap B nybbles
571 0x30
572 0x0C ;; increment C
573 0x3E ;; load 0x10 into A
574 0x10
575 0x18 ;; JUMP back to "load A into [FF00]" [20 steps?]
576 0xEB
577
578 ;; now A contains the pressed keys
579 0xEA ;; copy keys to input-number [D339]
580 0x39
514 0xD3 581 0xD3
515 582 0x18 ;;
516 0xC3 ;D40F ; go back to beginning 583 0xEB
517 0x1D ;D410 584
518 0xD3 ;D411 585
519 ] 586 ]
520 ) 587 )
521 588
522 (defn write-mem-dyl [] 589 (defn write-mem-dyl []
523 (-> (tick (mid-game)) 590 (-> (tick (mid-game))
524 (IE! 0) 591 (IE! 0)
525 (inject-item-assembly (write-memory-assembly*)))) 592 (inject-item-assembly (write-memory-assembly*))))
593
594
595 (defn dylan []
596 (->
597 (write-mem-dyl)
598 (tick)
599 (tick)
600 (tick)
601 (tick)
602 (tick)
603 (tick)
604 (tick)
605 (tick)
606 (tick)
607 (tick)
608 (tick)
609 (tick)
610 (tick)
611 (tick)
612 (tick)
613 (tick)
614 (tick)
615 (tick)
616 (tick)
617 (tick)
618 (tick)
619 (tick)
620 (tick)
621 (tick)
622 (tick)
623 (tick)
624 (tick)
625 (tick)
626
627
628 (d-tick)
629
630
631 (view-register "A" A)
632 (view-register "B" B)
633 (view-register "C" C)
634
635 ))
636
637
526 638
527 639
528 (defn d2 [] 640 (defn d2 []
529 (-> 641 (->
530 (write-mem-dyl) 642 (write-mem-dyl)
531 (view-memory 0xD31F) 643 (view-memory 0xD31F)
532 step step step step step 644 step step step step step
533 (view-memory 0xD31F))) 645 (view-memory 0xD31F)))
534 646
535 (defn dylan [] 647
536 (-> 648
537 (write-mem-dyl) 649
538 (tick) 650
539 (tick) 651
540 (tick) 652
541 (tick) 653
542 (tick) 654
543 (tick) 655
544 (tick) 656
545 (tick) 657
546 (tick) 658
547 (tick) 659
548 (tick) 660
549 (tick) 661
550
551 (tick)
552 (tick)
553 (tick)
554 (tick)
555 (tick)
556
557 (d-tick)
558 (view-register "A" A)
559 (view-register "B" B)
560 (view-register "C" C)
561
562 ))
563 662
564 663
565 664
566 665
567 (defn write-memory-assembly [] 666 (defn write-memory-assembly []