MAMEWorld >> EmuChat
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

krick
Get Fuzzy
Reged: 02/09/04
Posts: 4235
Send PM
Re: MAME's Output
12/12/11 12:08 AM


Looking at the source for rendlay.c, you definitely have the order correct. The representation is an 8-bit bitmap where a one indicates an "on" segment. The first seven bits represent the segments you've identified, while the eighth bit is used for a decimal point segment.


Code:

//-------------------------------------------------
// draw_led7seg - draw a 7-segment LCD
//-------------------------------------------------

void layout_element::component::draw_led7seg(bitmap_t &dest, const rectangle &bounds, int pattern)
{
const rgb_t onpen = MAKE_ARGB(0xff,0xff,0xff,0xff);
const rgb_t offpen = MAKE_ARGB(0xff,0x20,0x20,0x20);

// sizes for computation
int bmwidth = 250;
int bmheight = 400;
int segwidth = 40;
int skewwidth = 40;

// allocate a temporary bitmap for drawing
bitmap_t *tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32));
bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff,0x00,0x00,0x00));

// top bar
draw_segment_horizontal(*tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 0)) ? onpen : offpen);

// top-right bar
draw_segment_vertical(*tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 1)) ? onpen : offpen);

// bottom-right bar
draw_segment_vertical(*tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, bmwidth - segwidth/2, segwidth, (pattern & (1 << 2)) ? onpen : offpen);

// bottom bar
draw_segment_horizontal(*tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight - segwidth/2, segwidth, (pattern & (1 << 3)) ? onpen : offpen);

// bottom-left bar
draw_segment_vertical(*tempbitmap, bmheight/2 + segwidth/3, bmheight - 2*segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 4)) ? onpen : offpen);

// top-left bar
draw_segment_vertical(*tempbitmap, 0 + 2*segwidth/3, bmheight/2 - segwidth/3, 0 + segwidth/2, segwidth, (pattern & (1 << 5)) ? onpen : offpen);

// middle bar
draw_segment_horizontal(*tempbitmap, 0 + 2*segwidth/3, bmwidth - 2*segwidth/3, bmheight/2, segwidth, (pattern & (1 << 6)) ? onpen : offpen);

// apply skew
apply_skew(*tempbitmap, 40);

// decimal point
draw_segment_decimal(*tempbitmap, bmwidth + segwidth/2, bmheight - segwidth/2, segwidth, (pattern & (1 << 7)) ? onpen : offpen);

// resample to the target size
render_resample_argb_bitmap_hq(dest.base, dest.rowpixels, dest.width, dest.height, tempbitmap, NULL, &m_color);

global_free(tempbitmap);
}




GroovyMAME support forum on BYOAC







Entire thread
Subject Posted by Posted on
* MAME's Output Naoki 12/11/11 11:03 PM
. * Re: MAME's Output Naoki  12/11/11 11:20 PM
. * Re: MAME's Output krick  12/12/11 12:08 AM
. * Re: MAME's Output Naoki  12/12/11 12:30 AM
. * Re: MAME's Output krick  12/12/11 02:04 AM
. * Re: MAME's Output Naoki  12/12/11 02:10 AM
. * Re: MAME's Output RetroRepair  12/15/11 04:36 PM
. * Re: MAME's Output Naoki  12/12/11 01:07 AM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 464 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 1814