From 128fd4051668f81268e15e6c18f2d9fd4717b65e Mon Sep 17 00:00:00 2001 From: TalonFox <105325988+TalonFox@users.noreply.github.com> Date: Tue, 7 Mar 2023 19:57:20 -0600 Subject: [PATCH] Added a Mac-style disk icon Signed-off-by: TalonFox <105325988+TalonFox@users.noreply.github.com> --- font/disk1.png | Bin 0 -> 766 bytes font/disk1.raw | Bin 0 -> 4096 bytes font/disk2.png | Bin 0 -> 787 bytes font/disk2.raw | Bin 0 -> 4096 bytes icon.asm | 75 ++++++++++++++++++++++++++++++++++++++++++ main.asm | 86 ++++++++++++++++++++++++++++++++----------------- vsync.asm | 1 + 7 files changed, 132 insertions(+), 30 deletions(-) create mode 100644 font/disk1.png create mode 100644 font/disk1.raw create mode 100644 font/disk2.png create mode 100644 font/disk2.raw create mode 100644 icon.asm diff --git a/font/disk1.png b/font/disk1.png new file mode 100644 index 0000000000000000000000000000000000000000..eea8defafc81529db1baa2ce6a4986488764a220 GIT binary patch literal 766 zcmVEX>4Tx04R}tkv&MmP!xqvQ>7vm2Rn#3M5s;{L`58J6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5di;PO7sd*^W9eSpxYFwN?k05sh; z)5(OG&8>=|R|FBF5-=h&%ZN)-3cl;>9s$1J#dwzgy+2o)WQiH^gTvt4P<6LxE;F%FKlb$Dz5R1hQRyvrKOpSP&II3zo1T3qe}9ES00006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=K}`=D=b?K>>vOD02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{007oWL_t(o!`+wN5`-WKg+0FiJG(b)Z4Jf|L8kSFY9{zR z#g8c8)mm$1;{t$k56)U`F@6qT8Nn|Qzcd*T?@{3L-4pIkA5-1XtJ#3R_TAyq9PEa1+)`>^xU5(?tyT_iJ8*&p*>qSd1nT97` z_i%%*hRsi|VbgRs?=ZJc*YG)VFLCqu&bfCr?q28F%`6Wb^jvazwwHdNmD3EK?%ek( zryJBgIQVMEl;=L^zNYy;x%~ceKh4T$2Re6c%Hx+e-LwhdXG3}YZQk4|H)(B`-f2F`;sJFF4o>$soh;bA z>_GRRfxf%rWD;Ahc~WC;`AH*_=>BJRcs+l|$s{V58uPYu&s{frGT?Tf%;xbs?%%j) y;1iy7lifPoj@*QvnLLy3S?7~~(v_Wdf33gr-S7Uk|N0;FJM{d&_ym8nUe`DJaefZ~ literal 0 HcmV?d00001 diff --git a/font/disk2.png b/font/disk2.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f1ac16327626068ba77445933eebc180fbff20 GIT binary patch literal 787 zcmV+u1MK{XP)EX>4Tx04R}tkv&MmP!xqvQ>7vm2Rn#3M5s;{L`58J6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5di;PO7sd*^W9eSpxYFwN?k05sh; z)5(OG&8>=|R|FBF5-=h&%ZN)-3cl;>9s$1J#dwzgy+2o)WQiH^gTvt4P<6LxE;F%FKlb$Dz5R1hQRyvrKOpSP&II3zo1T3qe}9ES00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=K}`=EdtSiMri;502y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{008SrL_t(o!`)Zg7Q-M26aW98-OKFSod5xEXY<9j4@nw9 zK+1cy)>_%PL`2FrIlFs{!MU(bkUvD+)tnIVI}SX~%@Hu&fs6naxAqqi5wwq_nuXib zu=bpsP0on81gs+WM5qp|xcRi7{5)(Bfq3dka_B&+m;^2=*MSVV_RWh0m<2n^u$cv` z1^kBtNNA*5x;NpqOW3oI|%kX_!+d8liW!9qp$)?qr^jOf;<*F12_XZnUl; zgRX{6kFR0ll$$xcTc>mA9LY;OY5eB9ceUNMzGpXYY1l#cQtxm1^ai&#*WKOe z29?JS-tCzD)S3}o2G4?yva8%HN0E*){hQUCOb&a38nQpY4axE#I;+~dN+IO+M9e(8g{Vx;G{VX zx`y(J2VDaP`ptLUHO^^&vvWRrydd6&cpSaw#CtwEI1pY4m*|>lmxpOtjgy`{_6gB7 zl!s|OjgvmJ;3iBxxzcO=?r-)9$=RTHpeHwP+)wBpa<)h=da`(Lk(?_?C%ElIhwo~) Wax_=`>ARXi&K@0UC1v literal 0 HcmV?d00001 diff --git a/icon.asm b/icon.asm new file mode 100644 index 0000000..ca0288b --- /dev/null +++ b/icon.asm @@ -0,0 +1,75 @@ +; status icon routines +; created by TalonFox for Ry :3 + +; note to self: icon overlay is overlay 28 (0x1c) + +; changes the 32x32 pixel icon to the given icon pointed at the given address +; inputs: +; r0: Pointer to icon data +; outputs: +; none +change_icon: + push r0 + push r1 + push r31 + + ; write the cursor bitmap to the overlay framebuffer + movz.32 r1, r0 + mov r0, ICON_FRAMEBUFFER_PTR + mov r31, 1024 ; 32x32 +change_icon_loop: + mov [r0], [r1] + add r0, 4 + add r1, 4 + loop change_icon_loop + pop r31 + pop r1 + pop r0 + ret + +setup_icon: + push r0 + push r1 + movz r0, 0x8000001c + movz r1, ICON_POSITION_Y + sla r1, 16 + or r1, ICON_POSITION_X + out r0, r1 + add r0, 0x100 + movz r1, ICON_HEIGHT + sla r1, 16 + or r1, ICON_WIDTH + out r0, r1 + add r0, 0x100 + movz r1, ICON_FRAMEBUFFER_PTR + out r0, r1 + add r0, 0x100 + movz r1, 1 + out r0, r1 + pop r1 + pop r0 + ret + +const ICON_TICK: 0x03FFFFFC + +icon_update: + push r0 + mov.32 r0, [ICON_TICK] + add r0, 1 + rem r0, 60 + mov.32 [ICON_TICK], r0 + cmp r0, 0 + ifz jmp icon_update1 + cmp r0, 30 + ifz jmp icon_update2 + jmp icon_update_ret +icon_update1: + movz r0, disk_icon_q + call change_icon + jmp icon_update_ret +icon_update2: + movz r0, disk_icon + call change_icon +icon_update_ret: + pop r0 + ret \ No newline at end of file diff --git a/main.asm b/main.asm index 5d93afa..5cbb53d 100644 --- a/main.asm +++ b/main.asm @@ -121,36 +121,42 @@ draw_bottom_bar_loop: call draw_format_str_to_background ; draw the box in the middle of the screen - mov r0, 242 - mov r1, 203 - mov r2, 156 - mov r3, 60 - mov r4, 0xFFFFFFFF - call draw_filled_rectangle_to_background - mov r0, 243 - mov r1, 204 - mov r2, 154 - mov r3, 58 - mov r4, 0xFF000000 - call draw_filled_rectangle_to_background - mov r0, 244 - mov r1, 205 - mov r2, 152 - mov r3, 56 - mov r4, 0xFFFFFFFF - call draw_filled_rectangle_to_background + ;mov r0, 242 + ;mov r1, 203 + ;mov r2, 156 + ;mov r3, 60 + ;mov r4, 0xFFFFFFFF + ;call draw_filled_rectangle_to_background + ;mov r0, 243 + ;mov r1, 204 + ;mov r2, 154 + ;mov r3, 58 + ;mov r4, 0xFF000000 + ;call draw_filled_rectangle_to_background + ;mov r0, 244 + ;mov r1, 205 + ;mov r2, 152 + ;mov r3, 56 + ;mov r4, 0xFFFFFFFF + ;call draw_filled_rectangle_to_background ; draw the text inside the box - mov r0, startup_str_0 - mov r1, 256 - mov r2, 216 - mov r3, 0xFF000000 - mov r4, 0x00000000 - call draw_str_to_background - mov r0, startup_str_1 - mov r1, 256 - mov r2, 232 - call draw_str_to_background + ; mov r0, startup_str_0 + ; mov r1, 256 + ; mov r2, 216 + ; mov r3, 0xFF000000 + ; mov r4, 0x00000000 + ; call draw_str_to_background + ; mov r0, startup_str_1 + ; mov r1, 256 + ; mov r2, 232 + ; call draw_str_to_background + + mov r0, disk_icon_q + call change_icon + call setup_icon + + mov r0, bottom_bar_patterns event_loop: call get_next_event @@ -198,6 +204,7 @@ poweroff_wait: #include "draw_tile.asm" #include "event.asm" #include "exception.asm" + #include "icon.asm" #include "integer.asm" #include "keyboard.asm" #include "memory.asm" @@ -341,6 +348,18 @@ standard_font_data: mouse_cursor: #include_bin "font/cursor2.raw" +disk_icon: + #include_bin "font/disk1.raw" +disk_icon_q: + #include_bin "font/disk2.raw" + +; icon overlay struct: +const ICON_WIDTH: 32 +const ICON_HEIGHT: 32 +const ICON_POSITION_X: 304 +const ICON_POSITION_Y: 224 +const ICON_FRAMEBUFFER_PTR: 0x0212C000 + ; cursor overlay struct: const CURSOR_WIDTH: 8 const CURSOR_HEIGHT: 12 @@ -353,6 +372,13 @@ const MENU_BAR_POSITION_X: 0 const MENU_BAR_POSITION_Y: 0 const MENU_BAR_FRAMEBUFFER_PTR: 0x0214C180 +; menu bar overlay struct: +const MENU_BAR_WIDTH: 640 +const MENU_BAR_HEIGHT: 16 +const MENU_BAR_POSITION_X: 0 +const MENU_BAR_POSITION_Y: 0 +const MENU_BAR_FRAMEBUFFER_PTR: 0x0214D180 + ; menu overlay struct: ; this struct must be writable, so these are hard-coded addresses in ram const MENU_WIDTH: 0x02156180 ; 2 bytes @@ -362,8 +388,8 @@ const MENU_POSITION_Y: 0x02156186 ; 2 bytes const MENU_FRAMEBUFFER_PTR: 0x0215618A ; 4 bytes const MENU_FRAMEBUFFER: 0x0215618E ; max 640x480x4 = end address at 0x0228218E -startup_str_0: data.strz "Welcome to fox32" -startup_str_1: data.strz "Insert boot disk" +; startup_str_0: data.strz "Welcome to fox32" +; startup_str_1: data.strz "Insert boot disk" bottom_bar_str_0: data.strz "FOX" bottom_bar_str_1: data.strz "32" diff --git a/vsync.asm b/vsync.asm index 62a6f24..0cb1e6e 100644 --- a/vsync.asm +++ b/vsync.asm @@ -13,6 +13,7 @@ system_vsync_handler: call mouse_update call keyboard_update + call icon_update pop r7 pop r6