http://forum.defence-force.org/viewtopi ... highlight=
here to keep it a bit more focused.
Here are the (crapy) routines I used in my first demo (1997) and that I reused in ULA paint for loading and saving pictures...
Basicaly it does the same thing than CLOAD and CSAVE, except that you can force the loading adress to wherever you want (thus ignoring the loading adress that is present in the file header).
From C, I use the routine like this:
Code: Select all
void LoadPicture(const char *ptr_filename)
{
FileFlagForceAdress =1;
FileAdress=BufferMain1;
strcpy((char*)0x27f,ptr_filename);
FileLoad();
}
Here is the assembly code routine:
Code: Select all
_FileFlagForceAdress .byt 0
_FileAdress .byt 0,0
; =========================================
; Load a file from tape
; =========================================
_FileLoad
php
jsr $e76a ; Disable keyboard, enable tape engine remote
jsr $e4ac ; Read tape header
lda _FileFlagForceAdress
beq continue_load
; Patch load start and end adress
clc
lda _FileAdress
sta $2a9
adc #<8000-1
sta $2ab
lda _FileAdress+1
sta $2aa
adc #>8000-1
sta $2ac
continue_load
jsr $e4e0 ; Perform loading of data
jsr $e93d ; Restore keyboard, and stop engine remote
plp
rts
Obviously this crap routine forces the size at 8000 bytes... shame
But I'm too tired to try to correct that. I guess that the idea would be to subtract from 2ab/2ac what is in 2a9/2aa before adding the new forced load adress ?