parent
7485383d9f
commit
eb67419327
|
|
@ -0,0 +1,14 @@
|
|||
SRC_DIR=$(HOME)/src
|
||||
UVM_JOY=$(SRC_DIR)/Joypy/implementations/uvm-ncc
|
||||
UVM=$(SRC_DIR)/uvm
|
||||
UVM_NCC=$(UVM)/ncc
|
||||
UVM_VM=$(UVM)/vm
|
||||
|
||||
run: $(UVM_NCC)/out.asm
|
||||
cd $(UVM_VM) ; cargo run $(UVM_NCC)/out.asm
|
||||
|
||||
$(UVM_NCC)/out.asm: $(UVM_JOY)/xerblin.c
|
||||
cd $(UVM_NCC) ; cargo run $(UVM_JOY)/xerblin.c
|
||||
|
||||
clean:
|
||||
$(RM) $(UVM_NCC)/out.asm
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
FONT=Inconsolata
|
||||
POINTSIZE=24
|
||||
FILL=white
|
||||
|
||||
TXTS=00.txt 01.txt 02.txt 03.txt 04.txt 05.txt 06.txt 07.txt 08.txt 09.txt 10.txt 11.txt 12.txt 13.txt 14.txt 15.txt 16.txt 17.txt 18.txt 19.txt 20.txt 21.txt 22.txt 23.txt 24.txt 25.txt 26.txt 27.txt 28.txt 29.txt 30.txt 31.txt 32.txt 33.txt 34.txt 35.txt 36.txt 37.txt 38.txt 39.txt 40.txt 41.txt 42.txt 43.txt 44.txt 45.txt 46.txt 47.txt 48.txt 49.txt 50.txt 51.txt 52.txt 53.txt 54.txt 55.txt 56.txt 57.txt 58.txt 59.txt 60.txt 61.txt 62.txt 63.txt 64.txt 65.txt 66.txt 67.txt 68.txt 69.txt 70.txt 71.txt 72.txt 73.txt 74.txt 75.txt 76.txt 77.txt 78.txt 79.txt 80.txt 81.txt 82.txt 83.txt 84.txt 85.txt 86.txt 87.txt 88.txt 89.txt 90.txt 91.txt 92.txt 93.txt
|
||||
BMPS=00.bmp 01.bmp 02.bmp 03.bmp 04.bmp 05.bmp 06.bmp 07.bmp 08.bmp 09.bmp 10.bmp 11.bmp 12.bmp 13.bmp 14.bmp 15.bmp 16.bmp 17.bmp 18.bmp 19.bmp 20.bmp 21.bmp 22.bmp 23.bmp 24.bmp 25.bmp 26.bmp 27.bmp 28.bmp 29.bmp 30.bmp 31.bmp 32.bmp 33.bmp 34.bmp 35.bmp 36.bmp 37.bmp 38.bmp 39.bmp 40.bmp 41.bmp 42.bmp 43.bmp 44.bmp 45.bmp 46.bmp 47.bmp 48.bmp 49.bmp 50.bmp 51.bmp 52.bmp 53.bmp 54.bmp 55.bmp 56.bmp 57.bmp 58.bmp 59.bmp 60.bmp 61.bmp 62.bmp 63.bmp 64.bmp 65.bmp 66.bmp 67.bmp 68.bmp 69.bmp 70.bmp 71.bmp 72.bmp 73.bmp 74.bmp 75.bmp 76.bmp 77.bmp 78.bmp 79.bmp 80.bmp 81.bmp 82.bmp 83.bmp 84.bmp 85.bmp 86.bmp 87.bmp 88.bmp 89.bmp 90.bmp 91.bmp 92.bmp 93.bmp
|
||||
|
||||
all: font.h
|
||||
|
||||
%.bmp: %.txt
|
||||
convert \
|
||||
-background transparent \
|
||||
-depth 8 \
|
||||
-fill $(FILL) \
|
||||
-font $(FONT) \
|
||||
-pointsize $(POINTSIZE) \
|
||||
label:@$< \
|
||||
$@
|
||||
|
||||
|
||||
font.h: $(BMPS) convert.py
|
||||
python ./convert.py > font.h
|
||||
|
||||
$(TXTS): make_txt_files.py
|
||||
python ./make_txt_files.py
|
||||
|
||||
clean:
|
||||
$(RM) $(TXTS)
|
||||
$(RM) $(BMPS)
|
||||
|
||||
|
||||
# -size 1130x27 \
|
||||
# label:@text.txt \
|
||||
|
||||
# 1129 x 27 / 95 chars
|
||||
#>>> 1129 + 1
|
||||
#1130
|
||||
#>>> 1130 // 95
|
||||
#11
|
||||
#>>>
|
||||
# so 11 pixels per character?
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,51 @@
|
|||
from PIL import Image
|
||||
|
||||
txt = (
|
||||
'abcdefghijklmnopqrstuvwxyz'
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
'''0123456789@#$&_~|`'"%^=-+*'''
|
||||
r'/\<>[]{}(),.;:!?'
|
||||
)
|
||||
|
||||
g = ((i, ch) for i, ch in enumerate(txt))
|
||||
|
||||
w, h = Image.open('00.bmp').size
|
||||
|
||||
# Check that all the BMPs are the same size.
|
||||
for i, _ in enumerate(txt):
|
||||
with Image.open(f'{i:02}.bmp') as im:
|
||||
assert im.size == (w, h), f'bad size {i:02}.bmp {w} x {h}!'
|
||||
|
||||
print(f'const int font_width = {w};')
|
||||
print(f'const int font_height = {h};')
|
||||
print(f'pixel_t font_data[{len(txt)}][{w * h}] = {{')
|
||||
for i, ch in enumerate(txt):
|
||||
print(f'\t{{ // {repr(ch)}')
|
||||
with Image.open(f'{i:02}.bmp') as im:
|
||||
data = list(im.getdata())
|
||||
for blue, green, red, alpha in data:
|
||||
print(f'\t\t{{0x{blue:02x}, 0x{green:02x}, 0x{red:02x}, 0x{alpha:02x}}},')
|
||||
print(f'\t}},')
|
||||
print(f'}};')
|
||||
|
||||
##
|
||||
##if len(sys.argv) > 1:
|
||||
## fn = sys.argv[-1]
|
||||
##else:
|
||||
## fn = "font.bmp"
|
||||
##
|
||||
##with Image.open(fn) as im:
|
||||
## data = list(im.getdata())
|
||||
##
|
||||
##print(f'const int font_width = {im.width};')
|
||||
##print(f'const int font_height = {im.height};')
|
||||
##print(f'pixel_t font_data[{len(data)}] = {{')
|
||||
##print(
|
||||
## ',\n'.join(
|
||||
## f'\t{{0x{blue:02x}, 0x{green:02x}, 0x{red:02x}, 0x{alpha:02x}}}'
|
||||
## for blue, green, red, alpha in data[::1000]
|
||||
## )
|
||||
## )
|
||||
##print('};')
|
||||
##
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
txt = (
|
||||
'abcdefghijklmnopqrstuvwxyz'
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
'''0123456789@#$&_~|`'"%^=-+*'''
|
||||
r'/\<>[]{}(),.;:!?'
|
||||
)
|
||||
|
||||
for i, ch in enumerate(txt):
|
||||
open(f'{i:02}.txt', 'w').write(ch)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#include <uvm/syscalls.h>
|
||||
#include <uvm/utils.h>
|
||||
|
||||
#define RED 0xFF_00_00
|
||||
#define GREEN 0x00_FF_00
|
||||
|
||||
size_t FRAME_WIDTH = 1280;
|
||||
size_t FRAME_HEIGHT = 800;
|
||||
|
||||
// RGBA pixels: 800 * 600
|
||||
u32 frame_buffer[1024_000];
|
||||
|
||||
|
||||
void anim_callback()
|
||||
{
|
||||
// Clear the screen
|
||||
memset(frame_buffer, 0, sizeof(frame_buffer));
|
||||
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;
|
||||
}
|
||||
}
|
||||
window_draw_frame(0, frame_buffer);
|
||||
time_delay_cb(100, anim_callback);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0);
|
||||
time_delay_cb(0, anim_callback);
|
||||
enable_event_loop();
|
||||
}
|
||||
Loading…
Reference in New Issue