is it possible to read sectors straight off a disk on the 6128 in basic?

Started by the777, 18:52, 18 January 25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

the777

so i can take the decimal values and turn them into multicolored graphics.

Targhan

You can use the FDC tools I made a long time ago (in my signature). You can read both amsdos files, or the sector directy. The code is old but it is quite simple to understand to fit your needs.
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
CPC Scene Radio! 24/7 CPC music only! Website Stream
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

the777

Quote from: Targhan on 19:05, 18 January 25You can use the FDC tools I made a long time ago (in my signature). You can read both amsdos files, or the sector directy. The code is old but it is quite simple to understand to fit your needs.
i neglected to say, i would like it to work in basic. but thanks ill take a look

Targhan

Oh, well, if you know a bit of asm, you can make a Call with a few parameters (track, sector, sector count, destination buffer) from Basic and create the small asm code to load the sectors with my code.

However, if calling from Basic, I strongly suggest that you use regular Amsdos files, unless you have a very specific use-case!
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
CPC Scene Radio! 24/7 CPC music only! Website Stream
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

the777

Quote from: Targhan on 19:29, 18 January 25Oh, well, if you know a bit of asm, you can make a Call with a few parameters (track, sector, sector count, destination buffer) from Basic and create the small asm code to load the sectors with my code.

However, if calling from Basic, I strongly suggest that you use regular Amsdos files, unless you have a very specific use-case!
ive loaded it into winape and assembled it with no errors. although i cant work out how to call it from basic.

Targhan

The CALL command in Basic allows you to pass a number of 16 bits values and get them from Asm. I don't have the structure right now, but you can retrieve these values from asm via a pointer stored in IX+x (Sorry, I don't know x... maybe someone can be more accurate than I am! Or make a search). Anyway, if you don't know ASM it's not going to be easy for you. Also, you must stop the interruptions (DI) in asm, else the Basic is going meddle with the FDC code, which will make all operation fail (don't forget to EI at the end).

However, once again, I suggest you NOT to read straight sectors in Basic. Why do you want to achieve that you couldn't with straight Amsdos files?
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
CPC Scene Radio! 24/7 CPC music only! Website Stream
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Targhan

Ah, I just read in the code that:

; - The interruptions are CUT by the loading code.
; - Interruptions are turned on when turning on the FDC, so
;   put #c9fb in #38 before if you don't want your
;   interruptions code to be run at this moment.

So no need to DI/EI. However, you must save what is in #38 after the Basic CALL, and restore it before returning, else the Basic won't be able to continue its work (just like the test code that, line 67, though this is the save only, the restore is not here).
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
CPC Scene Radio! 24/7 CPC music only! Website Stream
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

the777

Quote from: Targhan on 20:13, 18 January 25The CALL command in Basic allows you to pass a number of 16 bits values and get them from Asm. I don't have the structure right now, but you can retrieve these values from asm via a pointer stored in IX+x (Sorry, I don't know x... maybe someone can be more accurate than I am! Or make a search). Anyway, if you don't know ASM it's not going to be easy for you. Also, you must stop the interruptions (DI) in asm, else the Basic is going meddle with the FDC code, which will make all operation fail (don't forget to EI at the end).

However, once again, I suggest you NOT to read straight sectors in Basic. Why do you want to achieve that you couldn't with straight Amsdos files?
no as i want to display a map of the disk

the777

Quote from: Targhan on 20:21, 18 January 25Ah, I just read in the code that:

; - The interruptions are CUT by the loading code.
; - Interruptions are turned on when turning on the FDC, so
;  put #c9fb in #38 before if you don't want your
;  interruptions code to be run at this moment.

So no need to DI/EI. However, you must save what is in #38 after the Basic CALL, and restore it before returning, else the Basic won't be able to continue its work (just like the test code that, line 67, though this is the save only, the restore is not here).

 

could you give an example of what i would type in basic? as i dont really understand what #38 means.

Targhan

Quotecould you give an example of what i would type in basic? as i dont really understand what #38 means.

Mmmh, you might lacking some knowledge about how Basic works, and probably ASM, which I don't have time to really fill you in right now, so you'll have to make a search to really understand what is going on.

But basically, in ASM, do this, which looks like I did in the test code (but better: I save what I've modified to restore it at the end):
di
ld hl,(#38)
ld (Save38 + 1),hl
ld hl,#c9fb
ld (#38),hl
... read the Basic parameter via IX, and call the LOADSCTS code.

Then, at the end after reading the sector, restore what you have modified:
Save38 ld hl,0
ld (#38),hl
ei
ret

And you should be good to go. The only thing I didn't explain is how you to get the parameter from Basic. Make a search :).
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
CPC Scene Radio! 24/7 CPC music only! Website Stream
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

BSC

As others have already pointed out, doing it purely in Basic is not possible. But you also don't need to deal with any external programs or even interrupts. Everything you need is already provided by Amsdos. You can find some example code here: https://www.cpcwiki.eu/index.php?title=Programming:Reading_a_sector_from_a_disc

But there's no way around dealing with assembly language, how to modify and assemble the example code so it fits your needs and how to call it from Basic, providing some arguments like track and sector number.

 
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

ZorrO

130 DATA  &21,&37 <read or &38 to write sector,
&80,&cd,&d4,&bc,&22,&34,&80,&79,&32,&36,&80,&1e,&00<drive,&16,&00<track,&0e,&c1<sector,&21,&00-&40 <buffor address 512bytes,&df,&34,&80,&c9,&00,&3c,&c0,&84,&85
140 FOR i=&8000 TO &8038:READ a:POKE i,a:NEXT

It looks rough but someone smart will know what to do with it.
CPC+PSX 4ever

Jean-Marie

This short listing from a greek mag provides a RSX which seems to do the job.


Jean-Marie

This one looks good too, and is working! Syntax is |RDSECT,0,0,&C1,&8000 to read the first sector in 8000h.

the777

Quote from: Jean-Marie on 01:55, 19 January 25This one looks good too, and is working! Syntax is |RDSECT,0,0,&C1,&8000 to read the first sector in 8000h.

thank you. ive managed to get them both working. although the code looks different in the disk version

McArti0

Quote from: the777 on 20:35, 18 January 25could you give an example of what i would type in basic?

1 Dr=0: Tr=0: Sec=&41: er%=0
111 DIM hl%(255)
1111 CALL &BFFC,&E9DD,&C9, &B903,&CD00 ,&B90F,&CD00, 0,&100, &12, @er%,&1100, &C03C,&CD00, @hl%(0),&2100, Tr*&100+Dr,&1100, Sec,&100, &B900,&CD00, &B90F,&CD00, 7,&100

For read byte...

333 DEF FNbyte(by%)=PEEK(@hl%(0)+by%)

? FNbyte(123)

Sample fast code:

1 Dr=0: Tr=0: Sec=&41: er%=0
2 DEFINT b,i
111 DIM hl%(255): starthl%=0:i=0:b=0
222 DEF FNbyte(by%)=PEEK(starthl%+by%) : REM risk, all variables must be init.
333 REM DEF FNbyte(by%)=PEEK(@hl%(0)+by%) : REM slower
1000 REM
1111 CALL &BFFC,&E9DD,&C9, &B903,&CD00 ,&B90F,&CD00, 0,&100, &12, @er%,&1100, &C03C,&CD00, @hl%(0),&2100, Tr*&100+Dr,&1100, Sec,&100, &B900,&CD00, &B90F,&CD00, 7,&100
1150 PRINT"Dr:";CHR$(65+Dr);" Tr:";Tr;" Sec:";"&";HEX$(Sec);" Error:";er%:PRINT
1199 IF er%>0 THEN END ELSE t=TIME:starthl%=@hl%(0)
1200 FOR i=0 TO 511 STEP 16
1205 PRINT HEX$(i,3);" | ";
1206 FOR b=0 TO 15
1210 PRINT HEX$(PEEK(starthl%+b+i),2);" ";
1215 NEXT:PRINT"| ";
1216 FOR b=0 TO 15:PRINT CHR$(1);CHR$(PEEK(starthl%+b+i));:NEXT:PRINT
1220 NEXT
1999 PRINT USING"###.#";(TIME-t)/300
2000 END
2222 SAVE"sector2.bas",a
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

reidrac

hah, wrong post! Ignore me :facepalm:

(can be deleted!)
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse, Brick Rick, Hyperdrive and The Heart of Salamanderland for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Powered by SMFPacks Menu Editor Mod