Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Reason for PUSH IX:POP HL is for some reason when using .command extensions it's HL, and at normal ram space it's IX
- So I used PUSH IX:POP HL so I can just have the same file handling code no matter if I was writing a .extension command or a game.
- One important thing to know is ESXDOS sets carry flag if call was not successful. Also, A register is set to error code. Finally, if dot command finishes (RET) with carry flag set, ESXDOS will show an message depending onA register value.
- All that put together means you can for instace call "fopen" and just after add "RET c", and in case open fails ESXDOS will show "file not found", "invalid file name" or whatever.
- I disassembled the bitmap test dot command for this very reason :)
- http://dailly.blogspot.co.uk/2017/06/zx-spectrum-next-bitmap-example.html
- This code of mine has a good example of how to read a file, and it has comments:
- https://github.com/Utodev/ZXUC/blob/master/zxuc.asm
- open and create IX = pointer to filename
- read write IX = buffer, BC = size
- setdrv xor a:rst $08:db $89:xor a:ld (handle),a:ret
- fopen ld b,$01:db 33
- fcreate ld b,$0c:push ix:pop hl:ld a,42:rst $08:db $9a:ld (handle),a:ret
- fread push ix:pop hl:db 62
- handle db 0:or a:ret z:rst $08:db $9d:ret
- fwrite push ix:pop hl:ld a,(handle):or a:ret z:rst $08:db $9e:ret
- fclose ld a,(handle):or a:ret z:rst $08:db $9b:ret
- fseek ld a,(handle):or a:ret z:rst $08:db $9f:ret
- ; // Seek BCDE bytes. A=handle
- ; // L=mode: 0-from start of file
- ; // 1-forward from current position
- ; // 2-back from current position
- ; // On return BCDE=current file pointer.
- ; // Does not currently return bytes
- ; // successfully sought.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement