Index: apps/plugins/rockboy/fb.h =================================================================== --- apps/plugins/rockboy/fb.h (revision 15194) +++ apps/plugins/rockboy/fb.h (working copy) @@ -15,8 +15,6 @@ { int l, r; } cc[3]; -#else - int mode; #endif int enabled; }; Index: apps/plugins/rockboy/lcd-gb.h =================================================================== --- apps/plugins/rockboy/lcd-gb.h (revision 15194) +++ apps/plugins/rockboy/lcd-gb.h (working copy) @@ -16,14 +16,10 @@ { int bg[64]; int wnd[64]; -#if LCD_DEPTH == 1 - byte buf[8][256]; -#elif LCD_DEPTH == 2 - byte buf[4][256]; -#elif LCD_DEPTH > 4 - byte buf[256]; + byte *buf; +#ifdef HAVE_LCD_COLOR + un32 pal[64]; #endif - un16 pal[64]; byte pri[256]; struct vissprite vs[16]; int ns, l, x, y, s, t, u, v, wx, wy, wt, wv; Index: apps/plugins/rockboy/lcd.c =================================================================== --- apps/plugins/rockboy/lcd.c (revision 15194) +++ apps/plugins/rockboy/lcd.c (working copy) @@ -19,15 +19,13 @@ #define BG (scan.bg) #define WND (scan.wnd) -#if LCD_DEPTH ==16 #define BUF (scan.buf) -#else -#define BUF (scan.buf[scanline_ind]) -#endif #define PRI (scan.pri) +#ifdef HAVE_LCD_COLOR #define PAL (scan.pal) +#endif #define VS (scan.vs) /* vissprites */ #define NS (scan.ns) @@ -51,11 +49,20 @@ ; byte patdirty[1024]; byte anydirty; +byte buf[256]; -#if LCD_DEPTH < 16 -static int scanline_ind=0; +#if !defined(HAVE_LCD_COLOR) && (LCD_PIXELFORMAT == VERTICAL_PACKING) +static int scanline=0; #endif +#if LCD_DEPTH == 1 +#define DRAW_MASK ~(1<>16)*LCD_WIDTH+1); else sremain=LCD_WIDTH-swidth; +#else + /* Handled in lcd_refreshline() */ #endif } void lcd_refreshline(void) { -#ifdef HAVE_LCD_COLOR char frameout[30]; -#endif if (!(R_LCDC & 0x80)) return; /* should not happen... */ -#if (LCD_HEIGHT <= 128) && !defined(HAVE_LCD_COLOR) - 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(R_LY == 143) + { + if(options.showstats) + { + snprintf(frameout,sizeof(frameout),"FPS: %d Frameskip: %d ",options.fps, options.frameskip); + rb->lcd_putsxy(0,LCD_HEIGHT-10,frameout); + } + rb->lcd_update(); + } +#if !defined(HAVE_LCD_COLOR) #if LCD_HEIGHT == 64 - || (R_LY & 1) /* calculate only even lines */ + if ( (options.scaling==0&&(R_LY >= 128)) || (options.scaling==1&&(R_LY < 16)) || + (options.scaling==2&&(R_LY<8||R_LY>=136)) || (options.scaling==3&&((R_LY%9)==8)) + || (R_LY & 1)) /* calculate only even lines */ +#elif LCD_HEIGHT == 110 + if ( (options.scaling==0&&(R_LY >= 110)) || (options.scaling==1&&(R_LY < 34)) || + (options.scaling==2&&(R_LY<17||R_LY>=127)) || (options.scaling==3&&((R_LY%4)==0) + && (R_LY!=3) && (R_LY != 135 )) ) +#elif LCD_HEIGHT == 128 + if ( (options.scaling==0&&(R_LY >= 128)) || (options.scaling==1&&(R_LY < 16)) || + (options.scaling==2&&(R_LY<8||R_LY>=136)) || (options.scaling==3&&((R_LY%9)==8)) ) #endif - ) - return; -#endif + return; /* line is skipped due to scaling */ +#endif /* HAVE_LCD_COLOR */ updatepatpix(); + + BUF = buf; L = R_LY; X = R_SCX; @@ -1046,18 +1068,46 @@ spr_scan(); #if !defined(HAVE_LCD_COLOR) + int cnt = 0; +#if (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == HORIZONTAL_PACKING) + unsigned char pixmask[4] = + { + 0xC0, 0x30, 0x0C, 0x03 + }; +#elif (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_PACKING) + unsigned char pixmask[4] = + { + 0x03, 0x0C, 0x30, 0xC0 + }; +#endif + + while (cnt < 160) + { +#if LCD_WIDTH < 160 + if (cnt < LCD_WIDTH) +#endif #if LCD_DEPTH == 1 - if (scanline_ind == 7) -#elif LCD_DEPTH == 2 - if (scanline_ind == 3) + vdest[cnt] = (vdest[cnt] & DRAW_MASK) | (((BUF[cnt]&0x2)>>1) << scanline); +#elif (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_PACKING) + vdest[cnt] = (vdest[cnt] & DRAW_MASK) | + ((BUF[cnt]&0x3) << ((scanline & 3)<<1)); +#elif (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == HORIZONTAL_PACKING) + vdest[cnt >> 2] = (vdest[cnt >> 2] & DRAW_MASK) | + ((BUF[cnt]&0x3) << ((~cnt & 0x3 )<<1)); +#endif /* LCD_DEPTH */ + cnt++; + } + +#if LCD_DEPTH == 1 + scanline = (scanline+1) % 8; + if (scanline == 0) +#elif (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_PACKING) + scanline = (scanline+1) % 4; + if (scanline == 0) #endif - { - if(fb.mode!=3) - vid_update(L); - else - vid_update(L-((int)(L/9))); -#else - { + vdest += LCD_FBWIDTH; + +#elif defined(HAVE_LCD_COLOR) /* Universal Scaling pulled from PrBoom and modified for rockboy */ static int hpt IDATA_ATTR=0x8000; @@ -1080,26 +1130,10 @@ } vdest+=remain; } - + if(L==143) - { - if(options.showstats) - { - snprintf(frameout,sizeof(frameout),"FPS: %d Frameskip: %d ",options.fps, options.frameskip); - rb->lcd_putsxy(0,LCD_HEIGHT-10,frameout); - } - hpt=0x8000; - rb->lcd_update(); - } - -#endif - } -#if LCD_DEPTH == 1 - scanline_ind = (scanline_ind+1) % 8; -#elif LCD_DEPTH == 2 - scanline_ind = (scanline_ind+1) % 4; -#endif +#endif /* HAVE_LCD_COLOR */ } #ifdef HAVE_LCD_COLOR @@ -1113,7 +1147,7 @@ { int c, r, g, b; - c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF; + c = (lcd.pal[i] | ((int)lcd.pal[(i)|1] << 8)) & 0x7FFF; r = (c & 0x001F) << 3; g = (c & 0x03E0) >> 2; b = (c & 0x7C00) >> 7; @@ -1130,7 +1164,7 @@ #elif LCD_PIXELFORMAT == RGB565SWAPPED c = swap16(r|g|b); #endif - PAL[i] = c; + PAL[i>>1] = c; } #endif /* HAVE_LCD_COLOR */ @@ -1139,7 +1173,7 @@ if (lcd.pal[i] == b) return; lcd.pal[i] = b; #ifdef HAVE_LCD_COLOR - updatepalette(i>>1); + updatepalette(i); #endif } @@ -1192,7 +1226,7 @@ pal_write_dmg(72, 3, R_OBP1); } #ifdef HAVE_LCD_COLOR - for (i = 0; i < 64; i++) + for (i = 0; i < 128; i+=2) updatepalette(i); #endif } Index: apps/plugins/rockboy/menu.c =================================================================== --- apps/plugins/rockboy/menu.c (revision 15194) +++ apps/plugins/rockboy/menu.c (working copy) @@ -348,16 +348,23 @@ { "5 Max", -1 }, { "6 Max", -1 }, }; - + + static const struct opt_items scaling[]= { #ifdef HAVE_LCD_COLOR - static const struct opt_items scaling[]= { { "Scaled", -1 }, { "Scaled - Maintain Ratio", -1 }, #if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144) { "Unscaled", -1 }, #endif +#else + { "Clip Bottom", -1 }, + { "Clip Top", -1 }, + { "Clip Top and Bottom Evenly", -1 }, + { "Skip Lines", -1 }, +#endif }; +#ifdef HAVE_LCD_COLOR static const struct opt_items palette[]= { { "Brown (Default)", -1 }, { "Gray", -1 }, @@ -384,8 +391,8 @@ { "Sound" , NULL }, { "Stats" , NULL }, { "Set Keys (Buggy)", NULL }, + { "Screen Size" , NULL }, #ifdef HAVE_LCD_COLOR - { "Screen Size" , NULL }, { "Screen Rotate" , NULL }, { "Set Palette" , NULL }, #endif @@ -417,12 +424,12 @@ case 3: /* Keys */ setupkeys(); break; -#ifdef HAVE_LCD_COLOR case 4: /* Screen Size */ rb->set_option(items[4].desc, &options.scaling, INT, scaling, sizeof(scaling)/sizeof(*scaling), NULL ); setvidmode(); break; +#ifdef HAVE_LCD_COLOR case 5: /* Screen rotate */ rb->set_option(items[5].desc, &options.rotate, INT, onoff, 2, NULL ); setvidmode(); Index: apps/plugins/rockboy/sys_rockbox.c =================================================================== --- apps/plugins/rockboy/sys_rockbox.c (revision 15194) +++ apps/plugins/rockboy/sys_rockbox.c (working copy) @@ -84,13 +84,9 @@ released = ~newbuttonstate & oldbuttonstate; pressed = newbuttonstate & ~oldbuttonstate; oldbuttonstate = newbuttonstate; -#if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) - if (rb->button_hold()&~holdbutton) - fb.mode=(fb.mode+1)%4; - holdbutton=rb->button_hold(); -#elif CONFIG_KEYPAD == RECORDER_PAD +#if CONFIG_KEYPAD == RECORDER_PAD if (pressed & BUTTON_ON) - fb.mode=(fb.mode+1)%4; + options.scaling=(options.scaling+1)%4; #endif #ifdef HAVE_WHEEL_POSITION @@ -216,11 +212,10 @@ fb.cc[1].l = 5; /* This is the offset to the G bits (16-5-6) */ fb.cc[2].r = 3; /* 8-5 (wasted bits on red) */ fb.cc[2].l = 0; /* This is the offset to the B bits (16-5-6-5) */ -#else - fb.mode=3; #endif } +#if 0 #if !defined(HAVE_LCD_COLOR) /* Color targets are handled in lcd.c */ fb_data *frameb; @@ -324,4 +319,5 @@ #endif /* LCD_HEIGHT */ } #endif +#endif