diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2026-11-14 18:38:26 -0600 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2026-11-14 18:38:26 -0600 |
| commit | c12d946e4e8c8e42a6f6a71f6e7cd557aa59c5d3 (patch) | |
| tree | 7d07f454d406408354cb67132244574f44a77b97 /armmaku/armmaku_render.S | |
| parent | 64321f1b4b50c46ae57f8c083bc110a75849dd9d (diff) | |
| download | demos-c12d946e4e8c8e42a6f6a71f6e7cd557aa59c5d3.tar.gz demos-c12d946e4e8c8e42a6f6a71f6e7cd557aa59c5d3.zip | |
Diffstat (limited to 'armmaku/armmaku_render.S')
| -rw-r--r-- | armmaku/armmaku_render.S | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/armmaku/armmaku_render.S b/armmaku/armmaku_render.S new file mode 100644 index 0000000..40e50c4 --- /dev/null +++ b/armmaku/armmaku_render.S @@ -0,0 +1,128 @@ +// ================================================================================================ +// Code +// ================================================================================================ +SECTION_TEXT + +// draw a single character +// w0: x (top-left) +// w1: y (top-left) +// w2: color +// w3: ASCII character +SYM(r_char): + stp x29, x30, [sp, #-16]! + mov x29, sp + + LOADADDR x9, g_fbufmap + ldr x9, [x9] + + LOADADDR x10, g_fstride + ldr w10, [x10] + + LOADADDR x11, g_font + + // x offset + mov w12, #4 + mul w12, w12, w0 + add x9, x9, w12, uxtw + + // y offset + mul w12, w10, w1 + add x9, x9, w12, uxtw + + // glyph offset + mov w12, #14 + mul w12, w12, w3 + add x11, x11, w12, uxtw + + mov w14, #0 // y cursor +LBL(r_char_yloop): + mov w13, #0 // x cursor + mov x15, x9 // dst row + ldrb w16, [x11] // src row +LBL(r_char_xloop): + tst w16, #0x80 + b.eq 1f + str w2, [x15] +1: + lsl w16, w16, #1 + add x15, x15, #4 + add w13, w13, #1 + cmp w13, #8 + b.lt LBL(r_char_xloop) + + add x9, x9, w10, uxtw + add w14, w14, #1 + add x11, x11, #1 + cmp w14, #14 + b.lt LBL(r_char_yloop) + + ldp x29, x30, [sp], #16 + ret + +// draw a string of characters +// w0: x (top-left) +// w1: y (top-left) +// w2: color +// x3: ASCII string +SYM(r_chars): + stp x29, x30, [sp, #-16]! + mov x29, sp + + mov x5, x3 +LBL(r_chars_loop): + ldrb w3, [x5] + cmp w3, #0 + b.eq 1f + bl SYM(r_char) + add x5, x5, #1 + add w0, w0, #8 + b LBL(r_chars_loop) +1: + + ldp x29, x30, [sp], #16 + ret + +// draw solid color rect +// w0: x (top-left) +// w1: y (top-left) +// w2: width +// w3: height +// w4: color +SYM(r_quad): + stp x29, x30, [sp, #-16]! + mov x29, sp + + LOADADDR x9, g_fbufmap + ldr x9, [x9] + + LOADADDR x10, g_fstride + ldr w10, [x10] + + // x offset + mov w11, #4 + mul w11, w11, w0 + add x9, x9, w11, uxtw + + // y offset + mul w11, w10, w1 + add x9, x9, w11, uxtw + + mov w12, #0 // y cursor +LBL(r_quad_yloop): + mov w11, #0 // x cursor + mov x13, x9 // row +LBL(r_quad_xloop): + str w4, [x13] + add x13, x13, #4 + add w11, w11, #1 + cmp w11, w2 + b.lt LBL(r_quad_xloop) + + add x9, x9, w10, uxtw + add w12, w12, #1 + cmp w12, w3 + b.lt LBL(r_quad_yloop) + + ldp x29, x30, [sp], #16 + ret + |
