show_logo: icl ; disable interrupts ; Save old interrupt handler mov r0, [0x3fc] push r0 ; Set vsync interrupt handler to logo display mov [0x3fc], intr_vsync_logo mov [SHOWING_LOGO], 1 mov [FRAMENR], 0 ise ; Enable interrupts ; Wait for logo display interrupt to return show_logo_wait: cmp [SHOWING_LOGO], 1 ifz jmp show_logo_wait icl ; Restore interrupt handler pop r0 mov [0x3fc], r0 ; Draw logo in black (clear) mov r0, 0 mov r1, 0 call draw_logo ret cycle_data: #include_bin "data/logo_cycle.dat" ; defines LOGO_LENGTH #include "data/logo_cycle.inc" intr_vsync_logo: ; [rsp] = interrupt number ; [rsp+4] = flags ; [rsp+8] = previous instuction inc [FRAMENR] mov r2, [FRAMENR] cmp r2, LOGO_LENGTH ifgteq mov [SHOWING_LOGO], 0 ; fetch brightness and glitchiness mul r2, 2 add r2, cycle_data movz.8 r0, [r2] inc r2 movz.8 r1, [r2] call draw_logo add rsp, 4 ; pop interrupt number reti boot_logo: #include_bin "data/logo.dat" ; defines LOGO_WIDTH, LOGO_HEIGHT: #include "data/logo.inc" const LOGO_SCALE: 8 ; pixels per pixel in logo ; input: r0: 0-255 color multiplier ; input: r1: glitch effect draw_logo: mov r31, r0 mov r30, r1 ; r0: x counter ; r1: y counter ; r2: pointer to current boot logo index ; r5: x on screen start ; r6: y on screen start mov r5, SCREEN_WIDTH mov r6, LOGO_WIDTH mul r6, LOGO_SCALE sub r5, r6 ror r5, 1 mov r6, SCREEN_HEIGHT mov r7, LOGO_HEIGHT mul r7, LOGO_SCALE sub r6, r7 ror r6, 1 mov r2, boot_logo mov r1, 0 draw_loop_y: cmp r1, LOGO_HEIGHT ifz jmp draw_logo_done mov r0, 0 draw_loop_x: cmp r0, LOGO_WIDTH ifz jmp draw_loop_x_done ; r3: color to draw mov r3, 0x00000000 ; black xor r2, r30 cmp.8 [r2], 1 ifz mov r3, 0x00040401 ; blue cmp.8 [r2], 2 ifz mov r3, 0x00040403; white cmp.8 [r2], 3 ifz mov r3, 0x00010204; orange xor r2, r30 cmp r30, 0 ifz jmp no_color_glitch cmp r3, 0 ifnz xor r3, r0 ifnz xor r3, r1 no_color_glitch: mov r28, r31 srl r28, 2 mul r3, r28 ; brightness xor r3, r29 or r3, 0xff000000 ; r4: screen buffer index of top left mov r4, r6 mov r7, r1 mul r7, LOGO_SCALE add r4, r7 mul r4, 640 add r4, r5 mov r7, r0 mul r7, LOGO_SCALE add r4, r7 mul r4, 4 add r4, BG_FRAMEBUFFER ; r7: paint x ; r8: point y mov r7, 0 draw_loop_px: cmp r7, LOGO_SCALE ifz jmp draw_loop_px_done mov r8, 0 draw_loop_py: cmp r8, LOGO_SCALE ifz jmp draw_loop_py_done mov r9, r8 mul r9, 640 add r9, r7 mul r9, 4 add r9, r4 mov [r9], r3 inc r8 jmp draw_loop_py draw_loop_py_done: inc r7 jmp draw_loop_px draw_loop_px_done: inc r2 inc r0 jmp draw_loop_x draw_loop_x_done: inc r1 jmp draw_loop_y draw_logo_done: ret