[Freedos-user] EMODE - translation from Pascal to C - what I screwed up?

2014-06-27 Thread Zbigniew
As a little exercise I translated a small EMODE utlity from German
c't magazine. The listing you can see here:
http://tinyurl.com/meyq7yb

Unfortunately, my version doesn't work as expected; it seems to try to
change the text mode of VGA card, but reports Abnormal program
termination in the end. Maybe someone of you could suggest, what has
to be fixed? Here's my listing tried with Turbo C:


#include stdio.h
#include dos.h

#define VIDEO 0x10


int VGAvorhanden(void) {
  union REGS regs;

  regs.x.ax = 0x1a00; /* infobajt */
  int86(VIDEO, regs, regs); /* VGA z monitorem VGA ? */
  return (regs.h.al == 0x1a)  ((regs.h.bl == 0x07) || (regs.h.bl == 0x08));
}

void VGAaus(void) {
  __emit__ (0xfa);/* CLI - blokada przerwania */
  outportb(0x3c4, 0); /* sequencer off */
  outportb(0x3c5, 1);
  outportb(0x3d4, 23); /* CRTC - reset */
  outportb(0x3d5, inportb(0x3d5)  127);
  outportb(0x3d4, 17); /* CRTC - register 0-7 freigeben */
  outportb(0x3d5, inportb(0x3d5)  127);
}

void VGAein(void) {
  outportb(0x3d4, 17); /* CRTC - register 0-7 sperren */
  outportb(0x3d5, inportb(0x3d5) | 128);
  outportb(0x3d4, 23); /* CRTC - reset freigeben */
  outportb(0x3d5, inportb(0x3d5) | 128);
  outportb(0x3c4, 0);  /* Sequencer on */
  outportb(0x3c5, 3);
  __emit__ (0xfb);  /* STI - zezwolenie na interrupt */
}

void VGA94spalten(void) {
unsigned char dummy;

  outportb(0x3c2, (inportb(0x3cc)  0xf3) | 4); /* 720 PEL waehlen */
  outportb(0x3c4, 1); /* 8-dot-mode anschalten */
  outportb(0x3c5, inportb(0x3c5) | 1);
  outportb(0x3d4, 0); /* Horizontal total-5 */
  outportb(0x3d5, 108);
  outportb(0x3d4, 1); /* Horizontal display enable end - 1 */
  outportb(0x3d5, 93);
  outportb(0x3d4, 2); /* Start horizontal blanking */
  outportb(0x3d5, 94);
  outportb(0x3d4, 3); /* End horizontal blanking */
  outportb(0x3d5, 128 + 15);
  outportb(0x3d4, 4); /* Start horizontal retrace */
  outportb(0x3d5, 98);
  outportb(0x3d4, 5); /* End horizontal retrace */
  outportb(0x3d5, 128 + 14);
  outportb(0x3d4, 19); /* Logical line width */
  outportb(0x3d5, 94 / 2);
  dummy = inportb(0x3da);  /* Horizontal PEL Panning */
  outportb(0x3c0, 19);
  outportb(0x3c0, 0);
  outportb(0x3c0, 32); /* Attribute controller */
  outportb(0x3c0, 32); /* reaktivieren */
}

void VGA480rasterzeilen(void) {
  outportb(0x3c2, inportb(0x3cc) | 192); /* Sync-polaritaet setzen */
  outportb(0x3d4, 6); /* Vertical total */
  outportb(0x3d5, 11);
  outportb(0x3d4, 7); /* CRTC Overflow */
  outportb(0x3d5, 62);
  outportb(0x3d4, 9); /* Maximum scan line */
  outportb(0x3d5, 79);
  outportb(0x3d4, 16); /* Start vertical retrace */
  outportb(0x3d5, 234);
  outportb(0x3d4, 17); /* End vertical retrace */
  outportb(0x3d5, 140);
  outportb(0x3d4, 18); /* Vert. display enable end */
  outportb(0x3d5, 223);
  outportb(0x3d4, 21); /* Start vertical blanking */
  outportb(0x3d5, 231);
  outportb(0x3d4, 22); /* End vertical blanking */
  outportb(0x3d5, 4);
}

void VGAzeichenhoehe(unsigned char size) {
  pokeb(0, 0x485, size);  /* mem[0:$485] := size; BIOS Informieren */
  outportb(0x3d4, 9); /* Maximum scan line */
  outportb(0x3d5, (inportb(0x3d5)  0xe0) + size - 1);
  outportb(0x3d4, 10);
  if (size = 12)
outportb(0x3d5, size - 2);
  else
outportb(0x3d5, size - 3);
  outportb(0x3d4, 11);  /* Cursor End */
  if (size = 12)
outportb(0x3d5, size - 1);
  else
outportb(0x3d5, size - 2);
}

void VGAmodus(unsigned char zeilen, unsigned char spalten) {
union REGS regs;

/* 350 oder 400 zeilen waehlen, bei 480 zeilen vorerst nur 400 */
  regs.h.ah = 0x12;
  regs.h.bl = 0x30;
  regs.h.al = (zeilen == 43) ? 1 : 2;
  int86(VIDEO, regs, regs);
/* 40 oder 80 Spalten waehlen, bei 94 Spalten vorerst nur 80 */
  regs.h.ah = 0;
  regs.h.al = (spalten == 40) ? 1 : 3;
  int86(VIDEO, regs, regs);
/* Passenden zeichensaetz in Video-Ram kopieren */
  regs.h.ah = 0x11;
  regs.h.bl = 0;
  switch (zeilen) {
case 25: regs.h.al = 4; break; /* 16x8 Pixel */
case 30: regs.h.al = 4; break; /* 16x8 Pixel */
case 34: regs.h.al = 1; break; /* 14x8 Pixel */
default: regs.h.al = 2;/*  8x8 Pixel */
  }
  int86(VIDEO, regs, regs);
  VGAaus();  /* Jetzt geht's an die register */
  if (spalten == 94)
VGA94spalten();
  if (zeilen == 30 || zeilen == 34 || zeilen == 60)
VGA480rasterzeilen();
  switch (zeilen) {
case 25: VGAzeichenhoehe(16); break;
case 30: VGAzeichenhoehe(16); break;
case 34: VGAzeichenhoehe(14); break;
default: VGAzeichenhoehe(8);
  }
  VGAein();  /* Alles wieder normal */
/* BIOS ueber die Bildschirmgrosse informieren */
  pokeb(0, 0x44a, (long int)spalten);
  pokeb(0, 0x484, (long int)zeilen - 1);
}

void holeParameter(unsigned char *pzeilen, unsigned char *pspalten,
char *argv[]) {
  int sp_allowed[] = {40, 80, 94, 0};
  int ze_allowed[] = {25, 30, 34, 43, 50, 60, 0};
  int *arrptr;
  unsigned char tmp;

  /* Zeilen und Spalten aus der Kommandozeile holen */
  sscanf(argv[2], %u, tmp);
  arrptr = sp_allowed;
  while 

Re: [Freedos-user] Sudoku on a 8086 (or anything newer)

2014-06-27 Thread Rugxulo
Hi,

On Thu, Jun 26, 2014 at 4:47 PM, Mateusz Viste mate...@viste.fr wrote:

 Some days ago I was looking up on the web for some Sudoku games that
 would run under FreeDOS. And I found.. almost nothing (only one game to
 be precise, that had no mouse support, and of course it wasn't free/libre).

You mean interactive? Or just solvers? Or puzzle generators?

Yes, I vaguely remember seeing one freeware graphical DOS version a
few years ago, but I don't remember the details.

For solvers, just for completeness, off the top of my head, I know of
three obvious options that can work in DOS:

1). The old Hugi compo winner (62-byte .COM, 186+)
= http://www.hugi.scene.org/compo/compoold.htm#compo25
= 
http://board.flatassembler.net/topic.php?t=6076postdays=0postorder=ascstart=0
2). IOCCC '05 entry aidan.c (also can generate puzzles; supposedly
also tested with BC45 small model)
= http://www.ioccc.org/years.html#2005
3). Lots of solvers in various languages, e.g. Lua or XPL0
= see http://rosettacode.org/wiki/Sudoku

 Therefore I decided to give it a try and write a libre Sudoku game for
 DOS. And to push the challenge a bit more, I wanted it to work in real
 mode :)

Looks quite good. I'm impressed. But I already knew you were cool.   B-)

 Mission accomplished - here I present sudoku86, a Sudoku game for DOS,
 running on 8086+ (requires VGA for mode 13h).

Why VGA? Granted, I know Mike Chambers ported Wolf3D to (very slowly!)
run on 8086 too, but most 8086 users probably don't have VGA. Well,
they probably don't even have CGA, but at least CGA can do more than
you think:

(8088 Domination, sequel to 8088 Corruption)
http://www.osnews.com/story/27792/Full-motion_video_on_a_1981_IBM_PC

Just FYI in case you weren't aware yet.   ;-)  CGA ftw! :-P

 It was fun to do, I hope it will be of any use to the community.

http://sudoku86.sourceforge.net

My only complaint is lack of undo. Well, is there undo? Or hints? I
can't seem to figure out if the right mouse button does anything or
not. It's quite frustrating to accidentally make a mistake (two 4s in
the same block) and not be able to erase it.

--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] Sudoku on a 8086 (or anything newer)

2014-06-27 Thread dmccunney
On Fri, Jun 27, 2014 at 9:30 PM, Rugxulo rugx...@gmail.com wrote:

 Why VGA? Granted, I know Mike Chambers ported Wolf3D to (very slowly!)
 run on 8086 too, but most 8086 users probably don't have VGA. Well,
 they probably don't even have CGA, but at least CGA can do more than
 you think:

Oh, come now.  Just how many actual 8086 users do you suppose there
are these days?

Anyone likely to run this game under FreeDOS is almost certainly doing
so on at least an 80286, and more likely a 386 class processor, and
has at least VGA graphics.

The key to Mateus's effort is that it *can* run on an 8086 with VGA,
not that anyone *will*.

Even in embedded systems where FreeDOS might find a niche, things are
well beyond the 8086.  Current embedded systems are increasingly based
on 32 bit processors like the current ARM offerings, and the
limitations are in other areas.
__
Dennis
https://plus.google.com/u/0/105128793974319004519

--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user