string asis include 'gsos.equ' include 'minix.equ' include 'records.equ' include 'fst.equ' include 'fst.macros' include 'M16.MiscTool' ; ; routines used to store data in parameter blocks ; ; input: ; x - must be preserved. ; y - offset in param_blk_ptr to store the value. ; ; outputs: ; x - must be preserved. ; set tool_error if error. ; import disk_inode:v1_inode import disk_super:v1_super do_ignore proc export rts endp do_file_sys_id proc export with dp with fst_parms lda #fst_id sta [param_blk_ptr],y rts endp ; assumes disk_inode is valid. do_storage_type proc export with dp,fst_parms phx ; save lda disk_inode.mode ; check for directory. GS/OS doesn't have concepts for other types (yet). and #S_IFMT ; $f000 xba lsr a lsr a lsr a tax jmp (table,x) table dc.w unknown dc.w fifo dc.w chr dc.w unknown dc.w dir dc.w unknown dc.w blk dc.w unknown dc.w reg dc.w unknown dc.w lnk dc.w unknown dc.w sock dc.w unknown dc.w wht dc.w unknown unknown lda #0 bra store fifo: chr: blk: lnk: sock: wht: lda disk_inode.mode and #S_IFMT bra store dir ; todo -- $d is for subdirectories. $f is for the volume root (inode 1) ; (however, we could have hard link to inode 1 which is not the root!) lda inode cmp #1 beq @root_dir lda #$0d bra store @root_dir lda #$0f bra store reg lda #1 ; could base it on size but whatever! ; drop through store plx ; restore sta [param_blk_ptr],y rts endp ; assume disk_inode is valid. do_file_type proc export with dp,fst_parms lda disk_inode.mode and #S_IFMT cmp #S_IFREG beq reg cmp #S_IFDIR beq dir unknown lda #$00 bra store dir lda #$0f bra store reg lda #$06 ; binary bra store store sta [param_blk_ptr],y rts endp do_aux_type proc export with dp,fst_parms ; chr and blk -- return the device type. lda disk_inode.mode and #S_IFMT cmp #S_IFCHR beq chr cmp #S_IFBLK beq blk lda #0 sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y rts chr blk lda disk_inode.zone sta [param_blk_ptr],y iny iny lda #0 sta [param_blk_ptr],y rts endp ; assumes disk_inode is valid. do_eof proc export with dp,fst_parms lda disk_inode.size sta [param_blk_ptr],y iny iny lda disk_inode.size+2 sta [param_blk_ptr],y rts endp ; file blocks, not disk blocks. do_blocks proc export with dp,fst_parms with v1 ; minix supports sparse blocks. should just guess based on size... phx ; save phy ; save ; 7 direct blocks, 1 indirect block, 1 double indirect block. ldx #0 ldy #0 ; count @loop lda disk_inode.zone,x beq @next iny @next inx inx cpx #NR_DZONES*2 bcc @loop ; y is number of direct blocks. ; check for indirect block... lda disk_inode.zone + NR_DZONES * 2 beq dib ; ; count up indirect blocks... ; iny dib ; check for double indirect block lda disk_inode.zone + (NR_DZONES + 1) * 2 beq store ; ; count up double indirect blocks.... ; iny store tya ply sta [param_blk_ptr],y iny iny lda #0 sta [param_blk_ptr],y plx ; restore rts endp do_r_eof proc export with dp,fst_parms export do_r_blocks do_r_blocks lda #0 sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y rts endp do_option_list proc export with dp,fst_parms ; if the option list is present, store my fst id. lda [param_blk_ptr],y sta ptr iny iny lda [param_blk_ptr],y sta ptr+2 ora ptr beq exit ; check if the option list ptr is large enough. lda [ptr] cmp #4 bcc pre ; store the size of the option list. ldy #2 lda #2 sta [ptr],y lda [ptr] cmp #6 bcc bts bra ok ; less than 4 is a parm range error. ; less than the necessary option list size is a buf_too_small error. ; (but store the space required) pre lda #parm_range_err sta tool_error bra exit bts lda #buff_too_small sta tool_error bra exit ok ldy #4 lda #fst_id sta [ptr],y exit rts endp do_create_date_time_0 proc export with fst_parms export do_mod_date_time_0 do_mod_date_time_0 with fst_parms ; minix has mod date but not create date. ; check if valid lda disk_inode.mtime ora disk_inode.mtime+2 beq null phx ; save pha ; result space pha pea 4 ; convert from seconds to ProDOS date/time. ; seconds + 0x7be5 1700 to convert from 1970 to 1904 ??? ; ; ; 86400 * (365 * (1970 - 1904) + 17) [17 leap years] ; $7c25b080 ; lda disk_inode.mtime clc adc #$b080 tax lda disk_inode.mtime+2 adc #$7c25 pha phx ; date ptr tya clc adc param_blk_ptr tax lda #0 adc param_blk_ptr+2 pha phx _ConvSeconds pla pla plx rts null lda #0 sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y rts endp do_create_date_time proc export with fst_parms export do_mod_date_time do_mod_date_time ; minix has mod date but not create date. ; check if valid lda disk_inode.mtime ora disk_inode.mtime+2 beq null phx ; save pha ; result space pha pea 0 ; convert from seconds to read time hex. ; seconds + 0x7be5 1700 to convert from 1970 to 1904 ??? ; ; ; 86400 * (365 * (1970 - 1904) + 17) [17 leap years] ; $7c25b080 ; lda disk_inode.mtime clc adc #$b080 tax lda disk_inode.mtime+2 adc #$7c25 pha phx ; date ptr tya clc adc param_blk_ptr tax lda #0 adc param_blk_ptr+2 pha phx _ConvSeconds pla pla plx rts null lda #0 sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y iny iny sta [param_blk_ptr],y rts endp ; ; fcr-based items. ; do_refnum proc export with fst_parms, dp lda [