Advertisement
vladikcomper

VDP managing macros

Aug 22nd, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; =============================================================
  2. ; Macro to set VRAM write access
  3. ; Arguments:    1 - raw VRAM offset
  4. ;       2 - register to write access bitfield in (Optional)
  5. ; -------------------------------------------------------------
  6. vram    macro
  7.     if (narg=1)
  8.         move.l  #($40000000+((\1&$3FFF)<<16)+((\1&$C000)>>14)),($C00004).l
  9.     else
  10.         move.l  #($40000000+((\1&$3FFF)<<16)+((\1&$C000)>>14)),\2
  11.     endc
  12.     endm
  13.    
  14.  
  15. ; =============================================================
  16. ; Macro to set CRAM write access
  17. ; Arguments:    1 - raw CRAM offset
  18. ;       2 - register to write access bitfield in (Optional)
  19. ; -------------------------------------------------------------
  20. cram    macro   offset,operand
  21.     if (narg=1)
  22.         move.l  #($C0000000+(\1<<16)),VDP_Ctrl
  23.     else
  24.         move.l  #($C0000000+(\1<<16)),\operand
  25.     endc
  26.     endm
  27.  
  28.  
  29. ; =============================================================
  30. ; Macro to direct copy data into VRAM via DMA
  31. ; Arguments:    1 - Source Offset
  32. ;       2 - Transfer Length (in bytes)
  33. ;       3 - Destination
  34. ; -------------------------------------------------------------
  35. writeVRAM   macro
  36.     lea VDP_Ctrl,a5
  37.     move.l  #$94000000+(((\2>>1)&$FF00)<<8)+$9300+((\2>>1)&$FF),(a5)
  38.     move.l  #$96000000+(((\1>>1)&$FF00)<<8)+$9500+((\1>>1)&$FF),(a5)
  39.     move.w  #$9700+((((\1>>1)&$FF0000)>>16)&$7F),(a5)
  40.     move.w  #$4000+(\3&$3FFF),(a5)
  41.     move.w  #$80+((\3&$C000)>>14),-(sp)
  42.     move.w  (sp)+,(a5)
  43.     endm
  44.  
  45. ; =============================================================
  46. ; Macro to direct copy data into CRAM via DMA
  47. ; Arguments:    1 - Source Offset
  48. ;       2 - Transfer Length (in bytes)
  49. ;       3 - Destination
  50. ; -------------------------------------------------------------
  51. writeCRAM   macro
  52.     lea VDP_Ctrl,a5
  53.     move.l  #$94000000+(((\2>>1)&$FF00)<<8)+$9300+((\2>>1)&$FF),(a5)
  54.     move.l  #$96000000+(((\1>>1)&$FF00)<<8)+$9500+((\1>>1)&$FF),(a5)
  55.     move.w  #$9700+((((\1>>1)&$FF0000)>>16)&$7F),(a5)
  56.     move.w  #$C000+(\3&$3FFF),(a5)
  57.     move.w  #$80+((\3&$C000)>>14),-(sp)
  58.     move.w  (sp)+,(a5)
  59.     endm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement