![]() |
![]() |
#21 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
I didn't want to spoil your Project thread, but I just wanted to say this is a cracking idea and, since it's SDL, I couldn't resist seeing how it ran on the Mac (in the absence of spoUP's
![]() ![]() I've not looked into the colour issue, but that'll be trivial. All I've done is setup an Xcode project with the SDL frameworks, removed the MessageBox and windows.h references and hardcoded a location to load a module from. It worked fine ![]() Please keep up with this! When I get more time I'll happily do what I can to see the Mac version stays in sync, as well. I'd *love* to have this fully working so I could make some 8bit tunes natively on my laptop! Last edited by korruptor; 09 August 2010 at 16:01. |
![]() |
![]() |
#22 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
Hmm... Seems the RGB is swapped to BGR on your port...
![]() All you need is to swap the RGB positions in the palette table (ProTracker_SDL.c). E.g. 0x0000FF -> 0xFF0000 I made a smart palette system, makes everything easier when it comes to color changing ![]() EDIT: Hmm no, it seems to be something else. Let me try something. EDIT2: Aha! It was the alpa channel missing. Code:
/* our main palette */ unsigned int palette[48] = { 0x00BBBBBB, /* 0 - tracker bg */ 0x00888888, /* 1 - tracker bg */ 0x00555555, /* 2 - tracker bg */ 0x00000000, /* 3 - general text */ 0x00009955, /* 4 - pattern text */ 0x00444444, /* 5 - cursor */ 0x00777777, /* 6 - cursor */ 0x00AAAAAA, /* 7 - cursor */ 0x0000FF00, /* 8 - colorkey/transparency */ 0x00BB00FF /* 9 - quadrascope */ }; I'll convert the vumeter pixels too now, hold on. EDIT3: This is the new vumeter_bitmap.h: http://pastebin.com/j2kNzS1h Done! Thanks for finding that error, I'll update the sources. Last edited by 8bitbubsy; 09 August 2010 at 16:36. |
![]() |
![]() |
#23 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Yup, found and fixed that after I posted.
Sounds great, I'm really impressed ![]() |
![]() |
![]() |
#24 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
Remember that the vumeter doesn't use the palette, so you need to change *all* the pixels in the bitmap. I did that for you, check my post earlier (where I linked to pastebin.com)
Thanks! ![]() 4mat ![]() I spoke to him and showed him this project, he loved it Last edited by 8bitbubsy; 09 August 2010 at 16:50. |
![]() |
![]() |
#25 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
I just stuck this in, but obviously the VUs were wrong
![]() Edit: yeah, just seen your post! Two ticks, lemme drop that in. Code:
unsigned int palette[48] = { // Blue, Green, Red, Alpha (0xBB << 24) | (0xBB << 16) | (0xBB << 8) | (0x00 << 0), (0x88 << 24) | (0x88 << 16) | (0x88 << 8) | (0x00 << 0), (0x55 << 24) | (0x55 << 16) | (0x55 << 8) | (0x00 << 0), (0x00 << 24) | (0x00 << 16) | (0x00 << 8) | (0x00 << 0), (0x55 << 24) | (0x99 << 16) | (0x00 << 8) | (0x00 << 0), (0x44 << 24) | (0x44 << 16) | (0x44 << 8) | (0x00 << 0), (0x77 << 24) | (0x77 << 16) | (0x77 << 8) | (0x00 << 0), (0xaa << 24) | (0xaa << 16) | (0xaa << 8) | (0x00 << 0), (0x00 << 24) | (0xff << 16) | (0x00 << 8) | (0x00 << 0), (0xff << 24) | (0x00 << 16) | (0xbb << 8) | (0x00 << 0) }; |
![]() |
![]() |
#26 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Pixel format is BRGA on mine, which is daft as I'm on Intel. Two ticks...
I've not used SDL in about 8 years, as you can tell ![]() |
![]() |
![]() |
#27 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
It's cos the pixel masks aren't set:
Try these: Code:
SDL_Surface *dst = SDL_CreateRGBSurface(screen->flags, src_width, src_height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); |
![]() |
![]() |
#28 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
The pixel format is ARGB here, Windows 7 + SDL 1.2.
EDIT: Nice, I'll do that. Ok: pixbuf = SDL_CreateRGBSurface(screen->flags, 320, 255, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); In ProTracker_SDL.c... If you've ever wondered why I do 320x255 and not 320x256, then I can tell you it's because ProTracker doesn't actually plot on the last scanline. If you see any other errors, feel free to comment! I love to learn from my (many) mistakes. Btw, do you hang around on IRC or MSN? It's easier to talk and share code there. Last edited by 8bitbubsy; 09 August 2010 at 17:05. |
![]() |
![]() |
#29 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Oh, hang on, that's still the wrong order on mine. There's something else. Lemme have a poke about.
Which IRC channel are you on? |
![]() |
![]() |
#30 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
|
![]() |
![]() |
#31 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Cool, I'll pop in when I get time to look at this. I've got as far as checking the screen and surface pixel formats, which match. Endians look ok, so I'm wondering if there's actually an endian difference when it's getting to the graphic card.
I need to dig about but I'm at work, so it's a bit tricky ![]() |
![]() |
![]() |
#32 |
Registered User
Join Date: Sep 2004
Location: Brasil
Age: 50
Posts: 181
|
Only want to add that commenting the MessageBoxs, the programs goes perfectly in my Debian 64
![]() Great Job!!! ![]() |
![]() |
![]() |
#33 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
![]() |
![]() |
![]() |
#34 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Okie doke, I was being a pleb earlier.
All your draw code assumes the screen's pixel format matches your palette, which isn't always the case. What I normally do is keep the colour components split until the last minute, and then shift and pack them together depending. So RGBA in my iPhone stuff ends up being: Code:
U32 colour = (alpha << 24) | (blue << 16) | (green << 8) | red; Code:
void drawPaletteBitmap(char *src, SDL_Surface * screen, SDL_Surface *dst, int putx, int puty, int src_width, int src_height) { unsigned int *dst_p = (unsigned int *)dst->pixels; int x, y; unsigned int tmpC = 0; for (y = 0; y < src_height; y++) { int _y = (puty + y) * dst->w; int srcY = y * src_width; for (x = 0; x < src_width; x++) { int paletteIndex = src[srcY + x]; if (paletteIndex != 8) { // get the ARGB colour value tmpC = palette[paletteIndex]; // Convert each component into the screen format unsigned int pixel = (((tmpC & 0xFF000000) >> 24) << screen->format->Ashift ) | (((tmpC & 0x00FF0000) >> 16) << screen->format->Rshift ) | (((tmpC & 0x0000FF00) >> 8) << screen->format->Gshift ) | ((tmpC & 0x000000FF) << screen->format->Bshift ); int _x = putx + x; if (((puty + y) < dst->h) && (_x < dst->w)) dst_p[_y + _x] = pixel; } } } return; } I don't think speed's much of an issue for this stuff though ![]() |
![]() |
![]() |
#35 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
Actually, it is... I spent a long time optimizing, and it went down from 5% CPU load to 0-1% on my Intel Core2 Quad 2.4GHz... 20% CPU load on my other DELL 2.8GHz
I'll try the code now and check the CPU load again. EDIT: Around 1% more CPU load with your code.... I'm sceptic. Meh you're right, portability is important! I'll keep your code, thanks ![]() So I guess you're joining the project, or? No need to often commit anything to the source, but just if you feel like adding/changing/optimizing something, then feel free ![]() Last edited by 8bitbubsy; 09 August 2010 at 22:00. |
![]() |
![]() |
#36 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Well, you can side step all that by building your palette to match the screen format. You have the base colours, so do all that shifting into a new palette structure on entry and go back to straight pixel copying in the main loop.
|
![]() |
![]() |
#37 | |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Quote:
![]() I'm happy to keep a mac version together for you, if that helps? |
|
![]() |
![]() |
#38 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,719
|
Hmm, what about
pixbuf = SDL_CreateRGBSurface(screen->flags, 320, 255, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); ? Should I change the last four parameters to something in the screen struct? Mmm! Back to 0-1% CPU load. Code:
/* our main palette */ unsigned int palette[48] = { 0x00BBBBBB, /* 0 - tracker bg */ 0x00888888, /* 1 - tracker bg */ 0x00555555, /* 2 - tracker bg */ 0x00000000, /* 3 - general text */ 0x00009955, /* 4 - pattern text */ 0x00444444, /* 5 - cursor */ 0x00777777, /* 6 - cursor */ 0x00AAAAAA, /* 7 - cursor */ 0x0000FF00, /* 8 - colorkey/transparency */ 0x00BB00FF /* 9 - quadrascope */ }; void convertPaletteToScreenFmt(unsigned int *palette, SDL_Surface *screen); [...] convertPaletteToScreenFmt(palette, screen); [...] void convertPaletteToScreenFmt(unsigned int *palette, SDL_Surface *screen) { if ((screen != NULL) && (palette != NULL)) { int i; for (i = 0; i < 48; i++) { if (palette == NULL) return; { unsigned int pix = *palette; *palette++ = (((pix & 0xFF000000) >> 24) << screen->format->Ashift ) | (((pix & 0x00FF0000) >> 16) << screen->format->Rshift ) | (((pix & 0x0000FF00) >> 8) << screen->format->Gshift ) | ((pix & 0x000000FF) << screen->format->Bshift ); } } } return; } Last edited by 8bitbubsy; 09 August 2010 at 22:13. |
![]() |
![]() |
#39 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
![]() |
![]() |
![]() |
#40 |
HOL/FTP busy bee
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 32,022
|
Code:
if ((screen != NULL) && (palette != NULL)) { ... { if (palette == NULL) return; ![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
My old source code | gemanix | Coders. General | 36 | 09 July 2017 13:33 |
Source code for game in C? | Leandro Jardim | Coders. General | 2 | 17 February 2013 00:27 |
Protracker all Versions incl. Source | sun68 | support.Apps | 16 | 01 April 2012 00:59 |
Source Code | camelord | support.Games | 2 | 06 August 2010 17:45 |
Source Code | Thalion | project.WinUAE - Kaillera | 3 | 28 April 2006 09:55 |
|
|