Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
090a3ac
commit 90e0c0d
Showing
10 changed files
with
1,998 additions
and
91 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
; Raspberry Pi 2 'Bare Metal' 8BPP Hello World Demo by krom (Peter Lemon): | ||
; 1. Setup Frame Buffer | ||
; 2. Copy Hello World Text Characters To Frame Buffer Using CPU | ||
|
||
format binary as 'img' | ||
include 'LIB\FASMARM.INC' | ||
include 'LIB\R_PI2.INC' | ||
|
||
; Setup Frame Buffer | ||
SCREEN_X = 640 | ||
SCREEN_Y = 480 | ||
BITS_PER_PIXEL = 8 | ||
|
||
; Setup Characters | ||
CHAR_X = 8 | ||
CHAR_Y = 8 | ||
|
||
org $8000 | ||
|
||
FB_Init: | ||
imm32 r0,FB_STRUCT + MAIL_TAGS | ||
imm32 r1,PERIPHERAL_BASE + MAIL_BASE + MAIL_WRITE + MAIL_TAGS | ||
str r0,[r1] ; Mail Box Write | ||
|
||
ldr r0,[FB_POINTER] ; R0 = Frame Buffer Pointer | ||
cmp r0,0 ; Compare Frame Buffer Pointer To Zero | ||
beq FB_Init ; IF Zero Re-Initialize Frame Buffer | ||
|
||
; Draw Characters | ||
imm32 r1,256 + (SCREEN_X * 32) | ||
add r0,r1 ; Place Text At XY Position 256,32 | ||
|
||
adr r1,Font ; R1 = Characters | ||
adr r2,Text ; R2 = Text Offset | ||
mov r3,12 ; R3 = Number Of Text Characters To Print | ||
DrawChars: | ||
mov r4,CHAR_Y ; R4 = Character Row Counter | ||
ldrb r5,[r2],1 ; R5 = Next Text Character | ||
add r5,r1,r5,lsl 6 ; Add Shift To Correct Position In Font (* 64) | ||
|
||
DrawChar: | ||
ldr r6,[r5],4 ; Load Font Text Character 1/2 Row | ||
str r6,[r0],4 ; Store Font Text Character 1/2 Row To Frame Buffer | ||
ldr r6,[r5],4 ; Load Font Text Character 1/2 Row | ||
str r6,[r0],4 ; Store Font Text Character 1/2 Row To Frame Buffer | ||
add r0,SCREEN_X ; Jump Down 1 Scanline | ||
sub r0,CHAR_X ; Jump Back 1 Char | ||
subs r4,1 ; Decrement Character Row Counter | ||
bne DrawChar ; IF (Character Row Counter != 0) DrawChar | ||
|
||
subs r3,1 ; Subtract Number Of Text Characters To Print | ||
subne r0,SCREEN_X * CHAR_Y ; Jump To Top Of Char | ||
addne r0,CHAR_X ; Jump Forward 1 Char | ||
bne DrawChars ; IF (Number Of Text Characters != 0) Continue To Print Characters | ||
|
||
Loop: | ||
b Loop | ||
|
||
align 16 | ||
FB_STRUCT: ; Mailbox Property Interface Buffer Structure | ||
dw FB_STRUCT_END - FB_STRUCT ; Buffer Size In Bytes (Including The Header Values, The End Tag And Padding) | ||
dw $00000000 ; Buffer Request/Response Code | ||
; Request Codes: $00000000 Process Request Response Codes: $80000000 Request Successful, $80000001 Partial Response | ||
; Sequence Of Concatenated Tags | ||
dw Set_Physical_Display ; Tag Identifier | ||
dw $00000008 ; Value Buffer Size In Bytes | ||
dw $00000008 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
dw SCREEN_X ; Value Buffer | ||
dw SCREEN_Y ; Value Buffer | ||
|
||
dw Set_Virtual_Buffer ; Tag Identifier | ||
dw $00000008 ; Value Buffer Size In Bytes | ||
dw $00000008 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
dw SCREEN_X ; Value Buffer | ||
dw SCREEN_Y ; Value Buffer | ||
|
||
dw Set_Depth ; Tag Identifier | ||
dw $00000004 ; Value Buffer Size In Bytes | ||
dw $00000004 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
dw BITS_PER_PIXEL ; Value Buffer | ||
|
||
dw Set_Virtual_Offset ; Tag Identifier | ||
dw $00000008 ; Value Buffer Size In Bytes | ||
dw $00000008 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
FB_OFFSET_X: | ||
dw 0 ; Value Buffer | ||
FB_OFFSET_Y: | ||
dw 0 ; Value Buffer | ||
|
||
dw Set_Palette ; Tag Identifier | ||
dw $00000010 ; Value Buffer Size In Bytes | ||
dw $00000010 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
dw 0 ; Value Buffer (Offset: First Palette Index To Set (0-255)) | ||
dw 2 ; Value Buffer (Length: Number Of Palette Entries To Set (1-256)) | ||
FB_PAL: | ||
dw $00000000,$FFFFFFFF ; RGBA Palette Values (Offset To Offset+Length-1) | ||
|
||
dw Allocate_Buffer ; Tag Identifier | ||
dw $00000008 ; Value Buffer Size In Bytes | ||
dw $00000008 ; 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes | ||
FB_POINTER: | ||
dw 0 ; Value Buffer | ||
dw 0 ; Value Buffer | ||
|
||
dw $00000000 ; $0 (End Tag) | ||
FB_STRUCT_END: | ||
|
||
Text: | ||
db "Hello World!" | ||
|
||
align 4 | ||
Font: | ||
include 'Font8x8.asm' |
Binary file not shown.
Oops, something went wrong.