|
@@ -1,7 +1,9 @@
|
|
|
#include <os.h>
|
|
#include <os.h>
|
|
|
-#include <graphics.h>
|
|
|
|
|
|
|
+#include <Graphics.h>
|
|
|
#include <misc.h>
|
|
#include <misc.h>
|
|
|
|
|
|
|
|
|
|
+#define GRAPHICS WalrusRPG::Graphics
|
|
|
|
|
+
|
|
|
#define LCD_CONTROLLER 0xC0000000
|
|
#define LCD_CONTROLLER 0xC0000000
|
|
|
volatile unsigned *lcd_base = (unsigned *) (LCD_CONTROLLER + 0x10);
|
|
volatile unsigned *lcd_base = (unsigned *) (LCD_CONTROLLER + 0x10);
|
|
|
volatile unsigned *lcd_ris = (unsigned *) (LCD_CONTROLLER + 0x20);
|
|
volatile unsigned *lcd_ris = (unsigned *) (LCD_CONTROLLER + 0x20);
|
|
@@ -16,7 +18,7 @@ unsigned short *buffer_front = NULL, *buffer_back = NULL, *buffer_os;
|
|
|
* Buffer management
|
|
* Buffer management
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-void buffer_allocate()
|
|
|
|
|
|
|
+void GRAPHICS::buffer_allocate()
|
|
|
{
|
|
{
|
|
|
buffer_front = (unsigned short *) malloc(BUFFER_SIZE);
|
|
buffer_front = (unsigned short *) malloc(BUFFER_SIZE);
|
|
|
buffer_back = (unsigned short *) malloc(BUFFER_SIZE);
|
|
buffer_back = (unsigned short *) malloc(BUFFER_SIZE);
|
|
@@ -37,7 +39,7 @@ void buffer_allocate()
|
|
|
*lcd_control |= 0b11 << 12;
|
|
*lcd_control |= 0b11 << 12;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void buffer_free()
|
|
|
|
|
|
|
+void GRAPHICS::buffer_free()
|
|
|
{
|
|
{
|
|
|
free(buffer_front);
|
|
free(buffer_front);
|
|
|
free(buffer_back);
|
|
free(buffer_back);
|
|
@@ -47,7 +49,7 @@ void buffer_free()
|
|
|
*lcd_control = lcd_control_bkp;
|
|
*lcd_control = lcd_control_bkp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void buffer_swap()
|
|
|
|
|
|
|
+void GRAPHICS::buffer_swap()
|
|
|
{
|
|
{
|
|
|
unsigned short *buffer_front_tmp = buffer_front;
|
|
unsigned short *buffer_front_tmp = buffer_front;
|
|
|
buffer_front = buffer_back;
|
|
buffer_front = buffer_back;
|
|
@@ -56,7 +58,7 @@ void buffer_swap()
|
|
|
*lcd_base = (unsigned) buffer_front;
|
|
*lcd_base = (unsigned) buffer_front;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void buffer_fill(unsigned color)
|
|
|
|
|
|
|
+void GRAPHICS::buffer_fill(unsigned color)
|
|
|
{
|
|
{
|
|
|
unsigned *buffer_back_32 = (unsigned *) buffer_back;
|
|
unsigned *buffer_back_32 = (unsigned *) buffer_back;
|
|
|
color += color << 16;
|
|
color += color << 16;
|
|
@@ -69,7 +71,7 @@ void buffer_fill(unsigned color)
|
|
|
* Misc LCD functions
|
|
* Misc LCD functions
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-void lcd_vsync()
|
|
|
|
|
|
|
+void GRAPHICS::lcd_vsync()
|
|
|
{
|
|
{
|
|
|
*lcd_icr = 1 << 3;
|
|
*lcd_icr = 1 << 3;
|
|
|
while (!(*lcd_ris & (1 << 3)));
|
|
while (!(*lcd_ris & (1 << 3)));
|
|
@@ -80,12 +82,12 @@ void lcd_vsync()
|
|
|
* Drawing
|
|
* Drawing
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-void draw_pixel(unsigned x, unsigned y, unsigned short color)
|
|
|
|
|
|
|
+void GRAPHICS::draw_pixel(unsigned x, unsigned y, unsigned short color)
|
|
|
{
|
|
{
|
|
|
buffer_back[x + (y * 320)] = color;
|
|
buffer_back[x + (y * 320)] = color;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect_t *window)
|
|
|
|
|
|
|
+void GRAPHICS::draw_sprite_sheet(const unsigned short *sheet, int x, int y, const GRAPHICS::Rect_t *window)
|
|
|
{
|
|
{
|
|
|
unsigned short color;
|
|
unsigned short color;
|
|
|
int w = min(window->w + x, 320);
|
|
int w = min(window->w + x, 320);
|
|
@@ -107,11 +109,10 @@ void draw_sprite_sheet(const unsigned short *sheet, int x, int y, const Rect_t *
|
|
|
* Sprite manipulation
|
|
* Sprite manipulation
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-unsigned short sprite_pixel_get(const unsigned short *sprite, unsigned x, unsigned y)
|
|
|
|
|
|
|
+unsigned short GRAPHICS::sprite_pixel_get(const unsigned short *sprite, unsigned x, unsigned y)
|
|
|
{
|
|
{
|
|
|
if (x < sprite[0] && y < sprite[1])
|
|
if (x < sprite[0] && y < sprite[1])
|
|
|
return sprite[x + (y * sprite[0]) + 3];
|
|
return sprite[x + (y * sprite[0]) + 3];
|
|
|
else
|
|
else
|
|
|
return sprite[2];
|
|
return sprite[2];
|
|
|
}
|
|
}
|
|
|
-
|
|
|