Properly handle the MainScreen struct everywhere; update rom
This commit is contained in:
parent
f094b712af
commit
0f02835148
|
@ -10,9 +10,9 @@ unsigned char fox32rom[] = {
|
|||
0x00, 0x00, 0x8c, 0x0e, 0x97, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
|
||||
0x00, 0x02, 0x97, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x02, 0x97, 0x00, 0x03,
|
||||
0x00, 0x80, 0x00, 0x02, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91,
|
||||
0x00, 0x02, 0xa8, 0x7b, 0x00, 0x00, 0xf0, 0x02, 0x97, 0x64, 0x47, 0x67,
|
||||
0xff, 0x00, 0x02, 0x98, 0xcd, 0x04, 0x00, 0xf0, 0x02, 0x89, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x98, 0x3e, 0x16, 0x00, 0xf0, 0x02, 0x98, 0xba, 0x16,
|
||||
0x00, 0x02, 0xa8, 0x7b, 0x00, 0x00, 0xf0, 0x02, 0x98, 0x42, 0x08, 0x00,
|
||||
0xf0, 0x02, 0x97, 0x64, 0x47, 0x67, 0xff, 0x00, 0x02, 0x98, 0xcd, 0x04,
|
||||
0x00, 0xf0, 0x02, 0x98, 0x3e, 0x16, 0x00, 0xf0, 0x02, 0x98, 0xba, 0x16,
|
||||
0x00, 0xf0, 0x02, 0x97, 0x37, 0xf2, 0x06, 0xf0, 0x00, 0x02, 0x97, 0xff,
|
||||
0xff, 0xff, 0xff, 0x01, 0x02, 0x98, 0x27, 0x17, 0x00, 0xf0, 0x02, 0x97,
|
||||
0x84, 0xf1, 0x06, 0xf0, 0x00, 0x02, 0x97, 0x10, 0x00, 0x00, 0x00, 0x01,
|
||||
|
|
|
@ -16,7 +16,7 @@ uint32_t PixelBuffer[FRAMEBUFFER_WIDTH * FRAMEBUFFER_HEIGHT];
|
|||
|
||||
extern fox32_vm_t vm;
|
||||
|
||||
void FramebufferDraw(struct Screen screen) {
|
||||
void FramebufferDraw(struct Screen *screen) {
|
||||
SDL_Texture *texture = ScreenGetTexture(screen);
|
||||
memcpy(PixelBuffer, &vm.memory_ram[0x02000000], FRAMEBUFFER_WIDTH * FRAMEBUFFER_HEIGHT * 4);
|
||||
SDL_UpdateTexture(texture, NULL, PixelBuffer, FRAMEBUFFER_WIDTH * 4);
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
|
||||
#define VSYNC_INTERRUPT_VECTOR 0xFF
|
||||
|
||||
void FramebufferDraw(struct Screen screen);
|
||||
void FramebufferDraw(struct Screen *screen);
|
||||
|
|
28
src/screen.c
28
src/screen.c
|
@ -56,7 +56,7 @@ void ScreenInit() {
|
|||
}
|
||||
|
||||
void ScreenDraw() {
|
||||
MainScreen.Draw(MainScreen);
|
||||
MainScreen.Draw(&MainScreen);
|
||||
|
||||
SDL_Rect screenrect = {
|
||||
.w = MainScreen.Width,
|
||||
|
@ -111,7 +111,7 @@ int ScreenProcessEvents() {
|
|||
case SDL_MOUSEMOTION: {
|
||||
if (ScreenMouseGrabbed) {
|
||||
if (MainScreen.MouseMoved)
|
||||
MainScreen.MouseMoved(MainScreen, event.motion.xrel, event.motion.yrel);
|
||||
MainScreen.MouseMoved(&MainScreen, event.motion.xrel, event.motion.yrel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -127,14 +127,14 @@ int ScreenProcessEvents() {
|
|||
}
|
||||
|
||||
if (MainScreen.MousePressed)
|
||||
MainScreen.MousePressed(MainScreen, event.button.button);
|
||||
MainScreen.MousePressed(&MainScreen, event.button.button);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case SDL_MOUSEBUTTONUP: {
|
||||
if (MainScreen.MouseReleased)
|
||||
MainScreen.MouseReleased(MainScreen, event.button.button);
|
||||
MainScreen.MouseReleased(&MainScreen, event.button.button);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -149,12 +149,12 @@ int ScreenProcessEvents() {
|
|||
}
|
||||
|
||||
if (MainScreen.KeyPressed)
|
||||
MainScreen.KeyPressed(MainScreen, event.key.keysym.scancode);
|
||||
MainScreen.KeyPressed(&MainScreen, event.key.keysym.scancode);
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
if (MainScreen.KeyReleased)
|
||||
MainScreen.KeyReleased(MainScreen, event.key.keysym.scancode);
|
||||
MainScreen.KeyReleased(&MainScreen, event.key.keysym.scancode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -162,22 +162,22 @@ int ScreenProcessEvents() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct SDL_Texture *ScreenGetTexture(struct Screen screen) {
|
||||
if (screen.Texture) {
|
||||
return screen.Texture;
|
||||
struct SDL_Texture *ScreenGetTexture(struct Screen *screen) {
|
||||
if (screen->Texture) {
|
||||
return screen->Texture;
|
||||
}
|
||||
|
||||
screen.Texture = SDL_CreateTexture(
|
||||
screen->Texture = SDL_CreateTexture(
|
||||
ScreenRenderer,
|
||||
SDL_PIXELFORMAT_ABGR32,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
screen.Width,
|
||||
screen.Height
|
||||
screen->Width,
|
||||
screen->Height
|
||||
);
|
||||
|
||||
SDL_SetTextureScaleMode(screen.Texture, SDL_ScaleModeNearest);
|
||||
SDL_SetTextureScaleMode(screen->Texture, SDL_ScaleModeNearest);
|
||||
|
||||
return screen.Texture;
|
||||
return screen->Texture;
|
||||
}
|
||||
|
||||
struct Screen ScreenCreate(
|
||||
|
|
14
src/screen.h
14
src/screen.h
|
@ -4,12 +4,12 @@
|
|||
|
||||
struct Screen;
|
||||
|
||||
typedef void (*ScreenDrawF)(struct Screen screen);
|
||||
typedef void (*ScreenKeyPressedF)(struct Screen screen, int sdlscancode);
|
||||
typedef void (*ScreenKeyReleasedF)(struct Screen screen, int sdlscancode);
|
||||
typedef void (*ScreenMousePressedF)(struct Screen screen, int button);
|
||||
typedef void (*ScreenMouseReleasedF)(struct Screen screen, int button);
|
||||
typedef void (*ScreenMouseMovedF)(struct Screen screen, int dx, int dy);
|
||||
typedef void (*ScreenDrawF)(struct Screen *screen);
|
||||
typedef void (*ScreenKeyPressedF)(struct Screen *screen, int sdlscancode);
|
||||
typedef void (*ScreenKeyReleasedF)(struct Screen *screen, int sdlscancode);
|
||||
typedef void (*ScreenMousePressedF)(struct Screen *screen, int button);
|
||||
typedef void (*ScreenMouseReleasedF)(struct Screen *screen, int button);
|
||||
typedef void (*ScreenMouseMovedF)(struct Screen *screen, int dx, int dy);
|
||||
|
||||
struct Screen {
|
||||
int Width;
|
||||
|
@ -33,7 +33,7 @@ void ScreenDraw();
|
|||
|
||||
int ScreenProcessEvents();
|
||||
|
||||
struct SDL_Texture *ScreenGetTexture(struct Screen screen);
|
||||
struct SDL_Texture *ScreenGetTexture(struct Screen *screen);
|
||||
|
||||
struct Screen ScreenCreate(
|
||||
int w, int h, char *title,
|
||||
|
|
Loading…
Reference in New Issue
Block a user