Author Topic: USIfAC II:Convert a PC or USB stick to Amstrad HDD,access dsk's,and many more!  (Read 53807 times)

0 Members and 1 Guest are viewing this topic.

Offline Devlin

  • CPC6128
  • ****
  • Posts: 165
  • Country: gb
    • Magicbane
    • Awards
Has a 3d-printable case been made for the USIfAC 2 yet? My current solution is less than ideal, and I'd prefer it in a case to prevent damaging my table/usifac2.
like
0
No reactions
Amstrad fan! | CPC464 + USIfAC II | Administrator of Amstrad Discord : https://discord.gg/ksWvApv

Offline issalig

  • CPC664
  • ***
  • Posts: 50
  • Country: es
    • Awards
Hi @ikonsgr , I finally took the time to study your code to run basic from asm and I have some questions

defb 14,0,33,149,234,205,27,0

that corresponds to
Code: [Select]
0000 0E 00          LD C,00
0002 21 95 EA       LD HL,EA95
0005 CD 1B 00       CALL 001B    ; KL_FAR_PCHL

and you said it was LD HL, EA92 (I guess it is just a mistake when writing by heart)
 
Second question is what cp &6e  is for? You are checking  the low part of the sum of &170 + basic_code_size  to &6e, ??

Third question is what ae29 does? it is just a variable that holds 0? and what is the purpose of copying and calling defb 14,0,33,149,234,205,27,0  on 7900, could not be called just from a label before defb line?

I have also tried similar code (https://www.cpcwiki.eu/forum/programming/asm-source-code/msg158311/#msg158311) and also in M4 ROM (https://github.com/M4Duke/m4rom/blob/a8a029134bc2412896c71dcdb4fedba9d417128d/M4ROM.s#L1936)  and both run in 464 that you said it was not working for you in USIFAC, you can give it a try.

- And the forth question is, what are the main differences between these two ways of running basic?In this code they detect basic version and also copy  4x times &170+basic_code_size but instead of using RST 3 and go to &ea95 (inside RUN routine)
they go directly to the beginning of RUN routine at &ea78  (cpc6128)

I have found a disassembly of CPC464 in case you need it https://acpc.me/ACME/LITTERATURE_LIVRES/%5BGER%5DGERMAN/MARKT-UND-TECHNIK/ROM-Listing_CPC464-664-6128(Jorn_W_ANNECK_Till_MOSSAKOWSKI).pdf

Yes, I had too many questions.


Well, after finishing setting up wifi module, you just give "LIST" at basic prompt, and you will get the BASIC listing!  :D
And here is the asm code for the |WIFI command:
Code: [Select]
data_size equ 3465
addr equ &170
org   &c000
   ld   hl, setwifi_code
   ld    de, addr
   ld   bc, data_size
   ldir   
   ld   a ,#FB
   in   a,(#Dc)
   ld   l, a   
   ld   h,&ae
   ld   de,data_size+&170
   ld   B,4
   
patch_mems:      ;length+1678+368 (&170)
   
   ld   (HL),e         
   INC   HL
   LD   (HL),d
   INC   HL
   dec   b
   jr   nz,patch_mems

   ld   a,l   
   cp   &6e
   jp   z,runcommand
   ret

runcommand:
   ld   hl,&ae29
   ld    a,0
   ld   (hl),a
   ld   hl, run_code
   ld    de, &7900
   ld   bc, 8
   ldir
   jp   &7900

Run_code:
   defb 14,0,33,149,234,205,27,0


setwifi_code:

defb 19,0,10,0,173,32,16,1,130,32,14,32,32,32,32,32,32,32,0,31,0,17,0,185,32,28,208,251,44,25,43,1,185,32,28,208,251,44,25,43,1,185
defb 32,28,208,251,44,25,43,0,60,0,20,0,147,32,3,0,0,83,208,40,25,10,41,1,13,0,0,115,101,114,115,112,101,101,228,239,25,24,1,13,0
defb 0,99,117,114,115,112,101,101,228,239,255,11,40,28,221,251,41,32,32,32,32,32,32,32,32,32,0,25,0,30,0,162,32,14,44,15,1,162,32,16,44
defb 14,1,186,32,16,1,138,32,32,32,0,10,0,40,0,159,32,30,136,19,0,36,0,50,0,3,0,0,225,239,34,65,84,43,67,87,77,79,68,69,61
defb 49,34,1,159,32,30,176,4,32,32,32,32,32,32,32,0,19,0,100,0,197,32,115,101,114,105,97,108,32,115,101,116,117,112,0,60,0,110,0,138,1
defb 216,32,35,14,44,25,18,44,25,55,44,17,44,22,1,124,0,83,84,65,212,1,216,32,35,14,44,25,18,44,25,55,44,18,44,22,1,138,1,216,32
defb 35,14,44,15,44,25,79,44,15,44,25,25,0,60,0,115,0,169,32,25,22,44,19,1,191,34,83,101,116,32,110,101,119,32,115,112,101,101,100,63,32
defb 40,89,47,78,41,34,1,131,32,28,3,187,1,13,0,0,111,102,102,115,101,244,239,14,32,32,32,32,32,32,32,0,34,0,116,0,161,32,255,10,40
defb 25,43,41,239,14,32,235,32,30,120,0,32,32,32,32,32,32,32,32,32,32,32,32,32,0,41,0,117,0,161,32,255,10,40,25,46,41,239,14,32,235
defb 32,13,0,0,111,102,102,115,101,244,239,25,11,1,160,32,30,84,1,32,32,32,32,32,0,10,0,118,0,160,32,30,116,0,0,58,0,120,0,191,1
defb 191,34,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,80,114,101,115,115,58,34,1,158,32,13,0,0,248,239
defb 21,32,236,32,25,14,32,32,32,32,0,75,0,130,0,195,32,3,0,0,83,208,40,13,0,0,248,245,20,41,1,169,32,25,32,44,13,0,0,248,1
defb 191,32,34,60,34,59,172,40,255,25,40,13,0,0,216,245,20,41,44,16,44,15,41,59,34,62,58,34,59,3,0,0,83,208,40,13,0,0,248,245,20
defb 41,32,32,0,11,0,140,0,176,32,13,0,0,248,0,60,0,160,0,140,32,57,54,48,48,44,53,55,54,48,48,44,49,49,53,50,48,48,44,50,51
defb 48,52,48,48,44,52,54,48,56,48,48,44,53,55,54,48,48,48,44,57,50,49,54,48,48,44,49,48,54,53,54,48,48,0,21,0,170,0,13,0,0
defb 115,101,114,115,240,239,14,1,131,32,28,3,187,0,51,0,180,0,161,32,255,10,40,25,64,41,239,14,32,235,32,13,0,0,115,101,114,115,240,239,25
defb 12,1,3,0,0,83,208,239,34,57,54,48,48,34,32,32,32,32,32,32,32,32,32,0,54,0,190,0,161,32,255,10,40,25,65,41,239,14,32,235,32
defb 13,0,0,115,101,114,115,240,239,25,15,1,3,0,0,83,208,239,34,53,55,54,48,48,34,32,32,32,32,32,32,32,32,32,32,32,0,52,0,200,0
defb 161,32,255,10,40,25,57,41,239,14,32,235,32,13,0,0,115,101,114,115,240,239,25,16,1,3,0,0,83,208,239,34,49,49,53,50,48,48,34,32,32
defb 32,32,32,32,32,32,0,51,0,210,0,161,32,255,10,40,25,56,41,239,14,32,235,32,13,0,0,115,101,114,115,240,239,25,17,1,3,0,0,83,208
defb 239,34,50,51,48,52,48,48,34,32,32,32,32,32,32,32,0,50,0,220,0,161,32,255,10,40,25,49,41,239,14,32,235,32,13,0,0,115,101,114,115
defb 240,239,25,18,1,3,0,0,83,208,239,34,52,54,48,56,48,48,34,32,32,32,32,32,32,0,54,0,230,0,161,32,255,10,40,25,48,41,239,14,32
defb 235,32,13,0,0,115,101,114,115,240,239,25,19,1,3,0,0,83,208,239,34,53,55,54,48,48,48,34,32,32,32,32,32,32,32,32,32,32,0,44,0
defb 240,0,161,32,255,10,40,25,41,41,239,14,32,235,32,13,0,0,115,101,114,115,240,239,25,21,1,3,0,0,83,208,239,34,57,50,49,54,48,48,34
defb 0,51,0,250,0,161,32,255,10,40,25,40,41,239,14,32,235,32,13,0,0,115,101,114,115,240,239,25,23,1,3,0,0,83,208,239,34,49,48,54,53
defb 54,48,48,34,32,32,32,32,32,32,0,25,0,24,1,161,32,13,0,0,115,101,114,115,240,239,14,32,235,32,160,32,30,180,0,0,54,0,44,1,3
defb 0,0,193,239,34,65,84,43,85,65,82,84,95,68,69,70,61,34,244,3,0,0,83,208,244,34,44,56,44,49,44,48,44,48,34,32,32,32,32,32,32
defb 32,32,32,32,32,32,32,0,33,0,54,1,159,32,30,176,4,1,185,32,28,209,251,44,13,0,0,115,101,114,115,240,1,185,32,28,209,251,44,15,0
defb 25,0,64,1,158,32,13,0,0,233,239,15,32,236,32,25,100,1,176,32,13,0,0,233,0,110,0,84,1,216,32,35,16,44,15,44,25,79,44,25,21
defb 245,13,0,0,79,70,70,83,69,212,44,25,25,245,13,0,0,79,70,70,83,69,212,1,186,32,35,16,44,14,1,187,32,35,16,44,15,1,216,32,35
defb 17,44,15,44,25,79,44,25,19,245,13,0,0,79,70,70,83,69,212,44,25,20,245,13,0,0,79,70,70,83,69,212,1,186,32,35,17,44,14,1,187
defb 32,35,17,44,15,1,159,32,30,208,7,0,37,0,86,1,3,0,0,225,239,34,65,84,43,67,73,80,77,79,68,69,61,49,34,1,159,32,30,176,4
defb 32,32,32,32,32,32,32,0,28,0,89,1,3,0,0,225,239,34,65,84,43,67,73,80,83,69,78,68,34,1,159,32,30,176,4,0,55,0,94,1,169
defb 32,25,30,44,25,22,245,13,0,0,79,70,70,83,69,212,1,191,34,87,105,70,105,32,77,111,100,117,108,101,32,99,111,110,110,101,99,116,101,100,33
defb 34,32,32,32,32,32,32,32,0,17,0,104,1,131,32,28,3,187,1,152,32,32,32,32,32,0,31,0,176,4,197,32,83,69,78,68,32,65,84,32,67
defb 79,77,77,65,78,68,83,32,82,79,85,84,73,78,69,0,24,0,196,4,158,32,13,0,0,235,239,15,32,236,32,255,14,40,3,0,0,225,41,0,29
defb 0,206,4,185,32,28,208,251,44,255,1,40,172,40,3,0,0,193,44,13,0,0,203,44,15,41,41,0,11,0,216,4,176,32,13,0,0,203,0,24,0
defb 226,4,185,32,28,208,251,44,28,13,0,1,185,32,28,208,251,44,28,10,0,0,12,0,236,4,3,0,0,193,239,34,34,0,6,0,246,4,201,0,24
defb 0,0,5,197,32,83,69,78,68,32,84,69,88,84,32,82,79,85,84,73,78,69,0,25,0,60,5,158,32,13,0,0,235,239,15,32,236,32,255,14,40
defb 3,0,0,225,41,32,0,38,0,70,5,185,32,28,208,251,44,255,1,40,172,40,3,0,0,193,44,13,0,0,203,44,15,41,41,32,32,32,32,32,32
defb 32,32,32,0,14,0,80,5,176,32,13,0,0,203,32,32,32,0,36,0,85,5,161,32,13,0,0,99,114,108,230,238,14,32,235,32,185,32,28,208,251
defb 44,25,13,1,185,32,28,208,251,44,25,10,0,36,0,90,5,191,32,35,15,44,255,3,40,25,10,41,244,255,3,40,25,13,41,1,3,0,0,225,239
defb 34,34,32,32,32,32,32,0,6,0,100,5,201,0,22,0,208,7,197,32,87,73,70,73,32,67,79,78,78,69,67,84,73,79,78,0,22,0,210,7,3
defb 0,0,193,239,34,65,84,69,48,34,1,159,32,30,176,4,0,12,0,213,7,185,32,28,209,251,44,15,0,10,0,218,7,159,32,30,184,11,0,10,0
defb 223,7,131,32,28,3,187,0,32,0,224,7,161,32,13,0,0,83,84,65,84,85,211,239,14,32,235,32,13,0,0,83,84,65,84,85,211,239,15,0,40
defb 0,228,7,178,32,13,0,0,115,116,97,116,117,243,32,160,32,30,2,8,44,30,152,8,44,30,238,7,44,30,152,8,44,30,2,8,32,32,0,6,0
defb 238,7,201,0,52,0,2,8,169,32,25,27,44,25,19,245,13,0,0,111,102,102,115,101,244,1,163,34,65,46,80,46,32,115,115,105,100,58,34,44,3
defb 0,0,115,115,105,228,32,32,32,32,32,32,32,32,0,52,0,12,8,169,32,25,28,44,25,20,245,13,0,0,111,102,102,115,101,244,1,163,34,112,97
defb 115,115,119,111,114,100,58,34,44,3,0,0,112,97,115,243,32,32,32,32,32,32,32,32,32,0,73,0,22,8,3,0,0,225,239,34,65,84,43,67,87
defb 74,65,80,95,68,69,70,61,34,244,255,3,40,25,34,41,244,3,0,0,83,83,73,196,244,255,3,40,25,34,41,244,34,44,34,244,255,3,40,25,34
defb 41,244,3,0,0,80,65,83,211,244,255,3,40,25,34,41,0,15,0,32,8,159,32,30,176,4,32,32,32,32,32,0,53,0,42,8,169,32,25,30,44
defb 25,21,245,13,0,0,111,102,102,115,101,244,1,191,34,67,111,110,110,101,99,116,105,110,103,46,46,46,34,59,32,32,32,32,32,32,32,32,32,32,32
defb 32,32,0,10,0,52,8,159,32,30,184,11,0,45,0,62,8,161,32,13,0,0,115,116,97,116,117,243,239,16,32,235,32,191,34,79,75,34,1,138,32
defb 35,17,1,160,32,30,228,7,32,32,32,32,32,32,32,32,0,73,0,72,8,169,32,25,15,44,25,22,245,13,0,0,111,102,102,115,101,244,1,191,34
defb 69,114,114,111,114,58,82,101,116,114,121,40,49,41,32,111,114,32,73,110,115,101,114,116,32,110,101,119,32,65,99,99,101,115,115,32,80,111,105,110,116
defb 40,50,41,63,34,32,32,0,36,0,82,8,161,32,255,10,40,25,64,41,239,14,32,235,32,138,32,35,16,1,160,32,30,32,8,32,32,32,32,32,32
defb 32,32,0,46,0,92,8,161,32,255,10,40,25,65,41,239,14,32,235,32,138,32,35,16,1,138,32,35,17,1,131,32,28,3,187,1,160,32,30,2,8
defb 32,32,32,32,32,32,32,0,10,0,102,8,160,32,30,82,8,0,60,0,152,8,138,32,35,16,1,131,32,28,3,187,1,169,32,25,27,44,25,19,245
defb 13,0,0,111,102,102,115,101,244,1,163,34,72,111,115,116,32,105,112,58,34,44,3,0,0,104,111,115,244,32,32,32,32,32,32,32,0,52,0,162,8
defb 169,32,25,30,44,25,20,245,13,0,0,111,102,102,115,101,244,1,163,34,112,111,114,116,58,34,44,3,0,0,112,111,114,244,32,32,32,32,32,32,32
defb 32,32,32,32,32,32,0,53,0,172,8,3,0,0,72,79,83,212,239,255,3,40,25,34,41,244,3,0,0,72,79,83,212,244,255,3,40,25,34,41,244
defb 34,44,34,244,3,0,0,80,79,82,212,32,32,32,32,32,32,32,0,56,0,182,8,3,0,0,225,239,34,65,84,43,67,73,80,83,84,65,82,84,61
defb 34,244,255,3,40,25,34,41,244,34,84,67,80,34,244,255,3,40,25,34,41,244,34,44,34,244,3,0,0,72,79,83,212,0,25,0,192,8,3,0,0
defb 99,111,110,110,101,99,244,239,3,0,0,225,32,32,32,32,32,0,10,0,197,8,159,32,30,176,4,0,56,0,202,8,169,32,25,30,44,25,21,245,13
defb 0,0,111,102,102,115,101,244,1,191,34,67,111,110,110,101,99,116,105,110,103,46,46,46,34,59,1,159,32,30,184,11,32,32,32,32,32,32,32,32,32
defb 32,0,22,0,212,8,161,32,13,0,0,83,84,65,84,85,211,239,17,32,235,32,201,0,70,0,222,8,169,32,25,15,44,25,22,245,13,0,0,111,102
defb 102,115,101,244,1,191,34,69,114,114,111,114,58,82,101,116,114,121,40,49,41,32,111,114,32,73,110,115,101,114,116,32,110,101,119,32,72,111,115,116,32
defb 83,101,114,118,101,114,40,50,41,63,34,0,31,0,232,8,161,32,255,10,40,25,64,41,239,14,32,235,32,138,32,35,16,1,160,32,30,182,8,32,32
defb 32,0,38,0,242,8,161,32,255,10,40,25,65,41,239,14,32,235,32,138,32,35,16,1,138,32,35,17,1,160,32,30,152,8,32,32,32,32,32,0,10
defb 0,252,8,160,32,30,232,8,0,13,0,184,11,197,32,115,116,97,116,117,115,0,12,0,189,11,185,32,28,209,251,44,15,0,38,0,194,11,3,0,0
defb 225,239,34,65,84,43,67,73,80,83,84,65,84,85,83,34,1,159,32,30,176,4,32,32,32,32,32,32,32,32,0,11,0,204,11,13,0,0,201,239,15
defb 0,40,0,214,11,214,32,40,13,0,0,201,241,22,41,32,250,32,40,255,11,40,28,209,251,41,239,25,255,41,32,32,32,32,32,32,32,32,32,32,0
defb 38,0,224,11,13,0,0,193,239,255,11,40,28,208,251,41,1,13,0,0,201,239,13,0,0,201,244,15,32,32,32,32,32,32,32,32,32,0,6,0,234
defb 11,213,0,25,0,244,11,13,0,0,83,84,65,84,85,211,239,255,11,40,28,208,251,41,245,25,48,0,42,0,249,11,161,32,40,13,0,0,83,84,65
defb 84,85,211,241,16,41,32,252,32,40,13,0,0,115,116,97,116,117,243,238,19,41,32,235,32,30,189,11,0,6,0,254,11,201,0,18,0,160,15,13,0
defb 0,225,239,15,1,13,0,0,233,239,14,0,27,0,170,15,214,32,40,13,0,0,225,239,15,41,32,250,32,40,13,0,0,233,241,25,15,41,0,29,0
defb 180,15,13,0,0,225,239,255,11,40,28,209,251,41,1,13,0,0,233,239,13,0,0,233,244,15,0,6,0,190,15,213,0,6,0,200,15,201,0,46,0
defb 136,19,197,32,97,117,116,111,109,97,116,105,99,32,115,112,101,101,100,32,100,101,116,101,99,116,105,111,110,32,111,102,32,119,105,102,105,32,32,32,32
defb 32,32,0,21,0,146,19,185,32,28,209,251,44,15,32,32,32,32,32,32,32,32,32,0,19,0,156,19,3,0,0,225,239,34,65,84,34,32,32,32,32
defb 32,0,16,0,166,19,159,32,30,176,4,1,159,32,30,160,15,0,19,0,176,19,161,32,13,0,0,193,239,15,32,235,32,30,196,19,0,51,0,186,19
defb 13,0,0,225,239,255,11,40,28,208,251,41,1,161,32,13,0,0,225,239,25,65,32,252,32,13,0,0,225,239,25,13,32,252,32,13,0,0,225,239,25
defb 79,32,235,32,201,0,30,0,196,19,13,0,0,83,69,82,83,80,69,69,196,239,13,0,0,83,69,82,83,80,69,69,196,245,15,0,77,0,201,19,161
defb 32,13,0,0,83,69,82,83,80,69,69,196,239,23,32,235,32,185,32,28,209,251,44,13,0,0,67,85,82,83,80,69,69,196,1,191,34,78,79,32,87
defb 105,70,105,32,109,111,100,117,108,101,32,100,101,116,101,99,116,101,100,33,34,1,152,32,32,32,32,32,32,32,0,28,0,206,19,185,32,28,209,251,44
defb 13,0,0,115,101,114,115,112,101,101,228,1,160,32,30,146,19,0,0,0

This is actaully a method of passing Basic files through assembly code, and i'm using it in many other RSX commands!
The bytes transferred to &170 is the actual basic listing, and it's nothing more that the saved BAS file, without the first 128 bytes of header!  ;)
After that, you only need to set some variables in memory (the "patch_mems" section) , and you are ready!
And finally, the best part: the few bytes in the "run code" section, allows you to automatically run the inserted basic program, without giving "RUN" command!  ;)
It's only a few instructions:
Code: [Select]
   ld   c,0
   ld   hl,&ea92
   call    &001b

This,as small as it may seems, was rather tricky and hard to accomplish, as it required to intercept the "Run" command in basic rom at specific address (far call RST 3 to &ea92 of rom 0=Basic)!
And because i couldn't find a dissasmble code of CPC 464 BASIC 1.0 rom, this automation is only available for CPC 6128  :)

btw, here is all you need to know about creating your own rsx commands: http://cpctech.cpc-live.com/docs/manual/s158se09.pdf
« Last Edit: 20:10, 08 June 21 by issalig »
like
0
No reactions

Offline eto

  • Supporter
  • 6128 Plus
  • *
  • Posts: 516
  • Country: de
    • Awards
Has a 3d-printable case been made for the USIfAC 2 yet? My current solution is less than ideal, and I'd prefer it in a case to prevent damaging my table/usifac2.
R


Somewhere in this thread someone has posted a 3d case. However it doesn't fit every Usifac II as I recognized. They differ slightly and I guess also the Reset-Button (or Pause?) has changed. And it doesn't close on its own, so I used some double-sided strip to keep the lid in place. Better than nothing though and it looks much better than the pure board.



like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
Hi @ikonsgr , I am having a look at your code to run basic from asm and I have some questions
defb 14,0,33,149,234,205,27,0
corresponds to
Code: [Select]
0000 0E 00          LD C,00
0002 21 95 EA       LD HL,EA95
0005 CD 1B 00       CALL 001B    ; KL_FAR_PCHL
and you said it was LD HL, EA92 (I guess it is just a mistake when writing by heart)

the bytes correspond to a far call RST 3 to &ea92 of rom 0=Basic:
Code: [Select]
   ld   c,0
   ld   hl,&ea92
   call    &001b

Second question is what cp &6e  is for? You are checking  the low part of the sum of &170 + basic_code_size  to &6e, ??
If you check firmware guide you will see that @ &AE66 (and also &AE68, &AE6A, &AE6C) are the addresses used by basic to store the start address of  free space (or start of variables & arrays area). This address can be calculated by adding &170 offset to the size of the basic program. Now, for Amstrad CPC464 this address is in slightly  different place (&ae83), so, i'm using the low byte of this address (&83 or &66) to store it in USIfAC's ram, and fetch it whenever is needed (using a simple inp &fbdc), BUT also to DISTINGUISH cpc464 from cpc6128.
Now, if you add 8 to &66 you will have &6e, and that would be the value of l register at the end of loop, IF we are running on a cpc 6128 (e.g. basic 1.1)! So in 2 words, the cp &6e is for distinguish cpc 464 form 6128 (or better basic 1.0 from 1.1).

Third question is what ae29 does? it is just a variable that holds 0? and what is the purpose of copying and calling defb 14,0,33,149,234,205,27,0  on 7900, could not be called just from a label before defb line?
again reading from firmware guide, you will see that &ae29 is for storing file type byte, where for Basic program, must be 0. Now, in order to run basic program i needed to execute the "RUN" code @ &ea78 of basic 1.1 rom. What i found out though, is that i needed to skip the first section (which is relevant to run from a BAS file) as i needed to run a basic code already in ram, that's why i start the execution of routine from &ea92. Executing the run command is actually a far call RST 3 to &ea92 of rom 0=Basic. This can't be done from usifac's rom directly (as the RST3 changes upper rom to basic rom), so it must be first placed in ram to execute it, thus the copying @ &7900.


- And the forth question is, what are the main differences between these two ways of running basic?In this code they detect basic version and also copy  4x times &170+basic_code_size but instead of using RST 3 and go to &ea95 (inside RUN routine)
they go directly to the beginning of RUN routine at &ea78  (cpc6128)
The cpc6128 "way" is direct running of basic program through the proccess i described. To do so, i needed the disasemble basic rom  to find out at what address i need to jump to ,for executing a run command properly. And so, because i couldn't fine a disassemble  of basic 1.0 rom,in case of cpc464, this must be ommited, and instead, you will need to give the "run" command manually at the prompt.


I have found a disassembly of CPC464 in case you need it https://acpc.me/ACME/LITTERATURE_LIVRES/%5BGER%5DGERMAN/MARKT-UND-TECHNIK/ROM-Listing_CPC464-664-6128(Jorn_W_ANNECK_Till_MOSSAKOWSKI).pdf
Thanks, i'll take a look and see if i can make it work for CPC464 too. :)
like
0
No reactions

Offline issalig

  • CPC664
  • ***
  • Posts: 50
  • Country: es
    • Awards
Thanks for all the details, I will need some time to digest it all

Anyway, I have assembled this code again
defb 14,0,33,149,234,205,27,0

and it gives ea 95 again
0E 00
21 95 EA   ld hl, ea95   
 CD 1B 00

So if ea92 is the correct one, shouldn't be this defb?
defb 14,0,33,146,234,205,27,0

like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
Yes, the correct is &ea95  ;D
like
0
No reactions

Offline issalig

  • CPC664
  • ***
  • Posts: 50
  • Country: es
    • Awards
Thanks, i'll take a look and see if i can make it work for CPC464 too. :)
I extracted the run function for BASIC 1.0 from the book (https://acpc.me/ACME/LITTERATURE_LIVRES/%5BGER%5DGERMAN/MARKT-UND-TECHNIK/ROM-Listing_CPC464-664-6128(Jorn_W_ANNECK_Till_MOSSAKOWSKI).pdf) and translated comments into English (Danke schöne Google Tanslator) and mixed it with this code https://www.cpcwiki.eu/forum/programming/asm-source-code/msg158311/#msg158311

I attach a working code  8) for 464,664 and 6128

The changes are:
- Address of start of BASIC variables ld l, &83 for 464  ld l, &66  for 6128 and 664
- RUN entry point EA95 is for 6128, EA7D for 664, and E9DB for 464
- file type byte AE29 (6128 and 664),  AE42 (464)

Code: [Select]
kl_rom_select equ &B90F
data_size equ 35                                ; size of BASIC file
addr    equ &170                                ; BASIC files normally start at 170, let's write in this area
org    &1200                                   ; and store our program in &1200

main:
                                                ; we will use 16-bit registers (hl, de, ... to deal with memory addresses that take 2 bytes &AABB)
    ld    hl, basic_code                  ; hl = address where basic_code is starts, i.e. org + something but the assembler does it for us
    ld     de, addr                        ; de = &170
    ld    bc, data_size                   ; bc = data size
    ldir                                    ; ldir copies a block from hl address to de address of length bc (i.e. memcpy)
                                             ; do not forget to go back from call

; Address of start of variables (&AE66-67 in cpc6128-664, &AE83-84 in cpc464)
    ;basic_version:
    ld c, 0
    call kl_rom_select         ;select upper rom given by C -> upper rom 0 -> BASIC
    ld a,(&c002)         ;basic 1.0 byte 2 is 0; basic 1.1 664 is 1; basic 1,1 byte 2 is 2; 
    ld (basic_version), a
    cp 0
    jr z,cpc464
    ld    l, &66  ; basic 1.1 at AE66
    ld a, &29
    ld (file_type), a

    ld (basic_version), a
    cp 1
    jr z,cpc664
   
    ld hl, run_entry
    ld (hl) , &95     ;ea95 for 6128
    inc hl
    ld (hl) , &ea
    jr patch_mems
cpc664:
    ld hl, run_entry
    ld (hl) , &7d     ;ea7d for 664   
    inc hl
    ld (hl) , &ea
    jr patch_mems

cpc464:
    ld    l, &83  ; basic 1.0 at AE83
    ld a, &42
    ld (file_type), a
   
    ld hl, run_entry
    ld (hl) , &db
    inc hl
    ld (hl) , &e9


patch_mems:
    ld    h,&ae  ;  hl =AExx
    ld    de, data_size+&170  ;end of data
    ld    B,4  ; 4 bytes
   
patch_loop:           
                                    ;write data_size+170  to AExx
    ld    (hl),e   
    inc    hl
    ld    (hl),d
    inc    hl
    dec    b
    jr    nz,patch_loop
    ld    a,l   
    jr    run_command
    ret

run_command:
    ;ld    hl,&ae29        ; file type 0   
    ;ld    hl,&ae42        ; file type 0   cpc464
    ld    h, &ae
    ld    a, (file_type)
    ld    l, a
    ld     a,0
    ld    (hl),a
    ld    hl, run_code     
    ld     de, &7900
    ld    bc, 9  ;  run code size,
    ldir
    jp    &7900 ; copy run code in memory and call it

run_code:
    ld c, 0
    ;ld hl, &ea95   ;6128
    ;ld hl, &e9db    ;464
    ld hl, (run_entry)
    call &001b
    ret


basic_code: ;35 bytes long
defb  &0c,&00,&0a,&00,&c5,&20,&48,&65,&6c,&6c,&6f,&00,&15,&00,&14,&00
defb  &bf,&20,&22,&48,&65,&6c,&6c,&6f,&20,&57,&6f,&72,&6c,&64,&21,&22
defb  &00,&00,&00
basic_code_end:

basic_version: defb 0
file_type: defb 0
run_entry: defw 0
Code of RUN function for 464

Code: [Select]
E9BD CD 51 DD           CALL DD51       End of statement?
E9C0 EB                 EX DE, HL
E9C1 2A 81 AE           LD HL, (AE81)   program start after DE
E9C4 EB                 EX DE, HL
E9C5 38 1C              JR C, E9E3      then from program start
E9C7 FE 1E              CP 1E           Token for line number?
E9C9 28 15              JR Z, E9E0      then from program line
E9CB FE 1D              CP 1D           Token for line address?
E9CD 28 11              JR 2, E9E0      then from the program line
E9CF CD 0D EA           CALL EA0D       1. Read and evaluate block
E9D2 21 30 EA           LD HL, EA30     Addr. Load binary file
E9D5 D2 13 BD           JP NC, BD13     Binadrdat. ? d. MC BOOT PROGRAM
E9D8 CD A8 EB           CALL EBA8       otherwise load program
E9DB 2A 81 AE           LD HL, (AE81)   Pointer to program start
E9DE 18 11              JR E9F1         start program
E9EO CD 67 E7           CALL E767       Get line address
E9E3 D5                 PUSH DE         Save pointer to entry point
E9E4 CD AD D2           CALL D2AD       initialize cassette
E9E7 CD 8C C1           CALL C18C       delete variables
E9EA CD 7A C1           CALL C17A       Initialize basic pointer
E9ED CD 5E C1           CALL C15E       Printout select. and I / O init.
E9F0 E1                 POP HL          new program pointer
E9F1 23                 INC HL          Pass over zero at the end of the line
E9F2 F1                 POP AF          delete call address
E9F3 C3 93 DD           JP DD93         for interpreter loop
« Last Edit: 19:17, 09 June 21 by issalig »
like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
That's great! I have too, check the code and manage to create a new "run command" code, that now works for CPC464 and CPC6128 (and most probable CPC664, although i don't have one to test it  :D ):
Code: [Select]
kl_rom_select equ &B90F
org &7900
write"DIRECT_ROM.BIN" 
ld c,0
call kl_rom_select
ld a,(&c002)
cp 0
jp z,cpc_464
cp 1
jp z,cpc_664
jp &ea78+&1d        ;; run BASIC CPC6128
cpc_664:
jp &ea7d+&1d        ;; run BASIC CPC664
cpc_464:
jp &e9bd+&1d        ;; run BASIC CPC464

The above code is transferred to ram and executed from there using this code:

ld hl, run_code
ld de, &7900
ld bc, 27
ldir
jp &7900
Run_code:
defb 14,0,205,15,185,58,2,192,254,0,202,24,121,254,1,202,21,121,195,149,234,195,154,234,195,218,233


As i explained before,the offset i'm using is for skipping the first section (which is relevant to run from a BAS file) of Basic's "Run" routine, which i assume is the same for all 3 models, so i used the same offset.

New firmware update (_4b) with the following improvements:

- RSX commands: |SET,|COM,|WIFI,|TER,|GALA,|PACMAN,|KGOR are now executed directly on CPC464, without needing to give "RUN" anymore!

- SNA routine now checks if Amstrad has 64k only, and loads only the 1st 64k ram dump even if snapshot file is for 128k. The reason i did this is because i noticed that the snapshot archive has a lot of game files that are 128k but actually only the 1st 64k iis used, so now you will be able to load most of the SNA files on CPC464 too!

- Minor optimization of  board's ROM code this time:replace "cp 0" with "or A" , reduce the size of hex file by dumping initial zeros of arrays & variables used in routines transferred to RAM.

- Fix a small bug in |format routine- now shows correctly  formatted track numbers.

- Fix a bug in |2PC routine when use the "invert file selection" function.
« Last Edit: 23:17, 09 June 21 by ikonsgr »
like
0
No reactions

Offline issalig

  • CPC664
  • ***
  • Posts: 50
  • Country: es
    • Awards
Maybe it is time for a fork with USIFAC support
https://github.com/yawor/m4board-enclosure
Somewhere in this thread someone has posted a 3d case. However it doesn't fit every Usifac II as I recognized. They differ slightly and I guess also the Reset-Button (or Pause?) has changed. And it doesn't close on its own, so I used some double-sided strip to keep the lid in place. Better than nothing though and it looks much better than the pure board.

like
0
No reactions

Offline Audronic

  • 6128 Plus
  • ******
  • Posts: 1.472
  • Country: au
  • I know RST3 . I now know a little More.
    • Awards
New firmware update (_4b) with the following improvements:
Hi John

Well done
Ps I can now delete the Macintosh extra files that are added to a USB stick (Known as TURDS)
Thanks for that.
A small request Is it possible to sort the Cat EG:- a-z etc
Keep up the GOOD Work

Keep Safe
Ray
like
0
No reactions
Procrastinators Unite,
If it Ain't Broke PLEASE Don't Fix it.
I keep telling you I am Not Pedantic.
As I Live " Down Under " I Take my Gravity Tablets and Wear my Magnetic Boots to Keep me from Falling off.

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
A small request Is it possible to sort the Cat EG:- a-z etc
I'm afraid usb host module doesn't allow that. Files/dirs will be shown in order of how they were initially written in usb flash drive, usually this is alphabetically anyway. But any new file saved will be added at the end of list.
In anycase, i thnk that using the filter argument of the |CAT (to filter the list of files taken), is what can really makes catalogue management ..."piece of cake"!  :)
like
0
No reactions

Offline Devlin

  • CPC6128
  • ****
  • Posts: 165
  • Country: gb
    • Magicbane
    • Awards
I've noticed when doing a CAT on a folder that a large number of said folders do not identify themselves with the <DIR> marker - And that any folder with a long name, and a period (.) in them, will incorrectly split their names - f.ex: "Dizzy. Amstrad Action Special Edition" will display as "DIZZY~1.AMS" which causes an error if trying to navigate to it with cd
like
0
No reactions
Amstrad fan! | CPC464 + USIfAC II | Administrator of Amstrad Discord : https://discord.gg/ksWvApv

Offline Devlin

  • CPC6128
  • ****
  • Posts: 165
  • Country: gb
    • Magicbane
    • Awards
I'm afraid usb host module doesn't allow that. Files/dirs will be shown in order of how they were initially written in usb flash drive, usually this is alphabetically anyway. But any new file saved will be added at the end of list.
In anycase, i thnk that using the filter argument of the |CAT (to filter the list of files taken), is what can really makes catalogue management ..."piece of cake"!  :)


the filter is nice but inconvenient to use on a 464 though - that said, a proper file manager (please don't just bake it into the next fw) would be a gods-send
I feel like it'd be a "killer utility" for the usifac2 and massively improve an already fantastic device.
« Last Edit: 15:54, 10 June 21 by Devlin »
like
0
No reactions
Amstrad fan! | CPC464 + USIfAC II | Administrator of Amstrad Discord : https://discord.gg/ksWvApv

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
the filter is nice but inconvenient to use on a 464 though - that said, a proper file manager (please don't just bake it into the next fw) would be a gods-send
I feel like it'd be a "killer utility" for the usifac2 and massively improve an already fantastic device.
It would be most unlikely for such a utility as a file manager to be incorporated into fw, because there is almost no space in microcontroller program memory left :)
But if i may say, judging from my (rather time consuming...) personal experience, the Basic loader utlity already masisvely imrpoved the user experience with cpc464, as it practically eliminates the need of issuing rsx commands! You just have a bunch of BAS files to select from, and run directly!
And although filtering is a bit tiresome on a CPC464, still, is MUCH easier and faster to load a game, than doing it "manually", using rsx commands (and the "sadistic" way of issuing arguments on a cpc 464  :laugh: )!
 In fact, i believe that ,for collections of up to a few 100's of games, you don't need filtering anyway, as with a simple cat, you get pages of 25 games (BAS files) in less than a second, so, practically you can "Scan" your entire collection in a few seconds!  ;)

 In a more general perspective,i would say that a little bit of CLI typing in usage, always adds to the "nostlagia feeling" of using an  80's home micro Amstrad CPC in 2021. It's like a kind of a small "ritual"  :)
Αnd the same goes the "other way":
Just imagine in a few years from now...
"man, this file manager looks too boring and tedious anymore, why don't add vocal recognition for loading games?  Or even better, wouldn't be great if i could just think of a game, and amstrad instantly load it?"  (yes, yes, my "tech-freak" driven boredom and laziness shows no limit...) :P
Τoo much easines and conveniences, and you will certainly loose the... "feeling"!  ;D 
Unless you are too young and this really doesn't matter for you... :)

In the end, if someone wants to just load and play games, as fast and easy as possible, well... that's what Amstrad emulators are for!  :)



« Last Edit: 19:23, 10 June 21 by ikonsgr »
like
0
No reactions

Offline Devlin

  • CPC6128
  • ****
  • Posts: 165
  • Country: gb
    • Magicbane
    • Awards
Quote from: ikonsgr
It would be most unlikely for such a utility as a file manager to be incorporated into fw, because there is almost no space in microcontroller program memory left :)
That, is entirely fair, and if honest, a bit of a relief.


Quote
In the end, if someone wants to just load and play games, as fast and easy as possible, well... that's what Amstrad emulators are for!  :)
I did not buy a usifac ii, so I could play in an emulator.. I like my real hardware :)
like
0
No reactions
Amstrad fan! | CPC464 + USIfAC II | Administrator of Amstrad Discord : https://discord.gg/ksWvApv

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
I've noticed when doing a CAT on a folder that a large number of said folders do not identify themselves with the <DIR> marker - And that any folder with a long name, and a period (.) in them, will incorrectly split their names - f.ex: "Dizzy. Amstrad Action Special Edition" will display as "DIZZY~1.AMS" which causes an error if trying to navigate to it with cd
Unfortunately this is a constraint (all names are converted in 8.3 dos type, so better not have too "fancy" long file names :) ) & a bug (sometimes not identifying a directory name with <DIR>,this mostly happens when you have many sub dirs ) of the CH376 usb host module... ::)
« Last Edit: 14:00, 11 June 21 by ikonsgr »
like
0
No reactions

Offline eto

  • Supporter
  • 6128 Plus
  • *
  • Posts: 516
  • Country: de
    • Awards
all names are converted in 8.3 dos type

Btw: Is it possible to get the long file names? Even if it cannot be used for the RSX commands, for a menu application, they could be used to display a more meaningful name. 
like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
I'm afraid not. The 8.3 names is not something i make for "compatibility" reasons (as amstrad cpc also uses 8.3 filenames) but it's what the usb module actually responds to.
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.154
  • Country: fr
    • urban exploration
    • Awards
hi @ikonsgr
is there softwares for Linux or documentation to create those softwares?
like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Online Fran123

  • CPC664
  • ***
  • Posts: 60
  • Country: es
    • Awards
Hello


Is there any way to create the DSK of current disk file into USB ?


Would you give us a program in BASIC or ASM or BIN?


Thank you.
like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
hi @ikonsgr
is there softwares for Linux or documentation to create those softwares?
I think you should ask issalig as he has already develop some utilities on linux: https://www.cpcwiki.eu/forum/amstrad-cpc-hardware/usifac-iimake-your-pc-or-usb-stick-an-hdd-for-amstrad-access-dsk-and-many-more!/msg201894/#msg201894
like
0
No reactions

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
Hello
Is there any way to create the DSK of current disk file into USB ?
Would you give us a program in BASIC or ASM or BIN?
Thank you.

 For now, there is no such ability to create a dsk image from a floppy disk. But you can copy directly files from a floppy disk to a usb flash drive using |2PC.
 Such a utility would certainly need quite a lot of work to develop, as it would require to recreate the whole structure of an image file , and for now i'm not thinking to get involved with that (i'm working on another project...  ;D )
like
0
No reactions

Online Fran123

  • CPC664
  • ***
  • Posts: 60
  • Country: es
    • Awards
I thought it would be easier, reading a sector and writing it to the file
like
0
No reactions

Offline Audronic

  • 6128 Plus
  • ******
  • Posts: 1.472
  • Country: au
  • I know RST3 . I now know a little More.
    • Awards
(i'm working on another project...  ;D )
Hmmmmnnn I wonder what that is ?

Keep up the good work

Keep Safe
Ray
like
0
No reactions
Procrastinators Unite,
If it Ain't Broke PLEASE Don't Fix it.
I keep telling you I am Not Pedantic.
As I Live " Down Under " I Take my Gravity Tablets and Wear my Magnetic Boots to Keep me from Falling off.

Offline ikonsgr

  • 6128 Plus
  • ******
  • Posts: 592
  • Country: gr
    • ikonsgr 80's Home Micros WorkBench
    • Awards
@Audronic ,it's a 512k ram expansion, but instead of the usual CPLD approach, i use (again  ;D ) a PIC mcu!  :)

@Devlin  , i had some thoughts about the "most wanted" file manager, and i think it would be rather easy to convert the existed assembly code for |CAT RSX command to output the list of names into memory instead of the screen. Then, using BASIC i could take the data from there and create a table of strings for each name for further proccess. Unfortunately the Basic routine for this it's rather slow (it would take ~4-5 seconds to get each page), but i'm thinking of using Turbo basic compiler to speed things up  ;)
like
0
No reactions