Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: I need a help, about -- blit.c / win_perform_blit()  (Read 1501 times)

0 Members and 1 Guest are viewing this topic.

Terry Bogard

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:June 23, 2005, 12:12:08 am
  • I want to build my own arcade controls!
I need a help, about -- blit.c / win_perform_blit()
« on: June 20, 2005, 01:51:03 pm »
I want repot MAME 0.96 to Pocket PC, when I ready start artwork, a trouble hitted me

Here's the function at the blit.c...

int win_perform_blit(const struct win_blit_params *blit, int update)
{
...

// copy data to the globals
asmblit_srcdata = (UINT8 *)blit->srcdata + blit->srcpitch * srcy + srcdepth * srcx;
asmblit_srcheight = blit->srcheight;
asmblit_srclookup = blit->srclookup;

asmblit_dstdata = (UINT8 *)blit->dstdata + blit->dstpitch * blit->dstyoffs + dstdepth * blit->dstxoffs;
asmblit_dstpitch = blit->dstpitch;

// pick the blitter
blitter = update ? (blitter_func)active_update_blitter : (blitter_func)active_fast_blitter;
(*blitter)();

...
}

asmblit_xxx defined at asmblit.asm, it's X86 ASM, you konw, ARM CPU can't use it.

So I need rewrite win_perform_blit use strandard C, but I don't understand the win_perform_blit how to work -__-

win_perform_blit make a mame_bitmap to display DIB? Who can tell me this function's algorithm ? or I can find a other way?

Thanks!

PacManFan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 858
  • Last login:December 06, 2005, 12:18:56 pm
    • Kymaera Home Page
Re: I need a help, about -- blit.c / win_perform_blit()
« Reply #1 on: June 20, 2005, 01:57:13 pm »
Hey, you need to just rewrite this in c using a loop, it's just a memory copy operation.

int win_perform_blit(const struct win_blit_params *blit, int update)
{
...

// copy data to the globals
asmblit_srcdata = (UINT8 *)blit->srcdata + blit->srcpitch * srcy + srcdepth * srcx;
asmblit_srcheight = blit->srcheight;
asmblit_srclookup = blit->srclookup;

asmblit_dstdata = (UINT8 *)blit->dstdata + blit->dstpitch * blit->dstyoffs + dstdepth * blit->dstxoffs;
asmblit_dstpitch = blit->dstpitch;

// pick the blitter
//blitter = update ? (blitter_func)active_update_blitter : //(blitter_func)active_fast_blitter;
//(*blitter)();

...

int c;
UINT8 * src = asmblit_srcdata;
UINT8 * dst= asmblit_dstdata;

for (c = 0;c<asmblit_srcheight;c++){
     memcpy(dst,src,blit->dstpitch);
     src += blit->srcpitch;
     dst += blit->dstpitch;
}

}

hope this helps.

-PMF
All Hail Smezznar! The Giant purple centipede of Omnicron 5. Regail him with your odiferous offerings of onion powder!

Terry Bogard

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:June 23, 2005, 12:12:08 am
  • I want to build my own arcade controls!
Re: I need a help, about -- blit.c / win_perform_blit()
« Reply #2 on: June 21, 2005, 10:44:46 am »
Thank you a lot!

But if I change it to your code, Mame display a black screen

 int win_perform_blit(const struct win_blit_params *blit, int update)
{
...

// copy data to the globals
asmblit_srcdata = (UINT8 *)blit->srcdata + blit->srcpitch * srcy + srcdepth * srcx;
asmblit_srcheight = blit->srcheight;
asmblit_srclookup = blit->srclookup;

asmblit_dstdata = (UINT8 *)blit->dstdata + blit->dstpitch * blit->dstyoffs + dstdepth * blit->dstxoffs;
asmblit_dstpitch = blit->dstpitch;

// pick the blitter
//blitter = update ? (blitter_func)active_update_blitter : //(blitter_func)active_fast_blitter;
//(*blitter)();

...

int c;
UINT8 * src = asmblit_srcdata;
UINT8 * dst= asmblit_dstdata;

for (c = 0;c<asmblit_srcheight;c++){
     memcpy(dst,src,blit->dstpitch);
     src += blit->srcpitch;
     dst += blit->dstpitch;
}

return 1;
}

if I add this code, it crush... :'(

int win_perform_blit(const struct win_blit_params *blit, int update)
{
...

// copy data to the globals
asmblit_srcdata = (UINT8 *)blit->srcdata + blit->srcpitch * srcy + srcdepth * srcx;
asmblit_srcheight = blit->srcheight;
asmblit_srclookup = blit->srclookup;

asmblit_dstdata = (UINT8 *)blit->dstdata + blit->dstpitch * blit->dstyoffs + dstdepth * blit->dstxoffs;
asmblit_dstpitch = blit->dstpitch;

// pick the blitter
//blitter = update ? (blitter_func)active_update_blitter : //(blitter_func)active_fast_blitter;
//(*blitter)();

...

int c;
UINT8 * src = asmblit_srcdata;
UINT8 * dst= asmblit_dstdata;

for (c = 0;c<asmblit_srcheight;c++){
     memcpy(dst,src,blit->dstpitch);
     src += blit->srcpitch;
     dst += blit->dstpitch;
}

// pick the blitter
blitter = update ? (blitter_func)active_update_blitter : (blitter_func)active_fast_blitter;
(*blitter)();

return 1;
}

What happened? blitter_func can't find dst's data?

BTW:Have any documents depict how to conversion mame_bitmap to display bitmap?

Thank you again!

PacManFan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 858
  • Last login:December 06, 2005, 12:18:56 pm
    • Kymaera Home Page
Re: I need a help, about -- blit.c / win_perform_blit()
« Reply #3 on: June 21, 2005, 10:56:15 am »
get rid of the:

// pick the blitter
blitter = update ? (blitter_func)active_update_blitter : (blitter_func)active_fast_blitter;
(*blitter)();

the code I wrote IS the blitter. however I should note that it only works if the srcdepth == dstdepth. If srcdepth != dstdepth, you need to do a color conversion.

Set a breakpoint on the:
for (c = 0;c<asmblit_srcheight;c++){
     memcpy(dst,src,blit->dstpitch);
     src += blit->srcpitch;
     dst += blit->dstpitch;
}

and look and see what the data is in the src blocks.

Also, check and see if you need to do a pageflip. That might be why it's black, it hasn't been copied to the current visible page.

-PMF


You might want to dig into the mame bitmap structure to see what it looks like. You could also try to use the CopyToDibsSection function to do the blit.

-PMF
All Hail Smezznar! The Giant purple centipede of Omnicron 5. Regail him with your odiferous offerings of onion powder!

Terry Bogard

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:June 23, 2005, 12:12:08 am
  • I want to build my own arcade controls!
Re: I need a help, about -- blit.c / win_perform_blit()
« Reply #4 on: June 21, 2005, 11:30:38 am »
Ok, at dib_draw_window functions, I watch mame_bitmap's data, it like this:

bitmap->width = 512;
bitmap->high = 256;
bitmap->depth = 16;

after win_perform_blit, it switch to a 320*224*16(555) bitmap save at converted_bitmap

I try write mame_bitmap and converted_bitmap to disk, converted_bitmap is correct, mame_bitmap is out-of-order, it like a tilemap...and at asmblit.asm, I note have a palette be load at here...

So, I don't think mame_bitmap is a strandard DIBBitmap
« Last Edit: June 21, 2005, 11:36:17 am by Terry Bogard »