Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 3.29 KB | None | 0 0
  1. #include <memcopy.bas>
  2.  
  3. border 0
  4. paper 0
  5. ink 6
  6. cls
  7.  
  8.  ASM
  9.                                 di                  ; disable intsd
  10.                                 LD A,(23388)  ; load a with previos port value
  11.                                 AND 248   ; and ‭11111000‬
  12.                                 OR 4 ; OR 1 to ‭11111001 (page 1)
  13.                                 LD BC,32765 ; load BC with
  14.                                 LD (23388),A
  15.                                 OUT (C),A
  16.                                 EI
  17.                                
  18.  END ASM
  19.  
  20. PRINT PEEK 23388
  21.  
  22. ' the playsoutine expects the music to be at 51310, so lets copy the music there
  23. memcopy(@music, 51310, @musicend-@music)
  24. ' The play routine expects to be at 49152, so lets copy it there
  25. memcopy(@ayplay, 49152, 1617)
  26. ' This is routine that will be called every frame, lets copy it to its correct location
  27. memcopy(@Ints, $6060, 60)
  28. 'memcopy(@ayplay, 24672, 1617)
  29. 'memcopy(@exe, 24064, 1200)
  30.  
  31. 'randomize USR 24064
  32.  
  33.  
  34. ' we need to init our play routine, so call it
  35. randomize usr 49152
  36.  
  37.  
  38.  
  39. 'print "WAITING": pause 0
  40. PRINT "DONE2"
  41. randomize USR @IMStart
  42.  
  43. END
  44.  
  45. ayplay:
  46. asm
  47.     incbin "vt49152.bin"
  48. END asm
  49.  
  50. music:
  51. asm
  52.     incbin "bomb2stg1.mide.pt3"
  53. END asm
  54. musicend:
  55.  
  56.  
  57. Ints:
  58.     asm
  59.                                 di                  ; disable interrupts
  60.                 push af             ; save all std regs
  61.                 push bc
  62.                 push de
  63.                 push hl
  64.                 push ix             ; save ix & iy
  65.                 push iy
  66.                                 ;ex (sp),hl
  67.                 ex af, af'          ; and shadow af
  68.                push af
  69.                                 ;exx
  70.                                 ;push bc
  71.                                 LD A,(23388)  ; load a with previos port value
  72.                                 AND 248   ; and ‭11110000‬
  73.                                 OR 4 ; OR 1 to ‭11111001 (page 1)
  74.                                 LD BC,32765 ; load BC with
  75.                             LD (23388),A
  76.                                 OUT (C),A
  77.  
  78.                                 call 49157       ; play the current tune
  79.                                
  80.                                 LD A,(23388)  ; load a with previos port value
  81.                                 AND 248   ; and ‭11111000‬
  82.                                 OR 0 ; OR 0 to ‭11111001 (page 1)
  83.                                 LD BC,32765 ; load BC with
  84.                                 LD (23388),A
  85.                                 OUT (C),A
  86.                                 ;pop bc
  87.                                 ;exx
  88.                pop af
  89.                                 ex af, af'          ; restore af
  90.                                 ;ex (sp),hl
  91.                 pop iy
  92.                 pop ix              ; restore ix & iy
  93.                 pop hl
  94.                 pop de
  95.                 pop bc
  96.                 pop af              ; restore all std regs
  97.                 ei                  ; enable interrupts
  98.                 ;ret                 ; done
  99.                 jp 56
  100.                                 ;rst 56
  101.     END asm
  102.  
  103. IMStart:
  104.     asm
  105.                                 DI
  106.                                 LD A,(23388)  ; load a with previos port value
  107.                                 AND 248   ; and ‭11110000‬
  108.                                 OR 4 ; OR 1 to ‭11111001 (page 1)
  109.                                 LD BC,32765 ; load BC with
  110.                                 LD (23388),A
  111.                                 OUT (C),A  
  112.                             ; this code creates a 256 byte vector table at $FE00, then sets IM2
  113.                        
  114.                 ld hl, $5e00
  115.                 ld de, $5e01
  116.                 ld bc, 256
  117.                 ld a, h
  118.                 ld i, a
  119.                 ld a, $60
  120.                 ld (hl), a
  121.                 ldir
  122.                 im 2
  123.                                 LD A,(23388)  ; load a with previos port value
  124.                                 AND 248   ; and ‭11111000‬
  125.                                 OR 0 ; OR 1 to ‭11111001 (page 1)
  126.                                 LD BC,32765 ; load BC with
  127.                                 LD (23388),A
  128.                                 OUT (C),A
  129.                 ei
  130.                 ret      
  131.     END asm
  132.  
  133. IMOff:
  134.     ASM        
  135.         DI
  136.         IM 1
  137.         EI
  138.         RET
  139.     END ASM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement