Example - Layer 2 esxdos
From SpecNext official Wiki
M_GETSETDRV equ $89 F_OPEN equ $9a F_CLOSE equ $9b F_READ equ $9d F_WRITE equ $9e F_SEEK equ $9f F_GET_DIR equ $a8 F_SET_DIR equ $a9 FA_READ equ $01 FA_APPEND equ $06 FA_OVERWRITE equ $0C ESXDOS macro command db $cf db command endm org 32768 start: ld a, '*' ; use current drive ld b, FA_READ ; set mode ld ix, bmp ; filename in ix ESXDOS F_OPEN ret c ; return if failed ld (handle), a ; store handle ld l, 0 ; seek from start of file ld bc, 0 ld de, 1078 ; 54 byte header and 1024 palette ESXDOS F_SEEK ld a, 3 ; enable write bit and make visible writeLoop: push af ; store bitmask ld bc, $123b ; set port for writing out (c), a ld a, (handle) ; restore handle ld ix, $0 ; read 16k into addr 0 ld bc, $4000 ESXDOS F_READ pop af ; restore bit mask add a, 64 ; next page jr nc, writeLoop ESXDOS F_CLOSE ; close file ld bc, $123b ; reset write bit ld a, 2 ; but keep visible out (c), a ret ; have a guess? handle: db 0 bmp: db "test.bmp" end start