8

a CHIP-8 emulator
Log | Files | Refs | README

UFO.SRC (2559B)


      1 option binary
      2 align off
      3 
      4      LD   I,  l2CD
      5      LD   V9,  #38
      6      LD   VA,  #08
      7      DRW  V9,  VA, 3
      8      LD   I,  l2D0
      9      LD   VB,  #00
     10      LD   VC,  #03
     11      DRW  VB,  VC, 3
     12      LD   I,  l2D6
     13      LD   V4,  #1D
     14      LD   V5,  #1F
     15      DRW  V4,  V5, 1
     16      LD   V7,  #00
     17      LD   V8,  #0F
     18      CALL l2A2
     19 l21E:  CALL l2AC
     20      SNE  V8,  #00
     21 l222:  JP  l222
     22      LD   V4,  #1E
     23      LD   V5,  #1C
     24      LD   I,  l2D3
     25      DRW  V4,  V5, 3
     26      LD   VE,  #00
     27 l22E:  LD   V6,  #80
     28      LD   VD,  #04
     29      SKNP VD
     30      LD   V6,  #FF
     31      LD   VD,  #05
     32      SKNP VD
     33      LD   V6,  #00
     34      LD   VD,  #06
     35      SKNP VD
     36      LD   V6,  #01
     37      SE   V6,  #80
     38      CALL l2D8
     39 l246:  LD   I,  l2D0
     40      DRW  VB,  VC, 3
     41      RND  VD,  #01
     42      ADD  VB,  VD
     43      DRW  VB,  VC, 3
     44      SE   VF,  #00
     45      JP  l292
     46      LD   I,  l2CD
     47      DRW  V9,  VA, 3
     48      RND  VD,  #01
     49      SE   VD,  #00
     50      LD   VD,  #FF
     51      ADD  V9,  #FE
     52      DRW  V9,  VA, 3
     53      SE   VF,  #00
     54      JP  l28C
     55      SNE  VE,  #00
     56      JP  l22E
     57      LD   I,  l2D3
     58      DRW  V4,  V5, 3
     59      SNE  V5,  #00
     60      JP  l286
     61      ADD  V5,  #FF
     62      ADD  V4,  V6
     63      DRW  V4,  V5, 3
     64      SE   VF,  #01
     65      JP  l246
     66      LD   VD,  #08
     67      AND  VD,  V5
     68      SNE  VD,  #08
     69      JP  l28C
     70      JP  l292
     71 l286:  CALL l2AC
     72      ADD  V8,  #FF
     73      JP  l21E
     74 l28C:  CALL l2A2
     75      ADD  V7,  #05
     76      JP  l296
     77 l292:  CALL l2A2
     78      ADD  V7,  #0F
     79 l296:  CALL l2A2
     80      LD   VD,  #03
     81      LD   ST,  VD
     82      LD   I,  l2D3
     83      DRW  V4,  V5, 3
     84      JP  l286
     85 l2A2:  DW #A2F8     ;LD   I,  l2F8 as we cannot load an effective address
     86      LD   B,   V7
     87      LD   V3,  #00
     88      CALL l2B6
     89      RET
     90 l2AC:  DW #A2F8     ;LD   I,  l2F8 as we cannot load an effective address
     91      LD   B,   V8
     92      LD   V3,  #32
     93      CALL l2B6
     94      RET
     95 l2B6:  LD   VD,  #1B
     96      LD   V2,  [I]
     97      LD   F,   V0
     98      DRW  V3,  VD, 5
     99      ADD  V3,  #05
    100      LD   F,   V1
    101      DRW  V3,  VD, 5
    102      ADD  V3,  #05
    103      LD   F,   V2
    104      DRW  V3,  VD, 5
    105      RET
    106      DB #01
    107 l2CD:     DB #7C        ; .11111..
    108      DB #FE             ; 1111111.
    109      DB #7C             ; .11111..
    110 l2D0:
    111        DB  #60          ;.11.....
    112        DB  #F0          ;1111....
    113        DB  #60          ;.11.....
    114 
    115 l2D3:  DB  #40          ;.1......
    116        DB  #E0          ;111.....
    117        DB  #A0          ;1.1.....
    118 
    119 l2D6:  DB   #F8         ;11111...
    120        DB   #D4         ;11.1.1..
    121 l2D8:  LD   VE,  #01
    122      LD   VD,  #10
    123      LD   ST,  VD
    124      RET