DMA to screen functions works only on emulator
7 posts
• Page 1 of 1
- ProgrammerNerd
- Junior Member
- Posts: 17
- Joined: Mon Dec 16, 2013 6:50 am
- Calculators: Casio fx-CG10, Casio fx-CG50
DMA to screen functions works only on emulator
So I wrote a DMA to screen function based on code present in Simon docs. It works perfect on the emulator. However when I try it on real hardware my program is still response but nothing get drawn to the screen. Here is the code
If anyone is wondering why bother with this thinking "why not just use Bdisp_PutDisp_DD();"? The reason is because by having the function not block programs can do various calculations while drawing. This gives an easy increase in framerate. I recently wrote an mpeg2 player based on libmpeg2 the framerate is good already but I want to make it better. Also just to be clear my program does NOT modify 0xA8000000 while DMA'ing. Also my port of open jazz jackrabbit does not directly modify 0xA8000000 instead of has a 384*216 byte buffer and a palette buffer that holds the 16 bit color for that index value. So the next frame can be calculated while this one is being drawn. So in other words there are many practical applications for this and as such If you have any information about this topic I encourage you to help the community and remember it will benefit us all.[/list]
- Code: Select all
// Module Stop Register 0
#define MSTPCR0 (volatile unsigned *)0xA4150030
// DMA0 operation register
#define DMA0_DMAOR (volatile unsigned short*)0xFE008060
#define DMA0_SAR_0 (volatile unsigned *)0xFE008020
#define DMA0_DAR_0 (volatile unsigned *)0xFE008024
#define DMA0_TCR_0 (volatile unsigned *)0xFE008028
#define DMA0_CHCR_0 (volatile unsigned *)0xFE00802C
/* DMA register offsets
destination address register_0*/
//#define DAR_0 0x04
// transfer count register_0
//#define TCR_0 0x08
// channel control register_0
//#define CHCR_0 0x0C
#define LCD_BASE 0xB4000000
#define VRAM_ADDR 0xA8000000
#define SYNCO() __asm__ volatile("SYNCO\n\t":::"memory");
#define PRDR *(volatile unsigned char*)0xA405013C
#define LCDC *(volatile unsigned short*)0xB4000000
#define LCD_GRAM_X 0x200
#define LCD_GRAM_Y 0x201
#define LCD_GRAM 0x202
#define LCD_WINDOW_LEFT 0x210
#define LCD_WINDOW_RIGHT 0x211
#define LCD_WINDOW_TOP 0x212
#define LCD_WINDOW_BOTTOM 0x213
static void DmaWaitNext(void){
while(1){
if((*DMA0_CHCR_0)&2)//Transfer is done
break;
if((*DMA0_DMAOR)&4)//Address error has occured stop looping
break;
}
SYNCO();
*DMA0_CHCR_0&=~1;
*DMA0_DMAOR=0;
}
#define RS_AUTO_DMA (4<<8)
#define DMA_SRC_INC (1<<12)
#define TS_DMA_32_BYTES (1<<20)
#define TS_DMA_WORD (1<<3)
#define DMA_FIXED_ALWAYS (3<<14)
static void DoDMAlcdNonblock(void){
Bdisp_WriteDDRegister3_bit7(1);
Bdisp_DefineDMARange(6,389,0,215);
Bdisp_DDRegisterSelect(LCD_GRAM);
*MSTPCR0&=~(1<<21);//Clear bit 21
*DMA0_CHCR_0&=~1;//Disable DMA on channel 0
*DMA0_DMAOR=0;//Disable all DMA
*DMA0_SAR_0=VRAM_ADDR;//Source address is VRAM
*DMA0_DAR_0=LCD_BASE;//Desination is LCD
*DMA0_TCR_0=216*384/16;//Transfer count bytes/32
*DMA0_CHCR_0=RS_AUTO_DMA|DMA_SRC_INC|TS_DMA_32_BYTES;//0x00101400;//0000 0000 0001 0000 0001 0100 0000 0000
*DMA0_DMAOR&=~6;//Clear flags
*DMA0_DMAOR|=1;//Enable DMA on all channels
*DMA0_CHCR_0|=1;//Enable channel0 DMA
}
If anyone is wondering why bother with this thinking "why not just use Bdisp_PutDisp_DD();"? The reason is because by having the function not block programs can do various calculations while drawing. This gives an easy increase in framerate. I recently wrote an mpeg2 player based on libmpeg2 the framerate is good already but I want to make it better. Also just to be clear my program does NOT modify 0xA8000000 while DMA'ing. Also my port of open jazz jackrabbit does not directly modify 0xA8000000 instead of has a 384*216 byte buffer and a palette buffer that holds the 16 bit color for that index value. So the next frame can be calculated while this one is being drawn. So in other words there are many practical applications for this and as such If you have any information about this topic I encourage you to help the community and remember it will benefit us all.[/list]
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: DMA to screen functions works only on emulator
Could you post the part of the LST-file in the vicinity of SYNCO().
I'll be back!
- ProgrammerNerd
- Junior Member
- Posts: 17
- Joined: Mon Dec 16, 2013 6:50 am
- Calculators: Casio fx-CG10, Casio fx-CG50
Re: DMA to screen functions works only on emulator
Alright. Objdump outputted quite a mess so I used IDA pro.
Here is both functions
Here is both functions
- Code: Select all
.text:00310F5E loc_310F5E: ; CODE XREF: _main+886j
.text:00310F5E ; _main+C58j
.text:00310F5E mov.l #_Bdisp_WriteDDRegister3_bit7, r2
.text:00310F60 jsr @r2 ; _Bdisp_WriteDDRegister3_bit7
.text:00310F62 mov #1, r4
.text:00310F64 mov.l #_Bdisp_DefineDMARange, r3
.text:00310F66 mov #6, r4
.text:00310F68 mov.w #h'D7, r7
.text:00310F6A mov.w #h'185, r5
.text:00310F6C jsr @r3 ; _Bdisp_DefineDMARange
.text:00310F6E mov #0, r6
.text:00310F70 mov.l #_Bdisp_DDRegisterSelect, r6
.text:00310F72 mov.w #h'202, r4
.text:00310F74 jsr @r6 ; _Bdisp_DDRegisterSelect
.text:00310F76 nop
.text:00310F78 mov.l #h'A4150030, r2
.text:00310F7A mov.l #h'FFDFFFFF, r3
.text:00310F7C mov.l @r2, r1
.text:00310F7E mov.l #h'A8000000, r7
.text:00310F80 and r3, r1
.text:00310F82 mov.l r1, @r2
.text:00310F84 mov #h'FFFFFFFE, r3
.text:00310F86 mov.l #h'FE00802C, r1
.text:00310F88 mov.l @r1, r2
.text:00310F8A and r3, r2
.text:00310F8C mov.l r2, @r1
.text:00310F8E mov #0, r3
.text:00310F90 mov.l #h'FE008060, r2
.text:00310F92 mov.w r3, @r2
.text:00310F94 mov.l #h'FE008020, r3
.text:00310F96 mov.l r7, @r3
.text:00310F98 mov.l #h'B4000000, r7
.text:00310F9A mov.l r7, @(4,r3)
.text:00310F9C mov.w #h'1440, r7
.text:00310F9E mov.l r7, @(8,r3)
.text:00310FA0 mov.l #h'101400, r3
.text:00310FA2 mov.l r3, @r1
.text:00310FA4 mov.w @r2, r7
.text:00310FA6 mov.l #h'FFF9, r3
.text:00310FA8 and r7, r3
.text:00310FAA mov.w r3, @r2
.text:00310FAC mov.w @r2, r0
.text:00310FAE extu.w r0, r0
.text:00310FB0 or #1, r0
.text:00310FB2 mov.w r0, @r2
.text:00310FB4 mov.l @r1, r0
.text:00310FB6 or #1, r0
.text:00310FB8 mov.l r0, @r1
.text:00310FBA bra loc_31101E
.text:00310FBC nop
.text:00310FBC ; ---------------------------------------------------------------------------
.text:00310FBE word_310FBE: .data.w h'180 ; DATA XREF: _main+826r
.text:00310FC0 word_310FC0: .data.w h'D8 ; DATA XREF: _main+834r
.text:00310FC2 word_310FC2: .data.w h'D7 ; DATA XREF: _main+924r
.text:00310FC4 word_310FC4: .data.w h'185 ; DATA XREF: _main+926r
.text:00310FC6 word_310FC6: .data.w h'202 ; DATA XREF: _main+92Er
.text:00310FC8 word_310FC8: .data.w h'1440 ; DATA XREF: _main+958r
.text:00310FCA .align 4
.text:00310FCC off_310FCC: .data.l _RTC_GetTicks ; DATA XREF: _main:loc_310E56r
.text:00310FCC ; _main+81Cr
.text:00310FD0 off_310FD0: .data.l ___sdivsi3_i4i ; DATA XREF: _main:loc_310E8Er
.text:00310FD4 dword_310FD4: .data.l h'1800000 ; DATA XREF: _main+84Cr
.text:00310FD8 dword_310FD8: .data.l h'D80000 ; DATA XREF: _main+852r
.text:00310FDC dword_310FDC: .data.l h'2AAAAAAB ; DATA XREF: _main+88Ar
.text:00310FE0 dword_310FE0: .data.l h'54000000 ; DATA XREF: _main+8BEr
.text:00310FE4 dword_310FE4: .data.l h'80000000 ; DATA XREF: _main+8DEr
.text:00310FE8 off_310FE8: .data.l _Bdisp_WriteDDRegister3_bit7
.text:00310FE8 ; DATA XREF: _main:loc_310F5Er
.text:00310FEC off_310FEC: .data.l _Bdisp_DefineDMARange ; DATA XREF: _main+920r
.text:00310FF0 off_310FF0: .data.l _Bdisp_DDRegisterSelect ; DATA XREF: _main+92Cr
.text:00310FF4 dword_310FF4: .data.l h'A4150030 ; DATA XREF: _main+934r
.text:00310FF8 dword_310FF8: .data.l h'FFDFFFFF ; DATA XREF: _main+936r
.text:00310FFC dword_310FFC: .data.l h'A8000000 ; DATA XREF: _main+93Ar
.text:00311000 dword_311000: .data.l h'FE00802C ; DATA XREF: _main+942r
.text:00311004 dword_311004: .data.l h'FE008060 ; DATA XREF: _main+94Cr
.text:00311008 dword_311008: .data.l h'FE008020 ; DATA XREF: _main+950r
.text:0031100C dword_31100C: .data.l h'B4000000 ; DATA XREF: _main+954r
.text:00311010 dword_311010: .data.l h'101400 ; DATA XREF: _main+95Cr
.text:00311014 dword_311014: .data.l h'FFF9 ; DATA XREF: _main+962r
.text:00311018 ; ---------------------------------------------------------------------------
.text:00311018
.text:00311018 loc_311018: ; CODE XREF: _main+9DEj
.text:00311018 mov.w @r2, r0
.text:0031101A tst #4, r0
.text:0031101C bf loc_311024
.text:0031101E
.text:0031101E loc_31101E: ; CODE XREF: _main+976j
.text:0031101E mov.l @r1, r0
.text:00311020 tst #2, r0
.text:00311022 bt loc_311018
.text:00311024
.text:00311024 loc_311024: ; CODE XREF: _main+9D8j
.text:00311024 synco
.text:00311026 mov.l #h'FE00802C, r2
.text:00311028 mov #h'FFFFFFFE, r3
.text:0031102A mov.l @r2, r1
.text:0031102C and r3, r1
.text:0031102E mov.l r1, @r2
.text:00311030 mov #0, r2
.text:00311032 mov.l #h'FE008060, r1
.text:00311034 mov.w r2, @r1
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: DMA to screen functions works only on emulator
I just had a look to my docs.
The code pieces are slightly different.
Though they are logically equal, I'd try the original order of the statements.
- Code: Select all
?DMA_end_hook:
mov.l @(CHCR_0,r14), r0 ; DMA0_CHCR_0
tst #2, r0 ; TE Transfer End Flag
bf/s ?DMA_quit
mov.l r0, @(h'C,r15)
mov.w @r13, r0 ; DMA0_DMAOR
and #4, r0 ; AE Address Error Flag
cmp/pl r0
bf ?DMA_loop
?DMA_quit: SYNCO
; wait loop end
- Code: Select all
.text:00311018 loc_311018: ; CODE XREF: _main+9DEj
.text:00311018 mov.w @r2, r0
.text:0031101A tst #4, r0
.text:0031101C bf loc_311024
.text:0031101E
.text:0031101E loc_31101E: ; CODE XREF: _main+976j
.text:0031101E mov.l @r1, r0
.text:00311020 tst #2, r0
.text:00311022 bt loc_311018
.text:00311024
.text:00311024 loc_311024: ; CODE XREF: _main+9D8j
.text:00311024 synco
The code pieces are slightly different.
Though they are logically equal, I'd try the original order of the statements.
I'll be back!
- ProgrammerNerd
- Junior Member
- Posts: 17
- Joined: Mon Dec 16, 2013 6:50 am
- Calculators: Casio fx-CG10, Casio fx-CG50
Re: DMA to screen functions works only on emulator
I tried that and it did not work. I am not sure of the cause. The reason I re-wrote the function in C is because I could not yours to assemble with GAS. The syntax is different. I though it would be cleaner to rewrite it in C since more people can understand it. When you assembled your function did it work on real hardware?
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: DMA to screen functions works only on emulator
Yes, I do not use any emulator. I just checked it on one of my Prizms.ProgrammerNerd wrote:When you assembled your function did it work on real hardware?
I'll be back!
- ProgrammerNerd
- Junior Member
- Posts: 17
- Joined: Mon Dec 16, 2013 6:50 am
- Calculators: Casio fx-CG10, Casio fx-CG50
Re: DMA to screen functions works only on emulator
I fixed long ago I just forgot to update my post sorry about that the real problem was the bitmask was wrong.
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests