SHARE
TWEET

Untitled

a guest Jan 4th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .memorymap
  2. defaultslot 0
  3. slotsize $8000
  4. slot 0 $0000
  5. .endme
  6.  
  7. .rombankmap
  8. bankstotal 1
  9. banksize $8000
  10. banks 1
  11. .endro
  12.  
  13. .define VDPControl $bf
  14. .define VDPStatus $bf
  15. .define VDPData $be
  16. .define VRAMWrite $4000
  17. .define CRAMWrite $c000
  18. .define Joypad1 $dc
  19. .define Joypad2 $dd
  20. .define PSTATUS $c000
  21. .define PSTATUS2 $c001
  22. .define JOYSTATUS $c002
  23. .define JOYSTATUS2 $c003
  24.  
  25. .bank 0 slot 0
  26. .org $0000
  27.     di
  28.     im 1
  29.     jp main
  30.  
  31. .org $0066
  32.     retn
  33.  
  34. .org $0038
  35.   push af
  36.     in a,(VDPStatus)
  37.     push bc
  38.         call VBlankRoutine
  39.     pop bc
  40.   pop af
  41.   ei
  42.   reti
  43.  
  44. main:
  45.     ld sp, $dff0
  46.  
  47.     di
  48.    
  49.     ld hl,VDPInitData
  50.     ld b,VDPInitDataEnd-VDPInitData
  51.     ld c,VDPControl
  52.     otir
  53.  
  54.     ld hl,$0000 | VRAMWrite
  55.     call SetVDPAddress
  56.     ld bc,$4000
  57. -:  xor a
  58.     out (VDPData),a
  59.     dec bc
  60.     ld a,b
  61.     or c
  62.     jr nz,-
  63.  
  64.     ld hl,$0000 | CRAMWrite
  65.     call SetVDPAddress
  66.     ld hl,PaletteData
  67.     ld bc,PaletteDataEnd-PaletteData
  68.     call CopyToVDP
  69.  
  70.     ld hl,$0000 | VRAMWrite
  71.     call SetVDPAddress
  72.     ld hl,FontData
  73.     ld bc,FontDataSize
  74.     call CopyToVDP
  75.  
  76.     ld hl,$3800 | VRAMWrite
  77.     call SetVDPAddress
  78.     ld hl,Message
  79. -:  ld a,(hl)
  80.     cp $ff
  81.     jr z,+
  82.     out (VDPData),a
  83.     xor a
  84.     out (VDPData),a
  85.     inc hl
  86.     jr -
  87. +:
  88.  
  89.     ld a,%01100000
  90.     out (VDPControl),a
  91.     ld a,$81
  92.     out (VDPControl),a
  93.  
  94.     ld a,%00000001
  95.     ld (PSTATUS),a
  96.  
  97.     ei
  98.  
  99. MainLoop:
  100.     ld a,(JOYSTATUS)
  101.     and %00000100
  102.     jr z,MainLoop
  103.  
  104.     ld b,a
  105.     ld a,(JOYSTATUS2)
  106.     xor b
  107.     and %00000100
  108.     call nz,ZapperPressed
  109.  
  110. jr MainLoop
  111.  
  112. VBlankRoutine:
  113.     ld bc,(JOYSTATUS)
  114.     ld (JOYSTATUS2),bc
  115.     in a,(Joypad2)
  116.     and %10000100
  117.     ld (JOYSTATUS),a
  118.     ret
  119.  
  120. ZapperPressed:
  121.     ld bc,PaletteDataEnd-PaletteData
  122.     ld a,(PSTATUS)
  123.     xor $01
  124.     ld (PSTATUS),a
  125.     and $01
  126.     jr z,_ll2
  127.    
  128.     ld hl,$0000 | CRAMWrite
  129.     call SetVDPAddress
  130.     ld hl,WPaletteData
  131.     jr _ll3
  132. _ll2:
  133.     ld hl,$0000 | CRAMWrite
  134.     call SetVDPAddress
  135.     ld hl,PaletteData
  136. _ll3:
  137.     call CopyToVDP
  138.     ret
  139.  
  140. SetVDPAddress:
  141.     push af
  142.         ld a,l
  143.         out (VDPControl),a
  144.         ld a,h
  145.         out (VDPControl),a
  146.     pop af
  147.     ret
  148.  
  149. CopyToVDP:
  150. -:  ld a,(hl)
  151.     out (VDPData),a
  152.     inc hl
  153.     dec bc
  154.     ld a,b
  155.     or c
  156.     jr nz,-
  157.     ret
  158.  
  159. .asciitable
  160. map " " to "~" = 0
  161. .enda
  162.  
  163. Message:
  164. .asc "0"
  165. .db $ff
  166.  
  167. PaletteData:
  168. .db $00,$3f
  169. PaletteDataEnd:
  170. WPaletteData:
  171. .db $3f,$00
  172. WPaletteDataEnd:
  173.  
  174. ; VDP initialisation data
  175. VDPInitData:
  176. .db $04,$80,$00,$81,$ff,$82,$ff,$85,$ff,$86,$ff,$87,$00,$88,$00,$89,$ff,$8a
  177. VDPInitDataEnd:
  178.  
  179. FontData:
  180. .incbin "font.bin" fsize FontDataSize
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top