April 13, 2024, 04:45:48 AM
Welcome,
Guest
Home
Help
Search
Login
Register
Recovery
xboxscene.org forums
>
OG Xbox Forums
>
Software Forums
>
Development
>
C/c++ Questions
« previous
next »
Pages: [
1
]
Print
Author
Topic: C/c++ Questions (Read 63 times)
razorrifh
Archived User
Sr. Member
Posts: 329
C/c++ Questions
«
on:
February 24, 2004, 12:19:00 PM »
CODE
u16* theVideoBuffer = (u16*)VideoBuffer;
u16* theBackBuffer = (u16*)BackBuffer;
u16* theScreenPalette = (u16*)BGPaletteMem;
can you set a variable that is not an array an array in its definition? see the theScreenPalette variable? when it is declared earlier/above, it idnt an array but it is used as one here. thanks for your help
CODE
int main()
{
SetMode( SCREENMODE4 | BG2ENABLE ); //Set screen mode
int x = 0, y = 0; //Coordinate for our left pixel
theScreenPalette[1] = RGB( 31, 31, 31); //Add white to the palette
theScreenPalette[2] = RGB(31,0,0); //Add red to the palette
u16 twoColors = (( 1 << 8 ) + 2); //Left pixel = 0, right pixel = 1
theBackBuffer[ x + y * 240 ] = twoColors; //Write the two colours
WaitForVblank(); //Wait for a vertical blank
Flip(); //Flip the buffers
return 0;
}
Logged
Mage
Archived User
Sr. Member
Posts: 482
C/c++ Questions
«
Reply #1 on:
February 24, 2004, 02:02:00 PM »
CODE
int y[5]={2,1,4,3,5}, *py=&y[0];
for(i = 0; i<5; i++)
printf("%u %u %u %u\n", *(py + i), py
, *(&y[0] + i), y
);
Those all represent the same thing. Subscripts merely makes it easier to deal with offsets from a base memory location.
So yes you can use them on variables that aren't defined as an array without problems.
Logged
razorrifh
Archived User
Sr. Member
Posts: 329
C/c++ Questions
«
Reply #2 on:
February 24, 2004, 07:54:00 PM »
and yes, its gba code
Logged
Print
Pages: [
1
]
« previous
next »
xboxscene.org forums
>
OG Xbox Forums
>
Software Forums
>
Development
>
C/c++ Questions