From 59825952f3d98d29e03b094642655968d7abcc02 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 16 Nov 2005 22:59:28 +0000 Subject: Rockboy: adapted to colour LCD (but no colours for gameboy color games yet). Some cleanup; killed a ton of TABs. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7915 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/rockboy/lcd-gb.h | 10 +- apps/plugins/rockboy/lcd.c | 878 +++++++++++++++++++------------------ apps/plugins/rockboy/main.c | 5 + apps/plugins/rockboy/sys_rockbox.c | 76 ++-- 4 files changed, 483 insertions(+), 486 deletions(-) diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h index 0b863b6eea..14d7ee49e0 100644 --- a/apps/plugins/rockboy/lcd-gb.h +++ b/apps/plugins/rockboy/lcd-gb.h @@ -16,10 +16,12 @@ struct scan { int bg[64]; int wnd[64]; -#if LCD_DEPTH == 2 - byte buf[4][256]; -#else - byte buf[8][256]; +#if LCD_DEPTH == 1 + byte buf[8][256]; +#elif LCD_DEPTH == 2 + byte buf[4][256]; +#elif LCD_DEPTH > 4 + byte buf[1][256]; #endif byte pal1[128]; un16 pal2[64]; diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c index 872311d0e6..a8f8c695da 100644 --- a/apps/plugins/rockboy/lcd.c +++ b/apps/plugins/rockboy/lcd.c @@ -99,21 +99,21 @@ static byte *vdest; #ifndef ASM_UPDATEPATPIX void updatepatpix(void) { - int i, j; + int i, j; #if ((CONFIG_CPU != SH7034) && (CONFIG_CPU != MCF5249)) || defined(SIMULATOR) - int k, a, c; + int k, a, c; #endif - byte *vram = lcd.vbank[0]; - - if (!anydirty) return; - for (i = 0; i < 1024; i++) - { - if (i == 384) i = 512; - if (i == 896) break; - if (!patdirty[i]) continue; - patdirty[i] = 0; - for (j = 0; j < 8; j++) - { + byte *vram = lcd.vbank[0]; + + if (!anydirty) return; + for (i = 0; i < 1024; i++) + { + if (i == 384) i = 512; + if (i == 896) break; + if (!patdirty[i]) continue; + patdirty[i] = 0; + for (j = 0; j < 8; j++) + { #if CONFIG_CPU == SH7034 && !defined(SIMULATOR) asm volatile ( "mov.w @%2,r1 \n" @@ -248,18 +248,18 @@ void updatepatpix(void) "d0", "d1", "d2" ); #else - a = ((i<<4) | (j<<1)); - for (k = 0; k < 8; k++) - { - c = vram[a] & (1<> 3) + 1; - - if (hw.cgb) { - if (R_LCDC & 0x10) - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = *tilemap - | (((int)*attrmap & 0x08) << 6) - | (((int)*attrmap & 0x60) << 5); - *(tilebuf++) = (((int)*attrmap & 0x07) << 2); - attrmap += *wrap + 1; - tilemap += *(wrap++) + 1; - } - else - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = (256 + ((n8)*tilemap)) - | (((int)*attrmap & 0x08) << 6) - | (((int)*attrmap & 0x60) << 5); - *(tilebuf++) = (((int)*attrmap & 0x07) << 2); - attrmap += *wrap + 1; - tilemap += *(wrap++) + 1; - } - } - else - { - if (R_LCDC & 0x10) - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = *(tilemap++); - tilemap += *(wrap++); - } - else - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = (256 + ((n8)*(tilemap++))); - tilemap += *(wrap++); - } - } - - if (WX >= 160) return; - - base = ((R_LCDC&0x40)?0x1C00:0x1800) + (WT<<5); - tilemap = lcd.vbank[0] + base; - attrmap = lcd.vbank[1] + base; - tilebuf = WND; - cnt = ((160 - WX) >> 3) + 1; - - if (hw.cgb) - { - if (R_LCDC & 0x10) - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = *(tilemap++) - | (((int)*attrmap & 0x08) << 6) - | (((int)*attrmap & 0x60) << 5); - *(tilebuf++) = (((int)*(attrmap++)&7) << 2); - } - else - for (i = cnt; i > 0; i--) - { - *(tilebuf++) = (256 + ((n8)*(tilemap++))) - | (((int)*attrmap & 0x08) << 6) - | (((int)*attrmap & 0x60) << 5); - *(tilebuf++) = (((int)*(attrmap++)&7) << 2); - } - } - else - - { - if (R_LCDC & 0x10) - for (i = cnt; i > 0; i--) - *(tilebuf++) = *(tilemap++); - else - for (i = cnt; i > 0; i--) - *(tilebuf++) = (256 + ((n8)*(tilemap++))); - } + int i, cnt; + int base; + byte *tilemap, *attrmap; + int *tilebuf; + int *wrap; + static int wraptable[64] = + { + 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-32 + }; + + base = ((R_LCDC&0x08)?0x1C00:0x1800) + (T<<5) + S; + tilemap = lcd.vbank[0] + base; + attrmap = lcd.vbank[1] + base; + tilebuf = BG; + wrap = wraptable + S; + cnt = ((WX + 7) >> 3) + 1; + + if (hw.cgb) { + if (R_LCDC & 0x10) + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = *tilemap + | (((int)*attrmap & 0x08) << 6) + | (((int)*attrmap & 0x60) << 5); + *(tilebuf++) = (((int)*attrmap & 0x07) << 2); + attrmap += *wrap + 1; + tilemap += *(wrap++) + 1; + } + else + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = (256 + ((n8)*tilemap)) + | (((int)*attrmap & 0x08) << 6) + | (((int)*attrmap & 0x60) << 5); + *(tilebuf++) = (((int)*attrmap & 0x07) << 2); + attrmap += *wrap + 1; + tilemap += *(wrap++) + 1; + } + } + else + { + if (R_LCDC & 0x10) + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = *(tilemap++); + tilemap += *(wrap++); + } + else + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = (256 + ((n8)*(tilemap++))); + tilemap += *(wrap++); + } + } + + if (WX >= 160) return; + + base = ((R_LCDC&0x40)?0x1C00:0x1800) + (WT<<5); + tilemap = lcd.vbank[0] + base; + attrmap = lcd.vbank[1] + base; + tilebuf = WND; + cnt = ((160 - WX) >> 3) + 1; + + if (hw.cgb) + { + if (R_LCDC & 0x10) + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = *(tilemap++) + | (((int)*attrmap & 0x08) << 6) + | (((int)*attrmap & 0x60) << 5); + *(tilebuf++) = (((int)*(attrmap++)&7) << 2); + } + else + for (i = cnt; i > 0; i--) + { + *(tilebuf++) = (256 + ((n8)*(tilemap++))) + | (((int)*attrmap & 0x08) << 6) + | (((int)*attrmap & 0x60) << 5); + *(tilebuf++) = (((int)*(attrmap++)&7) << 2); + } + } + else + + { + if (R_LCDC & 0x10) + for (i = cnt; i > 0; i--) + *(tilebuf++) = *(tilemap++); + else + for (i = cnt; i > 0; i--) + *(tilebuf++) = (256 + ((n8)*(tilemap++))); + } } @@ -507,318 +507,318 @@ void tilebuf(void) // U = start...something...thingy... 7 at most void bg_scan(void) { - int cnt; - byte *src, *dest; - int *tile; - - if (WX <= 0) return; - cnt = WX; - tile = BG; - dest = BUF; - - src = patpix[*(tile++)][V] + U; - memcpy(dest, src, 8-U); - dest += 8-U; - cnt -= 8-U; - if (cnt <= 0) return; - while (cnt >= 8) - { - src = patpix[*(tile++)][V]; - MEMCPY8(dest, src); - dest += 8; - cnt -= 8; - } - src = patpix[*tile][V]; - while (cnt--) - *(dest++) = *(src++); + int cnt; + byte *src, *dest; + int *tile; + + if (WX <= 0) return; + cnt = WX; + tile = BG; + dest = BUF; + + src = patpix[*(tile++)][V] + U; + memcpy(dest, src, 8-U); + dest += 8-U; + cnt -= 8-U; + if (cnt <= 0) return; + while (cnt >= 8) + { + src = patpix[*(tile++)][V]; + MEMCPY8(dest, src); + dest += 8; + cnt -= 8; + } + src = patpix[*tile][V]; + while (cnt--) + *(dest++) = *(src++); } void wnd_scan(void) { - int cnt; - byte *src, *dest; - int *tile; - - if (WX >= 160) return; - cnt = 160 - WX; - tile = WND; - dest = BUF + WX; - - while (cnt >= 8) - { - src = patpix[*(tile++)][WV]; - MEMCPY8(dest, src); - dest += 8; - cnt -= 8; - } - src = patpix[*tile][WV]; - while (cnt--) - *(dest++) = *(src++); + int cnt; + byte *src, *dest; + int *tile; + + if (WX >= 160) return; + cnt = 160 - WX; + tile = WND; + dest = BUF + WX; + + while (cnt >= 8) + { + src = patpix[*(tile++)][WV]; + MEMCPY8(dest, src); + dest += 8; + cnt -= 8; + } + src = patpix[*tile][WV]; + while (cnt--) + *(dest++) = *(src++); } static void blendcpy(byte *dest, byte *src, byte b, int cnt) { - while (cnt--) *(dest++) = *(src++) | b; + while (cnt--) *(dest++) = *(src++) | b; } static int priused(void *attr) { - un32 *a = attr; - return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080); + un32 *a = attr; + return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080); } void bg_scan_pri(void) { - int cnt, i; - byte *src, *dest; - - if (WX <= 0) return; - i = S; - cnt = WX; - dest = PRI; - src = lcd.vbank[1] + ((R_LCDC&0x08)?0x1C00:0x1800) + (T<<5); - - if (!priused(src)) - { - memset(dest, 0, cnt); - return; - } - - memset(dest, src[i++&31]&128, 8-U); - dest += 8-U; - cnt -= 8-U; - if (cnt <= 0) return; - while (cnt >= 8) - { - memset(dest, src[i++&31]&128, 8); - dest += 8; - cnt -= 8; - } - memset(dest, src[i&31]&128, cnt); + int cnt, i; + byte *src, *dest; + + if (WX <= 0) return; + i = S; + cnt = WX; + dest = PRI; + src = lcd.vbank[1] + ((R_LCDC&0x08)?0x1C00:0x1800) + (T<<5); + + if (!priused(src)) + { + memset(dest, 0, cnt); + return; + } + + memset(dest, src[i++&31]&128, 8-U); + dest += 8-U; + cnt -= 8-U; + if (cnt <= 0) return; + while (cnt >= 8) + { + memset(dest, src[i++&31]&128, 8); + dest += 8; + cnt -= 8; + } + memset(dest, src[i&31]&128, cnt); } void wnd_scan_pri(void) { - int cnt, i; - byte *src, *dest; - - if (WX >= 160) return; - i = 0; - cnt = 160 - WX; - dest = PRI + WX; - src = lcd.vbank[1] + ((R_LCDC&0x40)?0x1C00:0x1800) + (WT<<5); - - if (!priused(src)) - { - memset(dest, 0, cnt); - return; - } - - while (cnt >= 8) - { - memset(dest, src[i++]&128, 8); - dest += 8; - cnt -= 8; - } - memset(dest, src[i]&128, cnt); + int cnt, i; + byte *src, *dest; + + if (WX >= 160) return; + i = 0; + cnt = 160 - WX; + dest = PRI + WX; + src = lcd.vbank[1] + ((R_LCDC&0x40)?0x1C00:0x1800) + (WT<<5); + + if (!priused(src)) + { + memset(dest, 0, cnt); + return; + } + + while (cnt >= 8) + { + memset(dest, src[i++]&128, 8); + dest += 8; + cnt -= 8; + } + memset(dest, src[i]&128, cnt); } void bg_scan_color(void) { - int cnt; - byte *src, *dest; - int *tile; - - if (WX <= 0) return; - cnt = WX; - tile = BG; - dest = BUF; - - src = patpix[*(tile++)][V] + U; - blendcpy(dest, src, *(tile++), 8-U); - dest += 8-U; - cnt -= 8-U; - if (cnt <= 0) return; - while (cnt >= 8) - { - src = patpix[*(tile++)][V]; - blendcpy(dest, src, *(tile++), 8); - dest += 8; - cnt -= 8; - } - src = patpix[*(tile++)][V]; - blendcpy(dest, src, *(tile++), cnt); + int cnt; + byte *src, *dest; + int *tile; + + if (WX <= 0) return; + cnt = WX; + tile = BG; + dest = BUF; + + src = patpix[*(tile++)][V] + U; + blendcpy(dest, src, *(tile++), 8-U); + dest += 8-U; + cnt -= 8-U; + if (cnt <= 0) return; + while (cnt >= 8) + { + src = patpix[*(tile++)][V]; + blendcpy(dest, src, *(tile++), 8); + dest += 8; + cnt -= 8; + } + src = patpix[*(tile++)][V]; + blendcpy(dest, src, *(tile++), cnt); } void wnd_scan_color(void) { - int cnt; - byte *src, *dest; - int *tile; - - if (WX >= 160) return; - cnt = 160 - WX; - tile = WND; - dest = BUF + WX; - - while (cnt >= 8) - { - src = patpix[*(tile++)][WV]; - blendcpy(dest, src, *(tile++), 8); - dest += 8; - cnt -= 8; - } - src = patpix[*(tile++)][WV]; - blendcpy(dest, src, *(tile++), cnt); + int cnt; + byte *src, *dest; + int *tile; + + if (WX >= 160) return; + cnt = 160 - WX; + tile = WND; + dest = BUF + WX; + + while (cnt >= 8) + { + src = patpix[*(tile++)][WV]; + blendcpy(dest, src, *(tile++), 8); + dest += 8; + cnt -= 8; + } + src = patpix[*(tile++)][WV]; + blendcpy(dest, src, *(tile++), cnt); } static void recolor(byte *buf, byte fill, int cnt) { - while (cnt--) *(buf++) |= fill; + while (cnt--) *(buf++) |= fill; } void spr_count(void) { - int i; - struct obj *o; - - NS = 0; - if (!(R_LCDC & 0x02)) return; - - o = lcd.oam.obj; - - for (i = 40; i; i--, o++) - { - if (L >= o->y || L + 16 < o->y) - continue; - if (L + 8 >= o->y && !(R_LCDC & 0x04)) - continue; - if (++NS == 10) break; - } + int i; + struct obj *o; + + NS = 0; + if (!(R_LCDC & 0x02)) return; + + o = lcd.oam.obj; + + for (i = 40; i; i--, o++) + { + if (L >= o->y || L + 16 < o->y) + continue; + if (L + 8 >= o->y && !(R_LCDC & 0x04)) + continue; + if (++NS == 10) break; + } } void spr_enum(void) { - int i, j; - struct obj *o; - struct vissprite ts[10]; - int v, pat; - int l, x; - - NS = 0; - if (!(R_LCDC & 0x02)) return; - - o = lcd.oam.obj; - - for (i = 40; i; i--, o++) - { - if (L >= o->y || L + 16 < o->y) - continue; - if (L + 8 >= o->y && !(R_LCDC & 0x04)) - continue; - VS[NS].x = (int)o->x - 8; - v = L - (int)o->y + 16; - if (hw.cgb) - { - pat = o->pat | (((int)o->flags & 0x60) << 5) - | (((int)o->flags & 0x08) << 6); - VS[NS].pal = 32 + ((o->flags & 0x07) << 2); - } - else - { - pat = o->pat | (((int)o->flags & 0x60) << 5); - VS[NS].pal = 32 + ((o->flags & 0x10) >> 2); - } - VS[NS].pri = (o->flags & 0x80) >> 7; - if ((R_LCDC & 0x04)) - { - pat &= ~1; - if (v >= 8) - { - v -= 8; - pat++; - } - if (o->flags & 0x40) pat ^= 1; - } - VS[NS].buf = patpix[pat][v]; - if (++NS == 10) break; - } - if (!sprsort||hw.cgb) return; - /* not quite optimal but it finally works! */ - for (i = 0; i < NS; i++) - { - l = 0; - x = VS[0].x; - for (j = 1; j < NS; j++) - { - if (VS[j].x < x) - { - l = j; - x = VS[j].x; - } - } - ts[i] = VS[l]; - VS[l].x = 160; - } - memcpy(VS, ts, sizeof VS); + int i, j; + struct obj *o; + struct vissprite ts[10]; + int v, pat; + int l, x; + + NS = 0; + if (!(R_LCDC & 0x02)) return; + + o = lcd.oam.obj; + + for (i = 40; i; i--, o++) + { + if (L >= o->y || L + 16 < o->y) + continue; + if (L + 8 >= o->y && !(R_LCDC & 0x04)) + continue; + VS[NS].x = (int)o->x - 8; + v = L - (int)o->y + 16; + if (hw.cgb) + { + pat = o->pat | (((int)o->flags & 0x60) << 5) + | (((int)o->flags & 0x08) << 6); + VS[NS].pal = 32 + ((o->flags & 0x07) << 2); + } + else + { + pat = o->pat | (((int)o->flags & 0x60) << 5); + VS[NS].pal = 32 + ((o->flags & 0x10) >> 2); + } + VS[NS].pri = (o->flags & 0x80) >> 7; + if ((R_LCDC & 0x04)) + { + pat &= ~1; + if (v >= 8) + { + v -= 8; + pat++; + } + if (o->flags & 0x40) pat ^= 1; + } + VS[NS].buf = patpix[pat][v]; + if (++NS == 10) break; + } + if (!sprsort||hw.cgb) return; + /* not quite optimal but it finally works! */ + for (i = 0; i < NS; i++) + { + l = 0; + x = VS[0].x; + for (j = 1; j < NS; j++) + { + if (VS[j].x < x) + { + l = j; + x = VS[j].x; + } + } + ts[i] = VS[l]; + VS[l].x = 160; + } + memcpy(VS, ts, sizeof VS); } void spr_scan(void) { - int i, x; - byte pal, b, ns = NS; - byte *src, *dest, *bg, *pri; - struct vissprite *vs; - static byte bgdup[256]; - - if (!ns) return; - - memcpy(bgdup, BUF, 256); - vs = &VS[ns-1]; - - for (; ns; ns--, vs--) - { - x = vs->x; - if (x >= 160) continue; - if (x <= -8) continue; - if (x < 0) - { - src = vs->buf - x; - dest = BUF; - i = 8 + x; - } - else - { - src = vs->buf; - dest = BUF + x; - if (x > 152) i = 160 - x; - else i = 8; - } - pal = vs->pal; - if (vs->pri) - { - bg = bgdup + (dest - BUF); - while (i--) - { - b = src[i]; - if (b && !(bg[i]&3)) dest[i] = pal|b; - } - } - else if (hw.cgb) - { - bg = bgdup + (dest - BUF); - pri = PRI + (dest - BUF); - while (i--) - { - b = src[i]; - if (b && (!pri[i] || !(bg[i]&3))) - dest[i] = pal|b; - } - } - else while (i--) if (src[i]) dest[i] = pal|src[i]; - /* else while (i--) if (src[i]) dest[i] = 31 + ns; */ - } -// if (sprdebug) for (i = 0; i < NS; i++) BUF[i<<1] = 36; + int i, x; + byte pal, b, ns = NS; + byte *src, *dest, *bg, *pri; + struct vissprite *vs; + static byte bgdup[256]; + + if (!ns) return; + + memcpy(bgdup, BUF, 256); + vs = &VS[ns-1]; + + for (; ns; ns--, vs--) + { + x = vs->x; + if (x >= 160) continue; + if (x <= -8) continue; + if (x < 0) + { + src = vs->buf - x; + dest = BUF; + i = 8 + x; + } + else + { + src = vs->buf; + dest = BUF + x; + if (x > 152) i = 160 - x; + else i = 8; + } + pal = vs->pal; + if (vs->pri) + { + bg = bgdup + (dest - BUF); + while (i--) + { + b = src[i]; + if (b && !(bg[i]&3)) dest[i] = pal|b; + } + } + else if (hw.cgb) + { + bg = bgdup + (dest - BUF); + pri = PRI + (dest - BUF); + while (i--) + { + b = src[i]; + if (b && (!pri[i] || !(bg[i]&3))) + dest[i] = pal|b; + } + } + else while (i--) if (src[i]) dest[i] = pal|src[i]; + /* else while (i--) if (src[i]) dest[i] = 31 + ns; */ + } +// if (sprdebug) for (i = 0; i < NS; i++) BUF[i<<1] = 36; } @@ -828,43 +828,45 @@ void spr_scan(void) void lcd_begin(void) { -/* if (fb.indexed) - { - if (rgb332) pal_set332(); - else pal_expire(); - } - while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ - vdest = fb.ptr + ((fb.w*fb.pelsize)>>1) - - (80*fb.pelsize) - + ((fb.h>>1) - 72) * fb.pitch; - WY = R_WY; +/* if (fb.indexed) + { + if (rgb332) pal_set332(); + else pal_expire(); + } + while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ + vdest = fb.ptr + ((fb.w*fb.pelsize)>>1) + - (80*fb.pelsize) + + ((fb.h>>1) - 72) * fb.pitch; + WY = R_WY; } void lcd_refreshline(void) { - if (!fb.enabled) return; - if(!insync) { - if(R_LY!=0) - return; - else - insync=1; - } - - if (!(R_LCDC & 0x80)) - return; /* should not happen... */ - - if ( (fb.mode==0&&(R_LY >= 128)) || - (fb.mode==1&&(R_LY < 16)) || - (fb.mode==2&&(R_LY<8||R_LY>=136)) || - (fb.mode==3&&((R_LY%9)==8)) - + if (!fb.enabled) return; + if(!insync) { + if(R_LY!=0) + return; + else + insync=1; + } + + if (!(R_LCDC & 0x80)) + return; /* should not happen... */ + +#if LCD_HEIGHT < 144 + if ( (fb.mode==0&&(R_LY >= 128)) || + (fb.mode==1&&(R_LY < 16)) || + (fb.mode==2&&(R_LY<8||R_LY>=136)) || + (fb.mode==3&&((R_LY%9)==8)) + #if LCD_HEIGHT == 64 - || (R_LY & 1) /* calculate only even lines */ + || (R_LY & 1) /* calculate only even lines */ +#endif + ) + return; #endif - ) - return; - updatepatpix(); + updatepatpix(); L = R_LY; X = R_SCX; @@ -901,25 +903,25 @@ void lcd_refreshline(void) recolor(BUF+WX, 0x04, 160-WX); } spr_scan(); -#if LCD_DEPTH == 2 - if (scanline_ind == 3) -#else +#if LCD_DEPTH == 1 if (scanline_ind == 7) +#elif LCD_DEPTH == 2 + if (scanline_ind == 3) #endif { +#if LCD_HEIGHT < 144 if(fb.mode!=3) vid_update(L); - else - vid_update(L-((int)(L/9))); + else + vid_update(L-((int)(L/9))); +#else + vid_update(L); +#endif } -#if LCD_HEIGHT == 64 +#if LCD_DEPTH == 1 scanline_ind = (scanline_ind+1) % 8; -#else -#if LCD_DEPTH == 2 +#elif LCD_DEPTH == 2 scanline_ind = (scanline_ind+1) % 4; -#else - scanline_ind = (scanline_ind+1) % 8; -#endif #endif } diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c index 175ae78d86..6a99f6aa88 100644 --- a/apps/plugins/rockboy/main.c +++ b/apps/plugins/rockboy/main.c @@ -84,6 +84,11 @@ int gnuboy_main(char *rom) PUTS("Emu reset"); emu_reset(); PUTS("Emu run"); +#if (LCD_HEIGHT > 144) || (LCD_WIDTH > 160) + rb->lcd_clear_display(); + rb->lcd_drawrect((LCD_WIDTH-160)/2-1, (LCD_HEIGHT-144)/2-1, 162, 146); + rb->lcd_update(); +#endif emu_run(); // never reached diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index e8a4923eee..b6408d53dc 100644 --- a/apps/plugins/rockboy/sys_rockbox.c +++ b/apps/plugins/rockboy/sys_rockbox.c @@ -36,12 +36,9 @@ rcvar_t vid_exports[] = }; struct fb fb; -byte *video_base_buf; extern int debug_trace; -static byte frameb[145][160]; - void vid_settitle(char *title) { rb->splash(HZ*2, true, title); @@ -124,7 +121,7 @@ void ev_poll(void) ev_postevent(&ev); } if(pressed & ROCKBOY_MENU) { -#if CONFIG_KEYPAD == IRIVER_H100_PAD +#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) if (do_user_menu() == USER_MENU_QUIT) #endif { @@ -156,38 +153,32 @@ void vid_init(void) fb.pitch=160; fb.enabled=1; fb.dirty=0; - video_base_buf=fb.ptr=(byte *)frameb; fb.mode=3; } +#ifdef HAVE_LCD_COLOR +static const fb_data my_pal[4] = { + LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY, LCD_BLACK +}; +#endif + void vid_update(int scanline) { int cnt=0,scanline_remapped; - byte *frameb; -#if LCD_HEIGHT == 64 /* Archos */ + fb_data *frameb; +#if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */ int balance = 0; if (fb.mode==1) - scanline-=16; + scanline-=16; else if (fb.mode==2) - scanline-=8; + scanline-=8; scanline_remapped = scanline / 16; frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH; while (cnt < 160) { balance += LCD_WIDTH; if (balance > 0) { -#ifdef SIMULATOR /* simulator uses C */ - register unsigned scrbyte = 0; - if (scan.buf[0][cnt] & 0x02) scrbyte |= 0x01; - if (scan.buf[1][cnt] & 0x02) scrbyte |= 0x02; - if (scan.buf[2][cnt] & 0x02) scrbyte |= 0x04; - if (scan.buf[3][cnt] & 0x02) scrbyte |= 0x08; - if (scan.buf[4][cnt] & 0x02) scrbyte |= 0x10; - if (scan.buf[5][cnt] & 0x02) scrbyte |= 0x20; - if (scan.buf[6][cnt] & 0x02) scrbyte |= 0x40; - if (scan.buf[7][cnt] & 0x02) scrbyte |= 0x80; - *(frameb++) = scrbyte; -#else +#if (CONFIG_CPU == SH7034) && !defined(SIMULATOR) asm volatile ( "mov.b @%0,r0 \n" "add %1,%0 \n" @@ -234,25 +225,31 @@ void vid_update(int scanline) : /* clobbers */ "r0", "r1" ); +#else + register unsigned scrbyte = 0; + if (scan.buf[0][cnt] & 0x02) scrbyte |= 0x01; + if (scan.buf[1][cnt] & 0x02) scrbyte |= 0x02; + if (scan.buf[2][cnt] & 0x02) scrbyte |= 0x04; + if (scan.buf[3][cnt] & 0x02) scrbyte |= 0x08; + if (scan.buf[4][cnt] & 0x02) scrbyte |= 0x10; + if (scan.buf[5][cnt] & 0x02) scrbyte |= 0x20; + if (scan.buf[6][cnt] & 0x02) scrbyte |= 0x40; + if (scan.buf[7][cnt] & 0x02) scrbyte |= 0x80; + *(frameb++) = scrbyte; #endif balance -= 160; } cnt ++; } rb->lcd_update_rect(0, (scanline/2) & ~7, LCD_WIDTH, 8); -#else /* LCD_HEIGHT != 64, iRiver */ +#elif (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) /* iriver H1x0 */ if (fb.mode==1) - scanline-=16; + scanline-=16; else if (fb.mode==2) - scanline-=8; -#if LCD_DEPTH == 2 + scanline-=8; scanline_remapped = scanline / 4; -#else - scanline_remapped = scanline / 8; -#endif frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH; while (cnt < 160) { -#if LCD_DEPTH == 2 *(frameb++) = (scan.buf[0][cnt]&0x3) | ((scan.buf[1][cnt]&0x3)<<2) | ((scan.buf[2][cnt]&0x3)<<4) | @@ -260,21 +257,12 @@ void vid_update(int scanline) cnt++; } rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4); -#else - register unsigned scrbyte = 0; - if (scan.buf[0][cnt] & 0x02) scrbyte |= 0x01; - if (scan.buf[1][cnt] & 0x02) scrbyte |= 0x02; - if (scan.buf[2][cnt] & 0x02) scrbyte |= 0x04; - if (scan.buf[3][cnt] & 0x02) scrbyte |= 0x08; - if (scan.buf[4][cnt] & 0x02) scrbyte |= 0x10; - if (scan.buf[5][cnt] & 0x02) scrbyte |= 0x20; - if (scan.buf[6][cnt] & 0x02) scrbyte |= 0x40; - if (scan.buf[7][cnt] & 0x02) scrbyte |= 0x80; - *(frameb++) = scrbyte; - cnt++; - } - rb->lcd_update_rect(0, scanline & ~7, LCD_WIDTH, 8); -#endif /* LCD_DEPTH */ +#elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */ + scanline_remapped = scanline + (LCD_HEIGHT-144)/2; + frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH + (LCD_WIDTH-160)/2; + while (cnt < 160) + *frameb++ = my_pal[scan.buf[0][cnt++]&0x3]; + rb->lcd_update_rect((LCD_WIDTH-160)/2, scanline_remapped, 160, 1); #endif /* LCD_HEIGHT */ } -- cgit v1.2.3