Skip to content

Commit

Permalink
Input copy/paste, set background image
Browse files Browse the repository at this point in the history
  • Loading branch information
beckadamtheinventor committed Sep 8, 2024
1 parent f29465b commit a5ef8ca
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 128 deletions.
2 changes: 1 addition & 1 deletion bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace bos
?return_code_flags := ti.appData+30 ; flag byte that determines how to interpret the return value of the last run program. Is to be set within the program for non-default return interpretation.
?flashStatusByte := ti.appData+31 ; 1 byte
?filesystem_driver := ti.appData+32 ; 1 byte
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or -1 if nothing is stored.
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or 0 if nothing is stored.
?threading_enabled := ti.appData+36 ; 1 byte, determines if software threading is enabled and whether it should be used in OS routines
?current_thread := ti.appData+37 ; 1 byte, currently running thread ID
?gfx_string_temp := ti.appData+38 ; 16 bytes, temp location for integer printing
Expand Down
2 changes: 1 addition & 1 deletion convert_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def convert(fnamein, fnameout, mode=None):
with Image.open(fnamein) as img:
img = img.resize((320, (img.height*320)//img.width))
if img.height > 220:
img = img.crop((0, 110-img.height//2, 320, 110+img.height//2))
img = img.crop((0, 0, 320, 220))
# img = img.convert("RGB").quantize(palette=Image.open(os.path.join(os.path.dirname(__file__), "xlibc_palette.png")).convert("P"))
img = img.convert("RGB").convert("P", palette=xlibc_palette)
img.save(os.path.join(tmp, "image.png"))
Expand Down
2 changes: 2 additions & 0 deletions src/boot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ os_return_soft:
; set ti.bIntOSTmr,(hl)
call gfx_Set8bpp
xor a,a
sbc hl,hl
ld (copy_buffer),hl
call gfx_SetDraw

call os_check_recovery_key
Expand Down
244 changes: 129 additions & 115 deletions src/data/adrive/src/fs/bin/explorer/config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ explorer_configure_theme:
jq nz,.display_theme_loop_skip_4b_loop
jq .display_themes_loop
.done_displaying_themes:
ld hl,themes_option_strings
push hl
call draw_taskbar
pop bc
; ld hl,(.smc_y)
; ld de,display_margin_left+11
; ld bc,str_CustomTheme
Expand Down Expand Up @@ -118,6 +122,10 @@ explorer_configure_theme:
call bos.sys_WaitKeyCycle
cp a,ti.skClear
ret z
cp a,ti.skYequ
jq z,.custom
cp a,ti.skWindow
jq z,.background_image
cp a,ti.skEnter
jq z,.select
cp a,ti.skUp
Expand Down Expand Up @@ -178,123 +186,129 @@ explorer_configure_theme:
pop bc,bc,bc,bc
ret

; .colors:
; db 4 dup 0
; .exit:
; ld c,1
; push bc
; call gfx_SetDraw
; pop bc,bc ; pop caller of explorer_configure_theme.main
; ret
; .custom:
; ld a,(explorer_background_color)
; ld (.colors+0),a
; ld a,(explorer_statusbar_color)
; ld (.colors+1),a
; ld a,(explorer_foreground_color)
; ld (.colors+2),a
; ld a,(explorer_foreground2_color)
; ld (.colors+3),a
; ld hl,.colors
; .customloop:
; push hl
; ld c,1
; push bc
; call gfx_SetDraw
; pop bc
; ld bc,10
; ld (.drawbox_x_smc),bc
; ld a,(.colors+0)
; ld (explorer_background_color),a
; ld a,(.colors+1)
; ld (explorer_statusbar_color),a
; ld a,(.colors+2)
; ld (explorer_foreground_color),a
; ld a,(.colors+3)
; ld (explorer_foreground2_color),a
.background_image:
ld hl,$FF0000
ld de,str_ImageFilePrompt
call explorer_input_file_name
jp explorer_load_config.setbackgroundimage_entryhl

; call draw_background
; ld a,(explorer_background_color)
; call .drawbox
; ld a,(explorer_statusbar_color)
; call .drawbox
; ld a,(explorer_foreground_color)
; call .drawbox
; ld a,(explorer_foreground2_color)
; call .drawbox
; ld c,0
; push bc
; call gfx_SetColor
; pop bc
; ld bc,16
; push bc
; ld c,60
; push bc
; ld bc,0
; .custom_selected_x:=$-3
; push bc
; call gfx_HorizLine
; pop bc,bc,bc
; call gfx_BlitBuffer
; ld a,20
; call ti.DelayTenTimesAms
; call bos.sys_WaitKey
; pop hl
; cp a,ti.skRight
; jq nz,.dontprevcolor
; dec hl
; .dontprevcolor:
; cp a,ti.skLeft
; jq nz,.dontnextcolor
; inc hl
; .dontnextcolor:
; ld c,a
; ld a,l
; cp a, (.colors-1) and $FF
; jq nz,.notunder
; ld l, (.colors+3) and $FF
; .notunder:
; cp a, (.colors+4) and $FF
; jq nz,.notover
; ld l, .colors and $FF
; .notover:
; ld a,c
; cp a,ti.skUp
; jq nz,.dontdecrementcolor
; dec (hl)
; .dontdecrementcolor:
; cp a,ti.skDown
; jq nz,.dontincrementcolor
; inc (hl)
; .dontincrementcolor:
; cp a,ti.skClear
; jq z,.exit
; cp a,ti.skEnter
; jq nz,.customloop
; call explorer_write_config
; pop hl
; ret c ; return to caller of explorer_configure_theme if malloc failed
; jp (hl) ; otherwise return to caller of explorer_configure_theme.main
.colors:
db 4 dup 0
.exit:
ld c,1
push bc
call gfx_SetDraw
pop bc,bc ; pop caller of explorer_configure_theme.main
ret
.custom:
ld a,(explorer_background_color)
ld (.colors+0),a
ld a,(explorer_statusbar_color)
ld (.colors+1),a
ld a,(explorer_foreground_color)
ld (.colors+2),a
ld a,(explorer_foreground2_color)
ld (.colors+3),a
ld hl,.colors
.customloop:
push hl
ld c,1
push bc
call gfx_SetDraw
pop bc
ld bc,10
ld (.drawbox_x_smc),bc
ld a,(.colors+0)
ld (explorer_background_color),a
ld a,(.colors+1)
ld (explorer_statusbar_color),a
ld a,(.colors+2)
ld (explorer_foreground_color),a
ld a,(.colors+3)
ld (explorer_foreground2_color),a

; .drawbox:
; ld c,a
; push bc
; call gfx_SetColor
; pop bc
; ld bc,16
; push bc,bc
; ld bc,40
; push bc
; ld bc,0
; .drawbox_x_smc:=$-3
; push bc
; call gfx_FillRectangle
; pop bc,bc,bc,de
; ld hl,(.drawbox_x_smc)
; add hl,bc
; inc hl
; ld (.drawbox_x_smc),hl
; ret
call draw_background
ld a,(explorer_background_color)
call .drawbox
ld a,(explorer_statusbar_color)
call .drawbox
ld a,(explorer_foreground_color)
call .drawbox
ld a,(explorer_foreground2_color)
call .drawbox
ld c,0
push bc
call gfx_SetColor
pop bc
ld bc,16
push bc
ld c,60
push bc
ld bc,0
.custom_selected_x:=$-3
push bc
call gfx_HorizLine
pop bc,bc,bc
call gfx_BlitBuffer
ld a,20
call ti.DelayTenTimesAms
call bos.sys_WaitKey
pop hl
cp a,ti.skRight
jq nz,.dontprevcolor
dec hl
.dontprevcolor:
cp a,ti.skLeft
jq nz,.dontnextcolor
inc hl
.dontnextcolor:
ld c,a
ld a,l
cp a, (.colors-1) and $FF
jq nz,.notunder
ld l, (.colors+3) and $FF
.notunder:
cp a, (.colors+4) and $FF
jq nz,.notover
ld l, .colors and $FF
.notover:
ld a,c
cp a,ti.skUp
jq nz,.dontdecrementcolor
dec (hl)
.dontdecrementcolor:
cp a,ti.skDown
jq nz,.dontincrementcolor
inc (hl)
.dontincrementcolor:
cp a,ti.skClear
jq z,.exit
cp a,ti.skEnter
jq nz,.customloop
call explorer_write_config
pop hl
ret c ; return to caller of explorer_configure_theme if malloc failed
jp (hl) ; otherwise return to caller of explorer_configure_theme.main

.drawbox:
ld c,a
push bc
call gfx_SetColor
pop bc
ld bc,16
push bc,bc
ld bc,40
push bc
ld bc,0
.drawbox_x_smc:=$-3
push bc
call gfx_FillRectangle
pop bc,bc,bc,de
ld hl,(.drawbox_x_smc)
add hl,bc
inc hl
ld (.drawbox_x_smc),hl
ret


explorer_write_config:
Expand Down
24 changes: 22 additions & 2 deletions src/data/adrive/src/fs/bin/explorer/data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,32 @@ new_file_option_strings:
.l1:
db "file",0
.l2:
db "dir",0
db "dir"
.l3:
; db "link",0
.l4:
; db "image"
.l5:
db 0

themes_option_strings:
dl .strings
db 4 dup $C9
db 4 dup $C9
db 4 dup $C9
db 4 dup $C9
db 4 dup $C9
.strings:
dl .l1, .l2, .l3, .l4, .l5
.l1:
db "Custom",0
.l2:
db "Image"
.l3:
.l4:
.l5:
db 0

explorer_themes_default:
db "BOS Blue",0,$08,$11,$FF,$07
db "BOS Green",0,$04,$02,$AF,$C7
Expand All @@ -95,12 +113,14 @@ str_NewFileNamePrompt:
db "File name? ",0
str_NewDirNamePrompt:
db "Directory name? ",0
str_ImageFilePrompt:
db "Image file? ",0
; str_NewLinkPrompt:
; db "Link file name? ",0
; str_NewImagePrompt:
; db "Image file name? ",0
str_CustomTheme:
db "Custom Theme",0
db "Custom",0
; str_UsbRecvExecutable:
; db "/bin/usbrecv",0
; str_OffExecutable:
Expand Down
2 changes: 1 addition & 1 deletion src/data/adrive/src/fs/bin/explorer/display.asm
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ explorer_display_diritems:
pop hl
jq .dont_draw_extension
.main_draw_regular_file_name:
ld b,8
ld b,10
.main_draw_file_name_loop:
ld a,(hl)
or a,a
Expand Down
5 changes: 4 additions & 1 deletion src/data/adrive/src/fs/bin/explorer/loadconfig.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ explorer_load_config:
jq z,.nextline
.check:
push hl,bc
ld bc,.next ; push this so we can conditionally "return" to .next instead of using many conditional jumps
; push this so we can conditionally "return" to .next instead of using many conditional jumps.
; also so that we can call some of the subroutines (namely .setbackgroundimage) externally.
ld bc,.next
push bc
ld bc,(hl)
ld (ix-3),bc
Expand Down Expand Up @@ -212,6 +214,7 @@ str_fg2:=$-3

.setbackgroundimage:
ld hl,(ix-6)
.setbackgroundimage_entryhl:
push hl
call bos.fs_GetFilePtr
pop de
Expand Down
2 changes: 1 addition & 1 deletion src/data/adrive/src/fs/bin/include/bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace bos
?return_code_flags := ti.appData+30 ; flag byte that determines how to interpret the return value of the last run program. Is to be set within the program for non-default return interpretation.
?flashStatusByte := ti.appData+31 ; 1 byte
?filesystem_driver := ti.appData+32 ; 1 byte
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or -1 if nothing is stored.
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or 0 if nothing is stored.
?threading_enabled := ti.appData+36 ; 1 byte, determines if software threading is enabled and whether it should be used in OS routines
?current_thread := ti.appData+37 ; 1 byte, currently running thread ID
?gfx_string_temp := ti.appData+38 ; 16 bytes, temp location for integer printing
Expand Down
2 changes: 1 addition & 1 deletion src/data/adrive/src/fs/bin/include/defines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ running_program_ptr := ti.appData+27 ; 3 bytes. Stores pointer to currently r
return_code_flags := ti.appData+30 ; flag byte that determines how to interpret the return value of the last run program. Is to be set within the program for non-default return interpretation.
flashStatusByte := ti.appData+31 ; 1 byte
filesystem_driver := ti.appData+32 ; 1 byte
copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or -1 if nothing is stored.
copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or 0 if nothing is stored.
threading_enabled := ti.appData+36 ; 1 byte, determines if software threading is enabled and whether it should be used in OS routines
current_thread := ti.appData+37 ; 1 byte, currently running thread ID
gfx_string_temp := ti.appData+38 ; 16 bytes, temp location for integer printing
Expand Down
2 changes: 1 addition & 1 deletion src/data/adrive/src/fs/lib/include/bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace bos
?return_code_flags := ti.appData+30 ; flag byte that determines how to interpret the return value of the last run program. Is to be set within the program for non-default return interpretation.
?flashStatusByte := ti.appData+31 ; 1 byte
?filesystem_driver := ti.appData+32 ; 1 byte
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or -1 if nothing is stored.
?copy_buffer := ti.appData+33 ; 3 bytes, points to first copy buffer entry, or 0 if nothing is stored.
?threading_enabled := ti.appData+36 ; 1 byte, determines if software threading is enabled and whether it should be used in OS routines
?current_thread := ti.appData+37 ; 1 byte, currently running thread ID
?gfx_string_temp := ti.appData+38 ; 16 bytes, temp location for integer printing
Expand Down
Loading

0 comments on commit a5ef8ca

Please sign in to comment.