Hi all
One of the first programs I wrote was a 16-bit resource editor, and most of the programs I have made after that has been based on using this tool. It is very simplistic and hard to handle in some cases, but it still works.
The programs I made are still used (mostly by old farts), but the main problem with them is the lack of DOS support in newer hardware, especially printers. I also have a small baby project online, which I have been nursing for some time, but now MS is blocking the use of such applications even in XP.
Most of these programs are written in C/C++, so the plan was to convert the resource compiler to 32-bit instead of rewriting all this code. My knowledge of assembly is from 16-bit TASM, so I’m a bit rusty with regards to 32-bit MASM.
The learning curve will be to grind through the console functions first, using kernel32.lib and a few functions from user32.lib (clipboard functions).
The first problem I run into was the color setup, and here is some of the code used for manipulating colors used in 16-bit code:
include clib.inc
include conio.inc
include mouse.inc
.code
setpal proc _CType public uses bx? palid:size_t, clid:size_t
test console,CON_COLOR
jz setpal_end
ifndef __f__
mov ax,palid
mov dx,clid
mov ch,al
mov bx,dx
mov ax,0040h
mov es,ax
mov dx,es:[0063h]
cmp dx,03D4h
jne setpal_end
cli
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,bl
out dx,al
mov al,ch
out dx,al
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,20h
out dx,al
sti
else
; missing 32-bit code
endif
setpal_end:
ret
setpal endp
resetpal proc _CType public
push si?
xor si?,si?
.repeat
invoke setpal,si?,si?
inc si?
.until si? == 8
mov si?,56
.repeat
mov ax?,si?
add ax?,-48
invoke setpal,si?,ax?
inc si?
.until si? == 64
invoke setpal,0014h,0006h
pop si?
ret
resetpal endp
getxya proc _CType public x:size_t, y:size_t
ifndef __f__
invoke getxyw,x,y
mov al,ah
mov ah,0
else
local lpCharacter:dword, lpNumberOfAttributesRead:dword
mov eax,y
shl eax,16
add eax,x
mov ecx,eax
invoke ReadConsoleOutputAttribute,
OFSH_OUTPUT,addr lpCharacter,1,ecx,addr lpNumberOfAttributesRead
mov eax,lpCharacter
and eax,00FFh
endif
ret
getxya endp
scputa proc _CType public uses ax? dx? x:size_t, y:size_t, l:size_t, a:size_t
ifndef __f__
mov al,byte ptr x
mov ah,byte ptr y
call __getxypm
invoke wcputa,dx::ax,l,a
ShowMouseCursor
else
local pcx:dword
push ecx
movzx ecx,byte ptr a
movzx eax,byte ptr x
movzx edx,byte ptr y
shl edx,16
mov dx,ax
invoke FillConsoleOutputAttribute,OFSH_OUTPUT,ecx,l,edx,addr pcx
pop ecx
endif
ret
scputa endp
end
The code assign value [0..255] to index [0..15]
So, to my first question: is there a simple way to rearrange the 256 palettes like this in 32-bit, or do I have to apply a table of some sort for that?
The library used for this code could be downloaded from this site: https://sourceforge.net/projects/doszip/files/
hello ,
any chance of the source code for this attachment ?
Like to see the 16bit