Skip to content

Commit 61b9d63

Browse files
committed
Initial commit, based on original source. Original including precompiled files http://www.komkon.org/~dekogel/m2000.html
0 parents  commit 61b9d63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+27473
-0
lines changed

Asm.S

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*** M2000: Portable P2000 emulator *****************************************/
2+
/*** ***/
3+
/*** Asm.S ***/
4+
/*** ***/
5+
/*** This file contains MS-DOS specific assembler routines ***/
6+
/*** ***/
7+
/*** Copyright (C) Marcel de Kogel 1996,1997 ***/
8+
/*** You are not allowed to distribute this software commercially ***/
9+
/*** Please, notify me, if you make any changes to this file ***/
10+
/****************************************************************************/
11+
12+
.file "Asm.S"
13+
14+
.data
15+
.align 4
16+
DisplayStart: .long 0xA0000
17+
TimerCount: .long 0
18+
OldInt8: .long 0
19+
OldInt8Selector:.word 0
20+
.globl _DosSelector
21+
.globl _cs_alias
22+
23+
.text
24+
25+
.globl _nofunc
26+
_nofunc:
27+
ret
28+
29+
.globl ___enable
30+
___enable:
31+
sti
32+
ret
33+
34+
.globl ___disable
35+
___disable:
36+
cli
37+
ret
38+
39+
.globl _JoyGetPos
40+
_JoyGetPos:
41+
pushl %ebx
42+
pushl %ecx
43+
pushl %edx
44+
pushl %esi
45+
pushl %edi
46+
movw $0x201,%dx
47+
movl $10000,%ecx
48+
subl %esi,%esi
49+
subl %edi,%edi
50+
cli
51+
outb %al,%dx
52+
jmp _JoyGetPos_Loop
53+
_JoyGetPos_Loop:
54+
inb %dx,%al
55+
movl %eax,%ebx
56+
shrl $1,%ebx
57+
adcl $0,%esi
58+
shrl $1,%ebx
59+
adcl $0,%edi
60+
testb $3,%al
61+
loopnz _JoyGetPos_Loop
62+
sti
63+
movl %edi,%eax
64+
shll $16,%eax
65+
movw %si,%ax
66+
popl %edi
67+
popl %esi
68+
popl %edx
69+
popl %ecx
70+
popl %ebx
71+
ret
72+
73+
.globl _ReadTimer
74+
_ReadTimer:
75+
pushl %edi
76+
pushl %esi
77+
pushl %edx
78+
pushl %ecx
79+
pushl %ebx
80+
movl $50,%ecx
81+
ReadTimer_Loop:
82+
call _nofunc
83+
loop ReadTimer_Loop
84+
ReadTimer_Again:
85+
movl (TimerCount),%eax
86+
shll $16,%eax
87+
outb %al,$0x43
88+
jmp ReadTim1
89+
ReadTim1:
90+
jmp ReadTim2
91+
ReadTim2:
92+
inb $0x40,%al
93+
jmp ReadTim3
94+
ReadTim3:
95+
jmp ReadTim4
96+
ReadTim4:
97+
movb %al,%ah
98+
inb $0x40,%al
99+
xchgb %al,%ah
100+
notw %ax
101+
movl (TimerCount),%ebx
102+
shll $16,%ebx
103+
movw %ax,%bx
104+
cmpl %eax,%ebx
105+
jne ReadTimer_Again
106+
popl %ebx
107+
popl %ecx
108+
popl %edx
109+
popl %esi
110+
popl %edi
111+
ret
112+
113+
timer_interrupt:
114+
pushl %eax
115+
pushw %ds
116+
.byte 0x2e
117+
movw _cs_alias,%ax
118+
movw %ax,%ds
119+
incl (TimerCount)
120+
pushfl
121+
lcall (OldInt8)
122+
popw %ds
123+
popl %eax
124+
iret
125+
126+
install_timer_int:
127+
pushal
128+
movl $0x204,%eax
129+
movb $8,%bl
130+
int $0x31
131+
movl %edx,OldInt8
132+
movw %cx,OldInt8Selector
133+
movw %cs,%cx
134+
leal timer_interrupt,%edx
135+
movb $8,%bl
136+
movl $0x205,%eax
137+
int $0x31
138+
popal
139+
ret
140+
141+
restore_timer_int:
142+
pushal
143+
movl OldInt8,%edx
144+
movw OldInt8Selector,%cx
145+
movb $8,%bl
146+
movl $0x205,%eax
147+
int $0x31
148+
popal
149+
ret
150+
151+
.globl _StartTimer
152+
_StartTimer:
153+
pushl %eax
154+
cli
155+
movb $0x34,%al
156+
outb %al,$0x43
157+
jmp StartTim1
158+
StartTim1:
159+
jmp StartTim2
160+
StartTim2:
161+
subb %al,%al
162+
outb %al,$0x40
163+
jmp StartTim3
164+
StartTim3:
165+
jmp StartTim4
166+
StartTim4:
167+
outb %al,$0x40
168+
sti
169+
call install_timer_int
170+
popl %eax
171+
ret
172+
173+
.globl _RestoreTimer
174+
_RestoreTimer:
175+
pushl %eax
176+
cli
177+
movb $0x36,%al
178+
outb %al,$0x43
179+
jmp ResTim1
180+
ResTim1:
181+
jmp ResTim2
182+
ResTim2:
183+
subb %al,%al
184+
outb %al,$0x40
185+
jmp ResTim3
186+
ResTim3:
187+
jmp ResTim4
188+
ResTim4:
189+
outb %al,$0x40
190+
sti
191+
call restore_timer_int
192+
popl %eax
193+
ret
194+

Asm.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*** M2000: Portable P2000 emulator *****************************************/
2+
/*** ***/
3+
/*** Asm.h ***/
4+
/*** ***/
5+
/*** This file contains prototypes for MS-DOS specific assembler routines ***/
6+
/*** ***/
7+
/*** Copyright (C) Marcel de Kogel 1996,1997 ***/
8+
/*** You are not allowed to distribute this software commercially ***/
9+
/*** Please, notify me, if you make any changes to this file ***/
10+
/****************************************************************************/
11+
12+
unsigned JoyGetPos (void);
13+
void StartTimer (void);
14+
unsigned ReadTimer (void);
15+
void RestoreTimer (void);
16+
void nofunc (void);
17+
void __enable (void);
18+
void __disable (void);

BASIC.bin

16 KB
Binary file not shown.

Bitmap.c

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/****************************************************************************/
2+
/** **/
3+
/** Bitmap.c **/
4+
/** **/
5+
/** Routines to create screen shots in Windows bitmap format **/
6+
/** **/
7+
/** Copyright (C) Marcel de Kogel 1996 **/
8+
/** You are not allowed to distribute this software commercially **/
9+
/** Please, notify me, if you make any changes to this file **/
10+
/****************************************************************************/
11+
12+
#include <stdio.h>
13+
#include "Bitmap.h"
14+
15+
static void putint (char *p,int n)
16+
{
17+
p[0]=n&255;
18+
p[1]=(n>>8)&255;
19+
p[2]=(n>>16)&255;
20+
p[3]=(n>>24)&255;
21+
}
22+
23+
/****************************************************************************/
24+
/* Return values: */
25+
/* >=0 - Succes */
26+
/* -1 - File creation error */
27+
/* -2 - Write error */
28+
/****************************************************************************/
29+
int WriteBitmap (char *szFileName, int nBitsPerPixel, int nColoursUsed,
30+
int nWidthImageBuffer,
31+
int nWidthImage, int nHeightImage,
32+
char *pBitmapBits, char *pPalette)
33+
{
34+
int i,j,nPadBytes,nImageBytes,nBufBytes;
35+
FILE *f;
36+
static char bitmapheader[]=
37+
{
38+
/* BITMAPFILEHEADER */
39+
0x42,0x4D, /* 0 type='BM' */
40+
0x00,0x00,0x00,0x00, /* 2 size of file in bytes */
41+
0x00,0x00, /* 6 reserved */
42+
0x00,0x00, /* 8 reserved */
43+
0x00,0x00,0x00,0x00, /* 10 offset of bitmap data */
44+
/* BITMAPINFOHEADER */
45+
0x28,0x00,0x00,0x00, /* 14 size of this structure in bytes */
46+
0x00,0x00,0x00,0x00, /* 18 width of the image in pixels */
47+
0x00,0x00,0x00,0x00, /* 22 height of the image in pixels */
48+
0x01,0x00, /* 26 number of planes */
49+
0x00,0x00, /* 28 bits per pixel */
50+
0x00,0x00,0x00,0x00, /* 30 compression method */
51+
0x00,0x00,0x00,0x00, /* 34 size of the image in bytes */
52+
/* set to 0 if no compression is used */
53+
0xE8,0x05,0x00,0x00, /* 38 horizontal resolution in pixels per meter */
54+
0xE8,0x05,0x00,0x00, /* 42 vertical resolution in pixels per meter */
55+
0x00,0x00,0x00,0x00, /* 46 number of colours used in the colour table */
56+
0x00,0x00,0x00,0x00 /* 50 number of colours used in the image */
57+
};
58+
f=fopen (szFileName,"wb");
59+
if (!f) return -1;
60+
bitmapheader[28]=nBitsPerPixel;
61+
putint (bitmapheader+46,nColoursUsed);
62+
putint (bitmapheader+50,nColoursUsed);
63+
putint (bitmapheader+18,nWidthImage);
64+
putint (bitmapheader+22,nHeightImage);
65+
putint (bitmapheader+10,sizeof(bitmapheader)+nColoursUsed*4);
66+
nBufBytes=(nWidthImageBuffer*nBitsPerPixel+7)/8;
67+
i=nImageBytes=(nWidthImage*nBitsPerPixel+7)/8;
68+
nPadBytes=(4-(i&3))&3;
69+
i+=nPadBytes;
70+
putint (bitmapheader+2,(i*nHeightImage)+sizeof(bitmapheader)+nColoursUsed*4);
71+
if (fwrite(bitmapheader,sizeof(bitmapheader),1,f)!=1)
72+
{
73+
fclose (f);
74+
return -2;
75+
}
76+
for (i=0;i<nColoursUsed;++i)
77+
{
78+
if (fputc(pPalette[i*3+2],f)==EOF)
79+
{
80+
fclose (f);
81+
return -2;
82+
}
83+
if (fputc(pPalette[i*3+1],f)==EOF)
84+
{
85+
fclose (f);
86+
return -2;
87+
}
88+
if (fputc(pPalette[i*3+0],f)==EOF)
89+
{
90+
fclose (f);
91+
return -2;
92+
}
93+
if (fputc(0,f)==EOF)
94+
{
95+
fclose (f);
96+
return -2;
97+
}
98+
}
99+
for (i=nHeightImage-1;i>=0;--i)
100+
{
101+
if (fwrite(pBitmapBits+nBufBytes*i,nImageBytes,1,f)!=1)
102+
{
103+
fclose (f);
104+
return -2;
105+
}
106+
for (j=0;j<nPadBytes;++j)
107+
{
108+
if (fputc(0,f)==EOF)
109+
{
110+
fclose (f);
111+
return -2;
112+
}
113+
}
114+
}
115+
fclose (f);
116+
return 0;
117+
}

Bitmap.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/****************************************************************************/
2+
/** **/
3+
/** Bitmap.h **/
4+
/** **/
5+
/** Routines to create screen shots in Windows bitmap format **/
6+
/** **/
7+
/** Copyright (C) Marcel de Kogel 1996 **/
8+
/** You are not allowed to distribute this software commercially **/
9+
/** Please, notify me, if you make any changes to this file **/
10+
/****************************************************************************/
11+
12+
/****************************************************************************/
13+
/* Return values: */
14+
/* >=0 - Succes */
15+
/* -1 - File creation error */
16+
/* -2 - Write error */
17+
/****************************************************************************/
18+
int WriteBitmap (char *szFileName, int nBitsPerPixel, int nColoursUsed,
19+
int nWidthImageBuffer,
20+
int nWidthImage, int nHeightImage,
21+
char *pBitmapBits, char *pPalette);

0 commit comments

Comments
 (0)