Move draw_background to own file graphics.h.
This commit is contained in:
parent
27385e5319
commit
dbc2fe5854
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
void
|
||||||
|
draw_background(u32* buffer, size_t w, size_t h)
|
||||||
|
{
|
||||||
|
for (size_t x = 0; x < w; ++x) {
|
||||||
|
for (size_t y = 0; y < h; ++y) {
|
||||||
|
u32* pix_ptr = frame_buffer + w * y + x;
|
||||||
|
u8 blue = x & 255;
|
||||||
|
u8 green = y & 255;
|
||||||
|
u8 red = (x + y + 128) & 255;
|
||||||
|
u8 alpha = 123;
|
||||||
|
*pix_ptr = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
setenv UVM_JOY $HOME/src/Joypy/implementations/uvm-ncc
|
|
||||||
setenv UVM $HOME/src/uvm
|
|
||||||
setenv UVM_NCC $UVM/ncc
|
|
||||||
setenv UVM_VM $UVM/vm
|
|
||||||
|
|
||||||
cd $UVM_NCC
|
|
||||||
cargo run $UVM_JOY/xerblin.c
|
|
||||||
cd $UVM_VM
|
|
||||||
cargo run $UVM_NCC/out.asm
|
|
||||||
cd $UVM_JOY
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <uvm/syscalls.h>
|
#include <uvm/syscalls.h>
|
||||||
#include <uvm/utils.h>
|
#include <uvm/utils.h>
|
||||||
#include "/home/sforman/src/Joypy/implementations/uvm-ncc/font/font.h"
|
#include "/home/sforman/src/Joypy/implementations/uvm-ncc/font/font.h"
|
||||||
|
#include "/home/sforman/src/Joypy/implementations/uvm-ncc/graphics.h"
|
||||||
|
|
||||||
#define RED 0xFF_00_00
|
#define RED 0xFF_00_00
|
||||||
#define GREEN 0x00_FF_00
|
#define GREEN 0x00_FF_00
|
||||||
|
|
@ -39,21 +40,6 @@ draw_char(u8 ch, u64 dest_x, u64 dest_y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
draw_background()
|
|
||||||
{
|
|
||||||
for (size_t x = 0; x < FRAME_WIDTH; ++x) {
|
|
||||||
for (size_t y = 0; y < FRAME_HEIGHT; ++y) {
|
|
||||||
u32* pix_ptr = frame_buffer + FRAME_WIDTH * y + x;
|
|
||||||
u8 blue = x & 255;
|
|
||||||
u8 green = y & 255;
|
|
||||||
u8 red = (x + y + 128) & 255;
|
|
||||||
u8 alpha = 123;
|
|
||||||
*pix_ptr = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//void
|
//void
|
||||||
//keydown(u64 window_id, u16 keycode)
|
//keydown(u64 window_id, u16 keycode)
|
||||||
|
|
@ -76,7 +62,7 @@ main()
|
||||||
{
|
{
|
||||||
init_font_data();
|
init_font_data();
|
||||||
wid = window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0);
|
wid = window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0);
|
||||||
draw_background();
|
draw_background(frame_buffer, FRAME_WIDTH, FRAME_HEIGHT);
|
||||||
for (size_t ch = 0; ch < 94; ++ch) {
|
for (size_t ch = 0; ch < 94; ++ch) {
|
||||||
draw_char(
|
draw_char(
|
||||||
ch,
|
ch,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue