Author Topic: Playing cards  (Read 2636 times)

jj2007

  • Member
  • *****
  • Posts: 10112
  • Assembler is fun ;-)
    • MasmBasic
Playing cards
« on: September 27, 2016, 02:03:45 AM »
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

  • Member
  • *****
  • Posts: 1382
Re: Playing cards
« Reply #1 on: September 27, 2016, 05:42:55 AM »
Cool, and worth mentioning.
I am NaN ;)

anunitu

  • Member
  • *****
  • Posts: 1131
Re: Playing cards
« Reply #2 on: September 27, 2016, 08:05:07 AM »
Is this the dll from Microsoft..I remember finding something like this in the old MS download section under dos.

jj2007

  • Member
  • *****
  • Posts: 10112
  • Assembler is fun ;-)
    • MasmBasic
Re: Playing cards
« Reply #3 on: September 27, 2016, 08:19:34 AM »
Follow the links above. It was part of Windows but disappeared after XP.

WillASM

  • Regular Member
  • *
  • Posts: 10
Re: Playing cards
« Reply #4 on: September 27, 2016, 02:49:56 PM »
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

  • Member
  • *****
  • Posts: 10112
  • Assembler is fun ;-)
    • MasmBasic
Re: Playing cards
« Reply #5 on: September 27, 2016, 05:25:15 PM »
Catch22 has a good tutorial on using Cards.dll, http://www.catch22.net/tuts/using-cardsdll-api.

Linked above, behind Dll Cards$ ;)