use ZXpand to load files in asm?
-
- Posts: 325
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
use ZXpand to load files in asm?
Is there any way to load file-data with the ZXpands ROM-hooks in an asm-program without returning to BASIC? Or do I have to write my own code?
/Adam
Re: use ZXpand to load files in asm?
No need to return to basic. You can use some routines in ROM:
This will load content from the file 'file.xyz' located in the folder DIR1 to $8000 in RAM. All strings passed to the 'API' (lol) are high-bit-terminated. Return is by 'GOSLOW', $0207 in ROM.
I am looking at an issue found by Moggy which may indicate some problem in this area - so please let me know how you get on but don't be surprised if it doesn't work As far as I can see from a 10 minute look there is a problem in the file flags reporting, which results in the zxpand ROM overlay being disabled
C
Code: Select all
; de = fname pointer, with optional start,length; a = operation: 0 = load, 1 = delete, 2 = rename, 80-ff = save
;
api_fileop .equ $1ff8
...
call $02e7 ; go fast mode!
ld de,FILEPATH
xor a
call api_fileop
...
FILEPATH:
; file name data should be in zeddy code page, not ASCII
.db "/DIR1/FILE.XYZ;3276",'8'+$80
I am looking at an issue found by Moggy which may indicate some problem in this area - so please let me know how you get on but don't be surprised if it doesn't work As far as I can see from a 10 minute look there is a problem in the file flags reporting, which results in the zxpand ROM overlay being disabled
C
-
- Posts: 325
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: use ZXpand to load files in asm?
That is very similar to what I have done. Unfortunately the call never returns to do the rest of my asm code. Will try some more.
Oh, and so far I've only tested the code in EO 1.2
Oh, and so far I've only tested the code in EO 1.2
/Adam
-
- Posts: 325
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: use ZXpand to load files in asm?
I enclose the source, which does load the file-data to the location I define, but ends with "0/20" instead of going to the endless asm-loop.
Only tested in EO 1.2
---------------------------
format zx81
;labelusenumeric
;LISTOFF
// hardware options to be set and change defaults in ZX81DEF.INC
MEMAVL = MEM_16K // can be MEM_1K, MEM_2K, MEM_4K, MEM_8K, MEM_16K, MEM_32K, MEM_48K
STARTMODE EQU SLOW_MODE // SLOW or FAST
DFILETYPE EQU EXPANDED // COLLAPSED or EXPANDED or AUTO
include '..\SINCL-ZX\ZX81.INC' // definitions of constants
;LISTON
AUTOLINE 10
REM _asm
Main:
ld a,0 ;load file
ld de,FileName
call $1ff8 ;api_fileop
.Loop:
jp .Loop ;endless loop
FileName dbzx 'test.bin;819×' ;the last char is a '2' with high-bit set
END _asm
AUTORUN:
RAND USR #Main
include '..\SINCL-ZX\ZX81DISP.INC' ; include D_FILE and needed memory areas
VARS_ADDR:
db 80h ;DO NOT REMOVE!!!
WORKSPACE:
assert ($-MEMST)<MEMAVL
// end of program
Only tested in EO 1.2
---------------------------
format zx81
;labelusenumeric
;LISTOFF
// hardware options to be set and change defaults in ZX81DEF.INC
MEMAVL = MEM_16K // can be MEM_1K, MEM_2K, MEM_4K, MEM_8K, MEM_16K, MEM_32K, MEM_48K
STARTMODE EQU SLOW_MODE // SLOW or FAST
DFILETYPE EQU EXPANDED // COLLAPSED or EXPANDED or AUTO
include '..\SINCL-ZX\ZX81.INC' // definitions of constants
;LISTON
AUTOLINE 10
REM _asm
Main:
ld a,0 ;load file
ld de,FileName
call $1ff8 ;api_fileop
.Loop:
jp .Loop ;endless loop
FileName dbzx 'test.bin;819×' ;the last char is a '2' with high-bit set
END _asm
AUTORUN:
RAND USR #Main
include '..\SINCL-ZX\ZX81DISP.INC' ; include D_FILE and needed memory areas
VARS_ADDR:
db 80h ;DO NOT REMOVE!!!
WORKSPACE:
assert ($-MEMST)<MEMAVL
// end of program
/Adam
Re: use ZXpand to load files in asm?
By any chance is your test.bin file write protected?
-
- Posts: 325
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: use ZXpand to load files in asm?
Yes the file was write protected, but changing that made no difference. Regardless of what attributes are set on the file, the data gets loaded to memory properly, and the call exits via basic instead of returning to the asm-code.
Edit: after some tracing in EO I found that everything works as expected if I set zero flag true before the comparison at $1e11.
Edit: after some tracing in EO I found that everything works as expected if I set zero flag true before the comparison at $1e11.
Last edited by nollkolltroll on Tue Mar 01, 2016 7:48 am, edited 1 time in total.
/Adam
Re: use ZXpand to load files in asm?
I'm looking into it..
Re: use ZXpand to load files in asm?
Strange. It works on the machine I have here. What firmware do you have, Adam?
PRINT PEEK(7679)
PRINT PEEK(7679)
-
- Posts: 325
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: use ZXpand to load files in asm?
Tested some more: EightyOne v1.2 does not work, EightyOne 1.0 test X3.6 works OK.
I'll do a bug report on EightyOne v1.2 and continue my coding. And test on real HW...
I'll do a bug report on EightyOne v1.2 and continue my coding. And test on real HW...
/Adam
Re: use ZXpand to load files in asm?
Thanks. That's helpful.
The latest EO build was assembled from a fragmented set of sources. Paul did a great job but it's not surprising there are issues. I need to take another look into the EO code soon. I wonder if we should have a bugs thread under emulator topic? keep any information together.
The latest EO build was assembled from a fragmented set of sources. Paul did a great job but it's not surprising there are issues. I need to take another look into the EO code soon. I wonder if we should have a bugs thread under emulator topic? keep any information together.