diff --git a/disk.asm b/disk.asm new file mode 100644 index 0000000..fc9a010 --- /dev/null +++ b/disk.asm @@ -0,0 +1,43 @@ +; disk routines + +; read a sector into the specified memory buffer +; inputs: +; r0: sector number +; r1: disk ID +; r2: sector buffer (512 bytes) +; outputs: +; none +read_sector: + push r3 + push r4 + + mov r3, 0x80002000 ; command to set the location of the buffer + mov r4, 0x80003000 ; command to read a sector from a disk into the buffer + or.8 r4, r1 ; set the disk ID + out r3, r2 ; set the memory buffer location + out r4, r0 ; read the sector into memory + + pop r4 + pop r3 + ret + +; wrtie a sector from the specified memory buffer +; inputs: +; r0: sector number +; r1: disk ID +; r2: sector buffer (512 bytes) +; outputs: +; none +write_sector: + push r3 + push r4 + + mov r3, 0x80002000 ; command to set the location of the buffer + mov r4, 0x80004000 ; command to write a sector to a disk from the buffer + or.8 r4, r1 ; set the disk ID + out r3, r2 ; set the memory buffer location + out r4, r0 ; write the sector from memory + + pop r4 + pop r3 + ret \ No newline at end of file diff --git a/fox32rom.def b/fox32rom.def index 8533fa6..83076a8 100644 --- a/fox32rom.def +++ b/fox32rom.def @@ -45,6 +45,10 @@ draw_menu_items: jmp [0xF0044014] close_menu: jmp [0xF0044018] menu_update_event: jmp [0xF004401C] +; disk jump table +read_sector: jmp [0xF0045000] +write_sector: jmp [0xF0045004] + ; event types const MOUSE_CLICK_EVENT_TYPE: 0x00000000 const MENU_BAR_CLICK_EVENT_TYPE: 0x00000001 diff --git a/main.asm b/main.asm index 4f5438f..684b9f6 100644 --- a/main.asm +++ b/main.asm @@ -127,6 +127,7 @@ get_rom_version: #include "background.asm" #include "boot.asm" #include "debug.asm" + #include "disk.asm" #include "draw_rectangle.asm" #include "draw_text.asm" #include "event.asm" @@ -194,6 +195,11 @@ get_rom_version: data.32 close_menu data.32 menu_update_event + ; disk jump table + org.pad 0xF0045000 + data.32 read_sector + data.32 write_sector + org.pad 0xF004F000 standard_font_width: data.16 8