Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 3.50 KB | None | 0 0
  1. DECLARE SUB EchoInit            ' ECHO INITALIZATION
  2.     EchoZ80Reset                ' Reset Z80
  3.     EchoZ80request              ' Request Z80 Bus
  4.     POKE &hA01FFF, 1            ' Write init command number so that this is the first command executed by echo
  5.     reload VoiceList            ' Instrument Pointer List gets loaded
  6.     EchoWriteAdressParam        ' Write the address of the pointer list to Z80 memory
  7.     i=0                         ' i = amount of bytes written
  8.     reload Z80ProgEnd           ' Load the end of the driver binary into Dataptr&()
  9.     a& = dataptr&()             ' Use that as an ending marker for the transfer operation
  10.     reload Z80Prog              ' Load the adress of the Z80 driver
  11.     WHILE dataptr&() < a&       ' (LOOP) Copy the driver into the start of Z80 memory
  12.         READ byt                ' Read next byte of the binary
  13.         POKE 10485760+i, byt    ' Write it to Z80 memory
  14.         i=i+1                   ' increase counter
  15.     WEND                        ' Do this until the full binary is loaded
  16.     EchoZ80Reset                ' Reset Z80
  17.     EchoZ80Release              ' Release Z80 Bus
  18. END SUB
  19.  
  20. ' SUB: ECHOGETSTATUS
  21. '
  22. ' Returns the status of Echo (see docs for that)
  23.  
  24. DECLARE FUNCTION EchoGetStatus AS INTEGER
  25.     EchoZ80Request             
  26.     RETURN PEEK(&hA01FF0)
  27.     EchoZ80Release
  28. END FUNCTION
  29.  
  30. ' SUB: ECHOZ80REQUEST
  31. '
  32. ' Requests the Z80 Bus
  33.  
  34. DECLARE SUB EchoZ80Request
  35.     pokeint &hA11100,&h0100     ' Request Z80 Bus
  36. END SUB
  37.  
  38. ' SUB: ECHOZ80RELEASE
  39. '
  40. ' Releases the Z80 Bus
  41.  
  42. DECLARE SUB EchoZ80Release
  43.     pokeint &hA11100,&h0000     ' Release Z80 Bus
  44. END SUB
  45.  
  46. DECLARE SUB EchoZ80Reset
  47.     pokeint &hA11200,&h0000     ' Assert reset line
  48.     asm                         ' These nops make the 68k wait until the Z80 is operational
  49.         nop                     ; before releasing its RESET LINE
  50.         nop
  51.         nop
  52.         nop
  53.         nop
  54.         nop
  55.         nop
  56.         nop
  57.         nop
  58.         nop
  59.     END asm
  60.     pokeint &hA11200,&h0100     ' Release reset line
  61. END SUB
  62.  
  63. ' SUB: ECHOSENDCOMMAND
  64. '
  65. ' Sends a command to Echo
  66.  
  67.  
  68. DECLARE SUB EchoSendCommand(Command AS INTEGER)
  69.     EchoZ80Request  
  70.     WHILE PEEK(&hA01FFF) > 0
  71.         EchoZ80Release ' If Echo is not ready, let it continue for a while
  72.         f = &hFF
  73.         WHILE f > 0
  74.             f--
  75.         WEND
  76.         EchoZ80Request 
  77.     WEND
  78.     POKE &hA01FFF, Command 
  79.     EchoZ80Release
  80. END SUB
  81.  
  82. ' SUB: ECHOSENDCOMMANDEX
  83. '
  84. ' Sends a command with an adress parameter to Echo
  85.  
  86. DECLARE SUB EchoSendCommandEx(Command AS INTEGER)
  87.     EchoSendCommand Command
  88.     EchoZ80Request
  89.     EchoWriteAdressParam
  90.     EchoZ80Release 
  91. END SUB
  92.  
  93. ' SUB: ECHOWRITEADRESSPARAM
  94. '
  95. ' Writes an adress parameter for a command into Z80 RAM
  96.  
  97. DECLARE SUB EchoWriteAdressParam
  98.     regmove.l 0, d1             ' Clear d1 register of the 68K     
  99.     ParamAdress& = dataptr&()   ' Get adress from DataPtr&()
  100.     regmove.l ParamAdress&, d0  ' Move the adress into d0 register
  101.     asm                         ' Because this is complicated, we will use assembly for this
  102.         clr.l d1
  103.         move.b  d0, ($A01FFD)          
  104.         lsr.l   #7, d0                
  105.         lsr.b   #1, d0              
  106.         bset.l  #7, d0        
  107.         move.b  d0, ($A01FFE)      
  108.         lsr.w   #8, d0      
  109.         move.w  d0, d1          
  110.         lsr.w   #1, d1            
  111.         AND.b   #$7F, d0              
  112.         AND.b   #$80, d1      
  113.         OR.b    d1, d0    
  114.         move.b  d0, ($A01FFC)
  115.     END asm
  116. END SUB
  117.  
  118. ' SUB: ECHO COMMANDS
  119. '
  120. ' See their comment for information on what they actually do
  121.  
  122. DECLARE SUB EchoPlayBGM ' Tells Echo to play the BGM
  123.     EchoSendCommandEx 4
  124. END SUB
  125.  
  126. DECLARE SUB EchoStopBGM ' Tells Echo to stop the BGM
  127.     EchoSendCommand 5
  128. END SUB
  129.  
  130. DECLARE SUB EchoPlaySFX ' Tells Echo to play the SFX
  131.     EchoSendCommandEx 2
  132. END SUB
  133.  
  134. DECLARE SUB EchoStopSFX ' Tells Echo to stop the SFX
  135.     EchoSendCommand 3
  136. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement