Advertisement
Guest User

Untitled

a guest
Sep 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *************************************************
  2. * D - Draw sprite at I to VX, VY with N lines
  3. *************************************************
  4. OpDXYN_DrawSprite       PSHS    X       ; X = Source (Sprite)
  5.                 DisableInterrupts
  6.                 LDX #Chip8_RAM
  7.                 CLR Chip8_VF
  8.                 LDD Chip8_I
  9.                 LEAX    D,X     ; X now points at sprite
  10.                
  11.                 LDY #Chip8_Vars
  12.                 GetPreByteIntoB
  13.                 LDB B,Y
  14.                 STB Chip8_VY    ; VY = vertical loc
  15.                
  16.                 GetOtherHalfOfOpIntoA
  17.                 LDA A,Y
  18.                 STA Chip8_VX    ; VX = horizontal loc
  19.                
  20.                 GetPostByteIntoB
  21.                 BNE @Not16Case
  22.                 LDB #16
  23. @Not16Case          STB Chip8_PatternCount  ; N = number of vertbytes
  24.  
  25. @GetByte            LDA ,X
  26.                 STA Chip8_PatternHigh
  27.                 CLR Chip8_PatternLow
  28.                 LDB Chip8_VX
  29.                 ANDB    #7
  30. @CheckPosition          BEQ @CorrectPosition
  31.                 LSR Chip8_PatternHigh
  32.                 ROR Chip8_PatternLow
  33.                 DECB
  34.                 BNE @CheckPosition             
  35. @CorrectPosition        LDA Chip8_VY
  36.                 ANDA    #$1F    ; Mask to 5 bits for wrap
  37.                 ASLA
  38.                 ASLA
  39.                 ASLA   
  40.                 LDB Chip8_VX
  41.                 ANDB    #$3F    ; Mask to 6 bits
  42.                 LSRB
  43.                 LSRB
  44.                 LSRB
  45.                 PSHS    A
  46.                 ADDB    ,S+
  47.                 PSHS    X
  48.                 LDX #Video_RAM
  49.                 ABX
  50.                 TFR X,Y
  51.                 PULS    X
  52.                 LDA Chip8_PatternHigh
  53.                 LDB Chip8_PatternHigh
  54.                 EORA    ,Y
  55.                 ORB ,Y
  56.                 STA ,Y
  57.                 CMPB    ,Y
  58.                 BEQ @NoOverlapHigh
  59.                 LDA #$1
  60.                 STA Chip8_VF
  61. @NoOverlapHigh          LDA Chip8_PatternLow
  62.                 LDB Chip8_PatternLow
  63.                 EORA    1,Y
  64.                 ORB 1,Y
  65.                 STA 1,Y
  66.                 CMPB    1,Y
  67.                 BEQ @NoOverlapLow
  68.                 LDA #$1
  69.                 STA Chip8_VF
  70. @NoOverlapLow           INC Chip8_VY
  71.                 LEAX    1,X
  72.                 DEC Chip8_PatternCount
  73.                 BNE @GetByte
  74.                 EnableInterrupts
  75.                 PULS    X
  76.                 CWAI    #$EF
  77.                 RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement