home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / DigitalCD / PlayIt164 / !PlayIt / AOF / s / playitv
Text File  |  1999-09-28  |  14KB  |  489 lines

  1. ; PlayIt veneers
  2. ; by Rick Hudson, (c) 1999
  3. ; assembles with asm
  4. ; this source uses AOF register bindings for sl,fp,ip,sp,lr,pc (ie R10-R15)
  5. ; but plain ol' r0-r9 for the rest since the SWIs are defined in terms of them
  6. ; and it's confusing when arranging registers to sometimes use r0-r3 and sometimes
  7. ; a1-a4. So it is avoided.
  8. ;
  9. ; all 'out' parameters (ie those for writing return values) are tested and only
  10. ; written if they are non-NULL
  11. ;
  12. ; If the SWI returns an error return is immediate with any return parameters
  13. ; undefined (specifically they are not changed).
  14. ;
  15. ; PlayIt needs to be loaded to assemble this for SWI name lookup
  16.  
  17.  
  18. ; macro for returning a parameter (currently in register preg) for which the address of
  19. ; the location to store it is on the stack 'stack' words from sp (ie at sp+4*stack).
  20.  
  21.         MACRO    RETPARS,preg,stack
  22.         ldr    lr,[sp,#stack*4]
  23.         teq    lr,#0
  24.         strne    preg,[lr]
  25.         ENDM
  26.  
  27. ; macro for returning a parameter (currently in register preg) for which the address of
  28. ; the location to store it is in areg.
  29.  
  30.         MACRO    RETPARR,preg,areg
  31.         teq    areg,#0
  32.         strne    preg,[areg]
  33.         ENDM
  34.  
  35.         AREA    ASM$$Code,Code,Readonly
  36.  
  37.  
  38. ; playit_error *xplayit_version(/*out*/int *version)
  39.  
  40.         export    xplayit_version
  41. xplayit_version:
  42.         mov    ip,lr        ; keep lr somewhere safe
  43.         mov    r3,r0        ; move return parameter out of the way
  44.         swi    "XPlayIt_Version"
  45.         movvss    pc,ip        ; immediate exit if error
  46.         RETPARR    r0,r3        ; if (r3) [r3]=r0
  47.         mov    a1,#0        ; set a1=0 for no error
  48.         movs    pc,ip        ; return
  49.  
  50.  
  51. ; playit_error *xplayit_config_bits(/*in*/playit_configbits clear, playit_configbits xor,
  52. ;                                   /*out*/playit_configbits *newflags, playit_configbits *oldflags)
  53.  
  54.         export    xplayit_config_bits
  55. xplayit_config_bits:
  56.         mov    ip,lr        ; keep lr somewhere safe
  57.         stmfd    sp!,{r2}    ; move 1st return parameter out of the way
  58.         mov    r2,r1        ; set up parameters...
  59.         mov    r1,r0        ; ... for call to SWI
  60.         mov    r0,#0        ; reason = 0
  61.         swi    "XPlayIt_Config"
  62.         addvs    sp,sp,#4    ; if error, purge stack...
  63.         movvss    pc,ip        ; ...and return
  64.         ldmfd    sp!,{lr}    ; fetch 1st return par off stack
  65.         RETPARR    r1,lr        ; if (lr) [lr]=r1
  66.         RETPARR    r2,r3        ; if (r3) [r3]=r2
  67.         mov    r0,#0        ; set a1=0 for no error
  68.         movs    pc,ip        ; return
  69.  
  70.  
  71. ; playit_error *xplayit_config_discbuffer(/*in*/int size, /*out*/int *oldsize)
  72.  
  73.         export     xplayit_config_discbuffer
  74. xplayit_config_discbuffer:
  75.         mov    ip,lr        ; keep lr somewhere safe
  76.         mov    r2,r1        ; move return parameter out of the way
  77.         mov    r1,r0        ; set up registers for SWI
  78.         mov    r0,#1        ; reason = 1
  79.         swi    "XPlayIt_Config"
  80.         movvss    pc,ip        ; immediate exit if error
  81.         RETPARR    r1,r2        ; if (r2) [r2]=r1
  82.         mov    r0,#0        ; set a1=0 for no error
  83.         movs    pc,ip        ; return
  84.  
  85.  
  86. ; playit_error *xplayit_config_echodelay(/*in*/int ms, /*out*/int *oldms)
  87.  
  88.         export    xplayit_config_echodelay
  89. xplayit_config_echodelay:
  90.         mov    ip,lr        ; keep lr somewhere safe
  91.         mov    r2,r1        ; move return parameter out of the way
  92.         mov    r1,r0        ; set up registers for SWI
  93.         mov    r0,#2        ; reason = 2
  94.         swi    "XPlayIt_Config"
  95.         movvss    pc,ip        ; immediate exit if error
  96.         RETPARR    r1,r2        ; if (r2) [r2]=r1
  97.         mov    r0,#0        ; set a1=0 for no error
  98.         movs    pc,ip        ; return
  99.  
  100.  
  101. ; playit_error *xplayit_config_killbuffer(void)
  102.  
  103.         export     xplayit_config_killbuffer
  104. xplayit_config_killbuffer:
  105.         mov    ip,lr        ; keep lr somewhere safe
  106.         mov    r0,#3        ; reason = 3
  107.         swi    "XPlayIt_Config"
  108.         movvc    r0,#0        ; set a1=0 for no error
  109.         movs    pc,ip        ; return
  110.  
  111.  
  112. ; playit_error *xplayit_load_driver(/*in*/const char *name)
  113.  
  114.         export    xplayit_load_driver
  115. xplayit_load_driver:
  116.         mov    ip,lr        ; keep lr somewhere safe
  117.         swi    "XPlayIt_LoadDriver"
  118.         movvc    r0,#0        ; set a1=0 for no error
  119.         movs    pc,ip        ; return
  120.  
  121.  
  122. ; playit_error *xplayit_driver_info(/*out*/char **name, char **descr,
  123. ;                         char **version, int *framerate, int *mode)
  124.  
  125.         export    xplayit_driver_info
  126. xplayit_driver_info:
  127.         mov    ip,lr        ; keep lr somewhere safe
  128.         stmfd    sp!,{r0-r3}    ; all 5 parameters now on stack
  129.         stmfd    sp!,{r4}    ; have to preserve this
  130.         swi    "XPlayIt_DriverInfo"
  131.         bvs    xplayit_driver_info_X
  132.         RETPARS    r0,1        ; return 1st par if required
  133.         RETPARS    r1,2        ; return 2nd par if required
  134.         RETPARS    r2,3        ; return 3rd par if required
  135.         RETPARS    r3,4        ; return 4th par if required
  136.         RETPARS    r4,5        ; return 5th par if required
  137. xplayit_driver_info_X:
  138.         ldmfd    sp!,{r4}
  139.         add    sp,sp,#4*4    ; purge parameters from stack
  140.         movvc    r0,#0        ; set a1=0 for no error
  141.         movs    pc,ip        ; return
  142.  
  143.  
  144. ; playit_error *xplayit_sample_info(char **name, playit_format *format,
  145. ;              int *framerate, int *bstart, int *bend, int *numframes)
  146.  
  147.         export    xplayit_sample_info
  148. xplayit_sample_info:
  149.         mov    ip,lr        ; keep lr somewhere safe
  150.         stmfd    sp!,{r0-r3}     ; stick all parameters on stack
  151.         stmfd    sp!,{r4-r5}    ; store these cos we corrupt them
  152.         swi    "XPlayIt_SampleInfo"
  153.         bvs    xplayit_sample_info_x
  154.         RETPARS    r0,2        ; return 1st par if required
  155.         RETPARS    r1,3        ; return 2nd par if required
  156.         RETPARS    r2,4        ; return 3rd par if required
  157.         RETPARS    r3,5        ; return 4th par if required
  158.         RETPARS    r4,6        ; return 5th par if required
  159.         RETPARS    r5,7        ; return 6th par if required
  160. xplayit_sample_info_x:
  161.         ldmfd    sp!,{r4-r5}    ; restore r4 and r5
  162.         add    sp,sp,#4*4    ; purge rest of stack
  163.         movvc    r0,#0        ; set a1=0 for no error
  164.         movs    pc,ip        ; return
  165.  
  166.  
  167. ; playit_error *xplayit_status(playit_statusbits *status, playit_frame *frame)
  168.  
  169.         export    xplayit_status
  170. xplayit_status:
  171.         mov    ip,lr        ; keep lr somewhere safe
  172.         mov    r2,r0        ; keep 1st return in r2
  173.         mov    r3,r1        ; keep 2nd return in r3
  174.         swi    "XPlayIt_Status"
  175.         movvss    pc,ip        ; immediate exit if error
  176.         RETPARR    r0,r2        ; if (r2) [r2]=r0
  177.         RETPARR    r1,r3        ; if (r3) [r3]=r1
  178.         mov    r0,#0        ; set a1=0 for no error
  179.         movs    pc,ip        ; return
  180.  
  181.  
  182. ; playit_error *xplayit_volume(int volume, int *oldvol)
  183.  
  184.         export    xplayit_volume
  185. xplayit_volume:
  186.         mov    ip,lr        ; keep lr somewhere safe
  187.         swi    "XPlayIt_Volume"
  188.         movvss    pc,ip        ; immediate exit if error
  189.         RETPARR    r0,r1        ; if (r1) [r1]=r0
  190.         mov    r0,#0        ; set a1=0 for no error
  191.         movs    pc,ip        ; return
  192.  
  193.  
  194. ; playit_error *xplayit_open(const char *filename, playit_format format,
  195. ;                       int framerate, int bstart, int bend, int auxpar);
  196.  
  197.         export    xplayit_open
  198. xplayit_open:
  199.         mov    ip,lr        ; keep lr somewhere safe
  200.         stmfd    sp!,{r4-r5}
  201.         add    lr,sp,#2*4    ; point lr at original stack
  202.         ldmia    lr,{r4-r5}    ; get last two pars off stack
  203.         swi    "XPlayIt_Open"
  204.         ldmfd    sp!,{r4-r5}    ; restore original r4,r5
  205.         movvc    r0,#0        ; set a1=0 for no error
  206.         movs    pc,ip        ; return
  207.  
  208.  
  209. ; playit_error *xplayit_open_block(playit_open_block *block)
  210.  
  211.         export    xplayit_open_block
  212. xplayit_open_block:
  213.         mov    ip,lr        ; keep lr somewhere safe
  214.         stmfd    sp!,{r0,r4-r5}
  215.         ldmia    r0,{r0-r5}    ; load parameters from block
  216.         swi    "XPlayIt_Open"
  217.         ldmfd    sp!,{lr}    ; get back paramater (ptr to block)
  218.         stmia    lr,{r0-r5}    ; write registers back to block
  219.         ldmfd    sp!,{r4-r5}    ; restore original r4,r5
  220.         movvc    r0,#0        ; set a1=0 for no error
  221.         movs    pc,ip        ; return
  222.  
  223.  
  224. ; playit_error *xplayit_open_autodetect(const char *filename)
  225.  
  226.         export    xplayit_open_autodetect
  227. xplayit_open_autodetect:
  228.         mov    ip,lr        ; keep lr somewhere safe
  229.         stmfd    sp!,{r4-r5}    ; save r4,r5 cos swi corrupts them
  230.         mov    r1,#0        ; force auto-detect mode
  231.         swi    "XPlayIt_Open"
  232.         ldmfd    sp!,{r4-r5}    ; get back r4, r5
  233.         movvc    r0,#0        ; set a1=0 for no error
  234.         movs    pc,ip        ; return
  235.  
  236.  
  237. ; playit_error *xplayit_begin_end(playit_frame start, playit_frame end,
  238. ;                           playit_frame *rstart, playit_frame *rend);
  239.  
  240.         export    xplayit_begin_end
  241. xplayit_begin_end:
  242.         mov    ip,lr        ; keep lr somewhere safe
  243.         swi    "XPlayIt_BeginEnd"
  244.         movvss    pc,ip        ; immediate exit if error
  245.         RETPARR    r0,r2        ; if (r2) [r2]=r0
  246.         RETPARR    r1,r3        ; if (r3) [r3]=r1
  247.         mov    r0,#0        ; set a1=0 for no error
  248.         movs    pc,ip        ; return
  249.  
  250.  
  251. ; playit_error *xplayit_set_ptr(playit_frame frame, playit_frame *rframe)
  252.  
  253.         export    xplayit_set_ptr
  254. xplayit_set_ptr:
  255.         mov    ip,lr        ; keep lr somewhere safe
  256.         swi    "XPlayIt_SetPtr"
  257.         movvss    pc,ip        ; immediate exit if error
  258.         RETPARR    r0,r1        ; if (r1) [r1]=r0
  259.         mov    r0,#0        ; set a1=0 for no error
  260.         movs    pc,ip        ; return
  261.  
  262.  
  263. ; playit_error *xplayit_play(void)
  264.  
  265.         export    xplayit_play
  266. xplayit_play:
  267.         mov    ip,lr        ; keep lr somewhere safe
  268.         swi    "XPlayIt_Play"
  269.         movvc    r0,#0        ; set a1=0 for no error
  270.         movs    pc,ip        ; return
  271.  
  272.  
  273. ; playit_error *xplayit_stop(void);
  274.  
  275.         export    xplayit_stop
  276. xplayit_stop:
  277.         mov    ip,lr        ; keep lr somewhere safe
  278.         swi    "XPlayIt_Stop"
  279.         movvc    r0,#0        ; set a1=0 for no error
  280.         movs    pc,ip        ; return
  281.  
  282.  
  283. ; playit_error *xplayit_pause(void);
  284.  
  285.         export    xplayit_pause
  286. xplayit_pause:
  287.         mov    ip,lr        ; keep lr somewhere safe
  288.         swi    "XPlayIt_Pause"
  289.         movvc    r0,#0        ; set a1=0 for no error
  290.         movs    pc,ip        ; return
  291.  
  292.  
  293. ; playit_error *xplayit_balance(int balance, int *rbalance)
  294.  
  295.         export    xplayit_balance
  296. xplayit_balance:
  297.         mov    ip,lr        ; keep lr somewhere safe
  298.         swi    "XPlayIt_Balance"
  299.         movvss    pc,ip        ; immediate exit if error
  300.         RETPARR    r0,r1        ; if (r1) [r1]=r0
  301.         mov    r0,#0        ; set a1=0 for no error
  302.         movs    pc,ip        ; return
  303.  
  304.  
  305. ; playit_error *xplayit_pause_at(playit_frame frame, playit_frame *rframe)
  306.  
  307.         export    xplayit_pause_at
  308. xplayit_pause_at:
  309.         mov    ip,lr        ; keep lr somewhere safe
  310.         swi    "XPlayIt_PauseAt"
  311.         movvss    pc,ip        ; immediate exit if error
  312.         RETPARR    r0,r1        ; if (r1) [r1]=r0
  313.         mov    r0,#0        ; set a1=0 for no error
  314.         movs    pc,ip        ; return
  315.  
  316.  
  317. ; playit_error *xplayit_vu(int *left, int *right)
  318.  
  319.         export    xplayit_vu
  320. xplayit_vu:
  321.         mov    ip,lr        ; keep lr somewhere safe
  322.         mov    r2,r0
  323.         mov    r3,r1
  324.         swi    "XPlayIt_VU"
  325.         movvss    pc,ip        ; immediate exit if error
  326.         RETPARR    r0,r2        ; if (r2) [r2]=r0
  327.         RETPARR    r1,r3        ; if (r3) [r3]=r1
  328.         mov    r0,#0        ; set a1=0 for no error
  329.         movs    pc,ip        ; return
  330.  
  331.  
  332. ; playit_error *xplayit_list_drivers(int reason, char *dir, void *buffer, int idx, int buffsize,
  333. ;                                          int *num_read, int *idx_out);
  334.  
  335.         export    xplayit_list_drivers
  336. xplayit_list_drivers:
  337.         mov    ip,lr        ; keep lr somewhere safe
  338.         stmfd    sp!,{r4-r5}
  339.         mov    r4,r3
  340.         ldr    r5,[sp,#2*4]
  341.         swi    "XPlayIt_ListDrivers"
  342.         bvs    xplayit_list_drivers_X
  343.         RETPARS    r3,3
  344.         RETPARS    r4,4
  345. xplayit_list_drivers_X:
  346.         ldmfd    sp!,{r4-r5}
  347.         movvc    r0,#0        ; set a1=0 for no error
  348.         movs    pc,ip        ; return
  349.  
  350.  
  351. ; playit_error *xplayit_identify(const char *filename, playit_format *format, int *framerate,
  352. ;                                      int *bstart, int *bend, int *auxpar, int *numframes)
  353.  
  354.         export    xplayit_identify
  355. xplayit_identify:
  356.         mov    ip,lr        ; keep lr somewhere safe
  357.         stmfd    sp!,{r1-r3}    ; all 6 return parameters now on stack
  358.         stmfd    sp!,{r4-r6}    ;
  359.         swi    "XPlayIt_Identify"
  360.         bvs    xplayit_identify_X
  361.         RETPARR    r1,3
  362.         RETPARR    r2,4
  363.         RETPARR    r3,5
  364.         RETPARR    r4,6
  365.         RETPARR    r5,7
  366.         RETPARR    r6,8
  367. xplayit_identify_X:
  368.         ldmfd    sp!,{r4-r6}
  369.         add    sp,sp,#3*4    ; purge parameters
  370.         movvc    r0,#0        ; set a1=0 for no error
  371.         movs    pc,ip        ; return
  372.  
  373.  
  374. ; playit_error *xplayit_queue_add(const char *filename)
  375.  
  376.         export    xplayit_queue_add
  377. xplayit_queue_add:
  378.         mov    ip,lr        ; keep lr somewhere safe
  379.         mov    r1,r0
  380.         mov    r0,#0        ; reason code=0
  381.         swi    "XPlayIt_Queue"
  382.         movvc    r0,#0        ; set a1=0 for no error
  383.         movs    pc,ip        ; return
  384.  
  385.  
  386. ; playit_error *xplayit_queue_flush(void)
  387.  
  388.         export    xplayit_queue_flush
  389. xplayit_queue_flush:
  390.         mov    ip,lr        ; keep lr somewhere safe
  391.         mov    r0,#1        ; reason code=1
  392.         swi    "XPlayIt_Queue"
  393.         movvc    r0,#0        ; set a1=0 for no error
  394.         movs    pc,ip        ; return
  395.  
  396.  
  397. ; playit_error *xplayit_set_loop(playit_frame start, playit_frame stop, int count,
  398. ;                                      playit_frame *rstart, playit_frame *rstop)
  399.  
  400.         export    xplayit_set_loop
  401. xplayit_set_loop:
  402.         mov    ip,lr        ; keep lr somewhere safe
  403.         swi    "XPlayIt_SetLoop"
  404.         movvss    pc,ip        ; immediate exit if error
  405.         RETPARR    r0,r3        ; if (r3) [r3]=r0
  406.         RETPARS    r1,0        ; if (par5) (*par5)=r1
  407.         mov    r0,#0        ; set a1=0 for no error
  408.         movs    pc,ip        ; return
  409.  
  410.  
  411. ; playit_error *xplayit_file_info_format(char *filename, playit_sample_info *block)
  412.  
  413.         export    xplayit_file_info_format
  414. xplayit_file_info_format:
  415.         mov    ip,lr        ; keep lr somewhere safe
  416.         mov    r2,r1
  417.         mov    r1,r0        ; shuffle registers as required
  418.         mov    r0,#0        ; reason code=0
  419.         swi    "XPlayIt_FileInfo"
  420.         movvc    r0,#0        ; set a1=0 for no error
  421.         movs    pc,ip        ; return
  422.  
  423.  
  424. ; playit_error *xplayit_file_info_text(/*in*/char *filename, playit_text *block,
  425. ;                        int blocksize, playit_text_bits flags, /*out*/ int *nbytes);
  426.  
  427.         export    xplayit_file_info_text
  428. xplayit_file_info_text:
  429.         mov    ip,lr        ; keep lr somewhere safe
  430.         stmfd    sp!,{r4}
  431.         mov    r4,r3
  432.         mov    r3,r2
  433.         mov    r2,r1
  434.         mov    r1,r0        ; shuffle registers around
  435.         mov    r0,#1        ; reason code=1
  436.         swi    "XPlayIt_FileInfo"
  437.         bvs    xplayit_file_info_text_X
  438.         RETPARS    r3,1        ; if (par5) (*par5)=r3
  439. xplayit_file_info_text_X:
  440.         ldmfd    sp!,{r4}
  441.         movvc    r0,#0        ; set a1=0 for no error
  442.         movs    pc,ip        ; return
  443.  
  444.  
  445. ; playit_error *xplayit_file_info_filename(char **filename)
  446.  
  447.         export    xplayit_file_info_filename
  448. xplayit_file_info_filename:
  449.         mov    ip,lr        ; keep lr somewhere safe
  450.         mov    r2,r0
  451.         mov    r0,#2        ; reason code=2
  452.         swi    "XPlayIt_FileInfo"
  453.         movvss    pc,ip        ; immediate exit if error
  454.         RETPARR    r0,r2        ; if (r2) [r2]=r0
  455.         mov    r0,#0        ; set a1=0 for no error
  456.         movs    pc,ip        ; return
  457.  
  458.  
  459. ; playit_error *xplayit_clientop_register(/*in*/int flags, playit_eventbits events,
  460. ;                     /*out*/int **pollword)
  461.  
  462.         export    xplayit_clientop_register
  463. xplayit_clientop_register:
  464.         mov    ip,lr
  465.         mov    r3,r2        ; keep this where we can get it later
  466.         mov    r2,r1
  467.         mov    r1,r0
  468.         mov    r0,#0
  469.         swi    "XPlayIt_ClientOp"
  470.         movvss    pc,ip        ; immediate exit if error
  471.         RETPARR    r2,r3        ; if (r3) [r3]=r2
  472.         mov    r0,#0        ; set a1=0 for no error
  473.         movs    pc,ip        ; return
  474.  
  475.  
  476. ; playit_error *xplayit_clientop_deregister(/*in*/int *pollword, /*out*/int *num_registered)
  477.  
  478.         export    xplayit_clientop_deregister
  479. xplayit_clientop_deregister:
  480.         mov     ip,lr
  481.         mov    r3,r1        ; keep return par in r3 for a bit
  482.         mov    r2,r0        ; move pollword to r2
  483.         mov    r0,#1
  484.         swi    "XPlayIt_ClientOp"
  485.         movvss    pc,ip        ; immediate exit if error
  486.         RETPARR    r1,r3        ; if (r3) [r3]=r1
  487.         mov    r0,#0        ; set a1=0 for no error
  488.         movs    pc,ip        ; return
  489.