summaryrefslogtreecommitdiff
path: root/apps/plugins/doom/i_video.c
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
commit51db2d3f2cfddfb1c94de1085d130c817bcd953f (patch)
treea8452577070b7febf0ec640d2a065cd7e2c89847 /apps/plugins/doom/i_video.c
parente61b079c26e5eaa12f403da6964ac20282df248e (diff)
downloadrockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.tar.gz
rockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.zip
Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9418 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/doom/i_video.c')
-rw-r--r--apps/plugins/doom/i_video.c96
1 files changed, 16 insertions, 80 deletions
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index 1bfbf93ce8..b7dbd2bcf5 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -16,7 +16,10 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * $Log$ 18 * $Log$
19 * Revision 1.2 2006/03/28 17:20:49 christian 19 * Revision 1.3 2006/04/02 01:52:44 kkurbjun
20 * Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
21 *
22 * Revision 1.2 2006-03-28 17:20:49 christian
20 * added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD 23 * added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD
21 * 24 *
22 * Revision 1.1 2006-03-28 15:44:01 dave 25 * Revision 1.1 2006-03-28 15:44:01 dave
@@ -40,51 +43,12 @@
40#include "doomdef.h" 43#include "doomdef.h"
41 44
42#include "rockmacros.h" 45#include "rockmacros.h"
43 46#if defined(CPU_COLDFIRE)
47static char fastscreen[LCD_WIDTH*LCD_HEIGHT] IBSS_ATTR;
48#endif
44static fb_data palette[256] IBSS_ATTR; 49static fb_data palette[256] IBSS_ATTR;
45static fb_data *paldata=NULL; 50static fb_data *paldata=NULL;
46 51
47#if !defined(CPU_COLDFIRE) || defined(SIMULATOR)
48/*
49 This code is credit to the IDOOM port. It is not used for the H300, but
50 serves as a good reference point for other targets.
51*/
52static fb_data * xtable = 0;
53static fb_data * ytable1 = 0;
54static fb_data * ytable2 = 0;
55
56#define FLOOR4(a) \
57 (( a >> 2) << 2)
58
59static int video_w, video_h;
60
61static void genscalexytable(void)
62{
63 // shall we use uint8_t intead of ints?
64 int y = video_h-1;
65 int x = video_w-1;
66 int i = 1 + (x>y?x:y);
67 xtable = malloc(sizeof(int)*video_w );
68 ytable1 = malloc(sizeof(int)*video_h );
69 ytable2 = malloc(sizeof(int)*video_h );
70
71 while(i--)
72 {
73 if(y>=0)
74 {
75 ytable1[y] = ((y*SCREENHEIGHT) / video_h) * SCREENWIDTH;
76 ytable2[y] = y*video_w;
77 y--;
78 }
79 if(x>=0)
80 {
81 xtable[x] = (x*SCREENWIDTH) / video_w;
82 x--;
83 }
84 }
85}
86#endif
87
88// 52//
89// I_ShutdownGraphics (NOT USED) 53// I_ShutdownGraphics (NOT USED)
90// 54//
@@ -360,9 +324,7 @@ void I_FinishUpdate (void)
360{ 324{
361#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 325#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
362 /* 326 /*
363 Faster screen update than the lookuptables -> I'm wasting 7 pixels of width 327 Lookup tables are no longer needed
364 though. This code also doesn't use the framebuffer so rockbox's drawing
365 functions will not work on top of the doom drawing.
366 */ 328 */
367 329
368 // Start the write 330 // Start the write
@@ -373,51 +335,27 @@ void I_FinishUpdate (void)
373 unsigned char *screenptr=screens[0]; 335 unsigned char *screenptr=screens[0];
374 int wcnt=0, hcnt=0; 336 int wcnt=0, hcnt=0;
375 337
376 *(volatile unsigned short *) 0xf0000002 = 0;
377 *(volatile unsigned short *) 0xf0000002 = 0;
378 *(volatile unsigned short *) 0xf0000002 = 0;
379
380 while(hcnt<LCD_HEIGHT) 338 while(hcnt<LCD_HEIGHT)
381 { 339 {
382 while(wcnt<LCD_WIDTH-7) 340 while(wcnt<LCD_WIDTH)
383 { 341 {
384 if((wcnt&0x01))
385 screenptr++; // Skip every so many pixels in Doom buffer
386 *(volatile unsigned short *)0xf0000002 = palette[*screenptr]; 342 *(volatile unsigned short *)0xf0000002 = palette[*screenptr];
387 screenptr++; 343 screenptr++;
388 wcnt++; 344 wcnt++;
389 } 345 }
390 screenptr++;
391 // move on past those 7 pixels
392 *(volatile unsigned short *) 0xf0000002 = 0;
393 *(volatile unsigned short *) 0xf0000002 = 0;
394 *(volatile unsigned short *) 0xf0000002 = 0;
395 *(volatile unsigned short *) 0xf0000002 = 0;
396 *(volatile unsigned short *) 0xf0000002 = 0;
397 *(volatile unsigned short *) 0xf0000002 = 0;
398 *(volatile unsigned short *) 0xf0000002 = 0;
399 wcnt=0; 346 wcnt=0;
400 hcnt++; 347 hcnt++;
401 if((hcnt&0x07)==0x07)
402 screenptr+=SCREENWIDTH; // Skip every 7th line
403 } 348 }
404#else 349#else
405 // The IDOOM code for screen updates
406 unsigned char paletteIndex; 350 unsigned char paletteIndex;
407 int x, y; 351 int x, y;
408 352
409 for (y = 0; y < video_h; y++) 353 for (y = 0; y < LCD_HEIGHT; y++)
410 { 354 {
411 for (x = 0; x < video_w; x++) 355 for (x = 0; x < LCD_WIDTH; x++)
412 { 356 {
413#if LCD_HEIGHT >= SCREENHEIGHT 357 paletteIndex = screens[0][y*SCREENWIDTH + x];
414 paletteIndex = screens[0][((y*SCREENHEIGHT) / video_h) 358 rb->lcd_framebuffer[y * LCD_WIDTH + x] = palette[paletteIndex];
415 * SCREENWIDTH + x];
416 rb->lcd_framebuffer[y * video_w + x] = palette[paletteIndex];
417#else
418 paletteIndex = screens[0][ytable1[y] +xtable[x]];
419 rb->lcd_framebuffer[x + ytable2[y]] = palette[paletteIndex];
420#endif
421 } 359 }
422 } 360 }
423 rb->lcd_update(); 361 rb->lcd_update();
@@ -454,14 +392,12 @@ void I_InitGraphics(void)
454 printf("Starting Graphics engine\n"); 392 printf("Starting Graphics engine\n");
455 393
456 /* Note: The other screens are initialized later */ 394 /* Note: The other screens are initialized later */
457 screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char));
458 395
459#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 396#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
460 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); 397 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
398 screens[0] = fastscreen;
461#else 399#else
462 400 // Don't know if this will fit in other IRAMs
463 video_h = LCD_HEIGHT; 401 screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char));
464 video_w = FLOOR4(LCD_WIDTH); // From IDOOM, the width has to be a multiple of 4
465 genscalexytable();
466#endif 402#endif
467} 403}