From f5c5d4bd1b3a32db4e8b115d2c71773dd58d77bf Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 30 Oct 2011 16:22:21 +0800 Subject: [PATCH] Usermode/AxWin3 - Fixed all compile errors, runs and cursor moves, that is all --- Usermode/Applications/axwin3_src/WM/Makefile | 2 +- .../axwin3_src/WM/include/common.h | 22 ++++++++---- .../axwin3_src/WM/include/ipcmessages.h | 16 ++++++--- .../Applications/axwin3_src/WM/include/wm.h | 2 +- Usermode/Applications/axwin3_src/WM/ipc.c | 30 ++++------------ Usermode/Applications/axwin3_src/WM/main.c | 3 +- .../axwin3_src/WM/renderer_classes.c | 2 +- .../axwin3_src/WM/resources/cursor.h | 34 +++++++++++++++++++ Usermode/Applications/axwin3_src/WM/video.c | 12 ++++--- Usermode/Applications/axwin3_src/WM/wm.c | 7 +++- 10 files changed, 87 insertions(+), 43 deletions(-) create mode 100644 Usermode/Applications/axwin3_src/WM/resources/cursor.h diff --git a/Usermode/Applications/axwin3_src/WM/Makefile b/Usermode/Applications/axwin3_src/WM/Makefile index ada8ac3e..86fbbae1 100644 --- a/Usermode/Applications/axwin3_src/WM/Makefile +++ b/Usermode/Applications/axwin3_src/WM/Makefile @@ -6,7 +6,7 @@ CPPFLAGS += -I include/ DIR := Apps/AxWin/3.0 BIN := AxWinWM -OBJ := main.o wm.o input.o ipc.o +OBJ := main.o wm.o input.o video.o ipc.o OBJ += messageio.o OBJ += renderer_classes.o renderer_passthru.o renderer_widget.o diff --git a/Usermode/Applications/axwin3_src/WM/include/common.h b/Usermode/Applications/axwin3_src/WM/include/common.h index 7bc6f60c..360f99ad 100644 --- a/Usermode/Applications/axwin3_src/WM/include/common.h +++ b/Usermode/Applications/axwin3_src/WM/include/common.h @@ -12,15 +12,25 @@ #define TODO(str) +#define UNIMPLEMENTED() do{_SysDebug("TODO: Implement %s", __func__); for(;;);}while(0) + +#define AXWIN_VERSION 0x300 + +// === GLOBALS === +extern int giTerminalFD; +extern const char *gsTerminalDevice; + +extern int giScreenWidth, giScreenHeight; + // === FUNCTIONS === // --- Input --- - int Input_Init(void); -void Input_FillSelect(int *nfds, fd_set *set); -void Input_HandleSelect(fd_set *set); +extern int Input_Init(void); +extern void Input_FillSelect(int *nfds, fd_set *set); +extern void Input_HandleSelect(fd_set *set); // --- IPC --- -void IPC_Init(void); -void IPC_FillSelect(int *nfds, fd_set *set); -void IPC_HandleSelect(fd_set *set); +extern void IPC_Init(void); +extern void IPC_FillSelect(int *nfds, fd_set *set); +extern void IPC_HandleSelect(fd_set *set); #endif diff --git a/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h b/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h index e825293f..d9d7ee83 100644 --- a/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h +++ b/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h @@ -8,22 +8,30 @@ #ifndef _IPCMESSAGES_H_ #define _IPCMESSAGES_H_ -typedef struct sAxWin_IPCMessage tAxWin_IPCMessage; +typedef struct sAxWin_IPCMessage tAxWin_IPCMessage; +typedef struct sIPCMsg_Return tIPCMsg_Return; /** * \name Flags for IPC Messages * \{ */ //! Request a return value -#define IPCMSG_FLAG_RETURN 1 +#define IPCMSG_FLAG_RETURN 0x01 struct sAxWin_IPCMessage { - uint16_t ID; - uint16_t Flags; + uint8_t ID; + uint8_t Flags; + uint16_t Size; + uint32_t Window; char Data[]; }; +struct sIPCMsg_Return +{ + uint32_t Value; +}; + enum eAxWin_IPCMessageTypes { IPCMSG_PING, //!< diff --git a/Usermode/Applications/axwin3_src/WM/include/wm.h b/Usermode/Applications/axwin3_src/WM/include/wm.h index 79b8b3ae..cac23cb3 100644 --- a/Usermode/Applications/axwin3_src/WM/include/wm.h +++ b/Usermode/Applications/axwin3_src/WM/include/wm.h @@ -32,7 +32,7 @@ extern int WM_Reposition(tWindow *Window, int X, int Y, int W, int H); extern int WM_SetFlags(tWindow *Window, int Flags); extern int WM_SendMessage(tWindow *Window, int MessageID, int Length, void *Data); // --- Rendering -extern void Render_DrawFilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H); +extern void WM_Render_FilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H); #endif diff --git a/Usermode/Applications/axwin3_src/WM/ipc.c b/Usermode/Applications/axwin3_src/WM/ipc.c index 01f16be0..30516007 100644 --- a/Usermode/Applications/axwin3_src/WM/ipc.c +++ b/Usermode/Applications/axwin3_src/WM/ipc.c @@ -10,6 +10,7 @@ #include #include #include +#include #define AXWIN_PORT 4101 @@ -28,7 +29,7 @@ struct sIPC_Type void IPC_Init(void); void IPC_FillSelect(int *nfds, fd_set *set); void IPC_HandleSelect(fd_set *set); -void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message *Msg); +void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg); void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value); int IPC_Type_Datagram_GetSize(void *Ident); int IPC_Type_Datagram_Compare(void *Ident1, void *Ident2); @@ -97,25 +98,22 @@ void IPC_HandleSelect(fd_set *set) void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg) { - tApplication *app; - tElement *ele; - _SysDebug("IPC_Handle: (IPCType=%p, Ident=%p, MsgLen=%i, Msg=%p)", IPCType, Ident, MsgLen, Msg); - if( MsgLen < sizeof(tAxWin_Message) ) + if( MsgLen < sizeof(tAxWin_IPCMessage) ) return ; - if( MsgLen < sizeof(tAxWin_Message) + Msg->Size ) + if( MsgLen < sizeof(tAxWin_IPCMessage) + Msg->Size ) return ; - app = AxWin_GetClient(IPCType, Ident); +// win = AxWin_GetClient(IPCType, Ident, Msg->Window); switch((enum eAxWin_IPCMessageTypes) Msg->ID) { // --- Ping message (reset timeout and get server version) case IPCMSG_PING: _SysDebug(" IPC_Handle: IPCMSG_PING"); - if( MsgLen < sizeof(tAxWin_Message) + 4 ) return; + if( MsgLen < sizeof(tAxWin_IPCMessage) + 4 ) return; if( Msg->Flags & IPCMSG_FLAG_RETURN ) { Msg->ID = IPCMSG_PING; @@ -135,22 +133,6 @@ void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_IPCMessag } } -void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value) -{ - char data[sizeof(tAxWin_Message) + sizeof(tAxWin_RetMsg)]; - tAxWin_Message *msg = (void *)data; - tAxWin_RetMsg *ret_msg = (void *)msg->Data; - - msg->Source = 0; // 0 = Server - msg->ID = MSG_SRSP_RETURN; - msg->Size = sizeof(tAxWin_RetMsg); - ret_msg->ReqID = MessageID; - ret_msg->Rsvd = 0; - ret_msg->Value = Value; - - IPCType->SendMessage(Ident, sizeof(data), data); -} - int IPC_Type_Datagram_GetSize(void *Ident) { return 4 + Net_GetAddressSize( ((uint16_t*)Ident)[1] ); diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index 5186c215..2ae11aa7 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -10,6 +10,7 @@ // === IMPORTS === extern void WM_Update(void); +extern void Video_Setup(void); // === PROTOTYPES === void ParseCommandline(int argc, char **argv); @@ -41,7 +42,7 @@ int main(int argc, char *argv[]) gsMouseDevice = "/Devices/PS2Mouse"; } -// Video_Setup(); + Video_Setup(); // Interface_Init(); IPC_Init(); Input_Init(); diff --git a/Usermode/Applications/axwin3_src/WM/renderer_classes.c b/Usermode/Applications/axwin3_src/WM/renderer_classes.c index dfa447e9..2448c63f 100644 --- a/Usermode/Applications/axwin3_src/WM/renderer_classes.c +++ b/Usermode/Applications/axwin3_src/WM/renderer_classes.c @@ -44,7 +44,7 @@ tWindow *Renderer_Class_Create(int Width, int Height, int Flags) void Renderer_Class_Redraw(tWindow *Window) { tClassfulInfo *info = Window->RendererInfo; - Render_DrawFilledRect(Window, info->BGColour, 0, 0, Window->W, Window->H); + WM_Render_FilledRect(Window, info->BGColour, 0, 0, Window->W, Window->H); } int Renderer_Class_HandleMessage(tWindow *Target, int Msg, int Len, void *Data) diff --git a/Usermode/Applications/axwin3_src/WM/resources/cursor.h b/Usermode/Applications/axwin3_src/WM/resources/cursor.h new file mode 100644 index 00000000..3cce1f25 --- /dev/null +++ b/Usermode/Applications/axwin3_src/WM/resources/cursor.h @@ -0,0 +1,34 @@ +/* + */ +#ifndef _RESORUCE_CURSOR_H +#define _RESORUCE_CURSOR_H + +#include + +static struct { + uint16_t W, H, OfsX, OfsY; + uint32_t Data[]; +} cCursorBitmap = { + 8, 16, 0, 0, + { + 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, + 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, + 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, 0x00000000, + 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 + } +}; + +#endif + diff --git a/Usermode/Applications/axwin3_src/WM/video.c b/Usermode/Applications/axwin3_src/WM/video.c index 99b1f9db..d0476d09 100644 --- a/Usermode/Applications/axwin3_src/WM/video.c +++ b/Usermode/Applications/axwin3_src/WM/video.c @@ -5,11 +5,12 @@ * video.c * - Video methods */ -#include "common.h" +#include #include #include #include #include "resources/cursor.h" +#include // === PROTOTYPES === void Video_Setup(void); @@ -21,6 +22,7 @@ void Video_DrawRect(short X, short Y, short W, short H, uint32_t Color); // === GLOBALS === int giVideo_CursorX; int giVideo_CursorY; +uint32_t *gpScreenBuffer; // === CODE === void Video_Setup(void) @@ -64,7 +66,7 @@ void Video_Setup(void) // Create local framebuffer (back buffer) gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 ); - memset32( gpScreenBuffer, 0x8888FF, giScreenWidth*giScreenHeight ); + Video_FillRect(0, 0, giScreenWidth, giScreenHeight, 0x8080FF); // Set cursor position and bitmap ioctl(giTerminalFD, TERM_IOCTL_SETCURSORBITMAP, &cCursorBitmap); @@ -93,6 +95,7 @@ void Video_SetCursorPos(short X, short Y) void Video_FillRect(short X, short Y, short W, short H, uint32_t Color) { + int i; uint32_t *buf = gpScreenBuffer + Y*giScreenWidth + X; _SysDebug("Video_FillRect: (X=%i, Y=%i, W=%i, H=%i, Color=%08x)", @@ -106,8 +109,9 @@ void Video_FillRect(short X, short Y, short W, short H, uint32_t Color) while( H -- ) { - memset32( buf, Color, W ); - buf += giScreenWidth; + for( i = W; i --; ) + *buf++ = Color; + buf += giScreenWidth - W; } } diff --git a/Usermode/Applications/axwin3_src/WM/wm.c b/Usermode/Applications/axwin3_src/WM/wm.c index 0c0756ec..533754c4 100644 --- a/Usermode/Applications/axwin3_src/WM/wm.c +++ b/Usermode/Applications/axwin3_src/WM/wm.c @@ -11,7 +11,7 @@ // === CODE === void WM_RegisterRenderer(tWMRenderer *Renderer) { - TODO("Implement WM_RegisterRenderer"); + UNIMPLEMENTED(); } tWindow *WM_CreateWindowStruct(size_t ExtraSize) @@ -19,3 +19,8 @@ tWindow *WM_CreateWindowStruct(size_t ExtraSize) return NULL; } +void WM_Render_FilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H) +{ + UNIMPLEMENTED(); +} + -- 2.20.1