More memory: the efect of the CTRL key by Software

By manolito74

Paladin (955)

manolito74's picture

26-07-2017, 04:26

Hello,

Today I have been thinking again about the idea of turning off the second floppy drive or what is the same: emulate the press of the CTRL Key by Software.

Searching on Internet I saw that in some thread someone talked about a program called "CONTROL.BAS". I discover aht this Program was in the #20 of the Brazilian Magazine called "CPU MSX". I found that Magazine here:

http://files.datassette.org/revistas/cpu_msx_20.pdf?file=1&t...

in the page 38 we can find the List of the Program. I put it here:

100 ' CONTROL.BAS
110 '
120 ' Simula pulsaci¢n de la Tecla CTRL
130 ' para eliminar todas las Unidades
140 ' menos la primera (A:)
150 '
160 ' por Francis N. Ouinn  (Revista: CPU MSX - Num 20)
170 '
180 IF PEEK(&HFD9F)=&HC9 THEN END
190 IF PEEK(&HF347)=1 THEN END
200 FOR I=1 TO 1000: NEXT I
210 DP=256*PEEK(&HF356)+PEEK(&HF355)
220 IF PEEK(DP+16)=3 THEN FS=512
230 HI=&HE68D-FS
240 FC=&HE7A9-FS
250 E7=&HE7-(FS/256): E6=E7-1
260 BL=256*PEEK(&HF379)+PEEK(&HF378)
270 BS=PEEK(&HF348)
280 POKE &HFD9F,&HC9
290 FOR I=0 TO 24
300 POKE HI+I,PEEK(BL+I)
310 NEXT I
320 POKE &HF1AA,0
330 POKE &HF1BD,&HAA: POKE &HF1BE,E7
340 POKE &HF1C5,0: POKE &HF1C8,1
350 POKE FC,&HFF: POKE &HFB21,1
360 POKE &HF247,0: POKE &HF347,1
370 POKE &HF349,&HA9: POKE &HF34A,E7
380 POKE &HF34D,&HAA: POKE &HF34E,&HEF
390 POKE &HF34F,&HAA: POKE &HF350,&HED
400 POKE &HF351,&HAA: POKE &HF352,&HEB
410 POKE &HF353,&HA6: POKE &HF354,E6
420 POKE &HF355,&HAA: POKE &HF356,&HF1
430 IF PEEK(&HFB2C)<>BS THEN 470
440 FOR I=0 TO 2
450 POKE &HFDA0+I, PEEK(&HFB2C+I)
460 NEXT I
470 CLEAR 200,HI: CLEAR
480 POKE &HFD9F,&HF7
490 '
500 POKE &HFD09,&HF7
510 POKE &HFD0A,PEEK(&HF348)
520 POKE &HFD0B,&H22: POKE &HFD0C,&H40
530 DEFUSR=&HFD09: X=USR(0)

The purpose of this program is as I said before to disable the SECOND DRIVE in order to obtain more free memory. I have tested it on a real MSX (a Philips 8245) and also on the OpenMSX (emulating also the Philips 8245). The results obtained are the following:

- Running the program "CONTROL.BAS" and doing a PRINT FRE (0) I get 24,988 bytes free.

- If I hold the CTRL key pressed during startup and I make PRINT FRE (0) I get 24,990 bytes free.

There is a tiny difference of 2 bytes. But the matter is that after having executed the "CONTROL.BAS" Program te main Drive is disabled (in both case: the real MSX and the EMUlator)

Perhaps the Program "CONTROL.BAS" may be oriented to some Brazilian model. If any of you have a good knowledge of Assembler and the working of MSX Drives could find the error/s, because I don't have idea at all... :-(

I put HERE a ".DSK" image that contains the file "CONTROL.BAS".

Gracias & Saludetes. ;-)

Login or register to post comments

By tfh

Paragon (1681)

tfh's picture

26-07-2017, 10:07

Have you tried running the program on OpenMSX, using one of the Brazilian machines?

By NYYRIKKI

Enlighted (5176)

NYYRIKKI's picture

26-07-2017, 10:25

Please check out: https://www.msx.org/news/software/en/onedrive-10

Some times it is not enough to free only one drive, so I've also created a program "NODISK.BIN" that disables both drives.

Usage:
BLOAD"NODISK.BIN",R,< load address >

This program needs 116 bytes free RAM to load to.

Example:
BLOAD"NODISK.BIN",R,&HC000

By NYYRIKKI

Enlighted (5176)

NYYRIKKI's picture

26-07-2017, 10:43

Oh, just realized the download link is dead, so here is a mirror

By manolito74

Paladin (955)

manolito74's picture

27-07-2017, 16:58

Hello,

first of all thanks for your comments @Nyyrikki and for the links to the Programs ;-)

What I need really is just to emulate the working of the CTRL Key and just disable the 2nd Drive. The problem of the Program I put in my first post is that it disables too the Drive A:. I suppose that there is a little error in some line or in some address but I have no idea... :-(

I have searched for info about the addresses/instructions used by the Program and I have found some information, but I don't have knowledge about Assembler/Drive Working.... :-(

I put here the List of the Program with the remarks about the Information I have found. Perhaps anyone with more knowledge than me about that matter can find the error/s or improve/correct the Program.

This is the List:

100 ' CONTROL.BAS
110 '
120 ' Simulates the press of the CTRL Key
130 ' to disable all the Drives
140 ' except the Drive A:
150 '
160 ' by Francis N. Ouinn  (Revista: CPU MSX - Num 20)
170 '
180 IF PEEK(&HFD9F)=&HC9 THEN END --> That handles the interruptions of the timer MSXIO
      I suppose that is used to start/stop the Disk Drive but I have no idea :-(
190 IF PEEK(&HF347)=1 THEN END --> We check hee the number of Drives: 
      if only there is One Drive we don't need to do anything.
200 FOR I=1 TO 1000: NEXT I
210 DP=256*PEEK(&HF356)+PEEK(&HF355) --> I suppose it is used for Disk Drive A:
220 IF PEEK(DP+16)=3 THEN FS=512
230 HI=&HE68D-FS
240 FC=&HE7A9-FS
250 E7=&HE7-(FS/256): E6=E7-1
260 BL=256*PEEK(&HF379)+PEEK(&HF378)
270 BS=PEEK(&HF348) -> Id of the Slot of the DOS Kernel.
280 POKE &HFD9F,&HC9 --> I suppose it keeps the Disk Drive working
290 FOR I=0 TO 24
300 POKE HI+I,PEEK(BL+I)
310 NEXT I
320 POKE &HF1AA,0
330 POKE &HF1BD,&HAA: POKE &HF1BE,E7 --> F1BD, 1 is the Sector of the active Disk Drive
340 POKE &HF1C5,0: POKE &HF1C8,1
350 POKE FC,&HFF: POKE &HFB21,1 --> from FB21 to FB32 is reserved for DOS
360 POKE &HF247,0: POKE &HF347,1 --> F247: is the Default Drivela (0=A, 1=B) 
     --> F347,1: is the number of Drives of the System 
370 POKE &HF349,&HA9: POKE &HF34A,E7 --> F349,2: pointer to a copy of the FAT of Drive B: and 
      after that we have a copy of the FAT o the Drive A:  
	  (in both cases the size is 1,5 Kbytes for each one)
380 POKE &HF34D,&HAA: POKE &HF34E,&HEF --> F34D,2: pointer to a copy of the Default Drive (1,5kbytes)
390 POKE &HF34F,&HAA: POKE &HF350,&HED --> F34F,2: pointer to a area of 512 bytes used 
     by the DTA of the Disk Basic
400 POKE &HF351,&HAA: POKE &HF352,&HEB --> F351,2: is a pointer to a buffer of 512 bytes used 
     for transfering the data of sectors of the Disk.
410 POKE &HF353,&HA6: POKE &HF354,E6 --> F353, 2: pointer to the FCB of the File we are using
420 POKE &HF355,&HAA: POKE &HF356,&HF1 -> F355, 2: address of the DPB for the Drive A:
430 IF PEEK(&HFB2C)<>BS THEN 470
440 FOR I=0 TO 2
450 POKE &HFDA0+I, PEEK(&HFB2C+I)
460 NEXT I
470 CLEAR 200,HI: CLEAR
480 POKE &HFD9F,&HF7 --> FD9F is used to add Routines for managing intteruptions
490 '
500 POKE &HFD09,&HF7 --> fd09, 128 int this Table 2 bytes are asigned as 
     working area to each Page of each Slot
510 POKE &HFD0A,PEEK(&HF348) --> F348,1 is the ID of the Slot of DOS Kernet 
     (the same format as RDSLT - 000CH/BIOS)
520 POKE &HFD0B,&H22: POKE &HFD0C,&H40 
530 DEFUSR=&HFD09: X=USR(0) --> FD09, 128 Contains: In this Table 2 bytes are asigned as 
      Working area for each Page of each Slot

Gracias & Saludetes. ;-)

By alessandro_scaccia

Resident (40)

alessandro_scaccia's picture

29-03-2018, 22:56

The author says:

is possibile to insert command as game and so on from line 190 to 480

i make a test but not working... the basic reloaded with 24990 bytes but not execute nothings

If put control.bas in autoexec and then start game, the game don't start.

bye

My MSX profile