Hello,
I am currently working on creating a framebuffer in Assembly for a Raspberry Pi 5 Bare-Metal project. It should be 1920x1080 with 32-bit depth. Here is my code:
With this code, I get a screen with 1920x1080 pixels, but it only has 16-bit depth. The return values I see in my structure are: m_nDepth = 32, m_nPitch = 0xf00. When I use these values, the positions on the screen are obviously incorrect. Does anyone have any ideas?
I am currently working on creating a framebuffer in Assembly for a Raspberry Pi 5 Bare-Metal project. It should be 1920x1080 with 32-bit depth. Here is my code:
Code:
//// screen.S//#include "base.h"#include "mailbox.h".equ SCREEN_X, 1920.equ SCREEN_Y, 1080.equ BITS_PER_PIXEL, 32.section ".text.boot".globl Init_ScreenInit_Screen:str x30, [sp, -16]!ldr w0, =BCM_MAILBOX_PROP_OUTldr x1, =pScreenbl MailBox_WriteReadldr x0,=m_nBufferPtrldr w0,[x0]and w0,w0,#0x3FFFFFFFldr x1, =graphicsAddressstr w0,[x1]ldr x0, =m_nDepthldr w0,[x0]cmp w0, 32bne Init_Screen_falsemov w0,1ldr x30, [sp], 16retInit_Screen_false:movw0,0ldr x30, [sp], 16ret.globl DrawPixelDrawPixel: stp x29, x30, [sp, -16]! mov x29, sp ldr x3, =m_nWidth ldr w3,[x3] sub w3,w3,1 cmp w0, w3 bge DrawPixel_End ldr x3, =m_nHeight ldr w3,[x3] sub w3,w3,1 cmp w1, w3 bge DrawPixel_Endldr x3,=graphicsAddressldr w3,[x3]ldr x4,=m_nPitchldr w4,[x4] //lsr w4,w4,#2 <- mul w4,w4,w1add w4,w4,w0mov w4,w4lsl x4,x4,#2add x3,x3,x4str w2,[x3]DrawPixel_End: ldp x29, x30, [sp], 16 ret.section .data.align 16pScreen:.int pScreen_end - pScreen.int CODE_REQUEST.int PROPTAG_SET_PHYS_WIDTH_HEIGHT.int 8 .int 0 m_nWidth: .int SCREEN_X m_nHeight: .int SCREEN_Y .int PROPTAG_SET_VIRT_WIDTH_HEIGHT .int 8 .int 0 m_nVirtualWidth:.int SCREEN_X m_nVirtualHeight:.int SCREEN_Y .int PROPTAG_SET_DEPTH .int 4 .int 0 m_nDepth: .int BITS_PER_PIXEL .int PROPTAG_SET_VIRTUAL_OFFSET.int 8.int 0.int 0.int 0.int PROPTAG_ALLOCATE_BUFFER.int 8.int 4m_nBufferPtr:.int 0m_nBufferSize:.int 0.int PROPTAG_GET_PITCH.int 4.int 0m_nPitch:.int 0 .int PROPTAG_ENDpScreen_end:.align 2graphicsAddress:.int 0
With this code, I get a screen with 1920x1080 pixels, but it only has 16-bit depth. The return values I see in my structure are: m_nDepth = 32, m_nPitch = 0xf00. When I use these values, the positions on the screen are obviously incorrect. Does anyone have any ideas?
Statistics: Posted by satyria — Thu Jun 13, 2024 8:59 pm — Replies 1 — Views 44