News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Playing cards

Started by jj2007, September 27, 2016, 02:03:45 AM

Previous topic - Next topic

jj2007

Just found a nice DLL:

      .if !Exist(Cards$)
            void FileRead$("http://www.catonmat.net/ftp/cards.dll")      ; cards.dll - a fun dll that came with windows
            Rename "~FrLocal.tmp", Cards$
      .endif
      Dll Cards$            ; Using cards.dll API: BOOL WINAPI ...
      Declare void cdtInit, 2            ; cdtInit (int *width, int *height)
      Declare void cdtDraw, 6            ; cdtDraw (HDC hdc, int x, int y, int card, int type, DWORD color)
      ; Declare cdtAnimate, 5            ; cdtAnimate (HDC hdc, int cardback, int x, int y, int frame)
      Declare void cdtTerm, 0            ; cdtTerm (void)
      cdtInit(addr cardW, addr cardH)
  CASE WM_PAINT
      xchg rv(BeginPaint, hWnd, addr ps), esi
  if 0
      The card parameter controls which card is drawn. This parameter is dependent on the value of type. If a card face is to be drawn (type is 0 or 2),
      then card must be a value from 0 through 51 to represent each card. If type specifies that a card back is to be drawn (type is 1), then card must
      be a value from 53 to 68 (inclusive), to represent one of the 16 possible card backs.
     
      The card faces are organised in increasing order. That is, the aces come first, then the two's and so on. In each group, the cards are ordered by
      suit. The order is clubs, diamons, hearts, spades. This pattern is repeated as the card values increase.
  endif
      For_ colour=0 To 3            ; Enum 0:ecsCLUBS, ecsDIAMONDS, ecsHEARTS, ecsSPADES
            For_ card=0 To 12            ; Ace, 2, 3, ..., King
                  imul eax, card, 4
                  add eax, colour
                  imul ecx, card, 80            ; x=card*16
                  add ecx, 10
                  imul edx, colour, 100            ; set height by colour
                  cdtDraw(esi, ecx, edx, eax, 0, 0)      ; dc, x, y, card, type, col
            Next
      Next
      invoke EndPaint, hWnd, addr ps

rrr314159

Cool, and worth mentioning.
I am NaN ;)

anunitu

Is this the dll from Microsoft..I remember finding something like this in the old MS download section under dos.

jj2007

Follow the links above. It was part of Windows but disappeared after XP.

WillASM

Catch22 has a good tutorial on using Cards.dll, http://www.catch22.net/tuts/using-cardsdll-api.
Interesting how long Microsoft has kept this DLL active, guess a lot of people love playing heart's, solitaire...

jj2007