2019-03-31 22:53:14 +02:00
|
|
|
org 0x0000
|
2019-03-25 09:51:37 +01:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
jmp 0x07C0:main
|
|
|
|
|
|
|
|
times (0x0B - ($-$$)) db 0 ; space-padded
|
|
|
|
fdc:
|
2019-03-27 23:05:00 +01:00
|
|
|
.ss:
|
|
|
|
dw 0x200 ; sector size
|
|
|
|
.sc:
|
2019-03-31 22:53:14 +02:00
|
|
|
db 2 ; sectors per cluster
|
2019-03-27 23:05:00 +01:00
|
|
|
.rsc:
|
2019-03-31 22:53:14 +02:00
|
|
|
dw 1 ; reserved sector count
|
2019-03-27 23:05:00 +01:00
|
|
|
.fn:
|
2019-03-31 22:53:14 +02:00
|
|
|
db 2 ; number of file allocation tables
|
2019-03-27 23:05:00 +01:00
|
|
|
.rde:
|
2019-03-31 22:53:14 +02:00
|
|
|
dw 0x70 ; number of root directory entries
|
2019-03-28 00:06:13 +01:00
|
|
|
.ts:
|
|
|
|
dw 720 ; total number of sectors
|
2019-03-27 23:05:00 +01:00
|
|
|
.mi: ; medium identifier
|
2019-03-25 09:51:37 +01:00
|
|
|
db 0xFD ; 5.25-inch Double sided, 40 tracks per side, 9 sectors per track (360 KB)
|
2019-03-27 23:05:00 +01:00
|
|
|
.sf: ; sectors per fat
|
2019-03-31 22:53:14 +02:00
|
|
|
dw 2
|
2019-03-25 09:51:37 +01:00
|
|
|
.spt:
|
|
|
|
dw 9 ; sectors per track
|
2019-03-27 23:05:00 +01:00
|
|
|
.nos:
|
|
|
|
dw 2 ; number of sides (heads)
|
|
|
|
.po:
|
|
|
|
dd 0 ; partition offset (in LBA blocks)
|
2019-03-28 00:06:13 +01:00
|
|
|
.lrgts:
|
2019-05-07 19:50:07 +02:00
|
|
|
dd 0
|
2019-03-27 23:05:00 +01:00
|
|
|
.drv:
|
2019-03-26 21:46:40 +01:00
|
|
|
db 0 ; drive number
|
|
|
|
db 0
|
2019-03-27 23:05:00 +01:00
|
|
|
db 0x29 ; efdc signature
|
|
|
|
.vid:
|
|
|
|
dd 0 ; volume id
|
|
|
|
.vlabel:
|
|
|
|
db "2B"
|
|
|
|
times (54 - ($-$$)) db " "
|
|
|
|
.fstype:
|
|
|
|
db "FAT12"
|
|
|
|
times (62 - ($-$$)) db " "
|
2019-03-25 09:51:37 +01:00
|
|
|
|
2019-03-30 00:48:18 +01:00
|
|
|
main:
|
2019-05-02 22:51:20 +02:00
|
|
|
cli
|
2019-05-19 22:07:08 +02:00
|
|
|
; setup stack area growing down from directly below us
|
|
|
|
xor ax, ax
|
|
|
|
mov ss, ax
|
|
|
|
mov sp, 0x7C00
|
|
|
|
; setup base segments
|
|
|
|
mov ax, cs
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
; save initial environment
|
2019-04-20 23:02:35 +02:00
|
|
|
push bx
|
|
|
|
push cx
|
|
|
|
push dx
|
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
mov [fdc.drv], dl ; fix drive number in fdc
|
2019-03-31 22:53:14 +02:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
%include "chs.inc"
|
2019-03-29 23:32:50 +01:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
mov di, 0x1000 ; loading address for roms
|
|
|
|
call search_rootdir
|
2019-03-31 15:08:39 +02:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
mov ax, 0xFFFF
|
2019-04-20 23:02:35 +02:00
|
|
|
call error
|
2019-05-19 22:07:08 +02:00
|
|
|
db "THING", 0
|
|
|
|
|
|
|
|
search_rootdir:
|
|
|
|
mov ax, [fdc.sf]
|
|
|
|
mul byte [fdc.fn]
|
|
|
|
add ax, [fdc.rsc]
|
|
|
|
mul word [fdc.ss]
|
|
|
|
mov si, ax ; now pointing to start of rootdir
|
|
|
|
mov cx, [fdc.rde]
|
|
|
|
jmp .start
|
|
|
|
.next:
|
|
|
|
dec cx
|
|
|
|
jz .end
|
|
|
|
add si, 0x20
|
|
|
|
.start:
|
|
|
|
call lazy_load
|
|
|
|
cmp byte [si], 0 ; end of directory
|
|
|
|
je .end
|
|
|
|
cmp byte [si], 0xe5 ; deleted entry
|
|
|
|
je .next
|
|
|
|
cmp word [si+8], 0x4F52 ; first 2 chars of extension: "RO"
|
|
|
|
jne .next
|
|
|
|
mov ax, [si+10] ; 3rd char of extension, file flags
|
|
|
|
and ax, 0x14FF ; zero out flags except directory and system
|
|
|
|
cmp ax, 0x044D ; "M" , system flag set, directory flag unset
|
|
|
|
jne .next
|
|
|
|
mov ax, [si+26]
|
|
|
|
push si
|
|
|
|
push cx
|
|
|
|
call loadrom
|
|
|
|
pop cx
|
|
|
|
pop si
|
|
|
|
jmp .next
|
|
|
|
.end:
|
|
|
|
ret
|
2019-03-31 15:08:39 +02:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
; in ax cluster number
|
|
|
|
loadrom:
|
2019-03-31 15:08:39 +02:00
|
|
|
call print16
|
2019-05-19 22:07:08 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
; Makes sure the block starting with (or under SI) is
|
|
|
|
; already fetched from disk
|
|
|
|
; in ds:si data expected to be fetched from disk
|
|
|
|
; trashes ax, bx and dx
|
|
|
|
lazy_load:
|
|
|
|
cmp si, [max_si]
|
|
|
|
jc .end
|
|
|
|
; calculate next sector number
|
|
|
|
mov ax, [max_si]
|
|
|
|
xor dx, dx
|
|
|
|
div word [fdc.ss]
|
|
|
|
; write to es:bx
|
|
|
|
xor dx, dx
|
2019-03-31 22:53:14 +02:00
|
|
|
push cs
|
2019-05-19 22:07:08 +02:00
|
|
|
pop es
|
|
|
|
mov bx, [max_si]
|
|
|
|
call load_sector
|
|
|
|
; update max_si counter
|
|
|
|
mov ax, [max_si]
|
|
|
|
add ax, [fdc.ss]
|
|
|
|
mov [max_si], ax
|
|
|
|
; loop until requirement is satisfied
|
|
|
|
jmp lazy_load
|
|
|
|
.end:
|
|
|
|
ret
|
|
|
|
|
|
|
|
error:
|
|
|
|
call print16
|
2019-03-31 15:08:39 +02:00
|
|
|
pop si
|
|
|
|
mov bx, 0x0000
|
|
|
|
mov al, 0x20
|
|
|
|
.loop:
|
|
|
|
mov ah, 0x0e
|
|
|
|
int 0x10
|
|
|
|
lodsb
|
|
|
|
cmp al, 0x00
|
|
|
|
jne .loop
|
|
|
|
.hlt:
|
|
|
|
hlt
|
|
|
|
jmp .hlt
|
|
|
|
|
2019-03-25 09:51:37 +01:00
|
|
|
%include "print.asm"
|
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
times (0x1FA - ($-$$)) db 0
|
2019-03-29 22:40:44 +01:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
dw 0x2B2B
|
2019-03-29 22:40:44 +01:00
|
|
|
|
2019-05-19 22:07:08 +02:00
|
|
|
max_si:
|
|
|
|
dw 0x200
|
2019-03-29 22:40:44 +01:00
|
|
|
|
2019-03-25 09:51:37 +01:00
|
|
|
dw 0xAA55
|