Vorstellung
Verfasst: Mi 21. Apr 2010, 11:56
Hallo, ich programmiere gerne kleine DOS-Anwendungen und helfe auch gerne anderen DOSianer dabei.
Dirk
Dirk
dosforum.de - Deutschlands Retroforum rund um Spiele und Software unter DOS
https://www.dosforum.de/
Ups, als Gast werde ich wohl nicht freigeschaltet. Hier nun meine Benutzername innerhalb der Rauten.Gast hat geschrieben:Hallo, ich programmiere gerne kleine DOS-Anwendungen und helfe auch gerne anderen DOSianer dabei.
Dirk
Ich programmiere am liebsten Assembler und benutze MASM 5, oder MASM 6 (mit link.exe von MASM 5) und für ganz kleine Sachen nehme ich auch debug.DOSferatu hat geschrieben:Cool, noch ein DOS-Programmierer!
In welcher Sprache (oder Sprachen) programmierst Du denn?
(Ich programmiere halt auch unter DOS, deshalb interessiert mich das.)
Ein Webseite mit Assemble-Demos für DOS hatte ich mal, das ist aber schon ein paar Jahre her.DOSferatu hat geschrieben:Yeah!, ein Coder! Was hast Du denn schon so alles gemacht? Gibt's ne Webseite?
Serielle Ports verwende ich schon lange nicht mehr. Mein neuestes Mainboard hat nicht mal mehr einen PS2-Mouseanschluss, deswegen habe ich mir ein PS2-to-USB-Adapter besorgt und im BIOS USB-legacy auf enable gestellt. So kann ich die PS2-Mouse auch weiterhin unter DOS wie eine Mouse die am PS2-Anschluss eingesteckt wurde abfragen.DOSferatu hat geschrieben:Ja, ich programmiere auch einiges lieber direkt und hardwarenah. Bei Maus hab ich noch nicht PS/2 benutzt - an meinem DOS-Rechner hängt eine Maus am seriellen Port (und serielle Maus hab ich auch schon "direkt" - also ohne Treiber - programmiert, aber das ist ja auch weiter kein Problem).
Ich mache es z.B. so:Und Tastatur frage ich mitunter auch lieber mit Portzugriffen ab - wenn man Tastatursteuerung für Spiele programmiert, muß man das ja sowieso...
Code: Alles auswählen
; Zum Anfang schalte ich den Tastastatur-IRQ ab:
cli ; Software-Interrupts ausschalten
mov al, 2 ; IRQ 1 sperren
out 21h, al
sti
; Hauptschleife:
P1:
in al, 64h ; Tastatur-Status holen
test al, 1
jz P1
test al, 20h
jnz P1 ; wenn PS2-Mouse weiter
in al, 60h ; Tasten-Code holen
cmp al, 1 ; Escape ?
jz XRAUS
;---------------------------------------------
; E x t r a - T a s t e n a b f r a g e n
;---------------------------------------------
mov si, OFFSET SONTAB ; Zeiger auf Extra-Tasten-Tabelle
mov cl, Extablen ; länge
XSUCH: cmp al, [si] ; Taste suchen
jz XFOUND ; gefunden ?
lea si, [si+1]
dec cl
jnz XSUCH
;---------------------------------------------
; T a s t e n a b f r a g e n
;---------------------------------------------
mov si, OFFSET TASTTAB ; Zeiger auf Tasten-Tabelle
mov cx, tablen ; länge
mov bx, OFFSET TEXTTAB ; Offset auf Text
SUCH: cmp al, [si] ; Taste suchen
jz short FOUND ; gefunden ?
lea si, [si+1]
dec cx
jnz SUCH
jmp P1
;---------------------------------------------
FOUND:
;---------------------------------------------
XFOUND:
;---------------------------------------------
XRAUS:
; Zum Ende schalte ich den Tastastatur-IRQ wieder an:
cli
xor al, al ; IRQ 1 freigeben
out 21h, al
sti
mov ah, 1 ; Tastatur-Puffer löschen
int 16h
;---------------------------------------------
; Datenbereich
;---------------------------------------------
TASTTAB DB 02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh
DB 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Eh,1Fh
DB 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Bh,2Ch,2Dh,2Eh,2Fh
DB 30h,31h,32h,33h,34h,35h,39h
DB 56h
tablen = ($-TASTTAB)
TEXTTAB DB "1234567890ß'"
DB "qwertzuiopü+as"
DB "dfghjklöä^#yxcv"
DB "bnm,.- "
DB "<"
Textablen = ($-TEXTTAB)
;---------------------------------------------------------------------------
; Tab,shift li.,shift re.,HOME,UP,LEFT,RIGHT,END,DOWN
;----------
SONTAB DB 0Fh,2Ah,36h,47h,48h,4Bh,4Dh,4Fh,50h
Extablen = ($-SONTAB)
DB 0,0,0
SHIFT DW 0
So geht es mir auch immer.Vielleicht interessiert Dich ja auch evtl. mein Zeug. Ein etwas größeres Projekt, das als Preview auf meiner Seite zu finden ist, ist mein Spiel "Xpyderz". Ist aber nicht in VESA, sondern in VGA programmiert (Mode X, 320x200).
Das Ding hatte ich vor vielen Jahren mal als kleines Nebenprojekt angefangen und später immer mehr verändert und Code ausgewechselt - aber trotzdem ist der Source (die Sourcen) dafür mittlerweile etwas Kraut- und Rüben... Man sieht es dem Teil zwar von außen nicht an, aber wenn ich die Sourcen jetzt so sehe und auch einiges, was ich da angestellt habe, würde ich das ganze Ding am liebsten noch mal von vorne coden...
Ich helfe gerne.Aber naja, genug von mir. Aber wenn Deine Webseite nicht erreichbar ist... Du hast doch sicher die Sachen nicht ausschließlich dort (im Internet) gelagert, sondern die von Dir entwickelten Sachen auch noch zu Hause. OK, will aber auch nicht nerven.
Code: Alles auswählen
--------M-15C200-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - ENABLE/DISABLE
AX = C200h
BH = new state
00h disabled
01h enabled
Return: CF set on error
AH = status (see #00522)
Note: IBM classifies this function as required
SeeAlso: AX=C201h,AX=C207h,AX=C208h
(Table 00522)
Values for pointing device function status:
00h successful
01h invalid function
02h invalid input
03h interface error
04h need to resend
05h no device handler installed
--------M-15C201-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - RESET
AX = C201h
Return: CF set on error
AH = status (see #00522)
CF clear if successful
BH = device ID
BL = value returned by attached device after reset
AAh if device is a mouse
Notes: after successful completion of this call, the pointing device is set
as follows: disabled, sample rate 100 Hz, resolution 4 counts/mm,
scaling 1:1, unchanged data package size
this function should be called before rebooting the system (see
INT 15/AH=4Fh), since otherwise the mouse may behave erratically on
some systems after the boot. Before calling this function, the
caller should check that the INT 15h vector is in fact initialized
(on some very old machines the IVT may contain 0000h:0000h).
IBM classifies this function as required
SeeAlso: INT 33/AX=0000h,AX=C200h,AX=C207h
--------M-15C202-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - SET SAMPLING RATE
AX = C202h
BH = sampling rate
00h 10/second
01h 20/second
02h 40/second
03h 60/second
04h 80/second
05h 100/second
06h 200/second
Return: CF set on error
AH = status (see #00522)
SeeAlso: INT 33/AX=001Ch
--------M-15C203-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - SET RESOLUTION
AX = C203h
BH = resolution (see #00523)
Return: CF set on error
AH = status (see #00522)
(Table 00523)
Values for pointing device resolution:
00h one count per mm
01h two counts per mm
02h four counts per mm
03h eight counts per mm
--------M-15C204-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - GET TYPE
AX = C204h
Return: CF set on error
AH = status (see #00522)
CF clear if successful
BH = device ID
--------M-15C205-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - INITIALIZE
AX = C205h
BH = data package size (1 - 8 bytes)
Return: CF set on error
AH = status (see #00522)
Note: the pointing device is set as follows: disabled, 100 Hz sample rate,
resolution 4 counts/mm, scaling 1:1
SeeAlso: AX=C201h
--------M-15C206-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - EXTENDED COMMANDS
AX = C206h
BH = subfunction
00h return device status
Return: BL = pointing device status (see #00524)
CL = resolution (see #00523)
DL = sample rate, reports per second
01h set scaling at 1:1
02h set scaling at 2:1
Return: CF set on error
AH = status (see #00522)
Bitfields for pointing device status:
Bit(s) Description (Table 00524)
0 right button pressed
1 reserved
2 left button pressed
3 reserved
4 0 if 1:1 scaling, 1 if 2:1 scaling
5 device enabled
6 0 if stream mode, 1 if remote mode
7 reserved
--------M-15C207-----------------------------
INT 15 - SYSTEM - POINTING DEVICE BIOS INTERFACE (PS) - SET DEVICE HANDLER ADDR
AX = C207h
ES:BX -> FAR user device handler or 0000h:0000h to cancel
Return: CF set on error
AH = status (see #00522)
Note: when the subroutine is called, it is passed the following values on
the stack; the handler should return with a FAR return without
popping the stack:
WORD 1: status (see #00525)
WORD 2: X data (high byte = 00h)
WORD 3: Y data (high byte = 00h)
WORD 4: 0000h
SeeAlso: INT 33/AX=000Ch
Bitfields for pointing device status:
Bit(s) Description (Table 00525)
15-8 reserved (0)
7 Y data overflowed
6 X data overflowed
5 Y data is negative
4 X data is negative
3 reserved (1)
2 reserved (0)
1 right button pressed
0 left button pressed
---------------------------------------------------
Code: Alles auswählen
START: mov eax, 1 ; request for feature flags
DB 0Fh, 0A2h ; CPUID instruction
test edx, 00800000h ; is MMX feature flag(bit 23) set ?
jz NOMMX ; NEIN, kein MMX
call CHECKPS2
jc NOMOUSE
call PS2ON
jc NOMOUSE
call MREPOS ; Mousebegrenzung setzen(Hauptseite)
cli
mov WORD PTR[XACK], MXpos ; X-Pos. Maus
mov WORD PTR[YACK], MYpos ; Y-Pos. Maus
sti
xor ecx, ecx
xor edx, edx
xor ebx, ebx
xor esi, esi
xor edi, edi
mov ebp, DWORD PTR[MAUEND]
call M1ST
; ---Hauptschleife---
call GETMPOS ; Mouse-Zeiger holen/setzen
;----------------------------------------------------------------------------
; Subroutinen
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;------------------------------------------------------
CHECKPS2: int 11h ; get equipment list
test al, 3
jz short NOPS2 ; jump if PS/2-Mouse not indicated
mov bh, 3 ; data package size (1 - 8 bytes)
mov ax, 0C205h
int 15h ; initialize mouse, bh=datasize
jc short NOPS2
mov bh, 3 ; 03h eight counts per mm
mov ax, 0C203h
int 15h ; set mouse resolution bh
jc short NOPS2
mov ax, cs
mov es, ax
mov bx, OFFSET PS2TEST
mov ax, 0C207h
int 15h ; mouse, es:bx=ptr to handler
jc short NOPS2
xor bx, bx
mov es, bx ; mouse, es:bx=ptr to handler
mov ax, 0C207h
int 15h
ret
NOPS2: stc
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;----------------------------------------------------------------------------
PS2ON: call PS2OFF
mov ax, cs
mov es, ax
mov bx, OFFSET PS2IRQ
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
jc short NOPS2
mov bh, 1 ; set mouse on
mov ax, 0C200h
int 15h
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;-------------------------------------
PS2OFF: xor bx, bx ; set mouse off
mov ax, 0C200h
int 15h
xor bx, bx
mov es, bx
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;----------------------------------------------------------------------------
PS2IRQ: push ds
pusha
mov ax, DATEN
mov ds, ax
mov bp, sp
mov bx, [bp+22+6] ; status byte(buttons,Sign,Overflow)
mov cx, [bp+22+4] ; X movement
mov dx, [bp+22+2] ; Y movement
mov ax, [XACK]
test bx, 10h ; Sign X Mouse goes right
jz short MOGOR
neg cl
sub ax, cx
cmp ax, [BHMIN] ; (Hmin) Mouse-Zeiger zu weit links ?
jb short IY0
; test bx, 40h ; Overflow X
; jz short IY0
IX1: jmp short IX2 ; X schreiben
;---------
MOGOR: add ax, cx
cmp ax, [BHMAX] ; (Hmax) Mouse-Zeiger zu weit rechts ?
ja short IY0
; test bx, 40h ; Overflow X
; jz short IY0
IX2: mov [XACK], ax
;---------------------------------
IY0: mov ax, [YACK]
test bx, 20h ; Sign Y Mouse goes down
jnz short MOGOU
sub ax, dx
cmp ax, [BVMIN] ; (Vmin) Mouse-Zeiger zu hoch ?
jb short IIZ
; test bx, 80h ; Overflow Y
; jz short IIZ
IY1: jmp short IY2 ; Y schreiben
;---------
MOGOU: neg dl
add ax, dx
cmp ax, [BVMAX] ; (Vmax) Mouse-Zeiger zu tief ?
ja short IIZ
; test bx, 80h ; Overflow Y
; jz short IIZ
IY2: mov [YACK], ax
;---------------------------------
IIZ: and bx, 3 ; only buttons, remove Sign + Overflow
mov [TACK], bx
;---------
popa
pop ds
PS2TEST: retf
;----------------------------------------------------------------------------
; Mousezeiger zum Bildschirm
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;----------------------------------------------------------------------------
GETMPOS: cli
xor ecx, ecx
xor edx, edx
mov cx, [XACK] ; cx = X-Positon holen
mov dx, [YACK] ; dx = Y-Position holen
mov bx, [TACK] ; bx = Mouse-Taste holen
lea ecx, [ecx*4]
lea edx, [edx*4]
mov [RETCLIC], bx
cmp ecx, DWORD PTR[MX]
jnz short MSOI
cmp edx, DWORD PTR[MY]
jz NOMOUT ; wenn dieselbe Pos., dann nicht setzen
MSOI: mov DWORD PTR[MY], edx
mov dx, Rast_Port
mov bl, 8
mov DWORD PTR[MX], ecx ; Mouse-Zeiger setzen
RAST: in al, dx ; Bewegung mit Raster-Strahl
and al, bl ; synchronisieren
jnz RAST
RASTER: in al, dx
and al, bl
jz RASTER
call RESTAU ; Mouse-Hintergrund restaurieren
M1ST: mov ebx, DWORD PTR[MY] ; erster Mouse-Ansprung
mov ebx, [ebx] ; Zeilen-Offset holen
mov esi, DWORD PTR[MAUHI1] ; Zeiger auf Rett-Sprite-Tabelle
add ebx, DWORD PTR[MX] ; plus X
mov DWORD PTR[RETTPOS], ebx ; neue Bild-Position retten
OBJECT2: mov edi, [esi] ; Offset aus Tabelle holen
mov eax, [edi+ebx] ; Farbe vom Bildschirm holen
mov ecx, [esi+8]
DB 67h, 0Fh, 6Eh, 1Ch, 19h ; movd mm3, [ecx+ebx]
mov [esi+4], eax ; Farbe in Tabelle retten
DB 67h, 0Fh, 7Eh, 5Eh, 0Ch ; movd [esi+0Ch], mm3
lea esi, [esi+10h]
cmp esi, ebp ; Ende erreicht ?
jb OBJECT2
mov esi, DWORD PTR[MAUKA1] ; Zeiger auf Sprite-Tabelle
mov ebp, DWORD PTR[MAUHI1] ; Tabellen-Ende
OBJECT3: mov edi, [esi] ; Adresse aus Tabelle holen
mov eax, [esi+4] ; Farbe aus Tabelle holen
mov ecx, [esi+8]
DB 67h, 0Fh, 6Eh, 5Eh, 0Ch ; movd mm3, [esi+0Ch]
lea esi, [esi+10h]
mov [edi+ebx], eax ; Farbe zum Bildschirm
DB 67h, 0Fh, 7Eh, 1Ch, 19h ; movd [ecx+ebx], mm3
cmp esi, ebp ; Ende erreicht ?
jb OBJECT3
mov bx, [RETCLIC]
mov ecx, DWORD PTR[MX]
mov edx, DWORD PTR[MY]
NOMOUT: sti
ret
;----------------------------------------------------------------------------
; Mouse-Hintergrund restaurieren
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;--------------------------------------------
RESTAU: mov esi, DWORD PTR[MAUHI1] ; Zeiger auf Rett-Sprite-Tabelle
mov ebx, DWORD PTR[RETTPOS] ; alte Bild-Position holen
mov ebp, DWORD PTR[MAUEND] ; Tabellen-Ende
RESTAU2: mov edi, [esi] ; Offset aus Tabelle holen
mov eax, [esi+4] ; Farbe aus Tabelle holen
mov ecx, [esi+8]
DB 67h, 0Fh, 6Eh, 5Eh, 0Ch ; movd mm3, [esi+0Ch]
lea esi, [esi+10h]
mov [edi+ebx], eax ; Tabellen-Farbe zum Bild-Bereich
DB 67h, 0Fh, 7Eh, 1Ch, 19h ; movd [ecx+ebx], mm3
cmp esi, ebp ; Ende erreicht ?
jb RESTAU2
ret
;--------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;--------------------------------------------
MREPOS: cli
mov WORD PTR[BHMAX], Hmax
mov WORD PTR[BHMIN], Hmin
mov WORD PTR[BVMAX], Vmax
mov WORD PTR[BVMIN], Vmin
sti
ret
; Den Datenbereich und die dafür verwenden Speicherstellen die dazu gehören lasse ich hier mal weg.