[Turbo Pascal] Q&A official thread

Страница 5/17
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 02:56

hit9918 wrote:

when a clearscreen ends up with an unknown IDE command sent... that smells like a wild crash.
in C function names starting with an underscore mean something like "used by the system", "special, not standard", maybe it's similar in Pascal.

Yes.

I'm using the same concept in my library. This is a "system" call, but for now I'm using these functions as valid callable functions. In newer releases of my library I'll try to create an initializing function (something like a constructor) to point the original ClrScr and GotoXY to my _ClrScr and _GotoXY. These new functions are faster than the older functions that uses BDOS calls that are known to be slower functions.

[]'s
PopolonY2k

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 02:53

Hi rolandve I've compiled your code using my TurboR A1GT and even in Zemmix and it is not crashing. In fact is working, but the only issue I found is that the MSXBIOS function $00C3 (CLS BIOS call) was not working as expected, so after checking the MSXBIOS specification at MSX Assemby pages by Grauw (http://map.grauw.nl/resources/msxbios.php) I found the problem.

To call the _ClrScr BIOS function is necessary the Z80 zero flag to be set before calling this function, so the fixed _ClrScr procedure will be like below :

Procedure _ClrScr;
Const
        ctCLS     = $00C3;  { Clear screen, including graphic modes }
Var
       regs   : TRegs;
       CSRY   : Byte Absolute $F3DC; { Current row-position of the cursor    }
       CSRX   : Byte Absolute $F3DD; { Current column-position of the cursor }
       EXPTB1 : Byte Absolute $FCC1; { Slot 0 }
Begin
     regs.IX := ctCLS;
     regs.IY := Mem[EXPTB1-1]; { EXPTBL-1 }
     (*
      * The Z80 zero flag must be set before calling the CLS BIOS function.
      * Check the MSX BIOS specification.
      *)
     Inline( $AF );                 { XOR A }
     CALSLT( regs );
     CSRX := 0;
     CSRY := 0;
End;

Please change this function in your local CONIO.PAS file and let me know if something changes.

[]'s
PopolonY2k

By rolandve

Champion (372)

Аватар пользователя rolandve

21-06-2016, 11:51

Hi Popolony2k,

Yes, 3.3 supports directories so {$I inc\....} works but breaks compatibility downwards because 3.0 can't handle subdirectories.

I tried it, but the code still fails. I downgraded my compiler to 3.0 but the code still crashes. Throwing the same error about IDE commands not working. I tried some other code that performs direct writes to vram and these work. These libraries are based on Kari's code.

PROGRAM MSXDOS;
{$I wrtvram.inc}
{$I fastwrit.inc}

Begin
      FastWrite('Hello World');
End.

Given that I am the only one that has these errors it has to be either something in my setup: the files I am using. These are constant factors between my real machine and the emulated version. My real machine has MFSCC+ card, the emulated machine has a sunrise IDE emulated.

I found that the issue might be European hardware related. When I switch openMSX to Boosted MSX2+ JP the code compiles and executes without crash!. The same for a TurboR in OpenMSX.

PROGRAM MSXDOS;

{$I types.pas}
{$I msxbios.pas}
{$I conio.pas}
Begin
      _ClrScr;
      repeat until keypressed;
       WriteLn(''Hello World');
       repeat until keypressed;
END.

This is also not flawless. After _ClrScr the screen is empty and the line Hello World I added is not displayed, but at least there is no crash.

Thanks!

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 15:17

Thanks for your response.

Please send me here what is the European hardware you're using in OpenMSX (with all extensions IDE and so on), because maybe can be something to be fixed in the library. In fact I don't believe that could be something in the library because it is just using a standard MSX BIOS call, but checking this is a good idea, so I'll try to find a workaround if is possible.

[]'s
PopolonY2k

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 15:56

If you're trying to use something like the Kali's FastWrite function in your program, please consider using my DVRAM.PAS (Direct VRAM) procedures/functions.
These procedures/functions have the same effect of fastwrite but are better because with a simple modification you can still use the same Write and WriteLn standard Pascal procedures.

Check the code below:

Program TestDirectVRAM;

{$i types.pas}
{$i dvram.pas}
{$I msxbios.pas}
{$i conio.pas}     { For _GotoXY function }

Var
       scrHandle : TOutputHandle;
 
Begin
 (* 
  * Open the text mode for direct access, enabling WriteLn and Write to access 
  * the VRAM directly instead using BDOS calls.
  *)
  OpenDirectTextMode( scrHandle );

  (* 
   * Use the standard ClrScr if you're having problems with European machines. 
   * This will be modified in the future and the standard ClrSrc will be pointed 
   * to the new _ClrScr, so all legacy code will work  fully without big changes.
   *)
  _ClrScr;

  WriteLn('Hello World');

  (*
   * If you're using the DVRAM to redirect the Write/WriteLn procedures to the 
   * library's fast VRAM handling the standard GotoXY won't work. Use the 
   * CONIO.PAS _GotoXY procedure instead. This will be modified 
   * in the future and the standard GotoXY will be pointed to the new _GotoXY,
   *  so all legacy code will work fully without big changes.
   *)
  _GotoXY( 10, 10 );

  WriteLn('Hello World');
  CloseDirectTextMode( scrHandle );   { Restore the original handlers }
End.

[]'s
PopolonY2k

By rolandve

Champion (372)

Аватар пользователя rolandve

21-06-2016, 16:05

Hi Popolony2k,

Perhaps we should have this discussion through other media, but I can't find my inbox on this forum.
The real machine, it doesn't work on is a NMS 8250. The emulated machines are OpenMSX boosted (2, 2+ JP) and also the emulated NMS 8250 hangs.

Things that make me look strange is that Japanese machines do not hang, other machines hang. I used a floppy in MSX-DOS 1 without IDE controller on my real MSX and the openMSX version: hang. Difference between the IDE version and the non IDE version of OpenMSX is that OpenMSX writes status output about the IDE controller when it is there. The machine hangs silently when there is no IDE controller.

My real machine has a MFSCC+ card with SD but it also hangs.

I am going to speculate here, but it looks like data is written to the wrong addresses, otherwise I can't figure out why a IDE component would complain about instructions it doesn't understand Sad I can send the compiled file to anyone that can use a debugger.

Thanks for the fast access tip, I will try it as soon as I am home Smile

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 17:44

Hi friend.

Thanks, I tried this config NMS8250 and I'm facing the same problems you reported here. I think that is related to slot selection. I'll try to fix this.

I think that is a good idea to create a new thread for discussing about PopolonY2k's framework fixes, new ideas and improvements.

[]'s
PopolonY2k

By popolony2k

Hero (544)

Аватар пользователя popolony2k

21-06-2016, 17:47

The new thread for discussing newer features, fixes and improvements of this library can be reached here.

https://www.msx.org/forum/msx-talk/development/turbo-pascal-...

[]'s
PopolonY2k

By rolandve

Champion (372)

Аватар пользователя rolandve

22-06-2016, 08:06

Hi Popolony2k,

I did an attempt to debug the old fashion way (Writeln() before and after each line of code) and I also had a my doubts about CallSlt. At least I am glad to see that my problem can be reproduced Smile

By rolandve

Champion (372)

Аватар пользователя rolandve

29-06-2016, 08:50

I have a set of questions, for the experts Smile
- How do I detect multiple keys being pressed? (for example detect CTRL-ENTER of CTRL-F)?
- different coloured characters without going to 32 characters per screen or going to a graphics screen?
- is there a simple library that allows me to allocate memory and then write and read from it?

Thanks

Страница 5/17
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10