View previous topic :: View next topic |
Author |
Message |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Fri May 19, 2006 11:50 pm Post subject: a DMA routine for HuC |
|
|
Here's a small DMA routine for use with HuC. The PCE has a total of five DMA instructions - I actually didn't notice a fifth one until today
I made the interface C friendly. The instructions on it use are inside the DMA_RTN.h file. The destination can be anywhere - VDC, VCE, memory, SGX data port($0012), etc. You're not limited to global variables when assigning the parameters, but it's prefered for speed when used in loops.
The speed of the DMA is at ASM level since it's a block transfer instruction, but the arguement assigning is handled via the HuC compiler for flexibility and ease of use. If there is a need for a fast parameter setup in clock cycle resitrictive loops, let me know and I'll see what I can come up with.
Here's the file - http://pcedev.net/HuC/Dma_rtn.zip
-Rich
[Edit]
The DMA routine does not load BANK that contains the specific DATA pointed by routine.
For bandaid fix, do a each time in HuC to prime the bank, before using START_DMA() - until I can update the code.
If you use DMA_SRC=DATA right before START_DMA, you should be ok as this should cause HuC to load the corrosponding bank inwhich the DATA is pointed to.
[Edit]#2
DMA_SRC=DATA does not trigger the BANK switch - probably because it's a #define instead of a var. Use a global var to trigger the bank switch,i.e. force_bank=data[0]; . _________________ www.pcedev.net |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
Posted: Sat May 20, 2006 1:45 pm Post subject: |
|
|
What a coincidence! I too recently discovered the wonders of the block transfer instructions, and replaced some slow routines (sprite DMA) with fast ones for use with MagicKit.
Anyway, for reference to ASM people, since the TIA, TII, etc. instructions take hard coded values, the best way to use them is to have a subroutine that copies them to 8 bytes in RAM, so you can modify the instruction type, parameters, and then just JSR to this routine. Like so:
RAM_Routine:
TIA $SSSS,$DDDD,$LLLL
RTS _________________ http://www.chrismcovell.com |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Sat May 20, 2006 3:51 pm Post subject: |
|
|
Yup, a JSR to the code in ram .
I ended up using 12bytes since I need WORD alignment for ease of use with HuC.
BTW Chris, Do you know what address in ZP are reserved for the user? All my code functions/macros and libs in magickit were custom, so I didn't have to worry about ZP issues, but now that I'm using HuC(which compiles an S file using magickit) I not sure what address on the ZP are available to users by default?
-Rich _________________ www.pcedev.net |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Sat May 20, 2006 7:32 pm Post subject: |
|
|
Sorry, I was refering more to magickit than HuC.
Anyway, I figured it out. I just need to assign variables in the zerpage without the .org directive and after all the library functions are inlcuded and assigned.
Code: |
#asm
.zp
test1: .ds 1
#endasm
|
Still have a problem in that HuC can't read a variable name if it's delcared inside the ASM directive, so I just need to figure out how to setup variables in ZP for C.
***UPDATE***
I updated the file/zip. The old code used an array to house and access the parameters, which generated 315bytes of code for this..
Code: |
DMA_TYPE=TIA;
DMA_SRC=bg_chr;
DMA_DSTN=0x0012;
DMA_LEN=0x1200;
START_DMA();
|
I changed it to "INT a, b, c, d" which cut it down to 28bytes. Much faster
Btw, it looks like magickit lib already has a DMA routine loaded into ram, though it looks like its TIA only as the title load_vram suggest.
Code: |
792 ; ----
793 ; load_vram
794 ; ----
795 ; copy a block of memory to VRAM
796 ; ----
797 ; IN : _DI = VRAM location
798 ; _BL = data bank
799 ; _SI = data memory location
800 ; _CX = number of words to copy
801 ; ----
802 26CC .bss
803
804 ; This actually places a 'TIA' command
805 ; into RAM, from which to execute
806 ; for BLiT to VRAM for SATB transfer
807 ; and other VRAM load functions
808
809 --:26CC _ram_hdwr_tia .ds 1
810 --:26CD _ram_hdwr_tia_src .ds 2
811 --:26CF _ram_hdwr_tia_dest .ds 2
812 --:26D1 _ram_hdwr_tia_size .ds 2
813 --:26D3 _ram_hdwr_tia_rts .ds 1
|
_________________ www.pcedev.net |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|